@btst/stack 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -37
- package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +4 -4
- package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs +4 -4
- package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs +282 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs +247 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +3 -3
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.mjs +3 -3
- package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.cjs +845 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.mjs +799 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.cjs +7 -7
- package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.mjs +7 -7
- package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.cjs +147 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.mjs +131 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.cjs +244 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.mjs +224 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.cjs +742 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.mjs +719 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.cjs +17 -17
- package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.mjs +17 -17
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.cjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.mjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.mjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.cjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.mjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.cjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.mjs +1 -1
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +9 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/sidecar.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.cjs +610 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.mjs +608 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.cjs +221 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.mjs +219 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.cjs +315 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.mjs +313 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.cjs +122 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.mjs +120 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.cjs +397 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs +391 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +227 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +225 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.cjs +31 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.mjs +29 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.cjs +11 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.mjs +8 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +18 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +16 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +39 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +22 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +20 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +37 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +18 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +16 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.cjs +26 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.mjs +24 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +199 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +191 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.cjs +63 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.mjs +61 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.cjs +14 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.mjs +11 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.cjs +241 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.mjs +239 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/db.cjs +65 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/db.mjs +63 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/schemas.cjs +42 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/schemas.mjs +38 -0
- package/dist/packages/better-stack/src/plugins/blog/api/plugin.cjs +8 -2
- package/dist/packages/better-stack/src/plugins/blog/api/plugin.mjs +8 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.cjs +12 -309
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.mjs +13 -303
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/on-this-page.cjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/on-this-page.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -2
- package/dist/packages/ui/src/components/alert-dialog.cjs +1 -1
- package/dist/packages/ui/src/components/alert-dialog.mjs +1 -1
- package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.cjs → ui/src/components/better-stack-attribution.cjs} +3 -3
- package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.mjs → ui/src/components/better-stack-attribution.mjs} +3 -3
- package/dist/packages/ui/src/components/dialog.cjs +14 -0
- package/dist/packages/ui/src/components/dialog.mjs +14 -1
- package/dist/packages/ui/src/components/dropdown-menu.cjs +67 -0
- package/dist/packages/ui/src/components/dropdown-menu.mjs +62 -0
- package/dist/packages/ui/src/components/markdown-content.cjs +306 -0
- package/dist/packages/ui/src/components/markdown-content.mjs +297 -0
- package/dist/packages/ui/src/components/scroll-area.cjs +63 -0
- package/dist/packages/ui/src/components/scroll-area.mjs +60 -0
- package/dist/packages/ui/src/components/select.cjs +1 -1
- package/dist/packages/ui/src/components/select.mjs +1 -1
- package/dist/packages/ui/src/components/sheet.cjs +87 -0
- package/dist/packages/ui/src/components/sheet.mjs +69 -0
- package/dist/plugins/ai-chat/api/index.cjs +9 -0
- package/dist/plugins/ai-chat/api/index.d.cts +9 -0
- package/dist/plugins/ai-chat/api/index.d.mts +9 -0
- package/dist/plugins/ai-chat/api/index.d.ts +9 -0
- package/dist/plugins/ai-chat/api/index.mjs +2 -0
- package/dist/plugins/ai-chat/client/components/index.cjs +27 -0
- package/dist/plugins/ai-chat/client/components/index.d.cts +30 -0
- package/dist/plugins/ai-chat/client/components/index.d.mts +30 -0
- package/dist/plugins/ai-chat/client/components/index.d.ts +30 -0
- package/dist/plugins/ai-chat/client/components/index.mjs +11 -0
- package/dist/plugins/ai-chat/client/hooks/index.cjs +13 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/index.cjs +19 -0
- package/dist/plugins/ai-chat/client/index.d.cts +327 -0
- package/dist/plugins/ai-chat/client/index.d.mts +327 -0
- package/dist/plugins/ai-chat/client/index.d.ts +327 -0
- package/dist/plugins/ai-chat/client/index.mjs +7 -0
- package/dist/plugins/ai-chat/client.css +6 -0
- package/dist/plugins/ai-chat/query-keys.cjs +60 -0
- package/dist/plugins/ai-chat/query-keys.d.cts +478 -0
- package/dist/plugins/ai-chat/query-keys.d.mts +478 -0
- package/dist/plugins/ai-chat/query-keys.d.ts +478 -0
- package/dist/plugins/ai-chat/query-keys.mjs +58 -0
- package/dist/plugins/ai-chat/style.css +19 -0
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +85 -62
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/shared/stack.Be1QIHEn.d.cts +23 -0
- package/dist/shared/stack.Be1QIHEn.d.mts +23 -0
- package/dist/shared/stack.Be1QIHEn.d.ts +23 -0
- package/dist/shared/stack.DorMi9CZ.d.cts +80 -0
- package/dist/shared/stack.DorMi9CZ.d.mts +80 -0
- package/dist/shared/stack.DorMi9CZ.d.ts +80 -0
- package/package.json +61 -3
- package/src/plugins/ai-chat/api/index.ts +2 -0
- package/src/plugins/ai-chat/api/plugin.ts +1083 -0
- package/src/plugins/ai-chat/client/components/chat-input.tsx +295 -0
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +455 -0
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +160 -0
- package/src/plugins/ai-chat/client/components/chat-message.tsx +505 -0
- package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +296 -0
- package/src/plugins/ai-chat/client/components/index.ts +16 -0
- package/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.tsx +57 -0
- package/src/plugins/ai-chat/client/components/loading/index.tsx +11 -0
- package/src/plugins/ai-chat/client/components/pages/404-page.tsx +27 -0
- package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +31 -0
- package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +46 -0
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +28 -0
- package/src/plugins/ai-chat/client/components/shared/error-placeholder.tsx +22 -0
- package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +349 -0
- package/src/plugins/ai-chat/client/hooks/index.tsx +1 -0
- package/src/plugins/ai-chat/client/index.ts +14 -0
- package/src/plugins/ai-chat/client/localization/index.ts +156 -0
- package/src/plugins/ai-chat/client/overrides.ts +170 -0
- package/src/plugins/ai-chat/client/plugin.tsx +449 -0
- package/src/plugins/ai-chat/client.css +6 -0
- package/src/plugins/ai-chat/db.ts +65 -0
- package/src/plugins/ai-chat/query-keys.ts +87 -0
- package/src/plugins/ai-chat/schemas.ts +40 -0
- package/src/plugins/ai-chat/style.css +19 -0
- package/src/plugins/ai-chat/types.ts +29 -0
- package/src/plugins/blog/api/plugin.ts +10 -4
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +1 -1
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +85 -62
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +19 -427
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +1 -1
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -2
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -2
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +0 -9
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +0 -19
- package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.mjs +0 -0
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const utils = require('../lib/utils.cjs');
|
|
6
|
+
const React = require('react');
|
|
7
|
+
const ReactMarkdown = require('react-markdown');
|
|
8
|
+
const rehypeHighlight = require('rehype-highlight');
|
|
9
|
+
const rehypeRaw = require('rehype-raw');
|
|
10
|
+
const remarkGfm = require('remark-gfm');
|
|
11
|
+
const lucideReact = require('lucide-react');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
14
|
+
|
|
15
|
+
const ReactMarkdown__default = /*#__PURE__*/_interopDefaultCompat(ReactMarkdown);
|
|
16
|
+
const rehypeHighlight__default = /*#__PURE__*/_interopDefaultCompat(rehypeHighlight);
|
|
17
|
+
const rehypeRaw__default = /*#__PURE__*/_interopDefaultCompat(rehypeRaw);
|
|
18
|
+
const remarkGfm__default = /*#__PURE__*/_interopDefaultCompat(remarkGfm);
|
|
19
|
+
|
|
20
|
+
const DefaultLink = (props) => {
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { ...props });
|
|
22
|
+
};
|
|
23
|
+
const DefaultImage = (props) => {
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx("img", { ...props });
|
|
25
|
+
};
|
|
26
|
+
function containsMath(markdown) {
|
|
27
|
+
return /\$\$[\s\S]+?\$\$/.test(markdown) || // Display math
|
|
28
|
+
/(?<!\$)\$(?!\$)[^\$\n]+?\$(?!\$)/.test(markdown) || // Inline math (not $$)
|
|
29
|
+
/\\begin\{(equation|align|gather|math)\}/.test(markdown);
|
|
30
|
+
}
|
|
31
|
+
function slugify(text) {
|
|
32
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
33
|
+
}
|
|
34
|
+
function getNodeText(node) {
|
|
35
|
+
if (node == null) return "";
|
|
36
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
37
|
+
if (Array.isArray(node)) return node.map(getNodeText).join("");
|
|
38
|
+
if (React.isValidElement(node)) {
|
|
39
|
+
const props = node.props;
|
|
40
|
+
return getNodeText(props.children);
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
function simpleHash(str) {
|
|
45
|
+
let hash = 0;
|
|
46
|
+
for (let i = 0; i < str.length; i++) {
|
|
47
|
+
const char = str.charCodeAt(i);
|
|
48
|
+
hash = (hash << 5) - hash + char;
|
|
49
|
+
hash = hash & hash;
|
|
50
|
+
}
|
|
51
|
+
return Math.abs(hash).toString(36).slice(0, 6);
|
|
52
|
+
}
|
|
53
|
+
function isCheckboxElement(node) {
|
|
54
|
+
return React.isValidElement(node) && node.type === "input" && node.props.type === "checkbox";
|
|
55
|
+
}
|
|
56
|
+
function createTaskListItemRenderer() {
|
|
57
|
+
return function LiRenderer(props) {
|
|
58
|
+
const { className, children, ...rest } = props;
|
|
59
|
+
const isTaskItem = (className ?? "").split(" ").includes("task-list-item");
|
|
60
|
+
if (!isTaskItem) {
|
|
61
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { className, ...rest, children });
|
|
62
|
+
}
|
|
63
|
+
const childArray = Array.isArray(children) ? children : [children];
|
|
64
|
+
const checkboxNode = childArray.find(isCheckboxElement);
|
|
65
|
+
const nonCheckboxChildren = childArray.filter((c) => !isCheckboxElement(c));
|
|
66
|
+
const labelText = getNodeText(nonCheckboxChildren);
|
|
67
|
+
const baseId = slugify(labelText || "task-item");
|
|
68
|
+
const hashSuffix = simpleHash(labelText || "task-item");
|
|
69
|
+
const uniqueId = `${baseId}-${hashSuffix}`;
|
|
70
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className, ...rest, children: [
|
|
71
|
+
checkboxNode ? React.createElement(checkboxNode.type, {
|
|
72
|
+
...checkboxNode.props,
|
|
73
|
+
id: uniqueId,
|
|
74
|
+
"aria-label": labelText || "Task item"
|
|
75
|
+
}) : null,
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: uniqueId, children: nonCheckboxChildren })
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function createHeadingRenderer(tag) {
|
|
81
|
+
return function HeadingRenderer(props) {
|
|
82
|
+
const { children, ...rest } = props;
|
|
83
|
+
const text = getNodeText(children);
|
|
84
|
+
const id = slugify(text);
|
|
85
|
+
return React.createElement(
|
|
86
|
+
tag,
|
|
87
|
+
{ id, ...rest },
|
|
88
|
+
children,
|
|
89
|
+
text ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
+
"a",
|
|
91
|
+
{
|
|
92
|
+
className: "heading-anchor",
|
|
93
|
+
href: `#${id}`,
|
|
94
|
+
"aria-label": "Link to heading",
|
|
95
|
+
children: "#"
|
|
96
|
+
}
|
|
97
|
+
) : null
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function CodeRenderer({ inline, className, children, ...rest }) {
|
|
102
|
+
const hasLanguage = /language-([a-z0-9-]+)/i.test(className ?? "");
|
|
103
|
+
const isInline = inline ?? !hasLanguage;
|
|
104
|
+
if (isInline) {
|
|
105
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", { className, ...rest, children });
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", { className, ...rest, children });
|
|
108
|
+
}
|
|
109
|
+
function PreRenderer(props) {
|
|
110
|
+
const { children, ...rest } = props;
|
|
111
|
+
const child = Array.isArray(children) ? children[0] : children;
|
|
112
|
+
let language;
|
|
113
|
+
if (React.isValidElement(child)) {
|
|
114
|
+
const className = child.props.className;
|
|
115
|
+
const match = /language-([a-z0-9-]+)/i.exec(className ?? "");
|
|
116
|
+
language = match?.[1];
|
|
117
|
+
}
|
|
118
|
+
const label = (language ?? "text").toUpperCase();
|
|
119
|
+
const preRef = React.useRef(null);
|
|
120
|
+
const [copied, setCopied] = React.useState(false);
|
|
121
|
+
const resetTimerRef = React.useRef(null);
|
|
122
|
+
let codeText = "";
|
|
123
|
+
if (React.isValidElement(child)) {
|
|
124
|
+
const childProps = child.props;
|
|
125
|
+
codeText = getNodeText(childProps.children);
|
|
126
|
+
}
|
|
127
|
+
const normalized = codeText.endsWith("\n") ? codeText.slice(0, -1) : codeText;
|
|
128
|
+
const lineCount = Math.max(1, normalized.split("\n").length);
|
|
129
|
+
const digitCount = String(lineCount).length;
|
|
130
|
+
const onCopy = async (e) => {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
try {
|
|
134
|
+
const text = preRef.current?.textContent ?? "";
|
|
135
|
+
if (text && typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
136
|
+
await navigator.clipboard.writeText(text);
|
|
137
|
+
setCopied(true);
|
|
138
|
+
if (resetTimerRef.current) window.clearTimeout(resetTimerRef.current);
|
|
139
|
+
resetTimerRef.current = window.setTimeout(() => {
|
|
140
|
+
setCopied(false);
|
|
141
|
+
resetTimerRef.current = null;
|
|
142
|
+
}, 2e3);
|
|
143
|
+
}
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: "markdown-code-block",
|
|
151
|
+
style: {
|
|
152
|
+
["--code-gutter-width"]: `${digitCount + 1}ch`
|
|
153
|
+
},
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "code-toolbar", children: [
|
|
156
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "language-label", children: label }),
|
|
157
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
type: "button",
|
|
161
|
+
className: "copy-button",
|
|
162
|
+
onClick: onCopy,
|
|
163
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
164
|
+
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, { size: 16 })
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "code-content", children: [
|
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "line-numbers", "aria-hidden": true, children: Array.from({ length: lineCount }).map((_, idx) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: idx + 1 }, idx + 1)) }),
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, ...rest, children })
|
|
171
|
+
] })
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function MarkdownContent({
|
|
177
|
+
markdown,
|
|
178
|
+
className,
|
|
179
|
+
variant = "default",
|
|
180
|
+
LinkComponent = DefaultLink,
|
|
181
|
+
ImageComponent = DefaultImage
|
|
182
|
+
}) {
|
|
183
|
+
const [mathPlugins, setMathPlugins] = React.useState(null);
|
|
184
|
+
const [isLoadingMath, setIsLoadingMath] = React.useState(false);
|
|
185
|
+
const hasMath = React.useMemo(() => containsMath(markdown), [markdown]);
|
|
186
|
+
React.useEffect(() => {
|
|
187
|
+
if (!hasMath || mathPlugins || isLoadingMath) return;
|
|
188
|
+
setIsLoadingMath(true);
|
|
189
|
+
const katexCSSId = "katex-css";
|
|
190
|
+
if (typeof document !== "undefined" && !document.getElementById(katexCSSId)) {
|
|
191
|
+
const link = document.createElement("link");
|
|
192
|
+
link.id = katexCSSId;
|
|
193
|
+
link.rel = "stylesheet";
|
|
194
|
+
link.href = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css";
|
|
195
|
+
link.integrity = "sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+";
|
|
196
|
+
link.crossOrigin = "anonymous";
|
|
197
|
+
document.head.appendChild(link);
|
|
198
|
+
const fontDisplayStyleId = "katex-font-display-override";
|
|
199
|
+
if (!document.getElementById(fontDisplayStyleId)) {
|
|
200
|
+
const style = document.createElement("style");
|
|
201
|
+
style.id = fontDisplayStyleId;
|
|
202
|
+
style.textContent = `
|
|
203
|
+
@font-face {
|
|
204
|
+
font-family: 'KaTeX_Main';
|
|
205
|
+
font-style: normal;
|
|
206
|
+
font-weight: normal;
|
|
207
|
+
font-display: swap;
|
|
208
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Main-Regular.woff2') format('woff2');
|
|
209
|
+
}
|
|
210
|
+
@font-face {
|
|
211
|
+
font-family: 'KaTeX_Math';
|
|
212
|
+
font-style: italic;
|
|
213
|
+
font-weight: normal;
|
|
214
|
+
font-display: swap;
|
|
215
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Math-Italic.woff2') format('woff2');
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
document.head.appendChild(style);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
Promise.all([import('remark-math'), import('rehype-katex')]).then(([remarkMathModule, rehypeKatexModule]) => {
|
|
222
|
+
setMathPlugins({
|
|
223
|
+
remarkMath: remarkMathModule.default,
|
|
224
|
+
rehypeKatex: rehypeKatexModule.default
|
|
225
|
+
});
|
|
226
|
+
}).catch((error) => {
|
|
227
|
+
console.error("Failed to load math plugins:", error);
|
|
228
|
+
}).finally(() => {
|
|
229
|
+
setIsLoadingMath(false);
|
|
230
|
+
});
|
|
231
|
+
}, [hasMath, mathPlugins, isLoadingMath]);
|
|
232
|
+
const AnchorRenderer = React.useMemo(() => {
|
|
233
|
+
return function AnchorRendererComponent(props) {
|
|
234
|
+
const { href = "", children, className: anchorClassName, ...rest } = props;
|
|
235
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinkComponent, { href, className: anchorClassName, ...rest, children });
|
|
236
|
+
};
|
|
237
|
+
}, [LinkComponent]);
|
|
238
|
+
const ImgRenderer = React.useMemo(() => {
|
|
239
|
+
return function ImgRendererComponent(props) {
|
|
240
|
+
const {
|
|
241
|
+
src = "",
|
|
242
|
+
alt = "",
|
|
243
|
+
className: imgClassName,
|
|
244
|
+
width,
|
|
245
|
+
height,
|
|
246
|
+
style,
|
|
247
|
+
...rest
|
|
248
|
+
} = props;
|
|
249
|
+
const imageProps = {
|
|
250
|
+
src,
|
|
251
|
+
alt,
|
|
252
|
+
className: imgClassName,
|
|
253
|
+
style,
|
|
254
|
+
...rest
|
|
255
|
+
};
|
|
256
|
+
if (width != null && height != null) {
|
|
257
|
+
imageProps.width = width;
|
|
258
|
+
imageProps.height = height;
|
|
259
|
+
} else {
|
|
260
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "markdown-image-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(ImageComponent, { ...imageProps }) });
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ImageComponent, { ...imageProps });
|
|
263
|
+
};
|
|
264
|
+
}, [ImageComponent]);
|
|
265
|
+
const components = React.useMemo(() => {
|
|
266
|
+
return {
|
|
267
|
+
a: AnchorRenderer,
|
|
268
|
+
img: ImgRenderer,
|
|
269
|
+
code: CodeRenderer,
|
|
270
|
+
pre: PreRenderer,
|
|
271
|
+
h1: createHeadingRenderer("h1"),
|
|
272
|
+
h2: createHeadingRenderer("h2"),
|
|
273
|
+
h3: createHeadingRenderer("h3"),
|
|
274
|
+
h4: createHeadingRenderer("h4"),
|
|
275
|
+
h5: createHeadingRenderer("h5"),
|
|
276
|
+
h6: createHeadingRenderer("h6"),
|
|
277
|
+
li: createTaskListItemRenderer()
|
|
278
|
+
};
|
|
279
|
+
}, [AnchorRenderer, ImgRenderer]);
|
|
280
|
+
const remarkPlugins = React.useMemo(() => {
|
|
281
|
+
const plugins = [remarkGfm__default];
|
|
282
|
+
if (hasMath && mathPlugins?.remarkMath) {
|
|
283
|
+
plugins.push(mathPlugins.remarkMath);
|
|
284
|
+
}
|
|
285
|
+
return plugins;
|
|
286
|
+
}, [hasMath, mathPlugins]);
|
|
287
|
+
const rehypePlugins = React.useMemo(() => {
|
|
288
|
+
const plugins = [rehypeRaw__default, rehypeHighlight__default];
|
|
289
|
+
if (hasMath && mathPlugins?.rehypeKatex) {
|
|
290
|
+
plugins.push(mathPlugins.rehypeKatex);
|
|
291
|
+
}
|
|
292
|
+
return plugins;
|
|
293
|
+
}, [hasMath, mathPlugins]);
|
|
294
|
+
const variantClass = variant === "chat" ? "markdown-content-chat" : "";
|
|
295
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: utils.cn("markdown-content", variantClass, className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "markdown-inner", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "markdown-body", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
296
|
+
ReactMarkdown__default,
|
|
297
|
+
{
|
|
298
|
+
remarkPlugins,
|
|
299
|
+
rehypePlugins,
|
|
300
|
+
components,
|
|
301
|
+
children: markdown
|
|
302
|
+
}
|
|
303
|
+
) }) }) });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
exports.MarkdownContent = MarkdownContent;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { cn } from '../lib/utils.mjs';
|
|
4
|
+
import { useState, useMemo, useEffect, createElement, isValidElement, useRef } from 'react';
|
|
5
|
+
import ReactMarkdown from 'react-markdown';
|
|
6
|
+
import rehypeHighlight from 'rehype-highlight';
|
|
7
|
+
import rehypeRaw from 'rehype-raw';
|
|
8
|
+
import remarkGfm from 'remark-gfm';
|
|
9
|
+
import { CheckIcon, CopyIcon } from 'lucide-react';
|
|
10
|
+
|
|
11
|
+
const DefaultLink = (props) => {
|
|
12
|
+
return /* @__PURE__ */ jsx("a", { ...props });
|
|
13
|
+
};
|
|
14
|
+
const DefaultImage = (props) => {
|
|
15
|
+
return /* @__PURE__ */ jsx("img", { ...props });
|
|
16
|
+
};
|
|
17
|
+
function containsMath(markdown) {
|
|
18
|
+
return /\$\$[\s\S]+?\$\$/.test(markdown) || // Display math
|
|
19
|
+
/(?<!\$)\$(?!\$)[^\$\n]+?\$(?!\$)/.test(markdown) || // Inline math (not $$)
|
|
20
|
+
/\\begin\{(equation|align|gather|math)\}/.test(markdown);
|
|
21
|
+
}
|
|
22
|
+
function slugify(text) {
|
|
23
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
24
|
+
}
|
|
25
|
+
function getNodeText(node) {
|
|
26
|
+
if (node == null) return "";
|
|
27
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
28
|
+
if (Array.isArray(node)) return node.map(getNodeText).join("");
|
|
29
|
+
if (isValidElement(node)) {
|
|
30
|
+
const props = node.props;
|
|
31
|
+
return getNodeText(props.children);
|
|
32
|
+
}
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
function simpleHash(str) {
|
|
36
|
+
let hash = 0;
|
|
37
|
+
for (let i = 0; i < str.length; i++) {
|
|
38
|
+
const char = str.charCodeAt(i);
|
|
39
|
+
hash = (hash << 5) - hash + char;
|
|
40
|
+
hash = hash & hash;
|
|
41
|
+
}
|
|
42
|
+
return Math.abs(hash).toString(36).slice(0, 6);
|
|
43
|
+
}
|
|
44
|
+
function isCheckboxElement(node) {
|
|
45
|
+
return isValidElement(node) && node.type === "input" && node.props.type === "checkbox";
|
|
46
|
+
}
|
|
47
|
+
function createTaskListItemRenderer() {
|
|
48
|
+
return function LiRenderer(props) {
|
|
49
|
+
const { className, children, ...rest } = props;
|
|
50
|
+
const isTaskItem = (className ?? "").split(" ").includes("task-list-item");
|
|
51
|
+
if (!isTaskItem) {
|
|
52
|
+
return /* @__PURE__ */ jsx("li", { className, ...rest, children });
|
|
53
|
+
}
|
|
54
|
+
const childArray = Array.isArray(children) ? children : [children];
|
|
55
|
+
const checkboxNode = childArray.find(isCheckboxElement);
|
|
56
|
+
const nonCheckboxChildren = childArray.filter((c) => !isCheckboxElement(c));
|
|
57
|
+
const labelText = getNodeText(nonCheckboxChildren);
|
|
58
|
+
const baseId = slugify(labelText || "task-item");
|
|
59
|
+
const hashSuffix = simpleHash(labelText || "task-item");
|
|
60
|
+
const uniqueId = `${baseId}-${hashSuffix}`;
|
|
61
|
+
return /* @__PURE__ */ jsxs("li", { className, ...rest, children: [
|
|
62
|
+
checkboxNode ? createElement(checkboxNode.type, {
|
|
63
|
+
...checkboxNode.props,
|
|
64
|
+
id: uniqueId,
|
|
65
|
+
"aria-label": labelText || "Task item"
|
|
66
|
+
}) : null,
|
|
67
|
+
/* @__PURE__ */ jsx("label", { htmlFor: uniqueId, children: nonCheckboxChildren })
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createHeadingRenderer(tag) {
|
|
72
|
+
return function HeadingRenderer(props) {
|
|
73
|
+
const { children, ...rest } = props;
|
|
74
|
+
const text = getNodeText(children);
|
|
75
|
+
const id = slugify(text);
|
|
76
|
+
return createElement(
|
|
77
|
+
tag,
|
|
78
|
+
{ id, ...rest },
|
|
79
|
+
children,
|
|
80
|
+
text ? /* @__PURE__ */ jsx(
|
|
81
|
+
"a",
|
|
82
|
+
{
|
|
83
|
+
className: "heading-anchor",
|
|
84
|
+
href: `#${id}`,
|
|
85
|
+
"aria-label": "Link to heading",
|
|
86
|
+
children: "#"
|
|
87
|
+
}
|
|
88
|
+
) : null
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function CodeRenderer({ inline, className, children, ...rest }) {
|
|
93
|
+
const hasLanguage = /language-([a-z0-9-]+)/i.test(className ?? "");
|
|
94
|
+
const isInline = inline ?? !hasLanguage;
|
|
95
|
+
if (isInline) {
|
|
96
|
+
return /* @__PURE__ */ jsx("code", { className, ...rest, children });
|
|
97
|
+
}
|
|
98
|
+
return /* @__PURE__ */ jsx("code", { className, ...rest, children });
|
|
99
|
+
}
|
|
100
|
+
function PreRenderer(props) {
|
|
101
|
+
const { children, ...rest } = props;
|
|
102
|
+
const child = Array.isArray(children) ? children[0] : children;
|
|
103
|
+
let language;
|
|
104
|
+
if (isValidElement(child)) {
|
|
105
|
+
const className = child.props.className;
|
|
106
|
+
const match = /language-([a-z0-9-]+)/i.exec(className ?? "");
|
|
107
|
+
language = match?.[1];
|
|
108
|
+
}
|
|
109
|
+
const label = (language ?? "text").toUpperCase();
|
|
110
|
+
const preRef = useRef(null);
|
|
111
|
+
const [copied, setCopied] = useState(false);
|
|
112
|
+
const resetTimerRef = useRef(null);
|
|
113
|
+
let codeText = "";
|
|
114
|
+
if (isValidElement(child)) {
|
|
115
|
+
const childProps = child.props;
|
|
116
|
+
codeText = getNodeText(childProps.children);
|
|
117
|
+
}
|
|
118
|
+
const normalized = codeText.endsWith("\n") ? codeText.slice(0, -1) : codeText;
|
|
119
|
+
const lineCount = Math.max(1, normalized.split("\n").length);
|
|
120
|
+
const digitCount = String(lineCount).length;
|
|
121
|
+
const onCopy = async (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
try {
|
|
125
|
+
const text = preRef.current?.textContent ?? "";
|
|
126
|
+
if (text && typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
127
|
+
await navigator.clipboard.writeText(text);
|
|
128
|
+
setCopied(true);
|
|
129
|
+
if (resetTimerRef.current) window.clearTimeout(resetTimerRef.current);
|
|
130
|
+
resetTimerRef.current = window.setTimeout(() => {
|
|
131
|
+
setCopied(false);
|
|
132
|
+
resetTimerRef.current = null;
|
|
133
|
+
}, 2e3);
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ jsxs(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: "markdown-code-block",
|
|
142
|
+
style: {
|
|
143
|
+
["--code-gutter-width"]: `${digitCount + 1}ch`
|
|
144
|
+
},
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsxs("div", { className: "code-toolbar", children: [
|
|
147
|
+
/* @__PURE__ */ jsx("span", { className: "language-label", children: label }),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
className: "copy-button",
|
|
153
|
+
onClick: onCopy,
|
|
154
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
155
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 16 }) : /* @__PURE__ */ jsx(CopyIcon, { size: 16 })
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ jsxs("div", { className: "code-content", children: [
|
|
160
|
+
/* @__PURE__ */ jsx("ol", { className: "line-numbers", "aria-hidden": true, children: Array.from({ length: lineCount }).map((_, idx) => /* @__PURE__ */ jsx("li", { children: idx + 1 }, idx + 1)) }),
|
|
161
|
+
/* @__PURE__ */ jsx("pre", { ref: preRef, ...rest, children })
|
|
162
|
+
] })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function MarkdownContent({
|
|
168
|
+
markdown,
|
|
169
|
+
className,
|
|
170
|
+
variant = "default",
|
|
171
|
+
LinkComponent = DefaultLink,
|
|
172
|
+
ImageComponent = DefaultImage
|
|
173
|
+
}) {
|
|
174
|
+
const [mathPlugins, setMathPlugins] = useState(null);
|
|
175
|
+
const [isLoadingMath, setIsLoadingMath] = useState(false);
|
|
176
|
+
const hasMath = useMemo(() => containsMath(markdown), [markdown]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!hasMath || mathPlugins || isLoadingMath) return;
|
|
179
|
+
setIsLoadingMath(true);
|
|
180
|
+
const katexCSSId = "katex-css";
|
|
181
|
+
if (typeof document !== "undefined" && !document.getElementById(katexCSSId)) {
|
|
182
|
+
const link = document.createElement("link");
|
|
183
|
+
link.id = katexCSSId;
|
|
184
|
+
link.rel = "stylesheet";
|
|
185
|
+
link.href = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css";
|
|
186
|
+
link.integrity = "sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+";
|
|
187
|
+
link.crossOrigin = "anonymous";
|
|
188
|
+
document.head.appendChild(link);
|
|
189
|
+
const fontDisplayStyleId = "katex-font-display-override";
|
|
190
|
+
if (!document.getElementById(fontDisplayStyleId)) {
|
|
191
|
+
const style = document.createElement("style");
|
|
192
|
+
style.id = fontDisplayStyleId;
|
|
193
|
+
style.textContent = `
|
|
194
|
+
@font-face {
|
|
195
|
+
font-family: 'KaTeX_Main';
|
|
196
|
+
font-style: normal;
|
|
197
|
+
font-weight: normal;
|
|
198
|
+
font-display: swap;
|
|
199
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Main-Regular.woff2') format('woff2');
|
|
200
|
+
}
|
|
201
|
+
@font-face {
|
|
202
|
+
font-family: 'KaTeX_Math';
|
|
203
|
+
font-style: italic;
|
|
204
|
+
font-weight: normal;
|
|
205
|
+
font-display: swap;
|
|
206
|
+
src: url('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Math-Italic.woff2') format('woff2');
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
document.head.appendChild(style);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
Promise.all([import('remark-math'), import('rehype-katex')]).then(([remarkMathModule, rehypeKatexModule]) => {
|
|
213
|
+
setMathPlugins({
|
|
214
|
+
remarkMath: remarkMathModule.default,
|
|
215
|
+
rehypeKatex: rehypeKatexModule.default
|
|
216
|
+
});
|
|
217
|
+
}).catch((error) => {
|
|
218
|
+
console.error("Failed to load math plugins:", error);
|
|
219
|
+
}).finally(() => {
|
|
220
|
+
setIsLoadingMath(false);
|
|
221
|
+
});
|
|
222
|
+
}, [hasMath, mathPlugins, isLoadingMath]);
|
|
223
|
+
const AnchorRenderer = useMemo(() => {
|
|
224
|
+
return function AnchorRendererComponent(props) {
|
|
225
|
+
const { href = "", children, className: anchorClassName, ...rest } = props;
|
|
226
|
+
return /* @__PURE__ */ jsx(LinkComponent, { href, className: anchorClassName, ...rest, children });
|
|
227
|
+
};
|
|
228
|
+
}, [LinkComponent]);
|
|
229
|
+
const ImgRenderer = useMemo(() => {
|
|
230
|
+
return function ImgRendererComponent(props) {
|
|
231
|
+
const {
|
|
232
|
+
src = "",
|
|
233
|
+
alt = "",
|
|
234
|
+
className: imgClassName,
|
|
235
|
+
width,
|
|
236
|
+
height,
|
|
237
|
+
style,
|
|
238
|
+
...rest
|
|
239
|
+
} = props;
|
|
240
|
+
const imageProps = {
|
|
241
|
+
src,
|
|
242
|
+
alt,
|
|
243
|
+
className: imgClassName,
|
|
244
|
+
style,
|
|
245
|
+
...rest
|
|
246
|
+
};
|
|
247
|
+
if (width != null && height != null) {
|
|
248
|
+
imageProps.width = width;
|
|
249
|
+
imageProps.height = height;
|
|
250
|
+
} else {
|
|
251
|
+
return /* @__PURE__ */ jsx("span", { className: "markdown-image-wrapper", children: /* @__PURE__ */ jsx(ImageComponent, { ...imageProps }) });
|
|
252
|
+
}
|
|
253
|
+
return /* @__PURE__ */ jsx(ImageComponent, { ...imageProps });
|
|
254
|
+
};
|
|
255
|
+
}, [ImageComponent]);
|
|
256
|
+
const components = useMemo(() => {
|
|
257
|
+
return {
|
|
258
|
+
a: AnchorRenderer,
|
|
259
|
+
img: ImgRenderer,
|
|
260
|
+
code: CodeRenderer,
|
|
261
|
+
pre: PreRenderer,
|
|
262
|
+
h1: createHeadingRenderer("h1"),
|
|
263
|
+
h2: createHeadingRenderer("h2"),
|
|
264
|
+
h3: createHeadingRenderer("h3"),
|
|
265
|
+
h4: createHeadingRenderer("h4"),
|
|
266
|
+
h5: createHeadingRenderer("h5"),
|
|
267
|
+
h6: createHeadingRenderer("h6"),
|
|
268
|
+
li: createTaskListItemRenderer()
|
|
269
|
+
};
|
|
270
|
+
}, [AnchorRenderer, ImgRenderer]);
|
|
271
|
+
const remarkPlugins = useMemo(() => {
|
|
272
|
+
const plugins = [remarkGfm];
|
|
273
|
+
if (hasMath && mathPlugins?.remarkMath) {
|
|
274
|
+
plugins.push(mathPlugins.remarkMath);
|
|
275
|
+
}
|
|
276
|
+
return plugins;
|
|
277
|
+
}, [hasMath, mathPlugins]);
|
|
278
|
+
const rehypePlugins = useMemo(() => {
|
|
279
|
+
const plugins = [rehypeRaw, rehypeHighlight];
|
|
280
|
+
if (hasMath && mathPlugins?.rehypeKatex) {
|
|
281
|
+
plugins.push(mathPlugins.rehypeKatex);
|
|
282
|
+
}
|
|
283
|
+
return plugins;
|
|
284
|
+
}, [hasMath, mathPlugins]);
|
|
285
|
+
const variantClass = variant === "chat" ? "markdown-content-chat" : "";
|
|
286
|
+
return /* @__PURE__ */ jsx("div", { className: cn("markdown-content", variantClass, className), children: /* @__PURE__ */ jsx("div", { className: "markdown-inner", children: /* @__PURE__ */ jsx("div", { className: "markdown-body", children: /* @__PURE__ */ jsx(
|
|
287
|
+
ReactMarkdown,
|
|
288
|
+
{
|
|
289
|
+
remarkPlugins,
|
|
290
|
+
rehypePlugins,
|
|
291
|
+
components,
|
|
292
|
+
children: markdown
|
|
293
|
+
}
|
|
294
|
+
) }) }) });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { MarkdownContent };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const index = require('../../../../node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.cjs');
|
|
6
|
+
const utils = require('../lib/utils.cjs');
|
|
7
|
+
|
|
8
|
+
function ScrollArea({
|
|
9
|
+
className,
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
14
|
+
index.Root,
|
|
15
|
+
{
|
|
16
|
+
"data-slot": "scroll-area",
|
|
17
|
+
className: utils.cn("relative", className),
|
|
18
|
+
...props,
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
+
index.Viewport,
|
|
22
|
+
{
|
|
23
|
+
"data-slot": "scroll-area-viewport",
|
|
24
|
+
className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
|
|
25
|
+
children
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
|
|
29
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.Corner, {})
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function ScrollBar({
|
|
35
|
+
className,
|
|
36
|
+
orientation = "vertical",
|
|
37
|
+
...props
|
|
38
|
+
}) {
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
+
index.ScrollAreaScrollbar,
|
|
41
|
+
{
|
|
42
|
+
"data-slot": "scroll-area-scrollbar",
|
|
43
|
+
orientation,
|
|
44
|
+
className: utils.cn(
|
|
45
|
+
"flex touch-none p-px transition-colors select-none",
|
|
46
|
+
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent",
|
|
47
|
+
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
|
|
48
|
+
className
|
|
49
|
+
),
|
|
50
|
+
...props,
|
|
51
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
52
|
+
index.ScrollAreaThumb,
|
|
53
|
+
{
|
|
54
|
+
"data-slot": "scroll-area-thumb",
|
|
55
|
+
className: "bg-border relative flex-1 rounded-full"
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.ScrollArea = ScrollArea;
|
|
63
|
+
exports.ScrollBar = ScrollBar;
|