@tensorpass/aiconnect-react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +15 -2
  4. package/dist/AboutView.d.ts +1 -0
  5. package/dist/AboutView.js +8 -0
  6. package/dist/AboutView.js.map +1 -0
  7. package/dist/AiConnectProvider.d.ts +26 -0
  8. package/dist/AiConnectProvider.js +44 -0
  9. package/dist/AiConnectProvider.js.map +1 -0
  10. package/dist/BrandMark.d.ts +3 -0
  11. package/dist/BrandMark.js +8 -0
  12. package/dist/BrandMark.js.map +1 -0
  13. package/dist/ConnectButton.d.ts +4 -0
  14. package/dist/ConnectButton.js +15 -0
  15. package/dist/ConnectButton.js.map +1 -0
  16. package/dist/ConnectModal.d.ts +1 -0
  17. package/dist/ConnectModal.js +68 -0
  18. package/dist/ConnectModal.js.map +1 -0
  19. package/dist/ConnectRing.d.ts +3 -0
  20. package/dist/ConnectRing.js +8 -0
  21. package/dist/ConnectRing.js.map +1 -0
  22. package/dist/WebAccountStep.d.ts +13 -0
  23. package/dist/WebAccountStep.js +34 -0
  24. package/dist/WebAccountStep.js.map +1 -0
  25. package/dist/index.d.ts +23 -0
  26. package/dist/index.js +12 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/launcher.d.ts +11 -0
  29. package/dist/launcher.js +46 -0
  30. package/dist/launcher.js.map +1 -0
  31. package/dist/launchers.css +150 -0
  32. package/dist/messages.d.ts +15 -0
  33. package/dist/messages.js +46 -0
  34. package/dist/messages.js.map +1 -0
  35. package/dist/moduleMessages.d.ts +29 -0
  36. package/dist/moduleMessages.js +147 -0
  37. package/dist/moduleMessages.js.map +1 -0
  38. package/dist/modules/AiChatInline.d.ts +3 -0
  39. package/dist/modules/AiChatInline.js +18 -0
  40. package/dist/modules/AiChatInline.js.map +1 -0
  41. package/dist/modules/AiChatPage.d.ts +4 -0
  42. package/dist/modules/AiChatPage.js +23 -0
  43. package/dist/modules/AiChatPage.js.map +1 -0
  44. package/dist/modules/AiChatPanel.d.ts +4 -0
  45. package/dist/modules/AiChatPanel.js +22 -0
  46. package/dist/modules/AiChatPanel.js.map +1 -0
  47. package/dist/modules/AiChatPopup.d.ts +4 -0
  48. package/dist/modules/AiChatPopup.js +21 -0
  49. package/dist/modules/AiChatPopup.js.map +1 -0
  50. package/dist/modules/AiSearch.d.ts +3 -0
  51. package/dist/modules/AiSearch.js +76 -0
  52. package/dist/modules/AiSearch.js.map +1 -0
  53. package/dist/modules/Launcher.d.ts +9 -0
  54. package/dist/modules/Launcher.js +8 -0
  55. package/dist/modules/Launcher.js.map +1 -0
  56. package/dist/modules/parts/AccountBadge.d.ts +3 -0
  57. package/dist/modules/parts/AccountBadge.js +15 -0
  58. package/dist/modules/parts/AccountBadge.js.map +1 -0
  59. package/dist/modules/parts/AnswerText.d.ts +8 -0
  60. package/dist/modules/parts/AnswerText.js +43 -0
  61. package/dist/modules/parts/AnswerText.js.map +1 -0
  62. package/dist/modules/parts/ChatFrame.d.ts +12 -0
  63. package/dist/modules/parts/ChatFrame.js +16 -0
  64. package/dist/modules/parts/ChatFrame.js.map +1 -0
  65. package/dist/modules/parts/Composer.d.ts +13 -0
  66. package/dist/modules/parts/Composer.js +64 -0
  67. package/dist/modules/parts/Composer.js.map +1 -0
  68. package/dist/modules/parts/ConnectNote.d.ts +4 -0
  69. package/dist/modules/parts/ConnectNote.js +51 -0
  70. package/dist/modules/parts/ConnectNote.js.map +1 -0
  71. package/dist/modules/parts/ConnectStep.d.ts +4 -0
  72. package/dist/modules/parts/ConnectStep.js +17 -0
  73. package/dist/modules/parts/ConnectStep.js.map +1 -0
  74. package/dist/modules/parts/Conversation.d.ts +22 -0
  75. package/dist/modules/parts/Conversation.js +69 -0
  76. package/dist/modules/parts/Conversation.js.map +1 -0
  77. package/dist/modules/parts/PlanOffer.d.ts +3 -0
  78. package/dist/modules/parts/PlanOffer.js +79 -0
  79. package/dist/modules/parts/PlanOffer.js.map +1 -0
  80. package/dist/modules/parts/ToolActivity.d.ts +5 -0
  81. package/dist/modules/parts/ToolActivity.js +33 -0
  82. package/dist/modules/parts/ToolActivity.js.map +1 -0
  83. package/dist/modules/parts/accountModel.d.ts +2 -0
  84. package/dist/modules/parts/accountModel.js +13 -0
  85. package/dist/modules/parts/accountModel.js.map +1 -0
  86. package/dist/modules/parts/answerMarkdown.d.ts +32 -0
  87. package/dist/modules/parts/answerMarkdown.js +105 -0
  88. package/dist/modules/parts/answerMarkdown.js.map +1 -0
  89. package/dist/modules/parts/icons.d.ts +10 -0
  90. package/dist/modules/parts/icons.js +15 -0
  91. package/dist/modules/parts/icons.js.map +1 -0
  92. package/dist/modules/parts/moduleAnalytics.d.ts +5 -0
  93. package/dist/modules/parts/moduleAnalytics.js +9 -0
  94. package/dist/modules/parts/moduleAnalytics.js.map +1 -0
  95. package/dist/modules/parts/moduleClass.d.ts +1 -0
  96. package/dist/modules/parts/moduleClass.js +6 -0
  97. package/dist/modules/parts/moduleClass.js.map +1 -0
  98. package/dist/modules/parts/planPrice.d.ts +2 -0
  99. package/dist/modules/parts/planPrice.js +8 -0
  100. package/dist/modules/parts/planPrice.js.map +1 -0
  101. package/dist/modules/parts/useModuleChat.d.ts +24 -0
  102. package/dist/modules/parts/useModuleChat.js +117 -0
  103. package/dist/modules/parts/useModuleChat.js.map +1 -0
  104. package/dist/modules/parts/useModuleHandle.d.ts +3 -0
  105. package/dist/modules/parts/useModuleHandle.js +12 -0
  106. package/dist/modules/parts/useModuleHandle.js.map +1 -0
  107. package/dist/modules/types.d.ts +28 -0
  108. package/dist/modules/types.js +5 -0
  109. package/dist/modules/types.js.map +1 -0
  110. package/dist/modules/useOverlay.d.ts +20 -0
  111. package/dist/modules/useOverlay.js +102 -0
  112. package/dist/modules/useOverlay.js.map +1 -0
  113. package/dist/pickerMessages.d.ts +35 -0
  114. package/dist/pickerMessages.js +222 -0
  115. package/dist/pickerMessages.js.map +1 -0
  116. package/dist/styles.css +1721 -0
  117. package/dist/useAiChat.d.ts +33 -0
  118. package/dist/useAiChat.js +143 -0
  119. package/dist/useAiChat.js.map +1 -0
  120. package/dist/webAccountMessages.d.ts +24 -0
  121. package/dist/webAccountMessages.js +130 -0
  122. package/dist/webAccountMessages.js.map +1 -0
  123. package/package.json +48 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA4B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAA0B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAwB,CAAC","sourcesContent":["export { AiConnectProvider, useAiConnect } from './AiConnectProvider.tsx';\nexport type { AiConnectProviderProps } from './AiConnectProvider.tsx';\nexport { ConnectButton } from './ConnectButton.tsx';\nexport type { ConnectButtonProps } from './ConnectButton.tsx';\nexport { useAiChat } from './useAiChat.ts';\nexport type { ChatTurn, ToolActivity, UseAiChatOptions } from './useAiChat.ts';\nexport { builtInLauncherMessages } from './launcher.ts';\nexport type { LauncherLocale, LauncherMessages } from './launcher.ts';\nexport { builtInMessages, builtInModuleMessages } from './messages.ts';\nexport type { Locale, ModuleMessages, PickerMessages, RefusalStep } from './messages.ts';\nexport { builtInWebMessages } from './webAccountMessages.ts';\nexport type { WebAccountMessages } from './webAccountMessages.ts';\nexport { AiChatInline } from './modules/AiChatInline.tsx';\nexport type { AiChatInlineProps } from './modules/AiChatInline.tsx';\nexport { AiChatPage } from './modules/AiChatPage.tsx';\nexport type { AiChatPageProps } from './modules/AiChatPage.tsx';\nexport { AiChatPanel } from './modules/AiChatPanel.tsx';\nexport type { AiChatPanelProps } from './modules/AiChatPanel.tsx';\nexport { AiChatPopup } from './modules/AiChatPopup.tsx';\nexport type { AiChatPopupProps } from './modules/AiChatPopup.tsx';\nexport { AiSearch } from './modules/AiSearch.tsx';\nexport type { AiSearchProps } from './modules/AiSearch.tsx';\nexport type { AiModuleHandle, AiModuleProps, AiOverlayProps } from './modules/types.ts';\n"]}
@@ -0,0 +1,11 @@
1
+ export type LauncherLocale = 'en' | 'fr' | 'he' | 'ar' | 'zh';
2
+ export interface LauncherMessages {
3
+ dir: 'ltr' | 'rtl';
4
+ title: string;
5
+ pageTitle: string;
6
+ openChat: string;
7
+ closeChat: string;
8
+ }
9
+ export declare const builtInLauncherMessages: Record<LauncherLocale, LauncherMessages>;
10
+ export declare const WAVE_ARCS: string[];
11
+ export declare const WAVE_STROKE_WIDTH = 2.4;
@@ -0,0 +1,46 @@
1
+ // What the buttons that open a chat over the page show: their label in each language, the reading
2
+ // direction, and the wallet's wave mark. The modules draw these buttons with React, and the Web
3
+ // Components' loader draws the same ones before the chat's script arrives, so a page shows one button
4
+ // before and after. The module holds no React, which keeps the loader small.
5
+ export const builtInLauncherMessages = {
6
+ en: {
7
+ dir: 'ltr',
8
+ title: 'Ask AI',
9
+ pageTitle: 'AI mode',
10
+ openChat: 'Open the chat',
11
+ closeChat: 'Close the chat',
12
+ },
13
+ fr: {
14
+ dir: 'ltr',
15
+ title: 'Demandez à l\'IA',
16
+ pageTitle: 'Mode IA',
17
+ openChat: 'Ouvrir la conversation',
18
+ closeChat: 'Fermer la conversation',
19
+ },
20
+ he: {
21
+ dir: 'rtl',
22
+ title: 'שאלו את הבינה המלאכותית',
23
+ pageTitle: 'מצב AI',
24
+ openChat: 'פתיחת השיחה',
25
+ closeChat: 'סגירת השיחה',
26
+ },
27
+ ar: {
28
+ dir: 'rtl',
29
+ title: 'اسأل الذكاء الاصطناعي',
30
+ pageTitle: 'وضع الذكاء الاصطناعي',
31
+ openChat: 'فتح المحادثة',
32
+ closeChat: 'إغلاق المحادثة',
33
+ },
34
+ zh: {
35
+ dir: 'ltr',
36
+ title: '问问 AI',
37
+ pageTitle: 'AI 模式',
38
+ openChat: '打开聊天',
39
+ closeChat: '关闭聊天',
40
+ },
41
+ };
42
+ // The wallet's wave mark: three arcs on a 24 grid, each its own path so a live answer can light them
43
+ // one after the other.
44
+ export const WAVE_ARCS = ['M6 8.5a5 5 0 0 1 0 7', 'M10.5 5.5a9.5 9.5 0 0 1 0 13', 'M15 2.5a14 14 0 0 1 0 19'];
45
+ export const WAVE_STROKE_WIDTH = 2.4;
46
+ //# sourceMappingURL=launcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher.js","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,gGAAgG;AAChG,sGAAsG;AACtG,6EAA6E;AAe7E,MAAM,CAAC,MAAM,uBAAuB,GAA6C;IAC/E,EAAE,EAAE;QACF,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,QAAQ;QACf,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,eAAe;QACzB,SAAS,EAAE,gBAAgB;KAC5B;IACD,EAAE,EAAE;QACF,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,wBAAwB;QAClC,SAAS,EAAE,wBAAwB;KACpC;IACD,EAAE,EAAE;QACF,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,yBAAyB;QAChC,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,aAAa;QACvB,SAAS,EAAE,aAAa;KACzB;IACD,EAAE,EAAE;QACF,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,uBAAuB;QAC9B,SAAS,EAAE,sBAAsB;QACjC,QAAQ,EAAE,cAAc;QACxB,SAAS,EAAE,gBAAgB;KAC5B;IACD,EAAE,EAAE;QACF,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF,qGAAqG;AACrG,uBAAuB;AACvB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,sBAAsB,EAAE,8BAA8B,EAAE,0BAA0B,CAAC,CAAC;AAC9G,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC","sourcesContent":["// What the buttons that open a chat over the page show: their label in each language, the reading\n// direction, and the wallet's wave mark. The modules draw these buttons with React, and the Web\n// Components' loader draws the same ones before the chat's script arrives, so a page shows one button\n// before and after. The module holds no React, which keeps the loader small.\n\nexport type LauncherLocale = 'en' | 'fr' | 'he' | 'ar' | 'zh';\n\nexport interface LauncherMessages {\n dir: 'ltr' | 'rtl';\n // The chat's heading, which also labels a side panel's button.\n title: string;\n // The full page's heading, which also labels its button.\n pageTitle: string;\n // The floating button's label while the popup is closed, then while it is open.\n openChat: string;\n closeChat: string;\n}\n\nexport const builtInLauncherMessages: Record<LauncherLocale, LauncherMessages> = {\n en: {\n dir: 'ltr',\n title: 'Ask AI',\n pageTitle: 'AI mode',\n openChat: 'Open the chat',\n closeChat: 'Close the chat',\n },\n fr: {\n dir: 'ltr',\n title: 'Demandez à l\\'IA',\n pageTitle: 'Mode IA',\n openChat: 'Ouvrir la conversation',\n closeChat: 'Fermer la conversation',\n },\n he: {\n dir: 'rtl',\n title: 'שאלו את הבינה המלאכותית',\n pageTitle: 'מצב AI',\n openChat: 'פתיחת השיחה',\n closeChat: 'סגירת השיחה',\n },\n ar: {\n dir: 'rtl',\n title: 'اسأل الذكاء الاصطناعي',\n pageTitle: 'وضع الذكاء الاصطناعي',\n openChat: 'فتح المحادثة',\n closeChat: 'إغلاق المحادثة',\n },\n zh: {\n dir: 'ltr',\n title: '问问 AI',\n pageTitle: 'AI 模式',\n openChat: '打开聊天',\n closeChat: '关闭聊天',\n },\n};\n\n// The wallet's wave mark: three arcs on a 24 grid, each its own path so a live answer can light them\n// one after the other.\nexport const WAVE_ARCS = ['M6 8.5a5 5 0 0 1 0 7', 'M10.5 5.5a9.5 9.5 0 0 1 0 13', 'M15 2.5a14 14 0 0 1 0 19'];\nexport const WAVE_STROKE_WIDTH = 2.4;\n"]}
@@ -0,0 +1,150 @@
1
+ /* The buttons that open a chat over the page: the popup's floating button at the page's corner, and
2
+ the button a side panel or the full page puts where the site renders it. They stand outside the
3
+ module's own ground, so they carry the shades and the type they need. The Web Components' loader
4
+ draws the same buttons from this file before the chat's script arrives, so both look alike. */
5
+
6
+ @keyframes aic-ripple {
7
+ from { opacity: 0.55; transform: scale(1); }
8
+ to { opacity: 0; transform: scale(1.55); }
9
+ }
10
+
11
+ .aic-launcher,
12
+ .aic-fab {
13
+ --aic-m-fill: var(--aic-fill, color-mix(in srgb, var(--aic-ink) 7%, var(--aic-surface)));
14
+ --aic-m-lift: 0 1px 2px rgba(11, 13, 18, 0.08), 0 10px 22px -12px rgba(11, 13, 18, 0.26);
15
+ --aic-m-ease: cubic-bezier(0.16, 1, 0.3, 1);
16
+ box-sizing: border-box;
17
+ font-family: var(--aic-font);
18
+ font-size: 16px;
19
+ line-height: 1.4;
20
+ letter-spacing: normal;
21
+ text-align: start;
22
+ text-transform: none;
23
+ -webkit-font-smoothing: antialiased;
24
+ -webkit-tap-highlight-color: transparent;
25
+ }
26
+
27
+ .aic-launcher:focus-visible,
28
+ .aic-fab:focus-visible {
29
+ outline: 2px solid var(--aic-focus);
30
+ outline-offset: 3px;
31
+ }
32
+
33
+ /* The floating button: the wallet's wave mark, crossed into a close mark while the popup is open,
34
+ and the wallet's ripples while the visitor's AI answers. */
35
+ .aic-fab {
36
+ position: fixed;
37
+ right: 20px;
38
+ bottom: max(20px, env(safe-area-inset-bottom));
39
+ z-index: var(--aic-layer);
40
+ display: grid;
41
+ place-items: center;
42
+ width: 58px;
43
+ height: 58px;
44
+ margin: 0;
45
+ padding: 0;
46
+ border: 0;
47
+ border-radius: 50%;
48
+ background: var(--aic-accent);
49
+ color: var(--aic-accent-ink);
50
+ box-shadow: 0 2px 6px rgba(11, 13, 18, 0.16), 0 14px 28px -14px rgba(11, 13, 18, 0.7);
51
+ cursor: pointer;
52
+ transition: transform 240ms var(--aic-m-ease);
53
+ }
54
+
55
+ .aic-fab[dir='rtl'] {
56
+ right: auto;
57
+ left: 20px;
58
+ }
59
+
60
+ .aic-fab:hover {
61
+ transform: translateY(-2px);
62
+ }
63
+
64
+ .aic-fab:active {
65
+ transform: scale(0.96);
66
+ }
67
+
68
+ .aic-fab > * {
69
+ grid-area: 1 / 1;
70
+ transition: opacity 200ms ease, transform 280ms var(--aic-m-ease);
71
+ }
72
+
73
+ .aic-fab-close {
74
+ display: grid;
75
+ opacity: 0;
76
+ transform: rotate(-90deg) scale(0.6);
77
+ }
78
+
79
+ .aic-fab[data-open] .aic-fab-wave {
80
+ opacity: 0;
81
+ transform: rotate(90deg) scale(0.6);
82
+ }
83
+
84
+ .aic-fab[data-open] .aic-fab-close {
85
+ opacity: 1;
86
+ transform: none;
87
+ }
88
+
89
+ .aic-fab[data-live]::before,
90
+ .aic-fab[data-live]::after {
91
+ content: '';
92
+ position: absolute;
93
+ inset: 0;
94
+ border: 2px solid var(--aic-cyan);
95
+ border-radius: 50%;
96
+ animation: aic-ripple 2.4s ease-out infinite;
97
+ pointer-events: none;
98
+ }
99
+
100
+ .aic-fab[data-live]::after {
101
+ animation-delay: 1.2s;
102
+ }
103
+
104
+ /* The button a panel or the full page puts where the site renders it. */
105
+ .aic-launcher {
106
+ display: inline-flex;
107
+ align-items: center;
108
+ gap: 8px;
109
+ height: 40px;
110
+ margin: 0;
111
+ padding-block: 0;
112
+ padding-inline: 12px 16px;
113
+ border: 0;
114
+ border-radius: 12px;
115
+ background: var(--aic-surface);
116
+ box-shadow: 0 0 0 1px var(--aic-border), 0 1px 2px rgba(11, 13, 18, 0.06);
117
+ color: var(--aic-ink);
118
+ font-family: inherit;
119
+ font-size: 15px;
120
+ font-weight: 700;
121
+ line-height: 1;
122
+ white-space: nowrap;
123
+ cursor: pointer;
124
+ transition: box-shadow 200ms var(--aic-m-ease), transform 200ms var(--aic-m-ease);
125
+ }
126
+
127
+ .aic-launcher:hover {
128
+ box-shadow: 0 0 0 1px var(--aic-border), var(--aic-m-lift);
129
+ transform: translateY(-1px);
130
+ }
131
+
132
+ .aic-launcher[aria-expanded='true'] {
133
+ background: var(--aic-m-fill);
134
+ box-shadow: 0 0 0 1px var(--aic-border);
135
+ transform: none;
136
+ }
137
+
138
+ .aic-launcher-mark {
139
+ flex: none;
140
+ color: var(--aic-cyan);
141
+ }
142
+
143
+ @media (prefers-reduced-motion: reduce) {
144
+ .aic-fab,
145
+ .aic-fab *,
146
+ .aic-launcher {
147
+ animation: none !important;
148
+ transition: none !important;
149
+ }
150
+ }
@@ -0,0 +1,15 @@
1
+ import type { VisitorBrowser, WalletRefusal } from '@tensorpass/aiconnect';
2
+ import type { ModuleMessages } from './moduleMessages.ts';
3
+ import type { PickerMessages, RefusalStep } from './pickerMessages.ts';
4
+ export { builtInModuleMessages } from './moduleMessages.ts';
5
+ export type { ModuleMessages } from './moduleMessages.ts';
6
+ export { builtInMessages } from './pickerMessages.ts';
7
+ export type { Locale, PickerMessages, RefusalStep } from './pickerMessages.ts';
8
+ export declare function installLabel(messages: PickerMessages, browser: VisitorBrowser): string;
9
+ export declare function installText(messages: PickerMessages, browser: VisitorBrowser): string;
10
+ export declare function alreadyAddedLine(messages: PickerMessages, browser: VisitorBrowser): string | undefined;
11
+ export declare function refusalStep(state: {
12
+ message: string;
13
+ reason?: WalletRefusal;
14
+ }, messages: PickerMessages): RefusalStep;
15
+ export declare function failedAnswerText(reason: unknown, account: string, messages: ModuleMessages): string;
@@ -0,0 +1,46 @@
1
+ // The copy of the connect window and of the interface modules, with what reads it: the step after a
2
+ // connection that did not go through and the words of an answer that failed. The copy of each
3
+ // language lives in pickerMessages.ts and moduleMessages.ts.
4
+ import { BROWSER_NAMES } from '@tensorpass/aiconnect';
5
+ export { builtInModuleMessages } from "./moduleMessages.js";
6
+ export { builtInMessages } from "./pickerMessages.js";
7
+ // The visitor's browser by its name in Latin script, or `undefined` for a browser the wallet does not name.
8
+ function browserName(browser) {
9
+ return browser === 'other' ? undefined : BROWSER_NAMES[browser];
10
+ }
11
+ // The words of the install button: "Add to" the visitor's browser, or the general words for a browser the
12
+ // wallet does not name.
13
+ export function installLabel(messages, browser) {
14
+ const name = browserName(browser);
15
+ return name ? messages.addToBrowser(name) : messages.installButton;
16
+ }
17
+ // The text of the install step, which names the visitor's browser where the wallet knows it.
18
+ export function installText(messages, browser) {
19
+ return messages.installText(browserName(browser));
20
+ }
21
+ // The line under the install button for a visitor who may have the wallet already: in Safari, which runs
22
+ // an extension only on the sites the visitor allowed, the way to allow it on every website. Any other
23
+ // browser runs the wallet everywhere once it is added, and has no such line.
24
+ export function alreadyAddedLine(messages, browser) {
25
+ return browser === 'safari' ? messages.safariAlreadyAdded : undefined;
26
+ }
27
+ // The step a connection in error shows: the words for the reason the wallet gave, or the wallet's
28
+ // own message under the general title.
29
+ export function refusalStep(state, messages) {
30
+ return state.reason ? messages.refusals[state.reason] : { ...messages.refusals.failed, text: state.message };
31
+ }
32
+ // The words of an answer that failed, in the page's language: the account's usage limit for a 429 and the
33
+ // provider out of service for a 5xx, which only the provider sends. Any other failure keeps the wallet's own
34
+ // message, since the wallet answers 401, 403 and 499 itself. The error comes from the wallet's own copy of
35
+ // `WalletRequestError`, so its status is read as a field.
36
+ export function failedAnswerText(reason, account, messages) {
37
+ const status = reason?.status;
38
+ if (status === 429) {
39
+ return messages.limitReached.replaceAll('{account}', account);
40
+ }
41
+ if (typeof status === 'number' && status >= 500) {
42
+ return messages.providerDown.replaceAll('{account}', account);
43
+ }
44
+ return reason instanceof Error ? reason.message : String(reason);
45
+ }
46
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,8FAA8F;AAC9F,6DAA6D;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,4GAA4G;AAC5G,SAAS,WAAW,CAAC,OAAuB;IAC1C,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAClE,CAAC;AAED,0GAA0G;AAC1G,wBAAwB;AACxB,MAAM,UAAU,YAAY,CAAC,QAAwB,EAAE,OAAuB;IAC5E,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC;AACrE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CAAC,QAAwB,EAAE,OAAuB;IAC3E,OAAO,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,yGAAyG;AACzG,sGAAsG;AACtG,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,QAAwB,EAAE,OAAuB;IAChF,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC;AAED,kGAAkG;AAClG,uCAAuC;AACvC,MAAM,UAAU,WAAW,CAAC,KAAkD,EAAE,QAAwB;IACtG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AAC/G,CAAC;AAED,0GAA0G;AAC1G,6GAA6G;AAC7G,2GAA2G;AAC3G,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,MAAe,EAAE,OAAe,EAAE,QAAwB;IACzF,MAAM,MAAM,GAAI,MAAsC,EAAE,MAAM,CAAC;IAC/D,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAChD,OAAO,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACnE,CAAC","sourcesContent":["// The copy of the connect window and of the interface modules, with what reads it: the step after a\n// connection that did not go through and the words of an answer that failed. The copy of each\n// language lives in pickerMessages.ts and moduleMessages.ts.\n\nimport { BROWSER_NAMES } from '@tensorpass/aiconnect';\nimport type { VisitorBrowser, WalletRefusal } from '@tensorpass/aiconnect';\nimport type { ModuleMessages } from './moduleMessages.ts';\nimport type { PickerMessages, RefusalStep } from './pickerMessages.ts';\n\nexport { builtInModuleMessages } from './moduleMessages.ts';\nexport type { ModuleMessages } from './moduleMessages.ts';\nexport { builtInMessages } from './pickerMessages.ts';\nexport type { Locale, PickerMessages, RefusalStep } from './pickerMessages.ts';\n\n// The visitor's browser by its name in Latin script, or `undefined` for a browser the wallet does not name.\nfunction browserName(browser: VisitorBrowser): string | undefined {\n return browser === 'other' ? undefined : BROWSER_NAMES[browser];\n}\n\n// The words of the install button: \"Add to\" the visitor's browser, or the general words for a browser the\n// wallet does not name.\nexport function installLabel(messages: PickerMessages, browser: VisitorBrowser): string {\n const name = browserName(browser);\n return name ? messages.addToBrowser(name) : messages.installButton;\n}\n\n// The text of the install step, which names the visitor's browser where the wallet knows it.\nexport function installText(messages: PickerMessages, browser: VisitorBrowser): string {\n return messages.installText(browserName(browser));\n}\n\n// The line under the install button for a visitor who may have the wallet already: in Safari, which runs\n// an extension only on the sites the visitor allowed, the way to allow it on every website. Any other\n// browser runs the wallet everywhere once it is added, and has no such line.\nexport function alreadyAddedLine(messages: PickerMessages, browser: VisitorBrowser): string | undefined {\n return browser === 'safari' ? messages.safariAlreadyAdded : undefined;\n}\n\n// The step a connection in error shows: the words for the reason the wallet gave, or the wallet's\n// own message under the general title.\nexport function refusalStep(state: { message: string; reason?: WalletRefusal }, messages: PickerMessages): RefusalStep {\n return state.reason ? messages.refusals[state.reason] : { ...messages.refusals.failed, text: state.message };\n}\n\n// The words of an answer that failed, in the page's language: the account's usage limit for a 429 and the\n// provider out of service for a 5xx, which only the provider sends. Any other failure keeps the wallet's own\n// message, since the wallet answers 401, 403 and 499 itself. The error comes from the wallet's own copy of\n// `WalletRequestError`, so its status is read as a field.\nexport function failedAnswerText(reason: unknown, account: string, messages: ModuleMessages): string {\n const status = (reason as { status?: unknown } | null)?.status;\n if (status === 429) {\n return messages.limitReached.replaceAll('{account}', account);\n }\n if (typeof status === 'number' && status >= 500) {\n return messages.providerDown.replaceAll('{account}', account);\n }\n return reason instanceof Error ? reason.message : String(reason);\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { LauncherMessages } from './launcher.ts';
2
+ import type { Locale } from './pickerMessages.ts';
3
+ export interface ModuleMessages extends LauncherMessages {
4
+ intro: string;
5
+ placeholder: string;
6
+ searchPlaceholder: string;
7
+ searchLabel: string;
8
+ suggestionsLabel: string;
9
+ send: string;
10
+ stop: string;
11
+ stopped: string;
12
+ newChat: string;
13
+ close: string;
14
+ clear: string;
15
+ question: string;
16
+ answersWith: string;
17
+ thinking: string;
18
+ toolRunning: string;
19
+ toolDone: string;
20
+ toolFailed: string;
21
+ connect: string;
22
+ pendingText: string;
23
+ retry: string;
24
+ guardQuestion: string;
25
+ guardAnswer: string;
26
+ limitReached: string;
27
+ providerDown: string;
28
+ }
29
+ export declare const builtInModuleMessages: Record<Locale, ModuleMessages>;
@@ -0,0 +1,147 @@
1
+ // The copy of the interface modules in each built in language. A site passes `locale`, or its own
2
+ // `moduleMessages`, to match its voice. The modules also read the connect window's copy for the
3
+ // connection steps they show.
4
+ import { builtInLauncherMessages } from "./launcher.js";
5
+ const enModules = {
6
+ ...builtInLauncherMessages.en,
7
+ intro: 'What would you like to know?',
8
+ placeholder: 'Ask a question',
9
+ searchPlaceholder: 'Search or ask a question',
10
+ searchLabel: 'Ask this site',
11
+ suggestionsLabel: 'Suggested questions',
12
+ send: 'Send',
13
+ stop: 'Stop',
14
+ stopped: 'Answer stopped',
15
+ newChat: 'New chat',
16
+ close: 'Close',
17
+ clear: 'Clear',
18
+ question: 'Your question',
19
+ answersWith: 'Answers with',
20
+ thinking: 'Thinking',
21
+ toolRunning: 'running',
22
+ toolDone: 'done',
23
+ toolFailed: 'Failed',
24
+ connect: 'Connect your AI',
25
+ pendingText: 'Your question is ready. Connect your AI to see the answer.',
26
+ retry: 'Try again',
27
+ guardQuestion: 'This chat answers questions about the site. Ask about what you are looking for here.',
28
+ guardAnswer: 'This answer was held back because it broke the site\'s rules. Try asking another way.',
29
+ limitReached: '{account} has reached its usage limit for now. Try again later, or choose another account in '
30
+ + 'AI Wallet.',
31
+ providerDown: '{account} is not answering right now. Try again in a moment.',
32
+ };
33
+ const frModules = {
34
+ ...builtInLauncherMessages.fr,
35
+ intro: 'Que voulez-vous savoir\u00a0?',
36
+ placeholder: 'Posez votre question',
37
+ searchPlaceholder: 'Cherchez ou posez une question',
38
+ searchLabel: 'Interrogez ce site',
39
+ suggestionsLabel: 'Questions suggérées',
40
+ send: 'Envoyer',
41
+ stop: 'Arrêter',
42
+ stopped: 'Réponse arrêtée',
43
+ newChat: 'Nouvelle conversation',
44
+ close: 'Fermer',
45
+ clear: 'Effacer',
46
+ question: 'Votre question',
47
+ answersWith: 'Répond avec',
48
+ thinking: 'Réflexion en cours',
49
+ toolRunning: 'en cours',
50
+ toolDone: 'terminé',
51
+ toolFailed: 'Échec',
52
+ connect: 'Connecter votre IA',
53
+ pendingText: 'Votre question est prête. Connectez votre IA pour voir la réponse.',
54
+ retry: 'Réessayer',
55
+ guardQuestion: 'Cette conversation répond aux questions sur le site. Demandez ce que vous cherchez ici.',
56
+ guardAnswer: 'Cette réponse a été retenue, car elle enfreignait les règles du site. Reformulez votre question.',
57
+ limitReached: '{account} a atteint sa limite d\'utilisation pour le moment. Réessayez plus tard, ou choisissez '
58
+ + 'un autre compte dans AI Wallet.',
59
+ providerDown: '{account} ne répond pas pour le moment. Réessayez dans un instant.',
60
+ };
61
+ const heModules = {
62
+ ...builtInLauncherMessages.he,
63
+ intro: 'מה תרצו לדעת?',
64
+ placeholder: 'כתבו שאלה',
65
+ searchPlaceholder: 'חפשו או שאלו שאלה',
66
+ searchLabel: 'שאלו את האתר',
67
+ suggestionsLabel: 'שאלות מוצעות',
68
+ send: 'שליחה',
69
+ stop: 'עצירה',
70
+ stopped: 'התשובה נעצרה',
71
+ newChat: 'שיחה חדשה',
72
+ close: 'סגירה',
73
+ clear: 'ניקוי',
74
+ question: 'השאלה שלכם',
75
+ answersWith: 'עונה עם',
76
+ thinking: 'חושב',
77
+ toolRunning: 'פועל',
78
+ toolDone: 'הסתיים',
79
+ toolFailed: 'נכשל',
80
+ connect: 'חיבור הבינה המלאכותית',
81
+ pendingText: 'השאלה שלכם מוכנה. חברו את הבינה המלאכותית שלכם כדי לראות את התשובה.',
82
+ retry: 'ניסיון נוסף',
83
+ guardQuestion: 'הצ׳אט הזה עונה על שאלות על האתר. שאלו על מה שאתם מחפשים כאן.',
84
+ guardAnswer: 'התשובה הזו נעצרה כי היא חרגה מהכללים של האתר. נסו לשאול אחרת.',
85
+ limitReached: '{account} הגיע למגבלת השימוש שלו כרגע. נסו שוב מאוחר יותר, או בחרו חשבון אחר '
86
+ + 'בתוך AI Wallet.',
87
+ providerDown: '{account} לא עונה כרגע. נסו שוב בעוד רגע.',
88
+ };
89
+ const arModules = {
90
+ ...builtInLauncherMessages.ar,
91
+ intro: 'ماذا تريد أن تعرف؟',
92
+ placeholder: 'اطرح سؤالًا',
93
+ searchPlaceholder: 'ابحث أو اطرح سؤالًا',
94
+ searchLabel: 'اسأل هذا الموقع',
95
+ suggestionsLabel: 'أسئلة مقترحة',
96
+ send: 'إرسال',
97
+ stop: 'إيقاف',
98
+ stopped: 'توقفت الإجابة',
99
+ newChat: 'محادثة جديدة',
100
+ close: 'إغلاق',
101
+ clear: 'مسح',
102
+ question: 'سؤالك',
103
+ answersWith: 'يجيب عبر',
104
+ thinking: 'يفكر',
105
+ toolRunning: 'قيد التشغيل',
106
+ toolDone: 'تم',
107
+ toolFailed: 'فشل',
108
+ connect: 'اربط الذكاء الاصطناعي الخاص بك',
109
+ pendingText: 'سؤالك جاهز. اربط الذكاء الاصطناعي الخاص بك لرؤية الإجابة.',
110
+ retry: 'إعادة المحاولة',
111
+ guardQuestion: 'تجيب هذه المحادثة عن أسئلة حول الموقع. اسأل عمّا تبحث عنه هنا.',
112
+ guardAnswer: 'حُجبت هذه الإجابة لأنها خالفت قواعد الموقع. جرّب صياغة سؤالك بطريقة أخرى.',
113
+ limitReached: '{account} بلغ حد الاستخدام في الوقت الحالي. حاول مرة أخرى لاحقًا، أو اختر حسابًا آخر في '
114
+ + 'AI Wallet.',
115
+ providerDown: '{account} لا يجيب الآن. حاول مرة أخرى بعد قليل.',
116
+ };
117
+ const zhModules = {
118
+ ...builtInLauncherMessages.zh,
119
+ intro: '你想了解什么?',
120
+ placeholder: '提个问题',
121
+ searchPlaceholder: '搜索或提问',
122
+ searchLabel: '向这个网站提问',
123
+ suggestionsLabel: '推荐问题',
124
+ send: '发送',
125
+ stop: '停止',
126
+ stopped: '回答已停止',
127
+ newChat: '新对话',
128
+ close: '关闭',
129
+ clear: '清除',
130
+ question: '你的问题',
131
+ answersWith: '回答使用',
132
+ thinking: '思考中',
133
+ toolRunning: '运行中',
134
+ toolDone: '完成',
135
+ toolFailed: '失败',
136
+ connect: '连接你的 AI',
137
+ pendingText: '你的问题已准备好。连接你的 AI 即可查看回答。',
138
+ retry: '重试',
139
+ guardQuestion: '这个对话回答有关本网站的问题。请询问你在这里要找的内容。',
140
+ guardAnswer: '这个回答因违反网站规则而被拦下。请换一种方式提问。',
141
+ limitReached: '{account} 暂时已达到使用上限。请稍后再试,或在 AI Wallet 中选择其他账户。',
142
+ providerDown: '{account} 现在没有响应。请稍后再试。',
143
+ };
144
+ export const builtInModuleMessages = {
145
+ en: enModules, fr: frModules, he: heModules, ar: arModules, zh: zhModules,
146
+ };
147
+ //# sourceMappingURL=moduleMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleMessages.js","sourceRoot":"","sources":["../src/moduleMessages.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,gGAAgG;AAChG,8BAA8B;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAoCxD,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,gBAAgB;IAC7B,iBAAiB,EAAE,0BAA0B;IAC7C,WAAW,EAAE,eAAe;IAC5B,gBAAgB,EAAE,qBAAqB;IACvC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,cAAc;IAC3B,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE,WAAW;IAClB,aAAa,EAAE,sFAAsF;IACrG,WAAW,EAAE,uFAAuF;IACpG,YAAY,EAAE,+FAA+F;UACzG,YAAY;IAChB,YAAY,EAAE,8DAA8D;CAC7E,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,sBAAsB;IACnC,iBAAiB,EAAE,gCAAgC;IACnD,WAAW,EAAE,oBAAoB;IACjC,gBAAgB,EAAE,qBAAqB;IACvC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,uBAAuB;IAChC,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,gBAAgB;IAC1B,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,oBAAoB;IAC9B,WAAW,EAAE,UAAU;IACvB,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,oBAAoB;IAC7B,WAAW,EAAE,oEAAoE;IACjF,KAAK,EAAE,WAAW;IAClB,aAAa,EAAE,yFAAyF;IACxG,WAAW,EAAE,kGAAkG;IAC/G,YAAY,EAAE,kGAAkG;UAC5G,iCAAiC;IACrC,YAAY,EAAE,oEAAoE;CACnF,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,WAAW;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,WAAW,EAAE,cAAc;IAC3B,gBAAgB,EAAE,cAAc;IAChC,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,uBAAuB;IAChC,WAAW,EAAE,qEAAqE;IAClF,KAAK,EAAE,aAAa;IACpB,aAAa,EAAE,8DAA8D;IAC7E,WAAW,EAAE,+DAA+D;IAC5E,YAAY,EAAE,+EAA+E;UACzF,iBAAiB;IACrB,YAAY,EAAE,2CAA2C;CAC1D,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,qBAAqB;IACxC,WAAW,EAAE,iBAAiB;IAC9B,gBAAgB,EAAE,cAAc;IAChC,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,eAAe;IACxB,OAAO,EAAE,cAAc;IACvB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,OAAO;IACjB,WAAW,EAAE,UAAU;IACvB,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,gCAAgC;IACzC,WAAW,EAAE,2DAA2D;IACxE,KAAK,EAAE,gBAAgB;IACvB,aAAa,EAAE,gEAAgE;IAC/E,WAAW,EAAE,2EAA2E;IACxF,YAAY,EAAE,0FAA0F;UACpG,YAAY;IAChB,YAAY,EAAE,iDAAiD;CAChE,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,MAAM;IACnB,iBAAiB,EAAE,OAAO;IAC1B,WAAW,EAAE,SAAS;IACtB,gBAAgB,EAAE,MAAM;IACxB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,0BAA0B;IACvC,KAAK,EAAE,IAAI;IACX,aAAa,EAAE,8BAA8B;IAC7C,WAAW,EAAE,2BAA2B;IACxC,YAAY,EAAE,iDAAiD;IAC/D,YAAY,EAAE,yBAAyB;CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAmC;IACnE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS;CAC1E,CAAC","sourcesContent":["// The copy of the interface modules in each built in language. A site passes `locale`, or its own\n// `moduleMessages`, to match its voice. The modules also read the connect window's copy for the\n// connection steps they show.\n\nimport { builtInLauncherMessages } from './launcher.ts';\nimport type { LauncherMessages } from './launcher.ts';\nimport type { Locale } from './pickerMessages.ts';\n\n// The modules' copy. The direction, the headings and the labels of the buttons that open a chat come from\n// the launcher module, which the Web Components' loader reads too.\nexport interface ModuleMessages extends LauncherMessages {\n intro: string;\n placeholder: string;\n searchPlaceholder: string;\n searchLabel: string;\n suggestionsLabel: string;\n send: string;\n stop: string;\n stopped: string;\n newChat: string;\n close: string;\n clear: string;\n question: string;\n answersWith: string;\n thinking: string;\n toolRunning: string;\n toolDone: string;\n toolFailed: string;\n connect: string;\n pendingText: string;\n retry: string;\n // Shown in place of a question or an answer the chat's guards stopped, unless the site sets its own.\n guardQuestion: string;\n guardAnswer: string;\n // Shown when the account that answers is refused by its provider: its usage limit reached (HTTP 429) or\n // the provider out of service (5xx). `{account}` stands for the account's name, such as ChatGPT.\n limitReached: string;\n providerDown: string;\n}\n\nconst enModules: ModuleMessages = {\n ...builtInLauncherMessages.en,\n intro: 'What would you like to know?',\n placeholder: 'Ask a question',\n searchPlaceholder: 'Search or ask a question',\n searchLabel: 'Ask this site',\n suggestionsLabel: 'Suggested questions',\n send: 'Send',\n stop: 'Stop',\n stopped: 'Answer stopped',\n newChat: 'New chat',\n close: 'Close',\n clear: 'Clear',\n question: 'Your question',\n answersWith: 'Answers with',\n thinking: 'Thinking',\n toolRunning: 'running',\n toolDone: 'done',\n toolFailed: 'Failed',\n connect: 'Connect your AI',\n pendingText: 'Your question is ready. Connect your AI to see the answer.',\n retry: 'Try again',\n guardQuestion: 'This chat answers questions about the site. Ask about what you are looking for here.',\n guardAnswer: 'This answer was held back because it broke the site\\'s rules. Try asking another way.',\n limitReached: '{account} has reached its usage limit for now. Try again later, or choose another account in '\n + 'AI Wallet.',\n providerDown: '{account} is not answering right now. Try again in a moment.',\n};\n\nconst frModules: ModuleMessages = {\n ...builtInLauncherMessages.fr,\n intro: 'Que voulez-vous savoir\\u00a0?',\n placeholder: 'Posez votre question',\n searchPlaceholder: 'Cherchez ou posez une question',\n searchLabel: 'Interrogez ce site',\n suggestionsLabel: 'Questions suggérées',\n send: 'Envoyer',\n stop: 'Arrêter',\n stopped: 'Réponse arrêtée',\n newChat: 'Nouvelle conversation',\n close: 'Fermer',\n clear: 'Effacer',\n question: 'Votre question',\n answersWith: 'Répond avec',\n thinking: 'Réflexion en cours',\n toolRunning: 'en cours',\n toolDone: 'terminé',\n toolFailed: 'Échec',\n connect: 'Connecter votre IA',\n pendingText: 'Votre question est prête. Connectez votre IA pour voir la réponse.',\n retry: 'Réessayer',\n guardQuestion: 'Cette conversation répond aux questions sur le site. Demandez ce que vous cherchez ici.',\n guardAnswer: 'Cette réponse a été retenue, car elle enfreignait les règles du site. Reformulez votre question.',\n limitReached: '{account} a atteint sa limite d\\'utilisation pour le moment. Réessayez plus tard, ou choisissez '\n + 'un autre compte dans AI Wallet.',\n providerDown: '{account} ne répond pas pour le moment. Réessayez dans un instant.',\n};\n\nconst heModules: ModuleMessages = {\n ...builtInLauncherMessages.he,\n intro: 'מה תרצו לדעת?',\n placeholder: 'כתבו שאלה',\n searchPlaceholder: 'חפשו או שאלו שאלה',\n searchLabel: 'שאלו את האתר',\n suggestionsLabel: 'שאלות מוצעות',\n send: 'שליחה',\n stop: 'עצירה',\n stopped: 'התשובה נעצרה',\n newChat: 'שיחה חדשה',\n close: 'סגירה',\n clear: 'ניקוי',\n question: 'השאלה שלכם',\n answersWith: 'עונה עם',\n thinking: 'חושב',\n toolRunning: 'פועל',\n toolDone: 'הסתיים',\n toolFailed: 'נכשל',\n connect: 'חיבור הבינה המלאכותית',\n pendingText: 'השאלה שלכם מוכנה. חברו את הבינה המלאכותית שלכם כדי לראות את התשובה.',\n retry: 'ניסיון נוסף',\n guardQuestion: 'הצ׳אט הזה עונה על שאלות על האתר. שאלו על מה שאתם מחפשים כאן.',\n guardAnswer: 'התשובה הזו נעצרה כי היא חרגה מהכללים של האתר. נסו לשאול אחרת.',\n limitReached: '{account} הגיע למגבלת השימוש שלו כרגע. נסו שוב מאוחר יותר, או בחרו חשבון אחר '\n + 'בתוך AI Wallet.',\n providerDown: '{account} לא עונה כרגע. נסו שוב בעוד רגע.',\n};\n\nconst arModules: ModuleMessages = {\n ...builtInLauncherMessages.ar,\n intro: 'ماذا تريد أن تعرف؟',\n placeholder: 'اطرح سؤالًا',\n searchPlaceholder: 'ابحث أو اطرح سؤالًا',\n searchLabel: 'اسأل هذا الموقع',\n suggestionsLabel: 'أسئلة مقترحة',\n send: 'إرسال',\n stop: 'إيقاف',\n stopped: 'توقفت الإجابة',\n newChat: 'محادثة جديدة',\n close: 'إغلاق',\n clear: 'مسح',\n question: 'سؤالك',\n answersWith: 'يجيب عبر',\n thinking: 'يفكر',\n toolRunning: 'قيد التشغيل',\n toolDone: 'تم',\n toolFailed: 'فشل',\n connect: 'اربط الذكاء الاصطناعي الخاص بك',\n pendingText: 'سؤالك جاهز. اربط الذكاء الاصطناعي الخاص بك لرؤية الإجابة.',\n retry: 'إعادة المحاولة',\n guardQuestion: 'تجيب هذه المحادثة عن أسئلة حول الموقع. اسأل عمّا تبحث عنه هنا.',\n guardAnswer: 'حُجبت هذه الإجابة لأنها خالفت قواعد الموقع. جرّب صياغة سؤالك بطريقة أخرى.',\n limitReached: '{account} بلغ حد الاستخدام في الوقت الحالي. حاول مرة أخرى لاحقًا، أو اختر حسابًا آخر في '\n + 'AI Wallet.',\n providerDown: '{account} لا يجيب الآن. حاول مرة أخرى بعد قليل.',\n};\n\nconst zhModules: ModuleMessages = {\n ...builtInLauncherMessages.zh,\n intro: '你想了解什么?',\n placeholder: '提个问题',\n searchPlaceholder: '搜索或提问',\n searchLabel: '向这个网站提问',\n suggestionsLabel: '推荐问题',\n send: '发送',\n stop: '停止',\n stopped: '回答已停止',\n newChat: '新对话',\n close: '关闭',\n clear: '清除',\n question: '你的问题',\n answersWith: '回答使用',\n thinking: '思考中',\n toolRunning: '运行中',\n toolDone: '完成',\n toolFailed: '失败',\n connect: '连接你的 AI',\n pendingText: '你的问题已准备好。连接你的 AI 即可查看回答。',\n retry: '重试',\n guardQuestion: '这个对话回答有关本网站的问题。请询问你在这里要找的内容。',\n guardAnswer: '这个回答因违反网站规则而被拦下。请换一种方式提问。',\n limitReached: '{account} 暂时已达到使用上限。请稍后再试,或在 AI Wallet 中选择其他账户。',\n providerDown: '{account} 现在没有响应。请稍后再试。',\n};\n\nexport const builtInModuleMessages: Record<Locale, ModuleMessages> = {\n en: enModules, fr: frModules, he: heModules, ar: arModules, zh: zhModules,\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { AiModuleProps } from './types.ts';
2
+ export type AiChatInlineProps = AiModuleProps;
3
+ export declare function AiChatInline({ ref, ...props }: AiChatInlineProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // A chat set inline in the page, where the site renders it, at the height of the
3
+ // `--aic-inline-height` token. Its conversation scrolls inside it.
4
+ import { useId, useRef } from 'react';
5
+ import { useAiConnect } from "../AiConnectProvider.js";
6
+ import { ChatFrame } from "./parts/ChatFrame.js";
7
+ import { moduleClass } from "./parts/moduleClass.js";
8
+ import { useModuleChat } from "./parts/useModuleChat.js";
9
+ import { useModuleHandle } from "./parts/useModuleHandle.js";
10
+ export function AiChatInline({ ref, ...props }) {
11
+ const { moduleMessages } = useAiConnect();
12
+ const chat = useModuleChat(props);
13
+ useModuleHandle(ref, chat.ask);
14
+ const fieldRef = useRef(null);
15
+ const titleId = useId();
16
+ return (_jsx("section", { className: moduleClass('inline', props.className), dir: moduleMessages.dir, "aria-labelledby": titleId, children: _jsx(ChatFrame, { module: props, chat: chat, title: props.title ?? moduleMessages.title, titleId: titleId, fieldRef: fieldRef }) }));
17
+ }
18
+ //# sourceMappingURL=AiChatInline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiChatInline.js","sourceRoot":"","sources":["../../src/modules/AiChatInline.tsx"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,mEAAmE;AAEnE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAK7D,MAAM,UAAU,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAqB;IAC/D,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,OAAO,CACL,kBAAS,SAAS,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,qBAChE,OAAO,YACxB,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAChG,QAAQ,EAAE,QAAQ,GAAI,GAChB,CACX,CAAC;AACJ,CAAC","sourcesContent":["// A chat set inline in the page, where the site renders it, at the height of the\n// `--aic-inline-height` token. Its conversation scrolls inside it.\n\nimport { useId, useRef } from 'react';\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps } from './types.ts';\n\nexport type AiChatInlineProps = AiModuleProps;\n\nexport function AiChatInline({ ref, ...props }: AiChatInlineProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n useModuleHandle(ref, chat.ask);\n const fieldRef = useRef<HTMLTextAreaElement>(null);\n const titleId = useId();\n return (\n <section className={moduleClass('inline', props.className)} dir={moduleMessages.dir}\n aria-labelledby={titleId}>\n <ChatFrame module={props} chat={chat} title={props.title ?? moduleMessages.title} titleId={titleId}\n fieldRef={fieldRef} />\n </section>\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { AiModuleProps, AiOverlayProps } from './types.ts';
2
+ export interface AiChatPageProps extends AiModuleProps, AiOverlayProps {
3
+ }
4
+ export declare function AiChatPage({ ref, ...props }: AiChatPageProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A full page AI mode: the chat takes the whole window over the site, in one centred column, with
3
+ // the page's scroll held and the focus kept inside until the visitor closes it. It opens from its
4
+ // own button, placed where the site renders the module, or from the site's own through `open`.
5
+ import { useAiConnect } from "../AiConnectProvider.js";
6
+ import { Launcher } from "./Launcher.js";
7
+ import { ChatFrame } from "./parts/ChatFrame.js";
8
+ import { moduleClass } from "./parts/moduleClass.js";
9
+ import { useModuleChat } from "./parts/useModuleChat.js";
10
+ import { useModuleHandle } from "./parts/useModuleHandle.js";
11
+ import { useFocusTrap, useOverlay, useScrollLock } from "./useOverlay.js";
12
+ export function AiChatPage({ ref, ...props }) {
13
+ const { moduleMessages, isPickerOpen } = useAiConnect();
14
+ const chat = useModuleChat(props);
15
+ const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);
16
+ useModuleHandle(ref, chat.ask, show);
17
+ useScrollLock(open);
18
+ // The connect window opens over the page mode and keeps the focus while it is open.
19
+ useFocusTrap(layerRef, open && !isPickerOpen);
20
+ const title = props.title ?? moduleMessages.pageTitle;
21
+ return (_jsxs(_Fragment, { children: [props.hideLauncher ? null : (_jsx(Launcher, { label: props.launcherLabel ?? title, open: open, controls: layerId, onClick: toggle, launcherRef: launcherRef })), _jsx("section", { ref: layerRef, id: layerId, className: moduleClass('page', props.className), dir: moduleMessages.dir, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, hidden: !open, children: _jsx("div", { className: "aic-page-column", children: _jsx(ChatFrame, { module: props, chat: chat, title: title, titleId: titleId, fieldRef: fieldRef, onClose: close }) }) })] }));
22
+ }
23
+ //# sourceMappingURL=AiChatPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiChatPage.js","sourceRoot":"","sources":["../../src/modules/AiChatPage.tsx"],"names":[],"mappings":";AAAA,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAI1E,MAAM,UAAU,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAmB;IAC3D,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3G,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,oFAAoF;IACpF,YAAY,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,SAAS,CAAC;IACtD,OAAO,CACL,8BACG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC3B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC3F,WAAW,EAAE,WAAW,GAAI,CAC/B,EACD,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,EAClF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,gBAAY,MAAM,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAC/F,MAAM,EAAE,CAAC,IAAI,YACb,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GAChB,GACE,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A full page AI mode: the chat takes the whole window over the site, in one centred column, with\n// the page's scroll held and the focus kept inside until the visitor closes it. It opens from its\n// own button, placed where the site renders the module, or from the site's own through `open`.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useFocusTrap, useOverlay, useScrollLock } from './useOverlay.ts';\n\nexport interface AiChatPageProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPage({ ref, ...props }: AiChatPageProps) {\n const { moduleMessages, isPickerOpen } = useAiConnect();\n const chat = useModuleChat(props);\n const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);\n useModuleHandle(ref, chat.ask, show);\n useScrollLock(open);\n // The connect window opens over the page mode and keeps the focus while it is open.\n useFocusTrap(layerRef, open && !isPickerOpen);\n const title = props.title ?? moduleMessages.pageTitle;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('page', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-modal=\"true\" aria-labelledby={titleId} tabIndex={-1}\n hidden={!open}>\n <div className=\"aic-page-column\">\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </div>\n </section>\n </>\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { AiModuleProps, AiOverlayProps } from './types.ts';
2
+ export interface AiChatPanelProps extends AiModuleProps, AiOverlayProps {
3
+ }
4
+ export declare function AiChatPanel({ ref, ...props }: AiChatPanelProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A chat docked in a side panel at the page's edge. It opens from its own button, placed where the
3
+ // site renders the module, or from the site's own button through `open`. The page stays usable
4
+ // beside it, and the conversation stays while the panel is closed. The panel docks on the right in
5
+ // left to right languages and on the left in right to left ones, and takes the whole screen on a
6
+ // phone.
7
+ import { useAiConnect } from "../AiConnectProvider.js";
8
+ import { Launcher } from "./Launcher.js";
9
+ import { ChatFrame } from "./parts/ChatFrame.js";
10
+ import { moduleClass } from "./parts/moduleClass.js";
11
+ import { useModuleChat } from "./parts/useModuleChat.js";
12
+ import { useModuleHandle } from "./parts/useModuleHandle.js";
13
+ import { useOverlay } from "./useOverlay.js";
14
+ export function AiChatPanel({ ref, ...props }) {
15
+ const { moduleMessages } = useAiConnect();
16
+ const chat = useModuleChat(props);
17
+ const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);
18
+ useModuleHandle(ref, chat.ask, show);
19
+ const title = props.title ?? moduleMessages.title;
20
+ return (_jsxs(_Fragment, { children: [props.hideLauncher ? null : (_jsx(Launcher, { label: props.launcherLabel ?? title, open: open, controls: layerId, onClick: toggle, launcherRef: launcherRef })), _jsx("section", { ref: layerRef, id: layerId, className: moduleClass('panel', props.className), dir: moduleMessages.dir, role: "dialog", "aria-labelledby": titleId, tabIndex: -1, hidden: !open, children: _jsx(ChatFrame, { module: props, chat: chat, title: title, titleId: titleId, fieldRef: fieldRef, onClose: close }) })] }));
21
+ }
22
+ //# sourceMappingURL=AiChatPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiChatPanel.js","sourceRoot":"","sources":["../../src/modules/AiChatPanel.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,+FAA+F;AAC/F,mGAAmG;AACnG,iGAAiG;AACjG,SAAS;AAET,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAoB;IAC7D,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3G,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;IAClD,OAAO,CACL,8BACG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC3B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC3F,WAAW,EAAE,WAAW,GAAI,CAC/B,EACD,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EACnF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAC5F,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GACZ,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A chat docked in a side panel at the page's edge. It opens from its own button, placed where the\n// site renders the module, or from the site's own button through `open`. The page stays usable\n// beside it, and the conversation stays while the panel is closed. The panel docks on the right in\n// left to right languages and on the left in right to left ones, and takes the whole screen on a\n// phone.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPanelProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPanel({ ref, ...props }: AiChatPanelProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);\n useModuleHandle(ref, chat.ask, show);\n const title = props.title ?? moduleMessages.title;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('panel', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-labelledby={titleId} tabIndex={-1} hidden={!open}>\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </section>\n </>\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { AiModuleProps, AiOverlayProps } from './types.ts';
2
+ export interface AiChatPopupProps extends AiModuleProps, AiOverlayProps {
3
+ }
4
+ export declare function AiChatPopup({ ref, ...props }: AiChatPopupProps): import("react").JSX.Element;