khoj 1.20.4.dev13__py3-none-any.whl → 1.20.5.dev15__py3-none-any.whl

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.
Files changed (56) hide show
  1. khoj/configure.py +1 -0
  2. khoj/database/adapters/__init__.py +15 -8
  3. khoj/database/admin.py +11 -1
  4. khoj/database/migrations/0056_searchmodelconfig_cross_encoder_model_config.py +17 -0
  5. khoj/database/models/__init__.py +2 -0
  6. khoj/interface/compiled/404/index.html +1 -1
  7. khoj/interface/compiled/_next/static/chunks/app/agents/{page-922694b75f1fb67b.js → page-6ade083d5e27a023.js} +1 -1
  8. khoj/interface/compiled/_next/static/chunks/app/automations/{page-d7972645ccb80df1.js → page-559111e9b97f158d.js} +1 -1
  9. khoj/interface/compiled/_next/static/chunks/app/chat/{page-51ab7c4b766ff344.js → page-37ff98d93e65b5a4.js} +1 -1
  10. khoj/interface/compiled/_next/static/chunks/app/factchecker/{page-60be5e3295e2c0bc.js → page-6ca723a9ff0dfd70.js} +1 -1
  11. khoj/interface/compiled/_next/static/chunks/app/{page-ef4e7248d37fae41.js → page-a7e6517e91dde51a.js} +1 -1
  12. khoj/interface/compiled/_next/static/chunks/app/search/{page-dcd385f03255ef36.js → page-fa15807b1ad7e30b.js} +1 -1
  13. khoj/interface/compiled/_next/static/chunks/app/settings/{page-e83f6fa32691ca64.js → page-b0fae6e054ca311e.js} +1 -1
  14. khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-699b364dc6fbf139.js → page-0ae8f5b868af65c1.js} +1 -1
  15. khoj/interface/compiled/_next/static/chunks/{webpack-c6008e79c8ef349d.js → webpack-072d1cbdec7e1782.js} +1 -1
  16. khoj/interface/compiled/_next/static/css/2bfe35fbe2c97a56.css +1 -0
  17. khoj/interface/compiled/_next/static/css/592ca99f5122e75a.css +1 -0
  18. khoj/interface/compiled/agents/index.html +1 -1
  19. khoj/interface/compiled/agents/index.txt +2 -2
  20. khoj/interface/compiled/automations/index.html +1 -1
  21. khoj/interface/compiled/automations/index.txt +2 -2
  22. khoj/interface/compiled/chat/index.html +1 -1
  23. khoj/interface/compiled/chat/index.txt +2 -2
  24. khoj/interface/compiled/factchecker/index.html +1 -1
  25. khoj/interface/compiled/factchecker/index.txt +2 -2
  26. khoj/interface/compiled/index.html +1 -1
  27. khoj/interface/compiled/index.txt +2 -2
  28. khoj/interface/compiled/search/index.html +1 -1
  29. khoj/interface/compiled/search/index.txt +2 -2
  30. khoj/interface/compiled/settings/index.html +1 -1
  31. khoj/interface/compiled/settings/index.txt +2 -2
  32. khoj/interface/compiled/share/chat/index.html +1 -1
  33. khoj/interface/compiled/share/chat/index.txt +2 -2
  34. khoj/processor/conversation/anthropic/anthropic_chat.py +6 -2
  35. khoj/processor/conversation/offline/chat_model.py +15 -3
  36. khoj/processor/conversation/openai/gpt.py +6 -3
  37. khoj/processor/conversation/openai/utils.py +1 -1
  38. khoj/processor/conversation/prompts.py +20 -0
  39. khoj/processor/embeddings.py +3 -1
  40. khoj/processor/tools/online_search.py +9 -3
  41. khoj/routers/api.py +3 -1
  42. khoj/routers/api_chat.py +2 -2
  43. khoj/routers/helpers.py +10 -2
  44. khoj/search_filter/file_filter.py +5 -2
  45. {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev15.dist-info}/METADATA +1 -1
  46. {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev15.dist-info}/RECORD +54 -53
  47. khoj/interface/compiled/_next/static/css/4cae6c0e5c72fb2d.css +0 -1
  48. khoj/interface/compiled/_next/static/css/df6f4c34ec280d53.css +0 -1
  49. /khoj/interface/compiled/_next/static/{EuaXDNeXisAc9H0EHd10x → K0mF1QxJRVM2LVZZQ_Edc}/_buildManifest.js +0 -0
  50. /khoj/interface/compiled/_next/static/{EuaXDNeXisAc9H0EHd10x → K0mF1QxJRVM2LVZZQ_Edc}/_ssgManifest.js +0 -0
  51. /khoj/interface/compiled/_next/static/chunks/{8423-132ea64eac83fd43.js → 8423-898d821eaab634af.js} +0 -0
  52. /khoj/interface/compiled/_next/static/chunks/{9178-5a1fa2b9023249af.js → 9178-ef3257c08d8973c8.js} +0 -0
  53. /khoj/interface/compiled/_next/static/chunks/{9417-2e54c6fd056982d8.js → 9417-5d14ac74aaab2c66.js} +0 -0
  54. {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev15.dist-info}/WHEEL +0 -0
  55. {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev15.dist-info}/entry_points.txt +0 -0
  56. {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev15.dist-info}/licenses/LICENSE +0 -0
khoj/configure.py CHANGED
@@ -263,6 +263,7 @@ def configure_server(
263
263
  model.cross_encoder,
264
264
  model.cross_encoder_inference_endpoint,
265
265
  model.cross_encoder_inference_endpoint_api_key,
266
+ model_kwargs=model.cross_encoder_model_config,
266
267
  )
267
268
  }
268
269
  )
@@ -1048,7 +1048,7 @@ class FileObjectAdapters:
1048
1048
 
1049
1049
 
1050
1050
  class EntryAdapters:
1051
- word_filer = WordFilter()
1051
+ word_filter = WordFilter()
1052
1052
  file_filter = FileFilter()
1053
1053
  date_filter = DateFilter()
1054
1054
 
@@ -1150,14 +1150,14 @@ class EntryAdapters:
1150
1150
  def apply_filters(user: KhojUser, query: str, file_type_filter: str = None):
1151
1151
  q_filter_terms = Q()
1152
1152
 
1153
- explicit_word_terms = EntryAdapters.word_filer.get_filter_terms(query)
1153
+ word_filters = EntryAdapters.word_filter.get_filter_terms(query)
1154
1154
  file_filters = EntryAdapters.file_filter.get_filter_terms(query)
1155
1155
  date_filters = EntryAdapters.date_filter.get_query_date_range(query)
1156
1156
 
1157
- if len(explicit_word_terms) == 0 and len(file_filters) == 0 and len(date_filters) == 0:
1157
+ if len(word_filters) == 0 and len(file_filters) == 0 and len(date_filters) == 0:
1158
1158
  return Entry.objects.filter(user=user)
1159
1159
 
1160
- for term in explicit_word_terms:
1160
+ for term in word_filters:
1161
1161
  if term.startswith("+"):
1162
1162
  q_filter_terms &= Q(raw__icontains=term[1:])
1163
1163
  elif term.startswith("-"):
@@ -1167,7 +1167,16 @@ class EntryAdapters:
1167
1167
 
1168
1168
  if len(file_filters) > 0:
1169
1169
  for term in file_filters:
1170
- q_file_filter_terms |= Q(file_path__regex=term)
1170
+ if term.startswith("-"):
1171
+ # Convert the glob term to a regex pattern
1172
+ regex_term = re.escape(term[1:]).replace(r"\*", ".*").replace(r"\?", ".")
1173
+ # Exclude all files that match the regex term
1174
+ q_file_filter_terms &= ~Q(file_path__regex=regex_term)
1175
+ else:
1176
+ # Convert the glob term to a regex pattern
1177
+ regex_term = re.escape(term).replace(r"\*", ".*").replace(r"\?", ".")
1178
+ # Include any files that match the regex term
1179
+ q_file_filter_terms |= Q(file_path__regex=regex_term)
1171
1180
 
1172
1181
  q_filter_terms &= q_file_filter_terms
1173
1182
 
@@ -1182,9 +1191,7 @@ class EntryAdapters:
1182
1191
  formatted_max_date = date.fromtimestamp(max_date).strftime("%Y-%m-%d")
1183
1192
  q_filter_terms &= Q(embeddings_dates__date__lte=formatted_max_date)
1184
1193
 
1185
- relevant_entries = Entry.objects.filter(user=user).filter(
1186
- q_filter_terms,
1187
- )
1194
+ relevant_entries = Entry.objects.filter(user=user).filter(q_filter_terms)
1188
1195
  if file_type_filter:
1189
1196
  relevant_entries = relevant_entries.filter(file_type=file_type_filter)
1190
1197
  return relevant_entries
khoj/database/admin.py CHANGED
@@ -94,7 +94,6 @@ admin.site.register(KhojUser, KhojUserAdmin)
94
94
 
95
95
  admin.site.register(ProcessLock)
96
96
  admin.site.register(SpeechToTextModelOptions)
97
- admin.site.register(SearchModelConfig)
98
97
  admin.site.register(ReflectiveQuestion)
99
98
  admin.site.register(UserSearchModelConfig)
100
99
  admin.site.register(ClientApplication)
@@ -178,6 +177,17 @@ class OpenAIProcessorConversationConfigAdmin(admin.ModelAdmin):
178
177
  search_fields = ("id", "name", "api_key", "api_base_url")
179
178
 
180
179
 
180
+ @admin.register(SearchModelConfig)
181
+ class SearchModelConfigAdmin(admin.ModelAdmin):
182
+ list_display = (
183
+ "id",
184
+ "name",
185
+ "bi_encoder",
186
+ "cross_encoder",
187
+ )
188
+ search_fields = ("id", "name", "bi_encoder", "cross_encoder")
189
+
190
+
181
191
  @admin.register(ServerChatSettings)
182
192
  class ServerChatSettingsAdmin(admin.ModelAdmin):
183
193
  list_display = (
@@ -0,0 +1,17 @@
1
+ # Generated by Django 5.0.7 on 2024-08-07 09:12
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("database", "0055_alter_agent_style_icon"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AddField(
13
+ model_name="searchmodelconfig",
14
+ name="cross_encoder_model_config",
15
+ field=models.JSONField(blank=True, default=dict),
16
+ ),
17
+ ]
@@ -259,6 +259,8 @@ class SearchModelConfig(BaseModel):
259
259
  bi_encoder_docs_encode_config = models.JSONField(default=dict, blank=True)
260
260
  # Cross-encoder model of sentence-transformer type to load from HuggingFace
261
261
  cross_encoder = models.CharField(max_length=200, default="mixedbread-ai/mxbai-rerank-xsmall-v1")
262
+ # Config passed to the cross-encoder model constructor. E.g. device="cuda:0", trust_remote_server=True etc.
263
+ cross_encoder_model_config = models.JSONField(default=dict, blank=True)
262
264
  # Inference server API endpoint to use for embeddings inference. Bi-encoder model should be hosted on this server
263
265
  embeddings_inference_endpoint = models.CharField(max_length=200, default=None, null=True, blank=True)
264
266
  # Inference server API Key to use for embeddings inference. Bi-encoder model should be hosted on this server
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/9d5b867ec04494a6.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c6008e79c8ef349d.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-52c1be60135eb057.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta http-equiv="Content-Security-Policy" content="default-src &#x27;self&#x27; https://assets.khoj.dev; media-src * blob:; script-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; &#x27;unsafe-eval&#x27;; connect-src &#x27;self&#x27; https://ipapi.co/json ws://localhost:42110; style-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; https://fonts.googleapis.com; img-src &#x27;self&#x27; data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src &#x27;self&#x27; https://assets.khoj.dev https://fonts.gstatic.com; child-src &#x27;none&#x27;; object-src &#x27;none&#x27;;"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-c6008e79c8ef349d.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/9d5b867ec04494a6.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/9d5b867ec04494a6.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"EuaXDNeXisAc9H0EHd10x\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/_not-found/\",\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]]],null],null]},[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[],\"styles\":null}]}]]}],null],null],\"couldBeIntercepted\":false,\"initialHead\":[false,\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/9d5b867ec04494a6.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-072d1cbdec7e1782.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-52c1be60135eb057.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta http-equiv="Content-Security-Policy" content="default-src &#x27;self&#x27; https://assets.khoj.dev; media-src * blob:; script-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; &#x27;unsafe-eval&#x27;; connect-src &#x27;self&#x27; https://ipapi.co/json ws://localhost:42110; style-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; https://fonts.googleapis.com; img-src &#x27;self&#x27; data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src &#x27;self&#x27; https://assets.khoj.dev https://fonts.gstatic.com; child-src &#x27;none&#x27;; object-src &#x27;none&#x27;;"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-072d1cbdec7e1782.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/9d5b867ec04494a6.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/9d5b867ec04494a6.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"K0mF1QxJRVM2LVZZQ_Edc\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/_not-found/\",\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]]],null],null]},[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[],\"styles\":null}]}]]}],null],null],\"couldBeIntercepted\":false,\"initialHead\":[false,\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9718],{1813:function(e,a,t){Promise.resolve().then(t.bind(t,87529))},87529:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return R}});var n=t(57437),r=t(15283),l=t.n(r),s=t(66648),o=t(29039),c=t(2265),i=t(79306),d=t(50495),h=t(19666),u=t(52195);let m=new Map([["bold",c.createElement(c.Fragment,null,c.createElement("path",{d:"M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z"}))],["duotone",c.createElement(c.Fragment,null,c.createElement("path",{d:"M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z",opacity:"0.2"}),c.createElement("path",{d:"M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z"}))],["fill",c.createElement(c.Fragment,null,c.createElement("path",{d:"M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z"}))],["light",c.createElement(c.Fragment,null,c.createElement("path",{d:"M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z"}))],["regular",c.createElement(c.Fragment,null,c.createElement("path",{d:"M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z"}))],["thin",c.createElement(c.Fragment,null,c.createElement("path",{d:"M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z"}))]]);var g=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,b=(e,a,t)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,w=(e,a)=>{for(var t in a||(a={}))j.call(a,t)&&b(e,t,a[t]);if(x)for(var t of x(a))v.call(a,t)&&b(e,t,a[t]);return e},y=(e,a)=>p(e,f(a));let N=(0,c.forwardRef)((e,a)=>c.createElement(u.Z,y(w({ref:a},e),{weights:m})));N.displayName="PaperPlaneTilt";var L=t(35418),E=t(64945),Z=t(36013),A=t(90837),O=t(7951),M=t(66820),k=t(58485),P=t(48861),_=t(89417),F=t(58575),z=t(47412),C=t(69591);async function V(e,a){let t="/login?next=/agents?agent=".concat(e);if(!a){window.location.href=t;return}let n=await fetch("/api/chat/sessions?agent_slug=".concat(e),{method:"POST"}),r=await n.json();200==n.status?window.location.href="/chat?conversationId=".concat(r.conversation_id):403==n.status||401==n.status?window.location.href=t:alert("Failed to start chat session")}let S=()=>window.fetch("/api/agents").then(e=>e.json()).catch(e=>console.log(e));function H(e){let a=new URLSearchParams(window.location.search).get("agent"),[t,r]=(0,c.useState)(a===e.data.slug),[o,i]=(0,c.useState)(!1),h=e.userProfile;t&&window.history.pushState({},"Khoj AI - Agent ".concat(e.data.slug),"/agents?agent=".concat(e.data.slug));let u=(0,F.oz)(e.data.color);return(0,n.jsxs)(Z.Zb,{className:"shadow-sm bg-gradient-to-b from-white 20% to-".concat(e.data.color?e.data.color:"gray","-100/50 dark:from-[hsl(var(--background))] dark:to-").concat(e.data.color?e.data.color:"gray","-950/50 rounded-xl hover:shadow-md"),children:[o&&(0,n.jsx)(M.Z,{loginRedirectMessage:"Sign in to start chatting with ".concat(e.data.name),onOpenChange:i}),(0,n.jsx)(Z.Ol,{children:(0,n.jsx)(Z.ll,{children:e.isMobileWidth?(0,n.jsxs)(O.dy,{open:t,onOpenChange:e=>{r(e),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,n.jsx)(O.Qz,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:50,height:50}),e.data.name]})}),(0,n.jsx)("div",{className:"float-right",children:e.userProfile?(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100",onClick:()=>V(e.data.slug,h),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})}):(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm",onClick:()=>i(!0),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})})}),(0,n.jsxs)(O.sc,{className:"whitespace-pre-line p-2",children:[(0,n.jsxs)(O.OX,{children:[(0,n.jsx)(O.iI,{children:e.data.name}),(0,n.jsx)(O.u6,{children:"Full Prompt"})]}),e.data.persona,(0,n.jsx)(O.ze,{children:(0,n.jsx)(O.uh,{children:"Done"})})]})]}):(0,n.jsxs)(A.Vq,{open:t,onOpenChange:()=>{r(!t),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,n.jsx)(A.hg,{children:(0,n.jsxs)("div",{className:"flex items-center relative top-2",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:50,height:50}),e.data.name]})}),(0,n.jsx)("div",{className:"float-right",children:e.userProfile?(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>V(e.data.slug,h),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})}):(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>i(!0),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})})}),(0,n.jsxs)(A.cZ,{className:"whitespace-pre-line max-h-[80vh]",children:[(0,n.jsx)(A.fK,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:32,height:50}),(0,n.jsx)("p",{className:"font-bold text-lg",children:e.data.name})]})}),(0,n.jsx)("div",{className:"max-h-[60vh] overflow-y-scroll text-neutral-500 dark:text-white",children:e.data.persona}),(0,n.jsx)(A.cN,{children:(0,n.jsxs)(d.z,{className:"pt-6 pb-6 ".concat(u," bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white border-2 border-stone-100 shadow-sm rounded-xl hover:bg-stone-100 dark:hover:bg-neutral-900 dark:border-neutral-700"),onClick:()=>{V(e.data.slug,h),r(!1)},children:[(0,n.jsx)(N,{className:"w-6 h-6 m-2 ".concat((0,F.oz)(e.data.color))}),"Start Chatting"]})})]})]})})}),(0,n.jsx)(Z.aY,{children:(0,n.jsx)("div",{className:l().agentPersonality,children:(0,n.jsx)("button",{className:"".concat(l().infoButton," text-neutral-500 dark:text-white"),onClick:()=>r(!0),children:(0,n.jsx)("p",{children:e.data.persona})})})})]})}function R(){let{data:e,error:a}=(0,o.ZP)("agents",S,{revalidateOnFocus:!1}),t=(0,i.G)(),[r,s]=(0,c.useState)(!1),d=(0,C.IC)();return a?(0,n.jsxs)("main",{className:l().main,children:[(0,n.jsx)("div",{className:"".concat(l().titleBar," text-5xl"),children:"Agents"}),(0,n.jsx)("div",{className:l().agentList,children:"Error loading agents"})]}):e?(0,n.jsx)("main",{className:"w-full mx-auto",children:(0,n.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,n.jsx)("div",{className:"".concat(l().sidePanel," top-0"),children:(0,n.jsx)(P.Z,{conversationId:null,uploadedFiles:[],isMobileWidth:d})}),(0,n.jsxs)("div",{className:"".concat(l().pageLayout," w-full"),children:[(0,n.jsxs)("div",{className:"pt-6 md:pt-8 flex justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl flex items-center",children:"Agents"}),(0,n.jsx)("div",{className:"ml-auto float-right border p-2 pt-3 rounded-xl font-bold hover:bg-stone-100 dark:hover:bg-neutral-900",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{children:(0,n.jsxs)("div",{className:"flex flex-row",children:[(0,n.jsx)(L.v,{className:"pr-2 w-6 h-6"}),(0,n.jsx)("p",{className:"pr-2",children:"Create Agent"})]})}),(0,n.jsx)(h._v,{children:(0,n.jsx)("p",{children:"Coming Soon!"})})]})})})]}),r&&(0,n.jsx)(M.Z,{loginRedirectMessage:"Sign in to start chatting with a specialized agent",onOpenChange:s}),(0,n.jsx)(z.bZ,{className:"bg-secondary border-none my-4",children:(0,n.jsxs)(z.X,{children:[(0,n.jsx)(E.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,n.jsx)("span",{className:"font-bold",children:"How it works"})," Use any of these specialized personas to tune your conversation to your needs."]})}),(0,n.jsx)("div",{className:"".concat(l().agentList),children:e.map(e=>(0,n.jsx)(H,{data:e,userProfile:t,isMobileWidth:d},e.slug))})]})]})}):(0,n.jsx)("main",{className:l().main,children:(0,n.jsxs)("div",{className:l().agentList,children:[(0,n.jsx)(k.l,{})," booting up your agents"]})})}},66820:function(e,a,t){"use strict";t.d(a,{Z:function(){return s}});var n=t(57437),r=t(6780),l=t(87138);function s(e){return(0,n.jsx)(r.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,n.jsxs)(r._T,{children:[(0,n.jsx)(r.fY,{children:(0,n.jsx)(r.f$,{children:"Sign in to Khoj to continue"})}),(0,n.jsxs)(r.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,n.jsx)(l.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,n.jsxs)(r.xo,{children:[(0,n.jsx)(r.le,{children:"Dismiss"}),(0,n.jsx)(r.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,n.jsxs)(l.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},47412:function(e,a,t){"use strict";t.d(a,{X:function(){return i},bZ:function(){return c}});var n=t(57437),r=t(2265),l=t(12218),s=t(37440);let o=(0,l.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),c=r.forwardRef((e,a)=>{let{className:t,variant:r,...l}=e;return(0,n.jsx)("div",{ref:a,role:"alert",className:(0,s.cn)(o({variant:r}),t),...l})});c.displayName="Alert",r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,n.jsx)("h5",{ref:a,className:(0,s.cn)("mb-1 font-medium leading-none tracking-tight",t),...r})}).displayName="AlertTitle";let i=r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,n.jsx)("div",{ref:a,className:(0,s.cn)("text-sm [&_p]:leading-relaxed",t),...r})});i.displayName="AlertDescription"},19666:function(e,a,t){"use strict";t.d(a,{_v:function(){return d},aJ:function(){return i},pn:function(){return o},u:function(){return c}});var n=t(57437),r=t(2265),l=t(27071),s=t(37440);let o=l.zt,c=l.fC,i=l.xz,d=r.forwardRef((e,a)=>{let{className:t,sideOffset:r=4,...o}=e;return(0,n.jsx)(l.VY,{ref:a,sideOffset:r,className:(0,s.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o})});d.displayName=l.VY.displayName},27158:function(e,a,t){"use strict";function n(e){let{src:a,width:t,quality:n}=e;return a.startsWith("http")?a:(a.startsWith("/")&&(a=a.slice(1)),"/static/".concat(a))}t.r(a),t.d(a,{default:function(){return n}})},15283:function(e){e.exports={titleBar:"agents_titleBar__FzYbY",agentPersonality:"agents_agentPersonality__o0Ysz",pageLayout:"agents_pageLayout__gR3S3",sidePanel:"agents_sidePanel__wGVGc",infoButton:"agents_infoButton__NqI7E",agentList:"agents_agentList__XVx4A"}},64945:function(e,a,t){"use strict";t.d(a,{B:function(){return p}});var n=t(2265),r=t(52195);let l=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M219.71,117.38a12,12,0,0,0-7.25-8.52L161.28,88.39l10.59-70.61a12,12,0,0,0-20.64-10l-112,120a12,12,0,0,0,4.31,19.33l51.18,20.47L84.13,238.22a12,12,0,0,0,20.64,10l112-120A12,12,0,0,0,219.71,117.38ZM113.6,203.55l6.27-41.77a12,12,0,0,0-7.41-12.92L68.74,131.37,142.4,52.45l-6.27,41.77a12,12,0,0,0,7.41,12.92l43.72,17.49Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M96,240l16-80L48,136,160,16,144,96l64,24Z",opacity:"0.2"}),n.createElement("path",{d:"M215.79,118.17a8,8,0,0,0-5-5.66L153.18,90.9l14.66-73.33a8,8,0,0,0-13.69-7l-112,120a8,8,0,0,0,3,13l57.63,21.61L88.16,238.43a8,8,0,0,0,13.69,7l112-120A8,8,0,0,0,215.79,118.17ZM109.37,214l10.47-52.38a8,8,0,0,0-5-9.06L62,132.71l84.62-90.66L136.16,94.43a8,8,0,0,0,5,9.06l52.8,19.8Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.85,125.46l-112,120a8,8,0,0,1-13.69-7l14.66-73.33L45.19,143.49a8,8,0,0,1-3-13l112-120a8,8,0,0,1,13.69,7L153.18,90.9l57.63,21.61a8,8,0,0,1,3,12.95Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.84,118.63a6,6,0,0,0-3.73-4.25L150.88,92.17l15-75a6,6,0,0,0-10.27-5.27l-112,120a6,6,0,0,0,2.28,9.71l59.23,22.21-15,75a6,6,0,0,0,3.14,6.52A6.07,6.07,0,0,0,96,246a6,6,0,0,0,4.39-1.91l112-120A6,6,0,0,0,213.84,118.63ZM106,220.46l11.85-59.28a6,6,0,0,0-3.77-6.8l-55.6-20.85,91.46-98L138.12,94.82a6,6,0,0,0,3.77,6.8l55.6,20.85Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M215.79,118.17a8,8,0,0,0-5-5.66L153.18,90.9l14.66-73.33a8,8,0,0,0-13.69-7l-112,120a8,8,0,0,0,3,13l57.63,21.61L88.16,238.43a8,8,0,0,0,13.69,7l112-120A8,8,0,0,0,215.79,118.17ZM109.37,214l10.47-52.38a8,8,0,0,0-5-9.06L62,132.71l84.62-90.66L136.16,94.43a8,8,0,0,0,5,9.06l52.8,19.8Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M211.89,119.09a4,4,0,0,0-2.49-2.84l-60.81-22.8,15.33-76.67a4,4,0,0,0-6.84-3.51l-112,120a4,4,0,0,0-1,3.64,4,4,0,0,0,2.49,2.84l60.81,22.8L92.08,239.22a4,4,0,0,0,6.84,3.51l112-120A4,4,0,0,0,211.89,119.09ZM102.68,227l13.24-66.2a4,4,0,0,0-2.52-4.53L55,134.36,153.32,29l-13.24,66.2a4,4,0,0,0,2.52,4.53L201,121.64Z"}))]]);var s=Object.defineProperty,o=Object.defineProperties,c=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,u=(e,a,t)=>a in e?s(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,m=(e,a)=>{for(var t in a||(a={}))d.call(a,t)&&u(e,t,a[t]);if(i)for(var t of i(a))h.call(a,t)&&u(e,t,a[t]);return e},g=(e,a)=>o(e,c(a));let p=(0,n.forwardRef)((e,a)=>n.createElement(r.Z,g(m({ref:a},e),{weights:l})));p.displayName="Lightning"},35418:function(e,a,t){"use strict";t.d(a,{v:function(){return p}});var n=t(2265),r=t(52195);let l=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),n.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]);var s=Object.defineProperty,o=Object.defineProperties,c=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,u=(e,a,t)=>a in e?s(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,m=(e,a)=>{for(var t in a||(a={}))d.call(a,t)&&u(e,t,a[t]);if(i)for(var t of i(a))h.call(a,t)&&u(e,t,a[t]);return e},g=(e,a)=>o(e,c(a));let p=(0,n.forwardRef)((e,a)=>n.createElement(r.Z,g(m({ref:a},e),{weights:l})));p.displayName="Plus"}},function(e){e.O(0,[647,9001,3062,743,7071,6648,1603,9417,2971,7023,1744],function(){return e(e.s=1813)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9718],{1813:function(e,a,t){Promise.resolve().then(t.bind(t,87529))},87529:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return R}});var n=t(57437),r=t(15283),l=t.n(r),s=t(66648),o=t(29039),c=t(2265),i=t(79306),d=t(50495),h=t(19666),u=t(52195);let m=new Map([["bold",c.createElement(c.Fragment,null,c.createElement("path",{d:"M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z"}))],["duotone",c.createElement(c.Fragment,null,c.createElement("path",{d:"M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z",opacity:"0.2"}),c.createElement("path",{d:"M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z"}))],["fill",c.createElement(c.Fragment,null,c.createElement("path",{d:"M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z"}))],["light",c.createElement(c.Fragment,null,c.createElement("path",{d:"M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z"}))],["regular",c.createElement(c.Fragment,null,c.createElement("path",{d:"M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z"}))],["thin",c.createElement(c.Fragment,null,c.createElement("path",{d:"M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z"}))]]);var g=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,b=(e,a,t)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,w=(e,a)=>{for(var t in a||(a={}))j.call(a,t)&&b(e,t,a[t]);if(x)for(var t of x(a))v.call(a,t)&&b(e,t,a[t]);return e},y=(e,a)=>p(e,f(a));let N=(0,c.forwardRef)((e,a)=>c.createElement(u.Z,y(w({ref:a},e),{weights:m})));N.displayName="PaperPlaneTilt";var L=t(35418),E=t(64945),Z=t(36013),A=t(90837),O=t(7951),M=t(66820),k=t(58485),P=t(48861),_=t(89417),F=t(58575),z=t(47412),C=t(69591);async function V(e,a){let t="/login?next=/agents?agent=".concat(e);if(!a){window.location.href=t;return}let n=await fetch("/api/chat/sessions?agent_slug=".concat(e),{method:"POST"}),r=await n.json();200==n.status?window.location.href="/chat?conversationId=".concat(r.conversation_id):403==n.status||401==n.status?window.location.href=t:alert("Failed to start chat session")}let S=()=>window.fetch("/api/agents").then(e=>e.json()).catch(e=>console.log(e));function H(e){let a=new URLSearchParams(window.location.search).get("agent"),[t,r]=(0,c.useState)(a===e.data.slug),[o,i]=(0,c.useState)(!1),h=e.userProfile;t&&window.history.pushState({},"Khoj AI - Agent ".concat(e.data.slug),"/agents?agent=".concat(e.data.slug));let u=(0,F.oz)(e.data.color);return(0,n.jsxs)(Z.Zb,{className:"shadow-sm bg-gradient-to-b from-white 20% to-".concat(e.data.color?e.data.color:"gray","-100/50 dark:from-[hsl(var(--background))] dark:to-").concat(e.data.color?e.data.color:"gray","-950/50 rounded-xl hover:shadow-md"),children:[o&&(0,n.jsx)(M.Z,{loginRedirectMessage:"Sign in to start chatting with ".concat(e.data.name),onOpenChange:i}),(0,n.jsx)(Z.Ol,{children:(0,n.jsx)(Z.ll,{children:e.isMobileWidth?(0,n.jsxs)(O.dy,{open:t,onOpenChange:e=>{r(e),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,n.jsx)(O.Qz,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:50,height:50}),e.data.name]})}),(0,n.jsx)("div",{className:"float-right",children:e.userProfile?(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100",onClick:()=>V(e.data.slug,h),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})}):(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm",onClick:()=>i(!0),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})})}),(0,n.jsxs)(O.sc,{className:"whitespace-pre-line p-2",children:[(0,n.jsxs)(O.OX,{children:[(0,n.jsx)(O.iI,{children:e.data.name}),(0,n.jsx)(O.u6,{children:"Full Prompt"})]}),e.data.persona,(0,n.jsx)(O.ze,{children:(0,n.jsx)(O.uh,{children:"Done"})})]})]}):(0,n.jsxs)(A.Vq,{open:t,onOpenChange:()=>{r(!t),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,n.jsx)(A.hg,{children:(0,n.jsxs)("div",{className:"flex items-center relative top-2",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:50,height:50}),e.data.name]})}),(0,n.jsx)("div",{className:"float-right",children:e.userProfile?(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>V(e.data.slug,h),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})}):(0,n.jsx)(d.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>i(!0),children:(0,n.jsx)(N,{className:"w-6 h-6 ".concat((0,F.oz)(e.data.color))})})}),(0,n.jsxs)(A.cZ,{className:"whitespace-pre-line max-h-[80vh]",children:[(0,n.jsx)(A.fK,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,_.T)(e.data.icon,e.data.color)||(0,n.jsx)(s.default,{src:e.data.avatar,alt:e.data.name,width:32,height:50}),(0,n.jsx)("p",{className:"font-bold text-lg",children:e.data.name})]})}),(0,n.jsx)("div",{className:"max-h-[60vh] overflow-y-scroll text-neutral-500 dark:text-white",children:e.data.persona}),(0,n.jsx)(A.cN,{children:(0,n.jsxs)(d.z,{className:"pt-6 pb-6 ".concat(u," bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white border-2 border-stone-100 shadow-sm rounded-xl hover:bg-stone-100 dark:hover:bg-neutral-900 dark:border-neutral-700"),onClick:()=>{V(e.data.slug,h),r(!1)},children:[(0,n.jsx)(N,{className:"w-6 h-6 m-2 ".concat((0,F.oz)(e.data.color))}),"Start Chatting"]})})]})]})})}),(0,n.jsx)(Z.aY,{children:(0,n.jsx)("div",{className:l().agentPersonality,children:(0,n.jsx)("button",{className:"".concat(l().infoButton," text-neutral-500 dark:text-white"),onClick:()=>r(!0),children:(0,n.jsx)("p",{children:e.data.persona})})})})]})}function R(){let{data:e,error:a}=(0,o.ZP)("agents",S,{revalidateOnFocus:!1}),t=(0,i.G)(),[r,s]=(0,c.useState)(!1),d=(0,C.IC)();return a?(0,n.jsxs)("main",{className:l().main,children:[(0,n.jsx)("div",{className:"".concat(l().titleBar," text-5xl"),children:"Agents"}),(0,n.jsx)("div",{className:l().agentList,children:"Error loading agents"})]}):e?(0,n.jsx)("main",{className:"w-full mx-auto",children:(0,n.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,n.jsx)("div",{className:"".concat(l().sidePanel," top-0"),children:(0,n.jsx)(P.Z,{conversationId:null,uploadedFiles:[],isMobileWidth:d})}),(0,n.jsxs)("div",{className:"".concat(l().pageLayout," w-full"),children:[(0,n.jsxs)("div",{className:"pt-6 md:pt-8 flex justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl flex items-center",children:"Agents"}),(0,n.jsx)("div",{className:"ml-auto float-right border p-2 pt-3 rounded-xl font-bold hover:bg-stone-100 dark:hover:bg-neutral-900",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{children:(0,n.jsxs)("div",{className:"flex flex-row",children:[(0,n.jsx)(L.v,{className:"pr-2 w-6 h-6"}),(0,n.jsx)("p",{className:"pr-2",children:"Create Agent"})]})}),(0,n.jsx)(h._v,{children:(0,n.jsx)("p",{children:"Coming Soon!"})})]})})})]}),r&&(0,n.jsx)(M.Z,{loginRedirectMessage:"Sign in to start chatting with a specialized agent",onOpenChange:s}),(0,n.jsx)(z.bZ,{className:"bg-secondary border-none my-4",children:(0,n.jsxs)(z.X,{children:[(0,n.jsx)(E.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,n.jsx)("span",{className:"font-bold",children:"How it works"})," Use any of these specialized personas to tune your conversation to your needs."]})}),(0,n.jsx)("div",{className:"".concat(l().agentList),children:e.map(e=>(0,n.jsx)(H,{data:e,userProfile:t,isMobileWidth:d},e.slug))})]})]})}):(0,n.jsx)("main",{className:l().main,children:(0,n.jsxs)("div",{className:l().agentList,children:[(0,n.jsx)(k.l,{})," booting up your agents"]})})}},66820:function(e,a,t){"use strict";t.d(a,{Z:function(){return s}});var n=t(57437),r=t(6780),l=t(87138);function s(e){return(0,n.jsx)(r.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,n.jsxs)(r._T,{children:[(0,n.jsx)(r.fY,{children:(0,n.jsx)(r.f$,{children:"Sign in to Khoj to continue"})}),(0,n.jsxs)(r.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,n.jsx)(l.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,n.jsxs)(r.xo,{children:[(0,n.jsx)(r.le,{children:"Dismiss"}),(0,n.jsx)(r.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,n.jsxs)(l.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},47412:function(e,a,t){"use strict";t.d(a,{X:function(){return i},bZ:function(){return c}});var n=t(57437),r=t(2265),l=t(12218),s=t(37440);let o=(0,l.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),c=r.forwardRef((e,a)=>{let{className:t,variant:r,...l}=e;return(0,n.jsx)("div",{ref:a,role:"alert",className:(0,s.cn)(o({variant:r}),t),...l})});c.displayName="Alert",r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,n.jsx)("h5",{ref:a,className:(0,s.cn)("mb-1 font-medium leading-none tracking-tight",t),...r})}).displayName="AlertTitle";let i=r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,n.jsx)("div",{ref:a,className:(0,s.cn)("text-sm [&_p]:leading-relaxed",t),...r})});i.displayName="AlertDescription"},19666:function(e,a,t){"use strict";t.d(a,{_v:function(){return d},aJ:function(){return i},pn:function(){return o},u:function(){return c}});var n=t(57437),r=t(2265),l=t(27071),s=t(37440);let o=l.zt,c=l.fC,i=l.xz,d=r.forwardRef((e,a)=>{let{className:t,sideOffset:r=4,...o}=e;return(0,n.jsx)(l.VY,{ref:a,sideOffset:r,className:(0,s.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o})});d.displayName=l.VY.displayName},27158:function(e,a,t){"use strict";function n(e){let{src:a,width:t,quality:n}=e;return a.startsWith("http")?a:(a.startsWith("/")&&(a=a.slice(1)),"/static/".concat(a))}t.r(a),t.d(a,{default:function(){return n}})},15283:function(e){e.exports={titleBar:"agents_titleBar__FzYbY",agentPersonality:"agents_agentPersonality__o0Ysz",pageLayout:"agents_pageLayout__gR3S3",sidePanel:"agents_sidePanel__wGVGc",infoButton:"agents_infoButton__NqI7E",agentList:"agents_agentList__XVx4A"}},64945:function(e,a,t){"use strict";t.d(a,{B:function(){return p}});var n=t(2265),r=t(52195);let l=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M219.71,117.38a12,12,0,0,0-7.25-8.52L161.28,88.39l10.59-70.61a12,12,0,0,0-20.64-10l-112,120a12,12,0,0,0,4.31,19.33l51.18,20.47L84.13,238.22a12,12,0,0,0,20.64,10l112-120A12,12,0,0,0,219.71,117.38ZM113.6,203.55l6.27-41.77a12,12,0,0,0-7.41-12.92L68.74,131.37,142.4,52.45l-6.27,41.77a12,12,0,0,0,7.41,12.92l43.72,17.49Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M96,240l16-80L48,136,160,16,144,96l64,24Z",opacity:"0.2"}),n.createElement("path",{d:"M215.79,118.17a8,8,0,0,0-5-5.66L153.18,90.9l14.66-73.33a8,8,0,0,0-13.69-7l-112,120a8,8,0,0,0,3,13l57.63,21.61L88.16,238.43a8,8,0,0,0,13.69,7l112-120A8,8,0,0,0,215.79,118.17ZM109.37,214l10.47-52.38a8,8,0,0,0-5-9.06L62,132.71l84.62-90.66L136.16,94.43a8,8,0,0,0,5,9.06l52.8,19.8Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.85,125.46l-112,120a8,8,0,0,1-13.69-7l14.66-73.33L45.19,143.49a8,8,0,0,1-3-13l112-120a8,8,0,0,1,13.69,7L153.18,90.9l57.63,21.61a8,8,0,0,1,3,12.95Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.84,118.63a6,6,0,0,0-3.73-4.25L150.88,92.17l15-75a6,6,0,0,0-10.27-5.27l-112,120a6,6,0,0,0,2.28,9.71l59.23,22.21-15,75a6,6,0,0,0,3.14,6.52A6.07,6.07,0,0,0,96,246a6,6,0,0,0,4.39-1.91l112-120A6,6,0,0,0,213.84,118.63ZM106,220.46l11.85-59.28a6,6,0,0,0-3.77-6.8l-55.6-20.85,91.46-98L138.12,94.82a6,6,0,0,0,3.77,6.8l55.6,20.85Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M215.79,118.17a8,8,0,0,0-5-5.66L153.18,90.9l14.66-73.33a8,8,0,0,0-13.69-7l-112,120a8,8,0,0,0,3,13l57.63,21.61L88.16,238.43a8,8,0,0,0,13.69,7l112-120A8,8,0,0,0,215.79,118.17ZM109.37,214l10.47-52.38a8,8,0,0,0-5-9.06L62,132.71l84.62-90.66L136.16,94.43a8,8,0,0,0,5,9.06l52.8,19.8Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M211.89,119.09a4,4,0,0,0-2.49-2.84l-60.81-22.8,15.33-76.67a4,4,0,0,0-6.84-3.51l-112,120a4,4,0,0,0-1,3.64,4,4,0,0,0,2.49,2.84l60.81,22.8L92.08,239.22a4,4,0,0,0,6.84,3.51l112-120A4,4,0,0,0,211.89,119.09ZM102.68,227l13.24-66.2a4,4,0,0,0-2.52-4.53L55,134.36,153.32,29l-13.24,66.2a4,4,0,0,0,2.52,4.53L201,121.64Z"}))]]);var s=Object.defineProperty,o=Object.defineProperties,c=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,u=(e,a,t)=>a in e?s(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,m=(e,a)=>{for(var t in a||(a={}))d.call(a,t)&&u(e,t,a[t]);if(i)for(var t of i(a))h.call(a,t)&&u(e,t,a[t]);return e},g=(e,a)=>o(e,c(a));let p=(0,n.forwardRef)((e,a)=>n.createElement(r.Z,g(m({ref:a},e),{weights:l})));p.displayName="Lightning"},35418:function(e,a,t){"use strict";t.d(a,{v:function(){return p}});var n=t(2265),r=t(52195);let l=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),n.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]);var s=Object.defineProperty,o=Object.defineProperties,c=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,u=(e,a,t)=>a in e?s(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,m=(e,a)=>{for(var t in a||(a={}))d.call(a,t)&&u(e,t,a[t]);if(i)for(var t of i(a))h.call(a,t)&&u(e,t,a[t]);return e},g=(e,a)=>o(e,c(a));let p=(0,n.forwardRef)((e,a)=>n.createElement(r.Z,g(m({ref:a},e),{weights:l})));p.displayName="Plus"}},function(e){e.O(0,[9460,9427,9001,3062,743,7071,6648,1603,9417,2971,7023,1744],function(){return e(e.s=1813)}),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4371],{2743:function(e,t,a){Promise.resolve().then(a.bind(a,40393))},40393:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return eP}});var s=a(57437),n=a(29039),r=a(58485),o=a(36013),i=a(50495),l=a(2265),c=a(77539),d=a(42421),u=a(14392),m=a(22468),h=a(37440);let x=c.fC;c.ZA;let f=c.B4,p=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e;return(0,s.jsxs)(c.xz,{ref:t,className:(0,h.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[n,(0,s.jsx)(c.JO,{asChild:!0,children:(0,s.jsx)(d.Z,{className:"h-4 w-4 opacity-50"})})]})});p.displayName=c.xz.displayName;let g=l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.u_,{ref:t,className:(0,h.cn)("flex cursor-default items-center justify-center py-1",a),...n,children:(0,s.jsx)(u.Z,{className:"h-4 w-4"})})});g.displayName=c.u_.displayName;let j=l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.$G,{ref:t,className:(0,h.cn)("flex cursor-default items-center justify-center py-1",a),...n,children:(0,s.jsx)(d.Z,{className:"h-4 w-4"})})});j.displayName=c.$G.displayName;let y=l.forwardRef((e,t)=>{let{className:a,children:n,position:r="popper",...o}=e;return(0,s.jsx)(c.h_,{children:(0,s.jsxs)(c.VY,{ref:t,className:(0,h.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:r,...o,children:[(0,s.jsx)(g,{}),(0,s.jsx)(c.l_,{className:(0,h.cn)("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),(0,s.jsx)(j,{})]})})});y.displayName=c.VY.displayName,l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.__,{ref:t,className:(0,h.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...n})}).displayName=c.__.displayName;let w=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e;return(0,s.jsxs)(c.ck,{ref:t,className:(0,h.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(c.wU,{children:(0,s.jsx)(m.Z,{className:"h-4 w-4"})})}),(0,s.jsx)(c.eT,{children:n})]})});w.displayName=c.ck.displayName,l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.Z0,{ref:t,className:(0,h.cn)("-mx-1 my-1 h-px bg-muted",a),...n})}).displayName=c.Z0.displayName;var v=a(18760),b=a.n(v),N=a(31014),D=a(39343),S=a(59772),C=a(71538),k=a(67135);let _=D.RV,A=l.createContext({}),I=e=>{let{...t}=e;return(0,s.jsx)(A.Provider,{value:{name:t.name},children:(0,s.jsx)(D.Qr,{...t})})},M=()=>{let e=l.useContext(A),t=l.useContext(T),{getFieldState:a,formState:s}=(0,D.Gc)(),n=a(e.name,s);if(!e)throw Error("useFormField should be used within <FormField>");let{id:r}=t;return{id:r,name:e.name,formItemId:"".concat(r,"-form-item"),formDescriptionId:"".concat(r,"-form-item-description"),formMessageId:"".concat(r,"-form-item-message"),...n}},T=l.createContext({}),R=l.forwardRef((e,t)=>{let{className:a,...n}=e,r=l.useId();return(0,s.jsx)(T.Provider,{value:{id:r},children:(0,s.jsx)("div",{ref:t,className:(0,h.cn)("space-y-2",a),...n})})});R.displayName="FormItem";let L=l.forwardRef((e,t)=>{let{className:a,...n}=e,{error:r,formItemId:o}=M();return(0,s.jsx)(k._,{ref:t,className:(0,h.cn)(r&&"text-destructive",a),htmlFor:o,...n})});L.displayName="FormLabel";let O=l.forwardRef((e,t)=>{let{...a}=e,{error:n,formItemId:r,formDescriptionId:o,formMessageId:i}=M();return(0,s.jsx)(C.g7,{ref:t,id:r,"aria-describedby":n?"".concat(o," ").concat(i):"".concat(o),"aria-invalid":!!n,...a})});O.displayName="FormControl";let P=l.forwardRef((e,t)=>{let{className:a,...n}=e,{formDescriptionId:r}=M();return(0,s.jsx)("p",{ref:t,id:r,className:(0,h.cn)("text-sm text-muted-foreground",a),...n})});P.displayName="FormDescription";let z=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e,{error:o,formMessageId:i}=M(),l=o?String(null==o?void 0:o.message):n;return l?(0,s.jsx)("p",{ref:t,id:i,className:(0,h.cn)("text-sm font-medium text-destructive",a),...r,children:l}):null});z.displayName="FormMessage";var q=a(83102),W=a(90837),E=a(13304),U=a(93146),V=a(69591),F=a(23611),Z=a.n(F),B=a(18642),G=a(16463),Y=a(19573),$=a(20319),H=a(22049),K=a(55362),Q=a(13537),X=a(76082),J=a(52674),ee=a(23751),et=a(83522),ea=a(8837),es=a(21819),en=a(35418),er=a(64945),eo=a(79306),ei=a(66820),el=a(35657),ec=a(50151),ed=a(47412),eu=a(48861),em=a(7951);let eh=()=>window.fetch("/api/automations").then(e=>e.json()).catch(e=>console.log(e));function ex(e){let t=e.split(" "),a=t[2],s=t[4];return"*"===a&&"*"===s?"Day":"*"!==s?"Week":"*"!==a?"Month":"Day"}function ef(e){let t=e.split(" ");if("*"===t[3]&&"*"!==t[4])return Number(t[4])}function ep(e){let t=e.split(" "),a=t[1],s=t[0],n=Number(a)>=12?"PM":"AM",r=Number(a)>12?Number(a)-12:a;"00"===r&&(r="12");let o=s;return 10>Number(o)&&"00"!==o&&(o="0".concat(o)),"".concat(r,":").concat(o," ").concat(n)}function eg(e){return String(e.split(" ")[2])}function ej(e){return b().toString(e)}let ey=["Day","Week","Month"],ew=Array.from({length:31},(e,t)=>String(t+1)),ev=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],eb=[],eN=["AM","PM"];for(var eD=0;eD<eN.length;eD++)for(var eS=0;eS<12;eS++)for(var eC=0;eC<60;eC+=15){let e=String(eC).padStart(2,"0"),t=0===eS?12:eS;eb.push("".concat(t,":").concat(e," ").concat(eN[eD]))}let ek=Date.now(),e_=[{subject:"Weekly Newsletter",query_to_run:"Compile a message including: 1. A recap of news from last week 2. An at-home workout I can do before work 3. A quote to inspire me for the week ahead",schedule:"9AM every Monday",next:"Next run at 9AM on Monday",crontime:"0 9 * * 1",id:ek,scheduling_request:""},{subject:"Daily Bedtime Story",query_to_run:"Compose a bedtime story that a five-year-old might enjoy. It should not exceed five paragraphs. Appeal to the imagination, but weave in learnings.",schedule:"9PM every night",next:"Next run at 9PM today",crontime:"0 21 * * *",id:ek+1,scheduling_request:""},{subject:"Front Page of Hacker News",query_to_run:"Summarize the top 5 posts from https://news.ycombinator.com/best and share them with me, including links",schedule:"9PM on every Wednesday",next:"Next run at 9PM on Wednesday",crontime:"0 21 * * 3",id:ek+2,scheduling_request:""},{subject:"Market Summary",query_to_run:"Get the market summary for today and share it with me. Focus on tech stocks and the S&P 500.",schedule:"9AM on every weekday",next:"Next run at 9AM on Monday",crontime:"0 9 * * *",id:ek+3,scheduling_request:""}];function eA(e){let t=encodeURIComponent(e.subject),a=encodeURIComponent(e.query_to_run),s=encodeURIComponent(e.crontime);return"".concat(window.location.origin,"/automations?subject=").concat(t,"&query=").concat(a,"&crontime=").concat(s)}function eI(e){let[t,a]=(0,l.useState)(!1),[n,r]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(""),{toast:h}=(0,el.pm)(),x=e.automation,[f,p]=(0,l.useState)(""),[g,j]=(0,l.useState)("");return((0,l.useEffect)(()=>{let e=n||x;p(ep(e.crontime));let t=ex(e.crontime);if("Day"===t)j("Daily");else if("Week"===t){let t=ef(e.crontime);void 0===t?j("Weekly"):j("".concat(ev[t]))}else if("Month"===t){let t=eg(e.crontime);j("Monthly on the ".concat(t))}},[n,x]),(0,l.useEffect)(()=>{let e="Automation: ".concat((null==n?void 0:n.subject)||x.subject);u&&(h({title:e,description:u,action:(0,s.jsx)(ec.gD,{altText:"Dismiss",children:"Ok"})}),m(""))},[u,n,x,h]),c)?null:(0,s.jsxs)(o.Zb,{className:"bg-secondary h-full shadow-sm rounded-lg bg-gradient-to-b from-background to-slate-50 dark:to-gray-950 border ".concat(Z().automationCard),children:[(0,s.jsx)(o.Ol,{children:(0,s.jsxs)(o.ll,{className:"line-clamp-2 leading-normal flex justify-between",children:[(null==n?void 0:n.subject)||x.subject,(0,s.jsxs)(Y.J2,{children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsx)(i.z,{className:"bg-background",variant:"ghost",children:(0,s.jsx)($.F,{className:"h-4 w-4"})})}),(0,s.jsxs)(Y.yk,{className:"w-auto grid gap-2 text-left bg-secondary",children:[!e.suggestedCard&&e.locationData&&(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Edit",createNew:!1,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:r,authenticatedData:e.authenticatedData,isCreating:t,automation:n||x,ipLocationData:e.locationData}),(0,s.jsx)(B.Z,{buttonTitle:"Share",includeIcon:!0,buttonClassName:"justify-start px-4 py-2 h-10",buttonVariant:"outline",title:"Share Automation",description:"Copy the link below and share it with your coworkers or friends.",url:eA(x),onShare:()=>{navigator.clipboard.writeText(eA(x))}}),!e.suggestedCard&&(0,s.jsxs)(i.z,{variant:"outline",className:"justify-start",onClick:()=>{!function(e,t){fetch("/api/trigger/automation?automation_id=".concat(e),{method:"POST"}).then(e=>{if(!e.ok)throw Error("Network response was not ok");return e}).then(e=>{t("Automation triggered. Check your inbox in a few minutes!")}).catch(e=>{t("Sorry, something went wrong. Try again later.")})}(x.id.toString(),m)},children:[(0,s.jsx)(H.s,{className:"h-4 w-4 mr-2"}),"Run Now"]}),(0,s.jsxs)(i.z,{variant:"destructive",className:"justify-start",onClick:()=>{if(e.suggestedCard){d(!0);return}!function(e,t){fetch("/api/automation?automation_id=".concat(e),{method:"DELETE"}).then(e=>e.json()).then(e=>{t(!0)})}(x.id.toString(),d)},children:[(0,s.jsx)(K.r,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),(0,s.jsx)(o.aY,{className:"text-secondary-foreground break-all",children:(null==n?void 0:n.query_to_run)||x.query_to_run}),(0,s.jsxs)(o.eW,{className:"flex flex-col items-start md:flex-row md:justify-between md:items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center bg-blue-50 rounded-lg p-1.5 border-blue-200 border dark:bg-blue-800 dark:border-blue-500",children:[(0,s.jsx)(Q.T,{className:"h-4 w-4 mr-2 text-blue-700 dark:text-blue-300"}),(0,s.jsx)("div",{className:"text-s text-blue-700 dark:text-blue-300",children:f})]}),(0,s.jsxs)("div",{className:"flex items-center bg-purple-50 rounded-lg p-1.5 border-purple-200 border dark:bg-purple-800 dark:border-purple-500",children:[(0,s.jsx)(X.u,{className:"h-4 w-4 mr-2 text-purple-700 dark:text-purple-300"}),(0,s.jsx)("div",{className:"text-s text-purple-700 dark:text-purple-300",children:g})]})]}),e.suggestedCard&&e.setNewAutomationData&&(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Add",createNew:!0,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:t,automation:x,ipLocationData:e.locationData})]})]})}function eM(e){let t=(0,G.useSearchParams)(),[a,n]=(0,l.useState)(!0),r=t.get("subject"),o=t.get("query"),i=t.get("crontime");if(!r||!o||!i)return null;let c={id:0,subject:decodeURIComponent(r),query_to_run:decodeURIComponent(o),scheduling_request:"",schedule:ej(decodeURIComponent(i)),crontime:decodeURIComponent(i),next:""};return a?(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Shared",createNew:!0,setIsCreating:n,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:a,automation:c,ipLocationData:e.locationData}):null}let eT=S.z.object({subject:S.z.optional(S.z.string()),everyBlah:S.z.string({required_error:"Every is required"}),dayOfWeek:S.z.optional(S.z.number()),dayOfMonth:S.z.optional(S.z.string()),timeRecurrence:S.z.string({required_error:"Time Recurrence is required"}),queryToRun:S.z.string({required_error:"Query to Run is required"})});function eR(e){let t=e.automation,a=(0,D.cI)({resolver:(0,N.F)(eT),defaultValues:{subject:null==t?void 0:t.subject,everyBlah:(null==t?void 0:t.crontime)?ex(t.crontime):"Day",dayOfWeek:(null==t?void 0:t.crontime)?ef(t.crontime):void 0,timeRecurrence:(null==t?void 0:t.crontime)?ep(t.crontime):"12:00 PM",dayOfMonth:(null==t?void 0:t.crontime)?eg(t.crontime):"1",queryToRun:null==t?void 0:t.query_to_run}});return(0,s.jsx)(eL,{authenticatedData:e.authenticatedData,locationData:e.locationData||null,form:a,onSubmit:a=>{let s=function(e,t,a,s){let n="",r=t.split(":")[1].split(" ")[0],o=t.split(":")[1].split(" ")[1],i=Number(t.split(":")[0]),l="PM"===o&&i<12?String(i+12):i;switch(e){case"Day":n="".concat(r," ").concat(l," * * *");break;case"Week":n="".concat(r," ").concat(l," * * ").concat(void 0!==a?7===a?0:a:"*");break;case"Month":n="".concat(r," ").concat(l," ").concat(s," * *")}return n}(a.everyBlah,a.timeRecurrence,a.dayOfWeek,a.dayOfMonth),n="/api/automation?";n+="q=".concat(a.queryToRun),(null==t?void 0:t.id)&&!e.createNew&&(n+="&automation_id=".concat(t.id)),a.subject&&(n+="&subject=".concat(a.subject)),n+="&crontime=".concat(s),e.locationData&&(n+="&city=".concat(e.locationData.city)+"&region=".concat(e.locationData.region)+"&country=".concat(e.locationData.country)+"&timezone=".concat(e.locationData.timezone)),fetch(n,{method:e.createNew?"POST":"PUT"}).then(e=>e.json()).then(t=>{e.setIsEditing(!1),e.setUpdatedAutomationData({id:t.id,subject:t.subject||"",query_to_run:t.query_to_run,scheduling_request:t.scheduling_request,schedule:ej(t.crontime),crontime:t.crontime,next:t.next})})},create:e.createNew,isLoggedIn:e.isLoggedIn,setShowLoginPrompt:e.setShowLoginPrompt})}function eL(e){var t,a;let[n,r]=(0,l.useState)(!1),{errors:o}=e.form.formState,c=["Make a picture of","Generate a summary of","Create a newsletter of","Notify me when"];return(0,s.jsx)(_,{...e.form,children:(0,s.jsxs)("form",{onSubmit:e.form.handleSubmit(t=>{e.onSubmit(t),r(!0)}),className:"space-y-6",children:[(0,s.jsx)(R,{className:"space-y-1",children:(0,s.jsxs)(P,{children:["Emails will be sent to this address. Timezone and location data will be used to schedule automations.",e.locationData&&(t=e.locationData,a=e.authenticatedData,(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[a?(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(et.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),a.email]}):null,t&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(ea.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),t?"".concat(t.city,", ").concat(t.country):"Unknown"]}),t&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(es.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),t?"".concat(t.timezone):"Unknown"]})]}))]})}),!e.create&&(0,s.jsx)(I,{control:e.form.control,name:"subject",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"space-y-1",children:[(0,s.jsx)(L,{children:"Subject"}),(0,s.jsx)(P,{children:"This is the subject of the email you will receive."}),(0,s.jsx)(O,{children:(0,s.jsx)(q.I,{placeholder:"Digest of Healthcare AI trends",...a})}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.subject)||void 0===t?void 0:t.message})]})}}),(0,s.jsx)(I,{control:e.form.control,name:"everyBlah",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(L,{children:"Frequency"}),(0,s.jsx)(P,{children:"How often should this automation run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(J.W,{className:"h-4 w-4 mr-2 inline"}),"Every"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ey.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.everyBlah)||void 0===t?void 0:t.message})]})}}),"Week"===e.form.watch("everyBlah")&&(0,s.jsx)(I,{control:e.form.control,name:"dayOfWeek",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(P,{children:"Every week, on which day should this automation run?"}),(0,s.jsxs)(x,{onValueChange:e=>a.onChange(Number(e)),defaultValue:String(a.value),children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(ee.n,{className:"h-4 w-4 mr-2 inline"}),"On"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ev.map((e,t)=>(0,s.jsx)(w,{value:String(t),children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.dayOfWeek)||void 0===t?void 0:t.message})]})}}),"Month"===e.form.watch("everyBlah")&&(0,s.jsx)(I,{control:e.form.control,name:"dayOfMonth",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(P,{children:"Every month, on which day should the automation run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(ee.n,{className:"h-4 w-4 mr-2 inline"}),"On the"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ew.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.dayOfMonth)||void 0===t?void 0:t.message})]})}}),("Day"===e.form.watch("everyBlah")||"Week"==e.form.watch("everyBlah")||"Month"==e.form.watch("everyBlah"))&&(0,s.jsx)(I,{control:e.form.control,name:"timeRecurrence",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(L,{children:"Time"}),(0,s.jsx)(P,{children:"On the days this automation runs, at what time should it run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(X.u,{className:"h-4 w-4 mr-2 inline"}),"At"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:eb.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.timeRecurrence)||void 0===t?void 0:t.message})]})}}),(0,s.jsx)(I,{control:e.form.control,name:"queryToRun",render:t=>{var a;let{field:n}=t;return(0,s.jsxs)(R,{className:"space-y-1",children:[(0,s.jsx)(L,{children:"Instructions"}),(0,s.jsx)(P,{children:"What do you want Khoj to do?"}),e.create&&(0,s.jsx)("div",{children:c.map(e=>{var t;return t=n.onChange,(0,s.jsxs)(i.z,{className:"text-xs bg-slate-50 dark:bg-slate-950 h-auto p-1.5 m-1 rounded-full",variant:"ghost",onClick:a=>{a.preventDefault(),t({target:{value:e}},a)},children:[e,"..."]},e)})}),(0,s.jsx)(O,{children:(0,s.jsx)(U.g,{placeholder:"Create a summary of the latest news about AI in healthcare.",value:n.value,onChange:n.onChange})}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(a=o.queryToRun)||void 0===a?void 0:a.message})]})}}),(0,s.jsx)("fieldset",{disabled:n,children:e.isLoggedIn?n?(0,s.jsx)(i.z,{type:"submit",disabled:!0,children:"Saving..."}):(0,s.jsx)(i.z,{type:"submit",children:"Save"}):(0,s.jsx)(i.z,{onClick:t=>{t.preventDefault(),e.setShowLoginPrompt(!0)},variant:"default",children:"Login to Save"})})]})})}function eO(e){return e.isMobileWidth?(0,s.jsxs)(em.dy,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,s.jsx)(em.Qz,{asChild:!0,children:(0,s.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,s.jsxs)(em.sc,{className:"p-2",children:[(0,s.jsx)(em.iI,{children:"Automation"}),(0,s.jsx)(eR,{createNew:e.createNew,automation:e.automation,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]}):(0,s.jsxs)(W.Vq,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,s.jsx)(W.hg,{asChild:!0,children:(0,s.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,s.jsxs)(W.cZ,{className:"max-h-[98vh] overflow-y-auto",children:[(0,s.jsx)(E.$N,{children:"Automation"}),(0,s.jsx)(eR,{automation:e.automation,createNew:e.createNew,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]})}function eP(){let e=(0,eo.G)(),{data:t,error:a,isLoading:o}=(0,n.ZP)(e?"automations":null,eh,{revalidateOnFocus:!1}),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[h,x]=(0,l.useState)([]),[f,p]=(0,l.useState)([]),[g,j]=(0,l.useState)(!1),y=(0,V.IC)(),w=(0,V.k6)();return((0,l.useEffect)(()=>{u&&(x([...h,u]),m(null))},[u,h]),(0,l.useEffect)(()=>{let e=t?t.concat(h):h;e&&p(e_.filter(t=>void 0===e.find(e=>t.subject===e.subject)))},[t,h]),a)?(0,s.jsx)(r.l,{message:"Oops, something went wrong. Please refresh the page."}):(0,s.jsx)("main",{className:"w-full mx-auto",children:(0,s.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,s.jsx)("div",{className:"".concat(Z().sidePanel," top-0"),children:(0,s.jsx)(eu.Z,{conversationId:null,uploadedFiles:[],isMobileWidth:y})}),(0,s.jsxs)("div",{className:"".concat(Z().pageLayout," w-full"),children:[(0,s.jsxs)("div",{className:"pt-6 md:pt-8 grid gap-1 md:flex md:justify-between",children:[(0,s.jsx)("h1",{className:"text-3xl flex items-center",children:"Automations"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[e?(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(et.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),e.email]}):null,w&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(ea.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),w?"".concat(w.city,", ").concat(w.country):"Unknown"]}),w&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(es.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),w?"".concat(w.timezone):"Unknown"]})]})]}),g&&(0,s.jsx)(ei.Z,{loginRedirectMessage:"Create an account to make your own automation",onOpenChange:j}),(0,s.jsx)(ed.bZ,{className:"bg-secondary border-none my-4",children:(0,s.jsxs)(ed.X,{children:[(0,s.jsx)(er.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,s.jsx)("span",{className:"font-bold",children:"How it works"})," Automations help you structure your time by automating tasks you do regularly. Build your own, or try out our presets. Get results straight to your inbox."]})}),(0,s.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,s.jsx)("h3",{className:"text-xl",children:"Your Creations"}),e?(0,s.jsx)(eO,{isMobileWidth:y,callToAction:"Create Automation",createNew:!0,setIsCreating:d,setShowLoginPrompt:j,setNewAutomationData:m,authenticatedData:e,isCreating:c,ipLocationData:w}):(0,s.jsxs)(i.z,{className:"shadow-sm",onClick:()=>j(!0),variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),"Create Automation"]})]}),(0,s.jsx)(l.Suspense,{children:(0,s.jsx)(eM,{isMobileWidth:y,authenticatedData:e,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j,setNewAutomationData:m})}),(!t||0===t.length)&&0==h.length&&!o&&(0,s.jsxs)("div",{className:"px-4",children:["So empty! Create your own automation to get started.",(0,s.jsx)("div",{className:"mt-4",children:e?(0,s.jsx)(eO,{isMobileWidth:y,callToAction:"Design Automation",createNew:!0,setIsCreating:d,setShowLoginPrompt:j,setNewAutomationData:m,authenticatedData:e,isCreating:c,ipLocationData:w}):(0,s.jsx)(i.z,{onClick:()=>j(!0),variant:"default",children:"Design"})})]}),o&&(0,s.jsx)(r.l,{message:"booting up your automations"}),(0,s.jsxs)("div",{className:"".concat(Z().automationsLayout),children:[t&&t.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j},t.id)),h.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j},t.id))]}),(0,s.jsx)("h3",{className:"text-xl py-4",children:"Try these out"}),(0,s.jsx)("div",{className:"".concat(Z().automationsLayout),children:f.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,setNewAutomationData:m,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j,suggestedCard:!0},t.id))})]})]})})}},66820:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var s=a(57437),n=a(6780),r=a(87138);function o(e){return(0,s.jsx)(n.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,s.jsxs)(n._T,{children:[(0,s.jsx)(n.fY,{children:(0,s.jsx)(n.f$,{children:"Sign in to Khoj to continue"})}),(0,s.jsxs)(n.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,s.jsx)(r.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,s.jsxs)(n.xo,{children:[(0,s.jsx)(n.le,{children:"Dismiss"}),(0,s.jsx)(n.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,s.jsxs)(r.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},18642:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var s=a(57437),n=a(90837),r=a(50495),o=a(83102),i=a(67135),l=a(34797);function c(e){var t;return(0,s.jsxs)(n.Vq,{children:[(0,s.jsx)(n.hg,{asChild:!0,onClick:e.onShare,children:(0,s.jsxs)(r.z,{size:"sm",className:"".concat(e.buttonClassName||"px-3"),variant:null!==(t=e.buttonVariant)&&void 0!==t?t:"default",children:[e.includeIcon&&(0,s.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,s.jsxs)(n.cZ,{children:[(0,s.jsxs)(n.fK,{children:[(0,s.jsx)(n.$N,{children:e.title}),(0,s.jsx)(n.Be,{children:e.description})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,s.jsx)(i._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,s.jsx)(o.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,s.jsx)(r.z,{type:"submit",size:"sm",className:"px-3",onClick:()=>(function(e){let t=navigator.clipboard;t&&t.writeText(e)})(e.url),children:(0,s.jsx)("span",{children:"Copy"})})]})]})]})}},47412:function(e,t,a){"use strict";a.d(t,{X:function(){return c},bZ:function(){return l}});var s=a(57437),n=a(2265),r=a(12218),o=a(37440);let i=(0,r.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),l=n.forwardRef((e,t)=>{let{className:a,variant:n,...r}=e;return(0,s.jsx)("div",{ref:t,role:"alert",className:(0,o.cn)(i({variant:n}),a),...r})});l.displayName="Alert",n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("h5",{ref:t,className:(0,o.cn)("mb-1 font-medium leading-none tracking-tight",a),...n})}).displayName="AlertTitle";let c=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("text-sm [&_p]:leading-relaxed",a),...n})});c.displayName="AlertDescription"},67135:function(e,t,a){"use strict";a.d(t,{_:function(){return c}});var s=a(57437),n=a(2265),r=a(38364),o=a(12218),i=a(37440);let l=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.f,{ref:t,className:(0,i.cn)(l(),a),...n})});c.displayName=r.f.displayName},93146:function(e,t,a){"use strict";a.d(t,{g:function(){return o}});var s=a(57437),n=a(2265),r=a(37440);let o=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("textarea",{className:(0,r.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...n})});o.displayName="Textarea"},50151:function(e,t,a){"use strict";a.d(t,{FN:function(){return m},Mi:function(){return f},VW:function(){return c},_i:function(){return d},gD:function(){return h},lj:function(){return p},sA:function(){return x}});var s=a(57437),n=a(2265),r=a(44504),o=a(12218),i=a(74697),l=a(37440);let c=r.zt,d=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.l_,{ref:t,className:(0,l.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...n})});d.displayName=r.l_.displayName;let u=(0,o.j)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),m=n.forwardRef((e,t)=>{let{className:a,variant:n,...o}=e;return(0,s.jsx)(r.fC,{ref:t,className:(0,l.cn)(u({variant:n}),a),...o})});m.displayName=r.fC.displayName;let h=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.aU,{ref:t,className:(0,l.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...n})});h.displayName=r.aU.displayName;let x=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.x8,{ref:t,className:(0,l.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...n,children:(0,s.jsx)(i.Z,{className:"h-4 w-4"})})});x.displayName=r.x8.displayName;let f=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.Dx,{ref:t,className:(0,l.cn)("text-sm font-semibold",a),...n})});f.displayName=r.Dx.displayName;let p=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.dk,{ref:t,className:(0,l.cn)("text-sm opacity-90",a),...n})});p.displayName=r.dk.displayName},35657:function(e,t,a){"use strict";a.d(t,{pm:function(){return m}});var s=a(2265);let n=0,r=new Map,o=e=>{if(r.has(e))return;let t=setTimeout(()=>{r.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);r.set(e,t)},i=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?o(a):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},l=[],c={toasts:[]};function d(e){c=i(c,e),l.forEach(e=>{e(c)})}function u(e){let{...t}=e,a=(n=(n+1)%Number.MAX_SAFE_INTEGER).toString(),s=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||s()}}}),{id:a,dismiss:s,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function m(){let[e,t]=s.useState(c);return s.useEffect(()=>(l.push(t),()=>{let e=l.indexOf(t);e>-1&&l.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},23611:function(e){e.exports={automationsLayout:"automations_automationsLayout__Atoh_",automationCard:"automations_automationCard__BKidA",pageLayout:"automations_pageLayout__OaoYA",sidePanel:"automations_sidePanel__MPciO"}}},function(e){e.O(0,[2734,647,9001,3062,4504,9162,1603,2971,7023,1744],function(){return e(e.s=2743)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4371],{2743:function(e,t,a){Promise.resolve().then(a.bind(a,40393))},40393:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return eP}});var s=a(57437),n=a(29039),r=a(58485),o=a(36013),i=a(50495),l=a(2265),c=a(77539),d=a(42421),u=a(14392),m=a(22468),h=a(37440);let x=c.fC;c.ZA;let f=c.B4,p=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e;return(0,s.jsxs)(c.xz,{ref:t,className:(0,h.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[n,(0,s.jsx)(c.JO,{asChild:!0,children:(0,s.jsx)(d.Z,{className:"h-4 w-4 opacity-50"})})]})});p.displayName=c.xz.displayName;let g=l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.u_,{ref:t,className:(0,h.cn)("flex cursor-default items-center justify-center py-1",a),...n,children:(0,s.jsx)(u.Z,{className:"h-4 w-4"})})});g.displayName=c.u_.displayName;let j=l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.$G,{ref:t,className:(0,h.cn)("flex cursor-default items-center justify-center py-1",a),...n,children:(0,s.jsx)(d.Z,{className:"h-4 w-4"})})});j.displayName=c.$G.displayName;let y=l.forwardRef((e,t)=>{let{className:a,children:n,position:r="popper",...o}=e;return(0,s.jsx)(c.h_,{children:(0,s.jsxs)(c.VY,{ref:t,className:(0,h.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:r,...o,children:[(0,s.jsx)(g,{}),(0,s.jsx)(c.l_,{className:(0,h.cn)("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),(0,s.jsx)(j,{})]})})});y.displayName=c.VY.displayName,l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.__,{ref:t,className:(0,h.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...n})}).displayName=c.__.displayName;let w=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e;return(0,s.jsxs)(c.ck,{ref:t,className:(0,h.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(c.wU,{children:(0,s.jsx)(m.Z,{className:"h-4 w-4"})})}),(0,s.jsx)(c.eT,{children:n})]})});w.displayName=c.ck.displayName,l.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(c.Z0,{ref:t,className:(0,h.cn)("-mx-1 my-1 h-px bg-muted",a),...n})}).displayName=c.Z0.displayName;var v=a(18760),b=a.n(v),N=a(31014),D=a(39343),S=a(59772),C=a(71538),k=a(67135);let _=D.RV,A=l.createContext({}),I=e=>{let{...t}=e;return(0,s.jsx)(A.Provider,{value:{name:t.name},children:(0,s.jsx)(D.Qr,{...t})})},M=()=>{let e=l.useContext(A),t=l.useContext(T),{getFieldState:a,formState:s}=(0,D.Gc)(),n=a(e.name,s);if(!e)throw Error("useFormField should be used within <FormField>");let{id:r}=t;return{id:r,name:e.name,formItemId:"".concat(r,"-form-item"),formDescriptionId:"".concat(r,"-form-item-description"),formMessageId:"".concat(r,"-form-item-message"),...n}},T=l.createContext({}),R=l.forwardRef((e,t)=>{let{className:a,...n}=e,r=l.useId();return(0,s.jsx)(T.Provider,{value:{id:r},children:(0,s.jsx)("div",{ref:t,className:(0,h.cn)("space-y-2",a),...n})})});R.displayName="FormItem";let L=l.forwardRef((e,t)=>{let{className:a,...n}=e,{error:r,formItemId:o}=M();return(0,s.jsx)(k._,{ref:t,className:(0,h.cn)(r&&"text-destructive",a),htmlFor:o,...n})});L.displayName="FormLabel";let O=l.forwardRef((e,t)=>{let{...a}=e,{error:n,formItemId:r,formDescriptionId:o,formMessageId:i}=M();return(0,s.jsx)(C.g7,{ref:t,id:r,"aria-describedby":n?"".concat(o," ").concat(i):"".concat(o),"aria-invalid":!!n,...a})});O.displayName="FormControl";let P=l.forwardRef((e,t)=>{let{className:a,...n}=e,{formDescriptionId:r}=M();return(0,s.jsx)("p",{ref:t,id:r,className:(0,h.cn)("text-sm text-muted-foreground",a),...n})});P.displayName="FormDescription";let z=l.forwardRef((e,t)=>{let{className:a,children:n,...r}=e,{error:o,formMessageId:i}=M(),l=o?String(null==o?void 0:o.message):n;return l?(0,s.jsx)("p",{ref:t,id:i,className:(0,h.cn)("text-sm font-medium text-destructive",a),...r,children:l}):null});z.displayName="FormMessage";var q=a(83102),W=a(90837),E=a(13304),U=a(93146),V=a(69591),F=a(23611),Z=a.n(F),B=a(18642),G=a(16463),Y=a(19573),$=a(20319),H=a(22049),K=a(55362),Q=a(13537),X=a(76082),J=a(52674),ee=a(23751),et=a(83522),ea=a(8837),es=a(21819),en=a(35418),er=a(64945),eo=a(79306),ei=a(66820),el=a(35657),ec=a(50151),ed=a(47412),eu=a(48861),em=a(7951);let eh=()=>window.fetch("/api/automations").then(e=>e.json()).catch(e=>console.log(e));function ex(e){let t=e.split(" "),a=t[2],s=t[4];return"*"===a&&"*"===s?"Day":"*"!==s?"Week":"*"!==a?"Month":"Day"}function ef(e){let t=e.split(" ");if("*"===t[3]&&"*"!==t[4])return Number(t[4])}function ep(e){let t=e.split(" "),a=t[1],s=t[0],n=Number(a)>=12?"PM":"AM",r=Number(a)>12?Number(a)-12:a;"00"===r&&(r="12");let o=s;return 10>Number(o)&&"00"!==o&&(o="0".concat(o)),"".concat(r,":").concat(o," ").concat(n)}function eg(e){return String(e.split(" ")[2])}function ej(e){return b().toString(e)}let ey=["Day","Week","Month"],ew=Array.from({length:31},(e,t)=>String(t+1)),ev=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],eb=[],eN=["AM","PM"];for(var eD=0;eD<eN.length;eD++)for(var eS=0;eS<12;eS++)for(var eC=0;eC<60;eC+=15){let e=String(eC).padStart(2,"0"),t=0===eS?12:eS;eb.push("".concat(t,":").concat(e," ").concat(eN[eD]))}let ek=Date.now(),e_=[{subject:"Weekly Newsletter",query_to_run:"Compile a message including: 1. A recap of news from last week 2. An at-home workout I can do before work 3. A quote to inspire me for the week ahead",schedule:"9AM every Monday",next:"Next run at 9AM on Monday",crontime:"0 9 * * 1",id:ek,scheduling_request:""},{subject:"Daily Bedtime Story",query_to_run:"Compose a bedtime story that a five-year-old might enjoy. It should not exceed five paragraphs. Appeal to the imagination, but weave in learnings.",schedule:"9PM every night",next:"Next run at 9PM today",crontime:"0 21 * * *",id:ek+1,scheduling_request:""},{subject:"Front Page of Hacker News",query_to_run:"Summarize the top 5 posts from https://news.ycombinator.com/best and share them with me, including links",schedule:"9PM on every Wednesday",next:"Next run at 9PM on Wednesday",crontime:"0 21 * * 3",id:ek+2,scheduling_request:""},{subject:"Market Summary",query_to_run:"Get the market summary for today and share it with me. Focus on tech stocks and the S&P 500.",schedule:"9AM on every weekday",next:"Next run at 9AM on Monday",crontime:"0 9 * * *",id:ek+3,scheduling_request:""}];function eA(e){let t=encodeURIComponent(e.subject),a=encodeURIComponent(e.query_to_run),s=encodeURIComponent(e.crontime);return"".concat(window.location.origin,"/automations?subject=").concat(t,"&query=").concat(a,"&crontime=").concat(s)}function eI(e){let[t,a]=(0,l.useState)(!1),[n,r]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(""),{toast:h}=(0,el.pm)(),x=e.automation,[f,p]=(0,l.useState)(""),[g,j]=(0,l.useState)("");return((0,l.useEffect)(()=>{let e=n||x;p(ep(e.crontime));let t=ex(e.crontime);if("Day"===t)j("Daily");else if("Week"===t){let t=ef(e.crontime);void 0===t?j("Weekly"):j("".concat(ev[t]))}else if("Month"===t){let t=eg(e.crontime);j("Monthly on the ".concat(t))}},[n,x]),(0,l.useEffect)(()=>{let e="Automation: ".concat((null==n?void 0:n.subject)||x.subject);u&&(h({title:e,description:u,action:(0,s.jsx)(ec.gD,{altText:"Dismiss",children:"Ok"})}),m(""))},[u,n,x,h]),c)?null:(0,s.jsxs)(o.Zb,{className:"bg-secondary h-full shadow-sm rounded-lg bg-gradient-to-b from-background to-slate-50 dark:to-gray-950 border ".concat(Z().automationCard),children:[(0,s.jsx)(o.Ol,{children:(0,s.jsxs)(o.ll,{className:"line-clamp-2 leading-normal flex justify-between",children:[(null==n?void 0:n.subject)||x.subject,(0,s.jsxs)(Y.J2,{children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsx)(i.z,{className:"bg-background",variant:"ghost",children:(0,s.jsx)($.F,{className:"h-4 w-4"})})}),(0,s.jsxs)(Y.yk,{className:"w-auto grid gap-2 text-left bg-secondary",children:[!e.suggestedCard&&e.locationData&&(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Edit",createNew:!1,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:r,authenticatedData:e.authenticatedData,isCreating:t,automation:n||x,ipLocationData:e.locationData}),(0,s.jsx)(B.Z,{buttonTitle:"Share",includeIcon:!0,buttonClassName:"justify-start px-4 py-2 h-10",buttonVariant:"outline",title:"Share Automation",description:"Copy the link below and share it with your coworkers or friends.",url:eA(x),onShare:()=>{navigator.clipboard.writeText(eA(x))}}),!e.suggestedCard&&(0,s.jsxs)(i.z,{variant:"outline",className:"justify-start",onClick:()=>{!function(e,t){fetch("/api/trigger/automation?automation_id=".concat(e),{method:"POST"}).then(e=>{if(!e.ok)throw Error("Network response was not ok");return e}).then(e=>{t("Automation triggered. Check your inbox in a few minutes!")}).catch(e=>{t("Sorry, something went wrong. Try again later.")})}(x.id.toString(),m)},children:[(0,s.jsx)(H.s,{className:"h-4 w-4 mr-2"}),"Run Now"]}),(0,s.jsxs)(i.z,{variant:"destructive",className:"justify-start",onClick:()=>{if(e.suggestedCard){d(!0);return}!function(e,t){fetch("/api/automation?automation_id=".concat(e),{method:"DELETE"}).then(e=>e.json()).then(e=>{t(!0)})}(x.id.toString(),d)},children:[(0,s.jsx)(K.r,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),(0,s.jsx)(o.aY,{className:"text-secondary-foreground break-all",children:(null==n?void 0:n.query_to_run)||x.query_to_run}),(0,s.jsxs)(o.eW,{className:"flex flex-col items-start md:flex-row md:justify-between md:items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center bg-blue-50 rounded-lg p-1.5 border-blue-200 border dark:bg-blue-800 dark:border-blue-500",children:[(0,s.jsx)(Q.T,{className:"h-4 w-4 mr-2 text-blue-700 dark:text-blue-300"}),(0,s.jsx)("div",{className:"text-s text-blue-700 dark:text-blue-300",children:f})]}),(0,s.jsxs)("div",{className:"flex items-center bg-purple-50 rounded-lg p-1.5 border-purple-200 border dark:bg-purple-800 dark:border-purple-500",children:[(0,s.jsx)(X.u,{className:"h-4 w-4 mr-2 text-purple-700 dark:text-purple-300"}),(0,s.jsx)("div",{className:"text-s text-purple-700 dark:text-purple-300",children:g})]})]}),e.suggestedCard&&e.setNewAutomationData&&(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Add",createNew:!0,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:t,automation:x,ipLocationData:e.locationData})]})]})}function eM(e){let t=(0,G.useSearchParams)(),[a,n]=(0,l.useState)(!0),r=t.get("subject"),o=t.get("query"),i=t.get("crontime");if(!r||!o||!i)return null;let c={id:0,subject:decodeURIComponent(r),query_to_run:decodeURIComponent(o),scheduling_request:"",schedule:ej(decodeURIComponent(i)),crontime:decodeURIComponent(i),next:""};return a?(0,s.jsx)(eO,{isMobileWidth:e.isMobileWidth,callToAction:"Shared",createNew:!0,setIsCreating:n,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:a,automation:c,ipLocationData:e.locationData}):null}let eT=S.z.object({subject:S.z.optional(S.z.string()),everyBlah:S.z.string({required_error:"Every is required"}),dayOfWeek:S.z.optional(S.z.number()),dayOfMonth:S.z.optional(S.z.string()),timeRecurrence:S.z.string({required_error:"Time Recurrence is required"}),queryToRun:S.z.string({required_error:"Query to Run is required"})});function eR(e){let t=e.automation,a=(0,D.cI)({resolver:(0,N.F)(eT),defaultValues:{subject:null==t?void 0:t.subject,everyBlah:(null==t?void 0:t.crontime)?ex(t.crontime):"Day",dayOfWeek:(null==t?void 0:t.crontime)?ef(t.crontime):void 0,timeRecurrence:(null==t?void 0:t.crontime)?ep(t.crontime):"12:00 PM",dayOfMonth:(null==t?void 0:t.crontime)?eg(t.crontime):"1",queryToRun:null==t?void 0:t.query_to_run}});return(0,s.jsx)(eL,{authenticatedData:e.authenticatedData,locationData:e.locationData||null,form:a,onSubmit:a=>{let s=function(e,t,a,s){let n="",r=t.split(":")[1].split(" ")[0],o=t.split(":")[1].split(" ")[1],i=Number(t.split(":")[0]),l="PM"===o&&i<12?String(i+12):i;switch(e){case"Day":n="".concat(r," ").concat(l," * * *");break;case"Week":n="".concat(r," ").concat(l," * * ").concat(void 0!==a?7===a?0:a:"*");break;case"Month":n="".concat(r," ").concat(l," ").concat(s," * *")}return n}(a.everyBlah,a.timeRecurrence,a.dayOfWeek,a.dayOfMonth),n="/api/automation?";n+="q=".concat(a.queryToRun),(null==t?void 0:t.id)&&!e.createNew&&(n+="&automation_id=".concat(t.id)),a.subject&&(n+="&subject=".concat(a.subject)),n+="&crontime=".concat(s),e.locationData&&(n+="&city=".concat(e.locationData.city)+"&region=".concat(e.locationData.region)+"&country=".concat(e.locationData.country)+"&timezone=".concat(e.locationData.timezone)),fetch(n,{method:e.createNew?"POST":"PUT"}).then(e=>e.json()).then(t=>{e.setIsEditing(!1),e.setUpdatedAutomationData({id:t.id,subject:t.subject||"",query_to_run:t.query_to_run,scheduling_request:t.scheduling_request,schedule:ej(t.crontime),crontime:t.crontime,next:t.next})})},create:e.createNew,isLoggedIn:e.isLoggedIn,setShowLoginPrompt:e.setShowLoginPrompt})}function eL(e){var t,a;let[n,r]=(0,l.useState)(!1),{errors:o}=e.form.formState,c=["Make a picture of","Generate a summary of","Create a newsletter of","Notify me when"];return(0,s.jsx)(_,{...e.form,children:(0,s.jsxs)("form",{onSubmit:e.form.handleSubmit(t=>{e.onSubmit(t),r(!0)}),className:"space-y-6",children:[(0,s.jsx)(R,{className:"space-y-1",children:(0,s.jsxs)(P,{children:["Emails will be sent to this address. Timezone and location data will be used to schedule automations.",e.locationData&&(t=e.locationData,a=e.authenticatedData,(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[a?(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(et.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),a.email]}):null,t&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(ea.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),t?"".concat(t.city,", ").concat(t.country):"Unknown"]}),t&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(es.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),t?"".concat(t.timezone):"Unknown"]})]}))]})}),!e.create&&(0,s.jsx)(I,{control:e.form.control,name:"subject",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"space-y-1",children:[(0,s.jsx)(L,{children:"Subject"}),(0,s.jsx)(P,{children:"This is the subject of the email you will receive."}),(0,s.jsx)(O,{children:(0,s.jsx)(q.I,{placeholder:"Digest of Healthcare AI trends",...a})}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.subject)||void 0===t?void 0:t.message})]})}}),(0,s.jsx)(I,{control:e.form.control,name:"everyBlah",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(L,{children:"Frequency"}),(0,s.jsx)(P,{children:"How often should this automation run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(J.W,{className:"h-4 w-4 mr-2 inline"}),"Every"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ey.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.everyBlah)||void 0===t?void 0:t.message})]})}}),"Week"===e.form.watch("everyBlah")&&(0,s.jsx)(I,{control:e.form.control,name:"dayOfWeek",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(P,{children:"Every week, on which day should this automation run?"}),(0,s.jsxs)(x,{onValueChange:e=>a.onChange(Number(e)),defaultValue:String(a.value),children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(ee.n,{className:"h-4 w-4 mr-2 inline"}),"On"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ev.map((e,t)=>(0,s.jsx)(w,{value:String(t),children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.dayOfWeek)||void 0===t?void 0:t.message})]})}}),"Month"===e.form.watch("everyBlah")&&(0,s.jsx)(I,{control:e.form.control,name:"dayOfMonth",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(P,{children:"Every month, on which day should the automation run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(ee.n,{className:"h-4 w-4 mr-2 inline"}),"On the"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:ew.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.dayOfMonth)||void 0===t?void 0:t.message})]})}}),("Day"===e.form.watch("everyBlah")||"Week"==e.form.watch("everyBlah")||"Month"==e.form.watch("everyBlah"))&&(0,s.jsx)(I,{control:e.form.control,name:"timeRecurrence",render:e=>{var t;let{field:a}=e;return(0,s.jsxs)(R,{className:"w-full space-y-1",children:[(0,s.jsx)(L,{children:"Time"}),(0,s.jsx)(P,{children:"On the days this automation runs, at what time should it run?"}),(0,s.jsxs)(x,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,s.jsx)(O,{children:(0,s.jsxs)(p,{className:"w-[200px]",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(X.u,{className:"h-4 w-4 mr-2 inline"}),"At"]}),(0,s.jsx)(f,{placeholder:""})]})}),(0,s.jsx)(y,{children:eb.map(e=>(0,s.jsx)(w,{value:e,children:e},e))})]}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(t=o.timeRecurrence)||void 0===t?void 0:t.message})]})}}),(0,s.jsx)(I,{control:e.form.control,name:"queryToRun",render:t=>{var a;let{field:n}=t;return(0,s.jsxs)(R,{className:"space-y-1",children:[(0,s.jsx)(L,{children:"Instructions"}),(0,s.jsx)(P,{children:"What do you want Khoj to do?"}),e.create&&(0,s.jsx)("div",{children:c.map(e=>{var t;return t=n.onChange,(0,s.jsxs)(i.z,{className:"text-xs bg-slate-50 dark:bg-slate-950 h-auto p-1.5 m-1 rounded-full",variant:"ghost",onClick:a=>{a.preventDefault(),t({target:{value:e}},a)},children:[e,"..."]},e)})}),(0,s.jsx)(O,{children:(0,s.jsx)(U.g,{placeholder:"Create a summary of the latest news about AI in healthcare.",value:n.value,onChange:n.onChange})}),(0,s.jsx)(z,{}),o.subject&&(0,s.jsx)(z,{children:null===(a=o.queryToRun)||void 0===a?void 0:a.message})]})}}),(0,s.jsx)("fieldset",{disabled:n,children:e.isLoggedIn?n?(0,s.jsx)(i.z,{type:"submit",disabled:!0,children:"Saving..."}):(0,s.jsx)(i.z,{type:"submit",children:"Save"}):(0,s.jsx)(i.z,{onClick:t=>{t.preventDefault(),e.setShowLoginPrompt(!0)},variant:"default",children:"Login to Save"})})]})})}function eO(e){return e.isMobileWidth?(0,s.jsxs)(em.dy,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,s.jsx)(em.Qz,{asChild:!0,children:(0,s.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,s.jsxs)(em.sc,{className:"p-2",children:[(0,s.jsx)(em.iI,{children:"Automation"}),(0,s.jsx)(eR,{createNew:e.createNew,automation:e.automation,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]}):(0,s.jsxs)(W.Vq,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,s.jsx)(W.hg,{asChild:!0,children:(0,s.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,s.jsxs)(W.cZ,{className:"max-h-[98vh] overflow-y-auto",children:[(0,s.jsx)(E.$N,{children:"Automation"}),(0,s.jsx)(eR,{automation:e.automation,createNew:e.createNew,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]})}function eP(){let e=(0,eo.G)(),{data:t,error:a,isLoading:o}=(0,n.ZP)(e?"automations":null,eh,{revalidateOnFocus:!1}),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[h,x]=(0,l.useState)([]),[f,p]=(0,l.useState)([]),[g,j]=(0,l.useState)(!1),y=(0,V.IC)(),w=(0,V.k6)();return((0,l.useEffect)(()=>{u&&(x([...h,u]),m(null))},[u,h]),(0,l.useEffect)(()=>{let e=t?t.concat(h):h;e&&p(e_.filter(t=>void 0===e.find(e=>t.subject===e.subject)))},[t,h]),a)?(0,s.jsx)(r.l,{message:"Oops, something went wrong. Please refresh the page."}):(0,s.jsx)("main",{className:"w-full mx-auto",children:(0,s.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,s.jsx)("div",{className:"".concat(Z().sidePanel," top-0"),children:(0,s.jsx)(eu.Z,{conversationId:null,uploadedFiles:[],isMobileWidth:y})}),(0,s.jsxs)("div",{className:"".concat(Z().pageLayout," w-full"),children:[(0,s.jsxs)("div",{className:"pt-6 md:pt-8 grid gap-1 md:flex md:justify-between",children:[(0,s.jsx)("h1",{className:"text-3xl flex items-center",children:"Automations"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[e?(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(et.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),e.email]}):null,w&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(ea.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),w?"".concat(w.city,", ").concat(w.country):"Unknown"]}),w&&(0,s.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,s.jsx)(es.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),w?"".concat(w.timezone):"Unknown"]})]})]}),g&&(0,s.jsx)(ei.Z,{loginRedirectMessage:"Create an account to make your own automation",onOpenChange:j}),(0,s.jsx)(ed.bZ,{className:"bg-secondary border-none my-4",children:(0,s.jsxs)(ed.X,{children:[(0,s.jsx)(er.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,s.jsx)("span",{className:"font-bold",children:"How it works"})," Automations help you structure your time by automating tasks you do regularly. Build your own, or try out our presets. Get results straight to your inbox."]})}),(0,s.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,s.jsx)("h3",{className:"text-xl",children:"Your Creations"}),e?(0,s.jsx)(eO,{isMobileWidth:y,callToAction:"Create Automation",createNew:!0,setIsCreating:d,setShowLoginPrompt:j,setNewAutomationData:m,authenticatedData:e,isCreating:c,ipLocationData:w}):(0,s.jsxs)(i.z,{className:"shadow-sm",onClick:()=>j(!0),variant:"outline",children:[(0,s.jsx)(en.v,{className:"h-4 w-4 mr-2"}),"Create Automation"]})]}),(0,s.jsx)(l.Suspense,{children:(0,s.jsx)(eM,{isMobileWidth:y,authenticatedData:e,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j,setNewAutomationData:m})}),(!t||0===t.length)&&0==h.length&&!o&&(0,s.jsxs)("div",{className:"px-4",children:["So empty! Create your own automation to get started.",(0,s.jsx)("div",{className:"mt-4",children:e?(0,s.jsx)(eO,{isMobileWidth:y,callToAction:"Design Automation",createNew:!0,setIsCreating:d,setShowLoginPrompt:j,setNewAutomationData:m,authenticatedData:e,isCreating:c,ipLocationData:w}):(0,s.jsx)(i.z,{onClick:()=>j(!0),variant:"default",children:"Design"})})]}),o&&(0,s.jsx)(r.l,{message:"booting up your automations"}),(0,s.jsxs)("div",{className:"".concat(Z().automationsLayout),children:[t&&t.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j},t.id)),h.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j},t.id))]}),(0,s.jsx)("h3",{className:"text-xl py-4",children:"Try these out"}),(0,s.jsx)("div",{className:"".concat(Z().automationsLayout),children:f.map(t=>(0,s.jsx)(eI,{isMobileWidth:y,setNewAutomationData:m,authenticatedData:e,automation:t,locationData:w,isLoggedIn:!!e,setShowLoginPrompt:j,suggestedCard:!0},t.id))})]})]})})}},66820:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var s=a(57437),n=a(6780),r=a(87138);function o(e){return(0,s.jsx)(n.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,s.jsxs)(n._T,{children:[(0,s.jsx)(n.fY,{children:(0,s.jsx)(n.f$,{children:"Sign in to Khoj to continue"})}),(0,s.jsxs)(n.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,s.jsx)(r.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,s.jsxs)(n.xo,{children:[(0,s.jsx)(n.le,{children:"Dismiss"}),(0,s.jsx)(n.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,s.jsxs)(r.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},18642:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var s=a(57437),n=a(90837),r=a(50495),o=a(83102),i=a(67135),l=a(34797);function c(e){var t;return(0,s.jsxs)(n.Vq,{children:[(0,s.jsx)(n.hg,{asChild:!0,onClick:e.onShare,children:(0,s.jsxs)(r.z,{size:"sm",className:"".concat(e.buttonClassName||"px-3"),variant:null!==(t=e.buttonVariant)&&void 0!==t?t:"default",children:[e.includeIcon&&(0,s.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,s.jsxs)(n.cZ,{children:[(0,s.jsxs)(n.fK,{children:[(0,s.jsx)(n.$N,{children:e.title}),(0,s.jsx)(n.Be,{children:e.description})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,s.jsx)(i._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,s.jsx)(o.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,s.jsx)(r.z,{type:"submit",size:"sm",className:"px-3",onClick:()=>(function(e){let t=navigator.clipboard;t&&t.writeText(e)})(e.url),children:(0,s.jsx)("span",{children:"Copy"})})]})]})]})}},47412:function(e,t,a){"use strict";a.d(t,{X:function(){return c},bZ:function(){return l}});var s=a(57437),n=a(2265),r=a(12218),o=a(37440);let i=(0,r.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),l=n.forwardRef((e,t)=>{let{className:a,variant:n,...r}=e;return(0,s.jsx)("div",{ref:t,role:"alert",className:(0,o.cn)(i({variant:n}),a),...r})});l.displayName="Alert",n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("h5",{ref:t,className:(0,o.cn)("mb-1 font-medium leading-none tracking-tight",a),...n})}).displayName="AlertTitle";let c=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("text-sm [&_p]:leading-relaxed",a),...n})});c.displayName="AlertDescription"},67135:function(e,t,a){"use strict";a.d(t,{_:function(){return c}});var s=a(57437),n=a(2265),r=a(38364),o=a(12218),i=a(37440);let l=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.f,{ref:t,className:(0,i.cn)(l(),a),...n})});c.displayName=r.f.displayName},93146:function(e,t,a){"use strict";a.d(t,{g:function(){return o}});var s=a(57437),n=a(2265),r=a(37440);let o=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)("textarea",{className:(0,r.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...n})});o.displayName="Textarea"},50151:function(e,t,a){"use strict";a.d(t,{FN:function(){return m},Mi:function(){return f},VW:function(){return c},_i:function(){return d},gD:function(){return h},lj:function(){return p},sA:function(){return x}});var s=a(57437),n=a(2265),r=a(44504),o=a(12218),i=a(74697),l=a(37440);let c=r.zt,d=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.l_,{ref:t,className:(0,l.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...n})});d.displayName=r.l_.displayName;let u=(0,o.j)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),m=n.forwardRef((e,t)=>{let{className:a,variant:n,...o}=e;return(0,s.jsx)(r.fC,{ref:t,className:(0,l.cn)(u({variant:n}),a),...o})});m.displayName=r.fC.displayName;let h=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.aU,{ref:t,className:(0,l.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...n})});h.displayName=r.aU.displayName;let x=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.x8,{ref:t,className:(0,l.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...n,children:(0,s.jsx)(i.Z,{className:"h-4 w-4"})})});x.displayName=r.x8.displayName;let f=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.Dx,{ref:t,className:(0,l.cn)("text-sm font-semibold",a),...n})});f.displayName=r.Dx.displayName;let p=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(r.dk,{ref:t,className:(0,l.cn)("text-sm opacity-90",a),...n})});p.displayName=r.dk.displayName},35657:function(e,t,a){"use strict";a.d(t,{pm:function(){return m}});var s=a(2265);let n=0,r=new Map,o=e=>{if(r.has(e))return;let t=setTimeout(()=>{r.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);r.set(e,t)},i=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?o(a):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},l=[],c={toasts:[]};function d(e){c=i(c,e),l.forEach(e=>{e(c)})}function u(e){let{...t}=e,a=(n=(n+1)%Number.MAX_SAFE_INTEGER).toString(),s=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||s()}}}),{id:a,dismiss:s,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function m(){let[e,t]=s.useState(c);return s.useEffect(()=>(l.push(t),()=>{let e=l.indexOf(t);e>-1&&l.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},23611:function(e){e.exports={automationsLayout:"automations_automationsLayout__Atoh_",automationCard:"automations_automationCard__BKidA",pageLayout:"automations_pageLayout__OaoYA",sidePanel:"automations_sidePanel__MPciO"}}},function(e){e.O(0,[9427,9001,3062,4504,9162,1603,2971,7023,1744],function(){return e(e.s=2743)}),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,t,s){Promise.resolve().then(s.bind(s,38874))},38874:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var n=s(57437),a=s(65104),o=s.n(a),c=s(2265),i=s(48861),r=s(82697),l=s(16463),d=s(58485),u=s(9557);s(7395);var h=s(69591),g=s(38423),m=s(79306);function f(e){let t=(0,l.useSearchParams)().get("conversationId"),[s,a]=(0,c.useState)(""),[i,d]=(0,c.useState)(!1),[u,h]=(0,c.useState)(null),m=e.setQueryToProcess,f=e.onConversationIdChange;if((0,c.useEffect)(()=>{let e=localStorage.getItem("message");e&&(d(!0),m(e))},[m]),(0,c.useEffect)(()=>{s&&(d(!0),m(s))},[s,m]),(0,c.useEffect)(()=>{t&&(null==f||f(t))},[t,f]),(0,c.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?d(!1):a("")},[e.streamedMessages]),!t){window.location.href="/";return}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:o().chatBodyFull,children:(0,n.jsx)(r.Z,{conversationId:t,setTitle:e.setTitle,setAgent:h,pendingMessage:i?s:"",incomingMessages:e.streamedMessages})}),(0,n.jsx)("div",{className:"".concat(o().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-t-2xl rounded-b-none md:rounded-xl"),children:(0,n.jsx)(g.Z,{agentColor:null==u?void 0:u.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>a(e),sendDisabled:i,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}function x(){let e="Khoj AI - Chat",[t,s]=(0,c.useState)(null),[a,r]=(0,c.useState)(!0),[l,g]=(0,c.useState)(e),[x,p]=(0,c.useState)(null),[v,_]=(0,c.useState)([]),[y,j]=(0,c.useState)(""),[b,w]=(0,c.useState)(!1),[M,C]=(0,c.useState)([]),S=(0,h.k6)(),I=(0,m.G)(),N=(0,h.IC)();async function B(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,n="␃\uD83D\uDD1A␗",a="",o=[],c={};for(;;){let e;let{done:i,value:r}=await t.read();if(i){j(""),w(!1);break}for(a+=s.decode(r,{stream:!0});-1!==(e=a.indexOf(n));){let t=a.slice(0,e);if(a=a.slice(e+n.length),t){let e=v.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:o,onlineContext:c}=(0,u.VK)(t,e,o,c)),_([...v])}}}}async function T(){if(localStorage.removeItem("message"),!y||!x)return;let e="/api/chat?q=".concat(encodeURIComponent(y),"&conversation_id=").concat(x,"&stream=true&client=web");S&&(e+="&region=".concat(S.region,"&country=").concat(S.country,"&city=").concat(S.city,"&timezone=").concat(S.timezone));let t=await fetch(e);try{await B(t)}catch(e){console.log(e)}}return((0,c.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{r(!1),e&&s(e)}).catch(e=>{console.error(e)}),(0,h.EK)()},[]),(0,c.useEffect)(()=>{if(y){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:y||""};_(t=>[...t,e]),w(!0)}},[y]),(0,c.useEffect)(()=>{b&&T()},[b]),a)?(0,n.jsx)(d.Z,{}):(0,n.jsxs)("div",{className:"".concat(o().main," ").concat(o().chatLayout),children:[(0,n.jsx)("title",{children:"".concat(e).concat(l&&l!==e?": ".concat(l):"")}),(0,n.jsx)("div",{children:(0,n.jsx)(i.Z,{conversationId:x,uploadedFiles:M,isMobileWidth:N})}),(0,n.jsx)("div",{className:o().chatBox,children:(0,n.jsxs)("div",{className:o().chatBoxBody,children:[!N&&(0,n.jsx)("div",{className:"text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mr-8",children:l&&(0,n.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden pt-6",children:l})}),(0,n.jsx)(c.Suspense,{fallback:(0,n.jsx)(d.Z,{}),children:(0,n.jsx)(f,{isLoggedIn:null!==I,streamedMessages:v,chatOptionsData:t,setTitle:g,setQueryToProcess:j,setUploadedFiles:C,isMobileWidth:N,onConversationIdChange:e=>{p(e)}})})]})})]})}},82697:function(e,t,s){"use strict";s.d(t,{Z:function(){return p}});var n=s(57437),a=s(15238),o=s.n(a),c=s(2265),i=s(89178),r=s(94880),l=s(58485),d=s(16288),u=s(26100),h=s(19666),g=s(50495),m=e=>{let{name:t,avatar:s,link:a,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{asChild:!0,children:(0,n.jsxs)(g.z,{variant:"ghost",className:"flex items-center justify-center",children:[s,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(h._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[s,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(u.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})},f=s(89417),x=s(69591);function p(e){let[t,s]=(0,c.useState)(null),[a,u]=(0,c.useState)(0),[h,g]=(0,c.useState)(!0),p=(0,c.useRef)(null),v=(0,c.useRef)(null),_=(0,c.useRef)(null),[y,j]=(0,c.useState)(null),[b,w]=(0,c.useState)(!1),M=(0,x.IC)();(0,c.useEffect)(()=>{a<2&&((null==t?void 0:t.chat.length)||setTimeout(()=>{C()},500))},[t,a]),(0,c.useEffect)(()=>{if(!h||b)return;let n=new IntersectionObserver(n=>{n[0].isIntersecting&&h&&(w(!0),function(n){if(!h||b)return;let a=n+1,o="";if(e.conversationId)o="/api/chat/history?client=web&conversation_id=".concat(e.conversationId,"&n=").concat(10*a);else{if(!e.publicConversationSlug)return;o="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(10*a)}fetch(o).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(a.response.chat.length===(null==t?void 0:t.chat.length)){g(!1),w(!1);return}e.setAgent(a.response.agent),s(a.response),n<2&&C(),w(!1)}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),s(t)}g(!1),w(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(a),u(e=>e+1))},{threshold:1});return _.current&&n.observe(_.current),()=>n.disconnect()},[h,a,b]),(0,c.useEffect)(()=>{g(!0),w(!1),u(0),s(null)},[e.conversationId]),(0,c.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&j(e.incomingMessages.length-1)}S()&&C()},[e.incomingMessages]);let C=()=>{v.current&&v.current.scrollIntoView(!1)},S=()=>{if(!v.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:s}=v.current;return e+s>=t-25};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(r.x,{className:"h-[80vh]",children:(0,n.jsx)("div",{ref:p,children:(0,n.jsxs)("div",{className:o().chatHistory,ref:v,children:[(0,n.jsx)("div",{ref:_,style:{height:"1px"},children:b&&(0,n.jsx)(l.l,{message:"Loading Conversation",className:"opacity-50"})}),t&&t.chat&&t.chat.map((e,s)=>(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:s===t.chat.length-1},"".concat(s,"fullHistory"))),e.incomingMessages&&e.incomingMessages.map((e,s)=>(0,n.jsxs)(c.Fragment,{children:[(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500")},"".concat(s,"outgoing")),e.trainOfThought&&function(e,t,s,a){let c=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=e.length-1;return(0,n.jsxs)("div",{className:"".concat(o().trainOfThought," shadow-sm"),children:[!c&&(0,n.jsx)(l.l,{className:"float-right"}),e.map((e,a)=>(0,n.jsx)(i.H,{message:e,primary:a===r&&t&&!c,agentColor:s},"train-".concat(a)))]},a)}(e.trainOfThought,s===y,(null==t?void 0:t.agent.color)||"orange","".concat(s,"trainOfThought"),e.completed),(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"".concat(s,"incoming"))]},"incomingMessage".concat(s))),e.pendingMessage&&(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),t&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(m,{name:t&&t.agent&&t.agent.name?t.agent.name:"Agent",link:t&&t.agent&&t.agent.slug?"/agents?agent=".concat(t.agent.slug):"/agents",avatar:(0,f.T)(t.agent.icon,t.agent.color)||(0,n.jsx)(d.v,{}),description:t&&t.agent&&t.agent.persona?t.agent.persona:""})})})]})})}):null}},16463:function(e,t,s){"use strict";var n=s(71169);s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},65104:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w"}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",chatLayout:"chatHistory_chatLayout__ABli_",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}}},function(e){e.O(0,[7812,647,929,3954,9001,3062,743,7071,2614,9693,1603,9417,9178,8423,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,t,s){Promise.resolve().then(s.bind(s,38874))},38874:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var n=s(57437),a=s(65104),o=s.n(a),c=s(2265),i=s(48861),r=s(82697),l=s(16463),d=s(58485),u=s(9557);s(7395);var h=s(69591),g=s(38423),m=s(79306);function f(e){let t=(0,l.useSearchParams)().get("conversationId"),[s,a]=(0,c.useState)(""),[i,d]=(0,c.useState)(!1),[u,h]=(0,c.useState)(null),m=e.setQueryToProcess,f=e.onConversationIdChange;if((0,c.useEffect)(()=>{let e=localStorage.getItem("message");e&&(d(!0),m(e))},[m]),(0,c.useEffect)(()=>{s&&(d(!0),m(s))},[s,m]),(0,c.useEffect)(()=>{t&&(null==f||f(t))},[t,f]),(0,c.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?d(!1):a("")},[e.streamedMessages]),!t){window.location.href="/";return}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:o().chatBodyFull,children:(0,n.jsx)(r.Z,{conversationId:t,setTitle:e.setTitle,setAgent:h,pendingMessage:i?s:"",incomingMessages:e.streamedMessages})}),(0,n.jsx)("div",{className:"".concat(o().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-t-2xl rounded-b-none md:rounded-xl"),children:(0,n.jsx)(g.Z,{agentColor:null==u?void 0:u.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>a(e),sendDisabled:i,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}function x(){let e="Khoj AI - Chat",[t,s]=(0,c.useState)(null),[a,r]=(0,c.useState)(!0),[l,g]=(0,c.useState)(e),[x,p]=(0,c.useState)(null),[v,_]=(0,c.useState)([]),[y,j]=(0,c.useState)(""),[b,w]=(0,c.useState)(!1),[M,C]=(0,c.useState)([]),S=(0,h.k6)(),I=(0,m.G)(),N=(0,h.IC)();async function B(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,n="␃\uD83D\uDD1A␗",a="",o=[],c={};for(;;){let e;let{done:i,value:r}=await t.read();if(i){j(""),w(!1);break}for(a+=s.decode(r,{stream:!0});-1!==(e=a.indexOf(n));){let t=a.slice(0,e);if(a=a.slice(e+n.length),t){let e=v.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:o,onlineContext:c}=(0,u.VK)(t,e,o,c)),_([...v])}}}}async function T(){if(localStorage.removeItem("message"),!y||!x)return;let e="/api/chat?q=".concat(encodeURIComponent(y),"&conversation_id=").concat(x,"&stream=true&client=web");S&&(e+="&region=".concat(S.region,"&country=").concat(S.country,"&city=").concat(S.city,"&timezone=").concat(S.timezone));let t=await fetch(e);try{await B(t)}catch(e){console.log(e)}}return((0,c.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{r(!1),e&&s(e)}).catch(e=>{console.error(e)}),(0,h.EK)()},[]),(0,c.useEffect)(()=>{if(y){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:y||""};_(t=>[...t,e]),w(!0)}},[y]),(0,c.useEffect)(()=>{b&&T()},[b]),a)?(0,n.jsx)(d.Z,{}):(0,n.jsxs)("div",{className:"".concat(o().main," ").concat(o().chatLayout),children:[(0,n.jsx)("title",{children:"".concat(e).concat(l&&l!==e?": ".concat(l):"")}),(0,n.jsx)("div",{children:(0,n.jsx)(i.Z,{conversationId:x,uploadedFiles:M,isMobileWidth:N})}),(0,n.jsx)("div",{className:o().chatBox,children:(0,n.jsxs)("div",{className:o().chatBoxBody,children:[!N&&(0,n.jsx)("div",{className:"text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mr-8",children:l&&(0,n.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden pt-6",children:l})}),(0,n.jsx)(c.Suspense,{fallback:(0,n.jsx)(d.Z,{}),children:(0,n.jsx)(f,{isLoggedIn:null!==I,streamedMessages:v,chatOptionsData:t,setTitle:g,setQueryToProcess:j,setUploadedFiles:C,isMobileWidth:N,onConversationIdChange:e=>{p(e)}})})]})})]})}},82697:function(e,t,s){"use strict";s.d(t,{Z:function(){return p}});var n=s(57437),a=s(15238),o=s.n(a),c=s(2265),i=s(89178),r=s(94880),l=s(58485),d=s(16288),u=s(26100),h=s(19666),g=s(50495),m=e=>{let{name:t,avatar:s,link:a,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{asChild:!0,children:(0,n.jsxs)(g.z,{variant:"ghost",className:"flex items-center justify-center",children:[s,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(h._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[s,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(u.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})},f=s(89417),x=s(69591);function p(e){let[t,s]=(0,c.useState)(null),[a,u]=(0,c.useState)(0),[h,g]=(0,c.useState)(!0),p=(0,c.useRef)(null),v=(0,c.useRef)(null),_=(0,c.useRef)(null),[y,j]=(0,c.useState)(null),[b,w]=(0,c.useState)(!1),M=(0,x.IC)();(0,c.useEffect)(()=>{a<2&&((null==t?void 0:t.chat.length)||setTimeout(()=>{C()},500))},[t,a]),(0,c.useEffect)(()=>{if(!h||b)return;let n=new IntersectionObserver(n=>{n[0].isIntersecting&&h&&(w(!0),function(n){if(!h||b)return;let a=n+1,o="";if(e.conversationId)o="/api/chat/history?client=web&conversation_id=".concat(e.conversationId,"&n=").concat(10*a);else{if(!e.publicConversationSlug)return;o="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(10*a)}fetch(o).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(a.response.chat.length===(null==t?void 0:t.chat.length)){g(!1),w(!1);return}e.setAgent(a.response.agent),s(a.response),n<2&&C(),w(!1)}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),s(t)}g(!1),w(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(a),u(e=>e+1))},{threshold:1});return _.current&&n.observe(_.current),()=>n.disconnect()},[h,a,b]),(0,c.useEffect)(()=>{g(!0),w(!1),u(0),s(null)},[e.conversationId]),(0,c.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&j(e.incomingMessages.length-1)}S()&&C()},[e.incomingMessages]);let C=()=>{v.current&&v.current.scrollIntoView(!1)},S=()=>{if(!v.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:s}=v.current;return e+s>=t-25};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(r.x,{className:"h-[80vh]",children:(0,n.jsx)("div",{ref:p,children:(0,n.jsxs)("div",{className:o().chatHistory,ref:v,children:[(0,n.jsx)("div",{ref:_,style:{height:"1px"},children:b&&(0,n.jsx)(l.l,{message:"Loading Conversation",className:"opacity-50"})}),t&&t.chat&&t.chat.map((e,s)=>(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:s===t.chat.length-1},"".concat(s,"fullHistory"))),e.incomingMessages&&e.incomingMessages.map((e,s)=>(0,n.jsxs)(c.Fragment,{children:[(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500")},"".concat(s,"outgoing")),e.trainOfThought&&function(e,t,s,a){let c=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=e.length-1;return(0,n.jsxs)("div",{className:"".concat(o().trainOfThought," shadow-sm"),children:[!c&&(0,n.jsx)(l.l,{className:"float-right"}),e.map((e,a)=>(0,n.jsx)(i.H,{message:e,primary:a===r&&t&&!c,agentColor:s},"train-".concat(a)))]},a)}(e.trainOfThought,s===y,(null==t?void 0:t.agent.color)||"orange","".concat(s,"trainOfThought"),e.completed),(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"".concat(s,"incoming"))]},"incomingMessage".concat(s))),e.pendingMessage&&(0,n.jsx)(i.Z,{isMobileWidth:M,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),t&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(m,{name:t&&t.agent&&t.agent.name?t.agent.name:"Agent",link:t&&t.agent&&t.agent.slug?"/agents?agent=".concat(t.agent.slug):"/agents",avatar:(0,f.T)(t.agent.icon,t.agent.color)||(0,n.jsx)(d.v,{}),description:t&&t.agent&&t.agent.persona?t.agent.persona:""})})})]})})}):null}},16463:function(e,t,s){"use strict";var n=s(71169);s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},65104:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w"}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",chatLayout:"chatHistory_chatLayout__ABli_",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}}},function(e){e.O(0,[7812,9427,929,3954,9001,3062,743,7071,2614,9693,1603,9417,9178,8423,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);