@copilotkit/react-ui 0.2.0 → 0.3.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/.turbo/turbo-build.log +12 -14
- package/CHANGELOG.md +13 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +36 -2
- package/dist/index.js +48 -10
- package/dist/index.mjs +26 -0
- package/package.json +39 -8
- package/src/components/chat-components/chat-list.tsx +32 -0
- package/src/components/chat-components/chat-message-actions.tsx +40 -0
- package/src/components/chat-components/chat-message.tsx +74 -0
- package/src/components/chat-components/chat-panel.tsx +77 -0
- package/src/components/chat-components/chat-scroll-anchor.tsx +29 -0
- package/src/components/chat-components/clear-history.tsx +73 -0
- package/src/components/chat-components/copilot-chat.tsx +61 -0
- package/src/components/chat-components/default-empty-screen.tsx +62 -0
- package/src/components/chat-components/external-link.tsx +29 -0
- package/src/components/chat-components/markdown.tsx +9 -0
- package/src/components/chat-components/prompt-form.tsx +91 -0
- package/src/components/chat-components/theme-toggle.tsx +31 -0
- package/src/components/chat-components/toaster.tsx +3 -0
- package/src/components/chat-components/ui/alert-dialog.tsx +150 -0
- package/src/components/chat-components/ui/badge.tsx +36 -0
- package/src/components/chat-components/ui/button.tsx +57 -0
- package/src/components/chat-components/ui/codeblock.tsx +142 -0
- package/src/components/chat-components/ui/dialog.tsx +128 -0
- package/src/components/chat-components/ui/dropdown-menu.tsx +128 -0
- package/src/components/chat-components/ui/icons.tsx +507 -0
- package/src/components/chat-components/ui/input.tsx +25 -0
- package/src/components/chat-components/ui/label.tsx +26 -0
- package/src/components/chat-components/ui/select.tsx +119 -0
- package/src/components/chat-components/ui/separator.tsx +31 -0
- package/src/components/chat-components/ui/sheet.tsx +122 -0
- package/src/components/chat-components/ui/switch.tsx +29 -0
- package/src/components/chat-components/ui/textarea.tsx +24 -0
- package/src/components/chat-components/ui/tooltip.tsx +30 -0
- package/src/components/index.ts +7 -0
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +74 -0
- package/src/components/sidebar/copilot-sidebar.tsx +40 -0
- package/src/components/sidebar/sidebar-context.tsx +11 -0
- package/src/context/index.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-at-bottom.tsx +23 -0
- package/src/hooks/use-copy-to-clipboard.tsx +33 -0
- package/src/hooks/use-enter-submit.tsx +23 -0
- package/src/index.tsx +4 -3
- package/src/lib/utils.ts +43 -0
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +18 -0
- package/tailwind.config.js +1 -1
- package/tsconfig.json +1 -1
- package/dist/Button.d.ts +0 -3
- package/dist/Button.js +0 -10
- package/dist/Card.d.ts +0 -7
- package/dist/Card.js +0 -10
- package/dist/chunk-6OZR7L23.js +0 -7
- package/dist/chunk-FGO3LSHH.js +0 -7
- package/src/Button.tsx +0 -16
- package/src/Card.tsx +0 -27
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
|
|
2
|
-
> @copilotkit/react-ui@0.
|
|
3
|
-
> tsup --format cjs --dts
|
|
2
|
+
> @copilotkit/react-ui@0.2.0 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit2/packages/react-ui
|
|
3
|
+
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
4
4
|
|
|
5
|
-
CLI Building entry: src/
|
|
5
|
+
CLI Building entry: src/index.tsx
|
|
6
6
|
CLI Using tsconfig: tsconfig.json
|
|
7
7
|
CLI tsup v6.5.0
|
|
8
8
|
CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit2/packages/react-ui/tsup.config.ts
|
|
9
9
|
CLI Target: es6
|
|
10
10
|
CLI Cleaning output folder
|
|
11
|
+
ESM Build start
|
|
11
12
|
CJS Build start
|
|
12
13
|
Browserslist: caniuse-lite is outdated. Please run:
|
|
13
14
|
npx update-browserslist-db@latest
|
|
14
15
|
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
15
16
|
DTS Build start
|
|
16
|
-
CJS dist/index.css
|
|
17
|
-
CJS dist/
|
|
18
|
-
CJS
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
DTS
|
|
24
|
-
DTS dist/Button.d.ts 61.00 B
|
|
25
|
-
DTS dist/Card.d.ts 137.00 B
|
|
26
|
-
DTS dist/index.d.ts 72.00 B
|
|
17
|
+
CJS dist/index.css 19.35 KB
|
|
18
|
+
CJS dist/index.js 22.36 KB
|
|
19
|
+
CJS ⚡️ Build success in 625ms
|
|
20
|
+
ESM dist/index.css 19.35 KB
|
|
21
|
+
ESM dist/index.mjs 20.19 KB
|
|
22
|
+
ESM ⚡️ Build success in 625ms
|
|
23
|
+
DTS ⚡️ Build success in 1401ms
|
|
24
|
+
DTS dist/index.d.ts 1.37 KB
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- working version
|
|
8
|
+
- 9d2f3cb: semi compiling
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- Updated dependencies [9d2f3cb]
|
|
14
|
+
- @copilotkit/react-core@0.3.0
|
|
15
|
+
|
|
3
16
|
## 0.2.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.ui-ml-2{margin-left:.5rem}.ui-mt-4{margin-top:1rem}.ui-inline-block{display:inline-block}.ui-flex{display:flex}.ui-h-full{height:100%}.ui-w-full{width:100%}.ui-items-center{align-items:center}.ui-justify-center{justify-content:center}.ui-overflow-hidden{overflow:hidden}.ui-rounded-md{border-radius:.375rem}.ui-rounded-lg{border-radius:.5rem}.ui-border{border-width:1px}.ui-border-transparent{border-color:transparent}.ui-bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.ui-bg-zinc-900{--tw-bg-opacity: 1;background-color:rgb(24 24 27 / var(--tw-bg-opacity))}.ui-bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.ui-from-brandred{--tw-gradient-from: #ef4444;--tw-gradient-to: rgb(239 68 68 / 0);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.ui-to-brandblue{--tw-gradient-to: #3b82f6}.ui-bg-clip-text{-webkit-background-clip:text;background-clip:text}.ui-bg-origin-border{background-origin:border-box}.ui-p-4{padding:1rem}.ui-px-8{padding-left:2rem;padding-right:2rem}.ui-py-3{padding-top:.75rem;padding-bottom:.75rem}.ui-text-base{font-size:1rem;line-height:1.5rem}.ui-text-xl{font-size:1.25rem;line-height:1.75rem}.ui-text-xs{font-size:.75rem;line-height:1rem}.ui-font-medium{font-weight:500}.ui-text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.ui-text-transparent{color:transparent}.ui-text-\[\#6b7280\]{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.ui-text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.ui-no-underline{text-decoration-line:none}.hover\:ui-bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity))}.ui-group:hover .group-hover\:ui-underline{text-decoration-line:underline}@media (min-width: 768px){.md\:ui-py-3{padding-top:.75rem;padding-bottom:.75rem}.md\:ui-px-10{padding-left:2.5rem;padding-right:2.5rem}.md\:ui-text-lg{font-size:1.125rem;line-height:1.75rem}.md\:ui-leading-6{line-height:1.5rem}}
|
|
1
|
+
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.inset-x-0{left:0;right:0}.bottom-0{bottom:0}.left-0{left:0}.top-4{top:1rem}.right-0{right:0}.right-4{right:1rem}.left-2{left:.5rem}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.my-4{margin-top:1rem;margin-bottom:1rem}.-mx-1{margin-left:-.25rem;margin-right:-.25rem}.my-1{margin-top:.25rem;margin-bottom:.25rem}.mb-4{margin-bottom:1rem}.ml-4{margin-left:1rem}.mb-2{margin-bottom:.5rem}.mt-1{margin-top:.25rem}.mt-4{margin-top:1rem}.mb-8{margin-bottom:2rem}.mr-2{margin-right:.5rem}.ml-3{margin-left:.75rem}.mt-2{margin-top:.5rem}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-8{height:2rem}.h-10{height:2.5rem}.h-px{height:1px}.h-full{height:100%}.h-auto{height:auto}.h-7{height:1.75rem}.h-6{height:1.5rem}.h-11{height:2.75rem}.h-4{height:1rem}.h-9{height:2.25rem}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-3\.5{height:.875rem}.h-3{height:.75rem}.h-\[1px\]{height:1px}.h-\[24px\]{height:24px}.h-5{height:1.25rem}.max-h-60{max-height:15rem}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.w-8{width:2rem}.w-full{width:100%}.w-6{width:1.5rem}.w-4{width:1rem}.w-3\.5{width:.875rem}.w-3{width:.75rem}.w-\[1px\]{width:1px}.w-\[44px\]{width:44px}.w-5{width:1.25rem}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.max-w-2xl{max-width:42rem}.max-w-lg{max-width:32rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.translate-y-1{--tw-translate-y: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-4{gap:1rem}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.break-words{overflow-wrap:break-word}.rounded-md{border-radius:.375rem}.rounded-lg{border-radius:.5rem}.rounded-full{border-radius:9999px}.rounded-sm{border-radius:.125rem}.rounded-b-lg{border-bottom-right-radius:.5rem;border-bottom-left-radius:.5rem}.border{border-width:1px}.border-2{border-width:2px}.border-r{border-right-width:1px}.border-transparent{border-color:transparent}.bg-transparent{background-color:transparent}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(203 213 225 / var(--tw-bg-opacity))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-zinc-800{--tw-bg-opacity: 1;background-color:rgb(39 39 42 / var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.p-8{padding:2rem}.p-0{padding:0}.p-2{padding:.5rem}.p-6{padding:1.5rem}.p-1{padding:.25rem}.px-0{padding-left:0;padding-right:0}.px-1{padding-left:.25rem;padding-right:.25rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-8{padding-left:2rem;padding-right:2rem}.py-\[1\.3rem\]{padding-top:1.3rem;padding-bottom:1.3rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-0{padding-top:0;padding-bottom:0}.px-3{padding-left:.75rem;padding-right:.75rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.pt-5{padding-top:1.25rem}.pl-0{padding-left:0}.pr-6{padding-right:1.5rem}.pr-4{padding-right:1rem}.pl-8{padding-left:2rem}.pr-2{padding-right:.5rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-sm{font-size:.875rem;line-height:1.25rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-base{font-size:1rem;line-height:1.5rem}.text-xs{font-size:.75rem;line-height:1rem}.font-semibold{font-weight:600}.font-medium{font-weight:500}.lowercase{text-transform:lowercase}.leading-normal{line-height:1.5}.leading-4{line-height:1rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.tracking-tight{letter-spacing:-.025em}.tracking-widest{letter-spacing:.1em}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-zinc-100{--tw-text-opacity: 1;color:rgb(244 244 245 / var(--tw-text-opacity))}.underline-offset-4{text-underline-offset:4px}.opacity-70{opacity:.7}.opacity-100{opacity:1}.opacity-60{opacity:.6}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-0{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-slate-600{--tw-ring-opacity: 1;--tw-ring-color: rgb(71 85 105 / var(--tw-ring-opacity))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.file\:border-0::file-selector-button{border-width:0px}.file\:bg-transparent::file-selector-button{background-color:transparent}.file\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\:font-medium::file-selector-button{font-weight:500}.last\:mb-0:last-child{margin-bottom:0}.focus-within\:outline-none:focus-within{outline:2px solid transparent;outline-offset:2px}.hover\:bg-zinc-800:hover{--tw-bg-opacity: 1;background-color:rgb(39 39 42 / var(--tw-bg-opacity))}.hover\:text-gray-500:hover{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-indigo-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-slate-700:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: rgb(51 65 85 / var(--tw-ring-opacity))}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width: 0px}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:opacity-100{opacity:1}.peer:disabled~.peer-disabled\:cursor-not-allowed{cursor:not-allowed}.peer:disabled~.peer-disabled\:opacity-70{opacity:.7}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[state\=checked\]\:translate-x-5[data-state=checked]{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}@media (min-width: 640px){.sm\:left-4{left:1rem}.sm\:right-4{right:1rem}.sm\:mt-0{margin-top:0}.sm\:max-w-2xl{max-width:42rem}.sm\:max-w-lg{max-width:32rem}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-xl{border-radius:.75rem}.sm\:rounded-md{border-radius:.375rem}.sm\:rounded-lg{border-radius:.5rem}.sm\:px-4{padding-left:1rem;padding-right:1rem}.sm\:px-12{padding-left:3rem;padding-right:3rem}.sm\:text-left{text-align:left}.sm\:text-sm{font-size:.875rem;line-height:1.25rem}}@media (min-width: 768px){.md\:absolute{position:absolute}.md\:-right-10{right:-2.5rem}.md\:-top-2{top:-.5rem}.md\:my-4{margin-top:1rem;margin-bottom:1rem}.md\:w-full{width:100%}.md\:py-4{padding-top:1rem;padding-bottom:1rem}.md\:opacity-0{opacity:0}}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { UseCopilotChatOptions } from '@copilotkit/react-core';
|
|
4
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
+
|
|
6
|
+
interface EmptyScreenProps {
|
|
7
|
+
setInput: React__default.Dispatch<React__default.SetStateAction<string>>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ChatComponentInjectionsProps {
|
|
11
|
+
EmptyScreen?: React__default.FC<EmptyScreenProps>;
|
|
12
|
+
}
|
|
13
|
+
interface CopilotChatProps extends UseCopilotChatOptions, ChatComponentInjectionsProps {
|
|
14
|
+
}
|
|
15
|
+
declare function CopilotChat({ id, initialMessages, makeSystemMessage, EmptyScreen }: CopilotChatProps): JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
18
|
+
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
19
|
+
|
|
20
|
+
interface CopilotSidebarUIProviderProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
declare function CopilotSidebarUIProvider({ children }: CopilotSidebarUIProviderProps): JSX.Element;
|
|
24
|
+
|
|
25
|
+
interface SidebarProps {
|
|
26
|
+
setSidebarOpen: (open: boolean) => void;
|
|
27
|
+
}
|
|
28
|
+
declare function CopilotSidebar(props: SidebarProps): JSX.Element;
|
|
29
|
+
|
|
30
|
+
interface CopilotSidebarContextType {
|
|
31
|
+
isSidebarOpen: boolean;
|
|
32
|
+
toggleSidebar: () => void;
|
|
33
|
+
}
|
|
34
|
+
declare const CopilotSidebarContext: React.Context<CopilotSidebarContextType>;
|
|
35
|
+
|
|
36
|
+
export { CopilotChat, CopilotSidebar, CopilotSidebarContext, CopilotSidebarContextType, CopilotSidebarUIProvider, Tooltip, TooltipProvider };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var V = require('react');
|
|
4
|
+
var O = require('@radix-ui/react-separator');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var nanoid = require('nanoid');
|
|
7
|
+
var tailwindMerge = require('tailwind-merge');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var Ye = require('remark-gfm');
|
|
10
|
+
var $e = require('remark-math');
|
|
11
|
+
var reactSyntaxHighlighter = require('react-syntax-highlighter');
|
|
12
|
+
var prism = require('react-syntax-highlighter/dist/cjs/styles/prism');
|
|
13
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
14
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
15
|
+
var Ge = require('react-markdown');
|
|
16
|
+
var Qe = require('react-textarea-autosize');
|
|
17
|
+
var w = require('@radix-ui/react-tooltip');
|
|
18
|
+
var eo = require('next/link');
|
|
19
|
+
var reactIntersectionObserver = require('react-intersection-observer');
|
|
20
|
+
var reactCore = require('@copilotkit/react-core');
|
|
21
|
+
var outline = require('@heroicons/react/24/outline');
|
|
5
22
|
|
|
23
|
+
function _interopNamespaceDefault(e) {
|
|
24
|
+
var n = Object.create(null);
|
|
25
|
+
if (e) {
|
|
26
|
+
Object.keys(e).forEach(function (k) {
|
|
27
|
+
if (k !== 'default') {
|
|
28
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
29
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return e[k]; }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
n.default = e;
|
|
37
|
+
return Object.freeze(n);
|
|
38
|
+
}
|
|
6
39
|
|
|
40
|
+
var V__namespace = /*#__PURE__*/_interopNamespaceDefault(V);
|
|
41
|
+
var O__namespace = /*#__PURE__*/_interopNamespaceDefault(O);
|
|
42
|
+
var w__namespace = /*#__PURE__*/_interopNamespaceDefault(w);
|
|
7
43
|
|
|
8
|
-
Object.defineProperty(exports, 'Button', {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
44
|
+
var Se=Object.defineProperty,Me=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var Q=(e,o,r)=>o in e?Se(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,n=(e,o)=>{for(var r in o||(o={}))ee.call(o,r)&&Q(e,r,o[r]);if(I)for(var r of I(o))oe.call(o,r)&&Q(e,r,o[r]);return e},f=(e,o)=>Me(e,Le(o));var p=(e,o)=>{var r={};for(var t in e)ee.call(e,t)&&o.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&I)for(var t of I(e))o.indexOf(t)<0&&oe.call(e,t)&&(r[t]=e[t]);return r};var S=(e,o,r)=>new Promise((t,a)=>{var i=d=>{try{l(r.next(d));}catch(h){a(h);}},m=d=>{try{l(r.throw(d));}catch(h){a(h);}},l=d=>d.done?t(d.value):Promise.resolve(d.value).then(i,m);l((r=r.apply(e,o)).next());});function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}nanoid.customAlphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var U=V__namespace.forwardRef((i,a)=>{var m=i,{className:e,orientation:o="horizontal",decorative:r=!0}=m,t=p(m,["className","orientation","decorative"]);return jsxRuntime.jsx(O__namespace.Root,n({ref:a,decorative:r,orientation:o,className:s("shrink-0 bg-border",o==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e)},t))});U.displayName=O__namespace.Root.displayName;function T({timeout:e=2e3}){let[o,r]=V__namespace.useState(!1);return {isCopied:o,copyToClipboard:a=>{var i;typeof window=="undefined"||!((i=navigator.clipboard)!=null&&i.writeText)||!a||navigator.clipboard.writeText(a).then(()=>{r(!0),setTimeout(()=>{r(!1);},e);});}}}function ae(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsxs("svg",f(n({fill:"currentColor",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",className:s("h-4 w-4",e)},o),{children:[jsxRuntime.jsx("title",{children:"OpenAI icon"}),jsxRuntime.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})]}))}function ne(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z"})}))}function se(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z"})}))}function ie(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M224 128a8 8 0 0 1-8 8h-80v80a8 8 0 0 1-16 0v-80H40a8 8 0 0 1 0-16h80V40a8 8 0 0 1 16 0v80h80a8 8 0 0 1 8 8Z"})}))}function le(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z"})}))}function pe(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z"})}))}function ce(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z"})}))}function B(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z"})}))}function Z(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z"})}))}function me(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxRuntime.jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsxRuntime.jsx("path",{d:"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z"})}))}var D=classVarianceAuthority.cva("inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-md hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"shadow-none hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 shadow-none hover:underline"},size:{default:"h-8 px-4 py-2",sm:"h-8 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-8 w-8 p-0"}},defaultVariants:{variant:"default",size:"default"}}),u=V__namespace.forwardRef((m,i)=>{var l=m,{className:e,variant:o,size:r,asChild:t=!1}=l,a=p(l,["className","variant","size","asChild"]);return jsxRuntime.jsx(t?reactSlot.Slot:"button",n({className:s(D({variant:o,size:r,className:e})),ref:i},a))});u.displayName="Button";var Fe={javascript:".js",python:".py",java:".java",c:".c",cpp:".cpp","c++":".cpp","c#":".cs",ruby:".rb",php:".php",swift:".swift","objective-c":".m",kotlin:".kt",typescript:".ts",go:".go",perl:".pl",rust:".rs",scala:".scala",haskell:".hs",lua:".lua",shell:".sh",sql:".sql",html:".html",css:".css"},Ke=(e,o=!1)=>{let r="ABCDEFGHJKLMNPQRSTUVWXY3456789",t="";for(let a=0;a<e;a++)t+=r.charAt(Math.floor(Math.random()*r.length));return o?t.toLowerCase():t},F=V.memo(({language:e,value:o})=>{let{isCopied:r,copyToClipboard:t}=T({timeout:2e3});return jsxRuntime.jsxs("div",{className:"codeblock relative w-full bg-zinc-950 font-sans",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100",children:[jsxRuntime.jsx("span",{className:"text-xs lowercase",children:e}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsxs(u,{variant:"ghost",className:"hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",onClick:()=>{if(typeof window=="undefined")return;let m=Fe[e]||".file",l=`file-${Ke(3,!0)}${m}`,d=window.prompt("Enter file name",l);if(!d)return;let h=new Blob([o],{type:"text/plain"}),C=URL.createObjectURL(h),N=document.createElement("a");N.download=d,N.href=C,N.style.display="none",document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(C);},size:"icon",children:[jsxRuntime.jsx(me,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Download"})]}),jsxRuntime.jsxs(u,{variant:"ghost",size:"icon",className:"text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",onClick:()=>{r||t(o);},children:[r?jsxRuntime.jsx(Z,{}):jsxRuntime.jsx(B,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Copy code"})]})]})]}),jsxRuntime.jsx(reactSyntaxHighlighter.Prism,{language:e,style:prism.coldarkDark,PreTag:"div",showLineNumbers:!0,customStyle:{margin:0,width:"100%",background:"transparent",padding:"1.5rem 1rem"},codeTagProps:{style:{fontSize:"0.9rem",fontFamily:"var(--font-mono)"}},children:o})]})});F.displayName="CodeBlock";var fe=V.memo(Ge,(e,o)=>e.children===o.children&&e.className===o.className);function ue(t){var a=t,{message:e,className:o}=a,r=p(a,["message","className"]);let{isCopied:i,copyToClipboard:m}=T({timeout:2e3}),l=()=>{i||m(e.content);};return jsxRuntime.jsx("div",f(n({className:s("flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0",o)},r),{children:jsxRuntime.jsxs(u,{variant:"ghost",size:"icon",onClick:l,children:[i?jsxRuntime.jsx(Z,{}):jsxRuntime.jsx(B,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Copy message"})]})}))}function he(r){var t=r,{message:e}=t,o=p(t,["message"]);return jsxRuntime.jsxs("div",f(n({className:s("group relative mb-4 flex items-start")},o),{children:[jsxRuntime.jsx("div",{className:s("flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow",e.role==="user"?"bg-background":"bg-primary text-primary-foreground"),children:e.role==="user"?jsxRuntime.jsx(se,{}):jsxRuntime.jsx(ae,{})}),jsxRuntime.jsxs("div",{className:"ml-4 flex-1 space-y-2 overflow-hidden px-1",children:[jsxRuntime.jsx(fe,{className:"prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",remarkPlugins:[Ye,$e],components:{p({children:a}){return jsxRuntime.jsx("p",{className:"mb-2 last:mb-0",children:a})},code(d){var h=d,{children:a,className:i,inline:m}=h,l=p(h,["children","className","inline"]);if(a.length){if(a[0]=="\u258D")return jsxRuntime.jsx("span",{className:"mt-1 animate-pulse cursor-default",children:"\u258D"});a[0]=a[0].replace("`\u258D`","\u258D");}let C=/language-(\w+)/.exec(i||"");return m?jsxRuntime.jsx("code",f(n({className:i},l),{children:a})):jsxRuntime.jsx(F,n({language:C&&C[1]||"",value:String(a).replace(/\n$/,"")},l),Math.random())}},children:e.content}),jsxRuntime.jsx(ue,{message:e})]})]}))}function ve({messages:e}){let o=e.filter(r=>r.role!=="system");return o.length?jsxRuntime.jsx("div",{className:"relative mx-auto max-w-2xl px-0",children:o.map((r,t)=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(he,{message:r}),t<o.length-1&&jsxRuntime.jsx(U,{className:"my-4 md:my-4"})]},t))}):null}function we(){let e=V.useRef(null);return {formRef:e,onKeyDown:r=>{var t;r.key==="Enter"&&!r.shiftKey&&!r.nativeEvent.isComposing&&((t=e.current)==null||t.requestSubmit(),r.preventDefault());}}}var Xe=w__namespace.Provider,A=w__namespace.Root,j=w__namespace.Trigger,E=V__namespace.forwardRef((a,t)=>{var i=a,{className:e,sideOffset:o=4}=i,r=p(i,["className","sideOffset"]);return jsxRuntime.jsx(w__namespace.Content,n({ref:t,sideOffset:o,className:s("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",e)},r))});E.displayName=w__namespace.Content.displayName;function xe({onSubmit:e,input:o,setInput:r,isLoading:t}){let{formRef:a,onKeyDown:i}=we(),m=V__namespace.useRef(null);return V__namespace.useEffect(()=>{m.current&&m.current.focus();},[]),jsxRuntime.jsx("form",{onSubmit:l=>S(this,null,function*(){l.preventDefault(),o!=null&&o.trim()&&(r(""),yield e(o));}),ref:a,children:jsxRuntime.jsxs("div",{className:"relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12",children:[jsxRuntime.jsxs(A,{children:[jsxRuntime.jsx(j,{asChild:!0,children:jsxRuntime.jsxs(eo,{href:"/",className:s(D({size:"sm",variant:"outline"}),"absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4"),children:[jsxRuntime.jsx(ie,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"New Chat"})]})}),jsxRuntime.jsx(E,{children:"New Chat"})]}),jsxRuntime.jsx(Qe,{ref:m,tabIndex:0,onKeyDown:i,rows:1,value:o,onChange:l=>r(l.target.value),placeholder:"Send a message.",spellCheck:!1,className:"min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"}),jsxRuntime.jsx("div",{className:"absolute right-0 top-4 sm:right-4",children:jsxRuntime.jsxs(A,{children:[jsxRuntime.jsx(j,{asChild:!0,children:jsxRuntime.jsxs(u,{type:"submit",size:"icon",disabled:t||o==="",className:" bg-slate-300",children:[jsxRuntime.jsx(le,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Send message"})]})}),jsxRuntime.jsx(E,{children:"Send message"})]})})]})})}function be({id:e,isLoading:o,stop:r,append:t,reload:a,input:i,setInput:m,messages:l}){return jsxRuntime.jsx("div",{className:"inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8",style:{width:"100%",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsxs("div",{className:"mx-auto sm:max-w-2xl sm:px-4",children:[jsxRuntime.jsx("div",{className:"flex h-10 items-center justify-center mb-4",children:o?jsxRuntime.jsxs(u,{variant:"outline",onClick:()=>r(),className:"bg-background",children:[jsxRuntime.jsx(ce,{className:"mr-2"}),"Stop generating"]}):(l==null?void 0:l.length)>0&&jsxRuntime.jsxs(u,{variant:"outline",onClick:()=>a(),className:"bg-background",children:[jsxRuntime.jsx(pe,{className:"mr-2"}),"Regenerate response"]})}),jsxRuntime.jsx("div",{className:"space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4",children:jsxRuntime.jsx(xe,{onSubmit:d=>S(this,null,function*(){yield t({id:e,content:d,role:"user"});}),input:i,setInput:m,isLoading:o})})]})})}function Y({href:e,children:o}){return jsxRuntime.jsxs("a",{href:e,target:"_blank",className:"inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",children:[jsxRuntime.jsx("span",{children:o}),jsxRuntime.jsx("svg",{"aria-hidden":"true",height:"7",viewBox:"0 0 6 6",width:"7",className:"opacity-70",children:jsxRuntime.jsx("path",{d:"M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",fill:"currentColor"})})]})}var to=[{heading:"Explain technical concepts",message:'What is a "serverless function"?'},{heading:"Summarize an article",message:`Summarize the following article for a 2nd grader:
|
|
45
|
+
`},{heading:"Draft an email",message:`Draft an email to my boss about the following:
|
|
46
|
+
`}],ye=e=>jsxRuntime.jsx("div",{className:"mx-auto max-w-2xl px-4",children:jsxRuntime.jsxs("div",{className:"rounded-lg border bg-background p-8",children:[jsxRuntime.jsx("h1",{className:"mb-2 text-lg font-semibold",children:"Welcome to Copilot! \u{1F44B}"}),jsxRuntime.jsxs("p",{className:"mb-2 leading-normal text-muted-foreground",children:["This is a Copilot built with"," ",jsxRuntime.jsx(Y,{href:"https://recursively.ai",children:"recursively.ai's"})," ",jsxRuntime.jsx(Y,{href:"https://github.com/RecursivelyAI/CopilotKit",children:"CopilotKit"})," ","."]}),jsxRuntime.jsx("p",{className:"leading-normal text-muted-foreground",children:"You can start a conversation here or try the following examples:"}),jsxRuntime.jsx("div",{className:"mt-4 flex flex-col items-start space-y-2",children:to.map((o,r)=>jsxRuntime.jsxs(u,{variant:"link",className:"h-auto p-0 text-base",onClick:()=>e.setInput(o.message),children:[jsxRuntime.jsx(ne,{className:"mr-2 text-muted-foreground"}),o.heading]},r))})]})});function Ne(e=0){let[o,r]=V__namespace.useState(!1);return V__namespace.useEffect(()=>{let t=()=>{r(window.innerHeight+window.scrollY>=document.body.offsetHeight-e);};return window.addEventListener("scroll",t,{passive:!0}),t(),()=>{window.removeEventListener("scroll",t);}},[e]),o}function Pe({trackVisibility:e}){let o=Ne(),{ref:r,entry:t,inView:a}=reactIntersectionObserver.useInView({trackVisibility:e,delay:100,rootMargin:"0px 0px -150px 0px"});return V__namespace.useEffect(()=>{o&&e&&!a&&(t==null||t.target.scrollIntoView({block:"start"}));},[a,t,o,e]),jsxRuntime.jsx("div",{ref:r,className:"h-px w-full"})}function q({id:e,initialMessages:o,makeSystemMessage:r,EmptyScreen:t=ye}){let{visibleMessages:a,append:i,reload:m,stop:l,isLoading:d,input:h,setInput:C}=reactCore.useCopilotChat({id:e,initialMessages:o,makeSystemMessage:r});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col overflow-hidden box-border items-start",children:[jsxRuntime.jsx("div",{className:"pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow",children:a.length?jsxRuntime.jsxs("div",{className:"pl-0 pr-6",children:[jsxRuntime.jsx(ve,{messages:a}),jsxRuntime.jsx(Pe,{trackVisibility:d})]}):jsxRuntime.jsx(t,{setInput:C})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 w-full",children:jsxRuntime.jsx(be,{id:e,isLoading:d,stop:l,append:i,reload:m,messages:a,input:h,setInput:C})})]})}function X(e){return jsxRuntime.jsxs("div",{className:"shadow-lg bg-white flex flex-col",style:{width:"100%",height:"100%"},children:[jsxRuntime.jsx(io,n({},e)),jsxRuntime.jsx(q,{})]})}function io(e){return jsxRuntime.jsxs("div",{className:"py-6 bg-white flex items-center justify-between px-4",children:[jsxRuntime.jsx("h1",{className:"text-base font-semibold leading-6 text-gray-900",children:"Copilot Chat"}),jsxRuntime.jsx("div",{className:"ml-3 flex h-7 items-center",children:jsxRuntime.jsxs("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>e.setSidebarOpen(!1),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Close panel"}),jsxRuntime.jsx(outline.XMarkIcon,{className:"h-6 w-6","aria-hidden":"true"})]})})]})}var _=V.createContext({isSidebarOpen:!1,toggleSidebar:()=>{}});function mo({children:e}){let[o,r]=V.useState(!0),t=V.useCallback(()=>{r(a=>!a);},[]);return jsxRuntime.jsx(_.Provider,{value:{isSidebarOpen:o,toggleSidebar:t},children:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{style:{height:"100vh",width:"100vw",position:"relative"},children:[jsxRuntime.jsx("div",{style:{overflowY:"auto",overflowX:"hidden",height:"100%",width:o?"calc(100% - 450px)":"100%",position:"absolute",transition:"width 0.5s ease-in-out"},children:jsxRuntime.jsx("main",{children:e})}),jsxRuntime.jsx("div",{style:{overflowY:"auto",height:"100%",width:"450px",position:"absolute",right:o?"0":"-450px",transition:"right 0.5s ease-in-out"},children:jsxRuntime.jsx(X,{setSidebarOpen:r})}),!o&&jsxRuntime.jsx("button",{onClick:t,style:{position:"absolute",top:"5%",right:"20px",transform:"translateY(-50%)",transition:"opacity 0.5s ease-in-out"},className:"bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",children:"Open Copilot"})]})})})}
|
|
47
|
+
|
|
48
|
+
exports.CopilotChat = q;
|
|
49
|
+
exports.CopilotSidebar = X;
|
|
50
|
+
exports.CopilotSidebarContext = _;
|
|
51
|
+
exports.CopilotSidebarUIProvider = mo;
|
|
52
|
+
exports.Tooltip = A;
|
|
53
|
+
exports.TooltipProvider = Xe;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as V from 'react';
|
|
2
|
+
import { memo, createContext, useState, useCallback, useRef } from 'react';
|
|
3
|
+
import * as O from '@radix-ui/react-separator';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { customAlphabet } from 'nanoid';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
import Ye from 'remark-gfm';
|
|
9
|
+
import $e from 'remark-math';
|
|
10
|
+
import { Prism } from 'react-syntax-highlighter';
|
|
11
|
+
import { coldarkDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
12
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
13
|
+
import { cva } from 'class-variance-authority';
|
|
14
|
+
import Ge from 'react-markdown';
|
|
15
|
+
import Qe from 'react-textarea-autosize';
|
|
16
|
+
import * as w from '@radix-ui/react-tooltip';
|
|
17
|
+
import eo from 'next/link';
|
|
18
|
+
import { useInView } from 'react-intersection-observer';
|
|
19
|
+
import { useCopilotChat } from '@copilotkit/react-core';
|
|
20
|
+
import { XMarkIcon } from '@heroicons/react/24/outline';
|
|
21
|
+
|
|
22
|
+
var Se=Object.defineProperty,Me=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var Q=(e,o,r)=>o in e?Se(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,n=(e,o)=>{for(var r in o||(o={}))ee.call(o,r)&&Q(e,r,o[r]);if(I)for(var r of I(o))oe.call(o,r)&&Q(e,r,o[r]);return e},f=(e,o)=>Me(e,Le(o));var p=(e,o)=>{var r={};for(var t in e)ee.call(e,t)&&o.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&I)for(var t of I(e))o.indexOf(t)<0&&oe.call(e,t)&&(r[t]=e[t]);return r};var S=(e,o,r)=>new Promise((t,a)=>{var i=d=>{try{l(r.next(d));}catch(h){a(h);}},m=d=>{try{l(r.throw(d));}catch(h){a(h);}},l=d=>d.done?t(d.value):Promise.resolve(d.value).then(i,m);l((r=r.apply(e,o)).next());});function s(...e){return twMerge(clsx(e))}customAlphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var U=V.forwardRef((i,a)=>{var m=i,{className:e,orientation:o="horizontal",decorative:r=!0}=m,t=p(m,["className","orientation","decorative"]);return jsx(O.Root,n({ref:a,decorative:r,orientation:o,className:s("shrink-0 bg-border",o==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e)},t))});U.displayName=O.Root.displayName;function T({timeout:e=2e3}){let[o,r]=V.useState(!1);return {isCopied:o,copyToClipboard:a=>{var i;typeof window=="undefined"||!((i=navigator.clipboard)!=null&&i.writeText)||!a||navigator.clipboard.writeText(a).then(()=>{r(!0),setTimeout(()=>{r(!1);},e);});}}}function ae(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsxs("svg",f(n({fill:"currentColor",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",className:s("h-4 w-4",e)},o),{children:[jsx("title",{children:"OpenAI icon"}),jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})]}))}function ne(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z"})}))}function se(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z"})}))}function ie(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M224 128a8 8 0 0 1-8 8h-80v80a8 8 0 0 1-16 0v-80H40a8 8 0 0 1 0-16h80V40a8 8 0 0 1 16 0v80h80a8 8 0 0 1 8 8Z"})}))}function le(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z"})}))}function pe(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z"})}))}function ce(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z"})}))}function B(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z"})}))}function Z(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z"})}))}function me(r){var t=r,{className:e}=t,o=p(t,["className"]);return jsx("svg",f(n({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:s("h-4 w-4",e)},o),{children:jsx("path",{d:"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z"})}))}var D=cva("inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-md hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"shadow-none hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 shadow-none hover:underline"},size:{default:"h-8 px-4 py-2",sm:"h-8 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-8 w-8 p-0"}},defaultVariants:{variant:"default",size:"default"}}),u=V.forwardRef((m,i)=>{var l=m,{className:e,variant:o,size:r,asChild:t=!1}=l,a=p(l,["className","variant","size","asChild"]);return jsx(t?Slot:"button",n({className:s(D({variant:o,size:r,className:e})),ref:i},a))});u.displayName="Button";var Fe={javascript:".js",python:".py",java:".java",c:".c",cpp:".cpp","c++":".cpp","c#":".cs",ruby:".rb",php:".php",swift:".swift","objective-c":".m",kotlin:".kt",typescript:".ts",go:".go",perl:".pl",rust:".rs",scala:".scala",haskell:".hs",lua:".lua",shell:".sh",sql:".sql",html:".html",css:".css"},Ke=(e,o=!1)=>{let r="ABCDEFGHJKLMNPQRSTUVWXY3456789",t="";for(let a=0;a<e;a++)t+=r.charAt(Math.floor(Math.random()*r.length));return o?t.toLowerCase():t},F=memo(({language:e,value:o})=>{let{isCopied:r,copyToClipboard:t}=T({timeout:2e3});return jsxs("div",{className:"codeblock relative w-full bg-zinc-950 font-sans",children:[jsxs("div",{className:"flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100",children:[jsx("span",{className:"text-xs lowercase",children:e}),jsxs("div",{className:"flex items-center space-x-1",children:[jsxs(u,{variant:"ghost",className:"hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",onClick:()=>{if(typeof window=="undefined")return;let m=Fe[e]||".file",l=`file-${Ke(3,!0)}${m}`,d=window.prompt("Enter file name",l);if(!d)return;let h=new Blob([o],{type:"text/plain"}),C=URL.createObjectURL(h),N=document.createElement("a");N.download=d,N.href=C,N.style.display="none",document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(C);},size:"icon",children:[jsx(me,{}),jsx("span",{className:"sr-only",children:"Download"})]}),jsxs(u,{variant:"ghost",size:"icon",className:"text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",onClick:()=>{r||t(o);},children:[r?jsx(Z,{}):jsx(B,{}),jsx("span",{className:"sr-only",children:"Copy code"})]})]})]}),jsx(Prism,{language:e,style:coldarkDark,PreTag:"div",showLineNumbers:!0,customStyle:{margin:0,width:"100%",background:"transparent",padding:"1.5rem 1rem"},codeTagProps:{style:{fontSize:"0.9rem",fontFamily:"var(--font-mono)"}},children:o})]})});F.displayName="CodeBlock";var fe=memo(Ge,(e,o)=>e.children===o.children&&e.className===o.className);function ue(t){var a=t,{message:e,className:o}=a,r=p(a,["message","className"]);let{isCopied:i,copyToClipboard:m}=T({timeout:2e3}),l=()=>{i||m(e.content);};return jsx("div",f(n({className:s("flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0",o)},r),{children:jsxs(u,{variant:"ghost",size:"icon",onClick:l,children:[i?jsx(Z,{}):jsx(B,{}),jsx("span",{className:"sr-only",children:"Copy message"})]})}))}function he(r){var t=r,{message:e}=t,o=p(t,["message"]);return jsxs("div",f(n({className:s("group relative mb-4 flex items-start")},o),{children:[jsx("div",{className:s("flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow",e.role==="user"?"bg-background":"bg-primary text-primary-foreground"),children:e.role==="user"?jsx(se,{}):jsx(ae,{})}),jsxs("div",{className:"ml-4 flex-1 space-y-2 overflow-hidden px-1",children:[jsx(fe,{className:"prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",remarkPlugins:[Ye,$e],components:{p({children:a}){return jsx("p",{className:"mb-2 last:mb-0",children:a})},code(d){var h=d,{children:a,className:i,inline:m}=h,l=p(h,["children","className","inline"]);if(a.length){if(a[0]=="\u258D")return jsx("span",{className:"mt-1 animate-pulse cursor-default",children:"\u258D"});a[0]=a[0].replace("`\u258D`","\u258D");}let C=/language-(\w+)/.exec(i||"");return m?jsx("code",f(n({className:i},l),{children:a})):jsx(F,n({language:C&&C[1]||"",value:String(a).replace(/\n$/,"")},l),Math.random())}},children:e.content}),jsx(ue,{message:e})]})]}))}function ve({messages:e}){let o=e.filter(r=>r.role!=="system");return o.length?jsx("div",{className:"relative mx-auto max-w-2xl px-0",children:o.map((r,t)=>jsxs("div",{children:[jsx(he,{message:r}),t<o.length-1&&jsx(U,{className:"my-4 md:my-4"})]},t))}):null}function we(){let e=useRef(null);return {formRef:e,onKeyDown:r=>{var t;r.key==="Enter"&&!r.shiftKey&&!r.nativeEvent.isComposing&&((t=e.current)==null||t.requestSubmit(),r.preventDefault());}}}var Xe=w.Provider,A=w.Root,j=w.Trigger,E=V.forwardRef((a,t)=>{var i=a,{className:e,sideOffset:o=4}=i,r=p(i,["className","sideOffset"]);return jsx(w.Content,n({ref:t,sideOffset:o,className:s("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",e)},r))});E.displayName=w.Content.displayName;function xe({onSubmit:e,input:o,setInput:r,isLoading:t}){let{formRef:a,onKeyDown:i}=we(),m=V.useRef(null);return V.useEffect(()=>{m.current&&m.current.focus();},[]),jsx("form",{onSubmit:l=>S(this,null,function*(){l.preventDefault(),o!=null&&o.trim()&&(r(""),yield e(o));}),ref:a,children:jsxs("div",{className:"relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12",children:[jsxs(A,{children:[jsx(j,{asChild:!0,children:jsxs(eo,{href:"/",className:s(D({size:"sm",variant:"outline"}),"absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4"),children:[jsx(ie,{}),jsx("span",{className:"sr-only",children:"New Chat"})]})}),jsx(E,{children:"New Chat"})]}),jsx(Qe,{ref:m,tabIndex:0,onKeyDown:i,rows:1,value:o,onChange:l=>r(l.target.value),placeholder:"Send a message.",spellCheck:!1,className:"min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"}),jsx("div",{className:"absolute right-0 top-4 sm:right-4",children:jsxs(A,{children:[jsx(j,{asChild:!0,children:jsxs(u,{type:"submit",size:"icon",disabled:t||o==="",className:" bg-slate-300",children:[jsx(le,{}),jsx("span",{className:"sr-only",children:"Send message"})]})}),jsx(E,{children:"Send message"})]})})]})})}function be({id:e,isLoading:o,stop:r,append:t,reload:a,input:i,setInput:m,messages:l}){return jsx("div",{className:"inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8",style:{width:"100%",overflow:"hidden",boxSizing:"border-box"},children:jsxs("div",{className:"mx-auto sm:max-w-2xl sm:px-4",children:[jsx("div",{className:"flex h-10 items-center justify-center mb-4",children:o?jsxs(u,{variant:"outline",onClick:()=>r(),className:"bg-background",children:[jsx(ce,{className:"mr-2"}),"Stop generating"]}):(l==null?void 0:l.length)>0&&jsxs(u,{variant:"outline",onClick:()=>a(),className:"bg-background",children:[jsx(pe,{className:"mr-2"}),"Regenerate response"]})}),jsx("div",{className:"space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4",children:jsx(xe,{onSubmit:d=>S(this,null,function*(){yield t({id:e,content:d,role:"user"});}),input:i,setInput:m,isLoading:o})})]})})}function Y({href:e,children:o}){return jsxs("a",{href:e,target:"_blank",className:"inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",children:[jsx("span",{children:o}),jsx("svg",{"aria-hidden":"true",height:"7",viewBox:"0 0 6 6",width:"7",className:"opacity-70",children:jsx("path",{d:"M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",fill:"currentColor"})})]})}var to=[{heading:"Explain technical concepts",message:'What is a "serverless function"?'},{heading:"Summarize an article",message:`Summarize the following article for a 2nd grader:
|
|
23
|
+
`},{heading:"Draft an email",message:`Draft an email to my boss about the following:
|
|
24
|
+
`}],ye=e=>jsx("div",{className:"mx-auto max-w-2xl px-4",children:jsxs("div",{className:"rounded-lg border bg-background p-8",children:[jsx("h1",{className:"mb-2 text-lg font-semibold",children:"Welcome to Copilot! \u{1F44B}"}),jsxs("p",{className:"mb-2 leading-normal text-muted-foreground",children:["This is a Copilot built with"," ",jsx(Y,{href:"https://recursively.ai",children:"recursively.ai's"})," ",jsx(Y,{href:"https://github.com/RecursivelyAI/CopilotKit",children:"CopilotKit"})," ","."]}),jsx("p",{className:"leading-normal text-muted-foreground",children:"You can start a conversation here or try the following examples:"}),jsx("div",{className:"mt-4 flex flex-col items-start space-y-2",children:to.map((o,r)=>jsxs(u,{variant:"link",className:"h-auto p-0 text-base",onClick:()=>e.setInput(o.message),children:[jsx(ne,{className:"mr-2 text-muted-foreground"}),o.heading]},r))})]})});function Ne(e=0){let[o,r]=V.useState(!1);return V.useEffect(()=>{let t=()=>{r(window.innerHeight+window.scrollY>=document.body.offsetHeight-e);};return window.addEventListener("scroll",t,{passive:!0}),t(),()=>{window.removeEventListener("scroll",t);}},[e]),o}function Pe({trackVisibility:e}){let o=Ne(),{ref:r,entry:t,inView:a}=useInView({trackVisibility:e,delay:100,rootMargin:"0px 0px -150px 0px"});return V.useEffect(()=>{o&&e&&!a&&(t==null||t.target.scrollIntoView({block:"start"}));},[a,t,o,e]),jsx("div",{ref:r,className:"h-px w-full"})}function q({id:e,initialMessages:o,makeSystemMessage:r,EmptyScreen:t=ye}){let{visibleMessages:a,append:i,reload:m,stop:l,isLoading:d,input:h,setInput:C}=useCopilotChat({id:e,initialMessages:o,makeSystemMessage:r});return jsxs("div",{className:"w-full h-full flex flex-col overflow-hidden box-border items-start",children:[jsx("div",{className:"pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow",children:a.length?jsxs("div",{className:"pl-0 pr-6",children:[jsx(ve,{messages:a}),jsx(Pe,{trackVisibility:d})]}):jsx(t,{setInput:C})}),jsx("div",{className:"flex-shrink-0 w-full",children:jsx(be,{id:e,isLoading:d,stop:l,append:i,reload:m,messages:a,input:h,setInput:C})})]})}function X(e){return jsxs("div",{className:"shadow-lg bg-white flex flex-col",style:{width:"100%",height:"100%"},children:[jsx(io,n({},e)),jsx(q,{})]})}function io(e){return jsxs("div",{className:"py-6 bg-white flex items-center justify-between px-4",children:[jsx("h1",{className:"text-base font-semibold leading-6 text-gray-900",children:"Copilot Chat"}),jsx("div",{className:"ml-3 flex h-7 items-center",children:jsxs("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>e.setSidebarOpen(!1),children:[jsx("span",{className:"sr-only",children:"Close panel"}),jsx(XMarkIcon,{className:"h-6 w-6","aria-hidden":"true"})]})})]})}var _=createContext({isSidebarOpen:!1,toggleSidebar:()=>{}});function mo({children:e}){let[o,r]=useState(!0),t=useCallback(()=>{r(a=>!a);},[]);return jsx(_.Provider,{value:{isSidebarOpen:o,toggleSidebar:t},children:jsx(Fragment,{children:jsxs("div",{style:{height:"100vh",width:"100vw",position:"relative"},children:[jsx("div",{style:{overflowY:"auto",overflowX:"hidden",height:"100%",width:o?"calc(100% - 450px)":"100%",position:"absolute",transition:"width 0.5s ease-in-out"},children:jsx("main",{children:e})}),jsx("div",{style:{overflowY:"auto",height:"100%",width:"450px",position:"absolute",right:o?"0":"-450px",transition:"right 0.5s ease-in-out"},children:jsx(X,{setSidebarOpen:r})}),!o&&jsx("button",{onClick:t,style:{position:"absolute",top:"5%",right:"20px",transform:"translateY(-50%)",transition:"opacity 0.5s ease-in-out"},className:"bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",children:"Open Copilot"})]})})})}
|
|
25
|
+
|
|
26
|
+
export { q as CopilotChat, X as CopilotSidebar, _ as CopilotSidebarContext, mo as CopilotSidebarUIProvider, A as Tooltip, Xe as TooltipProvider };
|
package/package.json
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.3.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"**/*.css"
|
|
10
10
|
],
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
+
"main": "./dist/index.mjs",
|
|
12
13
|
"exports": {
|
|
13
|
-
".": "./dist",
|
|
14
|
+
".": "./dist/index.mjs",
|
|
14
15
|
"./styles.css": "./dist/index.css"
|
|
15
16
|
},
|
|
16
17
|
"license": "MIT",
|
|
@@ -19,18 +20,48 @@
|
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/react": "^18.2.5",
|
|
23
|
+
"@types/react-syntax-highlighter": "^15.5.7",
|
|
22
24
|
"eslint": "^7.32.0",
|
|
23
25
|
"postcss": "^8.4.20",
|
|
24
26
|
"react": "^18.2.0",
|
|
25
27
|
"tsup": "^6.1.3",
|
|
26
28
|
"typescript": "^4.9.4",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"tsconfig": "0.1.0",
|
|
30
|
+
"eslint-config-custom": "0.1.0",
|
|
31
|
+
"tailwind-config": "0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@heroicons/react": "^2.0.18",
|
|
35
|
+
"@radix-ui/react-alert-dialog": "^1.0.4",
|
|
36
|
+
"@radix-ui/react-dialog": "^1.0.4",
|
|
37
|
+
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
|
38
|
+
"@radix-ui/react-label": "^2.0.2",
|
|
39
|
+
"@radix-ui/react-select": "^1.2.2",
|
|
40
|
+
"@radix-ui/react-separator": "^1.0.3",
|
|
41
|
+
"@radix-ui/react-slot": "^1.0.2",
|
|
42
|
+
"@radix-ui/react-switch": "^1.0.3",
|
|
43
|
+
"@radix-ui/react-tooltip": "^1.0.6",
|
|
44
|
+
"ai": "^2.1.19",
|
|
45
|
+
"class-variance-authority": "^0.6.1",
|
|
46
|
+
"clsx": "^1.2.1",
|
|
47
|
+
"nanoid": "^4.0.2",
|
|
48
|
+
"next": "^13.4.1",
|
|
49
|
+
"next-themes": "^0.2.1",
|
|
50
|
+
"react-hot-toast": "^2.4.1",
|
|
51
|
+
"react-intersection-observer": "^9.5.2",
|
|
52
|
+
"react-markdown": "^8.0.7",
|
|
53
|
+
"react-syntax-highlighter": "^15.5.0",
|
|
54
|
+
"react-textarea-autosize": "^8.5.2",
|
|
55
|
+
"remark-gfm": "^3.0.1",
|
|
56
|
+
"remark-math": "^5.1.1",
|
|
57
|
+
"tailwind": "^4.0.0",
|
|
58
|
+
"tailwind-merge": "^1.13.2",
|
|
59
|
+
"@copilotkit/react-core": "0.3.0"
|
|
30
60
|
},
|
|
31
61
|
"scripts": {
|
|
32
|
-
"build": "tsup --format cjs --dts",
|
|
33
|
-
"dev": "tsup --watch",
|
|
34
|
-
"check-types": "tsc --noEmit"
|
|
62
|
+
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
|
|
63
|
+
"dev": "tsup src/index.tsx --format esm,cjs --dts --external react --watch",
|
|
64
|
+
"check-types": "tsc --noEmit",
|
|
65
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next"
|
|
35
66
|
}
|
|
36
67
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Message } from 'ai'
|
|
2
|
+
|
|
3
|
+
import { Separator } from './ui/separator'
|
|
4
|
+
import { ChatMessage } from './chat-message'
|
|
5
|
+
|
|
6
|
+
export interface ChatList {
|
|
7
|
+
messages: Message[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ChatList({ messages }: ChatList) {
|
|
11
|
+
// we don't want to display system messages
|
|
12
|
+
const displayedMessages = messages.filter(
|
|
13
|
+
message => message.role !== 'system'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if (!displayedMessages.length) {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="relative mx-auto max-w-2xl px-0">
|
|
22
|
+
{displayedMessages.map((message, index) => (
|
|
23
|
+
<div key={index}>
|
|
24
|
+
<ChatMessage message={message} />
|
|
25
|
+
{index < displayedMessages.length - 1 && (
|
|
26
|
+
<Separator className="my-4 md:my-4" />
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
))}
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type Message } from 'ai'
|
|
4
|
+
|
|
5
|
+
import { Button } from './ui/button'
|
|
6
|
+
import { IconCheck, IconCopy } from './ui/icons'
|
|
7
|
+
import { useCopyToClipboard } from '../../hooks/use-copy-to-clipboard'
|
|
8
|
+
import { cn } from '../../lib/utils'
|
|
9
|
+
|
|
10
|
+
interface ChatMessageActionsProps extends React.ComponentProps<'div'> {
|
|
11
|
+
message: Message
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ChatMessageActions({
|
|
15
|
+
message,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: ChatMessageActionsProps) {
|
|
19
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 })
|
|
20
|
+
|
|
21
|
+
const onCopy = () => {
|
|
22
|
+
if (isCopied) return
|
|
23
|
+
copyToClipboard(message.content)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={cn(
|
|
29
|
+
'flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0',
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<Button variant="ghost" size="icon" onClick={onCopy}>
|
|
35
|
+
{isCopied ? <IconCheck /> : <IconCopy />}
|
|
36
|
+
<span className="sr-only">Copy message</span>
|
|
37
|
+
</Button>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Message } from 'ai'
|
|
2
|
+
import remarkGfm from 'remark-gfm'
|
|
3
|
+
import remarkMath from 'remark-math'
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils'
|
|
6
|
+
import { CodeBlock } from './ui/codeblock'
|
|
7
|
+
import { MemoizedReactMarkdown } from './markdown'
|
|
8
|
+
import { IconOpenAI, IconUser } from './ui/icons'
|
|
9
|
+
import { ChatMessageActions } from './chat-message-actions'
|
|
10
|
+
|
|
11
|
+
export interface ChatMessageProps {
|
|
12
|
+
message: Message
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ChatMessage({ message, ...props }: ChatMessageProps) {
|
|
16
|
+
return (
|
|
17
|
+
<div className={cn('group relative mb-4 flex items-start')} {...props}>
|
|
18
|
+
<div
|
|
19
|
+
className={cn(
|
|
20
|
+
'flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow',
|
|
21
|
+
message.role === 'user'
|
|
22
|
+
? 'bg-background'
|
|
23
|
+
: 'bg-primary text-primary-foreground'
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
{message.role === 'user' ? <IconUser /> : <IconOpenAI />}
|
|
27
|
+
</div>
|
|
28
|
+
<div className="ml-4 flex-1 space-y-2 overflow-hidden px-1">
|
|
29
|
+
<MemoizedReactMarkdown
|
|
30
|
+
className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm"
|
|
31
|
+
remarkPlugins={[remarkGfm, remarkMath]}
|
|
32
|
+
components={{
|
|
33
|
+
p({ children }) {
|
|
34
|
+
return <p className="mb-2 last:mb-0">{children}</p>
|
|
35
|
+
},
|
|
36
|
+
code({ children, className, inline, ...props }) {
|
|
37
|
+
if (children.length) {
|
|
38
|
+
if (children[0] == '▍') {
|
|
39
|
+
return (
|
|
40
|
+
<span className="mt-1 animate-pulse cursor-default">▍</span>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
children[0] = (children[0] as string).replace('`▍`', '▍')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const match = /language-(\w+)/.exec(className || '')
|
|
48
|
+
|
|
49
|
+
if (inline) {
|
|
50
|
+
return (
|
|
51
|
+
<code className={className} {...props}>
|
|
52
|
+
{children}
|
|
53
|
+
</code>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<CodeBlock
|
|
59
|
+
key={Math.random()}
|
|
60
|
+
language={(match && match[1]) || ''}
|
|
61
|
+
value={String(children).replace(/\n$/, '')}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{message.content}
|
|
69
|
+
</MemoizedReactMarkdown>
|
|
70
|
+
<ChatMessageActions message={message} />
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|