@jingyi0605/codingns 0.8.0 → 0.8.5
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/bin/codingns.mjs +180 -0
- package/dist/public/assets/{AdaptiveButlerPage-BsgVNRAa.js → AdaptiveButlerPage-CJw8Ae62.js} +3 -3
- package/dist/public/assets/App-BOHBGFOd.js +30 -0
- package/dist/public/assets/{BootstrapPage--MDOigQi.js → BootstrapPage-BxHQT4nA.js} +1 -1
- package/dist/public/assets/{ConversationPage-BBss5ED8.js → ConversationPage-DWFsF6BB.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-CB8DoqwU.js → DesktopDetachPreviewPage-DOgEjYEf.js} +1 -1
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +1 -0
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +2 -0
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +1 -0
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +1 -0
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-DGVOzXyg.js → MobileTopHeaderFrame-lcp2GscV.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +1 -0
- package/dist/public/assets/PluginAccessOverview-DGcKAMQl.js +1 -0
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +1 -0
- package/dist/public/assets/PluginDetailPage-CAJ7LFpD.js +1 -0
- package/dist/public/assets/PluginsListPage-BxZG1NyT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-0MPPjxtQ.js → RelayConnectEntryPage-CfNO_TIl.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-by36Z_5k.js +1 -0
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +1 -0
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-NVZRxxmH.js +1 -0
- package/dist/public/assets/{TerminalPage-B6Rdhylx.js → TerminalPage-C4LNoPBp.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +1 -0
- package/dist/public/assets/ToolFilesPage-47zbdgTW.js +1 -0
- package/dist/public/assets/ToolGitPage-Fuk_b_jg.js +1 -0
- package/dist/public/assets/ToolProcessesPage-sWSMWD-9.js +1 -0
- package/dist/public/assets/ToolsHomePage-R1mZlbZi.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CqmiFH2u.js +1 -0
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +244 -0
- package/dist/public/assets/WorkbenchModal-C7qoQElW.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BPsrFffw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-KAtqZOAb.js +1 -0
- package/dist/public/assets/{client-runtime-manager-DGdKvYzx.js → client-runtime-manager-wmCJZKYd.js} +1 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +590 -0
- package/dist/public/assets/{index-CcaQt50x.css → index-C4t-vvqk.css} +1 -1
- package/dist/public/assets/index-CL97fwWB.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-DEP_xCmR.js → login-direct-candidate-resolver-BOAgTuUf.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-Cq99cnzV.js +1 -0
- package/dist/public/assets/plugins-api-BQTV5DOp.js +1 -0
- package/dist/public/assets/{preferences-service-CV6Ih0BG.js → preferences-service-DJxbEEeg.js} +1 -1
- package/dist/public/assets/realtime-client-CLafKzzJ.js +1 -0
- package/dist/public/assets/{relay-entry-C751A-Sm.js → relay-entry-D-LfvdiX.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-CRAVR-8G.js → terminal-runtime-meta-BJmy8dyK.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DQAWVdCo.js +1 -0
- package/dist/public/assets/workbench-navigation-MEzCSmsK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/main.js +2 -0
- package/dist/server/main.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-runtime-controller.d.ts +2 -1
- package/dist/server/modules/browser-runtime/browser-runtime-controller.js +1 -0
- package/dist/server/modules/browser-runtime/browser-runtime-controller.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-runtime-service.d.ts +4 -1
- package/dist/server/modules/browser-runtime/browser-runtime-service.js +40 -0
- package/dist/server/modules/browser-runtime/browser-runtime-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-task-payload.d.ts +2 -0
- package/dist/server/modules/browser-runtime/browser-task-payload.js.map +1 -1
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +153 -1
- package/dist/server/modules/file/file-controller.js +215 -1
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +2 -0
- package/dist/server/modules/file/file-preview-link-service.js +5 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +911 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +126 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +471 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/git/git-command-helper-process.js +0 -18
- package/dist/server/modules/git/git-command-helper-process.js.map +1 -1
- package/dist/server/modules/git/git-command-runner.js +0 -18
- package/dist/server/modules/git/git-command-runner.js.map +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +38 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +178 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.js +46 -3
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +1 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +11 -2
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skills/codingns-workspace-session/SKILL.md +2 -2
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +2 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/routes/files.js +40 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/server/create-server.d.ts +20 -0
- package/dist/server/server/create-server.js +47 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +63 -25
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.d.ts +1 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.js +28 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +250 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +140 -0
- package/dist/server/types/domain.d.ts +122 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +42 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +346 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js +80 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/index.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js +19 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js +659 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js +72 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +67 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +752 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +48 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +1184 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +84 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +2436 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +47 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +1480 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +33 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +684 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js +8 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +48 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +373 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +61 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +1191 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +27 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +415 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.d.ts +7 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js +22 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +24 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +329 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +30 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +939 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +70 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +2571 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.d.ts +21 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +561 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.d.ts +38 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js +911 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +38 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +970 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +21 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +168 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +152 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/services.d.ts +28 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js +148 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +6 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +9 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +198 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/package.json +33 -0
- package/package.json +15 -6
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/LICENSE +69 -0
- package/vendor/node-pty-fork/README.md +92 -0
- package/vendor/node-pty-fork/binding.gyp +117 -0
- package/vendor/node-pty-fork/deps/.editorconfig +2 -0
- package/vendor/node-pty-fork/deps/winpty/.drone.yml +17 -0
- package/vendor/node-pty-fork/deps/winpty/.gitattributes +19 -0
- package/vendor/node-pty-fork/deps/winpty/LICENSE +21 -0
- package/vendor/node-pty-fork/deps/winpty/Makefile +166 -0
- package/vendor/node-pty-fork/deps/winpty/README.md +151 -0
- package/vendor/node-pty-fork/deps/winpty/RELEASES.md +280 -0
- package/vendor/node-pty-fork/deps/winpty/VERSION.txt +1 -0
- package/vendor/node-pty-fork/deps/winpty/configure +167 -0
- package/vendor/node-pty-fork/deps/winpty/misc/BufferResizeTests.cc +90 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ClearConsole.cc +72 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.cc +117 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.ps1 +116 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConoutMode.cc +113 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DebugClient.py +42 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DebugServer.py +63 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DumpLines.py +5 -0
- package/vendor/node-pty-fork/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FontSurvey.cc +100 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FormatChar.h +21 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FreezePerfTest.cc +62 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetCh.cc +20 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetConsolePos.cc +41 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetFont.cc +261 -0
- package/vendor/node-pty-fork/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
- package/vendor/node-pty-fork/deps/winpty/misc/IsNewConsole.cc +87 -0
- package/vendor/node-pty-fork/deps/winpty/misc/MouseInputNotes.txt +90 -0
- package/vendor/node-pty-fork/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Notes.txt +219 -0
- package/vendor/node-pty-fork/deps/winpty/misc/OSVersion.cc +27 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest.cc +671 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SelectAllTest.cc +45 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetBufferSize.cc +32 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetCursorPos.cc +10 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetFont.cc +145 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetWindowRect.cc +36 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ShowArgv.cc +12 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ShowConsoleInput.cc +40 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Spew.py +5 -0
- package/vendor/node-pty-fork/deps/winpty/misc/TestUtil.cc +172 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnixEcho.cc +89 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Utf16Echo.cc +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/VeryLargeRead.cc +122 -0
- package/vendor/node-pty-fork/deps/winpty/misc/VkEscapeTest.cc +56 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest1.cc +57 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest2.cc +30 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo1.cc +26 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo2.cc +19 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test1.cc +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test2.cc +70 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test3.cc +78 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Write1.cc +44 -0
- package/vendor/node-pty-fork/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
- package/vendor/node-pty-fork/deps/winpty/misc/WriteConsole.cc +106 -0
- package/vendor/node-pty-fork/deps/winpty/misc/build32.sh +9 -0
- package/vendor/node-pty-fork/deps/winpty/misc/build64.sh +9 -0
- package/vendor/node-pty-fork/deps/winpty/misc/color-test.sh +212 -0
- package/vendor/node-pty-fork/deps/winpty/misc/font-notes.txt +300 -0
- package/vendor/node-pty-fork/deps/winpty/misc/winbug-15048.cc +201 -0
- package/vendor/node-pty-fork/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
- package/vendor/node-pty-fork/deps/winpty/ship/common_ship.py +53 -0
- package/vendor/node-pty-fork/deps/winpty/ship/make_msvc_package.py +165 -0
- package/vendor/node-pty-fork/deps/winpty/ship/ship.py +108 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.cc +605 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.h +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.cc +632 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.cc +852 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.h +109 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.cc +152 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.h +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Coord.h +87 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.cc +239 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.h +32 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DsrSender.h +30 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.cc +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.h +47 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.cc +246 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.h +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.cc +378 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.h +125 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.cc +699 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.h +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/SimplePool.h +75 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/SmallRect.h +143 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.cc +535 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.h +69 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.cc +107 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.h +67 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/main.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/subdir.mk +61 -0
- package/vendor/node-pty-fork/deps/winpty/src/configurations.gypi +60 -0
- package/vendor/node-pty-fork/deps/winpty/src/debugserver/DebugServer.cc +117 -0
- package/vendor/node-pty-fork/deps/winpty/src/debugserver/subdir.mk +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/include/winpty.h +242 -0
- package/vendor/node-pty-fork/deps/winpty/src/include/winpty_constants.h +131 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/subdir.mk +46 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/winpty.cc +970 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/AgentMsg.h +38 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.cc +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.h +102 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.cc +187 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.h +38 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.cc +138 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.h +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GetCommitHash.bat +13 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Mutex.h +54 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OsModule.h +63 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.cc +36 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.h +45 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilder.h +227 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.cc +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.h +80 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/TimeMeasurement.h +63 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.h +104 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.cc +252 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.h +29 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.cc +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.h +64 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.cc +57 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.h +43 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.cc +42 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.h +27 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/winpty_snprintf.h +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/subdir.mk +5 -0
- package/vendor/node-pty-fork/deps/winpty/src/tests/subdir.mk +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/tests/trivial_test.cc +158 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.cc +86 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.h +31 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/main.cc +729 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/subdir.mk +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/winpty.gyp +206 -0
- package/vendor/node-pty-fork/deps/winpty/vcbuild.bat +83 -0
- package/vendor/node-pty-fork/lib/conpty_console_list_agent.js +20 -0
- package/vendor/node-pty-fork/lib/conpty_console_list_agent.js.map +1 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.js +47 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.js.map +1 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.test.js +30 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/index.js +51 -0
- package/vendor/node-pty-fork/lib/index.js.map +1 -0
- package/vendor/node-pty-fork/lib/interfaces.js +7 -0
- package/vendor/node-pty-fork/lib/interfaces.js.map +1 -0
- package/vendor/node-pty-fork/lib/shared/conout.js +11 -0
- package/vendor/node-pty-fork/lib/shared/conout.js.map +1 -0
- package/vendor/node-pty-fork/lib/terminal.js +190 -0
- package/vendor/node-pty-fork/lib/terminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/terminal.test.js +139 -0
- package/vendor/node-pty-fork/lib/terminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/testUtils.test.js +28 -0
- package/vendor/node-pty-fork/lib/testUtils.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/types.js +7 -0
- package/vendor/node-pty-fork/lib/types.js.map +1 -0
- package/vendor/node-pty-fork/lib/unixTerminal.js +304 -0
- package/vendor/node-pty-fork/lib/unixTerminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/unixTerminal.test.js +330 -0
- package/vendor/node-pty-fork/lib/unixTerminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/utils.js +17 -0
- package/vendor/node-pty-fork/lib/utils.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsConoutConnection.js +122 -0
- package/vendor/node-pty-fork/lib/windowsConoutConnection.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.js +324 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js +90 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.js +201 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.test.js +203 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js +22 -0
- package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js.map +1 -0
- package/vendor/node-pty-fork/package.json +35 -0
- package/vendor/node-pty-fork/scripts/apply-patches.mjs +341 -0
- package/vendor/node-pty-fork/scripts/fetch-upstream.mjs +41 -0
- package/vendor/node-pty-fork/scripts/install-smoke.cjs +59 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/smoke-load.cjs +10 -0
- package/vendor/node-pty-fork/scripts/sync-upstream.mjs +29 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +62 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +52 -0
- package/vendor/node-pty-fork/scripts/verify-tarball.cjs +80 -0
- package/vendor/node-pty-fork/src/conpty_console_list_agent.ts +19 -0
- package/vendor/node-pty-fork/src/eventEmitter2.test.ts +30 -0
- package/vendor/node-pty-fork/src/eventEmitter2.ts +48 -0
- package/vendor/node-pty-fork/src/index.ts +51 -0
- package/vendor/node-pty-fork/src/interfaces.ts +129 -0
- package/vendor/node-pty-fork/src/native.d.ts +56 -0
- package/vendor/node-pty-fork/src/shared/conout.ts +15 -0
- package/vendor/node-pty-fork/src/terminal.test.ts +119 -0
- package/vendor/node-pty-fork/src/terminal.ts +211 -0
- package/vendor/node-pty-fork/src/testUtils.test.ts +23 -0
- package/vendor/node-pty-fork/src/tsconfig.json +22 -0
- package/vendor/node-pty-fork/src/types.ts +15 -0
- package/vendor/node-pty-fork/src/unix/pty.cc +826 -0
- package/vendor/node-pty-fork/src/unix/spawn-helper.cc +23 -0
- package/vendor/node-pty-fork/src/unixTerminal.test.ts +335 -0
- package/vendor/node-pty-fork/src/unixTerminal.ts +320 -0
- package/vendor/node-pty-fork/src/utils.ts +9 -0
- package/vendor/node-pty-fork/src/win/conpty.cc +500 -0
- package/vendor/node-pty-fork/src/win/conpty_console_list.cc +43 -0
- package/vendor/node-pty-fork/src/win/path_util.cc +73 -0
- package/vendor/node-pty-fork/src/win/path_util.h +22 -0
- package/vendor/node-pty-fork/src/win/winpty.cc +322 -0
- package/vendor/node-pty-fork/src/windowsConoutConnection.ts +79 -0
- package/vendor/node-pty-fork/src/windowsPtyAgent.test.ts +94 -0
- package/vendor/node-pty-fork/src/windowsPtyAgent.ts +323 -0
- package/vendor/node-pty-fork/src/windowsTerminal.test.ts +214 -0
- package/vendor/node-pty-fork/src/windowsTerminal.ts +208 -0
- package/vendor/node-pty-fork/src/worker/conoutSocketWorker.ts +22 -0
- package/vendor/node-pty-fork/typings/node-pty.d.ts +203 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/App-tPcbyRdS.js +0 -30
- package/dist/public/assets/DesktopWindowPage-GtIx5m8K.js +0 -2
- package/dist/public/assets/FileContextPanel-BcM7AIT4.js +0 -1
- package/dist/public/assets/GitSidebar-CMtkaxuI.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CrFY41_8.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DLkACTnQ.js +0 -1
- package/dist/public/assets/ServerSettingsModal-vgOhwus4.js +0 -1
- package/dist/public/assets/SessionIndexPage-KK626Ra9.js +0 -1
- package/dist/public/assets/SettingsPage-B3edBJIo.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-BxlhZp8c.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-BVLfrpSa.js +0 -1
- package/dist/public/assets/ToolFilesPage-N_gwwUjD.js +0 -1
- package/dist/public/assets/ToolGitPage-DOcuuWM1.js +0 -1
- package/dist/public/assets/ToolProcessesPage-D-FfJ7Re.js +0 -1
- package/dist/public/assets/ToolsHomePage-CHfPxd20.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CTTnfovY.js +0 -1
- package/dist/public/assets/WorkbenchLayout-CbpJg0g1.js +0 -244
- package/dist/public/assets/WorkbenchModal-Bt_1fYmM.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DyaMnPfS.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-s7yuDIxR.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-Cf-gVpqK.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-COf6I8sT.js +0 -1
- package/dist/public/assets/file-tree-icon-BeHqeru9.js +0 -590
- package/dist/public/assets/index-CuzMc7q2.js +0 -42
- package/dist/public/assets/model-switch-api-c6kcbBGm.js +0 -1
- package/dist/public/assets/realtime-client-CRCx5xBt.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-D6YtNS0r.js +0 -1
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
import{C as an,t as f,b as x,j as s,J as Yn,H as Gn,D as Zn,A as Wt}from"./index-CuzMc7q2.js";import{D as Jn}from"./WorkbenchModal-Bt_1fYmM.js";import{f as sn,e as ln}from"./App-tPcbyRdS.js";import{bI as Et,bJ as Qn,bK as er,bL as tr}from"./WorkbenchLayout-CbpJg0g1.js";async function nr(e){return await an.request("/api/presentation-exports",{method:"POST",body:JSON.stringify(e)})}async function rr(e){return await an.request(`/api/presentation-exports/${encodeURIComponent(e)}`)}const Ve={width:1600,height:900},cn=[{strategy:"deck-section-slide",selector:"body .deck > section.slide"},{strategy:"deck-direct-slide",selector:"body .deck > .slide"},{strategy:"section-slide",selector:"section.slide"},{strategy:"slide-data-title",selector:".slide[data-title]"},{strategy:"slide-data-slide",selector:".slide[data-slide]"},{strategy:"deck-direct-child",selector:"body > .deck > *"}],or=[".panel",".slide-shell",".content",".hero-main",".slide-inner"],Dt=new Set(["H1","H2","H3","H4","P","LI","SPAN","BUTTON","A"]),dn=[".slide-progress",".progress-bar",".ctrl-btn",".toc",".particle",".particles",".bg-glow",".bg-grid",".page","script"].join(", "),ir=["card","panel","metric","kpi","module","feature","timeline","diagram","table","grid","shell","content"],ar={position:"position",fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",fontStyle:"font-style",lineHeight:"line-height",letterSpacing:"letter-spacing",color:"color",textAlign:"text-align",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",whiteSpace:"white-space",padding:"padding",margin:"margin",borderRadius:"border-radius",borderWidth:"border-width",borderColor:"border-color",backgroundColor:"background-color",opacity:"opacity"};function Ht(e,t){if(!/\.(html?|HTML?)$/.test(t))return jt("unsupported-extension");const n=Bt(e);if(!(n!=null&&n.documentElement)||!n.querySelector("html"))return jt("invalid-html");const r=ct(n);if(!r)return jt("missing-page-structure");const o=[],i=r.elements.map((a,c)=>{a.querySelector("svg")&&o.push(`第 ${c+1} 页包含 SVG,只能先按只读节点导入。`),a.querySelector(dn)&&o.push(`第 ${c+1} 页包含展示壳或装饰层,导入时会过滤非内容节点。`);const h=mn(a,c);return{index:c,title:Sr(a,c),selector:h,sourceRef:{pageIndex:c,pageSelector:h,nodePath:[]}}});return{supported:!0,reason:null,mode:"presentation",strategy:r.strategy,pages:i,warnings:Pn(o),viewport:Ir(n)}}function sr(e){const t=Ht(e.html,e.filePath);if(!t.supported)return null;const n=Bt(e.html),r=ct(n,t.strategy??void 0);if(!r)return null;const o=t.warnings.map((h,p)=>({code:`probe-warning-${p+1}`,message:h})),i={},a=[],c=r.elements.map((h,p)=>{var y,M,C;const g=`page-${p+1}`,S=`${g}-root`,j=Er(h),b=mn(h,p),P=Cr(h,j);if(i[S]=xn({id:S,name:((y=t.pages[p])==null?void 0:y.title)??`第 ${p+1} 页`,sourceRef:{pageIndex:p,pageSelector:b,nodePath:P},runtimeFlags:j.hasAttribute("data-cns-layout-freeze")?["layout-freeze-container"]:[]}),zt({pageElement:h,containerElement:j,pageIndex:p,pageSelector:b,containerPath:P,parentNodeId:S,nodeIdPrefix:S,nodes:i,assets:a}),!i[S].children.length){const A=((M=h.textContent)==null?void 0:M.replace(/\s+/g," ").trim())??"";if(A){const R=`${S}-fallback-text`;i[R]=vn({id:R,name:"正文",text:A,sourceRef:{pageIndex:p,pageSelector:b,nodePath:P}}),i[S].children.push(R)}}return{id:g,order:p,title:((C=t.pages[p])==null?void 0:C.title)??`第 ${p+1} 页`,frame:{width:t.viewport.width,height:t.viewport.height,background:null},rootNodeId:S,sourceRef:{pageIndex:p,pageSelector:b,nodePath:[]},runtimeHints:{hasActiveStateClass:h.classList.contains("active"),hasDeckShell:!!h.closest(".deck")}}});return{id:Ur(e.filePath),schemaVersion:1,mode:"presentation",source:{kind:e.sourceKind??"codingns",path:e.filePath,version:e.version??null,entryHtmlHash:_t(e.html)},canvas:{width:t.viewport.width,height:t.viewport.height,unit:"px",aspectRatioLocked:!0},pages:c,nodes:i,assets:Or(a),warnings:o,meta:{originalTitle:n.title||null,pageDetectionStrategy:r.strategy}}}function lr(e){return un({html:e.html,project:e.project,pageIndex:e.pageIndex,selectedNodeId:e.selectedNodeId??null,selectedRunIndex:e.selectedRunIndex??null,inlineEditingNodeId:e.inlineEditingNodeId??null,baseHref:e.baseHref??null,mode:"preview"})}function cr(e){return un({html:e.html,project:e.project,pageIndex:0,selectedNodeId:null,mode:"save"})}function un(e){const t=Bt(e.html),n=ct(t,e.project.meta.pageDetectionStrategy);if(!n)return null;br({document:t,project:e.project,pageElements:n.elements});const r=ct(t,e.project.meta.pageDetectionStrategy);if(!r)return null;if(e.mode==="preview"&&(fr(t,e.project),dr(t,e.baseHref??null)),r.elements.forEach((o,i)=>{e.mode==="preview"&&(o.setAttribute("data-cns-page-root","true"),i===e.pageIndex?o.setAttribute("data-cns-active-page","true"):o.removeAttribute("data-cns-active-page"),o.classList.remove("prev","next"),o.classList.add("active"))}),Object.values(e.project.nodes).forEach(o=>{if($e(o,"draft-clone")||!o.sourceRef)return;const i=En(r.elements,o.sourceRef);i&&(e.mode==="preview"?(i.setAttribute("data-cns-node-id",o.id),i.removeAttribute("data-cns-node-selected"),i.removeAttribute("data-cns-inline-editing"),e.selectedNodeId&&o.id===e.selectedNodeId&&i.setAttribute("data-cns-node-selected","true"),e.inlineEditingNodeId&&o.id===e.inlineEditingNodeId&&i.setAttribute("data-cns-inline-editing","true")):(i.removeAttribute("data-cns-node-id"),i.removeAttribute("data-cns-node-selected"),i.removeAttribute("data-cns-inline-editing")),Cn(i,o),e.mode==="preview"&&Yr(i,o,{selected:e.selectedNodeId===o.id,selectedRunIndex:e.selectedNodeId===o.id?e.selectedRunIndex??null:null}))}),Object.values(e.project.nodes).forEach(o=>{$e(o,"draft-clone-root")&&ro({project:e.project,pageElements:r.elements,cloneRootNode:o,selectedNodeId:e.mode==="preview"?e.selectedNodeId:null,mode:e.mode})}),e.mode==="preview"){ur(t);const o=t.createElement("style");o.textContent=`
|
|
2
|
-
[data-cns-page-root="true"]:not([data-cns-active-page="true"]) {
|
|
3
|
-
display: none !important;
|
|
4
|
-
opacity: 0 !important;
|
|
5
|
-
pointer-events: none !important;
|
|
6
|
-
visibility: hidden !important;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] {
|
|
10
|
-
opacity: 1 !important;
|
|
11
|
-
pointer-events: auto !important;
|
|
12
|
-
visibility: visible !important;
|
|
13
|
-
transform: none !important;
|
|
14
|
-
transition: none !important;
|
|
15
|
-
width: ${e.project.canvas.width}px !important;
|
|
16
|
-
min-width: ${e.project.canvas.width}px !important;
|
|
17
|
-
max-width: ${e.project.canvas.width}px !important;
|
|
18
|
-
height: ${e.project.canvas.height}px !important;
|
|
19
|
-
min-height: ${e.project.canvas.height}px !important;
|
|
20
|
-
max-height: ${e.project.canvas.height}px !important;
|
|
21
|
-
margin: 0 !important;
|
|
22
|
-
box-sizing: border-box !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
[data-cns-node-selected="true"] {
|
|
26
|
-
outline: 2px solid #007aff !important;
|
|
27
|
-
outline-offset: 2px !important;
|
|
28
|
-
box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14) !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
[data-cns-node-host="true"] {
|
|
32
|
-
outline: none !important;
|
|
33
|
-
box-shadow: none !important;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
[data-cns-inline-editing="true"] {
|
|
37
|
-
color: transparent !important;
|
|
38
|
-
text-shadow: none !important;
|
|
39
|
-
caret-color: transparent !important;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.deck {
|
|
43
|
-
width: ${e.project.canvas.width}px !important;
|
|
44
|
-
min-width: ${e.project.canvas.width}px !important;
|
|
45
|
-
max-width: ${e.project.canvas.width}px !important;
|
|
46
|
-
margin: 0 !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
html,
|
|
50
|
-
body {
|
|
51
|
-
width: ${e.project.canvas.width}px !important;
|
|
52
|
-
min-width: ${e.project.canvas.width}px !important;
|
|
53
|
-
max-width: ${e.project.canvas.width}px !important;
|
|
54
|
-
height: ${e.project.canvas.height}px !important;
|
|
55
|
-
min-height: ${e.project.canvas.height}px !important;
|
|
56
|
-
max-height: ${e.project.canvas.height}px !important;
|
|
57
|
-
margin: 0 !important;
|
|
58
|
-
padding: 0 !important;
|
|
59
|
-
overflow: hidden !important;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
body {
|
|
63
|
-
transform-origin: center center !important;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
body[data-cns-preview-body-scale-reset="true"] {
|
|
67
|
-
transform: none !important;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] .fade-up,
|
|
71
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] .roadmap-line,
|
|
72
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] [class*="fade-"],
|
|
73
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] [class*="reveal-"] {
|
|
74
|
-
opacity: 1 !important;
|
|
75
|
-
transform: none !important;
|
|
76
|
-
transition: none !important;
|
|
77
|
-
transition-delay: 0s !important;
|
|
78
|
-
animation-delay: 0s !important;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
[data-cns-page-root="true"][data-cns-active-page="true"] .typing-cursor {
|
|
82
|
-
opacity: 1 !important;
|
|
83
|
-
animation: none !important;
|
|
84
|
-
}
|
|
85
|
-
`,t.head.appendChild(o);const i=t.createElement("script");i.setAttribute("data-cns-preview-bridge","true"),i.textContent=`
|
|
86
|
-
(() => {
|
|
87
|
-
const eventTypes = ["pointerdown", "click", "dblclick"];
|
|
88
|
-
let layoutModeEnabled = false;
|
|
89
|
-
let activeLayoutPointer = null;
|
|
90
|
-
let layoutHoveredNodeId = null;
|
|
91
|
-
const parsePixelValue = (value) => {
|
|
92
|
-
if (!value) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const matched = /-?\\d+(?:\\.\\d+)?/.exec(value);
|
|
97
|
-
return matched ? Number(matched[0]) : 0;
|
|
98
|
-
};
|
|
99
|
-
const isTransparentColor = (value) => {
|
|
100
|
-
if (!value) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const normalized = value.trim().toLowerCase();
|
|
105
|
-
|
|
106
|
-
if (normalized === "transparent") {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (/rgba\\((?:\\d+\\s*,\\s*){3}0(?:\\.0+)?\\)/.test(normalized)) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return false;
|
|
115
|
-
};
|
|
116
|
-
const resolveTextNodes = (element) => {
|
|
117
|
-
if (!element) {
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, {
|
|
122
|
-
acceptNode(node) {
|
|
123
|
-
return node.textContent && node.textContent.trim()
|
|
124
|
-
? NodeFilter.FILTER_ACCEPT
|
|
125
|
-
: NodeFilter.FILTER_REJECT;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
const textNodes = [];
|
|
129
|
-
let current = walker.nextNode();
|
|
130
|
-
|
|
131
|
-
while (current) {
|
|
132
|
-
textNodes.push(current);
|
|
133
|
-
current = walker.nextNode();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return textNodes;
|
|
137
|
-
};
|
|
138
|
-
const resolveEditableRect = (element, computedStyle) => {
|
|
139
|
-
if (!element || !element.getBoundingClientRect) {
|
|
140
|
-
return {
|
|
141
|
-
rect: null,
|
|
142
|
-
useContentRect: false
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const elementRect = element.getBoundingClientRect();
|
|
147
|
-
|
|
148
|
-
if (!computedStyle) {
|
|
149
|
-
return {
|
|
150
|
-
rect: elementRect,
|
|
151
|
-
useContentRect: false
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const paddingLeft = parsePixelValue(computedStyle.paddingLeft);
|
|
156
|
-
const paddingTop = parsePixelValue(computedStyle.paddingTop);
|
|
157
|
-
const paddingRight = parsePixelValue(computedStyle.paddingRight);
|
|
158
|
-
const paddingBottom = parsePixelValue(computedStyle.paddingBottom);
|
|
159
|
-
const borderLeftWidth = parsePixelValue(computedStyle.borderLeftWidth);
|
|
160
|
-
const borderTopWidth = parsePixelValue(computedStyle.borderTopWidth);
|
|
161
|
-
const borderRightWidth = parsePixelValue(computedStyle.borderRightWidth);
|
|
162
|
-
const borderBottomWidth = parsePixelValue(computedStyle.borderBottomWidth);
|
|
163
|
-
const hasSurface = !isTransparentColor(computedStyle.backgroundColor)
|
|
164
|
-
|| borderLeftWidth > 0
|
|
165
|
-
|| borderTopWidth > 0
|
|
166
|
-
|| borderRightWidth > 0
|
|
167
|
-
|| borderBottomWidth > 0
|
|
168
|
-
|| paddingLeft > 0
|
|
169
|
-
|| paddingTop > 0
|
|
170
|
-
|| paddingRight > 0
|
|
171
|
-
|| paddingBottom > 0;
|
|
172
|
-
|
|
173
|
-
if (!hasSurface) {
|
|
174
|
-
return {
|
|
175
|
-
rect: elementRect,
|
|
176
|
-
useContentRect: false
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const textNodes = resolveTextNodes(element);
|
|
181
|
-
|
|
182
|
-
if (textNodes.length > 0) {
|
|
183
|
-
const range = document.createRange();
|
|
184
|
-
range.setStart(textNodes[0], 0);
|
|
185
|
-
range.setEnd(textNodes[textNodes.length - 1], textNodes[textNodes.length - 1].textContent.length);
|
|
186
|
-
const textRect = range.getBoundingClientRect();
|
|
187
|
-
|
|
188
|
-
if (textRect && textRect.width > 0 && textRect.height > 0) {
|
|
189
|
-
return {
|
|
190
|
-
rect: textRect,
|
|
191
|
-
useContentRect: true
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const innerWidth = Math.max(1, elementRect.width - paddingLeft - paddingRight - borderLeftWidth - borderRightWidth);
|
|
197
|
-
const innerHeight = Math.max(1, elementRect.height - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth);
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
rect: {
|
|
201
|
-
left: elementRect.left + paddingLeft + borderLeftWidth,
|
|
202
|
-
top: elementRect.top + paddingTop + borderTopWidth,
|
|
203
|
-
width: innerWidth,
|
|
204
|
-
height: innerHeight
|
|
205
|
-
},
|
|
206
|
-
useContentRect: true
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
const resolveElement = (target) => {
|
|
210
|
-
if (!target || typeof target !== "object") {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (target.nodeType === Node.TEXT_NODE) {
|
|
215
|
-
return target.parentElement;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (target.nodeType === Node.ELEMENT_NODE) {
|
|
219
|
-
return target;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return null;
|
|
223
|
-
};
|
|
224
|
-
const resolveLayoutMeasurementElement = (nodeId) => {
|
|
225
|
-
const hostElement = document.querySelector('[data-cns-node-host-id="' + CSS.escape(nodeId) + '"]');
|
|
226
|
-
|
|
227
|
-
if (hostElement instanceof HTMLElement) {
|
|
228
|
-
return hostElement;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const element = document.querySelector('[data-cns-node-id="' + CSS.escape(nodeId) + '"]');
|
|
232
|
-
|
|
233
|
-
if (!(element instanceof HTMLElement)) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (element.parentElement?.getAttribute("data-cns-node-host") === "true") {
|
|
238
|
-
return element.parentElement;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const hostParent = element.closest('[data-cns-node-host="true"]');
|
|
242
|
-
return hostParent instanceof HTMLElement ? hostParent : element;
|
|
243
|
-
};
|
|
244
|
-
const resolveLayoutParentElement = (element) => {
|
|
245
|
-
if (!(element instanceof HTMLElement)) {
|
|
246
|
-
return document.body instanceof HTMLElement ? document.body : null;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const positionedParent = element.offsetParent;
|
|
250
|
-
|
|
251
|
-
if (positionedParent instanceof HTMLElement) {
|
|
252
|
-
return positionedParent;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return document.body instanceof HTMLElement ? document.body : null;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
const handler = (event) => {
|
|
259
|
-
const element = resolveElement(event.target);
|
|
260
|
-
|
|
261
|
-
if (!element) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const matched = element.closest("[data-cns-node-id]");
|
|
266
|
-
|
|
267
|
-
if (!matched) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const nodeId = matched.getAttribute("data-cns-node-id");
|
|
272
|
-
const runIndexValue = matched.getAttribute("data-cns-run-index");
|
|
273
|
-
const runIndex = runIndexValue !== null ? Number.parseInt(runIndexValue, 10) : null;
|
|
274
|
-
|
|
275
|
-
if (!nodeId) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const computedStyle = window.getComputedStyle ? window.getComputedStyle(matched) : null;
|
|
280
|
-
const editableRect = resolveEditableRect(matched, computedStyle);
|
|
281
|
-
const payload = {
|
|
282
|
-
type: "codingns-static-html-node-select",
|
|
283
|
-
nodeId,
|
|
284
|
-
runIndex: Number.isInteger(runIndex) ? runIndex : null,
|
|
285
|
-
eventType: event.type,
|
|
286
|
-
metaKey: Boolean(event.metaKey),
|
|
287
|
-
ctrlKey: Boolean(event.ctrlKey),
|
|
288
|
-
rect: editableRect.rect
|
|
289
|
-
? {
|
|
290
|
-
left: editableRect.rect.left,
|
|
291
|
-
top: editableRect.rect.top,
|
|
292
|
-
width: editableRect.rect.width,
|
|
293
|
-
height: editableRect.rect.height
|
|
294
|
-
}
|
|
295
|
-
: matched.getBoundingClientRect
|
|
296
|
-
? {
|
|
297
|
-
left: matched.getBoundingClientRect().left,
|
|
298
|
-
top: matched.getBoundingClientRect().top,
|
|
299
|
-
width: matched.getBoundingClientRect().width,
|
|
300
|
-
height: matched.getBoundingClientRect().height
|
|
301
|
-
}
|
|
302
|
-
: null,
|
|
303
|
-
appearance: computedStyle
|
|
304
|
-
? {
|
|
305
|
-
fontFamily: computedStyle.fontFamily || null,
|
|
306
|
-
fontSize: computedStyle.fontSize || null,
|
|
307
|
-
fontWeight: computedStyle.fontWeight || null,
|
|
308
|
-
fontStyle: computedStyle.fontStyle || null,
|
|
309
|
-
lineHeight: computedStyle.lineHeight || null,
|
|
310
|
-
letterSpacing: computedStyle.letterSpacing || null,
|
|
311
|
-
color: computedStyle.color || null,
|
|
312
|
-
textAlign: computedStyle.textAlign || null,
|
|
313
|
-
whiteSpace: computedStyle.whiteSpace || null,
|
|
314
|
-
padding: editableRect.useContentRect ? "0px" : (computedStyle.padding || null),
|
|
315
|
-
textTransform: computedStyle.textTransform || null
|
|
316
|
-
}
|
|
317
|
-
: null
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
window.parent?.postMessage(payload, "*");
|
|
321
|
-
|
|
322
|
-
if (layoutModeEnabled && event.type === "pointerdown") {
|
|
323
|
-
if (typeof matched.setPointerCapture === "function" && typeof event.pointerId === "number") {
|
|
324
|
-
try {
|
|
325
|
-
matched.setPointerCapture(event.pointerId);
|
|
326
|
-
} catch {
|
|
327
|
-
// ignore setPointerCapture failures
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
activeLayoutPointer = {
|
|
332
|
-
pointerId: typeof event.pointerId === "number" ? event.pointerId : null,
|
|
333
|
-
nodeId
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
window.parent?.postMessage({
|
|
337
|
-
type: "codingns-static-html-layout-pointer",
|
|
338
|
-
phase: "start",
|
|
339
|
-
nodeId,
|
|
340
|
-
clientX: event.clientX,
|
|
341
|
-
clientY: event.clientY,
|
|
342
|
-
metaKey: Boolean(event.metaKey),
|
|
343
|
-
ctrlKey: Boolean(event.ctrlKey)
|
|
344
|
-
}, "*");
|
|
345
|
-
|
|
346
|
-
event.preventDefault();
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const handlePointerOver = (event) => {
|
|
351
|
-
if (!layoutModeEnabled) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const element = resolveElement(event.target);
|
|
356
|
-
const matched = element?.closest ? element.closest("[data-cns-node-id]") : null;
|
|
357
|
-
const nodeId = matched?.getAttribute("data-cns-node-id")?.trim() || null;
|
|
358
|
-
|
|
359
|
-
if (nodeId === layoutHoveredNodeId) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
layoutHoveredNodeId = nodeId;
|
|
364
|
-
window.parent?.postMessage({
|
|
365
|
-
type: "codingns-static-html-layout-hover",
|
|
366
|
-
nodeId: nodeId || ""
|
|
367
|
-
}, "*");
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
const handlePointerLeaveViewport = () => {
|
|
371
|
-
if (!layoutModeEnabled || !layoutHoveredNodeId) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
layoutHoveredNodeId = null;
|
|
376
|
-
window.parent?.postMessage({
|
|
377
|
-
type: "codingns-static-html-layout-hover",
|
|
378
|
-
nodeId: ""
|
|
379
|
-
}, "*");
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const syncSelectionState = (payload) => {
|
|
383
|
-
layoutModeEnabled = Boolean(payload?.layoutModeEnabled);
|
|
384
|
-
layoutHoveredNodeId = typeof payload?.layoutHoveredNodeId === "string" && payload.layoutHoveredNodeId.trim()
|
|
385
|
-
? payload.layoutHoveredNodeId.trim()
|
|
386
|
-
: null;
|
|
387
|
-
if (!layoutModeEnabled) {
|
|
388
|
-
activeLayoutPointer = null;
|
|
389
|
-
layoutHoveredNodeId = null;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
const selectedNodeId = typeof payload?.selectedNodeId === "string" && payload.selectedNodeId.trim()
|
|
393
|
-
? payload.selectedNodeId.trim()
|
|
394
|
-
: null;
|
|
395
|
-
const selectedRunIndex = typeof payload?.selectedRunIndex === "number" && Number.isInteger(payload.selectedRunIndex)
|
|
396
|
-
? payload.selectedRunIndex
|
|
397
|
-
: null;
|
|
398
|
-
const inlineEditingNodeId = typeof payload?.inlineEditingNodeId === "string" && payload.inlineEditingNodeId.trim()
|
|
399
|
-
? payload.inlineEditingNodeId.trim()
|
|
400
|
-
: null;
|
|
401
|
-
const layoutSelectedNodeIds = Array.isArray(payload?.layoutSelectedNodeIds)
|
|
402
|
-
? payload.layoutSelectedNodeIds.filter((value) => typeof value === "string" && value.trim()).map((value) => value.trim())
|
|
403
|
-
: [];
|
|
404
|
-
|
|
405
|
-
document.querySelectorAll("[data-cns-node-selected]").forEach((element) => {
|
|
406
|
-
if (element.getAttribute("data-cns-node-id") !== selectedNodeId) {
|
|
407
|
-
element.removeAttribute("data-cns-node-selected");
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
document.querySelectorAll("[data-cns-inline-editing]").forEach((element) => {
|
|
412
|
-
if (element.getAttribute("data-cns-node-id") !== inlineEditingNodeId) {
|
|
413
|
-
element.removeAttribute("data-cns-inline-editing");
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
if (selectedNodeId) {
|
|
418
|
-
if (selectedRunIndex !== null) {
|
|
419
|
-
const selectedRunElement = document.querySelector(
|
|
420
|
-
'[data-cns-node-id="' + CSS.escape(selectedNodeId) + '"][data-cns-run-index="' + String(selectedRunIndex) + '"]'
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
if (selectedRunElement) {
|
|
424
|
-
selectedRunElement.setAttribute("data-cns-node-selected", "true");
|
|
425
|
-
}
|
|
426
|
-
} else {
|
|
427
|
-
const selectedElement = document.querySelector('[data-cns-node-id="' + CSS.escape(selectedNodeId) + '"]');
|
|
428
|
-
|
|
429
|
-
if (selectedElement) {
|
|
430
|
-
selectedElement.setAttribute("data-cns-node-selected", "true");
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
document.querySelectorAll("[data-cns-layout-selected]").forEach((element) => {
|
|
436
|
-
if (!layoutSelectedNodeIds.includes(element.getAttribute("data-cns-node-id") || "")) {
|
|
437
|
-
element.removeAttribute("data-cns-layout-selected");
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
document.querySelectorAll("[data-cns-layout-hovered]").forEach((element) => {
|
|
442
|
-
if (element.getAttribute("data-cns-node-id") !== layoutHoveredNodeId) {
|
|
443
|
-
element.removeAttribute("data-cns-layout-hovered");
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
layoutSelectedNodeIds.forEach((nodeId) => {
|
|
448
|
-
const layoutElement = resolveLayoutMeasurementElement(nodeId);
|
|
449
|
-
|
|
450
|
-
if (layoutElement) {
|
|
451
|
-
layoutElement.setAttribute("data-cns-layout-selected", "true");
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
if (layoutHoveredNodeId) {
|
|
456
|
-
const hoveredElement = resolveLayoutMeasurementElement(layoutHoveredNodeId);
|
|
457
|
-
|
|
458
|
-
if (hoveredElement) {
|
|
459
|
-
hoveredElement.setAttribute("data-cns-layout-hovered", "true");
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if (inlineEditingNodeId) {
|
|
464
|
-
const editingElement = document.querySelector('[data-cns-node-id="' + CSS.escape(inlineEditingNodeId) + '"]');
|
|
465
|
-
|
|
466
|
-
if (editingElement) {
|
|
467
|
-
editingElement.setAttribute("data-cns-inline-editing", "true");
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
const postLayoutMeasurements = (payload) => {
|
|
473
|
-
const nodeIds = Array.isArray(payload?.nodeIds)
|
|
474
|
-
? payload.nodeIds.filter((value) => typeof value === "string" && value.trim()).map((value) => value.trim())
|
|
475
|
-
: [];
|
|
476
|
-
|
|
477
|
-
const measurements = nodeIds
|
|
478
|
-
.map((nodeId) => {
|
|
479
|
-
const element = resolveLayoutMeasurementElement(nodeId);
|
|
480
|
-
|
|
481
|
-
if (!(element instanceof HTMLElement)) {
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const rect = element.getBoundingClientRect();
|
|
486
|
-
const parentElement = resolveLayoutParentElement(element);
|
|
487
|
-
const parentRect = parentElement?.getBoundingClientRect?.() ?? null;
|
|
488
|
-
const viewportRect = document.documentElement?.getBoundingClientRect?.() ?? null;
|
|
489
|
-
const localLeft = element.offsetLeft;
|
|
490
|
-
const localTop = element.offsetTop;
|
|
491
|
-
const absoluteLeft = viewportRect ? rect.left - viewportRect.left : rect.left;
|
|
492
|
-
const absoluteTop = viewportRect ? rect.top - viewportRect.top : rect.top;
|
|
493
|
-
const parentLeft = parentRect ? rect.left - parentRect.left : localLeft;
|
|
494
|
-
const parentTop = parentRect ? rect.top - parentRect.top : localTop;
|
|
495
|
-
|
|
496
|
-
return {
|
|
497
|
-
nodeId,
|
|
498
|
-
left: absoluteLeft,
|
|
499
|
-
top: absoluteTop,
|
|
500
|
-
width: rect.width,
|
|
501
|
-
height: rect.height,
|
|
502
|
-
localLeft: Number.isFinite(localLeft) ? localLeft : parentLeft,
|
|
503
|
-
localTop: Number.isFinite(localTop) ? localTop : parentTop
|
|
504
|
-
};
|
|
505
|
-
})
|
|
506
|
-
.filter(Boolean);
|
|
507
|
-
|
|
508
|
-
window.parent?.postMessage({
|
|
509
|
-
type: "codingns-static-html-layout-measurements",
|
|
510
|
-
measurements
|
|
511
|
-
}, "*");
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
eventTypes.forEach((eventType) => {
|
|
515
|
-
document.addEventListener(eventType, handler, true);
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
document.addEventListener("pointerover", handlePointerOver, true);
|
|
519
|
-
document.addEventListener("pointerleave", handlePointerLeaveViewport, true);
|
|
520
|
-
|
|
521
|
-
document.addEventListener("pointermove", (event) => {
|
|
522
|
-
if (!layoutModeEnabled || !activeLayoutPointer) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
if (typeof activeLayoutPointer.pointerId === "number" && event.pointerId !== activeLayoutPointer.pointerId) {
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
window.parent?.postMessage({
|
|
531
|
-
type: "codingns-static-html-layout-pointer",
|
|
532
|
-
phase: "move",
|
|
533
|
-
nodeId: activeLayoutPointer.nodeId,
|
|
534
|
-
clientX: event.clientX,
|
|
535
|
-
clientY: event.clientY
|
|
536
|
-
}, "*");
|
|
537
|
-
}, true);
|
|
538
|
-
|
|
539
|
-
const finishLayoutPointer = (event, phase) => {
|
|
540
|
-
if (!activeLayoutPointer) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
if (typeof activeLayoutPointer.pointerId === "number" && event.pointerId !== activeLayoutPointer.pointerId) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
window.parent?.postMessage({
|
|
549
|
-
type: "codingns-static-html-layout-pointer",
|
|
550
|
-
phase,
|
|
551
|
-
nodeId: activeLayoutPointer.nodeId,
|
|
552
|
-
clientX: event.clientX,
|
|
553
|
-
clientY: event.clientY
|
|
554
|
-
}, "*");
|
|
555
|
-
|
|
556
|
-
activeLayoutPointer = null;
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
document.addEventListener("pointerup", (event) => {
|
|
560
|
-
finishLayoutPointer(event, "end");
|
|
561
|
-
}, true);
|
|
562
|
-
|
|
563
|
-
document.addEventListener("pointercancel", (event) => {
|
|
564
|
-
finishLayoutPointer(event, "cancel");
|
|
565
|
-
}, true);
|
|
566
|
-
|
|
567
|
-
window.addEventListener("message", (event) => {
|
|
568
|
-
const payload = event.data;
|
|
569
|
-
|
|
570
|
-
if (!payload || typeof payload !== "object") {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
if (payload.type !== "codingns-static-html-selection-sync") {
|
|
575
|
-
if (payload.type === "codingns-static-html-layout-measure-request") {
|
|
576
|
-
postLayoutMeasurements(payload);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
syncSelectionState(payload);
|
|
583
|
-
});
|
|
584
|
-
})();
|
|
585
|
-
`,t.body.appendChild(i)}else ao(t);return t.documentElement.outerHTML}function dr(e,t){const n=(t==null?void 0:t.trim())??"";if(!n)return;const r=e.head??e.querySelector("head");if(!(r instanceof HTMLHeadElement))return;const o=r.querySelector("base");if(o){o.setAttribute("href",n);return}const i=e.createElement("base");i.setAttribute("href",n),r.insertBefore(i,r.firstChild)}function ur(e){e.querySelectorAll("script").forEach(t=>{t.remove()})}function fr(e,t){var i;const n=e.body;if(!n||!n.getAttribute)return;n.style.width=`${t.canvas.width}px`,n.style.minWidth=`${t.canvas.width}px`,n.style.maxWidth=`${t.canvas.width}px`,n.style.height=`${t.canvas.height}px`,n.style.minHeight=`${t.canvas.height}px`,n.style.maxHeight=`${t.canvas.height}px`;const r=((i=n.style.transform)==null?void 0:i.trim())??"",o=Array.from(e.querySelectorAll("style")).some(a=>{const c=a.textContent??"";return/body\s*\{[\s\S]*?transform\s*:\s*scale\(/i.test(c)});/scale\(/i.test(r)&&!/translate\(/i.test(r)&&(n.style.transform="none"),o?n.setAttribute("data-cns-preview-body-scale-reset","true"):n.removeAttribute("data-cns-preview-body-scale-reset")}function Ct(e,t,n){const r=e.nodes[t];return r?{...e,nodes:{...e.nodes,[t]:n(r)}}:e}function hr(e,t,n){if(t.length===0)return e;const r={...e.nodes};let o=!1;return t.forEach(i=>{const a=r[i];a&&(r[i]=n(a,i),o=!0)}),o?{...e,nodes:r}:e}function pr(e,t){if(!e.nodes[t])return{project:e,duplicatedNodeId:null};const r=vr(e,t);if(!r)return{project:e,duplicatedNodeId:null};const o={...e.nodes},i=no(e.nodes),a=Rn({project:e,sourceNodeId:t,nextNodes:o,idCounter:i,isRoot:!0}),c=o[r];if(!c)return{project:e,duplicatedNodeId:null};const h=c.children.indexOf(t),p=[...c.children];return p.splice(h>=0?h+1:p.length,0,a),o[r]={...c,children:p},{project:{...e,nodes:o},duplicatedNodeId:a}}function mr(e,t){const n=t!=null&&t.insertAfterPageId?e.pages.findIndex(g=>g.id===t.insertAfterPageId):-1,r=n>=0?n+1:e.pages.length,o=yn(e),i=`${o}-root`,a=e.pages[Math.max(0,r-1)]??e.pages[e.pages.length-1]??null,c=xn({id:i,name:f("conversation.fileViewerPresentationUntitled"),sourceRef:null}),h={id:o,order:r,title:f("conversation.fileViewerPresentationUntitled"),frame:(a==null?void 0:a.frame)??{width:e.canvas.width,height:e.canvas.height,background:null},rootNodeId:i,sourceRef:{pageIndex:r,pageSelector:`[data-cns-page-id="${o}"]`,nodePath:[]},runtimeHints:(a==null?void 0:a.runtimeHints)??{hasActiveStateClass:!1,hasDeckShell:!0}},p=[...e.pages];return p.splice(r,0,h),{pageId:o,project:ut({...e,pages:p,nodes:{...e.nodes,[i]:c}})}}function gr(e,t){const n=e.pages.find(g=>g.id===t);if(!n)return{project:e,pageId:null};const r=e.pages.findIndex(g=>g.id===t),o=r>=0?r+1:e.pages.length,i=yn(e),a=`${i}-root`,c={...e.nodes},h=n.sourceRef.pageIndex;jn({project:e,sourceNodeId:n.rootNodeId,targetNodeId:a,nextPageId:i,sourcePageIndex:h,nextNodes:c});const p=[...e.pages];return p.splice(o,0,{...n,id:i,order:o,title:n.title,rootNodeId:a,sourceRef:{...n.sourceRef}}),{pageId:i,project:ut({...e,pages:p,nodes:c})}}function xr(e,t){var h,p;if(e.pages.length<=1)return{project:e,nextPageId:((h=e.pages[0])==null?void 0:h.id)??null};const n=e.pages.find(g=>g.id===t);if(!n)return{project:e,nextPageId:((p=e.pages[0])==null?void 0:p.id)??null};const r=e.pages.findIndex(g=>g.id===t),o=e.pages.filter(g=>g.id!==t),i={...e.nodes};hn(i,n.rootNodeId);const a=ut({...e,pages:o,nodes:i}),c=a.pages[Math.min(r,a.pages.length-1)]??null;return{project:a,nextPageId:(c==null?void 0:c.id)??null}}function yr(e,t,n){const r=e.pages.findIndex(c=>c.id===t);if(r<0)return{project:e,pageId:null};const o=Math.max(0,Math.min(n,e.pages.length-1));if(r===o)return{project:e,pageId:t};const i=[...e.pages],[a]=i.splice(r,1);return a?(i.splice(o,0,a),{project:ut({...e,pages:i}),pageId:t}):{project:e,pageId:null}}function Rt(e,t){const n=e.pages.find(o=>o.id===t);if(!n)return[];const r=[];return fn(e,n.rootNodeId,r,!0),r}function fn(e,t,n,r=!1){const o=e.nodes[t];o&&(r||n.push(t),o.children.forEach(i=>{fn(e,i,n)}))}function vr(e,t){var n;return((n=Object.values(e.nodes).find(r=>r.children.includes(t)))==null?void 0:n.id)??null}function br(e){var h;const{document:t,project:n}=e,r=[...e.pageElements],o=(h=r[0])==null?void 0:h.parentElement;if(!o)return;const i=r[r.length-1]??t.body.firstElementChild,a=new Set;n.pages.map((p,g)=>{const S=jr(t,r,p);if(S&&!a.has(S))return a.add(S),Zt(S,p,!1,g),S;const j=Mr(t,S??i,p,g,!!S);return j?(Zt(j,p,!0,g),j):null}).filter(p=>p instanceof Element).forEach(p=>{o.appendChild(p)}),r.forEach(p=>{a.has(p)||p.remove()})}function hn(e,t){const n=e[t];n&&(n.children.forEach(r=>{hn(e,r)}),delete e[t])}function ut(e){return wr(e)}function wr(e){const t={...e.nodes};return{...e,pages:e.pages.map((n,r)=>{var o;return pn(t,n.rootNodeId,r),{...n,order:r,title:(o=n.title)!=null&&o.trim()?n.title:f("conversation.fileViewerPresentationUntitled"),sourceRef:{...n.sourceRef,pageIndex:r}}}),nodes:t}}function pn(e,t,n){const r=e[t];r&&(r.sourceRef&&(e[t]={...r,sourceRef:{...r.sourceRef,pageIndex:n}}),r.children.forEach(o=>{pn(e,o,n)}))}function Bt(e){return new DOMParser().parseFromString(e,"text/html")}function ct(e,t){if(t){const n=Nr(t),r=Array.from(e.querySelectorAll(n));if(r.length>0)return{strategy:t,elements:r}}return cn.map(n=>({strategy:n.strategy,elements:Array.from(e.querySelectorAll(n.selector))})).find(n=>n.elements.length>0)??null}function jt(e){return{supported:!1,reason:e,mode:"presentation",strategy:null,pages:[],warnings:[],viewport:{width:Ve.width,height:Ve.height}}}function Nr(e){var t;return((t=cn.find(n=>n.strategy===e))==null?void 0:t.selector)??"section.slide"}function Sr(e,t){var i,a;const n=(i=e.getAttribute("data-title"))==null?void 0:i.trim();if(n)return n;const r=e.querySelector("h1, h2, h3, .slide-title, .title, .page-title"),o=(a=r==null?void 0:r.textContent)==null?void 0:a.replace(/\s+/g," ").trim();return o||`第 ${t+1} 页`}function mn(e,t){const n=e.getAttribute("data-title");return n?`.slide[data-title="${Yt(n)}"]`:e.id?`#${Yt(e.id)}`:`.slide:nth-of-type(${t+1})`}function Yt(e){return e.replace(/"/g,'\\"')}function Ir(e,t){const n=Array.from(e.querySelectorAll("style")).map(a=>a.textContent??"").join(`
|
|
586
|
-
`),r=Gt(n,"--deck-width"),o=Gt(n,"--deck-height");if(r&&o)return{width:r,height:o};const i=kr(n);return i||{width:Ve.width,height:Ve.height}}function kr(e){const t=Pr(e,".slide"),n=Ke(e,".slide","width"),r=Ke(e,".slide","height"),o=Ke(e,".slide","max-height");if(n&&r)return{width:n,height:r};if(n&&t)return{width:n,height:Math.round(n/t)};if(o&&t)return{width:Math.round(o*t),height:o};const i=Ke(e,".deck","width"),a=Ke(e,".deck","height");return i&&a?{width:i,height:a}:null}function Gt(e,t){const n=new RegExp(`(?:^|[\\s;{])${Ge(t)}\\s*:\\s*(\\d{3,5})px`,"i").exec(e);return n?Number(n[1]):null}function Ke(e,t,n){const r=gn(e,t);if(!r)return null;const o=new RegExp(`(?:^|[\\s;])${Ge(n)}\\s*:\\s*(\\d{3,5})px`,"i").exec(r);if(o)return Number(o[1]);const i=new RegExp(`(?:^|[\\s;])${Ge(n)}\\s*:\\s*min\\(\\s*(\\d{3,5})px\\s*,`,"i").exec(r);if(i)return Number(i[1]);const a=new RegExp(`(?:^|[\\s;])${Ge(n)}\\s*:\\s*calc\\(\\s*100v[wh]\\s*-\\s*(\\d{1,4})px\\s*\\)`,"i").exec(r);return a?n.includes("height")?Ve.height-Number(a[1]):Ve.width-Number(a[1]):null}function Pr(e,t){const n=gn(e,t);if(!n)return null;const r=/aspect-ratio\s*:\s*(\d+(?:\.\d+)?)\s*\/\s*(\d+(?:\.\d+)?)/i.exec(n);if(!r)return null;const o=Number(r[1]),i=Number(r[2]);return!o||!i?null:o/i}function gn(e,t){const n=new RegExp(`${Ge(t)}\\s*\\{([\\s\\S]*?)\\}`,"i").exec(e);return(n==null?void 0:n[1])??null}function Ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Er(e){const t=ht(e);if(t.length===1){const r=t[0];if(r&&!$r(r))return r}for(const r of or){const o=e.querySelector(r);if(o)return o.parentElement===e&&t.length>1?e:o}const n=e.querySelector(".head + .content");return n||e}function Cr(e,t){if(e===t)return[];const n=[];let r=t;for(;r&&r!==e;){const o=r.parentElement;if(!o)return[];const a=Array.from(o.children).indexOf(r);if(a<0)return[];n.unshift(a),r=o}return n}function ft(e){if(e.matches(dn)||e.getAttribute("aria-hidden")==="true")return!0;const t=typeof e.className=="string"?e.className:"";return/(^|\s)(page|progress|ctrl|nav|particle|glow)(\s|$)/i.test(t)}function zt(e){const{containerElement:t,containerPath:n,pageIndex:r,pageSelector:o,parentNodeId:i,nodeIdPrefix:a,nodes:c,assets:h}=e;Array.from(t.children).forEach((g,S)=>{var M;if(ft(g))return;const j=[...n,S];if(In(g)){zt({...e,containerElement:g,containerPath:j,parentNodeId:i,nodeIdPrefix:a});return}const b=`${a}-node-${j.join("-")||"root"}`,P=Rr({element:g,pageIndex:r,pageSelector:o,nodePath:j,nodeId:b,assets:h});if(!P)return;const y=[...P.runtimeFlags];t.hasAttribute("data-cns-layout-freeze")&&!y.includes("layout-freeze-child")&&y.push("layout-freeze-child"),g.hasAttribute("data-cns-layout-freeze")&&!y.includes("layout-freeze-container")&&y.push("layout-freeze-container"),c[P.id]=y.length===P.runtimeFlags.length?P:{...P,runtimeFlags:y},(M=c[i])==null||M.children.push(P.id),P.type==="group"&&zt({...e,containerElement:g,containerPath:j,parentNodeId:P.id,nodeIdPrefix:P.id})})}function Rr(e){const{element:t,pageIndex:n,pageSelector:r,nodePath:o,nodeId:i,assets:a}=e,c={pageIndex:n,pageSelector:r,nodePath:o},h=ht(t);if(t.tagName==="IMG"){const g=t.getAttribute("src")??"",S=t.getAttribute("alt")??"";return g&&a.push({id:`asset-${_t(g)}`,type:"image",src:g}),{id:i,type:"image",name:S||"图片",editable:!0,lockedReason:null,box:qe(t),style:ze(t),content:{src:g,alt:S},children:[],sourceRef:c,patchStrategy:"replace_node",runtimeFlags:[]}}if(t.tagName==="SVG"||t.querySelector(":scope > svg"))return{id:i,type:"svg",name:"SVG",editable:!1,lockedReason:"复杂 SVG 先按只读节点导入",box:qe(t),style:ze(t),content:{html:t.outerHTML},children:[],sourceRef:c,patchStrategy:"replace_node",runtimeFlags:["readonly"]};if(Dt.has(t.tagName)||Nn(t)||Fr(t,h))return Mt(i,t,c);if(!h.length){const g=Mt(i,t,c);if(g)return g}if(h.length>0||Br(t))return{id:i,type:"group",name:Jt(t),editable:!0,lockedReason:null,box:qe(t),style:ze(t),content:{},children:[],sourceRef:c,patchStrategy:"style_only",runtimeFlags:[]};const p=t.outerHTML.trim();return p?{id:i,type:"html",name:Jt(t),editable:!1,lockedReason:"复杂 HTML 片段先按只读节点导入",box:qe(t),style:ze(t),content:{html:p},children:[],sourceRef:c,patchStrategy:"replace_node",runtimeFlags:["readonly"]}:null}function Mt(e,t,n){const r=Wr(t),o=Ot(r);return o?vn({id:e,name:o.slice(0,20),text:o,runs:r,sourceRef:n,style:ze(t),box:qe(t),preserveStructure:Hr(t)}):null}function xn(e){return{id:e.id,type:"group",name:e.name,editable:!0,lockedReason:null,box:bn(),style:{},content:{},children:[],sourceRef:e.sourceRef,patchStrategy:"style_only",runtimeFlags:e.runtimeFlags??[]}}function yn(e){return`page-${e.pages.reduce((n,r)=>{const o=/^page-(\d+)$/.exec(r.id);return o?Math.max(n,Number.parseInt(o[1]??"0",10)):n},0)+1}`}function jr(e,t,n){var i;const r=(i=n.sourceRef.pageSelector)==null?void 0:i.trim();if(r){const a=Array.from(e.querySelectorAll(r)).filter(c=>t.includes(c));if(a.length===1&&a[0]instanceof Element)return a[0];if(/^\[data-cns-page-id=/.test(r))return null}const o=t[n.sourceRef.pageIndex]??null;return o instanceof Element?o:null}function Mr(e,t,n,r,o=!1){var h,p;if(o&&t instanceof Element){const g=t.cloneNode(!0);if(g instanceof Element)return g}const i=e.createElement(((h=t==null?void 0:t.tagName)==null?void 0:h.toLowerCase())||"section");t instanceof Element?Lr(t,i):i.className="slide";const a=e.createElement("div");a.className=Tr(t);const c=e.createElement("h1");return c.textContent=((p=n.title)==null?void 0:p.trim())||f("conversation.fileViewerPresentationUntitled"),a.appendChild(c),i.appendChild(a),i}function Zt(e,t,n,r){var a,c;const o=((a=t.title)==null?void 0:a.trim())||f("conversation.fileViewerPresentationUntitled");e.setAttribute("data-title",o),e.setAttribute("data-cns-page-id",t.id),e.setAttribute("data-cns-page-order",String(r));const i=e.querySelector("h1, h2, h3, .slide-title, .title, .page-title");i&&(n||!((c=i.textContent)!=null&&c.trim()))&&(i.textContent=o)}function Lr(e,t){Array.from(e.attributes).forEach(n=>{n.name==="data-title"||n.name.startsWith("data-cns-")||t.setAttribute(n.name,n.value)})}function Tr(e){const t=e==null?void 0:e.querySelector(".slide-shell, .panel, .content, .slide-inner");return(typeof(t==null?void 0:t.className)=="string"?t.className.trim():"")||"slide-shell"}function vn(e){const t=!!e.preserveStructure||Array.isArray(e.runs)&&e.runs.some(n=>n.tagName||n.className||n.sourceKind==="element");return{id:e.id,type:"text",name:e.name,editable:!0,lockedReason:null,box:e.box??bn(),style:e.style??{},content:{text:e.text,runs:e.runs??null},children:[],sourceRef:e.sourceRef,patchStrategy:"text_and_style",runtimeFlags:t?["preserve-text-structure"]:[]}}function bn(){return{x:0,y:0,width:0,height:0,zIndex:0}}function ze(e){const t=wn(e);return{position:t.get("position")??null,fontFamily:t.get("font-family")??null,fontSize:Xe(t.get("font-size")),fontWeight:t.get("font-weight")??null,fontStyle:t.get("font-style")??null,lineHeight:t.get("line-height")??null,letterSpacing:t.get("letter-spacing")??null,color:t.get("color")??null,textAlign:t.get("text-align")??null,textDecoration:t.get("text-decoration")??null,textDecorationColor:t.get("text-decoration-color")??null,whiteSpace:t.get("white-space")??null,padding:t.get("padding")??null,margin:t.get("margin")??null,borderRadius:t.get("border-radius")??null,borderWidth:t.get("border-width")??null,borderColor:t.get("border-color")??null,backgroundColor:t.get("background-color")??null,opacity:Ar(t.get("opacity"))}}function qe(e){const t=wn(e);return{x:Xe(t.get("left"))??0,y:Xe(t.get("top"))??0,width:Xe(t.get("width"))??0,height:Xe(t.get("height"))??0,zIndex:zr(t.get("z-index"))??0}}function wn(e){const t=(e.getAttribute("style")??"").trim(),n=new Map;return t&&t.split(";").forEach(r=>{const[o,i]=r.split(":");!o||!i||n.set(o.trim(),i.trim())}),n}function Xe(e){if(!e)return null;const t=/(-?\d+(?:\.\d+)?)px/i.exec(e);return t?Number(t[1]):null}function Ar(e){if(!e)return null;const t=Number(e);return Number.isFinite(t)?t:null}function zr(e){if(!e)return null;const t=Number.parseInt(e,10);return Number.isFinite(t)?t:null}function Nn(e){return e.tagName!=="SPAN"?!1:!!Je(e.textContent??"")&&e.children.length===0}function ht(e){return Array.from(e.children).filter(t=>!ft(t))}function Sn(e){return Array.from(e.childNodes).some(t=>t.nodeType!==Node.TEXT_NODE?!1:!!Fe(t.textContent??""))}const Vr=new Set(["SPAN","STRONG","B","I","EM","U","SMALL","MARK","SUB","SUP","CODE","A","BR"]);function Fr(e,t){return dt(e,t)>0}function $r(e){return dt(e)>0}function dt(e,t){if(!Je(e.textContent??""))return 0;if(Dt.has(e.tagName))return 500;if(Nn(e))return 460;const r=t??ht(e);return r.length===0?420:r.every(i=>pt(i))&&Sn(e)?360:0}function In(e){if(ft(e)||dt(e)>0)return!1;const t=ht(e);if(t.length!==1||Sn(e))return!1;const n=t[0];return n?dt(n)>0?!0:In(n):!1}function pt(e){return!!(Vr.has(e.tagName)||e.tagName==="SPAN"&&e.children.length===0)}function Wr(e){const t=[];return kn(e,t,e),Dr(t)}function kn(e,t,n){if(n.nodeType===Node.TEXT_NODE){const r=n.textContent??"";if(!Ut(r))return;const o=Fe(r);o&&t.push({text:o,sourceKind:"text"});return}if(n instanceof Element&&!(ft(n)&&n!==e)){if(n!==e&&pt(n)){const r=Fe(n.textContent??"");r&&t.push({text:r,tagName:n.tagName.toLowerCase(),className:typeof n.className=="string"&&n.className.trim()?n.className.trim():null,style:ze(n),sourceKind:"element"});return}n.childNodes.forEach(r=>{kn(e,t,r)})}}function Dr(e){return e.map(n=>{const r=Fe(n.text);return r?{text:r,tagName:n.tagName??null,className:n.className??null,style:n.style??null,sourceKind:n.sourceKind??null}:null}).filter(n=>n!==null)}function Ot(e){return Je(e.map(t=>t.text).join(" "))}function Hr(e){if(e.querySelector("br"))return!0;let t=0;return e.childNodes.forEach(n=>{if(n.nodeType===Node.TEXT_NODE){Ut(n.textContent??"")&&(t+=1);return}n instanceof Element&&n.tagName!=="BR"&&pt(n)&&Fe(n.textContent??"")&&(t+=1)}),t>1}function Br(e){const t=typeof e.className=="string"?e.className.toLowerCase():"";return ir.some(n=>t.includes(n))}function Jt(e){const t=typeof e.className=="string"?e.className.trim():"";return t?t.split(/\s+/)[0]??e.tagName.toLowerCase():e.tagName.toLowerCase()}function Je(e){return e.replace(/\s+/g," ").trim()}function Fe(e){return e.replace(/\r\n/g,`
|
|
587
|
-
`).replace(/[^\S\r\n]+/g," ")}function Ut(e){return!e||!/\S/.test(e)?!1:!/^[\n\r\t ]+$/.test(e)}function Pn(e){return Array.from(new Set(e))}function Or(e){const t=new Map;return e.forEach(n=>{t.set(n.id,n)}),Array.from(t.values())}function Ur(e){return`static-html-${_t(e)}`}function En(e,t){const n=e[t.pageIndex];if(!n)return null;let r=n;for(const o of t.nodePath){const i=r.children.item(o);if(!(i instanceof Element))return null;r=i}return r}function Cn(e,t){switch(t.type){case"text":Array.isArray(t.content.runs)&&t.content.runs.length>0?_r(e,t.content.runs,{preserveStructure:$e(t,"preserve-text-structure")}):typeof t.content.text=="string"&&(e.textContent=t.content.text);break;case"image":typeof t.content.src=="string"&&t.content.src&&e.setAttribute("src",t.content.src),typeof t.content.alt=="string"&&e.setAttribute("alt",t.content.alt);break;default:!t.children.length&&typeof t.content.text=="string"&&t.content.text&&(e.textContent=t.content.text);break}mt(e,t.style),Jr(e,t),Qr(e,t)}function _r(e,t,n){if(n!=null&&n.preserveStructure&&Kr(e,t))return;const r=e.ownerDocument;if(!r){e.textContent=Ot(t);return}for(;e.firstChild;)e.removeChild(e.firstChild);t.forEach(o=>{if(!o.text)return;if(!o.tagName){e.appendChild(r.createTextNode(o.text));return}const i=r.createElement(o.tagName);o.className&&i.setAttribute("class",o.className),i.textContent=o.text,mt(i,o.style??{}),e.appendChild(i)})}function Kr(e,t){if(Je(e.textContent??"")===Ot(t))return!0;const n=qr(t);if(!n.length)return!1;const r=Xr(e);if(!r.length||r.length!==n.length)return!1;for(let o=0;o<r.length;o+=1){const i=r[o],a=n[o];if(!i||!a||i.kind!==a.kind||i.kind==="element"&&((i.tagName??null)!==(a.tagName??null)||(i.className??null)!==(a.className??null)))return!1}return r.forEach((o,i)=>{const a=n[i];if(a){if(o.kind==="text"&&o.node.nodeType===Node.TEXT_NODE){o.node.textContent=a.text;return}o.node instanceof Element&&(o.node.textContent=a.text,mt(o.node,a.style??{}))}}),!0}function qr(e){return e.map(t=>{const n=t.text??"";return n?{kind:t.tagName||t.className||t.sourceKind==="element"?"element":"text",text:n,tagName:t.tagName??null,className:t.className??null,style:t.style??null}:null}).filter(t=>!!t)}function Xr(e){const t=[];return e.childNodes.forEach(n=>{if(n.nodeType===Node.TEXT_NODE){const o=n.textContent??"";if(!Ut(o))return;t.push({kind:"text",node:n,tagName:null,className:null});return}!(n instanceof Element)||n.tagName==="BR"||!pt(n)||!Fe(n.textContent??"")||t.push({kind:"element",node:n,tagName:n.tagName.toLowerCase(),className:typeof n.className=="string"&&n.className.trim()?n.className.trim():null})}),t}function Yr(e,t,n){if(t.type!=="text"||!Gr(e,t))return;const r=typeof t.content.text=="string"?t.content.text:Je(e.textContent??""),o=Array.isArray(t.content.runs)?t.content.runs:[];if(!r)return;const i=e.ownerDocument;if(!i)return;const a=i.createElement("span");for(a.setAttribute("data-cns-text-proxy","true"),a.setAttribute("data-cns-node-id",t.id),e.setAttribute("data-cns-node-host","true"),e.setAttribute("data-cns-node-host-id",t.id),e.removeAttribute("data-cns-node-id"),n.selected&&(a.setAttribute("data-cns-node-selected","true"),e.removeAttribute("data-cns-node-selected")),a.setAttribute("style",["display: inline","background: transparent","border: none","padding: 0","margin: 0","white-space: inherit","color: inherit","font: inherit","letter-spacing: inherit","line-height: inherit","text-transform: inherit"].join("; ")),o.length>1?o.forEach((c,h)=>{const p=i.createElement(c.tagName||"span");p.setAttribute("data-cns-node-id",t.id),p.setAttribute("data-cns-run-index",String(h)),c.className&&p.setAttribute("class",c.className),n.selected&&n.selectedRunIndex===h&&p.setAttribute("data-cns-node-selected","true"),p.textContent=c.text,mt(p,c.style??{}),a.appendChild(p)}):a.textContent=r;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(a)}function Gr(e,t){return e.childElementCount>0||Dt.has(e.tagName)?!1:Zr(t.style)}function Zr(e){return!!(e.backgroundColor||e.padding||e.borderRadius||e.borderWidth||e.borderColor)}function mt(e,t){for(const[n,r]of Object.entries(t)){const o=ar[n];if(o){if(r==null||r===""){e instanceof HTMLElement?e.style.removeProperty(o):e.setAttribute("style",(e.getAttribute("style")??"").trim());continue}e.setAttribute("style",Me(e.getAttribute("style")??"",o,eo(n,r)))}}}function Jr(e,t){if(!($e(t,"draft-clone")||$e(t,"draft-box")))return;const r=e.getAttribute("style")??"";let o=Me(r,"position","absolute");o=Me(o,"left",`${t.box.x}px`),o=Me(o,"top",`${t.box.y}px`),t.box.width>0&&(o=Me(o,"width",`${t.box.width}px`)),t.box.height>0&&(o=Me(o,"height",`${t.box.height}px`)),t.box.zIndex!==0&&(o=Me(o,"z-index",String(t.box.zIndex))),e.setAttribute("style",o)}function Qr(e,t){if($e(t,"layout-freeze-container")){e.setAttribute("data-cns-layout-freeze","true");return}e.removeAttribute("data-cns-layout-freeze")}function Me(e,t,n){const r=new Map;return e.split(";").forEach(o=>{const[i,a]=o.split(":");!i||!a||r.set(i.trim(),a.trim())}),r.set(t,n),Array.from(r.entries()).map(([o,i])=>`${o}: ${i}`).join("; ")}function eo(e,t){return e==="fontSize"&&typeof t=="number"?`${t}px`:String(t)}function _t(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t.toString(16)}function Rn(e){const t=e.project.nodes[e.sourceNodeId];if(!t)return e.sourceNodeId;const n=to(t.id,e.idCounter),r=`clone-source:${t.id}`,o=Pn([...t.runtimeFlags.filter(c=>!c.startsWith("clone-source:")),"draft-clone",e.isRoot?"draft-clone-root":"draft-clone-child",r]),i={...t,id:n,name:`${t.name} 副本`,sourceRef:t.sourceRef,box:{...t.box,x:t.box.x+24,y:t.box.y+24},children:[],runtimeFlags:o};e.nextNodes[n]=i;const a=t.children.map(c=>Rn({project:e.project,sourceNodeId:c,nextNodes:e.nextNodes,idCounter:e.idCounter,isRoot:!1}));return e.nextNodes[n]={...i,children:a},n}function jn(e){const t=e.project.nodes[e.sourceNodeId];if(!t)return e.targetNodeId;const n={...t,id:e.targetNodeId,sourceRef:t.sourceRef?{...t.sourceRef,pageIndex:e.sourcePageIndex}:null,children:[],runtimeFlags:t.runtimeFlags.filter(o=>o!=="draft-clone"&&o!=="draft-clone-root"&&o!=="draft-clone-child"&&!o.startsWith("clone-source:"))};e.nextNodes[e.targetNodeId]=n;const r=t.children.map((o,i)=>jn({project:e.project,sourceNodeId:o,targetNodeId:`${e.targetNodeId}-node-${i}`,nextPageId:e.nextPageId,sourcePageIndex:e.sourcePageIndex,nextNodes:e.nextNodes}));return e.nextNodes[e.targetNodeId]={...n,children:r},e.targetNodeId}function to(e,t){const n=(t[e]??0)+1;return t[e]=n,`${e}-copy-${n}`}function no(e){const t={};return Object.keys(e).forEach(n=>{const r=/^(.*)-copy-(\d+)$/.exec(n);if(!r)return;const o=r[1],i=Number.parseInt(r[2]??"0",10);!o||!Number.isFinite(i)||(t[o]=Math.max(t[o]??0,i))}),t}function ro(e){const t=io(e.cloneRootNode);if(!t)return;const n=e.project.nodes[t];if(!(n!=null&&n.sourceRef))return;const r=En(e.pageElements,n.sourceRef);if(!(r!=null&&r.parentElement))return;const o=r.cloneNode(!0);o instanceof Element&&(r.parentElement.insertBefore(o,r.nextSibling),Mn({project:e.project,cloneNodeId:e.cloneRootNode.id,cloneElement:o,sourceRootPath:n.sourceRef.nodePath,selectedNodeId:e.selectedNodeId,mode:e.mode}))}function Mn(e){const t=e.project.nodes[e.cloneNodeId];t&&(e.cloneElement.setAttribute("data-cns-node-id",t.id),e.mode==="preview"?(e.cloneElement.removeAttribute("data-cns-node-selected"),e.selectedNodeId&&t.id===e.selectedNodeId&&e.cloneElement.setAttribute("data-cns-node-selected","true")):e.cloneElement.removeAttribute("data-cns-node-selected"),Cn(e.cloneElement,t),t.children.forEach(n=>{const r=e.project.nodes[n];if(!(r!=null&&r.sourceRef))return;const o=r.sourceRef.nodePath.slice(e.sourceRootPath.length),i=oo(e.cloneElement,o);i&&Mn({project:e.project,cloneNodeId:n,cloneElement:i,sourceRootPath:e.sourceRootPath,selectedNodeId:e.selectedNodeId,mode:e.mode})}))}function oo(e,t){let n=e;for(const r of t){const o=n.children.item(r);if(!(o instanceof Element))return null;n=o}return n}function $e(e,t){return e.runtimeFlags.includes(t)}function io(e){const t=e.runtimeFlags.find(n=>n.startsWith("clone-source:"));return t?t.slice(13):null}function ao(e){e.querySelectorAll("[data-cns-page-root]").forEach(t=>{t.removeAttribute("data-cns-page-root"),t.removeAttribute("data-cns-active-page")}),e.querySelectorAll("[data-cns-text-proxy]").forEach(t=>{const n=t.parentElement;if(!n){t.remove();return}n.textContent=t.textContent??"",n.removeAttribute("data-cns-node-host"),n.removeAttribute("data-cns-node-host-id")}),e.querySelectorAll("[data-cns-node-id]").forEach(t=>{t.removeAttribute("data-cns-node-id")}),e.querySelectorAll("[data-cns-node-selected]").forEach(t=>{t.removeAttribute("data-cns-node-selected")}),e.querySelectorAll("[data-cns-inline-editing]").forEach(t=>{t.removeAttribute("data-cns-inline-editing")}),e.querySelectorAll("[data-cns-node-host]").forEach(t=>{t.removeAttribute("data-cns-node-host"),t.removeAttribute("data-cns-node-host-id")}),e.querySelectorAll("[data-cns-page-id]").forEach(t=>{t.removeAttribute("data-cns-page-id"),t.removeAttribute("data-cns-page-order")}),e.querySelectorAll("style").forEach(t=>{var n;(n=t.textContent)!=null&&n.includes("[data-cns-page-root")&&t.remove()}),e.querySelectorAll('script[data-cns-preview-bridge="true"]').forEach(t=>{t.remove()})}const it=24;function O(e){return{x:Number.isFinite(e.x)?Math.round(e.x):0,y:Number.isFinite(e.y)?Math.round(e.y):0,width:Math.max(it,Number.isFinite(e.width)?Math.round(e.width):it),height:Math.max(it,Number.isFinite(e.height)?Math.round(e.height):it),zIndex:Number.isFinite(e.zIndex)?Math.round(e.zIndex):0}}function so(e,t){const n=O(t),r=e.runtimeFlags.includes("draft-box")?e.runtimeFlags:[...e.runtimeFlags,"draft-box"];return{...e,box:n,runtimeFlags:r}}function Lt(e,t){const n={...e.nodes};return Object.entries(t).forEach(([r,o])=>{const i=n[r];i&&(n[r]=so(i,o))}),{...e,nodes:n}}function lo(e,t){const n=Object.entries(e);if(n.length===0)return{};const r=co(n.map(([,i])=>i),t),o={};return n.forEach(([i,a])=>{const c=O(a);if(t==="left"){o[i]={...c,x:r};return}if(t==="right"){o[i]={...c,x:r-c.width};return}if(t==="top"){o[i]={...c,y:r};return}o[i]={...c,y:r-c.height}}),o}function co(e,t){return t==="left"?Math.min(...e.map(n=>n.x)):t==="right"?Math.max(...e.map(n=>n.x+n.width)):t==="top"?Math.min(...e.map(n=>n.y)):Math.max(...e.map(n=>n.y+n.height))}function uo(e){if(e.length===0)return null;const t=Math.min(...e.map(i=>i.x)),n=Math.min(...e.map(i=>i.y)),r=Math.max(...e.map(i=>i.x+i.width)),o=Math.max(...e.map(i=>i.y+i.height));return O({x:t,y:n,width:r-t,height:o-n,zIndex:Math.max(...e.map(i=>i.zIndex))})}function Qt(e){return{verticals:[e.x,e.x+e.width/2,e.x+e.width],horizontals:[e.y,e.y+e.height/2,e.y+e.height]}}const fo=4;function ho({filePath:e,html:t,baseHref:n,onProjectChange:r,onSave:o,canSave:i=!1,saving:a=!1}){const c=x.useMemo(()=>Ht(t,e),[e,t]),h=x.useMemo(()=>sr({html:t,filePath:e}),[e,t]),[p,g]=x.useState(h),[S,j]=x.useState(0),[b,P]=x.useState("content"),[y,M]=x.useState(null),[C,A]=x.useState([]),[R,L]=x.useState(null),[_,Z]=x.useState(null),[Pe,ne]=x.useState([]),[be,we]=x.useState(null),[W,pe]=x.useState(null),[I,Y]=x.useState(null),re=x.useRef(null),Le=x.useRef(null),me=x.useRef(null),G=x.useRef(null),Ne=x.useRef(null),J=x.useRef(null),de=x.useRef(h),We=x.useRef(1),De=x.useRef(null),Ee=x.useRef({}),Q=x.useRef(null),[D,H]=x.useState(1),[ge,He]=x.useState(1),[B,ue]=x.useState({}),[Ce,Re]=x.useState({}),[vt,Se]=x.useState([]),[X,xe]=x.useState(null),m=p,$=(m==null?void 0:m.pages[S])??(m==null?void 0:m.pages[0])??null,K=x.useMemo(()=>!m||!$?[]:Rt(m,$.id),[$,m]);x.useEffect(()=>{g(h),j(0),P("content"),M(null),A([]),L(null),Z(null),ne([]),we(null),pe(null),Y(null),ue({}),Re({}),Se([]),xe(null),Q.current=null},[h]),x.useEffect(()=>{r==null||r(p)},[p,r]),x.useEffect(()=>{de.current=p},[p]),x.useEffect(()=>{We.current=D},[D]),x.useEffect(()=>{const l=Ne.current,d=J.current;if(!l||!d){He(1);return}const u=()=>{const v=l.clientWidth,k=l.clientHeight,N=d.scrollWidth,E=d.scrollHeight;if(v<=0||k<=0||N<=0||E<=0){He(1);return}const T=v/N,F=k/E,z=Math.min(1,T,F);He(U=>Math.abs(U-z)<.01?U:z)};if(u(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{u()});return w.observe(l),w.observe(d),()=>{w.disconnect()}},[b,y,C,_]),x.useEffect(()=>{De.current=X},[X]),x.useEffect(()=>{Ee.current=Ce},[Ce]),x.useEffect(()=>{if(!m||!$){M(null),A([]),L(null),Z(null);return}const l=K.find(u=>{var w;return(w=m.nodes[u])==null?void 0:w.editable})??null,d=C.filter(u=>K.includes(u));d.length!==C.length&&A(d),R&&!K.includes(R)&&L(null),!(y&&K.includes(y))&&(M(l),A(l?[l]:[]),Z(null))},[$,m,R,K,y,C]);const te=y&&m?m.nodes[y]??null:null,et=b==="content"&&(te==null?void 0:te.type)==="html"?null:te,bt=x.useMemo(()=>C.map(l=>(m==null?void 0:m.nodes[l])??null).filter(l=>!!l),[m,C]),oe=x.useMemo(()=>m?lr({html:t,project:m,pageIndex:S,baseHref:n??null}):null,[n,S,m,t]);x.useEffect(()=>{!G.current||!I||(en(G.current,I.text),go(G.current))},[I==null?void 0:I.nodeId]),x.useEffect(()=>{!G.current||!I||en(G.current,I.text)},[I==null?void 0:I.text]),x.useEffect(()=>{if(!oe||!m)return;const l=d=>{const u=d.data;if(!u||typeof u!="object")return;if(u.type==="codingns-static-html-layout-pointer"){const E=typeof u.phase=="string"?u.phase:"",T=typeof u.nodeId=="string"?u.nodeId.trim():"",F=typeof u.clientX=="number"?u.clientX:Number.NaN,z=typeof u.clientY=="number"?u.clientY:Number.NaN;if(!T||!Number.isFinite(F)||!Number.isFinite(z))return;if(E==="start"){if(b!=="layout")return;const Ue=m.nodes[T],Kn=ke(Ue),Pt=!!u.metaKey||!!u.ctrlKey?C.includes(T)?C:[...C,T]:[T];if(M(T),A(Pt),Z(null),Y(null),!Kn.movable)return;const qn=Object.fromEntries(Pt.map(se=>{const _e=m.nodes[se];return _e?[se,ve(_e,B[se])]:null}).filter(se=>!!se)),Xn=Object.fromEntries(K.map(se=>{const _e=m.nodes[se];return _e?[se,ve(_e,B[se])]:null}).filter(se=>!!se));xe({source:"iframe",handle:"move",nodeIds:Pt,pointerStartX:F,pointerStartY:z,activated:!1,startProject:m,startPageIndex:S,pageNodeIds:K,referenceBoxes:Xn,startSelectedNodeId:y,startSelectedNodeIds:C,originBoxes:qn});return}const U=De.current;if(!U||U.source!=="iframe")return;if(E==="move"){Be(U,F,z);return}if(E==="end"||E==="cancel"){je(U);return}return}if(u.type==="codingns-static-html-layout-hover"){if(b!=="layout")return;const E=typeof u.nodeId=="string"?u.nodeId.trim():"";L(E||null);return}if(u.type!=="codingns-static-html-node-select")return;const w=typeof u.nodeId=="string"?u.nodeId.trim():"",v=typeof u.runIndex=="number"&&Number.isInteger(u.runIndex)?u.runIndex:null;if(!w||!m.nodes[w])return;const k=m.pages.findIndex(E=>Rt(m,E.id).includes(w));k>=0&&k!==S&&j(k);const N=m.nodes[w];if(N){if(b==="layout"){if(N.type==="html")return;const E=ke(N);if(E.movable||E.resizable||E.alignable){const T=u.eventType==="click"&&(!!u.metaKey||!!u.ctrlKey);A(F=>{if(!T)return[w];if(F.includes(w)){const z=F.filter(U=>U!==w);return z.length>0?z:[w]}return[...F,w]})}M(w),Z(null),Y(null);return}if(N.type!=="html"){if(M(w),A([w]),Z(v),u.eventType==="dblclick"){const E=Array.isArray(N==null?void 0:N.content.runs)&&N.content.runs.length>1,T=(N==null?void 0:N.editable)&&(N.type==="text"||typeof N.content.text=="string"),F=po(u.rect)?u.rect:null;if(T&&F&&!E&&v===null){const z={nodeId:w,text:N.content.text??"",rect:F,appearance:mo(u.appearance,N.style)};Y(z);return}}Y(null)}}};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[S,m,b,B,oe,y,C]),x.useEffect(()=>{var d;const l=(d=re.current)==null?void 0:d.contentWindow;l&&l.postMessage({type:"codingns-static-html-selection-sync",selectedNodeId:y,selectedRunIndex:_,inlineEditingNodeId:(I==null?void 0:I.nodeId)??null,layoutModeEnabled:b==="layout",layoutHoveredNodeId:b==="layout"?R:null,layoutSelectedNodeIds:b==="layout"?C:[]},"*")},[R,I==null?void 0:I.nodeId,b,oe,y,C,_]);const ye=($==null?void 0:$.id)??null,wt=Pe.length>0;function tt(){const l=Pe[Pe.length-1];l&&(Q.current=null,ne(d=>d.slice(0,-1)),g(l.project),Re({}),Se([]),j(l.currentPageIndex),M(l.selectedNodeId),A(l.selectedNodeId?[l.selectedNodeId]:l.selectedNodeIds),Z(null),Y(null),xe(null))}x.useEffect(()=>{if(!m||!me.current){H(1);return}const l=me.current,d=()=>{const w=l.getBoundingClientRect(),v=24,k=Math.max(1,w.width-v),N=Math.max(1,w.height-v),E=k/m.canvas.width,T=N/m.canvas.height,F=Math.min(E,T,1);H(F>0?F:1)};if(d(),window.addEventListener("resize",d),typeof ResizeObserver>"u")return()=>{window.removeEventListener("resize",d)};const u=new ResizeObserver(()=>{d()});return u.observe(l),()=>{u.disconnect(),window.removeEventListener("resize",d)}},[m]);const nt=x.useMemo(()=>{if(!m)return;const l=m.canvas.width*D,d=m.canvas.height*D;return{display:"flex",alignItems:"flex-start",justifyContent:"flex-start",width:`${l}px`,height:`${d}px`}},[m,D]),ie=x.useMemo(()=>{if(m)return{position:"absolute",left:0,top:0,width:`${m.canvas.width}px`,height:`${m.canvas.height}px`,transform:`scale(${D})`,transformOrigin:"top left"}},[m,D]),q=x.useMemo(()=>{var v,k;if(!I)return null;const l=(v=re.current)==null?void 0:v.getBoundingClientRect(),d=(k=Le.current)==null?void 0:k.getBoundingClientRect();if(!l||!d)return{left:Math.max(0,I.rect.left),top:Math.max(0,I.rect.top),width:Math.max(120,I.rect.width),minHeight:Math.max(48,I.rect.height)};const u=l.left-d.left+I.rect.left*D,w=l.top-d.top+I.rect.top*D;return{left:Math.max(0,u),top:Math.max(0,w),width:Math.max(120,I.rect.width*D),minHeight:Math.max(48,I.rect.height*D)}},[D,I]);x.useEffect(()=>{!G.current||!q||(G.current.style.height=`${q.minHeight}px`,G.current.style.height=`${Math.max(q.minHeight,G.current.scrollHeight)}px`)},[I==null?void 0:I.nodeId,I==null?void 0:I.text,q]);const rt=x.useMemo(()=>{if(!(!I||!q))return{left:`${q.left}px`,top:`${q.top}px`,width:`${q.width}px`,minHeight:`${q.minHeight}px`,fontFamily:I.appearance.fontFamily??void 0,fontSize:I.appearance.fontSize??void 0,fontWeight:I.appearance.fontWeight??void 0,fontStyle:I.appearance.fontStyle??void 0,lineHeight:I.appearance.lineHeight??void 0,letterSpacing:I.appearance.letterSpacing??void 0,color:I.appearance.color??void 0,caretColor:I.appearance.color??void 0,textAlign:yo(I.appearance.textAlign),whiteSpace:vo(I.appearance.whiteSpace),padding:I.appearance.padding??void 0,textTransform:bo(I.appearance.textTransform)}},[I,q]);function Nt(l,d){if(!l)return{nextIndex:0,nextSelectedNodeId:null};const u=d.pages.findIndex(N=>N.id===l),w=u>=0?u:0,v=d.pages[w]??null,k=v?Rt(d,v.id):[];return{nextIndex:w,nextSelectedNodeId:k.find(N=>{var E;return(E=d.nodes[N])==null?void 0:E.editable})??null}}function St(l,d){if(g(l),Re({}),Se([]),(d==null?void 0:d.focusPageId)!==void 0){const u=Nt(d.focusPageId,l);j(u.nextIndex),M(d.selectedNodeId??u.nextSelectedNodeId),A(d.selectedNodeIds??(d.selectedNodeId?[d.selectedNodeId]:u.nextSelectedNodeId?[u.nextSelectedNodeId]:[]));return}(d==null?void 0:d.selectedNodeId)!==void 0&&M(d.selectedNodeId),(d==null?void 0:d.selectedNodeIds)!==void 0&&A(d.selectedNodeIds)}function ee(l){m&&((!l.historyKey||Q.current!==l.historyKey)&&ne(d=>[...d,{project:m,currentPageIndex:S,selectedNodeId:y,selectedNodeIds:C}].slice(-10)),Q.current=l.historyKey??null,St(l.nextProject,{focusPageId:l.focusPageId,selectedNodeId:l.selectedNodeId,selectedNodeIds:l.selectedNodeIds}),l.preserveInlineEditor||Y(null))}function It(l){ne(d=>[...d,l].slice(-10))}function Be(l,d,u){const w=We.current,v=w>0?(d-l.pointerStartX)/w:0,k=w>0?(u-l.pointerStartY)/w:0,N=Math.hypot(v,k);if(!l.activated&&l.handle==="move"&&N<fo)return;l.activated||xe(T=>T&&{...T,activated:!0});const E=Po(l,v,k);Re(E.previewBoxes),Se(E.guideLines)}function je(l){const d=de.current,u=Ee.current;if(d&&l.activated&&Object.keys(u).length>0){const w=Object.fromEntries(Object.entries(u).map(([k,N])=>{const E=d.nodes[k],T=B[k];if(!E)return null;const F=Ye(E,T),z=ve(E,T),U=z.x-F.x,Ue=z.y-F.y;return[k,O({...N,x:N.x-U,y:N.y-Ue})]}).filter(k=>!!k)),v=Lt(d,w);Q.current=null,It({project:l.startProject,currentPageIndex:l.startPageIndex,selectedNodeId:l.startSelectedNodeId,selectedNodeIds:l.startSelectedNodeIds}),g(v)}Re({}),Se([]),xe(null)}function Te(l,d){if(!m||!m.nodes[l])return;const w=(d==null?void 0:d.additive)??!1;M(l),Z(null),d!=null&&d.switchToLayout&&P("layout"),A(v=>{if(!w)return[l];if(v.includes(l)){const k=v.filter(N=>N!==l);return k.length>0?k:[l]}return[...v,l]})}function kt(l){var d;return m?((d=Object.values(m.nodes).find(u=>u.children.includes(l)))==null?void 0:d.id)??null:null}function Ae(l){if(!m||!l)return null;const d=kt(l);if(!d)return null;const u=m.nodes[d];return!u||u.runtimeFlags.includes("layout-freeze-container")||!u.sourceRef?null:d}function Oe(l){if(!m)return!1;const d=Ae(l);if(!d)return!1;const u=m.nodes[d];if(!u)return!1;const w=m.nodes[l??""];if(!w)return!1;const v=fe(d,u);return v?!!ae(w,v):!1}function V(){if(!m||!y||!Oe(y))return;const l=Ae(y);if(!l)return;const d=m.nodes[l];if(!d)return;const u=fe(l,d);if(!u)return;const w=hr(m,[l,...d.children],(v,k)=>{if(k===l){const T=v.runtimeFlags.includes("layout-freeze-container")?v.runtimeFlags:[...v.runtimeFlags,"layout-freeze-container"];return{...v,style:{...v.style,position:Tn(v.style.position)?v.style.position:"relative"},runtimeFlags:T}}const N=ae(v,u);if(!N)return v;const E=v.runtimeFlags.filter(T=>T!=="layout-freeze-container").concat(v.runtimeFlags.includes("layout-freeze-child")?[]:["layout-freeze-child"],v.runtimeFlags.includes("draft-box")?[]:["draft-box"]);return{...v,box:N,style:{...v.style,position:"absolute",margin:"0px"},runtimeFlags:E}});ee({nextProject:w,selectedNodeId:y,selectedNodeIds:[y],historyKey:`layout-freeze:${l}`}),P("layout")}function fe(l,d){const u=B[l];if(u)return ve(d,u);if(l===($==null?void 0:$.rootNodeId))return O({x:0,y:0,width:(m==null?void 0:m.canvas.width)??d.box.width,height:(m==null?void 0:m.canvas.height)??d.box.height,zIndex:d.box.zIndex});for(const v of d.children){const k=m==null?void 0:m.nodes[v],N=B[v];if(!k||!N)continue;const E=N.left-N.localLeft,T=N.top-N.localTop,F=he(d);return O({x:E,y:T,width:F.width,height:F.height,zIndex:d.box.zIndex})}const w=he(d);return O({x:d.box.x,y:d.box.y,width:w.width,height:w.height,zIndex:d.box.zIndex})}function he(l){const d=l.children.map(N=>Ie((m==null?void 0:m.nodes[N])??null)).filter(N=>!!N),u=l.box.width,w=l.box.height;if(!d.length)return{width:u,height:w};const v=d.reduce((N,E)=>Math.max(N,E.x+E.width),0),k=d.reduce((N,E)=>Math.max(N,E.y+E.height),0);return{width:Math.max(u,v),height:Math.max(w,k)}}function Ie(l){if(!l)return null;const d=B[l.id];return O(d?{x:d.localLeft,y:d.localTop,width:d.width,height:d.height,zIndex:l.box.zIndex}:l.box)}function ae(l,d){const u=B[l.id];if(u){const v=ve(l,u);return O({x:v.x-d.x,y:v.y-d.y,width:v.width,height:v.height,zIndex:v.zIndex})}const w=Ie(l);return w?O(w):null}function Un(){if(!m||!y)return;const l=pr(m,y);l.duplicatedNodeId&&(ee({nextProject:l.project,selectedNodeId:l.duplicatedNodeId,selectedNodeIds:[l.duplicatedNodeId],historyKey:`duplicate:${y}`}),P("layout"))}function _n(l){if(!m||!y)return;const d=m.nodes[y];if(!d)return;const u=Ye(d,B[y]),w=O({...u,x:l.x??u.x,y:l.y??u.y,width:l.width??u.width,height:l.height??u.height,zIndex:u.zIndex}),v=Lt(m,{[y]:w});ee({nextProject:v,selectedNodeId:y,selectedNodeIds:C,historyKey:`layout-box:${y}`})}function ot(l){if(!m)return;const d=C.filter(v=>ke(m.nodes[v]).alignable);if(d.length<2)return;const u=lo(Object.fromEntries(d.map(v=>{const k=m.nodes[v];return k?[v,Ye(k,B[v])]:null}).filter(v=>!!v)),l),w=Lt(m,u);ee({nextProject:w,selectedNodeId:y,selectedNodeIds:d,historyKey:`layout-align:${l}:${d.join(",")}`})}return x.useEffect(()=>{if(!oe||b!=="layout"){ue({});return}const l=d=>{const u=d.data;if(!u||typeof u!="object"||u.type!=="codingns-static-html-layout-measurements"||!Array.isArray(u.measurements))return;const w={};u.measurements.forEach(v=>{if(!v||typeof v!="object")return;const k=v,N=typeof k.nodeId=="string"?k.nodeId.trim():"",E=typeof k.left=="number"?k.left:Number.NaN,T=typeof k.top=="number"?k.top:Number.NaN,F=typeof k.width=="number"?k.width:Number.NaN,z=typeof k.height=="number"?k.height:Number.NaN,U=typeof k.localLeft=="number"?k.localLeft:E,Ue=typeof k.localTop=="number"?k.localTop:T;!N||!Number.isFinite(E)||!Number.isFinite(T)||!Number.isFinite(F)||!Number.isFinite(z)||(w[N]={left:E,top:T,width:F,height:z,localLeft:U,localTop:Ue})}),ue(w)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[b,oe]),x.useEffect(()=>{var d;if(b!=="layout"||!oe)return;const l=(d=re.current)==null?void 0:d.contentWindow;l&&l.postMessage({type:"codingns-static-html-layout-measure-request",nodeIds:Array.from(new Set([($==null?void 0:$.rootNodeId)??"",...K].filter(u=>u&&(m==null?void 0:m.nodes[u]))))},"*")},[$==null?void 0:$.rootNodeId,m,b,K,oe]),x.useEffect(()=>{if(!X||X.source!=="overlay")return;const l=u=>{Be(X,u.clientX,u.clientY)},d=()=>{je(X)};return window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d)}},[X]),!c.supported||!m?s.jsxs("div",{className:"static-html-presentation-empty",children:[s.jsx("p",{className:"status-text",children:f("conversation.fileViewerPresentationUnsupported")}),c.reason?s.jsx("p",{className:"status-text",children:f("conversation.fileViewerPresentationUnsupportedReason").replace("{reason}",c.reason)}):null]}):s.jsxs("div",{className:"static-html-presentation-shell","data-testid":"static-html-presentation-view",children:[s.jsxs("aside",{className:"static-html-presentation-sidebar",children:[s.jsxs("div",{className:"static-html-presentation-sidebar-actions",children:[s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-sidebar-action-button",onClick:tt,disabled:!wt,children:f("conversation.fileViewerPresentationUndoAction")}),s.jsx("button",{type:"button",className:"primary-button static-html-presentation-sidebar-action-button",onClick:o,disabled:!i||a,children:a?f("conversation.filePanelSaving"):f("conversation.filePanelSave")})]}),s.jsx("div",{className:"static-html-presentation-page-toolbar",children:s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-page-toolbar-button",onClick:()=>{const l=mr(m,{insertAfterPageId:ye});ee({nextProject:l.project,focusPageId:l.pageId})},children:f("conversation.fileViewerPresentationAddPage")})}),s.jsx("div",{className:"static-html-presentation-page-list",role:"list",children:m.pages.map((l,d)=>s.jsxs("div",{className:"static-html-presentation-page-item","data-active":l.id===ye?"true":void 0,"data-dragging":be===l.id?"true":void 0,"data-drop-target":(W==null?void 0:W.pageId)===l.id?"true":void 0,"data-drop-position":(W==null?void 0:W.pageId)===l.id?W.position:void 0,draggable:!0,onDragStart:u=>{u.dataTransfer.effectAllowed="move",u.dataTransfer.setData("text/plain",l.id),we(l.id),pe(null)},onDragOver:u=>{u.preventDefault(),u.dataTransfer.dropEffect="move";const w=wo(u);pe(v=>(v==null?void 0:v.pageId)===l.id&&v.position===w?v:{pageId:l.id,position:w})},onDrop:u=>{u.preventDefault();const w=u.dataTransfer.getData("text/plain")||be;if(!w||!W)return;const v=No(m.pages,w,W);if(v===null){we(null),pe(null);return}const k=yr(m,w,v);ee({nextProject:k.project,focusPageId:k.pageId}),we(null),pe(null)},onDragEnd:()=>{we(null),pe(null)},children:[(W==null?void 0:W.pageId)===l.id&&W.position==="before"?s.jsx("div",{className:"static-html-presentation-page-drop-indicator","data-position":"before"}):null,s.jsxs("button",{type:"button",className:"static-html-presentation-page-main",onClick:()=>{const u=m.pages.findIndex(w=>w.id===l.id);j(u>=0?u:0)},children:[s.jsx("span",{className:"static-html-presentation-page-no",children:String(d+1).padStart(2,"0")}),s.jsx("span",{className:"static-html-presentation-page-title",children:l.title??`第 ${d+1} 页`})]}),s.jsxs("div",{className:"static-html-presentation-page-actions","aria-label":f("conversation.fileViewerPresentationPageActions"),children:[s.jsx("span",{className:"static-html-presentation-page-drag-hint",children:f("conversation.fileViewerPresentationDragToSort")}),s.jsx("button",{type:"button",className:"static-html-presentation-page-action",onClick:()=>{const u=gr(m,l.id);u.pageId&&ee({nextProject:u.project,focusPageId:u.pageId})},"aria-label":f("conversation.fileViewerPresentationDuplicatePage"),title:f("conversation.fileViewerPresentationDuplicatePage"),children:s.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[s.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5"}),s.jsx("path",{d:"M4 10H3.5A1.5 1.5 0 0 1 2 8.5v-5A1.5 1.5 0 0 1 3.5 2h5A1.5 1.5 0 0 1 10 3.5V4"})]})}),s.jsx("button",{type:"button",className:"static-html-presentation-page-action",onClick:()=>{const u=xr(m,l.id);ee({nextProject:u.project,focusPageId:u.nextPageId??ye})},disabled:m.pages.length<=1,"aria-label":f("conversation.fileViewerPresentationDeletePage"),title:f("conversation.fileViewerPresentationDeletePage"),children:"×"})]}),(W==null?void 0:W.pageId)===l.id&&W.position==="after"?s.jsx("div",{className:"static-html-presentation-page-drop-indicator","data-position":"after"}):null]},l.id))})]}),s.jsxs("section",{className:"static-html-presentation-stage",children:[s.jsxs("section",{className:"static-html-presentation-toolbar-panel",children:[s.jsx("div",{className:"static-html-presentation-toolbar-panel-header",children:s.jsxs("div",{className:"static-html-presentation-mode-switch",role:"group","aria-label":f("conversation.fileViewerModeLabel"),children:[s.jsx("button",{type:"button",className:"static-html-presentation-mode-button","data-active":b==="content"?"true":void 0,onClick:()=>P("content"),children:f("conversation.fileViewerPresentationTextMode")}),s.jsx("button",{type:"button",className:"static-html-presentation-mode-button","data-active":b==="layout"?"true":void 0,onClick:()=>{P("layout"),y&&A([y])},children:f("conversation.fileViewerPresentationLayoutMode")})]})}),s.jsx("div",{className:"static-html-presentation-toolbar-panel-body",children:s.jsx("div",{ref:Ne,className:"static-html-presentation-toolbar-viewport",children:s.jsx("div",{ref:J,className:"static-html-presentation-toolbar-scale-shell",style:{transform:`scale(${ge})`,width:ge<1?`${100/ge}%`:"100%"},children:s.jsx("div",{className:"static-html-presentation-toolbar static-html-presentation-inspector",children:b==="layout"?s.jsx(Co,{selectedNode:te,selectedLayoutBox:te?Ye(te,y?B[y]:void 0):null,selectedNodes:bt,showFreezeContainerAction:!!(y&&Ae(y)),canFreezeContainer:Oe(y),onDuplicate:Un,onFreezeContainer:V,onAlignLeft:()=>ot("left"),onAlignRight:()=>ot("right"),onAlignTop:()=>ot("top"),onAlignBottom:()=>ot("bottom"),onBoxChange:_n}):et?s.jsx(Ro,{node:et,selectedRunIndex:_,onSelectedRunChange:Z,compact:!0,onTextChange:({text:l,runs:d})=>{if(!y)return;const u=Ct(m,y,w=>({...w,content:{...w.content,text:l,runs:d??nn(w,l)}}));ee({nextProject:u,historyKey:`text:${y}`})},onStyleChange:l=>{if(!y)return;const d=Ct(m,y,u=>({...u,style:{...u.style,...l}}));ee({nextProject:d,historyKey:`style:${y}`})}}):s.jsx("div",{className:"static-html-presentation-toolbar-empty static-html-presentation-inspector-empty",children:s.jsx("p",{className:"status-text",children:f("conversation.fileViewerPresentationSelectNode")})})})})})})]}),s.jsx("section",{className:"static-html-presentation-content-panel",children:s.jsxs("div",{className:"static-html-presentation-workarea",children:[s.jsx("div",{className:"static-html-presentation-canvas-panel",children:s.jsx("div",{ref:me,className:"static-html-presentation-frame-shell",children:oe?s.jsxs("div",{ref:Le,className:"static-html-presentation-frame-stage",style:nt,children:[s.jsx("iframe",{ref:re,className:"static-html-presentation-frame","data-testid":"static-html-presentation-frame",title:($==null?void 0:$.title)??e,srcDoc:oe,sandbox:"allow-forms allow-modals allow-scripts",style:ie,onLoad:()=>{var l,d;(d=(l=re.current)==null?void 0:l.contentWindow)==null||d.postMessage({type:"codingns-static-html-selection-sync",selectedNodeId:y,inlineEditingNodeId:(I==null?void 0:I.nodeId)??null,layoutModeEnabled:b==="layout",layoutHoveredNodeId:b==="layout"?R:null,layoutSelectedNodeIds:b==="layout"?C:[]},"*")}}),b==="layout"?s.jsxs("div",{className:"static-html-presentation-layout-overlay","data-testid":"static-html-presentation-layout-overlay",children:[vt.map((l,d)=>s.jsx("div",{className:"static-html-presentation-layout-guide","data-orientation":l.orientation,style:So(l,D)},`${l.orientation}-${l.position}-${d}`)),R&&!C.includes(R)&&B[R]?s.jsx("div",{className:"static-html-presentation-layout-box static-html-presentation-layout-box-hover","data-hovered":"true",style:Tt(B[R],D)}):null,C.map(l=>{const d=Ce[l],u=B[l],w=m.nodes[l],v=ke(w),k=d?Tt({left:d.x,top:d.y,width:d.width,height:d.height,localLeft:d.x,localTop:d.y},D):u?Tt(u,D):void 0;return!k||!w?null:s.jsx("div",{className:"static-html-presentation-layout-box","data-primary":l===y?"true":void 0,"data-disabled":v.movable?void 0:"true",style:k,onPointerEnter:()=>{L(l)},onPointerLeave:()=>{L(N=>N===l?null:N)},onPointerDown:N=>{if(!v.movable)return;N.preventDefault(),N.stopPropagation(),Te(l,{additive:N.metaKey||N.ctrlKey,switchToLayout:!0});const E=N.metaKey||N.ctrlKey?C.includes(l)?C:[...C,l]:[l],T=Object.fromEntries(E.map(z=>{const U=m.nodes[z];return U?[z,ve(U,B[z])]:null}).filter(z=>!!z)),F=Object.fromEntries(K.map(z=>{const U=m.nodes[z];return U?[z,ve(U,B[z])]:null}).filter(z=>!!z));xe({source:"overlay",handle:"move",nodeIds:E,pointerStartX:N.clientX,pointerStartY:N.clientY,startProject:m,startPageIndex:S,pageNodeIds:K,referenceBoxes:F,startSelectedNodeId:y,startSelectedNodeIds:C,activated:!1,originBoxes:T})},children:v.resizable?s.jsx("button",{type:"button",className:"static-html-presentation-layout-resize-handle","aria-label":f("conversation.fileViewerPresentationResizeHandle"),onPointerDown:N=>{N.preventDefault(),N.stopPropagation(),Te(l,{switchToLayout:!0}),xe({source:"overlay",handle:"resize-se",nodeIds:[l],pointerStartX:N.clientX,pointerStartY:N.clientY,startProject:m,startPageIndex:S,pageNodeIds:K,referenceBoxes:Object.fromEntries(K.map(E=>{const T=m.nodes[E];return T?[E,ve(T,B[E])]:null}).filter(E=>!!E)),startSelectedNodeId:y,startSelectedNodeIds:C,activated:!0,originBoxes:{[l]:ve(m.nodes[l],B[l])}})},children:s.jsx("span",{})}):null},l)})]}):null,I?s.jsx("div",{ref:G,className:"static-html-presentation-inline-editor","data-testid":"static-html-presentation-inline-editor",role:"textbox","aria-multiline":"true",contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,style:rt,onInput:l=>{const d=Ln(l.currentTarget),u=I;if(Y(v=>v&&{...v,text:d}),!u||!m.nodes[u.nodeId])return;const w=Ct(m,u.nodeId,v=>({...v,content:{...v.content,text:d,runs:nn(v,d)}}));ee({nextProject:w,selectedNodeId:u.nodeId,historyKey:`inline-text:${u.nodeId}`,preserveInlineEditor:!0})},onBlur:()=>{Y(null)},onPaste:l=>{l.preventDefault();const d=l.clipboardData.getData("text/plain");xo(d)},onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),Y(null))}}):null]}):s.jsx("p",{className:"status-text",children:f("conversation.fileViewerHtmlPreviewUnavailable")})})}),s.jsxs("aside",{className:"static-html-presentation-node-sidebar",children:[s.jsx("div",{className:"static-html-presentation-node-sidebar-header",children:s.jsx("p",{className:"static-html-presentation-node-sidebar-kicker",children:f("conversation.fileViewerPresentationComponentList")})}),s.jsx("div",{className:"static-html-presentation-node-strip",role:"list",children:K.map(l=>{const d=m.nodes[l];return d?s.jsxs("button",{type:"button",className:"static-html-presentation-node-chip","data-active":l===y?"true":void 0,"data-selected":C.includes(l)?"true":void 0,"data-locked":d.editable?void 0:"true",title:b==="layout"?ke(d).reason??void 0:void 0,onClick:u=>{Te(l,{additive:b==="layout"&&(u.metaKey||u.ctrlKey),switchToLayout:b==="layout"})},children:[s.jsx("span",{className:"static-html-presentation-node-chip-type",children:d.type}),s.jsx("span",{className:"static-html-presentation-node-chip-name",children:d.name||d.id}),b==="layout"?s.jsx("span",{className:"static-html-presentation-node-chip-status",children:ke(d).reason?f("conversation.fileViewerPresentationLayoutLocked"):f("conversation.fileViewerPresentationLayoutEditable")}):null]},l):null})})]})]})})]})]})}function po(e){if(!e||typeof e!="object")return!1;const t=e;return["left","top","width","height"].every(n=>typeof t[n]=="number")}function mo(e,t){const n={fontFamily:t.fontFamily??null,fontSize:typeof t.fontSize=="number"?`${t.fontSize}px`:null,fontWeight:t.fontWeight??null,fontStyle:null,lineHeight:t.lineHeight??null,letterSpacing:t.letterSpacing??null,color:t.color??null,textAlign:t.textAlign??null,whiteSpace:t.whiteSpace??null,padding:t.padding??null,textTransform:null};if(!e||typeof e!="object")return n;const r=e;return{fontFamily:le(r.fontFamily,n.fontFamily),fontSize:le(r.fontSize,n.fontSize),fontWeight:le(r.fontWeight,n.fontWeight),fontStyle:le(r.fontStyle,n.fontStyle),lineHeight:le(r.lineHeight,n.lineHeight),letterSpacing:le(r.letterSpacing,n.letterSpacing),color:le(r.color,n.color),textAlign:le(r.textAlign,n.textAlign),whiteSpace:le(r.whiteSpace,n.whiteSpace),padding:le(r.padding,n.padding),textTransform:le(r.textTransform,n.textTransform)}}function le(e,t){return typeof e=="string"&&e.trim()?e:t}function en(e,t){Ln(e)!==t&&(e.textContent=t)}function go(e){e.focus();const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}function Ln(e){return Qe(typeof e.innerText=="string"?e.innerText:e.textContent??"")}function Qe(e){return e.replace(/\r\n/g,`
|
|
588
|
-
`).replace(/\u00a0/g," ")}function xo(e){const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0);n.deleteContents();const r=document.createTextNode(e);n.insertNode(r),n.setStartAfter(r),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function yo(e){if(!e)return;const t=e.trim().toLowerCase();if(t==="left"||t==="right"||t==="center"||t==="justify"||t==="start"||t==="end")return t}function vo(e){if(!e)return;const t=e.trim().toLowerCase();if(t==="normal"||t==="nowrap"||t==="pre"||t==="pre-wrap"||t==="pre-line"||t==="break-spaces")return t}function bo(e){if(!e)return;const t=e.trim().toLowerCase();if(t==="none"||t==="capitalize"||t==="uppercase"||t==="lowercase")return t}function wo(e){const t=e.currentTarget.getBoundingClientRect();return t.height<=0||e.clientY-t.top<t.height/2?"before":"after"}function No(e,t,n){const r=e.findIndex(c=>c.id===t),o=e.findIndex(c=>c.id===n.pageId);if(r<0||o<0)return null;const i=n.position==="before"?o:o+1,a=r<i?i-1:i;return Math.max(0,Math.min(a,e.length-1))}function ke(e){return e?e.editable?e.type==="svg"||e.type==="html"||e.type==="decoration"?{movable:!1,resizable:!1,alignable:!1,reason:f("conversation.fileViewerPresentationLayoutUnsupported"),strictModeLocked:!1}:e.id.endsWith("-root")?{movable:!1,resizable:!1,alignable:!1,reason:f("conversation.fileViewerPresentationLayoutRootLocked"),strictModeLocked:!1}:Io(e)?{movable:!0,resizable:!0,alignable:!0,reason:null,strictModeLocked:!1}:{movable:!1,resizable:!1,alignable:!1,reason:f("conversation.fileViewerPresentationLayoutStrictLocked"),strictModeLocked:!0}:{movable:!1,resizable:!1,alignable:!1,reason:e.lockedReason||f("conversation.fileViewerPresentationLayoutUnsupported"),strictModeLocked:!1}:{movable:!1,resizable:!1,alignable:!1,reason:f("conversation.fileViewerPresentationLayoutUnsupported"),strictModeLocked:!1}}function Tt(e,t){return{left:`${e.left*t}px`,top:`${e.top*t}px`,width:`${e.width*t}px`,height:`${e.height*t}px`}}function So(e,t){return e.orientation==="vertical"?{left:`${e.position*t}px`,top:`${e.start*t}px`,width:"1px",height:`${Math.max(0,(e.end-e.start)*t)}px`}:{left:`${e.start*t}px`,top:`${e.position*t}px`,width:`${Math.max(0,(e.end-e.start)*t)}px`,height:"1px"}}function Io(e){return e.runtimeFlags.includes("draft-clone")||e.runtimeFlags.includes("draft-box")?!0:e.sourceRef?!!(e.runtimeFlags.includes("layout-freeze-child")||Tn(e.style.position)):!1}function Tn(e){const t=(e==null?void 0:e.trim().toLowerCase())??"";return t==="absolute"||t==="fixed"}function Ye(e,t){return e.runtimeFlags.includes("draft-clone")||e.runtimeFlags.includes("draft-box")?O(e.box):O(t?{x:t.localLeft,y:t.localTop,width:t.width,height:t.height,zIndex:e.box.zIndex}:e.box)}function ve(e,t){return O(t?{x:t.left,y:t.top,width:t.width,height:t.height,zIndex:e.box.zIndex}:e.box)}function ko(e,t){if(e.nodeIds.length!==1)return[];const n=e.nodeIds[0],r=t[n];if(!n||!r)return[];const o=[r.x,r.x+r.width/2,r.x+r.width],i=[r.y,r.y+r.height/2,r.y+r.height],a=6,c=[];return Object.entries(e.originBoxes).forEach(([h])=>{}),Object.entries(e.startProject.nodes).forEach(([h,p])=>{if(h===n||e.nodeIds.includes(h))return;const g=e.startProject.nodes[h]?Ye(p,void 0):null;if(!g)return;const S=[g.x,g.x+g.width/2,g.x+g.width],j=[g.y,g.y+g.height/2,g.y+g.height];o.forEach(b=>{const P=S.find(y=>Math.abs(y-b)<=a);P!==void 0&&c.push({orientation:"vertical",position:P,start:Math.min(r.y,g.y),end:Math.max(r.y+r.height,g.y+g.height)})}),i.forEach(b=>{const P=j.find(y=>Math.abs(y-b)<=a);P!==void 0&&c.push({orientation:"horizontal",position:P,start:Math.min(r.x,g.x),end:Math.max(r.x+r.width,g.x+g.width)})})}),An(c)}function Po(e,t,n){const r={};if(e.nodeIds.forEach(i=>{const a=e.originBoxes[i];if(a){if(e.handle==="move"){r[i]=O({...a,x:a.x+t,y:a.y+n});return}r[i]=O({...a,width:a.width+t,height:a.height+n})}}),e.handle!=="move")return{previewBoxes:r,guideLines:ko(e,r)};const o=Eo(e,r);return{previewBoxes:o.previewBoxes,guideLines:o.guideLines}}function Eo(e,t){const n=e.nodeIds.map(b=>t[b]).filter(b=>!!b),r=uo(n);if(!r)return{previewBoxes:t,guideLines:[]};const o=6,i=Qt(r);let a=0,c=0,h=o+1,p=o+1;const g=[],S=e.pageNodeIds.filter(b=>!e.nodeIds.includes(b)).map(b=>e.referenceBoxes[b]).filter(b=>!!b&&b.width>0&&b.height>0),j={x:0,y:0,width:e.startProject.canvas.width,height:e.startProject.canvas.height,zIndex:0};return[...S,j].forEach(b=>{const P=Qt(b);i.verticals.forEach(y=>{P.verticals.forEach(M=>{const C=Math.abs(M-(y+a));C>o||C>=h||(h=C,a=M-y,g.push({orientation:"vertical",position:M,start:Math.min(r.y,b.y),end:Math.max(r.y+r.height,b.y+b.height)}))})}),i.horizontals.forEach(y=>{P.horizontals.forEach(M=>{const C=Math.abs(M-(y+c));C>o||C>=p||(p=C,c=M-y,g.push({orientation:"horizontal",position:M,start:Math.min(r.x,b.x),end:Math.max(r.x+r.width,b.x+b.width)}))})})}),(a!==0||c!==0)&&e.nodeIds.forEach(b=>{const P=t[b];P&&(t[b]=O({...P,x:P.x+a,y:P.y+c}))}),{previewBoxes:t,guideLines:An(g)}}function An(e){const t=new Map;return e.forEach(n=>{const r=`${n.orientation}:${Math.round(n.position)}`,o=t.get(r);if(!o){t.set(r,n);return}t.set(r,{...n,start:Math.min(o.start,n.start),end:Math.max(o.end,n.end)})}),Array.from(t.values())}function at(e){return{x:e?String(e.x):"",y:e?String(e.y):"",width:e?String(e.width):"",height:e?String(e.height):""}}function Co({selectedNode:e,selectedLayoutBox:t,selectedNodes:n,showFreezeContainerAction:r,canFreezeContainer:o,onDuplicate:i,onFreezeContainer:a,onAlignLeft:c,onAlignRight:h,onAlignTop:p,onAlignBottom:g,onBoxChange:S}){const j=ke(e),P=n.length>1&&n.every(R=>ke(R).alignable),y=!!e&&j.strictModeLocked&&r,[M,C]=x.useState(()=>at(t));x.useEffect(()=>{C(at(t))},[e==null?void 0:e.id,t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.width,t==null?void 0:t.height]);function A(R){if(!e)return;const L=M[R].trim();if(!L){C(at(t));return}const _=Number(L);if(!Number.isFinite(_)){C(at(t));return}S({[R]:_})}return s.jsxs("div",{className:"static-html-presentation-layout-toolbar",children:[s.jsxs("div",{className:"static-html-presentation-layout-toolbar-row",children:[s.jsx("span",{className:"static-html-presentation-layout-badge",children:n.length>1?f("conversation.fileViewerPresentationLayoutSelectionCount").replace("{count}",String(n.length)):f("conversation.fileViewerPresentationLayoutMode")}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:i,disabled:!e||!j.movable,children:f("conversation.fileViewerPresentationDuplicateAction")}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:c,disabled:!P,children:f("conversation.fileViewerPresentationLayoutAlignLeft")}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:h,disabled:!P,children:f("conversation.fileViewerPresentationLayoutAlignRight")}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:p,disabled:!P,children:f("conversation.fileViewerPresentationLayoutAlignTop")}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:g,disabled:!P,children:f("conversation.fileViewerPresentationLayoutAlignBottom")}),y?s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-layout-action",onClick:a,disabled:!o,children:f("conversation.fileViewerPresentationLayoutFreezeContainer")}):null]}),e?s.jsxs("div",{className:"static-html-presentation-layout-form",children:[s.jsxs("label",{className:"static-html-presentation-layout-field",children:[s.jsx("span",{children:f("conversation.fileViewerPresentationPositionXLabel")}),s.jsx("input",{type:"number",value:M.x,onChange:R=>C(L=>({...L,x:R.target.value})),onBlur:()=>A("x"),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),A("x"))},disabled:!j.movable})]}),s.jsxs("label",{className:"static-html-presentation-layout-field",children:[s.jsx("span",{children:f("conversation.fileViewerPresentationPositionYLabel")}),s.jsx("input",{type:"number",value:M.y,onChange:R=>C(L=>({...L,y:R.target.value})),onBlur:()=>A("y"),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),A("y"))},disabled:!j.movable})]}),s.jsxs("label",{className:"static-html-presentation-layout-field",children:[s.jsx("span",{children:f("conversation.fileViewerPresentationWidthLabel")}),s.jsx("input",{type:"number",value:M.width,onChange:R=>C(L=>({...L,width:R.target.value})),onBlur:()=>A("width"),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),A("width"))},disabled:!j.resizable})]}),s.jsxs("label",{className:"static-html-presentation-layout-field",children:[s.jsx("span",{children:f("conversation.fileViewerPresentationHeightLabel")}),s.jsx("input",{type:"number",value:M.height,onChange:R=>C(L=>({...L,height:R.target.value})),onBlur:()=>A("height"),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),A("height"))},disabled:!j.resizable})]}),j.reason?null:s.jsx("p",{className:"static-html-presentation-layout-hint",children:f("conversation.fileViewerPresentationLayoutHint")})]}):s.jsx("div",{className:"static-html-presentation-toolbar-empty static-html-presentation-inspector-empty",children:s.jsx("p",{className:"status-text",children:f("conversation.fileViewerPresentationLayoutSelectNode")})})]})}function Ro({node:e,selectedRunIndex:t,onSelectedRunChange:n,compact:r=!1,onTextChange:o,onStyleChange:i}){const a=e.type==="text"||typeof e.content.text=="string",c=typeof e.style.fontSize=="number"?e.style.fontSize:null,h=e.style.fontFamily??"",p=Mo(e.style.fontWeight),g=e.style.fontStyle??"",S=e.style.textDecoration??"",j=e.style.lineHeight??"",b=tn(e.style.color),P=tn(e.style.backgroundColor);return s.jsx("div",{className:"static-html-presentation-inspector-panel","data-compact":r?"true":void 0,children:s.jsx("div",{className:"static-html-presentation-inspector-controls","data-compact":r?"true":void 0,children:a?s.jsxs("div",{className:"static-html-presentation-text-edit-row",children:[s.jsx("div",{className:"static-html-presentation-text-toolbar",role:"toolbar","aria-label":f("conversation.fileViewerPresentationTextToolbar"),children:s.jsxs("div",{className:"static-html-presentation-text-toolbar-row",children:[s.jsxs("select",{className:"static-html-presentation-text-toolbar-select static-html-presentation-text-toolbar-font",value:h,onChange:y=>i({fontFamily:y.target.value||null}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationFontFamilyLabel"),children:[s.jsx("option",{value:"",children:f("conversation.fileViewerPresentationKeepOriginal")}),s.jsx("option",{value:'"PingFang SC", "Microsoft YaHei", sans-serif',children:f("conversation.fileViewerPresentationFontPresetTitle")}),s.jsx("option",{value:'"Noto Sans SC", "PingFang SC", sans-serif',children:f("conversation.fileViewerPresentationFontPresetSans")}),s.jsx("option",{value:'Georgia, "Times New Roman", serif',children:f("conversation.fileViewerPresentationFontPresetSerif")}),s.jsx("option",{value:'"SF Mono", "Cascadia Mono", monospace',children:f("conversation.fileViewerPresentationFontPresetMono")})]}),s.jsxs("select",{className:"static-html-presentation-text-toolbar-select static-html-presentation-text-toolbar-size",value:c?String(c):"",onChange:y=>{const M=y.target.value.trim();i({fontSize:M?Number(M):null})},disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationFontSizeLabel"),children:[s.jsx("option",{value:"",children:f("conversation.fileViewerPresentationKeepOriginal")}),[12,14,16,18,20,24,28,32,40,48,60].map(y=>s.jsx("option",{value:y,children:y},y))]}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-text-toolbar-button","data-active":p==="700"?"true":void 0,onClick:()=>i({fontWeight:p==="700"?null:"700"}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationBoldAction"),children:"B"}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-text-toolbar-button static-html-presentation-text-toolbar-button-italic","data-active":g==="italic"?"true":void 0,onClick:()=>i({fontStyle:g==="italic"?null:"italic"}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationItalicAction"),children:"I"}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-text-toolbar-button static-html-presentation-text-toolbar-button-underline","data-active":S.includes("underline")?"true":void 0,onClick:()=>i({textDecoration:S.includes("underline")?null:"underline"}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationUnderlineAction"),children:"U"}),s.jsxs("label",{className:"static-html-presentation-text-toolbar-color","aria-label":f("conversation.fileViewerPresentationTextColorLabel"),children:[s.jsx("span",{className:"static-html-presentation-text-toolbar-color-label",style:{"--static-html-toolbar-color":b},children:"A"}),s.jsx("input",{type:"color",value:b,onChange:y=>i({color:y.target.value}),disabled:!e.editable})]}),s.jsxs("label",{className:"static-html-presentation-text-toolbar-color","aria-label":f("conversation.fileViewerPresentationBackgroundColorLabel"),children:[s.jsx("span",{className:"static-html-presentation-text-toolbar-color-label static-html-presentation-text-toolbar-color-label-fill",style:{"--static-html-toolbar-color":P},children:"A"}),s.jsx("input",{type:"color",value:P,onChange:y=>i({backgroundColor:y.target.value}),disabled:!e.editable})]}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-text-toolbar-button",onClick:()=>i({fontSize:Math.max(8,(c??24)-2)}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationFontSizeDecreaseAction"),children:"A-"}),s.jsx("button",{type:"button",className:"secondary-button static-html-presentation-text-toolbar-button",onClick:()=>i({fontSize:Math.min(160,(c??24)+2)}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationFontSizeIncreaseAction"),children:"A+"}),s.jsxs("select",{className:"static-html-presentation-text-toolbar-select static-html-presentation-text-toolbar-line-height",value:j,onChange:y=>i({lineHeight:y.target.value||null}),disabled:!e.editable,"aria-label":f("conversation.fileViewerPresentationLineHeightLabel"),children:[s.jsx("option",{value:"",children:f("conversation.fileViewerPresentationLineHeightAuto")}),s.jsx("option",{value:"1",children:"1.0"}),s.jsx("option",{value:"1.2",children:"1.2"}),s.jsx("option",{value:"1.4",children:"1.4"}),s.jsx("option",{value:"1.6",children:"1.6"}),s.jsx("option",{value:"1.8",children:"1.8"}),s.jsx("option",{value:"2",children:"2.0"})]})]})}),s.jsx("textarea",{hidden:!0,readOnly:!0,value:e.content.text??"","aria-hidden":"true",tabIndex:-1}),s.jsx(jo,{node:e,selectedRunIndex:t,onSelectedRunChange:n,disabled:!e.editable,onChange:o})]}):s.jsx("p",{className:"static-html-presentation-inspector-warning",children:e.lockedReason||f("conversation.fileViewerPresentationReadOnlyHint")})})})}function jo({node:e,selectedRunIndex:t,onSelectedRunChange:n,disabled:r,onChange:o}){const i=x.useMemo(()=>Lo(e),[e]),a=x.useMemo(()=>i.length?t!==null&&t>=0&&t<i.length?t:0:null,[i,t]);function c(h,p){const g=i.map((S,j)=>j===h?{...rn(S),text:Qe(p)}:rn(S));o({text:To(g),runs:g})}return s.jsx("div",{className:"static-html-presentation-textarea static-html-presentation-textarea-standalone static-html-presentation-runs-editor","data-testid":"static-html-presentation-runs-editor",role:"group","aria-label":f("conversation.fileViewerPresentationTextToolbar"),children:i.map((h,p)=>s.jsx("label",{className:h.className??void 0,"data-static-html-run":String(p),"data-static-html-run-wrapper":"true","data-active":a===p?"true":void 0,"data-static-html-run-text":h.text,children:s.jsx("textarea",{className:"static-html-presentation-run-input","data-static-html-run-input":"true",value:h.text,disabled:r,rows:1,spellCheck:!1,"aria-label":`${f("conversation.fileViewerPresentationNodeTextLabel")} ${p+1}`,onFocus:()=>n(p),onClick:()=>n(p),onChange:g=>{c(p,g.target.value)},style:zo(h.style??null)})},`${p}-${h.tagName??"text"}-${h.className??"none"}`))})}function tn(e){if(!e||!/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim()))return"#000000";const t=e.trim();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function Mo(e){return e?e==="bold"?"700":e:""}function nn(e,t){const n=Qe(t),r=Array.isArray(e.content.runs)?e.content.runs:[];if(r.length===0)return n?[{text:n}]:null;const o=r.map(a=>({...a})),i=Vo(o);return i<0?n?[{text:n}]:null:(o[i]={...o[i],text:n},o)}function Lo(e){if(Array.isArray(e.content.runs)&&e.content.runs.length>0)return e.content.runs.map(n=>({...n,style:n.style?{...n.style}:null}));const t=Qe(e.content.text??"");return t?[{text:t}]:[]}function To(e){return!e||e.length===0?"":Qe(e.map(t=>t.text).join(""))}function rn(e){return{...e,style:e.style?{...e.style}:null}}function Ao(e){if(e)return{fontFamily:e.fontFamily??void 0,fontSize:typeof e.fontSize=="number"?`${e.fontSize}px`:void 0,fontWeight:e.fontWeight??void 0,fontStyle:e.fontStyle??void 0,lineHeight:e.lineHeight??void 0,letterSpacing:e.letterSpacing??void 0,color:e.color??void 0,textDecoration:e.textDecoration??void 0,textDecorationColor:e.textDecorationColor??void 0,backgroundColor:e.backgroundColor??void 0,whiteSpace:"pre-wrap"}}function zo(e){return{...Ao(e),width:"100%",minHeight:"34px",padding:"6px 8px",border:"none",outline:"none",resize:"none",overflow:"hidden",background:"transparent"}}function Vo(e){let t=-1,n=-1;return e.forEach((r,o)=>{const i=r.text.trim().length;i>n&&(n=i,t=o)}),t}const lt="allow-forms allow-modals allow-scripts",Fo=`${lt} allow-same-origin`,$o=new Set(["abstract","as","async","await","break","case","catch","class","const","continue","default","delete","do","else","enum","export","extends","false","finally","for","from","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","readonly","return","static","super","switch","this","throw","true","try","type","typeof","undefined","var","void","while","with","yield"]),Wo=new Set(["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","False","finally","for","from","global","if","import","in","is","lambda","None","nonlocal","not","or","pass","raise","return","True","try","while","with","yield"]),Do=new Set(["case","do","done","elif","else","esac","export","fi","for","function","if","in","local","readonly","return","then","until","while"]),Ho=new Set(["add","alter","and","as","asc","between","by","create","delete","desc","drop","from","group","having","insert","into","join","left","like","limit","not","null","offset","on","or","order","right","select","set","table","union","update","values","where"]),Bo=new Set(["add","arg","cmd","copy","entrypoint","env","expose","from","healthcheck","label","maintainer","onbuild","run","shell","stopsignal","user","volume","workdir","as"]),Oo=new Set(["trace","debug","info","warn","warning","error","fatal"]);function Ki({workspaceId:e,filePath:t,open:n,onClose:r,onSaved:o,diffContent:i}){var Ae,Oe;const[a,c]=x.useState(null),[h,p]=x.useState(""),[g,S]=x.useState(null),[j,b]=x.useState(!1),[P,y]=x.useState(!1),[M,C]=x.useState(!1),[A,R]=x.useState(!1),[L,_]=x.useState("preview"),[Z,Pe]=x.useState("regular"),[ne,be]=x.useState(0),[we,W]=x.useState("fit"),[pe,I]=x.useState(1),[Y,re]=x.useState(1),[Le,me]=x.useState(110),[G,Ne]=x.useState(!0),{showToast:J}=sn(),de=ln(),We=x.useRef(r),De=x.useRef(J),Ee=x.useMemo(()=>qt(t),[t]),Q=x.useMemo(()=>$i(i),[i]),D=x.useMemo(()=>Wi(h,Q),[h,Q]),H=(a==null?void 0:a.kind)??null,ge=!!((Ae=a==null?void 0:a.capabilities)!=null&&Ae.canEdit),He=!!((Oe=a==null?void 0:a.capabilities)!=null&&Oe.canRefresh),B=Yo(H,Ee),ue=x.useMemo(()=>Go(a,de.isDesktop),[de.isDesktop,a]),Ce=x.useMemo(()=>Zo(a,de.isDesktop),[de.isDesktop,a]),Re=x.useMemo(()=>Ft(ue,ne),[ue,ne]),vt=x.useMemo(()=>Qo(ue,ne,Y,Le,G),[ue,ne,Y,Le,G]),Se=x.useMemo(()=>Ft(ue,ne),[ue,ne]),X=(a==null?void 0:a.content)??"",xe=x.useDeferredValue(h),m=x.useMemo(()=>H!=="html"||!g?null:cr({html:X,project:g}),[X,g,H]),$=ge&&(h!==X||L==="presentation"&&!!m&&m!==X),K=x.useMemo(()=>H!=="html"||!X.trim()?null:Ht(X,t??"document.html"),[X,t,H]),te=!!(K!=null&&K.supported),et=Fn(H),bt=Vt(H),oe=_o(H,Ee),ye=de.isMobile,wt=L==="presentation"&&H==="html",tt=!ye&&H==="html",nt=ye||tt?"full":Z;if(x.useEffect(()=>{We.current=r},[r]),x.useEffect(()=>{De.current=J},[J]),x.useEffect(()=>{if(!n){c(null),p(""),S(null),b(!1),y(!1),C(!1),R(!1),_(zn(t,null)),Vn({setResourceRefreshVersion:be,setImageScale:I,setImageScaleMode:W,setPdfPage:re,setPdfScale:me,setPdfFitWidth:Ne}),Pe("regular");return}if(!e||!t)return;const V=e,fe=t;let he=!1;async function Ie(){b(!0);try{const ae=await Et(V,fe);he||At(ae,fe,{preserveMode:!1,setPreview:c,setEditorContent:p,setPresentationProject:S,setMode:_,setResourceRefreshVersion:be,setImageScale:I,setImageScaleMode:W,setPdfPage:re,setPdfScale:me,setPdfFitWidth:Ne})}catch(ae){he||(De.current({title:st(ae,f("conversation.filePanelOpenFailed")),tone:"error"}),We.current())}finally{he||b(!1)}}return Ie(),()=>{he=!0}},[t,n,e]),!n||!t)return null;const ie=t,q=e;async function rt(){if(!(!q||!(a!=null&&a.version)||!ge)){y(!0);try{await Qn(q,ie,L==="presentation"&&g?m??h:h,a.version);const fe=await Et(q,ie);At(fe,ie,{preserveMode:!1,setPreview:c,setEditorContent:p,setPresentationProject:S,setMode:_,setResourceRefreshVersion:be,setImageScale:I,setImageScaleMode:W,setPdfPage:re,setPdfScale:me,setPdfFitWidth:Ne}),await o(ie),J({title:f("conversation.filePanelSaveSuccess"),tone:"success"})}catch(V){J({title:st(V,f("conversation.filePanelSaveFailed")),tone:"error"})}finally{y(!1)}}}async function Nt(){if(!(!q||!He||$)){b(!0);try{const V=await Et(q,ie);At(V,ie,{preserveMode:!0,setPreview:c,setEditorContent:p,setPresentationProject:S,setMode:_,setResourceRefreshVersion:be,setImageScale:I,setImageScaleMode:W,setPdfPage:re,setPdfScale:me,setPdfFitWidth:Ne}),be(fe=>fe+1)}catch(V){J({title:st(V,f("conversation.fileViewerRefreshFailed")),tone:"error"})}finally{b(!1)}}}async function St(){if(!Ce)return;const V=await de.bridge.openExternal(Ce);V.ok||J({title:V.detail??f("conversation.fileViewerOpenExternalFailed"),tone:"error"})}async function ee(){await Be("pdf")}async function It(){await Be("pptx")}async function Be(V){if(!q||H!=="html"||!te||(V==="pdf"?M:A))return;const he=L==="presentation"&&g?m??h:h;if(!he.trim()){J({title:V==="pdf"?f("conversation.fileViewerExportPdfMissingHtml"):f("conversation.fileViewerExportPptxMissingHtml"),tone:"error"});return}V==="pdf"?C(!0):R(!0);try{const Ie=await nr({workspaceId:q,path:ie,htmlContent:he,format:V}),ae=await zi(Ie.taskId);if(ae.status!=="succeeded")throw new Wt(500,{detail:ae.errorMessage??(V==="pdf"?f("conversation.fileViewerExportPdfFailed"):f("conversation.fileViewerExportPptxFailed")),error_code:"PRESENTATION_EXPORT_FAILED"});J({title:V==="pdf"?f("conversation.fileViewerExportPdfSuccess",{path:ae.outputPath??ie.replace(/\.[^.]+$/,".pdf")}):f("conversation.fileViewerExportPptxSuccess",{path:ae.outputPath??ie.replace(/\.[^.]+$/,".pptx")}),tone:"success"})}catch(Ie){J({title:st(Ie,V==="pdf"?f("conversation.fileViewerExportPdfFailed"):f("conversation.fileViewerExportPptxFailed")),tone:"error"})}finally{V==="pdf"?C(!1):R(!1)}}const je=Ko({canShowPresentationTab:te,canShowPreviewTab:et,canShowCodeTab:bt,canEdit:ge}),Te=qo({preview:a,canOpenExternal:!!Ce,canExportPdf:H==="html"&&te,canExportPptx:H==="html"&&te,exportingPdf:M,exportingPptx:A,isDirty:$,handleRefreshPreview:Nt,handleExportPdf:ee,handleExportPptx:It,handleOpenExternal:St,imageScaleMode:we,imageScale:pe,setImageScale:I,setImageScaleMode:W,pdfPage:Y,setPdfPage:re,pdfScale:Le,setPdfScale:me,pdfFitWidth:G,setPdfFitWidth:Ne}),kt=ye?Te.filter(Xo):Te;return s.jsxs(Jn,{open:n,title:t,size:nt,layout:"viewer",className:`file-viewer-modal${de.isDesktop&&nt!=="full"?" is-resizable":""}`,bodyClassName:"file-viewer-modal-body",onClose:r,children:[s.jsxs("div",{className:"file-viewer-toolbar",children:[s.jsxs("div",{className:"file-viewer-toolbar-start",children:[s.jsxs("div",{className:"file-viewer-tabs",role:"tablist","aria-label":f("conversation.fileViewerModeLabel"),children:[je.includes("presentation")?s.jsx("button",{type:"button",className:"file-viewer-tab","data-active":L==="presentation",role:"tab","aria-selected":L==="presentation",onClick:()=>_("presentation"),children:f("conversation.fileViewerPresentation")}):null,je.includes("preview")?s.jsx("button",{type:"button",className:"file-viewer-tab","data-active":L==="preview",role:"tab","aria-selected":L==="preview",onClick:()=>_("preview"),children:f("conversation.fileViewerPreview")}):null,je.includes("code")?s.jsx("button",{type:"button",className:"file-viewer-tab","data-active":L==="code",role:"tab","aria-selected":L==="code",onClick:()=>_("code"),children:f("conversation.fileViewerCode")}):null,je.includes("edit")?s.jsx("button",{type:"button",className:"file-viewer-tab","data-active":L==="edit",role:"tab","aria-selected":L==="edit",onClick:()=>_("edit"),disabled:!ge,children:f("conversation.fileViewerEdit")}):null]}),ye?null:s.jsx("span",{className:"file-viewer-language",children:B})]}),s.jsxs("div",{className:"file-viewer-toolbar-end",children:[!ye&&!tt?s.jsxs("div",{className:"file-viewer-size-group",role:"group","aria-label":f("conversation.fileViewerSizeLabel"),children:[s.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":Z==="regular",onClick:()=>Pe("regular"),children:f("conversation.fileViewerSizeDefault")}),s.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":Z==="full",onClick:()=>Pe("full"),children:f("conversation.fileViewerSizeFull")})]}):null,s.jsx("div",{className:"file-viewer-actions",children:kt.map(V=>s.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":V.active?"true":void 0,onClick:()=>void V.onClick(),disabled:V.disabled,children:V.label},V.id))}),ge&&!wt?s.jsx("button",{type:"button",className:"primary-button",onClick:()=>void rt(),disabled:!$||P,children:P?f("conversation.filePanelSaving"):f("conversation.filePanelSave")}):null]})]}),s.jsx("div",{className:"file-viewer-body",children:j?s.jsx("p",{className:"status-text",children:f("common.loading")}):(a==null?void 0:a.supported)===!1?s.jsx("p",{className:"status-text",children:a.reason??f("conversation.filePanelUnsupported")}):L==="presentation"&&H==="html"?s.jsx(ho,{filePath:t,html:h,baseHref:Se,onProjectChange:S,onSave:()=>void rt(),canSave:$,saving:P}):L==="edit"?s.jsx(ri,{content:h,deferredContent:xe,language:Ee,useInlineRenderedEditor:oe,onContentChange:p}):L==="preview"&&H==="html"?s.jsx(ti,{src:Se,filePath:t,overviewMarkers:Q,overviewTotalLines:D}):L==="preview"&&H==="image"?s.jsx(ai,{src:Re,filePath:t,scale:pe,scaleMode:we,overviewMarkers:Q,overviewTotalLines:D}):L==="preview"&&H==="pdf"?s.jsx(si,{src:vt,filePath:t,overviewMarkers:Q,overviewTotalLines:D}):L==="preview"&&H==="markdown"?s.jsx(li,{content:h,overviewMarkers:Q,overviewTotalLines:D}):s.jsx(fi,{content:h,language:Ee,overviewMarkers:Q,overviewTotalLines:D})})]})}function zn(e,t){return t==="markdown"||t==="html"||t==="image"||t==="pdf"||Li(e??"")||Ti(e??"")?"preview":"code"}function At(e,t,n){n.setPreview(e),n.setEditorContent(e.content??""),n.setPresentationProject(null),n.setMode(r=>n.preserveMode&&Uo(r,e.kind)?r:zn(t,e.kind)),Vn(n)}function Vn(e){e.setResourceRefreshVersion(0),e.setImageScale(1),e.setImageScaleMode("fit"),e.setPdfPage(1),e.setPdfScale(110),e.setPdfFitWidth(!0)}function Fn(e){return e==="markdown"||e==="html"||e==="image"||e==="pdf"}function Vt(e){return e==="text"||e==="markdown"||e==="html"}function Uo(e,t){return e==="presentation"?t==="html":e==="preview"?Fn(t):Vt(t)}function _o(e,t){return e==="text"&&Mi(t)}function Ko(e){const t=[];return e.canShowPresentationTab&&t.push("presentation"),e.canShowPreviewTab&&t.push("preview"),e.canShowCodeTab?(t.push("code"),t.push("edit")):e.canEdit&&t.push("edit"),t}function qo(e){var r,o;if(!((r=e.preview)!=null&&r.supported))return[];const t=[],n=!((o=e.preview.capabilities)!=null&&o.canRefresh)||e.isDirty;return e.preview.kind==="image"&&t.push({id:"image-zoom-out",label:f("conversation.fileViewerZoomOut"),onClick:()=>{e.setImageScaleMode("custom"),e.setImageScale(i=>Math.max(.25,on(i-.25)))}},{id:"image-zoom-in",label:f("conversation.fileViewerZoomIn"),onClick:()=>{e.setImageScaleMode("custom"),e.setImageScale(i=>Math.min(4,on(i+.25)))}},{id:"image-fit",label:f("conversation.fileViewerFit"),active:e.imageScaleMode==="fit",onClick:()=>{e.setImageScaleMode("fit"),e.setImageScale(1)}},{id:"image-actual",label:f("conversation.fileViewerActualSize"),active:e.imageScaleMode==="actual",onClick:()=>{e.setImageScaleMode("actual"),e.setImageScale(1)}},{id:"image-refresh",label:f("conversation.fileViewerRefreshPreview"),disabled:n,onClick:e.handleRefreshPreview}),e.preview.kind==="pdf"&&t.push({id:"pdf-prev-page",label:f("conversation.fileViewerPreviousPage"),disabled:e.pdfPage<=1,onClick:()=>e.setPdfPage(i=>Math.max(1,i-1))},{id:"pdf-page-indicator",label:f("conversation.fileViewerPageIndicator").replace("{page}",String(e.pdfPage)),disabled:!0,onClick:()=>{}},{id:"pdf-next-page",label:f("conversation.fileViewerNextPage"),onClick:()=>e.setPdfPage(i=>i+1)},{id:"pdf-zoom-out",label:f("conversation.fileViewerZoomOut"),onClick:()=>{e.setPdfFitWidth(!1),e.setPdfScale(i=>Math.max(50,Math.round(i-10)))}},{id:"pdf-zoom-in",label:f("conversation.fileViewerZoomIn"),onClick:()=>{e.setPdfFitWidth(!1),e.setPdfScale(i=>Math.min(300,Math.round(i+10)))}},{id:"pdf-fit-width",label:f("conversation.fileViewerFitWidth"),active:e.pdfFitWidth,onClick:()=>e.setPdfFitWidth(!0)},{id:"pdf-refresh",label:f("conversation.fileViewerRefreshPreview"),disabled:n,onClick:e.handleRefreshPreview}),(e.preview.kind==="html"||e.preview.kind==="markdown"||e.preview.kind==="text")&&t.push({id:"text-refresh",label:f("conversation.fileViewerRefreshPreview"),disabled:n,onClick:e.handleRefreshPreview}),e.preview.kind==="html"&&e.canExportPdf&&t.push({id:"presentation-export-pdf",label:e.exportingPdf?f("conversation.fileViewerExportPdfRunning"):f("conversation.fileViewerExportPdf"),disabled:e.exportingPdf,onClick:e.handleExportPdf}),e.preview.kind==="html"&&e.canExportPptx&&t.push({id:"presentation-export-pptx",label:e.exportingPptx?f("conversation.fileViewerExportPptxRunning"):f("conversation.fileViewerExportPptx"),disabled:e.exportingPptx,onClick:e.handleExportPptx}),e.canOpenExternal&&t.push({id:"open-external",label:f("conversation.fileViewerOpenExternal"),onClick:e.handleOpenExternal}),t}function Xo(e){return e.id.endsWith("-refresh")||e.id==="text-refresh"||e.id==="presentation-export-pdf"||e.id==="presentation-export-pptx"}function Yo(e,t){switch(e){case"image":return f("conversation.fileViewerImage");case"pdf":return f("conversation.fileViewerPdf");case"html":return f("conversation.fileViewerHtml");case"markdown":return"Markdown";default:return Xt(t)}}function Ft(e,t){if(!e)return null;const n=new URL(e,window.location.origin);return n.searchParams.set("_preview",String(t)),n.hash="",n.toString()}function Go(e,t){var n;return e?!t&&e.previewPath&&typeof window<"u"&&((n=window.location)!=null&&n.origin)?new URL(e.previewPath,window.location.origin).toString():e.previewUrl??null:null}function Zo(e,t){var n;if(!e)return null;if(e.previewPath){if(!t&&typeof window<"u"&&((n=window.location)!=null&&n.origin))return new URL(e.previewPath,window.location.origin).toString();if(t){const r=Jo(e.previewPath);if(r)return r}}return e.previewUrl??null}function Jo(e){try{const t=Yn(Gn()).baseUrl;return Zn(e,t)}catch{return null}}function Qo(e,t,n,r,o){const i=Ft(e,t);if(!i)return null;const a=new URL(i,window.location.origin),c=new URLSearchParams;return c.set("page",String(n)),c.set("zoom",o?"page-width":String(r)),a.hash=c.toString(),a.toString()}function ei(e){var t;if(typeof window>"u"||!((t=window.location)!=null&&t.origin))return lt;try{if(new URL(e,window.location.origin).origin!==window.location.origin)return Fo}catch{return lt}return lt}function on(e){return Math.round(e*100)/100}function ti({src:e,filePath:t,overviewMarkers:n,overviewTotalLines:r}){const o=x.useRef(null);if(!e)return s.jsx("p",{className:"status-text",children:f("conversation.fileViewerHtmlPreviewUnavailable")});const i=ei(e);return s.jsx(gt,{overviewMarkers:n,overviewTotalLines:r,scrollContainerRef:o,children:s.jsx("div",{className:"file-viewer-html-frame-shell",ref:o,children:s.jsx("iframe",{className:"file-viewer-html-frame","data-testid":"file-viewer-html-preview",title:t,src:e,sandbox:i},e)})})}function gt({children:e,overviewMarkers:t,overviewTotalLines:n,scrollContainerRef:r}){const o=ni(t);return s.jsxs("div",{className:"file-viewer-preview-overview-shell",children:[e,o?s.jsx("div",{className:"file-viewer-preview-diff-badge","data-kind":o,children:o==="modify"?f("conversation.fileViewerDiffModified"):f("conversation.fileViewerDiffAdded")}):null,s.jsx(On,{markers:t,totalLines:n,scrollContainerRef:r,hideWithoutMarkers:!0})]})}function ni(e){return e.some(t=>t.kind==="modify")?"modify":e.some(t=>t.kind==="add")?"add":null}function ri(e){return e.useInlineRenderedEditor?s.jsx(oi,{content:e.content,deferredContent:e.deferredContent,language:e.language,onContentChange:e.onContentChange}):s.jsx("textarea",{className:"file-viewer-editor","data-testid":"file-viewer-editor",value:e.content,onChange:t=>e.onContentChange(t.target.value),spellCheck:!1})}function oi(e){const t=x.useRef(null);function n(r){const o=t.current;o&&(o.scrollTop=r.currentTarget.scrollTop,o.scrollLeft=r.currentTarget.scrollLeft)}return s.jsxs("div",{className:"file-viewer-inline-editor-shell",children:[s.jsx("div",{ref:t,className:"file-viewer-inline-editor-render","data-testid":"file-viewer-inline-render","aria-hidden":"true",children:s.jsx(ii,{content:e.deferredContent,language:e.language})}),s.jsx("textarea",{className:"file-viewer-editor file-viewer-editor-input","data-testid":"file-viewer-editor",value:e.content,onChange:r=>e.onContentChange(r.target.value),onScroll:n,spellCheck:!1})]})}function ii({content:e,language:t}){const n=e.split(/\r?\n/);return s.jsx("div",{className:"file-viewer-inline-editor-content",children:n.map((r,o)=>{const i=Hn(r,t);return s.jsx("div",{className:"file-viewer-inline-editor-line",children:s.jsx("code",{className:"file-viewer-inline-editor-code",children:i.length?i.map((a,c)=>s.jsx("span",{className:`code-token ${a.kind}`,children:a.text},`${o}-${c}-${a.text}`)):s.jsx("span",{className:"code-token plain",children:" "})})},`${o}-${r}`)})})}function ai({src:e,filePath:t,scale:n,scaleMode:r,overviewMarkers:o,overviewTotalLines:i}){const a=x.useRef(null);return e?s.jsx(gt,{overviewMarkers:o,overviewTotalLines:i,scrollContainerRef:a,children:s.jsx("div",{className:"file-viewer-media-shell","data-mode":r,ref:a,children:s.jsx("div",{className:"file-viewer-image-stage",children:s.jsx("img",{className:"file-viewer-image","data-testid":"file-viewer-image-preview","data-mode":r,src:e,alt:t,style:r==="fit"?void 0:{transform:`scale(${n})`}})})})}):s.jsx("p",{className:"status-text",children:f("conversation.fileViewerImageUnavailable")})}function si({src:e,filePath:t,overviewMarkers:n,overviewTotalLines:r}){const o=x.useRef(null);return e?s.jsx(gt,{overviewMarkers:n,overviewTotalLines:r,scrollContainerRef:o,children:s.jsx("div",{className:"file-viewer-pdf-shell",ref:o,children:s.jsx("iframe",{className:"file-viewer-pdf-frame","data-testid":"file-viewer-pdf-preview",title:t,src:e},e)})}):s.jsx("p",{className:"status-text",children:f("conversation.fileViewerPdfUnavailable")})}function li({content:e,overviewMarkers:t,overviewTotalLines:n}){const r=x.useRef(null),o=x.useMemo(()=>ci(t),[t]),i=x.useMemo(()=>di(o),[o]);return s.jsx(gt,{overviewMarkers:t,overviewTotalLines:n,scrollContainerRef:r,children:s.jsx("div",{className:"markdown-content file-viewer-markdown",ref:r,children:s.jsx(er,{remarkPlugins:[tr],components:i,children:e})})})}function ci(e){return{ranges:e.map(t=>({start:t.line,end:t.line+t.span-1,kind:t.kind})).sort((t,n)=>t.start-n.start)}}function di(e){return{h1(t){const{node:n,className:r,...o}=t;return s.jsx("h1",{...o,className:ce(r,n,e)})},h2(t){const{node:n,className:r,...o}=t;return s.jsx("h2",{...o,className:ce(r,n,e)})},h3(t){const{node:n,className:r,...o}=t;return s.jsx("h3",{...o,className:ce(r,n,e)})},h4(t){const{node:n,className:r,...o}=t;return s.jsx("h4",{...o,className:ce(r,n,e)})},h5(t){const{node:n,className:r,...o}=t;return s.jsx("h5",{...o,className:ce(r,n,e)})},h6(t){const{node:n,className:r,...o}=t;return s.jsx("h6",{...o,className:ce(r,n,e)})},p(t){const{node:n,className:r,...o}=t;return s.jsx("p",{...o,className:ce(r,n,e)})},li(t){const{node:n,className:r,...o}=t;return s.jsx("li",{...o,className:ce(r,n,e)})},blockquote(t){const{node:n,className:r,...o}=t;return s.jsx("blockquote",{...o,className:ce(r,n,e)})},table(t){const{node:n,className:r,...o}=t;return s.jsx("table",{...o,className:ce(r,n,e)})},pre(t){const{node:n,className:r}=t,o=pi(t.children);return o?s.jsx(hi,{content:o.content,language:o.language,codeClassName:o.codeClassName,changeKind:$n(n,e)}):s.jsx("pre",{className:ce(r,n,e),children:t.children})},code(t){const n=typeof t.className=="string"?t.className:"";return s.jsx("code",{className:n||void 0,children:t.children})}}}function ce(e,t,n){const r=typeof e=="string"?e:"",o=$n(t,n);return Wn(r,o?"markdown-diff-block":null,o?`diff-block-${o}`:null)}function $n(e,t){var a,c,h,p;const n=(c=(a=e==null?void 0:e.position)==null?void 0:a.start)==null?void 0:c.line,r=(p=(h=e==null?void 0:e.position)==null?void 0:h.end)==null?void 0:p.line;if(!n||!r)return null;let o=!1;const i=ui(t.ranges,n);for(let g=i;g<t.ranges.length;g+=1){const S=t.ranges[g];if(!S||S.start>r)break;if(S.end>=n){if(S.kind==="modify")return"modify";o=!0}}return o?"add":null}function ui(e,t){let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2),i=e[o];i&&i.end<t?n=o+1:r=o}return n}function fi({content:e,language:t,overviewMarkers:n=[],overviewTotalLines:r}){const o=e.split(/\r?\n/),i=x.useRef(null),a=x.useMemo(()=>{const c=new Map;for(const h of n)for(let p=0;p<h.span;p++)c.set(h.line+p,h.kind);return c},[n]);return s.jsxs("div",{className:"file-viewer-code-block",children:[s.jsxs("div",{className:"file-viewer-code-header",children:[s.jsx("span",{className:"file-viewer-code-header-label",children:Xt(t)}),s.jsx(Dn,{content:e})]}),s.jsxs("div",{className:"file-viewer-scroll-shell",children:[s.jsx("div",{className:"file-viewer-code-body",ref:i,children:o.map((c,h)=>{const p=Hn(c,t),g=h+1,S=a.get(g);return s.jsxs("div",{className:`file-viewer-code-line${S?` diff-line-${S}`:""}`,children:[s.jsx("span",{className:"file-viewer-code-gutter",children:g}),s.jsx("code",{className:"file-viewer-code-content",children:p.length?p.map((j,b)=>s.jsx("span",{className:`code-token ${j.kind}`,children:j.text},`${h}-${b}-${j.text}`)):s.jsx("span",{className:"code-token plain",children:" "})})]},`${h}-${c}`)})}),s.jsx(On,{markers:n,totalLines:r,scrollContainerRef:i})]})]})}function hi({content:e,language:t,codeClassName:n,changeKind:r=null}){const o=t?yt(t):null;return s.jsxs("div",{className:Wn("file-viewer-markdown-copy-block",r?"markdown-diff-block":null,r?`diff-block-${r}`:null),children:[s.jsxs("div",{className:"file-viewer-markdown-copy-header",children:[s.jsx("span",{className:"file-viewer-markdown-copy-label",children:o?Xt(o):f("conversation.fileViewerPlainText")}),s.jsx(Dn,{content:e})]}),s.jsx("pre",{className:n,children:s.jsx("code",{children:e})})]})}function Wn(...e){return e.filter(Boolean).join(" ")||void 0}function Dn({content:e}){const{showToast:t}=sn(),n=ln(),[r,o]=x.useState(!1);if(!e.trim())return null;async function i(){if(!r){o(!0);try{await gi(e,n),t({title:f("conversation.copyContentSuccess"),tone:"success"})}catch(a){t({title:a instanceof Error?a.message:f("conversation.copyContentFailed"),tone:"error"})}finally{o(!1)}}}return s.jsx("button",{type:"button",className:"file-viewer-copy-button","aria-label":f("conversation.copyAction"),title:f("conversation.copyAction"),onClick:()=>void i(),disabled:r,children:s.jsx(Ai,{})})}function $t(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>$t(n)).join(""):x.isValidElement(e)?$t(((t=e.props)==null?void 0:t.children)??""):""}function pi(e){const t=Array.isArray(e)?e[0]:e;if(!x.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",o=/language-([^\s]+)/.exec(r);return{content:$t(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(o==null?void 0:o[1])??null}}function mi(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function gi(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!mi(e))throw new Error(f("conversation.copyContentFailed"))}}function Hn(e,t){const n=yt(t);return n==="json"?xi(e):n==="yaml"?wi(e):n==="toml"?Ni(e):n==="ini"?Bn(e):n==="env"?Si(e):n==="properties"?Ii(e):n==="conf"?ki(e):n==="editorconfig"?Pi(e):n==="dockerfile"?Ei(e):n==="gitignore"?Ci(e):n==="log"?Ri(e):n==="python"?Ze(e,Wo,"#"):n==="shell"?Ze(e,Do,"#"):n==="sql"?bi(e):n==="html"||n==="xml"?yi(e):n==="css"?vi(e):n==="markdown"?[{text:e,kind:"plain"}]:Ze(e,$o,"//")}function Ze(e,t,n){const r=[];let o=0;for(;o<e.length;){const i=e.slice(o);if(i.startsWith(n)){r.push({text:i,kind:"comment"});break}const a=/^(?:'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"|`[^`\\]*(?:\\.[^`\\]*)*`)/.exec(i);if(a){r.push({text:a[0],kind:"string"}),o+=a[0].length;continue}const c=/^(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/.exec(i);if(c){r.push({text:c[0],kind:"number"}),o+=c[0].length;continue}const h=/^[A-Za-z_][\w$-]*/.exec(i);if(h){const g=h[0],S=g.toLowerCase();g==="true"||g==="false"||S==="true"||S==="false"?r.push({text:g,kind:"boolean"}):g==="null"||g==="None"||S==="none"?r.push({text:g,kind:"null"}):t.has(g)||t.has(S)?r.push({text:g,kind:"keyword"}):r.push({text:g,kind:"plain"}),o+=g.length;continue}const p=/^(?:===|!==|==|!=|<=|>=|=>|&&|\|\||[+\-*/%=<>!?:|&^~]+)/.exec(i);if(p){r.push({text:p[0],kind:"operator"}),o+=p[0].length;continue}r.push({text:i[0]??"",kind:"plain"}),o+=1}return r}function xi(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n),o=/^"(?:[^"\\]|\\.)*"/.exec(r);if(o){const h=e.slice(n+o[0].length).trimStart()[0];t.push({text:o[0],kind:h===":"?"attr":"string"}),n+=o[0].length;continue}const i=/^(?:-?\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i.exec(r);if(i){t.push({text:i[0],kind:"number"}),n+=i[0].length;continue}const a=/^(?:true|false|null)\b/.exec(r);if(a){const h=a[0]==="null"?"null":"boolean";t.push({text:a[0],kind:h}),n+=a[0].length;continue}const c=/^(?::|,|\{|\}|\[|\])/.exec(r);if(c){t.push({text:c[0],kind:"operator"}),n+=c[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function yi(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n);if(r.startsWith("<!--")){t.push({text:r,kind:"comment"});break}const o=/^(<\/?[\w:-]+)/.exec(r);if(o){t.push({text:o[0],kind:"tag"}),n+=o[0].length;continue}const i=/^([\w:-]+)(=)/.exec(r);if(i){t.push({text:i[1]??"",kind:"attr"}),t.push({text:i[2]??"",kind:"operator"}),n+=i[0].length;continue}const a=/^(?:'[^']*'|"[^"]*")/.exec(r);if(a){t.push({text:a[0],kind:"string"}),n+=a[0].length;continue}const c=/^(?:\/?>)/.exec(r);if(c){t.push({text:c[0],kind:"operator"}),n+=c[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function vi(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n);if(r.startsWith("/*")){t.push({text:r,kind:"comment"});break}const o=/^(?:'[^']*'|"[^"]*")/.exec(r);if(o){t.push({text:o[0],kind:"string"}),n+=o[0].length;continue}const i=/^([A-Za-z-]+)(\s*:)/.exec(r);if(i){t.push({text:i[1]??"",kind:"attr"}),t.push({text:i[2]??"",kind:"operator"}),n+=i[0].length;continue}const a=/^(?:#(?:[\da-fA-F]{3,8})|\d+(?:\.\d+)?(?:px|rem|em|vh|vw|%)?)/.exec(r);if(a){t.push({text:a[0],kind:"number"}),n+=a[0].length;continue}const c=/^(?:@media|@supports|@import|@keyframes)\b/.exec(r);if(c){t.push({text:c[0],kind:"keyword"}),n+=c[0].length;continue}const h=/^(?:[{}:;(),.>])/.exec(r);if(h){t.push({text:h[0],kind:"operator"}),n+=h[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function bi(e){return Ze(e,Ho,"--")}function wi(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n);if(r.startsWith("#")){t.push({text:r,kind:"comment"});break}const o=/^([A-Za-z0-9_.-]+)(\s*:)/.exec(r);if(o){t.push({text:o[1]??"",kind:"attr"}),t.push({text:o[2]??"",kind:"operator"}),n+=o[0].length;continue}const i=/^(?:'[^']*'|"[^"]*")/.exec(r);if(i){t.push({text:i[0],kind:"string"}),n+=i[0].length;continue}const a=/^(?:-?\d+(?:\.\d+)?)/.exec(r);if(a){t.push({text:a[0],kind:"number"}),n+=a[0].length;continue}const c=/^(?:true|false|yes|no|null|~)\b/i.exec(r);if(c){const p=c[0].toLowerCase(),g=p==="null"||p==="~"?"null":"boolean";t.push({text:c[0],kind:g}),n+=c[0].length;continue}const h=/^(?:[-?:,[\]{}|>])/.exec(r);if(h){t.push({text:h[0],kind:"operator"}),n+=h[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function Ni(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n);if(r.startsWith("#")){t.push({text:r,kind:"comment"});break}const o=/^(\[\[?[^\]]+\]?\])/.exec(r);if(o){t.push({text:o[0],kind:"tag"}),n+=o[0].length;continue}const i=/^([A-Za-z0-9_.-]+)(\s*=)/.exec(r);if(i){t.push({text:i[1]??"",kind:"attr"}),t.push({text:i[2]??"",kind:"operator"}),n+=i[0].length;continue}const a=xt(r,{trueValues:["true"],falseValues:["false"],nullValues:[]});if(a){t.push(...a.tokens),n+=a.length;continue}const c=/^(?:[,[\]{}])/.exec(r);if(c){t.push({text:c[0],kind:"operator"}),n+=c[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function Bn(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n),o=r.trimStart();if(o.startsWith(";")||o.startsWith("#")){t.push({text:r,kind:"comment"});break}const i=/^(\[[^\]]+\])/.exec(r);if(i){t.push({text:i[0],kind:"tag"}),n+=i[0].length;continue}const a=/^([A-Za-z0-9_.-]+)(\s*[=:])/.exec(r);if(a){t.push({text:a[1]??"",kind:"attr"}),t.push({text:a[2]??"",kind:"operator"}),n+=a[0].length;continue}const c=xt(r,{trueValues:["true","yes","on"],falseValues:["false","no","off"],nullValues:["null"]});if(c){t.push(...c.tokens),n+=c.length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function Si(e){if(e.trimStart().startsWith("#"))return[{text:e,kind:"comment"}];const n=/^(\s*)(export)(\s+)/.exec(e),r=n?n[0].length:0,o=[];n&&(o.push({text:n[1]??"",kind:"plain"}),o.push({text:n[2]??"",kind:"keyword"}),o.push({text:n[3]??"",kind:"plain"}));const i=e.slice(r),a=/^([A-Za-z_][A-Za-z0-9_]*)(=)/.exec(i);if(!a)return Bn(e);o.push({text:a[1]??"",kind:"attr"}),o.push({text:a[2]??"",kind:"operator"});const c=i.slice(a[0].length),h=xt(c,{trueValues:["true"],falseValues:["false"],nullValues:["null"]});return h?(o.push(...h.tokens),o):(o.push({text:c,kind:"plain"}),o)}function Ii(e){return Kt(e,{commentPrefixes:["#","!"],allowSection:!1,delimiters:["=",":"]})}function ki(e){return Kt(e,{commentPrefixes:["#",";"],allowSection:!0,delimiters:["=",":"]})}function Pi(e){return Kt(e,{commentPrefixes:["#",";"],allowSection:!0,delimiters:["="]})}function Ei(e){return Ze(e,Bo,"#")}function Ci(e){const t=e.trimStart();if(!t)return[];if(t.startsWith("#"))return[{text:e,kind:"comment"}];if(t.startsWith("!")){const n=e.length-t.length,r=e.slice(0,n),o=t.slice(1);return[{text:r,kind:"plain"},{text:"!",kind:"operator"},{text:o,kind:"string"}]}return[{text:e,kind:"string"}]}function Ri(e){const t=[];let n=0;for(;n<e.length;){const r=e.slice(n);if(r.startsWith("#")){t.push({text:r,kind:"comment"});break}const o=/^(?:\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:[.,]\d{3,6})?(?:Z|[+-]\d{2}:\d{2})?)/.exec(r);if(o){t.push({text:o[0],kind:"tag"}),n+=o[0].length;continue}const i=/^(?:\[(TRACE|DEBUG|INFO|WARN|WARNING|ERROR|FATAL)\])/.exec(r);if(i){t.push({text:r.slice(0,i[0].length),kind:"keyword"}),n+=i[0].length;continue}const a=/^[A-Za-z_][\w-]*/.exec(r);if(a){const h=a[0];Oo.has(h.toLowerCase())?t.push({text:h,kind:"keyword"}):t.push({text:h,kind:"plain"}),n+=h.length;continue}const c=/^(?:\d+(?:\.\d+)?)/.exec(r);if(c){t.push({text:c[0],kind:"number"}),n+=c[0].length;continue}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function Kt(e,t){const n=e.trimStart();if(t.commentPrefixes.some(h=>n.startsWith(h)))return[{text:e,kind:"comment"}];if(t.allowSection){const h=/^(\[[^\]]+\])/.exec(e);if(h)return[{text:h[0],kind:"tag"}]}const r=/^([A-Za-z0-9_.\-*?]+)(\s*(?:=|:))/.exec(e);if(!r)return[{text:e,kind:"plain"}];const o=(r[2]??"").trim();if(!t.delimiters.includes(o))return[{text:e,kind:"plain"}];const i=[{text:r[1]??"",kind:"attr"},{text:r[2]??"",kind:"operator"}],a=e.slice(r[0].length),c=ji(a);return c.length&&i.push(...c),i}function ji(e){if(!e)return[];const t=[];let n=0;for(;n<e.length;){const r=e.slice(n),o=xt(r,{trueValues:["true","yes","on"],falseValues:["false","no","off"],nullValues:["null"]});if(o){t.push(...o.tokens),n+=o.length;continue}if(r.startsWith("#")||r.startsWith(";")){t.push({text:r,kind:"comment"});break}t.push({text:r[0]??"",kind:"plain"}),n+=1}return t}function xt(e,t){const n=/^(?:'[^']*'|"[^"]*")/.exec(e);if(n)return{tokens:[{text:n[0],kind:"string"}],length:n[0].length};const r=/^(?:-?\d+(?:\.\d+)?)/.exec(e);if(r)return{tokens:[{text:r[0],kind:"number"}],length:r[0].length};const o=/^[A-Za-z0-9_.:+/-]+/.exec(e);if(!o)return null;const i=o[0],a=i.toLowerCase();return t.trueValues.includes(a)?{tokens:[{text:i,kind:"boolean"}],length:i.length}:t.falseValues.includes(a)?{tokens:[{text:i,kind:"boolean"}],length:i.length}:t.nullValues.includes(a)?{tokens:[{text:i,kind:"null"}],length:i.length}:{tokens:[{text:i,kind:"plain"}],length:i.length}}function qt(e){var r,o;if(!e)return"plain";const t=((r=e.split(/[\\/]/).pop())==null?void 0:r.toLowerCase())??"";if(t===".env"||t.startsWith(".env."))return"env";if(t===".editorconfig")return"editorconfig";if(t==="dockerfile"||t.endsWith(".dockerfile"))return"dockerfile";if(t===".gitignore")return"gitignore";switch(((o=e.split(".").pop())==null?void 0:o.toLowerCase())??""){case"md":case"markdown":return"markdown";case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"log":return"log";case"properties":return"properties";case"toml":return"toml";case"ini":return"ini";case"conf":return"conf";case"dockerfile":return"dockerfile";case"css":case"scss":case"less":return"css";case"html":case"htm":return"html";case"xml":case"svg":return"xml";case"py":return"python";case"sh":case"bash":case"zsh":return"shell";case"sql":return"sql";case"yml":case"yaml":return"yaml";case"rs":return"rust";case"go":return"go";case"java":return"java";case"c":case"h":case"cpp":case"cc":case"hpp":return"cpp";default:return"plain"}}function yt(e){const t=e.toLowerCase();switch(t){case"ts":case"tsx":case"typescript":return"typescript";case"js":case"jsx":case"javascript":return"javascript";case"bash":case"shell":case"sh":case"zsh":return"shell";case"md":case"markdown":return"markdown";case"properties":return"properties";case"toml":return"toml";case"ini":return"ini";case"env":return"env";case"conf":return"conf";case"editorconfig":return"editorconfig";case"dockerfile":return"dockerfile";case"gitignore":return"gitignore";case"log":return"log";default:return t}}function Mi(e){const t=yt(e);return t==="json"||t==="yaml"||t==="toml"||t==="ini"||t==="env"||t==="properties"||t==="conf"||t==="editorconfig"||t==="dockerfile"||t==="gitignore"}function Xt(e){switch(yt(e)){case"typescript":return"TypeScript";case"javascript":return"JavaScript";case"markdown":return"Markdown";case"json":return"JSON";case"properties":return"Properties";case"toml":return"TOML";case"ini":return"INI";case"env":return"ENV";case"conf":return"CONF";case"editorconfig":return"EditorConfig";case"dockerfile":return"Dockerfile";case"gitignore":return"GitIgnore";case"log":return"Log";case"css":return"CSS";case"html":return"HTML";case"xml":return"XML";case"python":return"Python";case"shell":return"Shell";case"sql":return"SQL";case"yaml":return"YAML";case"rust":return"Rust";case"go":return"Go";case"java":return"Java";case"cpp":return"C/C++";default:return f("conversation.fileViewerPlainText")}}function Li(e){return qt(e)==="markdown"}function Ti(e){return qt(e)==="html"}function Ai(){return s.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[s.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function st(e,t){return e instanceof Wt?e.message:t}async function zi(e){const t=Date.now();for(;Date.now()-t<6e4;){const n=await rr(e);if(n.status==="queued"||n.status==="running"){await Vi(800);continue}return n}throw new Wt(408,{detail:f("conversation.fileViewerExportTaskTimeout"),error_code:"PRESENTATION_EXPORT_TIMEOUT"})}function Vi(e){return new Promise(t=>{window.setTimeout(t,e)})}function Fi(e){const t=[],n=e.replace(/\r\n/g,`
|
|
589
|
-
`).split(`
|
|
590
|
-
`);let r=0,o=0;for(const i of n){if(i.startsWith("diff --git")||i.startsWith("index ")||i.startsWith("--- ")||i.startsWith("+++ ")){t.push({kind:"meta",text:i,oldLineNo:null,newLineNo:null});continue}const a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(i);if(a){r=parseInt(a[1],10),o=parseInt(a[2],10),t.push({kind:"hunk",text:i,oldLineNo:null,newLineNo:null});continue}if(i.startsWith(" ")||i===""){t.push({kind:"context",text:i.slice(1),oldLineNo:r,newLineNo:o}),r++,o++;continue}if(i.startsWith("+")){t.push({kind:"add",text:i.slice(1),oldLineNo:null,newLineNo:o}),o++;continue}if(i.startsWith("-")){t.push({kind:"remove",text:i.slice(1),oldLineNo:r,newLineNo:null}),r++;continue}t.push({kind:"meta",text:i,oldLineNo:null,newLineNo:null})}return t}function $i(e){if(!(e!=null&&e.trim()))return[];const t=Fi(e),n=[];let r=0,o=[];function i(){if(o.length===0){r=0;return}const a=r>0?"modify":"add";Di(n,o,a),r=0,o=[]}for(const a of t){if(a.kind==="remove"){r+=1;continue}if(a.kind==="add"){a.newLineNo!==null&&o.push(a.newLineNo);continue}i()}return i(),n}function Wi(e,t){const n=e?e.split(/\r?\n/).length:1,r=t.reduce((o,i)=>Math.max(o,i.line+i.span-1),0);return Math.max(n,r,1)}function Di(e,t,n){const r=t.filter(a=>a>0);if(r.length===0)return;let o=r[0]??1,i=o;for(let a=1;a<r.length;a+=1){const c=r[a]??i;if(c===i+1){i=c;continue}e.push({line:o,span:i-o+1,kind:n}),o=c,i=c}e.push({line:o,span:i-o+1,kind:n})}function On({markers:e,totalLines:t,scrollContainerRef:n,hideWithoutMarkers:r=!1}){const o=x.useRef(null),i=!r||e.length>0;if(x.useEffect(()=>{const c=n.current,h=o.current;if(!c||!h||!i)return;const p=c,g=h;let S=null;function j(){S=null;const{clientHeight:P,scrollHeight:y,scrollTop:M}=p;if(y<=0||P<=0||y<=P){g.style.display="none";return}const C=P/y,A=Math.min(100,Math.max(12,C*100)),R=y-P,L=Math.max(0,100-A),_=R<=0?0:M/R*L;g.style.display="block",g.style.top=`${_}%`,g.style.height=`${A}%`}function b(){S===null&&(S=window.requestAnimationFrame(j))}return j(),p.addEventListener("scroll",b,{passive:!0}),window.addEventListener("resize",b),()=>{S!==null&&window.cancelAnimationFrame(S),p.removeEventListener("scroll",b),window.removeEventListener("resize",b)}},[n,i]),r&&e.length===0)return null;const a=Math.max(t,1);return s.jsxs("div",{className:"file-overview-ruler","data-testid":"file-overview-ruler","aria-hidden":"true",children:[e.map(c=>{const h=(c.line-1)/a*100,p=Math.max(2,c.span/a*100);return s.jsx("div",{className:`file-overview-marker is-${c.kind}`,"data-kind":c.kind,style:{top:`${h}%`,height:`${p}%`}},`${c.kind}-${c.line}-${c.span}`)}),i?s.jsx("div",{ref:o,className:"file-overview-viewport"}):null]})}function qi(e){const t=e.toLowerCase();if(t===".env"||t.startsWith(".env."))return"ENV";if(t.endsWith(".d.ts"))return"DTS";switch(t.includes(".")?t.slice(t.lastIndexOf(".")+1):""){case"ts":return"TS";case"tsx":return"TSX";case"js":return"JS";case"jsx":return"JSX";case"json":return"{}";case"md":return"MD";case"css":return"CSS";case"scss":return"SASS";case"html":return"HTML";case"yml":case"yaml":return"YAML";case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return"IMG";case"txt":return"TXT";default:return"FILE"}}function Xi(e){const t=e.toLowerCase();return t===".env"||t.startsWith(".env.")?"env":t.endsWith(".md")?"md":t.endsWith(".css")||t.endsWith(".scss")?"style":t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".gif")||t.endsWith(".svg")||t.endsWith(".webp")?"image":t.endsWith(".ts")||t.endsWith(".tsx")||t.endsWith(".js")||t.endsWith(".jsx")?"code":t.endsWith(".json")||t.endsWith(".yml")||t.endsWith(".yaml")?"data":"default"}export{Ki as F,Xi as a,qi as r};
|