@pickaxeproject/react 3.23.1 → 4.0.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 (203) hide show
  1. package/dist/cjs/common/api/pickaxe.js +1 -0
  2. package/dist/cjs/common/utils.js +1 -1
  3. package/dist/cjs/components/EmbedPreview/ChatInput.js +1 -1
  4. package/dist/cjs/components/EmbedPreview/FAB.js +1 -1
  5. package/dist/cjs/components/EmbedPreview/Inline.js +1 -1
  6. package/dist/cjs/components/EmbedPreview/Popup.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Addons/Artifact/hooks/useArtifact.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Addons/Artifact/index.js +1 -1
  10. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  11. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.js +1 -1
  12. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  13. package/dist/cjs/components/Pickaxe/Chat/History/CustomMessage.js +1 -1
  14. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  15. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  16. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  17. package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
  18. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  19. package/dist/cjs/components/Pickaxe/Form/NewChat.js +1 -1
  20. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  21. package/dist/cjs/components/Pickaxe/Form/Questions/index.js +1 -1
  22. package/dist/cjs/components/Pickaxe/Form/index.js +1 -1
  23. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  24. package/dist/cjs/components/Pickaxe/ResponseProvider.js +1 -1
  25. package/dist/cjs/components/Pickaxe/common/PickaxeBranding.js +1 -1
  26. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  27. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  28. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  29. package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  30. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/TextShimmer.js +1 -0
  31. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -0
  32. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -0
  33. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/TextPart/index.js +1 -0
  34. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -0
  35. package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  36. package/dist/cjs/components/Pickaxe/index.js +1 -1
  37. package/dist/cjs/hooks/core/useAffiliate.js +1 -1
  38. package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
  39. package/dist/cjs/hooks/pickaxe/useFeedback.js +1 -0
  40. package/dist/cjs/hooks/pickaxe/useHistory.js +1 -1
  41. package/dist/cjs/hooks/pickaxe/usePickaxe.js +1 -1
  42. package/dist/cjs/hooks/pickaxe/useSubmit.js +1 -1
  43. package/dist/cjs/hooks/pickaxe/useSubmitDocument.js +1 -1
  44. package/dist/cjs/index.js +1 -1
  45. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  46. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  47. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  48. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  49. package/dist/cjs/src/common/api/pickaxe.d.ts +2 -0
  50. package/dist/cjs/src/common/utils.d.ts +2 -0
  51. package/dist/cjs/src/components/EmbedPreview/ChatInput.d.ts +1 -1
  52. package/dist/cjs/src/components/EmbedPreview/FAB.d.ts +1 -1
  53. package/dist/cjs/src/components/EmbedPreview/Inline.d.ts +1 -1
  54. package/dist/cjs/src/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.d.ts +5 -3
  55. package/dist/cjs/src/components/Pickaxe/Chat/History/CustomMessage.d.ts +2 -2
  56. package/dist/cjs/src/components/Pickaxe/Chat/History/Message.d.ts +4 -3
  57. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +23 -18
  58. package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +7 -4
  59. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +1 -2
  60. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +0 -2
  61. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +1 -4
  62. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +3 -4
  63. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/TextShimmer.d.ts +13 -0
  64. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +9 -0
  65. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.d.ts +7 -0
  66. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/TextPart/index.d.ts +6 -0
  67. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +7 -0
  68. package/dist/cjs/src/components/Pickaxe/index.d.ts +2 -2
  69. package/dist/cjs/src/hooks/core/useAffiliate.d.ts +1 -1
  70. package/dist/cjs/src/hooks/pickaxe/useConversation.d.ts +2 -2
  71. package/dist/cjs/src/hooks/pickaxe/{useThumbSelection.d.ts → useFeedback.d.ts} +5 -7
  72. package/dist/cjs/src/hooks/pickaxe/useHistory.d.ts +2 -1
  73. package/dist/cjs/src/hooks/pickaxe/usePickaxe.d.ts +1 -1
  74. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +15 -12
  75. package/dist/cjs/src/hooks/pickaxe/useResponseContext.d.ts +8 -4
  76. package/dist/cjs/src/hooks/pickaxe/useSubmit.d.ts +10 -8
  77. package/dist/cjs/src/hooks/pickaxe/useSubmitDocument.d.ts +7 -7
  78. package/dist/cjs/src/index.d.ts +1 -0
  79. package/dist/cjs/src/types/form.d.ts +0 -10
  80. package/dist/cjs/src/types/history.d.ts +56 -30
  81. package/dist/cjs/src/types/pickaxe.d.ts +1 -1
  82. package/dist/cjs/src/types/response.d.ts +11 -0
  83. package/dist/esm/common/api/pickaxe.js +1 -0
  84. package/dist/esm/common/utils.js +1 -1
  85. package/dist/esm/components/EmbedPreview/ChatInput.js +1 -1
  86. package/dist/esm/components/EmbedPreview/FAB.js +1 -1
  87. package/dist/esm/components/EmbedPreview/Inline.js +1 -1
  88. package/dist/esm/components/EmbedPreview/Popup.js +1 -1
  89. package/dist/esm/components/Pickaxe/Addons/Artifact/hooks/useArtifact.js +1 -1
  90. package/dist/esm/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.js +1 -1
  91. package/dist/esm/components/Pickaxe/Addons/Artifact/index.js +1 -1
  92. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  93. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.js +1 -1
  94. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  95. package/dist/esm/components/Pickaxe/Chat/History/CustomMessage.js +1 -1
  96. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  97. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  98. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  99. package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
  100. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  101. package/dist/esm/components/Pickaxe/Form/NewChat.js +1 -1
  102. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  103. package/dist/esm/components/Pickaxe/Form/Questions/index.js +1 -1
  104. package/dist/esm/components/Pickaxe/Form/index.js +1 -1
  105. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  106. package/dist/esm/components/Pickaxe/ResponseProvider.js +1 -1
  107. package/dist/esm/components/Pickaxe/common/PickaxeBranding.js +1 -1
  108. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  109. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  110. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  111. package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  112. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/TextShimmer.js +1 -0
  113. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -0
  114. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -0
  115. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/TextPart/index.js +1 -0
  116. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -0
  117. package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  118. package/dist/esm/components/Pickaxe/index.js +1 -1
  119. package/dist/esm/hooks/core/useAffiliate.js +1 -1
  120. package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
  121. package/dist/esm/hooks/pickaxe/useFeedback.js +1 -0
  122. package/dist/esm/hooks/pickaxe/useHistory.js +1 -1
  123. package/dist/esm/hooks/pickaxe/usePickaxe.js +1 -1
  124. package/dist/esm/hooks/pickaxe/useSubmit.js +1 -1
  125. package/dist/esm/hooks/pickaxe/useSubmitDocument.js +1 -1
  126. package/dist/esm/index.js +1 -1
  127. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  128. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  129. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  130. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  131. package/dist/esm/src/common/api/pickaxe.d.ts +2 -0
  132. package/dist/esm/src/common/utils.d.ts +2 -0
  133. package/dist/esm/src/components/EmbedPreview/ChatInput.d.ts +1 -1
  134. package/dist/esm/src/components/EmbedPreview/FAB.d.ts +1 -1
  135. package/dist/esm/src/components/EmbedPreview/Inline.d.ts +1 -1
  136. package/dist/esm/src/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.d.ts +5 -3
  137. package/dist/esm/src/components/Pickaxe/Chat/History/CustomMessage.d.ts +2 -2
  138. package/dist/esm/src/components/Pickaxe/Chat/History/Message.d.ts +4 -3
  139. package/dist/esm/src/components/Pickaxe/Provider.d.ts +23 -18
  140. package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +7 -4
  141. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +1 -2
  142. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +0 -2
  143. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +1 -4
  144. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +3 -4
  145. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/TextShimmer.d.ts +13 -0
  146. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +9 -0
  147. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.d.ts +7 -0
  148. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/TextPart/index.d.ts +6 -0
  149. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +7 -0
  150. package/dist/esm/src/components/Pickaxe/index.d.ts +2 -2
  151. package/dist/esm/src/hooks/core/useAffiliate.d.ts +1 -1
  152. package/dist/esm/src/hooks/pickaxe/useConversation.d.ts +2 -2
  153. package/dist/esm/src/hooks/pickaxe/{useThumbSelection.d.ts → useFeedback.d.ts} +5 -7
  154. package/dist/esm/src/hooks/pickaxe/useHistory.d.ts +2 -1
  155. package/dist/esm/src/hooks/pickaxe/usePickaxe.d.ts +1 -1
  156. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +15 -12
  157. package/dist/esm/src/hooks/pickaxe/useResponseContext.d.ts +8 -4
  158. package/dist/esm/src/hooks/pickaxe/useSubmit.d.ts +10 -8
  159. package/dist/esm/src/hooks/pickaxe/useSubmitDocument.d.ts +7 -7
  160. package/dist/esm/src/index.d.ts +1 -0
  161. package/dist/esm/src/types/form.d.ts +0 -10
  162. package/dist/esm/src/types/history.d.ts +56 -30
  163. package/dist/esm/src/types/pickaxe.d.ts +1 -1
  164. package/dist/esm/src/types/response.d.ts +11 -0
  165. package/package.json +1 -1
  166. package/dist/cjs/common/api/index.js +0 -1
  167. package/dist/cjs/common/api/streamer.js +0 -1
  168. package/dist/cjs/common/lotties/loader-black.js +0 -1
  169. package/dist/cjs/common/lotties/loader-white.js +0 -1
  170. package/dist/cjs/components/Pickaxe/common/PickaxeLottie.js +0 -1
  171. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/common/Action.js +0 -1
  172. package/dist/cjs/components/Pickaxe/utils/iframe.js +0 -1
  173. package/dist/cjs/hooks/pickaxe/useCreateFeedbackPayload.js +0 -1
  174. package/dist/cjs/hooks/pickaxe/useSubmitFeedback.js +0 -1
  175. package/dist/cjs/hooks/pickaxe/useThumbSelection.js +0 -1
  176. package/dist/cjs/src/common/api/index.d.ts +0 -2
  177. package/dist/cjs/src/common/api/streamer.d.ts +0 -8
  178. package/dist/cjs/src/common/lotties/loader-black.d.ts +0 -429
  179. package/dist/cjs/src/common/lotties/loader-white.d.ts +0 -429
  180. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/Action.d.ts +0 -5
  181. package/dist/cjs/src/components/Pickaxe/utils/iframe.d.ts +0 -1
  182. package/dist/cjs/src/hooks/pickaxe/useCreateFeedbackPayload.d.ts +0 -8
  183. package/dist/cjs/src/hooks/pickaxe/useSubmitFeedback.d.ts +0 -16
  184. package/dist/cjs/src/types/chat.d.ts +0 -10
  185. package/dist/esm/common/api/index.js +0 -1
  186. package/dist/esm/common/api/streamer.js +0 -1
  187. package/dist/esm/common/lotties/loader-black.js +0 -1
  188. package/dist/esm/common/lotties/loader-white.js +0 -1
  189. package/dist/esm/components/Pickaxe/common/PickaxeLottie.js +0 -1
  190. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/common/Action.js +0 -1
  191. package/dist/esm/components/Pickaxe/utils/iframe.js +0 -1
  192. package/dist/esm/hooks/pickaxe/useCreateFeedbackPayload.js +0 -1
  193. package/dist/esm/hooks/pickaxe/useSubmitFeedback.js +0 -1
  194. package/dist/esm/hooks/pickaxe/useThumbSelection.js +0 -1
  195. package/dist/esm/src/common/api/index.d.ts +0 -2
  196. package/dist/esm/src/common/api/streamer.d.ts +0 -8
  197. package/dist/esm/src/common/lotties/loader-black.d.ts +0 -429
  198. package/dist/esm/src/common/lotties/loader-white.d.ts +0 -429
  199. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/Action.d.ts +0 -5
  200. package/dist/esm/src/components/Pickaxe/utils/iframe.d.ts +0 -1
  201. package/dist/esm/src/hooks/pickaxe/useCreateFeedbackPayload.d.ts +0 -8
  202. package/dist/esm/src/hooks/pickaxe/useSubmitFeedback.d.ts +0 -16
  203. package/dist/esm/src/types/chat.d.ts +0 -10
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as n}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as r}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as c}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as m}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as p}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as u}from"framer-motion";import f from"../../../Icons/lock.svg.js";import g from"../../../Core/ErrorAlert.js";import x from"../../common/PickaxeHead.js";import j from"../../common/PickaxeEmbedHead.js";import b from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import v from"../../common/PickaxeHistoryButton.js";import k from"../../Addons/Scroll/ScrollLockView.js";import w from"../../Addons/Artifact/Renderer/index.js";import N from"./Message.js";import O from"./CustomMessage.js";import C from"../../Addons/IceBreaker/index.js";import S from"../../common/PickaxeBranding.js";import A from"../../../../common/cn.js";const I=({additionalScrollHeight:I,isForceHideInfo:P,isInputFocused:R,onSubmit:H})=>{var L,B,E;const{chatId:T,deploymentType:D,pickaxe:$,colors:z,translations:F,misc:W,isNewChat:M,isRtl:U,isEmbed:V,isEmailLogin:_,isShowIceBreaker:q,setChatId:G,setLastChatId:J}=t(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=o(),{onSend:ee}=n(),{scrollContainerRef:se}=c(),{messages:ie,status:ae,limitData:te,error:oe}=l(),{height:ne,width:le}=r(),{currentArtifact:re,chatPopupType:ce,currentPopupType:de}=p(),me=m(),pe=d(),he=a((()=>(null==$?void 0:$.icebreakers)?$.icebreakers.slice(0,3):[]),[null==$?void 0:$.icebreakers]),ue=a((()=>{const e=!!me.data&&me.data.messages.length>1;return!P&&me.isSuccess&&M&&!e}),[P,me.isSuccess,M,me.data]),fe=a((()=>{var e,s;return!!ie.length&&!(null!==(s=null===(e=null==ie?void 0:ie[ie.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[ie]),ge=a((()=>!!me.data&&me.data.messages.some((e=>"intromessage"===e.area))),[me.data]),xe=()=>{J(T),G("")},je="chat-input"===D&&_&&Q&&Z,be=q&&!R&&!ge&&ue&&le>767,ye=q&&!R&&(ge||le<=767);return e("div",Object.assign({ref:se,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-4 scrollbar scrollbar-thin",style:{height:`calc(${ne}px - 74px)`,paddingBottom:`${I+16}px`}},{children:[s(h,{children:!!re&&"inline"===de&&s(u.div,Object.assign({className:A("absolute top-0 z-20 w-full px-4 py-2",ce),style:{height:`calc(${ne-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(w,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[ue&&V&&s("div",Object.assign({className:A("absolute right-4 top-3 flex items-center gap-2","popup"===D&&"right-12")},{children:s(v,{tip:(null==F?void 0:F["chat-history"])||"Chat History",onClick:xe})})),s(x,Object.assign({className:A("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",ue&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!je&&{onIconClick:xe})),V&&!me.isLoading&&s(j,Object.assign({className:A("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!ue&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==F?void 0:F["chat-history"])||"Chat History"},!je&&{onIconClick:xe,onHistoryClick:xe})),e("div",Object.assign({className:A("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",V&&!me.isLoading&&!ue&&"mt-0")},{children:[be&&s("div",Object.assign({className:A("grid grid-cols-3 gap-4",2===he.length&&"grid-cols-2",1===he.length&&"grid-cols-1")},{children:s(C,{type:"center",data:he,onSend:H})})),je?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(O,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(f,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:K}))]}))})),s(O,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(L=null==F?void 0:F["we-sent-your-an-activation-link"])&&void 0!==L?L:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Y||X||ee(!0)}},{children:X?null!==(B=null==F?void 0:F.resending)&&void 0!==B?B:"Resending...":null!==(E=null==F?void 0:F.resend)&&void 0!==E?E:"Resend"}))]}))}))]}))})):s(i,{children:me.isLoading&&!(null==$?void 0:$.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[M&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):me.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:A(pe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):me.data?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[me.data.messages.map(((e,i)=>s(N,{index:i,message:e},i))),ie.map(((e,i)=>s(N,{index:me.data.messages.length+i,message:e},i))),"fetching"===ae||fe?s(O,Object.assign({chatRole:"assistant"},{children:s("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((e,i)=>s("div",{className:A("h-1.5 w-1.5 animate-dot rounded-full",1===i&&"animate-dot-down"),style:{backgroundColor:z.secondaryText}},i)))}))})):te?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(b,{})})):oe?s("div",Object.assign({className:A("flex items-center gap-x-3",U?"justify-end":"justify-start")},{children:s(g,{error:oe})})):null]})),e("div",Object.assign({className:A("flex flex-col",!W.isWhiteLabel||ye&&"mt-4")},{children:[!W.isWhiteLabel&&s(S,{containerClassName:A("justify-end",ye&&"mb-2")}),ye&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(C,{type:"right",data:he,onSend:H})})),s(k,{})]}))]})):null})]}))]}))]}))};export{I as default};
1
+ import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as r}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as c}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as m}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as p}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as u,motion as h}from"framer-motion";import f from"../../../Icons/lock.svg.js";import g from"../../../Core/ErrorAlert.js";import x from"../../common/PickaxeHead.js";import j from"../../common/PickaxeEmbedHead.js";import b from"../../common/PickaxeUpgradeCard.js";import v from"../../common/PickaxeSkeleton.js";import y from"../../common/PickaxeHistoryButton.js";import k from"../../Addons/Scroll/ScrollLockView.js";import w from"../../Addons/Artifact/Renderer/index.js";import N from"./Message.js";import O from"./CustomMessage.js";import C from"../../Addons/IceBreaker/index.js";import S from"../../common/PickaxeBranding.js";import A from"../../../../common/cn.js";const I=({additionalScrollHeight:I,isForceHideInfo:P,isInputFocused:L,onSubmit:H})=>{var R,B,E,D,T;const{sessionId:$,deploymentType:z,pickaxe:F,translations:M,misc:W,isNewChat:U,isRtl:V,isEmbed:_,isEmailLogin:q,isShowIceBreaker:G,setSessionId:J,setLastSessionId:K}=t(),{emailInput:Q,isLoggedOut:X,isSending:Y,isResendDisabled:Z,isSent:ee}=o(),{onSend:se}=l(),{scrollContainerRef:ie}=c(),{messages:ae,limitData:te,error:oe}=n(),{height:le,width:ne}=r(),{currentArtifact:re,chatPopupType:ce,currentPopupType:de}=p(),me=m(),pe=d(),ue=a((()=>(null==F?void 0:F.icebreakers)?F.icebreakers.slice(0,3):[]),[null==F?void 0:F.icebreakers]),he=a((()=>{const e=!!me.data&&me.data.messages.length>1;return!P&&me.isSuccess&&U&&!e}),[P,me.isSuccess,U,me.data]),fe=a((()=>!(null==F?void 0:F.chatflag)&&(null==F?void 0:F.enablechatresponses)&&ae.length>0),[F,ae]),ge=a((()=>!!me.data&&me.data.messages.some((e=>"intromessage"===e.area))),[me.data]),xe="chat-input"===z&&q&&X&&ee,je=G&&!L&&!ge&&he&&ne>767,be=G&&!L&&(ge||ne<=767),ve=()=>{K($),J("")};return e("div",Object.assign({ref:ie,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-4 scrollbar scrollbar-thin",style:{height:`calc(${le}px - 74px)`,paddingBottom:`${I+16}px`}},{children:[s(u,{children:!!re&&"inline"===de&&s(h.div,Object.assign({className:A("absolute top-0 z-20 w-full px-4 py-2",ce),style:{height:`calc(${le-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(w,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[he&&_&&s("div",Object.assign({className:A("absolute right-4 top-3 flex items-center gap-2","popup"===z&&"right-12")},{children:s(y,{tip:(null==M?void 0:M["chat-history"])||"Chat History",onClick:ve})})),s(x,Object.assign({className:A("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",he&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!xe&&{onIconClick:ve})),_&&!me.isLoading&&s(j,Object.assign({className:A("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!he&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==M?void 0:M["chat-history"])||"Chat History"},!xe&&{onIconClick:ve,onHistoryClick:ve})),e("div",Object.assign({className:A("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",_&&!me.isLoading&&!he&&"mt-0")},{children:[je&&s("div",Object.assign({className:A("grid grid-cols-3 gap-4",2===ue.length&&"grid-cols-2",1===ue.length&&"grid-cols-1")},{children:s(C,{type:"center",data:ue,onSend:H})})),xe?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(O,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(f,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Q}))]}))})),s(O,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(E=null==M?void 0:M["we-sent-your-an-activation-link"])&&void 0!==E?E:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Z||Y||se(!0)}},{children:Y?null!==(D=null==M?void 0:M.resending)&&void 0!==D?D:"Resending...":null!==(T=null==M?void 0:M.resend)&&void 0!==T?T:"Resend"}))]}))}))]}))})):s(i,{children:me.isLoading&&!(null==F?void 0:F.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[U&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(v,{className:"w-[72px] h-[72px]"}),s(v,{className:"h-[20px] mt-6 w-full"}),s(v,{className:"h-[20px] mt-2 w-full"}),s(v,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(v,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(v,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(v,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):me.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:A(pe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):me.data||fe?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(B=null===(R=me.data)||void 0===R?void 0:R.messages)&&void 0!==B?B:[]).map(((e,i)=>s(N,{index:i,message:e},i))),ae.map(((e,i)=>{var a,t;return s(N,{index:(null!==(t=null===(a=me.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:e,isLastMessage:i===ae.length-1},i)})),te?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(b,{})})):oe?s("div",Object.assign({className:A("flex items-center gap-x-3",V?"justify-end":"justify-start")},{children:s(g,{error:oe})})):null]})),e("div",Object.assign({className:A("flex flex-col",!W.isWhiteLabel||be&&"mt-4")},{children:[!W.isWhiteLabel&&s(S,{containerClassName:A("justify-end",be&&"mb-2")}),be&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(C,{type:"right",data:ue,onSend:H})})),s(k,{})]}))]})):null})]}))]}))]}))};export{I as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as o,Fragment as s}from"react/jsx-runtime";import{forwardRef as r,useState as i,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import{usePickaxeContext as u}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useAuthContext as h}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as v}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as b}from"../Addons/Document/hooks/useDocument.js";import{useScroll as j}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as y}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useSpeechRecognition as x}from"../../../hooks/pickaxe/useSpeechRecognition.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{useMediaQuery as O}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as w,allowedImageMimeTypes as S,additionalAllowedFileExtensions as C}from"../../../common/documents.js";import{createParser as I}from"eventsource-parser";import N from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import D from"../../Icons/microphone.svg.js";import E from"../../Icons/stop.svg.js";import T from"../Addons/Document/List.js";import L from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import W from"../../../common/error.js";import $ from"../../../common/cn.js";const H=r((({onFocus:r,onBlur:H,onInputHeightChange:F},B)=>{var P,U,J;const{formId:_,chatId:M,userId:z,studioUserId:G,embedUserId:K,deploymentId:Q,deploymentType:V,pickaxe:q,styles:X,colors:Y,studioLang:Z,forceMobile:ee,isNewChat:te,isRtl:ne,isEmailLogin:oe,isShowFeedbackMessage:se,setIsNewChat:re,setIsShowIceBreaker:ie,onGenerateComplete:ae}=u(),{token:le,isLoggedOut:ce,isSent:de}=h(),{messages:ue,status:me,limits:fe,isGenerating:pe,setMessages:ge,setStatus:he,setLimitData:ve,setError:be}=m(),{documents:je,isUploading:ye,isImageUploadAllowed:xe,documentError:ke,onFileUpload:Oe,setDocuments:we,setDocumentError:Se}=b(),{scrollStartSession:Ce,scrollEndSession:Ie,scrollToBottom:Ne}=j({auto:!0}),{artifacts:Ae,currentPopupType:De,setArtifacts:Ee,setCurrentArtifact:Te}=y(),Le=g(),Re=v(),[We,$e]=i(""),[He,Fe]=i(!1),[Be,Pe]=i(!1),Ue=a(null),Je=a(""),_e=a(null),Me=a(null),ze=a(null),{isSupported:Ge,isListening:Ke,finalTranscript:Qe,interimTranscript:Ve,startListening:qe,stopListening:Xe}=x({lang:Z||"en"}),[Ye]=O("(max-width: 899px)"),Ze=k(),{isHover:et}=Ze,tt=e(Ze,["isHover"]),nt=k(),{isHover:ot}=nt,st=e(nt,["isHover"]),rt=k(),{isHover:it}=rt,at=e(rt,["isHover"]),[lt,ct]=i(!1),dt=p(),ut=f(),mt=null===(P=null==q?void 0:q.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),ft=Ge&&(null==q?void 0:q.enablevoicetotext),pt="chat-input"===V&&te&&!de,gt="chat-input"===V&&oe&&ce&&de,ht=He||Be,vt=l((()=>{var e,t,n;return!!te&&(!!q&&(!Le.isLoading&&(!((null!==(t=null===(e=Le.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=q.icebreakers)||void 0===n?void 0:n.length)&&(!se&&!pt)))))}),[q,te,se,pt,Le.data,Le.isLoading]),bt=l((()=>{if(pe||ye)return!1;const e=je.length>0&&je.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!We.trim()&&!e)&&je.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[pe,ye,We,je]);c(B,(()=>({onSubmit:jt}))),d((()=>{ie(vt)}),[vt]),d((()=>{if(!Ke)return;const e=`${Je.current} ${Qe} ${Ve}`.trim();$e(e)}),[Qe,Ve,Ke]),d((()=>{!Ke&&Je.current&&($e(`${Je.current} ${Qe}`.trim()),Je.current="")}),[Ke,Qe]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;We.includes("\n")||je.length?e=!0:We.trim()||(e=!1),Fe(e)})()}),[We,je]),d((()=>{const e=Me.current,t=ze.current;if(!e||!t||He||We.includes("\n"))return void Pe(!1);const n=window.getComputedStyle(e),o=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,s=document.createElement("span");Object.assign(s.style,{font:o,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),s.textContent=We,document.body.appendChild(s);const r=s.offsetWidth;s.remove();const i=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-i-a-t.offsetWidth;Pe(r>l)}),[We,He]);const jt=e=>t(void 0,void 0,void 0,(function*(){var t,n;try{if("idle"!==me||ye)return;const o=je.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),s=o.length>0&&o.every((e=>e.startsWith("IMAGE-"))),r=null!=e?e:We;if(!r&&!s)return;be(""),Se(""),ve(null),$e(""),re(!1),he("fetching"),Ce(),Ne();const i=null!==(n=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,a=[...Array.from(ue),Object.assign({id:ue.length+1,role:"user",content:r},i&&{documentIds:o})];ge(a),Ne(),i&&we([]);const l=(yield Re.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:_,responseId:M,value:r},i&&{documentIds:o}),z&&{userId:z}),G&&{studioUserId:G}),K&&{embedUserId:K}),le&&{studioSessionToken:le}),Q&&{deploymentId:Q}))).body;if(!l)throw new Error("Streaming error");const c=a.length,d=new TextDecoder;_e.current=l.getReader();let u="",m=!0,f=!1,p=[...null!=Ae?Ae:[]];const g=I({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");u+=t,ge([...a.slice(0,c),{id:ue.length+1,role:"assistant",content:u}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee(p),De.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ee(p),De.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee(p),De.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");p=p.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),Ee(p)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ee(p.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);be(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m&&_e.current;){const{value:e,done:t}=yield _e.current.read();if(t){m=!1;break}const n=d.decode(e);n&&(f||(he("streaming"),f=!0),g.feed(n))}null==ae||ae(M)}catch(e){if("AbortError"===e.name)return void console.log("Stream stopped by user.");let t=W(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(fe).find((([e])=>t.includes(e)));n?ve(n[1]):be(t)}finally{Ne(),he("idle"),Ie(),_e.current=null}}));return gt?null:n("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!pt&&"px-4 pb-4"),dir:ne?"rtl":"ltr"},{children:o("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[o("div",Object.assign({className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===X.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ut),lt&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ct(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ct(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),ct(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),ct(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(re(!1),yield Oe(t))}))},{children:[Ke&&o("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(U=Y.accent)&&void 0!==U?U:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Y.text+"90"}},{children:"Listening..."}))]})),"idle"===me&&je.length>0&&n(T,{className:"p-4 pb-0",isDisabled:"idle"!==me}),n(L,Object.assign({ref:Me,className:$(dt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!We.trim()&&!We.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",ne?"text-right":"text-left",ht&&"mb-12",Ke&&"text-transparent"),value:We,placeholder:null!==(J=null==q?void 0:q.placeholdertext)&&void 0!==J?J:ne?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if($e(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let n=0;t>1&&(n=50),F(24*(t-1)+n)}},onKeyDown:e=>{ee||Ye||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ye||"idle"!==me||jt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),re(!1),yield Oe(t))}))},r&&{onFocus:r},H&&{onBlur:H},{dir:ne?"rtl":"ltr"})),n("div",Object.assign({ref:ze,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ht?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ht&&ut.backgroundColor&&{backgroundColor:ut.backgroundColor}),{borderTopRightRadius:X.cornerRadius+"px",borderBottomRightRadius:X.cornerRadius+"px"})},{children:pe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{_e.current&&(_e.current.cancel(),_e.current=null),he("idle")},style:{backgroundColor:Y.accent,color:Y.accentText}},{children:n(E,{className:"h-4 w-4 shrink-0"})})):Ke?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Xe,style:{backgroundColor:Y.accent,color:Y.accentText}},{children:n(E,{className:"h-4 w-4 shrink-0"})})):o(s,{children:[mt&&o("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ot?Y.accent+"10":void 0,color:ot?Y.accent:Y.accent+"80"},disabled:ye||"idle"!==me,onClick:()=>{var e;return null===(e=Ue.current)||void 0===e?void 0:e.click()}},st,{children:[n("input",{id:"file-upload",ref:Ue,type:"file",accept:[...w,...xe?S:[],...C].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){re(!1),yield Oe(Array.from(e.target.files||[])),e.target.value=""}))}),n(N,{className:"h-6 w-6 shrink-0"})]})),ft&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ke?Y.accent:it?Y.accent+"10":void 0,color:Ke?Y.accentText:it?Y.accent:Y.accent+"80"},disabled:ye||"idle"!==me,onClick:()=>{Ke?Xe():(Je.current=We,qe())}},at,{children:n(D,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:et||bt?Y.accent:Y.accent+"10",color:et||bt?Y.accentText:Y.accent+"80"},disabled:!bt,onClick:()=>jt()},tt,{children:n(A,{className:$("h-6 w-6 shrink-0",ne&&"scale-x-[-1] transform")})}))]})}))]})),ke&&n(R,{error:ke,className:"mt-3"})]}))}))}));H.displayName="Input";export{H as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as n,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import{usePickaxeContext as u}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as p}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as f}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useAuthContext as h}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as v}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as b}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useSpeechRecognition as x}from"../../../hooks/pickaxe/useSpeechRecognition.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{useMediaQuery as O}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as w,allowedImageMimeTypes as S,additionalAllowedFileExtensions as C}from"../../../common/documents.js";import{createParser as N}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import D from"../../Icons/microphone.svg.js";import E from"../../Icons/stop.svg.js";import T from"../Addons/Document/List.js";import W from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const H=i((({onFocus:i,onBlur:H,onInputHeightChange:F},J)=>{var P,B,V;const{origin:_,pickaxeId:M,sessionId:z,sender:G,senderType:U,deploymentId:K,deploymentType:Q,pickaxe:q,styles:X,colors:Y,locale:Z,forceMobile:ee,isNewChat:te,isRtl:se,isEmailLogin:ne,isShowFeedbackMessage:oe,setIsNewChat:ie,setIsShowIceBreaker:re,onGenerateComplete:ae}=u(),{token:le,isLoggedOut:ce,isSent:de}=h(),{messages:ue,limits:pe,isGenerating:me,setMessages:fe,setStatus:ge,setLimitData:he,setError:ve}=p(),{documents:be,isUploading:ye,isImageUploadAllowed:je,documentError:xe,onFileUpload:ke,setDocuments:Oe,setDocumentError:we}=b(),{scrollStartSession:Se,scrollEndSession:Ce,scrollToBottom:Ne}=y({auto:!0}),{artifacts:Ie,currentPopupType:Ae,setArtifacts:De,setCurrentArtifact:Ee}=j(),Te=g(),We=v(),[Re,Le]=r(""),[$e,He]=r(!1),[Fe,Je]=r(!1),Pe=a(null),Be=a(""),Ve=a(null),_e=a(null),Me=a(null),{isSupported:ze,isListening:Ge,finalTranscript:Ue,interimTranscript:Ke,startListening:Qe,stopListening:qe}=x({lang:Z}),[Xe]=O("(max-width: 480px)"),Ye=k(),{isHover:Ze}=Ye,et=e(Ye,["isHover"]),tt=k(),{isHover:st}=tt,nt=e(tt,["isHover"]),ot=k(),{isHover:it}=ot,rt=e(ot,["isHover"]),[at,lt]=r(!1),ct=f(),dt=m(),ut=null===(P=null==q?void 0:q.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),pt=ze&&(null==q?void 0:q.enablevoicetotext),mt="chat-input"===Q&&te&&!de,ft="chat-input"===Q&&ne&&ce&&de,gt=$e||Fe,ht=l((()=>{var e,t,s;return!!te&&(!!q&&(!Te.isLoading&&(!((null!==(t=null===(e=Te.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=q.icebreakers)||void 0===s?void 0:s.length)&&(!oe&&!mt)))))}),[q,te,oe,mt,Te.data,Te.isLoading]),vt=l((()=>{if(me||ye)return!1;const e=be.length>0&&be.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Re.trim()&&!e)&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[me,ye,Re,be]);c(J,(()=>({onSubmit:bt}))),d((()=>{re(ht)}),[ht]),d((()=>{if(!Ge)return;const e=`${Be.current} ${Ue} ${Ke}`.trim();Le(e)}),[Ue,Ke,Ge]),d((()=>{!Ge&&Be.current&&(Le(`${Be.current} ${Ue}`.trim()),Be.current="")}),[Ge,Ue]),d((()=>{if(!_e.current)return;(()=>{if(!_e.current)return;let e=_e.current.scrollHeight>52;Re.includes("\n")||be.length?e=!0:Re.trim()||(e=!1),He(e)})()}),[Re,be]),d((()=>{const e=_e.current,t=Me.current;if(!e||!t||$e||Re.includes("\n"))return void Je(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Re,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Je(i>l)}),[Re,$e]);const bt=e=>t(void 0,void 0,void 0,(function*(){var t,s;try{if(me||ye)return;const n=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),i=null!=e?e:Re;if(!i&&!o)return;ve(""),we(""),he(null),Le(""),ie(!1),ge("fetching"),Se(),Ne();const r=null!==(s=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,a=[...Array.from(ue),{id:ue.length+1,role:"user",parts:[{type:"text",content:i,isVisible:!0}],documentIds:r?n:[]},{id:ue.length+2,role:"assistant",parts:[],documentIds:[]}];fe(a),Ne(),r&&Oe([]);const l=(yield We.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:_,pickaxeId:M,sessionId:z,senderType:U,value:i},r&&{documentIds:n}),G&&{sender:G}),le&&{studioSessionToken:le}),K&&{deploymentId:K}))).body;if(!l)throw new Error("Streaming error");const c=a.length-1,d=new TextDecoder;Ve.current=l.getReader();const u=[];let p="",m=!0,f=!1,g=[...null!=Ie?Ie:[]];const h=N({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)p="",u.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("text-delta"===n.type)p+=n.delta,u[u.length-1].content=p,fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("text-end"===n.type)p="";else if("reasoning-start"===n.type)p="",u.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("reasoning-delta"===n.type)p+=n.delta,u[u.length-1].content=p,fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("reasoning-end"===n.type)p="";else if(n.type.startsWith("data-")){const e=n;u.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})])}}else if("artifact_created"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),De(g),Ae.startsWith("inline")||Ee({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),De(g),Ae.startsWith("inline")||Ee({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),De(g),Ae.startsWith("inline")||Ee({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");g=g.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),De(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);De(g.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);ve(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m&&Ve.current;){const{value:e,done:t}=yield Ve.current.read();if(t){m=!1;break}const s=d.decode(e);s&&(f||(ge("streaming"),f=!0),h.feed(s))}null==ae||ae(z)}catch(e){if("AbortError"===e.name)return;let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(pe).find((([e])=>t.includes(e)));s?he(s[1]):ve(t)}finally{Ne(),ge("idle"),Ce(),Ve.current=null}}));return ft?null:s("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!mt&&"px-4 pb-4"),dir:se?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===X.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},dt),at&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),lt(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),lt(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),lt(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),lt(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(ie(!1),yield ke(t))}))},{children:[Ge&&n("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(B=Y.accent)&&void 0!==B?B:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Y.text+"90"}},{children:"Listening..."}))]})),!me&&be.length>0&&s(T,{className:"p-4 pb-0",isDisabled:me}),s(W,Object.assign({ref:_e,className:$(ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Re.trim()&&!Re.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",se?"text-right":"text-left",gt&&"mb-12",Ge&&"text-transparent"),value:Re,placeholder:null!==(V=null==q?void 0:q.placeholdertext)&&void 0!==V?V:se?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Le(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let s=0;t>1&&(s=50),F(24*(t-1)+s)}},onKeyDown:e=>{ee||Xe||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ye||me||bt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),ie(!1),yield ke(t))}))},i&&{onFocus:i},H&&{onBlur:H},{dir:se?"rtl":"ltr"})),s("div",Object.assign({ref:Me,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",gt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!gt&&dt.backgroundColor&&{backgroundColor:dt.backgroundColor}),{borderTopRightRadius:X.cornerRadius+"px",borderBottomRightRadius:X.cornerRadius+"px"})},{children:me?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ve.current&&(Ve.current.cancel(),Ve.current=null),ge("idle")},style:{backgroundColor:Y.accent,color:Y.accentText}},{children:s(E,{className:"h-4 w-4 shrink-0"})})):Ge?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:qe,style:{backgroundColor:Y.accent,color:Y.accentText}},{children:s(E,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[ut&&n("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:st?Y.accent+"10":void 0,color:st?Y.accent:Y.accent+"80"},disabled:ye||me,onClick:()=>{var e;return null===(e=Pe.current)||void 0===e?void 0:e.click()}},nt,{children:[s("input",{id:"file-upload",ref:Pe,type:"file",accept:[...w,...je?S:[],...C].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){ie(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),pt&&s("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ge?Y.accent:it?Y.accent+"10":void 0,color:Ge?Y.accentText:it?Y.accent:Y.accent+"80"},disabled:ye||me,onClick:()=>{Ge?qe():(Be.current=Re,Qe())}},rt,{children:s(D,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ze||vt?Y.accent:Y.accent+"10",color:Ze||vt?Y.accentText:Y.accent+"80"},disabled:!vt,onClick:()=>bt()},et,{children:s(A,{className:$("h-6 w-6 shrink-0",se&&"scale-x-[-1] transform")})}))]})}))]})),xe&&s(R,{error:xe,className:"mt-3"})]}))}))}));H.displayName="Input";export{H as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as r}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as l}from"../../Addons/Artifact/hooks/useArtifact.js";import{format as a}from"date-fns";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as d}from"../../common/PickaxeMarkdown/Renderer.js";import m from"../../../Icons/visitor.svg.js";import p from"../../common/PickaxeIcon.js";import h from"../../../../common/cn.js";import u from"../../common/PickaxeMessageActions.js";const f=({item:f})=>{const{pickaxe:x,styles:g,colors:v,misc:b,translations:y,disableHtml:k,disableJs:j,disableCss:w,isRtl:N,setChatId:C,setIsNewChat:I}=t(),{setMessages:O}=i(),{setDocuments:A}=r(),{onLoadArtifact:M}=l(),$=n(),P=o((()=>a(f.createdAt,"hh:mm a MMM dd, yyy")),[f]),F=o((()=>f&&f.messages?f.messages.length:0),[f]),H=o((()=>{var e,s,o,t;if("form"===f.type){return(null!==(e=f.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]),R=o((()=>{var e,s,o,t;return"form"===f.type?null!==(e=f.questionResponse)&&void 0!==e?e:"":null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]);return e("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:v.primary,color:v.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(m,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${f.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:H.length<280}),s("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:H}}),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:h($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:h($.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:v.secondary,color:v.secondaryText}},{children:[b.isChatImage&&s(p,{src:null==x?void 0:x.chaticon,alt:`${null==x?void 0:x.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:v.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(c,Object.assign({theme:g.theme,colors:v,actions:!0},N&&{rtl:!0},k&&{disableHtml:!0},j&&{disableJs:!0},w&&{disableCss:!0},{onArtifactClick:M},{children:s(d,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",value:R})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s(u,{content:R,responseId:f.responseId,chatCount:F+1,onOpenChat:()=>{return e=f.responseId,A([]),O([]),I(!1),void C(e);var e},isForm:"form"===f.type}),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:h($.b3,"font-semibold uppercase opacity-30")},{children:P}))}))]}))]}))]}))]}))};export{f as default};
1
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as a}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as r}from"../../Addons/Artifact/hooks/useArtifact.js";import{format as l}from"date-fns";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import d from"../../../Icons/visitor.svg.js";import m from"../../common/PickaxeIcon.js";import p from"../../common/PickaxeMessageParts/index.js";import h from"../../common/PickaxeMessageActions.js";import f from"../../../../common/cn.js";const u=({item:u})=>{const{pickaxe:x,styles:g,colors:b,misc:k,translations:y,disableHtml:j,disableJs:v,disableCss:w,isRtl:N,setSessionId:O,setIsNewChat:C}=t(),{setMessages:I}=i(),{setDocuments:A}=a(),{onLoadArtifact:M}=r(),P=n(),$=o((()=>u&&u.messages?u.messages.length:0),[u]),F=o((()=>l(new Date(u.updatedAt),"hh:mm a MMM dd, yyy")),[u]),S=o((()=>{var e;if("FORM"===u.pickaxeType){return(null!==(e=u.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}const s=u.messages.find((e=>"user"===e.role));return s?s.parts[0].content:""}),[u]),T=o((()=>{if("FORM"===u.pickaxeType)return u.question.responseParts;const e=u.messages.find((e=>"assistant"===e.role));return e?e.parts:[]}),[u]);return e("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:b.primary,color:b.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(d,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${u.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:S.length<280}),s("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:S}}),s("label",Object.assign({htmlFor:`${u.sessionId}-input`,className:f(P.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:b.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${u.sessionId}-input`,className:f(P.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:b.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[k.isChatImage&&s(m,{src:null==x?void 0:x.chaticon,alt:`${null==x?void 0:x.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:b.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(c,Object.assign({theme:g.theme,colors:b},N&&{rtl:!0},j&&{disableHtml:!0},v&&{disableJs:!0},w&&{disableCss:!0},{onArtifactClick:M},{children:s(p,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:T})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s(h,{content:T.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:u.sessionId,messagesCount:$+1,onOpenChat:()=>{return e=u.sessionId,A([]),I([]),C(!1),void O(e);var e}}),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:f(P.b3,"font-semibold uppercase opacity-30")},{children:F}))}))]}))]}))]}))]}))};export{u as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as r}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as a}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as d}from"../../common/PickaxeMarkdown/Renderer.js";import{format as m}from"date-fns";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../Addons/Scroll/ScrollLockView.js";import u from"../../../../common/cn.js";import x from"../../common/PickaxeMessageActions.js";const b=()=>{const{pickaxe:b,styles:g,colors:v,misc:j,translations:k,disableHtml:y,disableJs:w,disableCss:N,isRtl:C,setChatId:O,setIsNewChat:I}=t(),{response:A}=i(),{scrollTargetRef:D}=r(),{setDocuments:S}=l(),{onLoadArtifact:M}=a(),R=n(),$=o((()=>m(A?A.sentAt:new Date,"hh:mm a MMM dd, yy")),[A]),P=o((()=>{var e;if(!A)return"";return(null!==(e=A.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[A]);return A?e("div",Object.assign({ref:D,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:v.primary,color:v.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${A.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:P.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:P}}),s("label",Object.assign({htmlFor:`${A.responseId}-input`,className:u(R.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:v.accent}},{children:(null==k?void 0:k["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${A.responseId}-input`,className:u(R.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:v.accent}},{children:(null==k?void 0:k["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:v.secondary,color:v.secondaryText}},{children:[j.isChatImage&&s(h,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:v.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(c,Object.assign({theme:g.theme,colors:v,actions:!0},C&&{rtl:!0},y&&{disableHtml:!0},w&&{disableJs:!0},N&&{disableCss:!0},{onArtifactClick:M},{children:s(d,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",value:A.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s("div",Object.assign({className:"flex items-center gap-3"},{children:s(x,{content:A.questionResponse,responseId:A.responseId,onOpenChat:()=>{return e=A.responseId,S([]),I(!1),void O(e);var e},chatCount:A.messageCount+1,isForm:!(null==b?void 0:b.chatflag)})})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:u(R.b3,"font-semibold uppercase opacity-30")},{children:$}))}))]}))]}))]})),s(f,{})]})):null};export{b as default};
1
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as a}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as r}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as l}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{format as d}from"date-fns";import m from"../../../Icons/visitor.svg.js";import p from"../../common/PickaxeIcon.js";import h from"../../Addons/Scroll/ScrollLockView.js";import f from"../../common/PickaxeMessageParts/index.js";import u from"../../common/PickaxeMessageActions.js";import x from"../../../../common/cn.js";const b=()=>{const{pickaxe:b,styles:g,colors:j,misc:v,translations:k,disableHtml:y,disableJs:w,disableCss:N,isRtl:C,setSessionId:O,setIsNewChat:I}=t(),{response:A,isGenerating:S}=i(),{scrollTargetRef:D}=a(),{setDocuments:P}=r(),{onLoadArtifact:M}=l(),$=n(),T=o((()=>d(A?A.sentAt:new Date,"hh:mm a MMM dd, yy")),[A]),q=o((()=>{var e;if(!A)return"";return(null!==(e=A.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[A]);return A?e("div",Object.assign({ref:D,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:j.primary,color:j.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(m,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${A.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:q.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:q}}),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:x($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:j.accent}},{children:(null==k?void 0:k["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:x($.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:j.accent}},{children:(null==k?void 0:k["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:j.secondary,color:j.secondaryText}},{children:[v.isChatImage&&s(p,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:j.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[s(c,Object.assign({theme:g.theme,colors:j},C&&{rtl:!0},y&&{disableHtml:!0},w&&{disableJs:!0},N&&{disableCss:!0},{onArtifactClick:M},{children:s(f,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:A.question.responseParts})})),s("div",Object.assign({className:"flex flex-col"},{children:S?s("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((e,o)=>s("div",{className:x("h-1.5 w-1.5 animate-dot rounded-full",1===o&&"animate-dot-down"),style:{backgroundColor:j.secondaryText}},o)))})):e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s("div",Object.assign({className:"flex items-center gap-3"},{children:s(u,{content:A.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:A.sessionId,messagesCount:A.messageCount+1,onOpenChat:()=>{return e=A.sessionId,P([]),I(!1),void O(e);var e}})})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:x($.b3,"font-semibold uppercase opacity-30")},{children:T}))}))]}))}))]}))]})),s(h,{})]})):null};export{b as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as t}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../hooks/pickaxe/useResponseContext.js";import{generateId as i}from"../../../common/utils.js";import a from"../common/PickaxeButton.js";import c from"../common/PickaxeBranding.js";const m=()=>{const{misc:m,translations:n,setChatId:r,setIsNewChat:l}=t(),{setMessages:x}=o();return e("div",Object.assign({className:"mt-4 flex flex-col items-center"},{children:s("div",Object.assign({className:"flex w-full max-w-[251px] flex-col gap-2"},{children:[!m.isWhiteLabel&&e(c,{}),e(a,Object.assign({className:"w-full",onClick:()=>{return e=i(20),x([]),r(e),void l(!0);var e}},{children:(null==n?void 0:n["new-chat"])||"New chat"}))]}))}))};export{m as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as t}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../hooks/pickaxe/useResponseContext.js";import{v4 as i}from"uuid";import a from"../common/PickaxeButton.js";import c from"../common/PickaxeBranding.js";const n=()=>{const{misc:n,translations:m,setSessionId:r,setIsNewChat:l}=t(),{setMessages:x}=o();return e("div",Object.assign({className:"mt-4 flex flex-col items-center"},{children:s("div",Object.assign({className:"flex w-full max-w-[251px] flex-col gap-2"},{children:[!n.isWhiteLabel&&e(c,{}),e(a,Object.assign({className:"w-full",onClick:()=>{x([]),r(i()),l(!0)}},{children:(null==m?void 0:m["new-chat"])||"New chat"}))]}))}))};export{n as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as s}from"react/jsx-runtime";import{useState as i}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as a}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as l}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as c}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as u}from"../../../../common/utils.js";import{encode as m}from"@nem035/gpt-3-encoder";import{createParser as p}from"eventsource-parser";import f from"../../common/PickaxeBranding.js";import g from"../../common/PickaxeButton.js";import h from"../../../../common/error.js";const v=({questions:v,resetQuestions:b})=>{var j;const{formId:O,userId:x,studioUserId:k,embedUserId:w,deploymentId:y,pickaxe:I,misc:S,translations:C,isRtl:A,setChatId:N,setIsNewChat:D,onGenerateComplete:E}=n(),{token:P}=o(),{status:R,limits:U,isGenerating:q,setResponse:J,setMessages:W,setStatus:_,setLimitData:T,setError:B}=r(),{documents:L,websiteLink:G,isUploading:M,onWebsiteUpload:K,setDocuments:Q,setDocumentError:X}=d(),{scrollStartSession:Y,scrollEndSession:z,scrollToTarget:F}=l({auto:!(null==I?void 0:I.enablechatresponses)}),{artifacts:H,currentPopupType:V,setArtifacts:Z,setCurrentArtifact:$}=c(),ee=a(),[te,se]=i(!1);return t("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:A?"rtl":"ltr"},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s(g,Object.assign({className:"px-5 min-h-[42px]",isDisabled:M||"idle"!==R||q||te,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,t;try{if("idle"!==R||M||te)return;B(""),X(""),T(null),J(null);const s=["Multiple Choice","Checkbox"];for(const e of v){if(m(e.input).length>e.maxLength&&!s.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=L.filter((e=>"finished"===e.status)),n=L.map((e=>e.name)),o=null!==(t=null===(e=null==I?void 0:I.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,r=v.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),a=u(G).filter((e=>!n.includes(e)));if(a.length){const e=a[a.length-1];se(!0);const t=yield K(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),se(!1)}else if(r&&o&&!i.length)return void X("Please paste a valid website/video link or drag a file to add to the knowledge base.");const d=i.map((e=>e.documentId)).filter(Boolean),l=o&&d.length>0;let c={};v.forEach((e=>c=Object.assign(Object.assign({},c),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input}))),_("fetching"),Y(),F();const f=yield ee.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:O,valueObj:c},l&&{documentIds:d}),x&&{userId:x}),k&&{studioUserId:k}),w&&{embedUserId:w}),P&&{studioSessionToken:P}),y&&{deploymentId:y})),g=f.body;if(!g)throw new Error("Streaming error");const h=f.headers.get("X-Pickaxe-Response-Id");if(!h)throw new Error("Response ID not found");const b=new TextDecoder,j=g.getReader();let S="",C=!0,A=!1,U=[...null!=H?H:[]];const q=p({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");S+=t,J({formId:O,responseId:h,documentIds:d,questions:v.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:S,messageCount:0,sentAt:new Date}),(null==I?void 0:I.enablechatresponses)&&W([{id:0,role:"assistant",content:S}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Z(U),V.startsWith("inline")||$({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Z(U),V.startsWith("inline")||$({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Z(U),V.startsWith("inline")||$({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");U=U.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Z(U)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Z(U.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);B(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(C=!1)}});for(;C;){const{value:e,done:t}=yield j.read();if(t){C=!1;break}const s=b.decode(e);s&&(A||(_("streaming"),A=!0,l&&Q([]),(null==I?void 0:I.enablechatresponses)&&(N(h),D(!1))),q.feed(s))}null==E||E(h)}catch(e){let t=h(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(U).find((([e])=>t.includes(e)));s?T(s[1]):B(t),F()}finally{_("idle"),se(!1),z()}}))},{children:te?(null==C?void 0:C.processing)||"Processing...":M?(null==C?void 0:C.uploading)||"Uploading...":"fetching"===R||"streaming"===R?(null==C?void 0:C.loading)||"Loading...":null!==(j=null==I?void 0:I.submittext)&&void 0!==j?j:"Submit"})),s(g,Object.assign({className:"min-h-[42px] px-5",isDisabled:M||"idle"!==R||q||te,onClick:b},{children:"Clear form"}))]})),!S.isWhiteLabel&&s(f,{containerClassName:"justify-end"})]}))};export{v as default};
1
+ import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t}from"react/jsx-runtime";import{useState as n,useMemo as i}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as l}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as c}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as p}from"../../../../common/utils.js";import{encode as m}from"@nem035/gpt-3-encoder";import{createParser as g}from"eventsource-parser";import f from"../../common/PickaxeBranding.js";import b from"../../common/PickaxeButton.js";import h from"../../../../common/error.js";const j=({questions:j,resetQuestions:v})=>{var O;const{origin:y,pickaxeId:x,sender:k,senderType:w,deploymentId:S,pickaxe:I,misc:q,translations:C,isRtl:P,setSessionId:A,setIsNewChat:N,onGenerateComplete:D}=o(),{token:E}=a(),{limits:T,isGenerating:J,setResponse:W,setMessages:_,setStatus:L,setLimitData:R,setError:U,setIsSwitchedToChat:V}=r(),{documents:B,websiteLink:G,isUploading:K,onWebsiteUpload:M,setDocuments:Q,setDocumentError:X}=d(),{scrollStartSession:Y,scrollEndSession:z,scrollToTarget:F}=c({auto:!(null==I?void 0:I.enablechatresponses)}),{artifacts:H,currentPopupType:Z,setArtifacts:$,setCurrentArtifact:ee}=u(),se=l(),[te,ne]=n(!1),ie=i((()=>j.some((e=>!("Short Answer"!==e.type&&"Long Answer"!==e.type&&"long"!==e.type&&"short"!==e.type&&"Checkbox"!==e.type&&"Knowledge Upload"!==e.type&&!e.id.includes("documentupload")||!(e.input.length>0))))),[j]);return s("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:P?"rtl":"ltr"},{children:[s("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t(b,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||J||te,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,s;try{if(J||K||te)return;U(""),X(""),R(null),W(null);const t=["Multiple Choice","Checkbox"];for(const e of j){if(m(e.input).length>e.maxLength&&!t.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const n=B.filter((e=>"finished"===e.status)),i=B.map((e=>e.name)),o=null!==(s=null===(e=null==I?void 0:I.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s,a=j.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),r=p(G).filter((e=>!i.includes(e)));if(r.length){const e=r[r.length-1];ne(!0);const s=yield M(e);s&&(n.push(s),yield new Promise((e=>setTimeout(e,5e3)))),ne(!1)}else if(a&&o&&!n.length)return void X("Please paste a valid website/video link or drag a file to add to the knowledge base.");const l=n.map((e=>e.documentId)).filter(Boolean),d=o&&l.length>0;let c={};j.forEach((e=>c=Object.assign(Object.assign({},c),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?n.map((e=>e.name)).join(",")||"":e.input}))),L("fetching"),Y(),F();const u=yield se.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:y,pickaxeId:x,senderType:w,valueObj:c},d&&{documentIds:l}),k&&{sender:k}),E&&{studioSessionToken:E}),S&&{deploymentId:S})),f=u.body;if(!f)throw new Error("Streaming error");const b=u.headers.get("X-Pickaxe-Session-Id");if(!b)throw new Error("Post SessionId not found");const h={sessionId:b,documentIds:d?l:[],question:{inputs:j.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[{type:"text",content:"",isVisible:!0}]},messageCount:0,sentAt:new Date};W(h);let v=[];(null==I?void 0:I.enablechatresponses)&&(v=[{id:0,role:"assistant",parts:[],documentIds:[]}],_(v));const O=new TextDecoder,q=f.getReader(),C=[];let P="",T=!0,z=!1,ie=[...null!=H?H:[]];const oe=g({onEvent:e=>{var s,t;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)P="",C.push({type:"text",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("text-delta"===n.type)P+=n.delta,C[C.length-1].content=P,W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("text-end"===n.type)P="";else if("reasoning-start"===n.type)P="",C.push({type:"reasoning",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("reasoning-delta"===n.type)P+=n.delta,C[C.length-1].content=P,W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("reasoning-end"===n.type)P="";else if(n.type.startsWith("data-")){const e=n;C.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}])}}else if("artifact_created"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_updated"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"updating"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_rewrite"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_content"===e.event){const s=JSON.parse(e.data),t=s.token.replace(/\u200B/g,"");ie=ie.map((e=>e.id===s.id&&e.version===s.version?Object.assign(Object.assign({},e),{content:e.content+t,status:"streaming"}):e)),$(ie)}else if("artifact_finished"===e.event){const s=JSON.parse(e.data);$(ie.map((e=>e.id===s.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const s=JSON.parse(e.data);U(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(T=!1)}});for(;T;){const{value:e,done:s}=yield q.read();if(s){T=!1;break}const t=O.decode(e);t&&(z||(L("streaming"),z=!0,d&&Q([]),(null==I?void 0:I.enablechatresponses)&&(A(b),N(!1),V(!0))),oe.feed(t))}null==D||D(b)}catch(e){let s=h(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(T).find((([e])=>s.includes(e)));t?R(t[1]):U(s),F()}finally{L("idle"),ne(!1),z()}}))},{children:te?(null==C?void 0:C.processing)||"Processing...":K?(null==C?void 0:C.uploading)||"Uploading...":J?(null==C?void 0:C.loading)||"Loading...":null!==(O=null==I?void 0:I.submittext)&&void 0!==O?O:"Submit"})),ie&&t(b,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||J||te,onClick:v},{children:"Clear form"}))]})),!q.isWhiteLabel&&t(f,{containerClassName:"justify-end"})]}))};export{j as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as r,useEffect as i,Fragment as s}from"react";import{usePickaxeContext as p}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import d from"../../../Core/ErrorAlert.js";import a from"../../common/PickaxeUpgradeCard.js";import l from"./Input.js";import m from"./Option.js";import u from"./Document.js";import c from"./Checkbox.js";import f from"./Submit.js";const x=()=>{const{pickaxe:x,translations:h}=p(),{error:g}=n(),[j,y]=o([]),[w,k]=o([]),q=e=>{y((t=>t.map((t=>t.id===e.id?e:t))))},C=r((()=>w),[w]);return i((()=>{if(!x)return;if(!x._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!x.updatedAt||new Date(x.updatedAt)<e,o=x._questions.map(((e,o)=>{var r;let i="";if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type){const t=e.example.split("S3P32X");t.includes(i)||(i=t[0])}let s=e.secondary||"";return t&&(s=e.secondary||("Knowledge Upload"===e.type?null!==(r=null==h?void 0:h["form-doc-placeholder"])&&void 0!==r?r:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:o+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:s},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));y(o),k(o)}),[x]),e("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[j.map(((e,o)=>"Multiple Choice"===e.type?t(s,{children:t(m,{field:e,update:q})},o):"Checkbox"===e.type?t(s,{children:t(c,{field:e,update:q})},o):"userinput:documentupload"===e.id?t(s,{children:t(u,{field:e,update:q})},o):t(s,{children:t(l,{field:e,update:q})},o))),t(d,{error:g}),t(a,{}),t(f,{questions:j,update:q,resetQuestions:()=>y(C)})]}))};export{x as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as i,useEffect as r,Fragment as p}from"react";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import d from"../../../Core/ErrorAlert.js";import a from"../../common/PickaxeUpgradeCard.js";import l from"./Input.js";import m from"./Option.js";import u from"./Document.js";import c from"./Checkbox.js";import f from"./Submit.js";const x=()=>{const{pickaxe:x,translations:h}=s(),{error:g}=n(),[j,y]=o([]),[w,k]=o([]),q=e=>{y((t=>t.map((t=>t.id===e.id?e:t))))},C=i((()=>w),[w]);return r((()=>{if(!x)return;if(!x._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!x.updatedAt||new Date(x.updatedAt)<e,o=x._questions.map(((e,o)=>{var i;let r="";if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)r="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(r)||(r=t[0])}let p=e.secondary||"";return t&&(p=e.secondary||("Knowledge Upload"===e.type?null!==(i=null==h?void 0:h["form-doc-placeholder"])&&void 0!==i?i:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:o+1,id:e.id,type:e.type,main:e.main,example:e.example,input:r,length:0,maxLength:parseInt(e.answerlength),placeholder:p},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));y(o),k(o)}),[x,h]),e("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[j.map(((e,o)=>"Multiple Choice"===e.type?t(p,{children:t(m,{field:e,update:q})},o):"Checkbox"===e.type?t(p,{children:t(c,{field:e,update:q})},o):"userinput:documentupload"===e.id?t(p,{children:t(u,{field:e,update:q})},o):t(p,{children:t(l,{field:e,update:q})},o))),t(d,{error:g}),t(a,{}),t(f,{questions:j,update:q,resetQuestions:()=>y(C)})]}))};export{x as default};
@@ -1 +1 @@
1
- import{jsxs as e,Fragment as t,jsx as i}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as l}from"../../../hooks/studio/useStyleFontSize.js";import o from"../common/PickaxeHead.js";import a from"../common/PickaxeEmbedHead.js";import r from"./History/index.js";import c from"./NewChat.js";import n from"./Questions/index.js";import m from"../../../common/cn.js";const x=()=>{const{pickaxe:x,lastChatId:p,responsiveBy:d,translations:f,isEmbed:h,setChatId:u}=s(),j=l(),b=h&&(null==x?void 0:x.chatflag);return e("div",Object.assign({className:m("relative flex w-full flex-col items-center pb-10",b?"pt-0":"pt-12","viewport"===d?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:[b?e(t,{children:[i(a,{className:"sticky top-0 z-10 w-full",historyBtnTip:(null==f?void 0:f["exit-chat-history"])||"Exit Chat History",onHistoryClick:()=>u(p)}),i("div",Object.assign({className:"relative flex min-h-[56px] w-full justify-end rounded-tl-lg rounded-tr-lg border-y p-4"},{children:i("p",Object.assign({className:m(j.b1,"absolute left-1/2 -translate-x-1/2 select-none text-center")},{children:(null==f?void 0:f["chat-history"])||"Chat History"}))}))]}):i("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:i(o,{})})),i("div",Object.assign({className:m("flex w-full flex-col items-center",b?"px-4":"px-6")},{children:i("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:e("div",Object.assign({className:m("flex flex-col gap-y-8","viewport"===d?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==x?void 0:x.chatflag)?i(c,{}):i(n,{}),i(r,{})]}))}))}))]}))};export{x as default};
1
+ import{jsxs as e,Fragment as t,jsx as i}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as l}from"../../../hooks/studio/useStyleFontSize.js";import o from"../common/PickaxeHead.js";import a from"../common/PickaxeEmbedHead.js";import r from"./History/index.js";import c from"./NewChat.js";import n from"./Questions/index.js";import m from"../../../common/cn.js";const x=()=>{const{lastSessionId:x,pickaxe:p,responsiveBy:d,translations:f,isEmbed:h,setSessionId:u}=s(),j=l(),b=h&&(null==p?void 0:p.chatflag);return e("div",Object.assign({className:m("relative flex w-full flex-col items-center pb-10",b?"pt-0":"pt-12","viewport"===d?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:[b?e(t,{children:[i(a,{className:"sticky top-0 z-10 w-full",historyBtnTip:(null==f?void 0:f["exit-chat-history"])||"Exit Chat History",onHistoryClick:()=>u(x)}),i("div",Object.assign({className:"relative flex min-h-[56px] w-full justify-end rounded-tl-lg rounded-tr-lg border-y p-4"},{children:i("p",Object.assign({className:m(j.b1,"absolute left-1/2 -translate-x-1/2 select-none text-center")},{children:(null==f?void 0:f["chat-history"])||"Chat History"}))}))]}):i("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:i(o,{})})),i("div",Object.assign({className:m("flex w-full flex-col items-center",b?"px-4":"px-6")},{children:i("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:e("div",Object.assign({className:m("flex flex-col gap-y-8","viewport"===d?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==p?void 0:p.chatflag)?i(c,{}):i(n,{}),i(r,{})]}))}))}))]}))};export{x as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useState as t,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import d from"./Addons/Document/Provider.js";import l from"./Addons/Auth/Provider.js";const c=o({}),m=({children:o,userId:m="",studioUserId:p="",deploymentId:h="",embedUserId:y="",deploymentType:u,deploymentDimensions:f,deploymentMisc:b,styles:g,colors:v,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:w,artifact:x={popupType:"auto"},responsiveBy:P="viewport",forceMobile:S=!1,disableHtml:k=!1,disableJs:j=!1,disableCss:C=!1,loadFont:D=!0,isRtl:L=!1,studioLang:H="en",opacity:R=1,isEmbed:E=!1,isDropShadow:O=!1,isEmailLogin:T=!1,onGenerateComplete:A})=>{const[M,U]=t(""),[B,N]=t(""),[W,G]=t(""),[J,_]=t(""),[z,Y]=t(null),[q,K]=t(!1),[Q,V]=t(!0),[X,Z]=t(!0),[$,ee]=t(!1);return s((()=>{K(!1)}),[null==g?void 0:g.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!q&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield import("webfontloader")).default.load({google:{families:[g.font]},active:()=>{K(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),K(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),K(!0)}}))}),[D,q,null==g?void 0:g.font]),i(c.Provider,Object.assign({value:Object.assign({formId:M,chatId:B,lastChatId:W,sessionId:J,userId:m,studioUserId:p,embedUserId:y,deploymentId:h,deploymentType:u,deploymentDimensions:f,deploymentMisc:b,pickaxe:z,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},w),artifact:x,responsiveBy:P,forceMobile:S,loadFont:D,disableHtml:k,disableJs:j,disableCss:C,isFontLoaded:q,isNewChat:Q,isShowIceBreaker:X,isShowFeedbackMessage:$,isRtl:L,studioLang:H,opacity:R,isEmbed:E,isDropShadow:O,isEmailLogin:T,setIsFontLoaded:K,setFormId:U,setChatId:N,setLastChatId:G,setSessionId:_,setPickaxe:Y,setIsNewChat:V,setIsShowIceBreaker:Z,setIsShowFeedbackMessage:ee},A&&{onGenerateComplete:A})},{children:i(l,{children:i(r,{children:i(a,Object.assign({limits:F},{children:i(d,{children:i(n,Object.assign({},x,{children:o}))})}))})})}))};export{c as PickaxeContext,m as PickaxeProvider};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useState as t,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import d from"./Addons/Document/Provider.js";import l from"./Addons/Auth/Provider.js";const c=o({}),m=({children:o,origin:m,sender:p,senderType:y,deploymentId:h,deploymentType:f,deploymentDimensions:u,deploymentMisc:b,styles:g,colors:v,limits:F={},misc:w={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:x,artifact:S={popupType:"auto"},responsiveBy:I="viewport",locale:k="en",opacity:P=1,forceMobile:j=!1,disableHtml:C=!1,disableJs:T=!1,disableCss:D=!1,loadFont:H=!0,isRtl:R=!1,isEmbed:E=!1,isDropShadow:L=!1,isEmailLogin:O=!1,allowGuestUsage:A=!0,onGenerateComplete:M})=>{const[B,G]=t(""),[N,U]=t(""),[W,J]=t(""),[_,z]=t(""),[Y,q]=t(p),[K,Q]=t(y),[V,X]=t(null),[Z,$]=t(!1),[ee,ie]=t(!0),[oe,te]=t(!0),[se,ne]=t(!1);return s((()=>{$(!1)}),[null==g?void 0:g.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&H&&!Z&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield import("webfontloader")).default.load({google:{families:[g.font]},active:()=>{$(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),$(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),$(!0)}}))}),[H,Z,null==g?void 0:g.font]),i(c.Provider,Object.assign({value:Object.assign({origin:m,contextId:B,pickaxeId:N,sessionId:W,lastSessionId:_,sender:Y,senderType:K,deploymentId:h,deploymentType:f,deploymentDimensions:u,deploymentMisc:b,pickaxe:V,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:w,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},x),artifact:S,responsiveBy:I,locale:k,opacity:P,forceMobile:j,loadFont:H,disableHtml:C,disableJs:T,disableCss:D,isFontLoaded:Z,isNewChat:ee,isShowIceBreaker:oe,isShowFeedbackMessage:se,isRtl:R,isEmbed:E,isDropShadow:L,isEmailLogin:O,allowGuestUsage:A,setContextId:G,setPickaxeId:U,setSessionId:J,setLastSessionId:z,setSender:q,setSenderType:Q,setPickaxe:X,setIsFontLoaded:$,setIsNewChat:ie,setIsShowIceBreaker:te,setIsShowFeedbackMessage:ne},M&&{onGenerateComplete:M})},{children:i(l,{children:i(r,{children:i(a,Object.assign({limits:F},{children:i(d,{children:i(n,Object.assign({},S,{children:o}))})}))})})}))};export{c as PickaxeContext,m as PickaxeProvider};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as t,useState as s}from"react";const r=t({}),i=({limits:t,children:i})=>{const[a,n]=s([]),[l,o]=s(null),[m,c]=s("idle"),[u,g]=s(null),[d,p]=s("");return e(r.Provider,Object.assign({value:{messages:a,response:l,status:m,limits:t,limitData:u,error:d,isGenerating:"fetching"===m||"streaming"===m,setMessages:n,setResponse:o,setStatus:c,setLimitData:g,setError:p}},{children:i}))};export{r as ResponseContext,i as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as t,useState as s}from"react";const i=t({}),r=({limits:t,children:r})=>{const[a,n]=s("idle"),[o,m]=s([]),[c,l]=s(null),[u,d]=s(null),[h,g]=s(!1),[p,f]=s(!1),[G,L]=s("");return e(i.Provider,Object.assign({value:{messages:o,response:c,status:a,limits:t,limitData:u,error:G,isGenerating:"fetching"===a||"streaming"===a,isGuestLimitReached:h,isSwitchedToChat:p,setMessages:m,setResponse:l,setStatus:n,setLimitData:d,setError:L,setIsGuestLimitReached:g,setIsSwitchedToChat:f}},{children:r}))};export{i as ResponseContext,r as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{useAffiliate as r}from"../../../hooks/core/useAffiliate.js";import i from"../../Icons/pickaxe.svg.js";import a from"../../../common/cn.js";const n=({containerClassName:n,className:c})=>{var l,m,f;const{formId:d,pickaxe:p,colors:u,misc:x,translations:h}=s(),k=r({formId:d}),v=t();return!p||x.isWhiteLabel?null:e("div",Object.assign({className:a("flex",n)},{children:o("a",Object.assign({href:null!==(m=null===(l=k.data)||void 0===l?void 0:l.link)&&void 0!==m?m:`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}`,target:"_top",rel:"noreferrer",className:a("flex select-none items-center gap-2 overflow-hidden rounded px-2 py-1 opacity-50 duration-300 ease-in-out hover:opacity-100",c,"#ffffff"===u.text.toLowerCase()?"text-white":"text-black")},{children:[e(i,{className:"h-3.5 w-3.5 shrink-0"}),e("span",Object.assign({className:a(v.b4)},{children:null!==(f=null==h?void 0:h["powered-by-pickaxe"])&&void 0!==f?f:"Powered by Pickaxe"}))]}))}))};export{n as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{useAffiliate as i}from"../../../hooks/core/useAffiliate.js";import a from"../../Icons/pickaxe.svg.js";import r from"../../../common/cn.js";const n=({containerClassName:n,className:c})=>{var l,m,p;const{pickaxeId:d,pickaxe:f,colors:x,misc:u,translations:h}=s(),k=i({pickaxeId:d}),v=t();return!f||u.isWhiteLabel?null:e("div",Object.assign({className:r("flex",n)},{children:o("a",Object.assign({href:null!==(m=null===(l=k.data)||void 0===l?void 0:l.link)&&void 0!==m?m:`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}`,target:"_top",rel:"noreferrer",className:r("flex select-none items-center gap-2 overflow-hidden rounded px-2 py-1 opacity-50 duration-300 ease-in-out hover:opacity-100",c,"#ffffff"===x.text.toLowerCase()?"text-white":"text-black")},{children:[e(a,{className:"h-3.5 w-3.5 shrink-0"}),e("span",Object.assign({className:r(v.b4)},{children:null!==(p=null==h?void 0:h["powered-by-pickaxe"])&&void 0!==p?p:"Powered by Pickaxe"}))]}))}))};export{n as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{useMemo as e}from"react";import{usePickaxeMarkdownContext as o}from"../../hooks/usePickaxeMarkdownContext.js";import{Img as r}from"../Img/index.js";import i from"../common/IframeVideo.js";import m from"../common/Action.js";import c from"./Audio.js";import s from"./Html/index.js";const a=({href:a="",children:n})=>{const{colors:l,actions:p}=o(),u=e((()=>{if(!a)return"";return a.startsWith("http://")?`https://${a.slice(7)}`:a.startsWith("www.")?`https://${a}`:a}),[a]),f=e((()=>{const t=u.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(t)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${t[1]}`};const e=u.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(e)return{title:"loom-embed",src:`https://www.loom.com/embed/${e[1]}`};const o=u.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(o)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${o[1]}`};const r=u.match(/streamable\.com\/([\w-]+)/i);return r?{title:"streamable-embed",src:`https://streamable.com/e/${r[1]}`}:null}),[u]),d=e((()=>u.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/)),[u]),h=e((()=>u.includes("action_generated_files")&&u.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/)),[u]),b=e((()=>u.includes("action_generated_files")&&u.match(/\.html$/)),[u]),w=e((()=>p&&u.includes("pickaxe")&&(u.includes("/api/fn/result")||u.includes("/api/function_call_results"))),[p,u]);return f?t(i,{title:f.title,src:f.src}):d?t(r,{src:u,alt:"string"==typeof n?n:"Markdown Image"}):h?t(c,{url:u}):b?t(s,{url:u}):w?t(m,{jobUrl:u}):t("a",Object.assign({href:u,target:"_blank",rel:"noopener noreferrer",style:{color:l.accent}},{children:n}))};export{a as A};
1
+ import{jsx as t}from"react/jsx-runtime";import{useMemo as e}from"react";import{usePickaxeMarkdownContext as r}from"../../hooks/usePickaxeMarkdownContext.js";import{Img as o}from"../Img/index.js";import m from"../common/IframeVideo.js";import i from"./Audio.js";import c from"./Html/index.js";const a=({href:a="",children:s})=>{const{colors:n}=r(),l=e((()=>{if(!a)return"";return a.startsWith("http://")?`https://${a.slice(7)}`:a.startsWith("www.")?`https://${a}`:a}),[a]),p=e((()=>{const t=l.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(t)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${t[1]}`};const e=l.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(e)return{title:"loom-embed",src:`https://www.loom.com/embed/${e[1]}`};const r=l.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const o=l.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[l]),f=e((()=>l.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/)),[l]),u=e((()=>l.includes("action_generated_files")&&l.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/)),[l]),d=e((()=>l.includes("action_generated_files")&&l.match(/\.html$/)),[l]);return p?t(m,{title:p.title,src:p.src}):f?t(o,{src:l,alt:"string"==typeof s?s:"Markdown Image"}):u?t(i,{url:l}):d?t(c,{url:l}):t("a",Object.assign({href:l,target:"_blank",rel:"noopener noreferrer",style:{color:n.accent}},{children:s}))};export{a as A};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as o,useMemo as i,useEffect as s}from"react";import{usePickaxeMarkdownContext as m}from"./hooks/usePickaxeMarkdownContext.js";import{rehypeCode as a,rehypeSanitize as p}from"./utils/custom-plugins.js";import l from"react-markdown";import c from"remark-gfm";import d from"remark-math";import h from"rehype-katex";import f from"rehype-raw";import{A as u}from"./Components/A/index.js";import{P as g}from"./Components/P/index.js";import{Img as x}from"./Components/Img/index.js";import{Iframe as b}from"./Components/Iframe/index.js";import{Code as j}from"./Components/Code/index.js";import{H1 as C,H2 as k,H3 as w,H4 as $,H5 as v}from"./Components/Headings/index.js";import{Ol as y,Ul as O,Li as L}from"./Components/List/index.js";import{Table as M,Th as N,Tr as P,Td as S}from"./Components/Table/index.js";import{Hr as T,Br as A,Blockquote as H}from"./Components/Others/index.js";import{ActionCaption as I,ActionFinished as B,ActionError as J}from"./Components/Action/index.js";import{Artifact as R,ArtifactError as W}from"./Components/Artifact/index.js";import{Think as _}from"./Components/Others/Think.js";import q from"../../../../common/cn.js";const z=({className:z,style:D,children:E,value:F,maxLines:G,maxChars:K,multiLineBreaks:Q,recursion:U,onExpandClick:V})=>{const{colors:X,rtl:Y,disableHtml:Z,disableJs:ee,disableCss:re}=m(),[te,ne]=n({width:0,height:0}),[oe,ie]=n(null),se=o(null),me=i((()=>{if(!F)return"";let e=F.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Q&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[F,Q]);s((()=>{if(K)return void ie(me.length>K?me.slice(0,K)+'<span class="pxe-expand-btn">...</span>':null);if(!G)return void ie(null);if(!se.current||!me||oe)return;const e=se.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),t=G*r;if(!(te.height>t))return;const n=Math.floor(te.width/8),o=Math.floor(n*G);ie(me.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[me,G,K,te,oe]);const ae={h1:C,h2:k,h3:w,h4:$,h5:v,p:g,a:u,img:x,iframe:b,code:j,ol:y,ul:O,li:L,table:M,th:N,tr:P,td:S,hr:T,br:A,blockquote:H,span:r=>{var{children:n}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?t("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:X.accent,marginLeft:".25rem",userSelect:"none"},V&&{cursor:"pointer"})},V&&{onClick:V},{children:n})):t("span",Object.assign({},o,{children:n}))},"action-caption":I,"action-finished":B,"action-error":J,artifact:R,"artifact-error":W,think:_};s((()=>{if(!se.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:t}=r.contentRect;ne({width:e,height:t})}}));return e.observe(se.current),()=>{e.disconnect()}}),[]);const pe=oe||me;return r("div",Object.assign({className:"pxe-markdown",ref:se,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},D)},Y&&{dir:"rtl"},{children:[t(l,Object.assign({className:q(!U&&"pxe-prose",z),components:ae,remarkPlugins:[c,[d,{singleDollarTextMath:!1}]],rehypePlugins:[a,h,...Z?[]:[f],[p,{disableJs:ee,disableCss:re}]]},{children:pe})),E]}))};export{z as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as o,useMemo as i,useEffect as s}from"react";import{usePickaxeMarkdownContext as m}from"./hooks/usePickaxeMarkdownContext.js";import{rehypeCode as a,rehypeSanitize as p}from"./utils/custom-plugins.js";import l from"react-markdown";import c from"remark-gfm";import d from"remark-math";import h from"rehype-katex";import f from"rehype-raw";import{A as u}from"./Components/A/index.js";import{P as g}from"./Components/P/index.js";import{Img as x}from"./Components/Img/index.js";import{Iframe as b}from"./Components/Iframe/index.js";import{Code as j}from"./Components/Code/index.js";import{H1 as C,H2 as k,H3 as w,H4 as $,H5 as v}from"./Components/Headings/index.js";import{Ol as y,Ul as O,Li as L}from"./Components/List/index.js";import{Table as M,Th as N,Tr as P,Td as S}from"./Components/Table/index.js";import{Hr as T,Br as A,Blockquote as H}from"./Components/Others/index.js";import{ActionCaption as I,ActionFinished as B,ActionError as J}from"./Components/Action/index.js";import{Artifact as R,ArtifactError as W}from"./Components/Artifact/index.js";import{Think as _}from"./Components/Others/Think.js";import q from"../../../../common/cn.js";const z=({className:z,style:D,children:E,value:F,maxLines:G,maxChars:K,multiLineBreaks:Q,onExpandClick:U})=>{const{colors:V,rtl:X,disableHtml:Y,disableJs:Z,disableCss:ee}=m(),[re,te]=n({width:0,height:0}),[ne,oe]=n(null),ie=o(null),se=i((()=>{if(!F)return"";let e=F.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Q&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[F,Q]);s((()=>{if(K)return void oe(se.length>K?se.slice(0,K)+'<span class="pxe-expand-btn">...</span>':null);if(!G)return void oe(null);if(!ie.current||!se||ne)return;const e=ie.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),t=G*r;if(!(re.height>t))return;const n=Math.floor(re.width/8),o=Math.floor(n*G);oe(se.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[se,G,K,re,ne]);const me={h1:C,h2:k,h3:w,h4:$,h5:v,p:g,a:u,img:x,iframe:b,code:j,ol:y,ul:O,li:L,table:M,th:N,tr:P,td:S,hr:T,br:A,blockquote:H,span:r=>{var{children:n}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?t("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:V.accent,marginLeft:".25rem",userSelect:"none"},U&&{cursor:"pointer"})},U&&{onClick:U},{children:n})):t("span",Object.assign({},o,{children:n}))},"action-caption":I,"action-finished":B,"action-error":J,artifact:R,"artifact-error":W,think:_};s((()=>{if(!ie.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:t}=r.contentRect;te({width:e,height:t})}}));return e.observe(ie.current),()=>{e.disconnect()}}),[]);const ae=ne||se;return r("div",Object.assign({className:"pxe-markdown",ref:ie,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},D)},X&&{dir:"rtl"},{children:[t(l,Object.assign({className:q("pxe-prose",z),components:me,remarkPlugins:[c,[d,{singleDollarTextMath:!1}]],rehypePlugins:[a,h,...Y?[]:[f],[p,{disableJs:Z,disableCss:ee}]]},{children:ae})),E]}))};export{z as PickaxeMarkdownRenderer};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as t}from"react";const r=e({}),n=({children:e,theme:n="light",syntaxTheme:l,colors:a={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},actions:i=!1,readOnly:s=!1,rtl:d=!1,disableHtml:F=!1,disableJs:m=!1,disableCss:p=!1,onArtifactClick:C})=>{const[b,g]=t(n),[h,u]=t({}),[y,f]=t(i);return o(r.Provider,Object.assign({value:Object.assign(Object.assign({theme:b,colors:a,styles:c,actionState:h,actions:y,readOnly:s,rtl:d,disableHtml:F,disableJs:m,disableCss:p,setTheme:g,setActionState:u,setActions:f},!!C&&{onArtifactClick:C}),{syntaxTheme:l||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}})},{children:e}))};export{n as PickaxeMarkdown,r as PickaxeMarkdownContext,n as default};
1
+ import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as t}from"react";const r=e({}),n=({children:e,theme:n="light",syntaxTheme:l,colors:a={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},readOnly:i=!1,rtl:s=!1,disableHtml:d=!1,disableJs:F=!1,disableCss:m=!1,onArtifactClick:p})=>{const[C,b]=t(n),[g,h]=t({});return o(r.Provider,Object.assign({value:Object.assign(Object.assign({theme:C,colors:a,styles:c,actionState:g,readOnly:i,rtl:s,disableHtml:d,disableJs:F,disableCss:m,setTheme:b,setActionState:h},!!p&&{onArtifactClick:p}),{syntaxTheme:l||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}})},{children:e}))};export{n as PickaxeMarkdown,r as PickaxeMarkdownContext,n as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitFeedback as a}from"../../../hooks/pickaxe/useSubmitFeedback.js";import{useThumbSelection as n}from"../../../hooks/pickaxe/useThumbSelection.js";import{AnimatePresence as l,motion as c}from"framer-motion";import r from"../../Icons/message-square-notes.svg.js";import m from"../../Icons/thumbs-down.svg.js";import p from"../../Icons/thumbs-up.svg.js";import u from"./PickaxeSimpleButton.js";import d from"./PickaxeCopyButton.js";import b from"./PickaxeFeedbackThumbsDownReasons.js";import h from"../../../common/cn.js";const f=({content:f,index:x=0,chatCount:k,responseId:g,isForm:y,isHideFeedback:v,onOpenChat:j})=>{var w,O,N,T;const{mutateAsync:S}=a(),{colors:C,translations:D,pickaxe:F,setIsShowFeedbackMessage:I}=o(),U=t(),{toggleThumb:P,submitThumbsDown:R,submitThumbsUp:z,isThumbsUpSelected:B,isThumbsDownSelected:H,showThumbsDownOptions:W,showThumbsUpOptions:q,showSuccess:A}=n({content:f,index:x,responseId:g,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>I(!0),onThumbsDownReasonClose:()=>I(!1),submit:S}),M="function"==typeof j&&!!(null==F?void 0:F.enablechatresponses)&&void 0!==g&&void 0!==k,E=Boolean((null==F?void 0:F.enablechatresponses)&&!j||!(null==F?void 0:F.enablechatresponses)&&y)&&!v;return e("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e("div",Object.assign({className:"flex h-4 items-center gap-3"},{children:[M&&e(u,Object.assign({color:C.accent,onClick:j},{children:[s(r,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:h(U.b3,"font-semibold")},{children:k}))]})),s(d,{color:C.accent,text:f}),E&&e(i,{children:[s(u,Object.assign({color:C.accent,onClick:()=>P("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:s(p,{className:"size-4",style:{fill:C.text,fillOpacity:B?.3:0}})})),s(u,Object.assign({color:C.accent,onClick:()=>P("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:s(m,{className:"size-4",style:{fill:C.text,fillOpacity:H?.3:0}})})),s(l,{children:A&&s(c.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:s("p",Object.assign({className:h(U.b4,C.secondary,"opacity-75")},{children:null!==(w=null==D?void 0:D["feedback-thanks"])&&void 0!==w?w:"Thanks for the feedback!"}))}))})]})]})),s(l,{children:(W||q)&&e(c.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e("div",Object.assign({className:"space-y-0.5"},{children:[s("p",Object.assign({className:h(U.b3,C.text)},{children:q?null!==(O=null==D?void 0:D["feedback-like-title"])&&void 0!==O?O:"What went right?":null!==(N=null==D?void 0:D["feedback-dislike-title"])&&void 0!==N?N:"What went wrong?"})),s("p",Object.assign({className:h(U.b3,C.secondary,"opacity-75")},{children:null!==(T=null==D?void 0:D["feedback-dislike-message"])&&void 0!==T?T:"Help us improve our answers"}))]})),s(c.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:s(b,{isUp:q,submitThumbsDown:R,submitThumbsUp:z})}))]}))})]}))};export{f as default};
1
+ import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useFeedback as a}from"../../../hooks/pickaxe/useFeedback.js";import{AnimatePresence as n,motion as l}from"framer-motion";import c from"../../Icons/message-square-notes.svg.js";import r from"../../Icons/thumbs-down.svg.js";import m from"../../Icons/thumbs-up.svg.js";import p from"./PickaxeSimpleButton.js";import d from"./PickaxeCopyButton.js";import u from"./PickaxeFeedbackThumbsDownReasons.js";import b from"../../../common/cn.js";const h=({content:h,sessionId:f,index:x=0,messagesCount:g,isHideFeedback:v,onOpenChat:k})=>{var y,j,w,O;const{colors:N,translations:T,pickaxe:C,setIsShowFeedbackMessage:D}=o(),S=t(),{toggleThumb:I,submitThumbsDown:F,submitThumbsUp:U,isThumbsUpSelected:P,isThumbsDownSelected:R,showThumbsDownOptions:z,showThumbsUpOptions:B,showSuccess:H}=a({content:h,index:x,sessionId:f,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>D(!0),onThumbsDownReasonClose:()=>D(!1)}),W="function"==typeof k&&((null==C?void 0:C.chatflag)||!!(null==C?void 0:C.enablechatresponses))&&void 0!==f&&void 0!==g,q=Boolean(((null==C?void 0:C.chatflag)||(null==C?void 0:C.enablechatresponses))&&!k||!(null==C?void 0:C.chatflag)&&!(null==C?void 0:C.enablechatresponses))&&!v;return e("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e("div",Object.assign({className:"flex h-4 items-center gap-3"},{children:[W&&e(p,Object.assign({color:N.accent,onClick:k},{children:[s(c,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:b(S.b3,"font-semibold")},{children:g}))]})),s(d,{color:N.accent,text:h}),q&&e(i,{children:[s(p,Object.assign({color:N.accent,onClick:()=>I("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:s(m,{className:"size-4",style:{fill:N.text,fillOpacity:P?.3:0}})})),s(p,Object.assign({color:N.accent,onClick:()=>I("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:s(r,{className:"size-4",style:{fill:N.text,fillOpacity:R?.3:0}})})),s(n,{children:H&&s(l.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:s("p",Object.assign({className:b(S.b4,N.secondary,"opacity-75")},{children:null!==(y=null==T?void 0:T["feedback-thanks"])&&void 0!==y?y:"Thanks for the feedback!"}))}))})]})]})),s(n,{children:(z||B)&&e(l.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e("div",Object.assign({className:"space-y-0.5"},{children:[s("p",Object.assign({className:b(S.b3,N.text)},{children:B?null!==(j=null==T?void 0:T["feedback-like-title"])&&void 0!==j?j:"What went right?":null!==(w=null==T?void 0:T["feedback-dislike-title"])&&void 0!==w?w:"What went wrong?"})),s("p",Object.assign({className:b(S.b3,N.secondary,"opacity-75")},{children:null!==(O=null==T?void 0:T["feedback-dislike-message"])&&void 0!==O?O:"Help us improve our answers"}))]})),s(l.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:s(u,{isUp:B,submitThumbsDown:F,submitThumbsUp:U})}))]}))})]}))};export{h as default};
@@ -0,0 +1 @@
1
+ import{jsx as a}from"react/jsx-runtime";import{memo as e,useMemo as r}from"react";import{motion as t}from"framer-motion";import n from"../../../../../common/cn.js";var o=e((({children:e,as:o="p",className:i,style:c,duration:s=2,spread:l=2,theme:d="light",isDisabled:g})=>{const b=t.create(o),p=r((()=>e.length*l),[e,l]);return a(b,Object.assign({className:n("relative inline-block bg-[length:250%_100%,auto] bg-clip-text",g?"text-current":"text-transparent [background-repeat:no-repeat,padding-box]",!g&&("dark"===d?"[--base-color:#71717a] [--base-gradient-color:#ffffff] [--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]":"[--base-color:#000000] [--base-gradient-color:#a1a1aa] [--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]"),i),initial:g?{}:{backgroundPosition:"100% center"},animate:g?{}:{backgroundPosition:"0% center"},transition:g?{}:{repeat:1/0,duration:s,ease:"linear"},style:Object.assign(Object.assign({},!g&&{"--spread":`${p}px`,backgroundImage:"var(--bg), linear-gradient(var(--base-color), var(--base-color))"}),c)},{children:e}))}));export{o as default};
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{usePickaxeContext as e}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import o from"./TextShimmer.js";const i=({caption:i,isLoading:r})=>{const{colors:s}=e();return r?t(o,Object.assign({theme:"#000000"===s.text?"light":"dark",isDisabled:!r},{children:i||"Loading..."})):null};export{i as default};
@@ -0,0 +1 @@
1
+ import{__rest as e}from"../../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as a}from"react";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useHover as s}from"../../../../../hooks/core/useHover.js";import{motion as n,AnimatePresence as c}from"framer-motion";import l from"../../../../Icons/chevron-down.svg.js";import m from"../../../../Icons/chevron-up.svg.js";const d=({children:d,isReasoning:p})=>{const{colors:h}=i(),[u,g]=r(-1),[f,x]=r(!1),v=s(),{isHover:j}=v,b=e(v,["isHover"]);return a((()=>{let e=null;return p?(g(0),e=setInterval((()=>{g((e=>e+1))}),1e3)):(e&&clearInterval(e),x(!1)),()=>{e&&clearInterval(e)}}),[p]),o(n.div,Object.assign({className:"flex flex-col mb-2",initial:{opacity:0},animate:{opacity:1},transition:{duration:.3,ease:"easeInOut"}},{children:[o("div",Object.assign({className:"flex flex-row gap-2 items-center"},{children:[t("div",Object.assign({className:"text-sm",style:{color:h.text+"80"}},{children:p?"Thinking...":u>=0?`Thought for ${u} seconds`:"Thought"})),t("button",Object.assign({className:"rounded-full cursor-pointer outline-none text-c-secondary transition-colors duration-300",style:{backgroundColor:f||j?h.secondary+"80":"transparent"},onClick:()=>{x(!f)}},b,{children:t(f?m:l,{className:"w-3 h-3 shrink-0"})}))]})),t(c,Object.assign({initial:!1},{children:f&&t(n.div,Object.assign({className:"flex flex-col gap-4 pl-3 text-sm whitespace-pre-wrap",style:{color:h.text+"80",borderLeftColor:h.secondary+"80"},initial:"collapsed",animate:"expanded",exit:"collapsed",variants:{collapsed:{height:0,opacity:0,marginTop:0,marginBottom:0},expanded:{height:"auto",opacity:1,marginTop:"1rem",marginBottom:0}},transition:{duration:.2,ease:"easeInOut"}},{children:d}),"reasoning")}))]}))};export{d as default};
@@ -0,0 +1 @@
1
+ import{jsx as e}from"react/jsx-runtime";const a=({children:a})=>e("div",Object.assign({className:"flex flex-col gap-4"},{children:a}));export{a as default};
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{Suspense as e,lazy as n}from"react";import{PickaxeMarkdownRenderer as i}from"../PickaxeMarkdown/Renderer.js";import{safeJSONParse as r}from"../../../../common/utils.js";import o from"../../../../common/cn.js";const a=n((()=>import("./TextPart/index.js"))),s=n((()=>import("./ReasoningPart/index.js"))),c=n((()=>import("./ActionToolCaptionPart/index.js"))),l=({className:n,parts:l})=>t("div",Object.assign({className:o("flex flex-col gap-2",n)},{children:t(e,Object.assign({fallback:t("div",{})},{children:l.map(((e,n)=>{if(!e.isVisible)return null;if("text"===e.type)return t(a,{children:t(i,{value:e.content})},n);if("reasoning"===e.type)return t(s,Object.assign({isReasoning:n===l.length-1},{children:t(i,{value:e.content})}),n);if("data-action-tool-caption"===e.type){const i=r(e.content);return t(c,Object.assign({},i&&i,{isLoading:n===l.length-1}),n)}return null}))}))}));export{l as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{AnimatePresence as s}from"framer-motion";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../hooks/studio/useStyleFontSize.js";import m from"../../Icons/circle-exclamation.svg.js";import a from"../../Core/SpringTransition.js";import c from"../../Core/HtmlRenderer.js";import n from"./PickaxeButton.js";import l from"../../../common/cn.js";import{isInIframe as f}from"../utils/iframe.js";const p=({className:p,iconClassName:h,htmlClassName:x})=>{const{colors:j}=r(),{limitData:d}=t(),g=i(),u=window.location.href.includes("_embed");return e(s,{children:!!d&&o(a,Object.assign({className:l("flex gap-3",p)},{children:[e(m,{className:l("h-5 w-5 shrink-0",h),style:{color:j.accent}}),o("div",Object.assign({className:"flex flex-col gap-4"},{children:[e(c,{className:l(g.b2,"font-semibold",x),style:{color:j.text},html:d.html}),!!d.cta&&e("a",Object.assign({href:d.ctaLink,target:f()&&!u?"_self":"_top",rel:"noreferrer"},{children:e(n,Object.assign({variant:"primary",className:"min-h-[38px]",style:{minHeight:"38px"}},{children:d.cta}))}))]}))]}))})};export{p as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{AnimatePresence as s}from"framer-motion";import{usePickaxeContext as t}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as r}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../hooks/studio/useStyleFontSize.js";import{isInIframe as m}from"../../../common/utils.js";import a from"../../Icons/circle-exclamation.svg.js";import c from"../../Core/SpringTransition.js";import n from"../../Core/HtmlRenderer.js";import l from"./PickaxeButton.js";import p from"../../../common/cn.js";const f=({className:f,iconClassName:h,htmlClassName:x})=>{const{colors:j}=t(),{limitData:d}=r(),g=i(),u=window.location.href.includes("_embed");return e(s,{children:!!d&&o(c,Object.assign({className:p("flex gap-3",f)},{children:[e(a,{className:p("h-5 w-5 shrink-0",h),style:{color:j.accent}}),o("div",Object.assign({className:"flex flex-col gap-4"},{children:[e(n,{className:p(g.b2,"font-semibold",x),style:{color:j.text},html:d.html}),!!d.cta&&e("a",Object.assign({href:d.ctaLink,target:m()&&!u?"_self":"_top",rel:"noreferrer"},{children:e(l,Object.assign({variant:"primary",className:"min-h-[38px]",style:{minHeight:"38px"}},{children:d.cta}))}))]}))]}))})};export{f as default};
@@ -1 +1 @@
1
- import{jsx as t,Fragment as e,jsxs as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as r,useEffect as a,useMemo as i}from"react";import{usePickaxeContext as l}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as c}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as p}from"./Addons/Artifact/hooks/useArtifactContext.js";import{generateId as x}from"../../common/utils.js";import{ScrollProvider as d}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import u from"./Chat/index.js";import h from"./Form/index.js";import k from"./Addons/Auth/index.js";import j from"../../common/cn.js";const w=({formId:w,className:g})=>{const{chatId:y,styles:A,colors:N,responsiveBy:C,deploymentType:b,isNewChat:v,isEmailLogin:S,opacity:O,setFormId:P,setChatId:I,setSessionId:D,setPickaxe:L}=l(),{isLoggedOut:E,isSent:F}=n(),{setMessages:R,setResponse:M,setError:$,setLimitData:B,setStatus:H}=m(),{setDocumentError:T}=c(),{setCurrentArtifact:W}=p(),[q,z]=r(!1),G=s(),J="chat-input"===b&&v&&!F,K="popup"===b&&y,Q="chat-input"!==b||!F,U="popup"===b&&!y&&S&&E;a((()=>{P(w)}),[w]),a((()=>{if(!G.data)return;const t=G.data.chatflag;I(t?x(15):""),D(x(15)),t?R([]):M(null),$(""),T(""),B(null),W(null),L(G.data),z(!0)}),[G.data]),a((()=>{$(""),T(""),B(null),R([]),M(null),W(null),H("idle")}),[y]);const V=i((()=>{const t=null!=O?O:1;if(!N.primary||!N.primary.startsWith("#")||t<0||t>1)return N.primary;const e=Math.round(255*t).toString(16).padStart(2,"0");return`${N.primary}${e}`}),[N.primary,O]);return G.data?t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full",(!b||K||U)&&"h-full","dark"===A.theme&&"dark",g),style:Object.assign({backgroundColor:J?"transparent":V,color:N.text},A.font&&"Real Head Pro"!==A.font&&{fontFamily:A.font})},{children:S&&E&&Q?t(k,{}):t(e,{children:G.isLoading||!q?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===C?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:o("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(f,{className:"w-[72px] h-[72px]"}),t(f,{className:"h-[20px] mt-6 w-full"}),t(f,{className:"h-[20px] mt-2 w-full"}),t(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(f,{className:j("w-full min-h-[48px]","viewport"===C?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t(e,{children:t(d,y?{children:t(u,{})}:{children:t(h,{})})})})})):null};export{w as Pickaxe};
1
+ import{jsx as t,Fragment as e,jsxs as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as r,useEffect as a,useMemo as i}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as c}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as p}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as x}from"uuid";import{ScrollProvider as d}from"./Addons/Scroll/Provider.js";import u from"./common/PickaxeSkeleton.js";import f from"./Chat/index.js";import h from"./Form/index.js";import k from"./Addons/Auth/index.js";import j from"../../common/cn.js";const w=({pickaxeId:w,className:g})=>{const{sessionId:y,styles:A,colors:C,responsiveBy:N,deploymentType:b,isNewChat:v,isEmailLogin:P,opacity:S,setContextId:I,setPickaxeId:O,setSessionId:D,setPickaxe:L}=n(),{isLoggedOut:E,isSent:R}=l(),{setMessages:F,setResponse:M,setError:T,setLimitData:$,setIsSwitchedToChat:B}=m(),{setDocumentError:H}=c(),{setCurrentArtifact:W}=p(),[q,z]=r(!1),G=s(),J="chat-input"===b&&v&&!R,K="popup"===b&&y,Q="chat-input"!==b||!R,U="popup"===b&&!y&&P&&E;a((()=>{O(w)}),[w]),a((()=>{if(!G.data)return;const t=G.data.chatflag;D(t?x():""),I(x()),t?F([]):M(null),T(""),H(""),$(null),W(null),B(!1),L(G.data),z(!0)}),[G.data]),a((()=>{T(""),H(""),$(null),F([]),M(null),W(null)}),[y]);const V=i((()=>{const t=null!=S?S:1;if(!C.primary||!C.primary.startsWith("#")||t<0||t>1)return C.primary;const e=Math.round(255*t).toString(16).padStart(2,"0");return`${C.primary}${e}`}),[C.primary,S]);return G.data?t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full",(!b||K||U)&&"h-full","dark"===A.theme&&"dark",g),style:Object.assign({backgroundColor:J?"transparent":V,color:C.text},A.font&&"Real Head Pro"!==A.font&&{fontFamily:A.font})},{children:P&&E&&Q?t(k,{}):t(e,{children:G.isLoading||!q?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===N?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:o("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(u,{className:"w-[72px] h-[72px]"}),t(u,{className:"h-[20px] mt-6 w-full"}),t(u,{className:"h-[20px] mt-2 w-full"}),t(u,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(u,{className:j("w-full min-h-[48px]","viewport"===N?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t(e,{children:t(d,y?{children:t(f,{})}:{children:t(h,{})})})})})):null};export{w as Pickaxe};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import i from"../../common/api/utils.js";const e=e=>{const r=o({queryKey:["affiliate",e],queryFn:()=>t(void 0,void 0,void 0,(function*(){return(({formId:o,studioId:e,deploymentId:r})=>t(void 0,void 0,void 0,(function*(){if(!o&&!e&&!r)throw new Error("[_getAffiliate] No formId, studioId or deploymentId provided");const t={};o?t.formId=o:e?t.studioId=e:r&&(t.deploymentId=r);const d=new URLSearchParams(t).toString(),f=d?`/affiliate?${d}`:"/affiliate",a=yield i.get(f),n=a.data;if(200!==a.status)throw new Error("[_getAffiliate] Failed to fetch affiliate "+n);return n})))(e)})),enabled:!!e.formId||!!e.studioId||!!e.deploymentId});return r};export{e as useAffiliate};
1
+ import{__awaiter as t}from"../../_virtual/_tslib.js";import{useQuery as i}from"@tanstack/react-query";import e from"../../common/api/utils.js";const o=o=>{const d=i({queryKey:["affiliate",o],queryFn:()=>t(void 0,void 0,void 0,(function*(){return(({pickaxeId:i,studioId:o,deploymentId:d})=>t(void 0,void 0,void 0,(function*(){if(!i&&!o&&!d)throw new Error("[_getAffiliate] No pickaxeId, studioId or deploymentId provided");const t={};i?t.formId=i:o?t.studioId=o:d&&(t.deploymentId=d);const r=new URLSearchParams(t).toString(),a=r?`/affiliate?${r}`:"/affiliate",n=yield e.get(a),f=n.data;if(200!==n.status)throw new Error("[_getAffiliate] Failed to fetch affiliate "+f);return f})))(o)})),enabled:!!o.pickaxeId||!!o.studioId||!!o.deploymentId});return d};export{o as useAffiliate};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import{usePickaxeContext as r}from"./usePickaxeContext.js";import e from"../../common/api/index.js";const i=()=>{const{formId:i,chatId:n}=r();return o({queryKey:["form",i,"chat",n],queryFn:()=>t(void 0,void 0,void 0,(function*(){return o=i,r=n,t(void 0,void 0,void 0,(function*(){const t=yield e.get(`/pickaxe/chat/conversation?formid=${o}&responseid=${r}`),i=t.data;if(200!==t.status)throw new Error("[_getChat] Failed to fetch chat conversation "+i);return i}));var o,r})),enabled:!!i&&!!n})};export{i as useConversation};
1
+ import{__awaiter as o}from"../../_virtual/_tslib.js";import{useQuery as t}from"@tanstack/react-query";import{usePickaxeContext as e}from"./usePickaxeContext.js";import{useResponseContext as r}from"./useResponseContext.js";import i from"../../common/api/pickaxe.js";const n=()=>{const{pickaxeId:n,sessionId:s}=e(),{isSwitchedToChat:a}=r();return t({queryKey:["form",n,"chat",s],queryFn:()=>o(void 0,void 0,void 0,(function*(){return t=n,e=s,o(void 0,void 0,void 0,(function*(){const o=yield i.get(`/conversation?pickaxeId=${t}&sessionId=${e}`),r=o.data;if(200!==o.status)throw new Error("[_getChat] Failed to fetch chat conversation "+r);return r}));var t,e})),enabled:!!n&&!!s&&!a})};export{n as useConversation};
@@ -0,0 +1 @@
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useState as s}from"react";import{useMutation as i}from"@tanstack/react-query";import{usePickaxeContext as o}from"./usePickaxeContext.js";import n from"../../common/api/pickaxe.js";const t=({content:t,index:d,sessionId:l,onThumbsDownReasonOpen:u,onThumbsDownReasonClose:a,onThumbsUpReasonOpen:r,onThumbsUpReasonClose:c,successDuration:m=3e3,promptRate:p=1})=>{const{sessionId:k,pickaxeId:b,sender:f,senderType:T,pickaxe:h}=o(),[v,w]=s(null),[x,y]=s(!1),[g,I]=s(!1),[O,j]=s(!1),D=i({mutationFn:s=>{return i=s,e(void 0,void 0,void 0,(function*(){const e=yield n.post("/feedback",i),s=e.data;if(200!==e.status)throw new Error("[_upsertFeedback] Failed to upsert feedback "+s);return s}));var i}}),R=e=>{(null==h?void 0:h.workspaceid)&&(null==h?void 0:h.studioid)&&(null==h?void 0:h.model)&&D.mutate(Object.assign(Object.assign(Object.assign({sessionId:l||k,pickaxeId:b},f&&{sender:f}),{senderType:T,index:d,workspaceId:h.workspaceid,studioId:h.studioid,model:h.model,content:t}),e))},U=()=>{j(!0),setTimeout((()=>j(!1)),m)},M=()=>{x&&(y(!1),null==a||a()),g&&(I(!1),null==c||c())};return{selectedThumb:v,showThumbsDownOptions:x,showThumbsUpOptions:g,toggleThumb:e=>{if("like"===e){const e="like"===v&&g,s=!e&&Math.random()<p;return M(),s?(w("like"),I(!0),void(null==r||r())):e?void w(null):(w("like"),R({feedbackType:"like"}),void U())}if("dislike"===e){const e="dislike"===v&&x,s=!e&&Math.random()<p;if(M(),s)return w("dislike"),y(!0),void(null==u||u());if(e)return void w(null);w("dislike"),R({feedbackType:"dislike"}),U()}},submitThumbsDown:e=>{R({feedbackType:"dislike",feedbackMessage:e}),M(),U()},submitThumbsUp:e=>{R({feedbackType:"like",feedbackMessage:e}),M(),U()},isThumbsUpSelected:"like"===v,isThumbsDownSelected:"dislike"===v,showSuccess:O}};export{t as useFeedback};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{useInfiniteQuery as t}from"@tanstack/react-query";import{usePickaxeContext as o}from"./usePickaxeContext.js";import{useAuthContext as s}from"../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js";import d from"../../common/api/index.js";const i=({enabled:i=!0}={enabled:!0})=>{const{formId:r,pickaxe:n,studioUserId:a,embedUserId:m,deploymentId:u}=o(),{token:c}=s(),l=t({queryKey:["form",r,"history"],queryFn:({pageParam:t=0})=>(({formId:t,place:o,studioId:s,studioUserId:i,embedUserId:r,studioSessionToken:n,deploymentId:a})=>e(void 0,void 0,void 0,(function*(){let e=`/pickaxe/history?formid=${t}&place=${o}`;s&&(e+=`&studioId=${s}`),i&&(e+=`&studioUserId=${i}`),r&&(e+=`&embedUserId=${r}`),n&&(e+=`&studioSessionToken=${n}`),a&&(e+=`&deploymentId=${a}`);const m=yield d.get(e),u=m.data;if(200!==m.status)throw new Error("[_getHistory] Failed to fetch history "+u);return{next:u.history.length<5?void 0:o+25,data:u.history}})))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:r,place:t},a&&(null==n?void 0:n.studioid)&&{studioId:n.studioid}),a&&{studioUserId:a}),m&&{embedUserId:m}),c&&{studioSessionToken:c}),u&&{deploymentId:u})),getNextPageParam:e=>e.next,enabled:i&&!!r});return l};export{i as useHistory};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useInfiniteQuery as t}from"@tanstack/react-query";import{usePickaxeContext as s}from"./usePickaxeContext.js";import{useAuthContext as r}from"../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js";import o from"../../common/api/pickaxe.js";const n=({enabled:n=!0,searchQuery:i}={enabled:!0})=>{const{pickaxeId:a,sender:c,senderType:d}=s(),{token:p}=r(),u=t({queryKey:["form",a,"history"],queryFn:({pageParam:t=0})=>(({pickaxeId:t,sender:s,senderType:r,studioSessionToken:n,searchQuery:i,place:a})=>e(void 0,void 0,void 0,(function*(){let e=`/history?pickaxeId=${t}&senderType=${r}&place=${a}`;s&&(e+=`&sender=${s}`),n&&(e+=`&studioSessionToken=${n}`),i&&(e+=`&searchQuery=${i}`);const c=yield o.get(e),d=c.data;if(200!==c.status)throw new Error("[_getHistory] Failed to fetch history "+d);return{next:d.history.length<3?void 0:a+3,data:d.history}})))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pickaxeId:a},c&&{sender:c}),{senderType:d}),p&&{studioSessionToken:p}),i&&{searchQuery:i}),{place:t})),getNextPageParam:e=>e.next,enabled:n&&!!a});return u};export{n as useHistory};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import{usePickaxeContext as r}from"./usePickaxeContext.js";const t=o=>e(void 0,void 0,void 0,(function*(){if(!o)return null;const e=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe?formid=${o}`,{method:"GET",headers:{"Content-Type":"application/json"}}),{success:r,data:t,error:i}=yield e.json();if(!r)throw new Error(i||"Failed to fetch pickaxe");return t})),i=()=>{const{formId:i}=r();return o({queryKey:["form",i],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t(i)})),enabled:!!i,staleTime:18e4})},n=r=>o({queryKey:["form",r],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t(r)})),enabled:!!r,staleTime:18e4});export{n as useInstantPickaxe,i as usePickaxe};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import{usePickaxeContext as r}from"./usePickaxeContext.js";const t=o=>e(void 0,void 0,void 0,(function*(){if(!o)return null;const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/pickaxe?pickaxeId=${o}`,{method:"GET",headers:{"Content-Type":"application/json"}}),{success:r,data:t,error:i}=yield e.json();if(!r)throw new Error(i||"Failed to fetch pickaxe");return t})),i=()=>{const{pickaxeId:i}=r();return o({queryKey:["form",i],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t(i)})),enabled:!!i,staleTime:18e4})},n=r=>o({queryKey:["form",r],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t(r)})),enabled:!!r,staleTime:18e4});export{n as useInstantPickaxe,i as usePickaxe};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{useMutation as s}from"@tanstack/react-query";const n=()=>s({mutationFn:s=>(({formId:s,responseId:n,documentIds:o,studioUserId:t,deploymentId:i,embedUserId:d,studioSessionToken:c,pickaxe:a,value:r,valueObj:p,disabledDocumentIds:u,metadata:O})=>e(void 0,void 0,void 0,(function*(){const e="undefined"!=typeof window?window.location.hostname:"",b="undefined"!=typeof window?window.location.href:"",l=e.includes("pickaxe.co")&&!b.includes("https://studio.pickaxe.co/_embed"),I=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe/sse`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},n&&{responseId:n}),o&&{documentIds:o}),t&&{studioUserId:t}),i&&{deploymentId:i}),d&&{embedUserId:d}),c&&{studioSessionToken:c}),a&&{pickaxe:a}),r&&{value:r}),p&&{valueObj:p}),u&&{disabledDocumentIds:u}),O&&{metadata:O}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),l&&{credentials:"include"}));if(200!==I.status){const e=yield I.json();throw new Error(e.error||"Unknown error, please contact support")}if("application/json"===I.headers.get("content-type")){const{success:e,error:s}=yield I.json();if(!e)throw new Error(s||"Unknown error, please contact support")}return I})))(s)});export{n as useSubmit};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useMutation as s}from"@tanstack/react-query";const n=()=>s({mutationFn:s=>(({origin:s,pickaxeId:n,sessionId:o,deploymentId:t,sender:i,senderType:c,sessionToken:a,studioSessionToken:r,value:d,valueObj:p,documentIds:u,pickaxe:O,metadata:l})=>e(void 0,void 0,void 0,(function*(){const e="undefined"!=typeof window?window.location.hostname:"",j="undefined"!=typeof window?window.location.href:"",b=e.includes("pickaxe.co")&&!j.includes("https://studio.pickaxe.co/_embed"),g=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/sse`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:s,pickaxeId:n,senderType:c},o&&{sessionId:o}),t&&{deploymentId:t}),i&&{sender:i}),a&&{sessionToken:a}),r&&{studioSessionToken:r}),d&&{value:d}),p&&{valueObj:p}),u&&{documentIds:u}),O&&{pickaxe:O}),l&&{metadata:l}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),b&&{credentials:"include"}));if(200!==g.status){const e=yield g.json();throw new Error(e.error||"Unknown error, please contact support")}if("application/json"===g.headers.get("content-type")){const{success:e,error:s}=yield g.json();if(!e)throw new Error(s||"Unknown error, please contact support")}return g})))(s)});export{n as useSubmit};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({formId:s,sessionId:o,file:i,workspaceId:n,responseId:t,studioUserId:r,studioSessionToken:d,isKnowledge:c,isBlocking:a})=>e(void 0,void 0,void 0,(function*(){var e,l;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const p=i.name.split(".").pop(),_="md"===p?"md":i.type,u={formid:s,mimetype:_,extension:p,responseid:t,workspaceid:n,sessionid:o},O=new URLSearchParams(Object.entries(u).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),g=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${O.toString()}`,m=yield fetch(g),f=yield m.json();if(!f.success)throw new Error(null!==(e=f.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const I=new FormData;Object.entries(Object.assign(Object.assign({},f.fields),{file:i})).forEach((([e,s])=>{I.append(e,s)}));const w=yield fetch(f.url,{method:"POST",body:I});if(!w.ok)throw new Error(w.statusText);const P=`${f.url}${f.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",P),_.startsWith("image"))return{success:!0,documentId:`IMAGE-${f.documentId}-${f.folder}`};const b=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s,documentId:f.documentId,fileName:i.name,fileSize:i.size},n&&{workspaceId:n}),t&&{responseId:t}),r&&{studioUserId:r}),d&&{studioSessionToken:d}),c&&{isKnowledge:c}),a&&{isBlocking:a})),headers:{"Content-Type":"application/json"}}),L=yield b.json();if(!L.success)throw new Error(null!==(l=L.error)&&void 0!==l?l:"Failed processing document, try again or contact support.");return L})),website:({formId:o,website:i,workspaceId:n,responseId:t,studioUserId:r,studioSessionToken:d,isKnowledge:c,isBlocking:a})=>e(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const l=s(20),p=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o,documentId:l,website:i},n&&{workspaceId:n}),t&&{responseId:t}),r&&{studioUserId:r}),d&&{studioSessionToken:d}),c&&{isKnowledge:c}),a&&{isBlocking:a})),headers:{"Content-Type":"application/json"}}),_=yield p.json();if(!_.success)throw new Error(null!==(e=_.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return _}))});export{o as useSubmitDocument};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({contextId:s,pickaxeId:o,file:i,workspaceId:n,sessionId:t,studioUserId:r,studioSessionToken:d,isKnowledge:c,isBlocking:a})=>e(void 0,void 0,void 0,(function*(){var e,l;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const p=i.name.split(".").pop(),_="md"===p?"md":i.type,u={sessionid:s,formid:o,mimetype:_,extension:p,responseid:t,workspaceid:n},O=new URLSearchParams(Object.entries(u).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),g=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${O.toString()}`,m=yield fetch(g),f=yield m.json();if(!f.success)throw new Error(null!==(e=f.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const I=new FormData;Object.entries(Object.assign(Object.assign({},f.fields),{file:i})).forEach((([e,s])=>{I.append(e,s)}));const w=yield fetch(f.url,{method:"POST",body:I});if(!w.ok)throw new Error(w.statusText);const P=`${f.url}${f.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",P),_.startsWith("image"))return{success:!0,documentId:`IMAGE-${f.documentId}-${f.folder}`};const b=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o,documentId:f.documentId,fileName:i.name,fileSize:i.size},n&&{workspaceId:n}),t&&{responseId:t}),r&&{studioUserId:r}),d&&{studioSessionToken:d}),c&&{isKnowledge:c}),a&&{isBlocking:a})),headers:{"Content-Type":"application/json"}}),L=yield b.json();if(!L.success)throw new Error(null!==(l=L.error)&&void 0!==l?l:"Failed processing document, try again or contact support.");return L})),website:({pickaxeId:o,website:i,workspaceId:n,sessionId:t,studioUserId:r,studioSessionToken:d,isKnowledge:c,isBlocking:a})=>e(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const l=s(20),p=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o,documentId:l,website:i},n&&{workspaceId:n}),t&&{responseId:t}),r&&{studioUserId:r}),d&&{studioSessionToken:d}),c&&{isKnowledge:c}),a&&{isBlocking:a})),headers:{"Content-Type":"application/json"}}),_=yield p.json();if(!_.success)throw new Error(null!==(e=_.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return _}))});export{o as useSubmitDocument};