@epam/ai-dial-chat-hooks 1.1.0-dev.422 → 1.1.0-dev.426

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 (178) hide show
  1. package/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
  2. package/api-transport/create-csrf-middleware.js +21 -0
  3. package/api-transport/create-unauthorized-middleware.js +41 -0
  4. package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
  5. package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
  6. package/attachments.js +3 -2
  7. package/catalog/catalog-derivations.js +10 -0
  8. package/catalog/catalog-primary-action.js +21 -0
  9. package/catalog/create-publish-api.js +27 -0
  10. package/catalog/deployment-endpoint-url.js +34 -0
  11. package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
  12. package/catalog/entity-details.js +6 -0
  13. package/catalog/map-deployment-limits-to-catalog.js +73 -0
  14. package/catalog/map-deployment-limits-to-input.js +14 -0
  15. package/catalog/map-deployment-to-catalog-item.js +92 -0
  16. package/catalog/map-entity-details-to-catalog.js +350 -0
  17. package/catalog/map-prompt-to-catalog-item.js +49 -0
  18. package/catalog/map-skill-to-catalog-item.js +123 -0
  19. package/catalog/mcp-endpoint-url.js +26 -0
  20. package/catalog/publish.js +18 -0
  21. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
  22. package/catalog/useCatalogItemDetails.js +101 -0
  23. package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
  24. package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
  25. package/catalog/usePublishFolders/usePublishFolders.js +72 -0
  26. package/catalog.js +22 -3
  27. package/conversation/announcement-message.js +42 -0
  28. package/conversation/conversation-transfer/async.js +18 -0
  29. package/conversation/conversation-transfer/attachment-refs.js +11 -0
  30. package/conversation/conversation-transfer/build-upload-path.js +27 -0
  31. package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
  32. package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
  33. package/conversation/conversation-transfer/export-conversation.js +32 -0
  34. package/conversation/conversation-transfer/import-conversation.js +93 -0
  35. package/conversation/conversation-transfer/progress.js +39 -0
  36. package/conversation/conversation-transfer/queue.js +84 -0
  37. package/conversation/conversation-transfer/types.js +9 -0
  38. package/conversation/conversation-transfer/zip-export.js +19 -0
  39. package/conversation/conversation-transfer/zip-import.js +29 -0
  40. package/conversation/create-chat-stream-api.js +96 -0
  41. package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
  42. package/conversation/display-name-watch.js +5 -0
  43. package/conversation/footer-message.js +23 -0
  44. package/conversation/get-model-id-from-conversation-id.js +14 -0
  45. package/conversation/greeting.js +7 -0
  46. package/conversation/message-factory.js +19 -0
  47. package/conversation/message-utils.js +13 -0
  48. package/conversation/overlay-messages.js +8 -0
  49. package/conversation/quick-app-conversation-starters.js +29 -0
  50. package/conversation/starter-option.js +27 -0
  51. package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
  52. package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
  53. package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
  54. package/conversation/useConversationExport/useConversationExport.js +285 -0
  55. package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
  56. package/conversation/useConversationHandlers/message-factory.js +21 -0
  57. package/conversation/useConversationHandlers/message-utils.js +8 -0
  58. package/conversation/useConversationHandlers/starter-option.js +11 -0
  59. package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
  60. package/conversation/useConversationImport/useConversationImport.js +239 -0
  61. package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
  62. package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
  63. package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
  64. package/conversation/useConversationStream/apply-chunk.js +78 -0
  65. package/conversation/useConversationStream/buffered-generation.js +18 -0
  66. package/conversation/useConversationStream/conversation-path.js +8 -0
  67. package/conversation/useConversationStream/generation-resume.js +126 -0
  68. package/conversation/useConversationStream/useConversationStream.js +148 -0
  69. package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
  70. package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
  71. package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
  72. package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
  73. package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
  74. package/conversation-sources.js +1 -1
  75. package/conversation-transfer.js +7 -3
  76. package/conversation.d.ts +66 -0
  77. package/conversation.js +31 -2
  78. package/file-manager.d.ts +3 -4
  79. package/file-manager.js +28 -3
  80. package/files/annotation.js +15 -0
  81. package/files/attachment-canvas.js +218 -0
  82. package/files/attachment-dto-to-display.js +15 -0
  83. package/files/attachment-types.js +16 -0
  84. package/files/create-files-api.js +40 -0
  85. package/files/create-upload-file-with-progress.js +42 -0
  86. package/files/dial-file-manager-copy-move.util.js +55 -0
  87. package/files/dial-file-manager-mapping.util.js +140 -0
  88. package/files/dial-file-manager-path.util.js +72 -0
  89. package/files/dial-file-manager.model.js +25 -0
  90. package/files/dial-file-manager.types.js +10 -0
  91. package/files/dial-file-to-attachment.js +37 -0
  92. package/files/dial-file.js +30 -0
  93. package/files/dial-files-api.js +6 -0
  94. package/files/download-destination.js +6 -0
  95. package/files/file-manager-variant.js +11 -0
  96. package/files/file-name.js +19 -0
  97. package/files/prepare-download-destination.js +24 -0
  98. package/files/resolve-dial-file-api-path.js +33 -0
  99. package/files/source-content.js +37 -0
  100. package/files/useDialFileListing/useDialFileListing.js +295 -0
  101. package/files/useDialFileManager/useDialFileManager.js +146 -0
  102. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
  103. package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
  104. package/files/useDialFileMutations/useDialFileMutations.js +359 -0
  105. package/files/useDialFileSharing/useDialFileSharing.js +70 -0
  106. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
  107. package/index.d.ts +69 -4
  108. package/index.js +134 -28
  109. package/mcp-apps/mcp-apps-api-client.js +48 -0
  110. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
  111. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
  112. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
  113. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
  114. package/mcp-apps.js +6 -2
  115. package/oauth/authorize-url.js +12 -0
  116. package/oauth/handshake.js +65 -0
  117. package/oauth/popup.js +29 -0
  118. package/oauth/toolset-id.js +10 -0
  119. package/oauth/types.js +24 -0
  120. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
  121. package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
  122. package/oauth.js +9 -3
  123. package/package.json +35 -23
  124. package/prompt/export-prompt.js +28 -0
  125. package/prompt/prompt-resource.js +15 -0
  126. package/prompt/prompt.js +12 -0
  127. package/prompt/usePromptsState/usePromptsState.js +42 -0
  128. package/scheduled-task/scheduled-task-mapping.js +6 -0
  129. package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
  130. package/scheduled-tasks.js +3 -2
  131. package/scroll-anchoring.js +1 -1
  132. package/shared/application-schema.js +4 -0
  133. package/shared/browser-timezone.js +10 -0
  134. package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
  135. package/shared/custom-apps.js +30 -0
  136. package/shared/external-services.js +18 -0
  137. package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
  138. package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
  139. package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
  140. package/shared/toolset-login-events.js +13 -0
  141. package/sharing.js +3 -3
  142. package/skill/skill-file-batch-validation.js +48 -0
  143. package/skill/skill-file-preview.js +15 -0
  144. package/skill/skill-manifest.js +70 -0
  145. package/skill/skill-types.js +15 -0
  146. package/skill/skill.js +48 -0
  147. package/skill/useSkillEditorLoad.js +103 -0
  148. package/skill/useSkillEditorSubmit.js +135 -0
  149. package/skill/useSkillFileActions.js +99 -0
  150. package/skill/useSkillFilePreview.js +29 -0
  151. package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
  152. package/skill-editor.js +8 -3
  153. package/skills-state.js +1 -1
  154. package/source-content.d.ts +29 -0
  155. package/source-content.js +2 -0
  156. package/usage/useUsageData/useUsageData.js +32 -0
  157. package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
  158. package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
  159. package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
  160. package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
  161. package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
  162. package/useToolsMenu/useToolsMenu.js +50 -0
  163. package/useViewportWidth/useViewportWidth.js +12 -0
  164. package/utils.js +17 -7
  165. package/viewport-layout.js +4 -2
  166. package/attachment-types-AAoN9E95.js +0 -7760
  167. package/browser-Btsa0Lmr.js +0 -607
  168. package/skill-manifest-CeG6-WSK.js +0 -4056
  169. package/useAttachmentValidation-CkMTd5lA.js +0 -102
  170. package/useConversationImport-CDRs7JF1.js +0 -826
  171. package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
  172. package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
  173. package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
  174. package/useSkillFileActions-B-VaGD20.js +0 -373
  175. package/useSkillFilePreview-B5o1n_0F.js +0 -1244
  176. package/useToolsMenu-zURpMEn1.js +0 -1882
  177. package/useToolsetLogin-B05m134e.js +0 -195
  178. package/useUsageData-D7BxloKZ.js +0 -201
@@ -1,1882 +0,0 @@
1
- import { n as e, r as t } from "./string-utils-iBi2Y55C.js";
2
- import { n } from "./deployment-id-CxWgJTs9.js";
3
- import { t as r } from "./useShareRecipientsCount-BgwCLKY0.js";
4
- import { AttachmentErrorReason as i, FilterTab as a, MessageRole as o, ResponseFormat as s, StatusEvent as c, generateUUID as l, isStatusMessage as u } from "@epam/ai-dial-chat-shared";
5
- import { normalizeRawAnnotations as d } from "@epam/ai-dial-quotations";
6
- import { useCallback as f, useEffect as p, useLayoutEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
7
- import { SendCompletionDtoModeEnum as v } from "@epam/ai-dial-chat-api-client";
8
- //#region ../../node_modules/dompurify/dist/purify.es.mjs
9
- function y(e, t) {
10
- (t == null || t > e.length) && (t = e.length);
11
- for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
12
- return r;
13
- }
14
- function b(e) {
15
- if (Array.isArray(e)) return e;
16
- }
17
- function x(e, t) {
18
- var n = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
19
- if (n != null) {
20
- var r, i, a, o, s = [], c = !0, l = !1;
21
- try {
22
- if (a = (n = n.call(e)).next, t !== 0) for (; !(c = (r = a.call(n)).done) && (s.push(r.value), s.length !== t); c = !0);
23
- } catch (e) {
24
- l = !0, i = e;
25
- } finally {
26
- try {
27
- if (!c && n.return != null && (o = n.return(), Object(o) !== o)) return;
28
- } finally {
29
- if (l) throw i;
30
- }
31
- }
32
- return s;
33
- }
34
- }
35
- function S() {
36
- throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
37
- }
38
- function C(e, t) {
39
- return b(e) || x(e, t) || w(e, t) || S();
40
- }
41
- function w(e, t) {
42
- if (e) {
43
- if (typeof e == "string") return y(e, t);
44
- var n = {}.toString.call(e).slice(8, -1);
45
- return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? y(e, t) : void 0;
46
- }
47
- }
48
- var ee = Object.entries, T = Object.setPrototypeOf, E = Object.isFrozen, D = Object.getPrototypeOf, O = Object.getOwnPropertyDescriptor, k = Object.freeze, A = Object.seal, te = Object.create, ne = typeof Reflect < "u" && Reflect, re = ne.apply, j = ne.construct;
49
- k ||= function(e) {
50
- return e;
51
- }, A ||= function(e) {
52
- return e;
53
- }, re ||= function(e, t) {
54
- var n = [...arguments].slice(2);
55
- return e.apply(t, n);
56
- }, j ||= function(e) {
57
- return new e(...[...arguments].slice(1));
58
- };
59
- var ie = F(Array.prototype.forEach), ae = F(Array.prototype.lastIndexOf), oe = F(Array.prototype.pop), se = F(Array.prototype.push), ce = F(Array.prototype.splice), M = Array.isArray, le = F(String.prototype.toLowerCase), ue = F(String.prototype.toString), de = F(String.prototype.match), fe = F(String.prototype.replace), pe = F(String.prototype.indexOf), me = F(String.prototype.trim), he = F(Number.prototype.toString), ge = F(Boolean.prototype.toString), _e = typeof BigInt > "u" ? null : F(BigInt.prototype.toString), ve = typeof Symbol > "u" ? null : F(Symbol.prototype.toString), N = F(Object.prototype.hasOwnProperty), ye = F(Object.prototype.toString), P = F(RegExp.prototype.test), be = xe(TypeError);
60
- function F(e) {
61
- return function(t) {
62
- t instanceof RegExp && (t.lastIndex = 0);
63
- var n = [...arguments].slice(1);
64
- return re(e, t, n);
65
- };
66
- }
67
- function xe(e) {
68
- return function() {
69
- return j(e, [...arguments]);
70
- };
71
- }
72
- function I(e, t) {
73
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : le;
74
- if (T && T(e, null), !M(t)) return e;
75
- let r = t.length;
76
- for (; r--;) {
77
- let i = t[r];
78
- if (typeof i == "string") {
79
- let e = n(i);
80
- e !== i && (E(t) || (t[r] = e), i = e);
81
- }
82
- e[i] = !0;
83
- }
84
- return e;
85
- }
86
- function Se(e) {
87
- for (let t = 0; t < e.length; t++) N(e, t) || (e[t] = null);
88
- return e;
89
- }
90
- function L(e) {
91
- let t = te(null);
92
- for (let r of ee(e)) {
93
- var n = C(r, 2);
94
- let i = n[0], a = n[1];
95
- N(e, i) && (M(a) ? t[i] = Se(a) : a && typeof a == "object" && a.constructor === Object ? t[i] = L(a) : t[i] = a);
96
- }
97
- return t;
98
- }
99
- function Ce(e) {
100
- switch (typeof e) {
101
- case "string": return e;
102
- case "number": return he(e);
103
- case "boolean": return ge(e);
104
- case "bigint": return _e ? _e(e) : "0";
105
- case "symbol": return ve ? ve(e) : "Symbol()";
106
- case "undefined": return ye(e);
107
- case "function":
108
- case "object": {
109
- if (e === null) return ye(e);
110
- let t = e, n = R(t, "toString");
111
- if (typeof n == "function") {
112
- let e = n(t);
113
- return typeof e == "string" ? e : ye(e);
114
- }
115
- return ye(e);
116
- }
117
- default: return ye(e);
118
- }
119
- }
120
- function R(e, t) {
121
- for (; e !== null;) {
122
- let n = O(e, t);
123
- if (n) {
124
- if (n.get) return F(n.get);
125
- if (typeof n.value == "function") return F(n.value);
126
- }
127
- e = D(e);
128
- }
129
- function n() {
130
- return null;
131
- }
132
- return n;
133
- }
134
- function we(e) {
135
- try {
136
- return P(e, ""), !0;
137
- } catch {
138
- return !1;
139
- }
140
- }
141
- var Te = k(/* @__PURE__ */ "a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr".split(".")), Ee = k(/* @__PURE__ */ "svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern".split(".")), De = k([
142
- "feBlend",
143
- "feColorMatrix",
144
- "feComponentTransfer",
145
- "feComposite",
146
- "feConvolveMatrix",
147
- "feDiffuseLighting",
148
- "feDisplacementMap",
149
- "feDistantLight",
150
- "feDropShadow",
151
- "feFlood",
152
- "feFuncA",
153
- "feFuncB",
154
- "feFuncG",
155
- "feFuncR",
156
- "feGaussianBlur",
157
- "feImage",
158
- "feMerge",
159
- "feMergeNode",
160
- "feMorphology",
161
- "feOffset",
162
- "fePointLight",
163
- "feSpecularLighting",
164
- "feSpotLight",
165
- "feTile",
166
- "feTurbulence"
167
- ]), Oe = k([
168
- "animate",
169
- "color-profile",
170
- "cursor",
171
- "discard",
172
- "font-face",
173
- "font-face-format",
174
- "font-face-name",
175
- "font-face-src",
176
- "font-face-uri",
177
- "foreignobject",
178
- "hatch",
179
- "hatchpath",
180
- "mesh",
181
- "meshgradient",
182
- "meshpatch",
183
- "meshrow",
184
- "missing-glyph",
185
- "script",
186
- "set",
187
- "solidcolor",
188
- "unknown",
189
- "use"
190
- ]), ke = k(/* @__PURE__ */ "math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts".split(".")), Ae = k([
191
- "maction",
192
- "maligngroup",
193
- "malignmark",
194
- "mlongdiv",
195
- "mscarries",
196
- "mscarry",
197
- "msgroup",
198
- "mstack",
199
- "msline",
200
- "msrow",
201
- "semantics",
202
- "annotation",
203
- "annotation-xml",
204
- "mprescripts",
205
- "none"
206
- ]), je = k(["#text"]), Me = k(/* @__PURE__ */ "accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns".split(".")), Ne = k(/* @__PURE__ */ "accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan".split(".")), Pe = k(/* @__PURE__ */ "accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns".split(".")), Fe = k([
207
- "xlink:href",
208
- "xml:id",
209
- "xlink:title",
210
- "xml:space",
211
- "xmlns:xlink"
212
- ]), Ie = A(/{{[\w\W]*|^[\w\W]*}}/g), Le = A(/<%[\w\W]*|^[\w\W]*%>/g), Re = A(/\${[\w\W]*/g), ze = A(/^data-[\-\w.\u00B7-\uFFFF]+$/), Be = A(/^aria-[\-\w]+$/), Ve = A(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), He = A(/^(?:\w+script|data):/i), Ue = A(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), We = A(/^html$/i), Ge = A(/^[a-z][.\w]*(-[.\w]+)+$/i), Ke = A(/<[/\w!]/g), qe = A(/<[/\w]/g), Je = A(/<\/no(script|embed|frames)/i), Ye = A(/\/>/i), z = {
213
- element: 1,
214
- attribute: 2,
215
- text: 3,
216
- cdataSection: 4,
217
- entityReference: 5,
218
- entityNode: 6,
219
- processingInstruction: 7,
220
- comment: 8,
221
- document: 9,
222
- documentType: 10,
223
- documentFragment: 11,
224
- notation: 12
225
- }, Xe = function() {
226
- return typeof window > "u" ? null : window;
227
- }, Ze = function(e, t) {
228
- if (typeof e != "object" || typeof e.createPolicy != "function") return null;
229
- let n = null, r = "data-tt-policy-suffix";
230
- t && t.hasAttribute(r) && (n = t.getAttribute(r));
231
- let i = "dompurify" + (n ? "#" + n : "");
232
- try {
233
- return e.createPolicy(i, {
234
- createHTML(e) {
235
- return e;
236
- },
237
- createScriptURL(e) {
238
- return e;
239
- }
240
- });
241
- } catch {
242
- return console.warn("TrustedTypes policy " + i + " could not be created."), null;
243
- }
244
- }, Qe = function() {
245
- return {
246
- afterSanitizeAttributes: [],
247
- afterSanitizeElements: [],
248
- afterSanitizeShadowDOM: [],
249
- beforeSanitizeAttributes: [],
250
- beforeSanitizeElements: [],
251
- beforeSanitizeShadowDOM: [],
252
- uponSanitizeAttribute: [],
253
- uponSanitizeElement: [],
254
- uponSanitizeShadowNode: []
255
- };
256
- }, B = function(e, t, n, r) {
257
- return N(e, t) && M(e[t]) ? I(r.base ? L(r.base) : {}, e[t], r.transform) : n;
258
- };
259
- function $e() {
260
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Xe(), t = (e) => $e(e);
261
- if (t.version = "3.4.13", t.removed = [], !e || !e.document || e.document.nodeType !== z.document || !e.Element) return t.isSupported = !1, t;
262
- let n = e.document, r = n, i = r.currentScript;
263
- e.DocumentFragment;
264
- let a = e.HTMLTemplateElement, o = e.Node, s = e.Element, c = e.NodeFilter;
265
- e.NamedNodeMap === void 0 && (e.NamedNodeMap || e.MozNamedAttrMap), e.HTMLFormElement;
266
- let l = e.DOMParser, u = e.trustedTypes, d = s.prototype, f = R(d, "cloneNode"), p = R(d, "remove"), m = R(d, "nextSibling"), h = R(d, "childNodes"), g = R(d, "parentNode"), _ = R(d, "shadowRoot"), v = R(d, "attributes"), y = o && o.prototype ? R(o.prototype, "nodeType") : null, b = o && o.prototype ? R(o.prototype, "nodeName") : null, x = o && o.prototype ? R(o.prototype, "ownerDocument") : null;
267
- if (typeof a == "function") {
268
- let e = n.createElement("template");
269
- e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
270
- }
271
- let S, C = "", w, T = !1, E = 0, D = function() {
272
- if (E > 0) throw be("A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
273
- }, O = function(e) {
274
- D(), E++;
275
- try {
276
- return S.createHTML(e);
277
- } finally {
278
- E--;
279
- }
280
- }, ne = function(e) {
281
- D(), E++;
282
- try {
283
- return S.createScriptURL(e);
284
- } finally {
285
- E--;
286
- }
287
- }, re = function() {
288
- return T ||= (w = Ze(u, i), !0), w;
289
- }, j = n, he = j.implementation, ge = j.createNodeIterator, _e = j.createDocumentFragment, ve = j.getElementsByTagName, ye = r.importNode, F = Qe();
290
- t.isSupported = typeof ee == "function" && typeof g == "function" && he && he.createHTMLDocument !== void 0;
291
- let xe = Ie, Se = Le, et = Re, tt = ze, nt = Be, rt = He, it = Ue, at = Ge, ot = Ve, V = null, st = I({}, [
292
- ...Te,
293
- ...Ee,
294
- ...De,
295
- ...ke,
296
- ...je
297
- ]), H = null, ct = I({}, [
298
- ...Me,
299
- ...Ne,
300
- ...Pe,
301
- ...Fe
302
- ]), U = Object.seal(te(null, {
303
- tagNameCheck: {
304
- writable: !0,
305
- configurable: !1,
306
- enumerable: !0,
307
- value: null
308
- },
309
- attributeNameCheck: {
310
- writable: !0,
311
- configurable: !1,
312
- enumerable: !0,
313
- value: null
314
- },
315
- allowCustomizedBuiltInElements: {
316
- writable: !0,
317
- configurable: !1,
318
- enumerable: !0,
319
- value: !1
320
- }
321
- })), lt = null, ut = null, W = Object.seal(te(null, {
322
- tagCheck: {
323
- writable: !0,
324
- configurable: !1,
325
- enumerable: !0,
326
- value: null
327
- },
328
- attributeCheck: {
329
- writable: !0,
330
- configurable: !1,
331
- enumerable: !0,
332
- value: null
333
- }
334
- })), dt = !0, ft = !0, pt = !1, mt = !0, G = !1, K = !0, q = !1, ht = !1, gt = null, _t = null, vt = !1, yt = !1, bt = !1, xt = !1, St = !0, Ct = !1, wt = "user-content-", Tt = !0, Et = !1, Dt = {}, J = null, Ot = I({}, /* @__PURE__ */ "annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp".split(".")), kt = null, At = I({}, [
335
- "audio",
336
- "video",
337
- "img",
338
- "source",
339
- "image",
340
- "track"
341
- ]), jt = null, Mt = I({}, [
342
- "alt",
343
- "class",
344
- "for",
345
- "id",
346
- "label",
347
- "name",
348
- "pattern",
349
- "placeholder",
350
- "role",
351
- "summary",
352
- "title",
353
- "value",
354
- "style",
355
- "xmlns"
356
- ]), Nt = "http://www.w3.org/1998/Math/MathML", Pt = "http://www.w3.org/2000/svg", Y = "http://www.w3.org/1999/xhtml", Ft = Y, It = !1, Lt = null, Rt = I({}, [
357
- Nt,
358
- Pt,
359
- Y
360
- ], ue), zt = k([
361
- "mi",
362
- "mo",
363
- "mn",
364
- "ms",
365
- "mtext"
366
- ]), Bt = I({}, zt), Vt = k(["annotation-xml"]), Ht = I({}, Vt), Ut = I({}, [
367
- "title",
368
- "style",
369
- "font",
370
- "a",
371
- "script"
372
- ]), Wt = null, Gt = ["application/xhtml+xml", "text/html"], X = null, Kt = null, qt = n.createElement("form"), Jt = function(e) {
373
- return e instanceof RegExp || e instanceof Function;
374
- }, Yt = function() {
375
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
376
- if (Kt && Kt === e) return;
377
- (!e || typeof e != "object") && (e = {}), e = L(e), Wt = Gt.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, X = Wt === "application/xhtml+xml" ? ue : le, V = B(e, "ALLOWED_TAGS", st, { transform: X }), H = B(e, "ALLOWED_ATTR", ct, { transform: X }), Lt = B(e, "ALLOWED_NAMESPACES", Rt, { transform: ue }), jt = B(e, "ADD_URI_SAFE_ATTR", Mt, {
378
- transform: X,
379
- base: Mt
380
- }), kt = B(e, "ADD_DATA_URI_TAGS", At, {
381
- transform: X,
382
- base: At
383
- }), J = B(e, "FORBID_CONTENTS", Ot, { transform: X }), lt = B(e, "FORBID_TAGS", L({}), { transform: X }), ut = B(e, "FORBID_ATTR", L({}), { transform: X }), Dt = N(e, "USE_PROFILES") ? e.USE_PROFILES && typeof e.USE_PROFILES == "object" ? L(e.USE_PROFILES) : e.USE_PROFILES : !1, dt = e.ALLOW_ARIA_ATTR !== !1, ft = e.ALLOW_DATA_ATTR !== !1, pt = e.ALLOW_UNKNOWN_PROTOCOLS || !1, mt = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, G = e.SAFE_FOR_TEMPLATES || !1, K = e.SAFE_FOR_XML !== !1, q = e.WHOLE_DOCUMENT || !1, yt = e.RETURN_DOM || !1, bt = e.RETURN_DOM_FRAGMENT || !1, xt = e.RETURN_TRUSTED_TYPE || !1, vt = e.FORCE_BODY || !1, St = e.SANITIZE_DOM !== !1, Ct = e.SANITIZE_NAMED_PROPS || !1, Tt = e.KEEP_CONTENT !== !1, Et = e.IN_PLACE || !1, ot = we(e.ALLOWED_URI_REGEXP) ? e.ALLOWED_URI_REGEXP : Ve, Ft = typeof e.NAMESPACE == "string" ? e.NAMESPACE : Y, Bt = N(e, "MATHML_TEXT_INTEGRATION_POINTS") && e.MATHML_TEXT_INTEGRATION_POINTS && typeof e.MATHML_TEXT_INTEGRATION_POINTS == "object" ? L(e.MATHML_TEXT_INTEGRATION_POINTS) : I({}, zt), Ht = N(e, "HTML_INTEGRATION_POINTS") && e.HTML_INTEGRATION_POINTS && typeof e.HTML_INTEGRATION_POINTS == "object" ? L(e.HTML_INTEGRATION_POINTS) : I({}, Vt);
384
- let t = N(e, "CUSTOM_ELEMENT_HANDLING") && e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING == "object" ? L(e.CUSTOM_ELEMENT_HANDLING) : te(null);
385
- if (U = te(null), N(t, "tagNameCheck") && Jt(t.tagNameCheck) && (U.tagNameCheck = t.tagNameCheck), N(t, "attributeNameCheck") && Jt(t.attributeNameCheck) && (U.attributeNameCheck = t.attributeNameCheck), N(t, "allowCustomizedBuiltInElements") && typeof t.allowCustomizedBuiltInElements == "boolean" && (U.allowCustomizedBuiltInElements = t.allowCustomizedBuiltInElements), A(U), G && (ft = !1), bt && (yt = !0), Dt && (V = I({}, je), H = te(null), Dt.html === !0 && (I(V, Te), I(H, Me)), Dt.svg === !0 && (I(V, Ee), I(H, Ne), I(H, Fe)), Dt.svgFilters === !0 && (I(V, De), I(H, Ne), I(H, Fe)), Dt.mathMl === !0 && (I(V, ke), I(H, Pe), I(H, Fe))), W.tagCheck = null, W.attributeCheck = null, N(e, "ADD_TAGS") && (typeof e.ADD_TAGS == "function" ? W.tagCheck = e.ADD_TAGS : M(e.ADD_TAGS) && (V === st && (V = L(V)), I(V, e.ADD_TAGS, X))), N(e, "ADD_ATTR") && (typeof e.ADD_ATTR == "function" ? W.attributeCheck = e.ADD_ATTR : M(e.ADD_ATTR) && (H === ct && (H = L(H)), I(H, e.ADD_ATTR, X))), N(e, "ADD_URI_SAFE_ATTR") && M(e.ADD_URI_SAFE_ATTR) && I(jt, e.ADD_URI_SAFE_ATTR, X), N(e, "FORBID_CONTENTS") && M(e.FORBID_CONTENTS) && (J === Ot && (J = L(J)), I(J, e.FORBID_CONTENTS, X)), N(e, "ADD_FORBID_CONTENTS") && M(e.ADD_FORBID_CONTENTS) && (J === Ot && (J = L(J)), I(J, e.ADD_FORBID_CONTENTS, X)), Tt && (V["#text"] = !0), q && I(V, [
386
- "html",
387
- "head",
388
- "body"
389
- ]), V.table && (I(V, ["tbody"]), delete lt.tbody), e.TRUSTED_TYPES_POLICY) {
390
- if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw be("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
391
- if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw be("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
392
- let t = S;
393
- S = e.TRUSTED_TYPES_POLICY;
394
- try {
395
- C = O("");
396
- } catch (e) {
397
- throw S = t, e;
398
- }
399
- } else e.TRUSTED_TYPES_POLICY === null ? (S = void 0, C = "") : (S === void 0 && (S = re()), S && typeof C == "string" && (C = O("")));
400
- k && k(e), Kt = e;
401
- }, Xt = I({}, [
402
- ...Ee,
403
- ...De,
404
- ...Oe
405
- ]), Zt = I({}, [...ke, ...Ae]), Qt = function(e, t, n) {
406
- return t.namespaceURI === Y ? e === "svg" : t.namespaceURI === Nt ? e === "svg" && (n === "annotation-xml" || Bt[n]) : !!Xt[e];
407
- }, $t = function(e, t, n) {
408
- return t.namespaceURI === Y ? e === "math" : t.namespaceURI === Pt ? e === "math" && Ht[n] : !!Zt[e];
409
- }, en = function(e, t, n) {
410
- return t.namespaceURI === Pt && !Ht[n] || t.namespaceURI === Nt && !Bt[n] ? !1 : !Zt[e] && (Ut[e] || !Xt[e]);
411
- }, tn = function(e) {
412
- let t = g(e);
413
- (!t || !t.tagName) && (t = {
414
- namespaceURI: Ft,
415
- tagName: "template"
416
- });
417
- let n = le(e.tagName), r = le(t.tagName);
418
- return Lt[e.namespaceURI] ? e.namespaceURI === Pt ? Qt(n, t, r) : e.namespaceURI === Nt ? $t(n, t, r) : e.namespaceURI === Y ? en(n, t, r) : !!(Wt === "application/xhtml+xml" && Lt[e.namespaceURI]) : !1;
419
- }, Z = function(e) {
420
- se(t.removed, { element: e });
421
- try {
422
- g(e).removeChild(e);
423
- } catch {
424
- if (p(e), !g(e)) throw be("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
425
- }
426
- }, nn = function(e) {
427
- an(e);
428
- let t = h(e);
429
- if (t) {
430
- let e = [];
431
- ie(t, (t) => {
432
- se(e, t);
433
- }), ie(e, (e) => {
434
- try {
435
- p(e);
436
- } catch {}
437
- });
438
- }
439
- let n = v(e);
440
- if (n) for (let t = n.length - 1; t >= 0; --t) {
441
- let r = n[t], i = r && r.name;
442
- if (typeof i == "string") try {
443
- e.removeAttribute(i);
444
- } catch {}
445
- }
446
- }, Q = function(e, n) {
447
- try {
448
- se(t.removed, {
449
- attribute: n.getAttributeNode(e),
450
- from: n
451
- });
452
- } catch {
453
- se(t.removed, {
454
- attribute: null,
455
- from: n
456
- });
457
- }
458
- if (n.removeAttribute(e), e === "is") if (yt || bt) try {
459
- Z(n);
460
- } catch {}
461
- else try {
462
- n.setAttribute(e, "");
463
- } catch {}
464
- }, rn = function(e) {
465
- let t = v(e);
466
- if (t) for (let n = t.length - 1; n >= 0; --n) {
467
- let r = t[n], i = r && r.name;
468
- if (!(typeof i != "string" || H[X(i)])) try {
469
- e.removeAttribute(i);
470
- } catch {}
471
- }
472
- }, an = function(e) {
473
- let t = [e];
474
- for (; t.length > 0;) {
475
- let e = t.pop();
476
- (y ? y(e) : e.nodeType) === z.element && rn(e);
477
- let n = h(e);
478
- if (n) for (let e = n.length - 1; e >= 0; --e) t.push(n[e]);
479
- }
480
- }, on = function(e) {
481
- if (!K) return;
482
- let t = [e];
483
- for (; t.length > 0;) {
484
- let e = t.pop(), n = y ? y(e) : e.nodeType;
485
- if (n === z.processingInstruction || n === z.comment && P(qe, e.data)) {
486
- try {
487
- p(e);
488
- } catch {}
489
- continue;
490
- }
491
- if (n === z.element) {
492
- let t = e, n = X(b ? b(e) : e.nodeName);
493
- try {
494
- t.hasAttribute && t.hasAttribute("patchsrc") && t.removeAttribute("patchsrc"), t.hasAttribute && t.hasAttribute("for") && n !== "label" && n !== "output" && t.removeAttribute("for");
495
- } catch {}
496
- }
497
- let r = h(e);
498
- if (r) for (let e = r.length - 1; e >= 0; --e) t.push(r[e]);
499
- }
500
- }, sn = function(e) {
501
- let t = null, r = null;
502
- if (vt) e = "<remove></remove>" + e;
503
- else {
504
- let t = de(e, /^[\r\n\t ]+/);
505
- r = t && t[0];
506
- }
507
- Wt === "application/xhtml+xml" && Ft === Y && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
508
- let i = S ? O(e) : e;
509
- if (Ft === Y) try {
510
- t = new l().parseFromString(i, Wt);
511
- } catch {}
512
- if (!t || !t.documentElement) {
513
- t = he.createDocument(Ft, "template", null);
514
- try {
515
- t.documentElement.innerHTML = It ? C : i;
516
- } catch {}
517
- }
518
- let a = t.body || t.documentElement;
519
- return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), Ft === Y ? ve.call(t, q ? "html" : "body")[0] : q ? t.documentElement : a;
520
- }, cn = function(e) {
521
- let t = x ? x(e) : e.ownerDocument;
522
- return ge.call(t || e, e, c.SHOW_ELEMENT | c.SHOW_COMMENT | c.SHOW_TEXT | c.SHOW_PROCESSING_INSTRUCTION | c.SHOW_CDATA_SECTION, null);
523
- }, ln = function(e) {
524
- return e = fe(e, xe, " "), e = fe(e, Se, " "), e = fe(e, et, " "), e;
525
- }, un = function(e) {
526
- e.normalize();
527
- let t = x ? x(e) : e.ownerDocument, n = ge.call(t || e, e, c.SHOW_TEXT | c.SHOW_COMMENT | c.SHOW_CDATA_SECTION | c.SHOW_PROCESSING_INSTRUCTION, null), r = n.nextNode();
528
- for (; r;) r.data = ln(r.data), r = n.nextNode();
529
- let i = e.querySelectorAll?.call(e, "template");
530
- i && ie(i, (e) => {
531
- fn(e.content) && un(e.content);
532
- });
533
- }, dn = function(e) {
534
- let t = b ? b(e) : null;
535
- return typeof t != "string" || X(t) !== "form" ? !1 : typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || e.attributes !== v(e) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function" || e.nodeType !== y(e) || e.childNodes !== h(e);
536
- }, fn = function(e) {
537
- if (!y || typeof e != "object" || !e) return !1;
538
- try {
539
- return y(e) === z.documentFragment;
540
- } catch {
541
- return !1;
542
- }
543
- }, pn = function(e) {
544
- if (!y || typeof e != "object" || !e) return !1;
545
- try {
546
- return typeof y(e) == "number";
547
- } catch {
548
- return !1;
549
- }
550
- };
551
- function $(e, n, r) {
552
- e.length !== 0 && ie(e, (e) => {
553
- e.call(t, n, r, Kt);
554
- });
555
- }
556
- let mn = function(e, t) {
557
- return !!(K && e.hasChildNodes() && !pn(e.firstElementChild) && P(Ke, e.textContent) && P(Ke, e.innerHTML) || K && e.namespaceURI === Y && t === "style" && pn(e.firstElementChild) || e.nodeType === z.processingInstruction || K && e.nodeType === z.comment && P(qe, e.data));
558
- }, hn = function(e, t, n) {
559
- if (!lt[t] && bn(t) && (U.tagNameCheck instanceof RegExp && P(U.tagNameCheck, t) || U.tagNameCheck instanceof Function && U.tagNameCheck(t))) return !1;
560
- if (Tt && !J[t]) {
561
- let t = g(e), r = h(e);
562
- if (r && t) {
563
- let i = r.length;
564
- for (let a = i - 1; a >= 0; --a) {
565
- let i = e === n ? f(r[a], !0) : r[a];
566
- t.insertBefore(i, m(e));
567
- }
568
- }
569
- }
570
- return Z(e), !0;
571
- }, gn = function(e, t, n, r) {
572
- return e.length === 0 ? t : t === n || t === r ? L(t) : t;
573
- }, _n = function(e, n) {
574
- if ($(F.beforeSanitizeElements, e, null), e !== n && g(e) === null) return Et && an(e), !0;
575
- if (dn(e)) return Z(e), !0;
576
- let r = X(b ? b(e) : e.nodeName);
577
- if (V = gn(F.uponSanitizeElement, V, st, gt), $(F.uponSanitizeElement, e, {
578
- tagName: r,
579
- allowedTags: V
580
- }), e !== n && g(e) === null) return Et && an(e), !0;
581
- if (mn(e, r)) return Z(e), !0;
582
- if (lt[r] || !(W.tagCheck instanceof Function && W.tagCheck(r)) && !V[r]) {
583
- let t = hn(e, r, n);
584
- return t === !1 && $(F.afterSanitizeElements, e, null), t;
585
- }
586
- if ((y ? y(e) : e.nodeType) === z.element && !tn(e) || (r === "noscript" || r === "noembed" || r === "noframes") && P(Je, e.innerHTML)) return Z(e), !0;
587
- if (G && e.nodeType === z.text) {
588
- let n = ln(e.textContent);
589
- e.textContent !== n && (se(t.removed, { element: e.cloneNode() }), e.textContent = n);
590
- }
591
- return $(F.afterSanitizeElements, e, null), !1;
592
- }, vn = function(e, t, r) {
593
- if (ut[t] || K && t === "patchsrc" || K && t === "for" && e !== "label" && e !== "output" || St && (t === "id" || t === "name") && (r in n || r in qt)) return !1;
594
- let i = H[t] || W.attributeCheck instanceof Function && W.attributeCheck(t, e);
595
- if (!(ft && P(tt, t)) && !(dt && P(nt, t))) {
596
- if (!i) {
597
- if (!(bn(e) && (U.tagNameCheck instanceof RegExp && P(U.tagNameCheck, e) || U.tagNameCheck instanceof Function && U.tagNameCheck(e)) && (U.attributeNameCheck instanceof RegExp && P(U.attributeNameCheck, t) || U.attributeNameCheck instanceof Function && U.attributeNameCheck(t, e)) || t === "is" && U.allowCustomizedBuiltInElements && (U.tagNameCheck instanceof RegExp && P(U.tagNameCheck, r) || U.tagNameCheck instanceof Function && U.tagNameCheck(r)))) return !1;
598
- } else if (!jt[t] && !P(ot, fe(r, it, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && pe(r, "data:") === 0 && kt[e]) && !(pt && !P(rt, fe(r, it, ""))) && r) return !1;
599
- }
600
- return !0;
601
- }, yn = I({}, [
602
- "annotation-xml",
603
- "color-profile",
604
- "font-face",
605
- "font-face-format",
606
- "font-face-name",
607
- "font-face-src",
608
- "font-face-uri",
609
- "missing-glyph"
610
- ]), bn = function(e) {
611
- return !yn[le(e)] && P(at, e);
612
- }, xn = function(e, t, n, r) {
613
- if (S && typeof u == "object" && typeof u.getAttributeType == "function" && !n) switch (u.getAttributeType(e, t)) {
614
- case "TrustedHTML": return O(r);
615
- case "TrustedScriptURL": return ne(r);
616
- }
617
- return r;
618
- }, Sn = function(e, n, r, i) {
619
- try {
620
- r ? e.setAttributeNS(r, n, i) : e.setAttribute(n, i), dn(e) ? Z(e) : oe(t.removed);
621
- } catch {
622
- Q(n, e);
623
- }
624
- }, Cn = function(e) {
625
- $(F.beforeSanitizeAttributes, e, null);
626
- let t = e.attributes;
627
- if (!t || dn(e)) return;
628
- H = gn(F.uponSanitizeAttribute, H, ct, _t);
629
- let n = {
630
- attrName: "",
631
- attrValue: "",
632
- keepAttr: !0,
633
- allowedAttributes: H,
634
- forceKeepAttr: void 0
635
- }, r = t.length, i = X(e.nodeName);
636
- for (; r--;) {
637
- let a = t[r], o = a.name, s = a.namespaceURI, c = a.value, l = X(o), u = c, d = o === "value" ? u : me(u);
638
- if (n.attrName = l, n.attrValue = d, n.keepAttr = !0, n.forceKeepAttr = void 0, $(F.uponSanitizeAttribute, e, n), d = n.attrValue, Ct && (l === "id" || l === "name") && pe(d, wt) !== 0 && (Q(o, e), d = wt + d), K && P(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, d)) {
639
- Q(o, e);
640
- continue;
641
- }
642
- if (l === "attributename" && de(d, "href")) {
643
- Q(o, e);
644
- continue;
645
- }
646
- if (!n.forceKeepAttr) {
647
- if (!n.keepAttr) {
648
- Q(o, e);
649
- continue;
650
- }
651
- if (!mt && P(Ye, d)) {
652
- Q(o, e);
653
- continue;
654
- }
655
- if (G && (d = ln(d)), !vn(i, l, d)) {
656
- Q(o, e);
657
- continue;
658
- }
659
- d = xn(i, l, s, d), d !== u && Sn(e, o, s, d);
660
- }
661
- }
662
- $(F.afterSanitizeAttributes, e, null);
663
- }, wn = function(e) {
664
- let t = null, n = cn(e);
665
- for ($(F.beforeSanitizeShadowDOM, e, null); t = n.nextNode();) if ($(F.uponSanitizeShadowNode, t, null), _n(t, e), Cn(t), fn(t.content) && wn(t.content), (y ? y(t) : t.nodeType) === z.element) {
666
- let e = _(t);
667
- fn(e) && (Tn(e), wn(e));
668
- }
669
- $(F.afterSanitizeShadowDOM, e, null);
670
- }, Tn = function(e) {
671
- let t = [{
672
- node: e,
673
- shadow: null
674
- }];
675
- for (; t.length > 0;) {
676
- let e = t.pop();
677
- if (e.shadow) {
678
- wn(e.shadow);
679
- continue;
680
- }
681
- let n = e.node, r = (y ? y(n) : n.nodeType) === z.element, i = h(n);
682
- if (i) for (let e = i.length - 1; e >= 0; --e) t.push({
683
- node: i[e],
684
- shadow: null
685
- });
686
- if (r) {
687
- let e = b ? b(n) : null;
688
- if (typeof e == "string" && X(e) === "template") {
689
- let e = n.content;
690
- fn(e) && t.push({
691
- node: e,
692
- shadow: null
693
- });
694
- }
695
- }
696
- if (r) {
697
- let e = _(n);
698
- fn(e) && t.push({
699
- node: null,
700
- shadow: e
701
- }, {
702
- node: e,
703
- shadow: null
704
- });
705
- }
706
- }
707
- };
708
- return t.sanitize = function(e) {
709
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = null, a = null, o = null, s = null;
710
- if (It = !e, It && (e = "<!-->"), typeof e != "string" && !pn(e) && (e = Ce(e), typeof e != "string")) throw be("dirty is not a string, aborting");
711
- if (!t.isSupported) return e;
712
- ht ? (V = gt, H = _t) : Yt(n), (F.uponSanitizeElement.length > 0 || F.uponSanitizeAttribute.length > 0) && (V = L(V)), F.uponSanitizeAttribute.length > 0 && (H = L(H)), t.removed = [];
713
- let c = Et && typeof e != "string" && pn(e);
714
- if (c) {
715
- on(e);
716
- let t = b ? b(e) : e.nodeName;
717
- if (typeof t == "string") {
718
- let n = X(t);
719
- if (!V[n] || lt[n]) throw nn(e), be("root node is forbidden and cannot be sanitized in-place");
720
- }
721
- if (dn(e)) throw nn(e), be("root node is clobbered and cannot be sanitized in-place");
722
- try {
723
- Tn(e);
724
- } catch (t) {
725
- throw nn(e), t;
726
- }
727
- } else if (pn(e)) i = sn("<!---->"), a = i.ownerDocument.importNode(e, !0), a.nodeType === z.element && a.nodeName === "BODY" || a.nodeName === "HTML" ? i = a : i.appendChild(a), Tn(a);
728
- else {
729
- if (!yt && !G && !q && e.indexOf("<") === -1) return S && xt ? O(e) : e;
730
- if (i = sn(e), !i) return yt ? null : xt ? C : "";
731
- }
732
- i && vt && Z(i.firstChild);
733
- let l = c ? e : i;
734
- try {
735
- let e = cn(l);
736
- for (; o = e.nextNode();) _n(o, l), Cn(o), fn(o.content) && wn(o.content);
737
- } catch (n) {
738
- throw c && (nn(e), ie(t.removed, (e) => {
739
- e.element && an(e.element);
740
- })), n;
741
- }
742
- if (c) return ie(t.removed, (e) => {
743
- e.element && an(e.element);
744
- }), G && un(e), e;
745
- if (yt) {
746
- if (G && un(i), bt) for (s = _e.call(i.ownerDocument); i.firstChild;) s.appendChild(i.firstChild);
747
- else s = i;
748
- return (H.shadowroot || H.shadowrootmode) && (s = ye.call(r, s, !0)), s;
749
- }
750
- let u = q ? i.outerHTML : i.innerHTML;
751
- return q && V["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && P(We, i.ownerDocument.doctype.name) && (u = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + u), G && (u = ln(u)), S && xt ? O(u) : u;
752
- }, t.setConfig = function() {
753
- Yt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), ht = !0, gt = V, _t = H;
754
- }, t.clearConfig = function() {
755
- Kt = null, ht = !1, gt = null, _t = null, S = w, C = "";
756
- }, t.isValidAttribute = function(e, t, n) {
757
- return Kt || Yt({}), vn(X(e), X(t), n);
758
- }, t.addHook = function(e, t) {
759
- typeof t == "function" && N(F, e) && se(F[e], t);
760
- }, t.removeHook = function(e, t) {
761
- if (N(F, e)) {
762
- if (t !== void 0) {
763
- let n = ae(F[e], t);
764
- return n === -1 ? void 0 : ce(F[e], n, 1)[0];
765
- }
766
- return oe(F[e]);
767
- }
768
- }, t.removeHooks = function(e) {
769
- N(F, e) && (F[e] = []);
770
- }, t.removeAllHooks = function() {
771
- F = Qe();
772
- }, t;
773
- }
774
- var et = $e(), tt = {
775
- ALLOWED_TAGS: [
776
- "a",
777
- "b",
778
- "strong",
779
- "em",
780
- "br",
781
- "span"
782
- ],
783
- ALLOWED_ATTR: [
784
- "href",
785
- "target",
786
- "rel"
787
- ]
788
- }, nt = {
789
- ALLOWED_TAGS: [
790
- "a",
791
- "b",
792
- "strong",
793
- "em",
794
- "u",
795
- "br",
796
- "span",
797
- "p"
798
- ],
799
- ALLOWED_ATTR: [
800
- "href",
801
- "target",
802
- "rel"
803
- ]
804
- };
805
- et.addHook("afterSanitizeAttributes", (e) => {
806
- e.tagName === "A" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
807
- });
808
- var rt = (e) => et.sanitize(e, tt), it = (e) => et.sanitize(e, nt), at = (e) => typeof e == "string" && e.length > 0, ot = ({ title: e, description: t }) => at(e) || at(t), V = (e) => ot(e) || at(e.html), st = (e) => ot(e) ? JSON.stringify({
809
- title: e.title ?? "",
810
- description: e.description ?? ""
811
- }) : e.html ?? "", H = { "Content-Type": "application/json" }, ct = (e, t, n) => {
812
- let r = e.trim();
813
- if (!r || r.startsWith(":") || !r.startsWith("data: ")) return;
814
- let i = r.slice(6);
815
- if (i !== "[DONE]") try {
816
- let e = JSON.parse(i);
817
- if (e.error) {
818
- n(Error(e.error.message));
819
- return;
820
- }
821
- t(e);
822
- } catch {}
823
- }, U = (e) => {
824
- let { completionsBasePath: t } = e, n = (...t) => (e.fetchImpl ?? fetch)(...t);
825
- return {
826
- streamCompletion: (r, i, a, o, s, c, l, u, d) => {
827
- let { onChunk: f, onComplete: p, onError: m, signal: h } = o;
828
- (async () => {
829
- let o;
830
- try {
831
- let f = e.getTimezone?.();
832
- o = await n(`${t}/completions`, {
833
- method: "POST",
834
- credentials: "include",
835
- signal: h,
836
- headers: {
837
- ...H,
838
- ...e.getCsrfToken() == null ? {} : { "X-CSRF-Token": e.getCsrfToken() },
839
- ...f ? { "X-Timezone": f } : {}
840
- },
841
- body: JSON.stringify({
842
- path: r,
843
- message: i ?? "",
844
- model: a,
845
- custom_content: s || {},
846
- ...c != null && { generationId: c },
847
- ...l != null && { mode: l },
848
- ...u != null && { messageIndex: u },
849
- ...d != null && { clientChannelId: d }
850
- })
851
- });
852
- } catch (e) {
853
- if (e instanceof Error && e.name === "AbortError") return;
854
- m(e instanceof Error ? e : Error(String(e)));
855
- return;
856
- }
857
- let g = o.headers.get("x-csrf-token");
858
- if (g && e.setCsrfToken(g), !o.ok) {
859
- m(/* @__PURE__ */ Error(`Stream request failed with status ${o.status}`));
860
- return;
861
- }
862
- if (!o.body) {
863
- m(/* @__PURE__ */ Error("No response body"));
864
- return;
865
- }
866
- let _ = o.body.getReader(), v = new TextDecoder(), y = "", b = !1, x = (e) => {
867
- b = !0, m(e);
868
- };
869
- try {
870
- for (;;) {
871
- let { done: e, value: t } = await _.read();
872
- if (e) {
873
- y.trim() && ct(y, f, x);
874
- break;
875
- }
876
- y += v.decode(t, { stream: !0 });
877
- let n = y.split("\n");
878
- y = n.pop() ?? "";
879
- for (let e of n) ct(e, f, x);
880
- }
881
- b || p();
882
- } catch (e) {
883
- if (e instanceof Error && e.name === "AbortError") return;
884
- m(e instanceof Error ? e : Error(String(e)));
885
- } finally {
886
- _.releaseLock();
887
- }
888
- })();
889
- },
890
- stopCompletion: async (r) => {
891
- let i = await n(`${t}/completions/stop`, {
892
- method: "POST",
893
- credentials: "include",
894
- headers: {
895
- ...H,
896
- ...e.getCsrfToken() == null ? {} : { "X-CSRF-Token": e.getCsrfToken() }
897
- },
898
- body: JSON.stringify(r)
899
- }), a = i.headers.get("x-csrf-token");
900
- if (a && e.setCsrfToken(a), !i.ok) throw Error(`stopCompletion failed: ${i.status}`);
901
- }
902
- };
903
- }, lt = (e) => e.messages.filter((e) => e.role !== o.Status).length < 2 ? !1 : e.llmNamingDone !== !0, ut = {
904
- ALLOWED_TAGS: [
905
- "a",
906
- "span",
907
- "strong",
908
- "u",
909
- "em",
910
- "br",
911
- "p"
912
- ],
913
- ALLOWED_ATTR: [
914
- "href",
915
- "target",
916
- "rel"
917
- ]
918
- }, W = (e) => et.sanitize(e, ut), dt = (e) => {
919
- let t = e.trim();
920
- return /^v/i.test(t) ? t : `v${t}`;
921
- }, ft = "__", pt = /[-+]/, mt = /^\d+$/, G = ".scheduler", K = "applications", q = (e) => e ? e.split(pt)[0].split(".").every((e) => mt.test(e)) : !1, ht = (e, t) => {
922
- let [n, r] = e.split(ft);
923
- return t && q(r) ? [n, r].join(ft) : n;
924
- }, gt = (e) => {
925
- let t = e.split("/");
926
- if (t.length < 3) return;
927
- let n = t.slice(2), r = n[0] === G ? n.slice(2) : n, i = r.findIndex((e) => e.includes(ft));
928
- if (i === -1) return;
929
- let a = r[i], o = r.slice(0, i).filter(Boolean), s = ht(a, o[0] === K), c = [...o, s].filter(Boolean);
930
- return c.length > 0 ? c.join("/") : void 0;
931
- }, _t = (e, t, n) => {
932
- let r = n != null && n.length > 0;
933
- return e >= 5 && e <= 11 ? r ? t.morningWithName : t.morningNoName : e >= 12 && e <= 16 ? r ? t.afternoonWithName : t.afternoonNoName : e >= 17 && e <= 20 ? r ? t.eveningWithName : t.eveningNoName : r ? t.nightWithName : t.nightNoName;
934
- }, vt = (e, t) => {
935
- let n = {
936
- event_type: c.ModelChanged,
937
- previous_deployment_id: e,
938
- new_deployment_id: t
939
- };
940
- return {
941
- id: l(),
942
- role: o.Status,
943
- content: "",
944
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
945
- deploymentId: t,
946
- custom_content: n
947
- };
948
- }, yt = (e, t, n, r) => r && t === n - 1 && e.role === o.Assistant, bt = (e) => {
949
- for (let t = e.length - 1; t >= 0; t--) {
950
- let n = e[t];
951
- if (u(n) && n.custom_content?.event_type === c.ModelChanged) return n.custom_content.new_deployment_id;
952
- }
953
- return null;
954
- }, xt = (e) => e.role === o.Assistant && (e.custom_content?.stages?.length ?? 0) > 0, St = (e) => {
955
- for (let t = e.length - 1; t >= 0; t--) if (e[t].role === o.User) return e[t].custom_content?.configuration_value;
956
- }, Ct = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? s.PlainText : s.Markdown, wt = (e) => e.map((e, t) => ({
957
- id: t.toString(),
958
- role: e.role,
959
- content: e.content
960
- })), Tt = (e) => typeof e == "object" && !!e && !Array.isArray(e), Et = (e) => {
961
- if (typeof e == "string") return e.trim() || void 0;
962
- }, Dt = (e) => {
963
- if (!Tt(e) || !Array.isArray(e.starters)) return {
964
- starters: [],
965
- introText: void 0,
966
- isChatMessageInputDisabled: !1
967
- };
968
- let t = e.autoSubmit !== !1;
969
- return {
970
- starters: e.starters.filter(Tt).map((e) => ({
971
- title: Et(e.title),
972
- text: Et(e.text)
973
- })).filter((e) => e.title != null && e.text != null).map((e, n) => ({
974
- const: n,
975
- title: e.title,
976
- "dial:widgetOptions": {
977
- populateText: e.text,
978
- submit: t,
979
- confirmationMessage: null
980
- }
981
- })),
982
- introText: Et(e.introText),
983
- isChatMessageInputDisabled: e.chatMessageInputDisabled === !0
984
- };
985
- }, J = (e) => e["dial:widgetOptions"].populateText || e.title, Ot = (e) => {
986
- let t = e?.properties;
987
- if (!t) return {
988
- starters: [],
989
- propertyKey: void 0,
990
- description: void 0
991
- };
992
- let n;
993
- if ("starter" in t ? n = "starter" : "button" in t && (n = "button"), !n) return {
994
- starters: [],
995
- propertyKey: void 0,
996
- description: void 0
997
- };
998
- let r = t[n], i = r?.oneOf, a = typeof r?.description == "string" ? r.description : void 0;
999
- return Array.isArray(i) ? {
1000
- starters: i,
1001
- propertyKey: n,
1002
- description: a
1003
- } : {
1004
- starters: [],
1005
- propertyKey: n,
1006
- description: a
1007
- };
1008
- }, kt = (e, t, n) => {
1009
- let i = !!(e.isReadonly || e.sharedWithMe || e.publishedWithMe), a = !i && t != null ? [...new Set(t.map((e) => e.folderPath.join("/")))] : [];
1010
- return {
1011
- isReadonly: i,
1012
- publishedFolders: a,
1013
- isRevokeVisible: n.status === r.Unknown || n.status === r.Resolved && (n.count ?? 0) > 0,
1014
- isPublishApplicable: a.length === 0,
1015
- isUnpublishApplicable: a.length > 0
1016
- };
1017
- }, At = ({ activeConversationId: e, items: t, refreshConversations: n, markConversationViewed: r, conversationIdsMatch: i, toPanelConversationId: a }) => {
1018
- let o = h(() => e ? a(e) : void 0, [e, a]);
1019
- return p(() => {
1020
- o && (t.some((e) => i(e.id, o)) || n());
1021
- }, [o, i]), p(() => {
1022
- if (!o) return;
1023
- let e = t.find((e) => i(e.id, o));
1024
- e && r(e.id);
1025
- }, [
1026
- o,
1027
- t,
1028
- r,
1029
- i
1030
- ]), o;
1031
- }, jt = () => {
1032
- let [e, t] = _(null), [n, r] = _(!1), [i, a] = _(null), o = g(null), s = g(!1), c = g(0), l = g(null), u = f((e, n) => {
1033
- let { activeElement: i } = document;
1034
- l.current = n ?? (i instanceof HTMLElement ? i : null), c.current += 1, o.current = e, s.current = !1, t(e), r(!1), a(null);
1035
- }, []);
1036
- p(() => {
1037
- if (e != null) return;
1038
- let t = l.current;
1039
- l.current = null, t?.isConnected && t.focus({ preventScroll: !0 });
1040
- }, [e]);
1041
- let d = f(() => {
1042
- c.current += 1, o.current = null, s.current = !1, t(null), a(null), r(!1);
1043
- }, []), m = f(async (e, n) => {
1044
- let i = o.current;
1045
- if (s.current || i == null) return;
1046
- let l = ++c.current;
1047
- s.current = !0, r(!0), a(null);
1048
- try {
1049
- if (await e(i), l !== c.current) return;
1050
- o.current = null, t(null), a(null), s.current = !1, r(!1);
1051
- } catch (e) {
1052
- if (l !== c.current) return;
1053
- a(n(e)), s.current = !1, r(!1);
1054
- }
1055
- }, []);
1056
- return {
1057
- pending: e,
1058
- isPending: e != null,
1059
- isRunning: n,
1060
- error: i,
1061
- open: u,
1062
- close: d,
1063
- confirm: m
1064
- };
1065
- }, Mt = ({ items: e, toPanelConversationId: t }) => h(() => {
1066
- let n = new Map(e.map((e) => [t(e.id), e.id])), r = new Map(e.map((e) => [t(e.id), e]));
1067
- return {
1068
- toContextId: (e) => n.get(e),
1069
- getRawItem: (e) => r.get(e)
1070
- };
1071
- }, [e, t]), Nt = (e) => e.sharedWithMe ? a.Shared : e.publishedWithMe ? a.Organization : a.MyChats, Pt = ({ items: e, deployments: r, isDeploymentsLoading: i, toPanelConversationId: a, resolveIconUrl: o, resolveIconTooltip: s, resolveHref: c, resolveTaskBadge: l }) => h(() => e.map((e) => {
1072
- let u = a(e.id), d = gt(e.id), f = d ? n(r, d) : void 0, p = d ? t(d.split("/").pop() ?? d) : "", m = l?.(e);
1073
- return {
1074
- id: u,
1075
- title: e.title,
1076
- isPinned: e.isPinned ?? !1,
1077
- iconUrl: o(f),
1078
- iconTooltip: s(f, p),
1079
- isIconLoading: i,
1080
- source: Nt(e),
1081
- href: c(u),
1082
- ...m == null ? {} : {
1083
- showTaskBadge: !0,
1084
- taskBadgeLabel: m.label,
1085
- isUnread: m.isUnread
1086
- }
1087
- };
1088
- }), [
1089
- e,
1090
- r,
1091
- i,
1092
- a,
1093
- o,
1094
- s,
1095
- c,
1096
- l
1097
- ]), Y = ({ accept: e, onFileSelected: t }) => {
1098
- let n = g(null);
1099
- return m(() => {
1100
- let t = n.current;
1101
- t && (e === void 0 || e === "" ? t.removeAttribute("accept") : t.accept = e);
1102
- }, [e]), {
1103
- inputRef: n,
1104
- triggerImport: f(() => {
1105
- n.current?.click();
1106
- }, []),
1107
- handleFileChange: f((e) => {
1108
- let n = e.target.files?.[0];
1109
- e.target.value = "", n && t(n);
1110
- }, [t])
1111
- };
1112
- }, Ft = 700, It = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", Lt = (e, t = /* @__PURE__ */ new Date()) => `uploads/${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}/${encodeURIComponent(It(e))}`, Rt = ({ filesApi: e, bucket: t, onNetworkError: n, debounceMs: r = Ft }) => {
1113
- let a = g([]), o = g(null);
1114
- return { handleUploadAttachment: f(async (s) => {
1115
- if (!t) throw Error("User bucket is not available");
1116
- try {
1117
- return (await e.uploadFile({
1118
- bucket: t,
1119
- path: Lt(s.name),
1120
- file: s.file
1121
- })).url;
1122
- } catch (e) {
1123
- if (!navigator.onLine) {
1124
- a.current.push(s.name), o.current != null && clearTimeout(o.current), o.current = setTimeout(() => {
1125
- let e = a.current.splice(0);
1126
- n?.(e), o.current = null;
1127
- }, r);
1128
- let t = e instanceof Error ? e : /* @__PURE__ */ Error("Network upload failed");
1129
- throw t.errorReason = i.Network, t;
1130
- }
1131
- throw e;
1132
- }
1133
- }, [
1134
- t,
1135
- r,
1136
- e,
1137
- n
1138
- ]) };
1139
- }, zt = (e) => {
1140
- if (!e.url) throw Error(`Attachment "${e.name}" has not been uploaded`);
1141
- return {
1142
- type: e.contentType,
1143
- title: e.name,
1144
- url: e.url
1145
- };
1146
- }, Bt = (e) => {
1147
- if (e.length) return e.map(zt);
1148
- }, Vt = (e, t, n) => {
1149
- let r = new Date(Date.now()).toISOString();
1150
- return {
1151
- userMessage: {
1152
- role: o.User,
1153
- content: e,
1154
- timestamp: r,
1155
- ...t && Object.keys(t).length ? { custom_content: t } : {}
1156
- },
1157
- assistantMessage: {
1158
- role: o.Assistant,
1159
- content: "",
1160
- timestamp: r,
1161
- ...n ? { deploymentId: n } : {}
1162
- }
1163
- };
1164
- }, Ht = (e) => e != null && Object.keys(e).length > 0, Ut = (e, t, n, r) => {
1165
- if (t !== e.content || r.length > 0) return !0;
1166
- let i = e.custom_content?.attachments?.length ?? 0;
1167
- return n.length !== i;
1168
- }, Wt = (e, t) => {
1169
- let { populateText: n } = e["dial:widgetOptions"];
1170
- return n == null && t ? t : J(e);
1171
- }, Gt = (e, t) => {
1172
- let { populateText: n, submit: r } = e["dial:widgetOptions"];
1173
- return r && n == null ? "" : t ?? J(e);
1174
- }, X = (t) => {
1175
- let n = t.indexOf("/");
1176
- return e(n === -1 ? t : t.substring(n + 1));
1177
- }, Kt = ({ conversation: e, conversationId: t, bucket: n, isStreaming: r, startStream: i, state: { setConversation: a, conversationRef: s }, filesApi: c, conversationsApi: u, rateApi: d, resolveModelId: p, onConversationDeleted: m, showNetworkError: h, toolConfigurationValue: g }) => {
1178
- let [y, b] = _(null), [x, S] = _(/* @__PURE__ */ new Set()), [C, w] = _(null), { handleUploadAttachment: ee } = Rt({
1179
- filesApi: c,
1180
- bucket: n,
1181
- onNetworkError: h
1182
- }), T = f(async (n, r) => {
1183
- if (!t || !e) return;
1184
- let o = Bt(r), c = Ht(g), u = o?.length || c ? {
1185
- ...o?.length ? { attachments: o } : {},
1186
- ...c ? { configuration_value: g } : {}
1187
- } : void 0, d = p(), { userMessage: f, assistantMessage: m } = Vt(n, u, d);
1188
- a((e) => {
1189
- if (!e) return e;
1190
- let t = {
1191
- ...e,
1192
- messages: [
1193
- ...e.messages,
1194
- f,
1195
- m
1196
- ]
1197
- };
1198
- return s.current = t, t;
1199
- }), i(t, n, e.messages.length + 1, d, u, l(), v.Append);
1200
- }, [
1201
- e,
1202
- t,
1203
- s,
1204
- p,
1205
- a,
1206
- i,
1207
- g
1208
- ]), E = f((n) => {
1209
- if (r || !t || !e || n === -1 || e.messages[n]?.role !== o.Assistant) return;
1210
- let c = e.messages[n - 1];
1211
- if (!c || c.role !== o.User) return;
1212
- let u = p();
1213
- a((e) => {
1214
- if (!e) return e;
1215
- let t = {
1216
- ...e.messages[n],
1217
- content: "",
1218
- custom_content: void 0,
1219
- wasStoppedByUser: void 0,
1220
- stoppedWithoutContent: void 0,
1221
- streamErrorMessage: void 0,
1222
- deploymentId: u
1223
- }, r = {
1224
- ...e,
1225
- messages: [...e.messages.slice(0, n), t]
1226
- };
1227
- return s.current = r, r;
1228
- }), S((e) => new Set([...e].filter((e) => e < n))), i(t, c.content, n, u, c.custom_content, l(), v.Regenerate);
1229
- }, [
1230
- e,
1231
- t,
1232
- s,
1233
- r,
1234
- p,
1235
- a,
1236
- i
1237
- ]), D = f((e) => {
1238
- r || b(e);
1239
- }, [r]), O = f(() => {
1240
- if (!t || y == null) return;
1241
- let e = y;
1242
- b(null);
1243
- let n = s.current;
1244
- if (!n || e === -1) return;
1245
- let r = X(t), i = n.messages[e + 1]?.role === o.Assistant ? n.messages.filter((t, n) => n !== e && n !== e + 1) : n.messages.filter((t, n) => n !== e);
1246
- if (i.length === 0 || i.length === 1 && i[0].role === o.Status) {
1247
- u.deleteConversation({ path: r }), m?.();
1248
- return;
1249
- }
1250
- let c = {
1251
- ...n,
1252
- messages: i
1253
- };
1254
- s.current = c, a(c), u.saveConversation({
1255
- path: r,
1256
- saveConversationBodyDto: { conversation: c }
1257
- });
1258
- }, [
1259
- t,
1260
- s,
1261
- u,
1262
- m,
1263
- y,
1264
- a
1265
- ]), k = f(async (n, r, i) => {
1266
- if (!t || !e) return !1;
1267
- let o = e.messages[n];
1268
- if (!o) return !1;
1269
- let c = o.rating, l = {
1270
- ...e,
1271
- messages: e.messages.map((e, t) => t === n ? {
1272
- ...e,
1273
- rating: r ?? void 0
1274
- } : e)
1275
- };
1276
- a(() => (s.current = l, l));
1277
- let f = X(t), p = () => {
1278
- a((e) => e && {
1279
- ...e,
1280
- messages: e.messages.map((e, t) => t === n ? {
1281
- ...e,
1282
- rating: c
1283
- } : e)
1284
- });
1285
- }, m = () => u.saveConversation({
1286
- path: f,
1287
- saveConversationBodyDto: { conversation: l }
1288
- });
1289
- if (r != null) {
1290
- let t = o.responseId;
1291
- if (!t) return p(), !1;
1292
- try {
1293
- return await d.rateMessage({ rateMessageDto: {
1294
- conversationId: e.id,
1295
- responseId: t,
1296
- modelId: e.model.id,
1297
- rate: r,
1298
- ...i ? { comment: i } : {}
1299
- } }), await m(), !0;
1300
- } catch {
1301
- return p(), !1;
1302
- }
1303
- } else try {
1304
- return await m(), !0;
1305
- } catch {
1306
- return p(), !1;
1307
- }
1308
- }, [
1309
- e,
1310
- t,
1311
- s,
1312
- u,
1313
- d,
1314
- a
1315
- ]), A = f((n, r, o) => {
1316
- if (!t || !e) return;
1317
- let c = o ?? n.title, u = Gt(n, o), d = r ? { [r]: n.const } : void 0, f = Ht(g), m = d || f ? {
1318
- ...d ? { form_value: d } : {},
1319
- ...f ? { configuration_value: g } : {}
1320
- } : void 0, h = p(), { userMessage: _, assistantMessage: y } = Vt(c, m, h);
1321
- a((e) => {
1322
- if (!e) return e;
1323
- let t = {
1324
- ...e,
1325
- messages: [
1326
- ...e.messages,
1327
- _,
1328
- y
1329
- ]
1330
- };
1331
- return s.current = t, t;
1332
- }), i(t, u, e.messages.length + 1, h, m, l(), v.Append);
1333
- }, [
1334
- e,
1335
- t,
1336
- s,
1337
- p,
1338
- a,
1339
- i,
1340
- g
1341
- ]);
1342
- return {
1343
- handleSend: T,
1344
- handleUploadAttachment: ee,
1345
- handleRegenerateMessage: E,
1346
- handleDeleteMessage: D,
1347
- handleConfirmDelete: O,
1348
- handleRateMessage: k,
1349
- handleButtonSelect: f((n, i, a) => {
1350
- !t || !e || r || (n["dial:widgetOptions"].confirmationMessage ? w({
1351
- starter: n,
1352
- propertyKey: i,
1353
- description: a
1354
- }) : A(n, i, a));
1355
- }, [
1356
- e,
1357
- t,
1358
- r,
1359
- A
1360
- ]),
1361
- handleConfirmStarter: f(() => {
1362
- if (!C) return;
1363
- let { starter: e, propertyKey: t, description: n } = C;
1364
- w(null), A(e, t, n);
1365
- }, [C, A]),
1366
- handleStartEdit: f((e) => {
1367
- S((t) => new Set([...t, e]));
1368
- }, []),
1369
- handleCancelEdit: f((e) => {
1370
- S((t) => {
1371
- let n = new Set(t);
1372
- return n.delete(e), n;
1373
- });
1374
- }, []),
1375
- handleEditMessage: f(async (n, c, u, d) => {
1376
- if (r || !t || !e) return;
1377
- let f = n;
1378
- if (f === -1 || e.messages[f].role !== o.User) return;
1379
- let m = e.messages[f];
1380
- if (!Ut(m, c, u, d)) {
1381
- S((e) => {
1382
- let t = new Set(e);
1383
- return t.delete(f), t;
1384
- });
1385
- return;
1386
- }
1387
- let h = Bt(d), g = new Set(u.map((e) => e.id)), _ = [...(m.custom_content?.attachments ?? []).filter((e) => {
1388
- let t = e.url ?? e.data ?? e.title;
1389
- return g.has(t);
1390
- }), ...h ?? []], { attachments: y, ...b } = m.custom_content ?? {}, x = _.length > 0 ? {
1391
- ...b,
1392
- attachments: _
1393
- } : Object.keys(b).length > 0 ? b : void 0, C = {
1394
- ...m,
1395
- content: c,
1396
- custom_content: x
1397
- }, w = Date.now(), ee = {
1398
- role: o.Assistant,
1399
- content: "",
1400
- timestamp: new Date(w).toISOString()
1401
- }, T = [
1402
- ...e.messages.slice(0, f),
1403
- C,
1404
- ee
1405
- ], E = {
1406
- ...e,
1407
- messages: T
1408
- };
1409
- a(() => (s.current = E, E));
1410
- let D = p();
1411
- i(t, c, T.length - 1, D, x, l(), v.Edit), S(/* @__PURE__ */ new Set());
1412
- }, [
1413
- e,
1414
- t,
1415
- s,
1416
- r,
1417
- p,
1418
- a,
1419
- i
1420
- ]),
1421
- editingMessageIndexes: x,
1422
- pendingDeleteIndex: y,
1423
- setPendingDeleteIndex: b,
1424
- pendingStarterContext: C,
1425
- setPendingStarterContext: w
1426
- };
1427
- }, qt = (e) => {
1428
- let t = e.target?.selector;
1429
- return t?.type === "html_tag" ? t.id : void 0;
1430
- }, Jt = (e, t) => {
1431
- if (e.index != null && t.index != null) return e.index === t.index;
1432
- let n = qt(e), r = qt(t);
1433
- return n != null && n === r;
1434
- }, Yt = (e, t) => {
1435
- let n = [...e];
1436
- for (let e of t) {
1437
- let t = n.findIndex((t) => Jt(t, e));
1438
- if (t >= 0) {
1439
- let r = n[t];
1440
- n[t] = {
1441
- ...r,
1442
- ...e,
1443
- body: {
1444
- ...r.body,
1445
- ...e.body,
1446
- title: (r.body?.title ?? "") + (e.body?.title ?? "") || void 0,
1447
- quote: (r.body?.quote ?? "") + (e.body?.quote ?? "") || void 0
1448
- }
1449
- };
1450
- } else n.push(e);
1451
- }
1452
- return n;
1453
- }, Xt = (e, t) => {
1454
- let n = [...e];
1455
- for (let e of t) {
1456
- let t = e.index == null ? -1 : n.findIndex((t) => t.index === e.index);
1457
- t >= 0 ? n[t] = {
1458
- ...n[t],
1459
- ...e,
1460
- title: (n[t].title ?? "") + (e.title ?? ""),
1461
- data: e.data == null ? n[t].data : (n[t].data ?? "") + e.data
1462
- } : n.push(e);
1463
- }
1464
- return n;
1465
- }, Zt = (e, t) => {
1466
- let n = [...e];
1467
- for (let e of t) {
1468
- let t = n.findIndex((t) => t.index === e.index);
1469
- t >= 0 ? n[t] = {
1470
- ...n[t],
1471
- ...e,
1472
- name: (n[t].name ?? "") + (e.name ?? ""),
1473
- content: (n[t].content ?? "") + (e.content ?? "") || void 0,
1474
- attachments: e.attachments?.length ? Xt(n[t].attachments ?? [], e.attachments) : n[t].attachments
1475
- } : n.push({
1476
- ...e,
1477
- name: e.name ?? ""
1478
- });
1479
- }
1480
- return n;
1481
- }, Qt = (e, t, n) => {
1482
- let r = n.choices[0]?.delta, i = r?.content ?? "", a = r?.custom_content?.form_schema, o = r?.custom_content?.attachments, s = r?.custom_content?.stages, c = r?.custom_content?.annotations, l = r?.custom_fields?.annotations, u = r?.custom_content?.state, f = !!i || !!a || !!o?.length || !!s?.length || !!c?.length || !!l?.length || !!u, p = r?.responseId ?? (f ? n.id : void 0);
1483
- return !f && !p ? null : e.map((e, n) => {
1484
- if (n !== t) return e;
1485
- let r = [...e.custom_content?.attachments ?? [], ...o ?? []], f = l?.length ? d(l, r) : [], m = [...c ?? [], ...f], h = a || o?.length || s?.length || m.length || u;
1486
- return {
1487
- ...e,
1488
- content: i ? e.content + i : e.content,
1489
- ...p && { responseId: p },
1490
- ...h && { custom_content: {
1491
- ...e.custom_content,
1492
- ...a && { form_schema: a },
1493
- ...o?.length && { attachments: r },
1494
- ...s?.length && { stages: Zt(e.custom_content?.stages ?? [], s) },
1495
- ...m.length && { annotations: Yt(e.custom_content?.annotations ?? [], m) },
1496
- ...u && { state: u }
1497
- } }
1498
- };
1499
- });
1500
- }, $t = (e, t) => ({
1501
- ...e,
1502
- ...t,
1503
- ...(e.custom_content || t.custom_content) && { custom_content: {
1504
- ...e.custom_content,
1505
- ...t.custom_content
1506
- } }
1507
- }), en = (e, t) => {
1508
- if (t.messageIndex > e.messages.length) return e;
1509
- let n = [...e.messages];
1510
- return t.messageIndex === n.length ? n.push(t.message) : n[t.messageIndex] = $t(n[t.messageIndex], t.message), {
1511
- ...e,
1512
- messages: n
1513
- };
1514
- }, tn = (e) => {
1515
- let t = e.custom_content;
1516
- return !!e.content || e.responseId != null || !!t?.attachments?.length || !!t?.stages?.length || !!t?.annotations?.length || !!t?.form_schema || t?.state != null;
1517
- }, Z = (e) => {
1518
- let t = e.messages[e.messages.length - 1];
1519
- return !!t && t.role === o.Assistant && !tn(t) && t.streamErrorMessage == null && !t.wasStoppedByUser;
1520
- }, nn = 300 * 1e3, Q = "awaiting-resume", rn = async (e, t) => {
1521
- let n = e.getReader(), r = new TextDecoder(), i = "";
1522
- try {
1523
- for (;;) {
1524
- let { done: e, value: a } = await n.read();
1525
- if (e) break;
1526
- i += r.decode(a, { stream: !0 });
1527
- let o = i.split("\n");
1528
- i = o.pop() ?? "";
1529
- let s = !1;
1530
- for (let e of o) {
1531
- let n = e.trim();
1532
- if (!n.startsWith("data:")) continue;
1533
- let r = n.slice(5).trim(), i;
1534
- try {
1535
- i = JSON.parse(r);
1536
- } catch {
1537
- continue;
1538
- }
1539
- if (await t(i)) {
1540
- s = !0;
1541
- break;
1542
- }
1543
- }
1544
- if (s) break;
1545
- }
1546
- } catch {} finally {
1547
- n.releaseLock();
1548
- }
1549
- }, an = ({ transport: t, setConversation: n, conversationRef: r, resumingPathsRef: i, bufferedGenerationsRef: a, addStreamingPath: o, removeStreamingPath: s, isPathDisplayed: c }) => (l, u) => {
1550
- if (!Z(u)) return;
1551
- let d = X(l);
1552
- if (i.current.has(d)) return;
1553
- i.current.add(d), o(d);
1554
- let f = u.messages.length - 1, p = (e) => {
1555
- i.current.delete(d), s(d), a.current.delete(d), e && c(d) && (n(e), r.current = e);
1556
- }, m = async () => {
1557
- try {
1558
- p(await t.getConversation(e(l)));
1559
- } catch {
1560
- p();
1561
- }
1562
- }, h = (e) => {
1563
- let t = {
1564
- generationId: Q,
1565
- messageIndex: f,
1566
- message: e
1567
- };
1568
- a.current.set(d, t), c(d) && n((e) => {
1569
- if (!e) return e;
1570
- let n = en(e, t);
1571
- return r.current = n, n;
1572
- });
1573
- }, g = (e) => {
1574
- let t = a.current.get(d);
1575
- if (t?.generationId === Q) {
1576
- let n = Qt([t.message], 0, e);
1577
- n && (t.message = n[0]);
1578
- }
1579
- c(d) && n((e) => {
1580
- if (!e) return e;
1581
- let t = a.current.get(d);
1582
- if (t?.generationId !== Q) return e;
1583
- let n = en(e, t);
1584
- return r.current = n, n;
1585
- });
1586
- }, _ = async () => {
1587
- let n = new AbortController(), r;
1588
- try {
1589
- r = await t.watchConversation(d, n.signal);
1590
- } catch {
1591
- await m();
1592
- return;
1593
- }
1594
- let i = !1, a = window.setTimeout(() => {
1595
- n.abort();
1596
- }, nn);
1597
- try {
1598
- await rn(r, async (n) => {
1599
- if (n?.action !== "UPDATE") return !1;
1600
- try {
1601
- let n = await t.getConversation(e(l));
1602
- if (!Z(n)) return p(n), i = !0, !0;
1603
- } catch {}
1604
- return !1;
1605
- });
1606
- } finally {
1607
- clearTimeout(a);
1608
- }
1609
- i || await m();
1610
- }, v = async () => {
1611
- let e = new AbortController(), n;
1612
- try {
1613
- n = await t.attachToGeneration(d, e.signal);
1614
- } catch {
1615
- return !1;
1616
- }
1617
- let r = !1;
1618
- return await rn(n, (e) => {
1619
- switch (e.type) {
1620
- case "snapshot": return h(e.message), !1;
1621
- case "chunk": return g(e.chunk), !1;
1622
- case "done":
1623
- case "error":
1624
- case "stopped": return r = !0, !0;
1625
- }
1626
- }), r ? (await m(), !0) : !1;
1627
- };
1628
- (async () => {
1629
- await v() || await _();
1630
- })();
1631
- }, on = 2e4, sn = ({ conversationId: t, state: { setConversation: n, conversationRef: r }, transport: i, generation: { startGeneration: a, completeGeneration: o }, channel: s, overlay: c, onStopError: u }) => {
1632
- let [d, m] = _(() => /* @__PURE__ */ new Set()), [y, b] = _(null), x = g(null), S = g(null), C = g(/* @__PURE__ */ new Set()), w = g(/* @__PURE__ */ new Map()), ee = g(/* @__PURE__ */ new Set()), T = g(t);
1633
- p(() => {
1634
- T.current = t;
1635
- }, [t]);
1636
- let E = f((e) => X(T.current ?? "") === e, []), D = f((e) => {
1637
- m((t) => {
1638
- if (t.has(e)) return t;
1639
- let n = new Set(t);
1640
- return n.add(e), n;
1641
- });
1642
- }, []), O = f((e) => {
1643
- m((t) => {
1644
- if (!t.has(e)) return t;
1645
- let n = new Set(t);
1646
- return n.delete(e), n;
1647
- });
1648
- }, []), k = f((t, u, d, f, p, m, h = v.Append) => {
1649
- let g = m ?? l(), _ = X(t);
1650
- x.current = g, S.current = _, b(_);
1651
- let y;
1652
- h === v.Regenerate ? y = d : h === v.Edit && (y = d - 1);
1653
- let C = a(_, g), T = r.current?.messages[d];
1654
- T ? w.current.set(_, {
1655
- generationId: g,
1656
- messageIndex: d,
1657
- message: T
1658
- }) : w.current.delete(_), D(_), c?.notifyGenerationStart?.(), s?.ensureConnected();
1659
- let k = {
1660
- signal: C.signal,
1661
- onChunk: (e) => {
1662
- if (x.current !== g) return;
1663
- let t = w.current.get(_);
1664
- if (t?.generationId === g) {
1665
- let n = Qt([t.message], 0, e);
1666
- n && (t.message = n[0]);
1667
- }
1668
- E(_) && n((t) => {
1669
- if (!t) return t;
1670
- let n = w.current.get(_), i;
1671
- if (n?.generationId === g) i = en(t, n);
1672
- else {
1673
- let n = Qt(t.messages, d, e);
1674
- if (!n) return t;
1675
- i = {
1676
- ...t,
1677
- messages: n
1678
- };
1679
- }
1680
- return r.current = i, i;
1681
- });
1682
- },
1683
- onComplete: async () => {
1684
- if (w.current.get(_)?.generationId === g && w.current.delete(_), O(_), x.current === g && (x.current = null, S.current = null, b(null)), o(_, g), s?.notifyGenerationSettled?.(), ee.current.has(g) ? ee.current.delete(g) : c?.notifyGenerationEnd?.(), E(_)) try {
1685
- let a = await i.getConversation(e(t));
1686
- if (!E(_)) return;
1687
- n(a), r.current = a;
1688
- } catch {}
1689
- },
1690
- onError: (e) => {
1691
- let t = w.current.get(_), i = t?.generationId === g ? t : void 0;
1692
- i && w.current.delete(_), O(_), x.current === g && (x.current = null, S.current = null, b(null)), o(_, g), s?.notifyGenerationSettled?.(), E(_) && n((t) => {
1693
- if (!t) return t;
1694
- let n = i?.generationId === g ? en(t, i) : t, a = {
1695
- ...n,
1696
- messages: n.messages.map((t, n) => n === d ? {
1697
- ...t,
1698
- streamErrorMessage: e.message
1699
- } : t)
1700
- };
1701
- return r.current = a, a;
1702
- });
1703
- }
1704
- };
1705
- (async () => {
1706
- try {
1707
- let e = s?.channelId ?? await s?.waitForChannel(on) ?? void 0;
1708
- i.streamCompletion(_, u, f, k, p, g, h, y, e);
1709
- } catch (e) {
1710
- k.onError(e instanceof Error ? e : Error(String(e)));
1711
- }
1712
- })();
1713
- }, [
1714
- a,
1715
- o,
1716
- D,
1717
- O,
1718
- E,
1719
- s?.channelId,
1720
- s?.ensureConnected,
1721
- s?.waitForChannel,
1722
- s?.notifyGenerationSettled,
1723
- c,
1724
- i
1725
- ]), A = f((e, t) => {
1726
- let n = X(e), r = w.current.get(n);
1727
- return r ? en(t, r) : t;
1728
- }, []), te = f(() => {
1729
- let e = x.current;
1730
- if (!e || !t) return;
1731
- let n = X(t);
1732
- S.current === n && (ee.current.add(e), c?.notifyStopGenerating?.(), i.stopCompletion({
1733
- generationId: e,
1734
- path: n
1735
- }).catch((e) => {
1736
- let t = e instanceof Error ? e : Error(String(e));
1737
- u?.(t);
1738
- }));
1739
- }, [
1740
- t,
1741
- u,
1742
- c,
1743
- i
1744
- ]), ne = h(() => an({
1745
- transport: i,
1746
- setConversation: n,
1747
- conversationRef: r,
1748
- resumingPathsRef: C,
1749
- bufferedGenerationsRef: w,
1750
- addStreamingPath: D,
1751
- removeStreamingPath: O,
1752
- isPathDisplayed: E
1753
- }), [
1754
- D,
1755
- O,
1756
- E,
1757
- i
1758
- ]), re = t != null && d.has(X(t)), j = t == null ? null : X(t);
1759
- return {
1760
- startStream: k,
1761
- handleStop: te,
1762
- resumeIfAwaitingGeneration: ne,
1763
- restoreBufferedGeneration: A,
1764
- isStreaming: re,
1765
- canStopStreaming: j != null && y === j
1766
- };
1767
- }, cn = {
1768
- settings: "Settings",
1769
- savedNotification: "Chat settings have been saved",
1770
- responseFormatLabel: "Response format",
1771
- responseFormatHint: "Applies to new and existing messages",
1772
- responseFormatMarkdown: "Markdown",
1773
- responseFormatPlainText: "Plain text",
1774
- systemPromptLabel: "System prompt",
1775
- systemPromptTooltip: "Enter a prompt",
1776
- temperatureLabel: "Temperature",
1777
- temperaturePrecise: "Precise",
1778
- temperatureNeutral: "Neutral",
1779
- temperatureCreative: "Creative",
1780
- temperatureHint: "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
1781
- saveLabel: "Apply changes",
1782
- saveDisabledTooltip: "Please select a response format"
1783
- }, ln = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? s.PlainText : s.Markdown, un = (e) => {
1784
- let t = h(() => ({
1785
- ...cn,
1786
- ...e.labels
1787
- }), [e.labels]), { onSaved: n } = e, r = e.mode === "local" ? e.values.responseFormat : ln(e.conversation.responseFormat), i = e.mode === "local" ? e.values.systemPrompt : e.conversation.prompt ?? "", a = e.mode === "local" ? e.values.temperature : e.conversation.temperature ?? .5, o = f((t) => {
1788
- e.mode === "local" ? e.onValuesChange({
1789
- responseFormat: t.responseFormat ?? e.values.responseFormat,
1790
- systemPrompt: t.systemPrompt ?? e.values.systemPrompt,
1791
- temperature: t.temperature ?? e.values.temperature
1792
- }) : e.onConversationChange({
1793
- ...e.conversation,
1794
- ...t.responseFormat != null && { responseFormat: t.responseFormat },
1795
- ...t.systemPrompt != null && { prompt: t.systemPrompt },
1796
- ...t.temperature != null && { temperature: t.temperature }
1797
- }), n?.();
1798
- }, [n, e]), s = e.deploymentFeatures?.systemPrompt ?? !1, c = !e.isQuickApp && (e.deploymentFeatures?.temperature ?? !1);
1799
- return h(() => ({
1800
- features: {
1801
- systemPrompt: s,
1802
- temperature: c,
1803
- responseFormat: !0
1804
- },
1805
- responseFormat: r,
1806
- systemPrompt: i,
1807
- temperature: a,
1808
- onSave: o,
1809
- menuItemLabel: t.settings,
1810
- title: t.settings,
1811
- responseFormatLabel: t.responseFormatLabel,
1812
- responseFormatHint: t.responseFormatHint,
1813
- responseFormatMarkdownLabel: t.responseFormatMarkdown,
1814
- responseFormatPlainTextLabel: t.responseFormatPlainText,
1815
- systemPromptLabel: t.systemPromptLabel,
1816
- systemPromptTooltip: t.systemPromptTooltip,
1817
- temperatureLabel: t.temperatureLabel,
1818
- temperatureLabels: [
1819
- t.temperaturePrecise,
1820
- t.temperatureNeutral,
1821
- t.temperatureCreative
1822
- ],
1823
- temperatureHint: t.temperatureHint,
1824
- saveLabel: t.saveLabel,
1825
- saveDisabledTooltip: t.saveDisabledTooltip
1826
- }), [
1827
- o,
1828
- s,
1829
- c,
1830
- t,
1831
- r,
1832
- i,
1833
- a
1834
- ]);
1835
- }, dn = (e) => e.type === "boolean" || e.type == null && typeof e.default == "boolean", fn = (e) => {
1836
- let t = e.replace(/[_-]+/g, " ").trim();
1837
- return t.length === 0 ? e : t.charAt(0).toUpperCase() + t.slice(1);
1838
- }, pn = (e) => {
1839
- let t = e?.properties;
1840
- return t == null ? [] : Object.entries(t).filter(([, e]) => dn(e)).map(([e, t]) => ({
1841
- id: e,
1842
- label: typeof t.title == "string" && t.title.length > 0 ? t.title : fn(e),
1843
- defaultValue: t.default === !0
1844
- }));
1845
- }, $ = (e) => {
1846
- let { selectedItemId: t, selectedDeploymentConfiguration: n, toolIcon: r } = e, i = h(() => pn(n), [n]), a = h(() => Object.fromEntries(i.map(({ id: e, defaultValue: t }) => [e, t])), [i]), [o, s] = _(a), c = JSON.stringify(a), l = g(a);
1847
- l.current = a, p(() => {
1848
- s(l.current);
1849
- }, [t, c]);
1850
- let u = f((e) => {
1851
- s((t) => e in t ? {
1852
- ...t,
1853
- [e]: !t[e]
1854
- } : t);
1855
- }, [s]), d = f((e) => {
1856
- e != null && s((t) => {
1857
- let n = !1, r = { ...t };
1858
- for (let i of Object.keys(t)) {
1859
- let a = e[i];
1860
- typeof a == "boolean" && a !== t[i] && (r[i] = a, n = !0);
1861
- }
1862
- return n ? r : t;
1863
- });
1864
- }, [s]);
1865
- return {
1866
- toolsMenuItems: h(() => i.map(({ id: e, label: t }) => ({
1867
- id: e,
1868
- label: t,
1869
- icon: r ?? null,
1870
- isSelected: o[e] ?? !1
1871
- })), [
1872
- i,
1873
- o,
1874
- r
1875
- ]),
1876
- onToolToggle: u,
1877
- toolConfigurationValue: h(() => Object.fromEntries(i.map(({ id: e }) => [e, o[e] ?? !1])), [i, o]),
1878
- restoreToolConfiguration: d
1879
- };
1880
- };
1881
- //#endregion
1882
- export { Ct as A, ot as B, Ot as C, St as D, bt as E, W as F, it as H, lt as I, U as L, _t as M, gt as N, yt as O, dt as P, st as R, J as S, wt as T, rt as V, Pt as _, Kt as a, At as b, Gt as c, Vt as d, zt as f, Nt as g, Y as h, Z as i, vt as j, xt as k, Ht as l, Rt as m, un as n, X as o, Bt as p, sn as r, Wt as s, $ as t, Ut as u, Mt as v, Dt as w, kt as x, jt as y, V as z };