@pickaxeproject/react 6.23.5 → 6.23.7

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 (67) hide show
  1. package/dist/cjs/common/canChat.js +1 -0
  2. package/dist/cjs/common/embedAuthEvents.js +1 -0
  3. package/dist/cjs/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  10. package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
  11. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  12. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  13. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  14. package/dist/cjs/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  15. package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  16. package/dist/cjs/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
  17. package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  18. package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
  19. package/dist/cjs/index.js +1 -1
  20. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  21. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  22. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  23. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  24. package/dist/cjs/src/common/canChat.d.ts +5 -0
  25. package/dist/cjs/src/common/embedAuthEvents.d.ts +26 -0
  26. package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
  27. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +16 -2
  28. package/dist/cjs/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
  29. package/dist/cjs/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
  30. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
  31. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  32. package/dist/cjs/src/index.d.ts +5 -0
  33. package/dist/cjs/src/types/history.d.ts +3 -0
  34. package/dist/esm/common/canChat.js +1 -0
  35. package/dist/esm/common/embedAuthEvents.js +1 -0
  36. package/dist/esm/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
  37. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  38. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
  39. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  40. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  41. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  42. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  43. package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
  44. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  45. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  46. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  47. package/dist/esm/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  48. package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  49. package/dist/esm/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
  50. package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  51. package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
  52. package/dist/esm/index.js +1 -1
  53. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  54. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  55. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  56. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  57. package/dist/esm/src/common/canChat.d.ts +5 -0
  58. package/dist/esm/src/common/embedAuthEvents.d.ts +26 -0
  59. package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
  60. package/dist/esm/src/components/Pickaxe/Provider.d.ts +16 -2
  61. package/dist/esm/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
  62. package/dist/esm/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
  63. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
  64. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  65. package/dist/esm/src/index.d.ts +5 -0
  66. package/dist/esm/src/types/history.d.ts +3 -0
  67. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.canChat=e=>Boolean(e&&(e.chatflag||e.enablechatresponses));
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new Map,t=new Set,o=({deploymentId:e,pickaxeId:t,studioId:o})=>[o,t,e||""].map((e=>encodeURIComponent(e))).join(":"),n=e=>`PXE-pending-auth-${e}`,r=e=>`PXE-emitted-auth-${e}`,d=(e,t)=>{if("undefined"==typeof window)return;const o=`pickaxe:${e.event}`,n=Object.assign(Object.assign({},e),t);window.parent===window?window.dispatchEvent(new CustomEvent(o,{detail:n})):window.parent.postMessage({type:o,detail:n},(()=>{if("undefined"==typeof document||!document.referrer)return"";try{return new URL(document.referrer).origin}catch(e){return""}})()||"*")};exports.emitEmbedLogout=i=>{const a=o(i);e.delete(a),t.clear();try{window.localStorage.removeItem(n(a)),window.localStorage.removeItem(r(a))}catch(e){}d({event:"logout"},i)},exports.emitPendingEmbedAuthOutcome=({token:i,outcome:a,context:c})=>{if("undefined"==typeof window||!a)return;const w=o(c),m=`${w}:${i}`;let s=e.get(w);try{const e=n(w);if(s=window.localStorage.getItem(e)||s,s!==i)return;window.localStorage.removeItem(e),window.localStorage.setItem(r(w),i)}catch(e){}s!==i||t.has(m)||(e.delete(w),t.add(m),d({event:a,method:"email"},c))},exports.rememberPendingEmbedAuth=(t,r)=>{if("undefined"==typeof window)return;const d=o(t);e.set(d,r);try{window.localStorage.setItem(n(d),r)}catch(e){}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),r=require("../../../../common/cn.js"),o=require("../../../../common/error.js"),a=require("../../../../common/api/pickaxe.js"),n=require("../../../../common/utils.js"),s=require("../../../Core/ErrorAlert.js"),c=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),d=require("../../common/PickaxeButton.js"),u=require("../../common/PickaxeInput.js"),m=require("./hooks/useAuthContext.js");const v=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]);exports.default=({compact:f=!1})=>{const{pickaxe:x,translations:h,setSender:p,setSenderType:g}=c.usePickaxeContext(),{setLimitData:j}=l.useResponseContext(),{isPricingAuth:k,setToken:y,setIsPricingAuth:b}=m.useAuthContext(),[q,C]=t.useState(""),[P,S]=t.useState(""),[w,A]=t.useState(!1),O=(null==x?void 0:x.studioid)||"",I=(e,i)=>{var t;return null!==(t=null==h?void 0:h[e])&&void 0!==t?t:i};return i.jsxs("form",Object.assign({className:r.default("flex w-full flex-col items-center gap-2",f&&"max-w-[328px]"),onSubmit:i=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==q.length||w||!O)return;const e=n.getAuthToken(O);if(e){S(""),A(!0);try{const i=yield a.pickaxeApi2.post("/auth/verify",{token:e,code:q});if(!i.data.success)throw new Error(i.data.error||I("verification-code-invalid","Invalid verification code."));n.setAuthToken(`PXE-token-${O}`,e),y(e),p(void 0),g("STUDIO_USER"),k&&(b(!1),j(null))}catch(e){const i=o.default(e);S(v.has(i)?I("verification-code-invalid","Invalid verification code."):i||I("verification-code-invalid","Invalid verification code."))}finally{A(!1)}}else S(I("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[i.jsx("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:I("enter-verification-code","Or enter the 6-digit code from the email")})),i.jsxs("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[i.jsx(u.default,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:q,"aria-invalid":!!P,"aria-describedby":P?"email-verification-code-error":void 0,onChange:e=>{C(e.target.value.replace(/\D/g,"").slice(0,6)),S("")}}),i.jsx(d.default,Object.assign({className:r.default("shrink-0",f&&"min-h-[44px]"),loadingText:I("verifying","Verifying..."),isLoading:w,isDisabled:6!==q.length},{children:I("verify","Verify")}))]})),i.jsx("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:i.jsx(s.default,{error:P})}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),o=require("../../../../common/cn.js"),r=require("../../../../common/error.js"),n=require("../../../../common/api/pickaxe.js"),a=require("../../../../common/utils.js"),s=require("../../../Core/ErrorAlert.js"),c=require("../../../../hooks/pickaxe/usePickaxeContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../common/PickaxeButton.js"),u=require("../../common/PickaxeInput.js"),m=require("./hooks/useAuthContext.js"),v=require("../../../../common/embedAuthEvents.js");const f=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]);exports.default=({compact:x=!1})=>{const{deploymentId:h,isEmbed:p,pickaxe:g,translations:j,setSender:k,setSenderType:b}=c.usePickaxeContext(),{setLimitData:y}=d.useResponseContext(),{isPricingAuth:q,setToken:I,setIsPricingAuth:A}=m.useAuthContext(),[C,O]=t.useState(""),[P,S]=t.useState(""),[w,E]=t.useState(!1),T=(null==g?void 0:g.studioid)||"",_=(e,i)=>{var t;return null!==(t=null==j?void 0:j[e])&&void 0!==t?t:i};return i.jsxs("form",Object.assign({className:o.default("flex w-full flex-col items-center gap-2",x&&"max-w-[328px]"),onSubmit:i=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==C.length||w||!T)return;const e=a.getAuthToken(T);if(e){S(""),E(!0);try{const i=yield n.pickaxeApi2.post("/auth/verify",{token:e,code:C});if(!i.data.success)throw new Error(i.data.error||_("verification-code-invalid","Invalid verification code."));a.setAuthToken(`PXE-token-${T}`,e),I(e),k(void 0),b("STUDIO_USER"),p&&v.emitPendingEmbedAuthOutcome({token:e,outcome:i.data.authOutcome,context:{deploymentId:h,pickaxeId:(null==g?void 0:g.formid)||"",studioId:T}}),q&&(A(!1),y(null))}catch(e){const i=r.default(e);S(f.has(i)?_("verification-code-invalid","Invalid verification code."):i||_("verification-code-invalid","Invalid verification code."))}finally{E(!1)}}else S(_("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[i.jsx("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:_("enter-verification-code","Or enter the 6-digit code from the email")})),i.jsxs("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[i.jsx(u.default,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:C,"aria-invalid":!!P,"aria-describedby":P?"email-verification-code-error":void 0,onChange:e=>{O(e.target.value.replace(/\D/g,"").slice(0,6)),S("")}}),i.jsx(l.default,Object.assign({className:o.default("shrink-0",x&&"min-h-[44px]"),loadingText:_("verifying","Verifying..."),isLoading:w,isDisabled:6!==C.length},{children:_("verify","Verify")}))]})),i.jsx("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:i.jsx(s.default,{error:P})}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js");exports.useAuth=()=>{const{deploymentId:n,isEmbed:d,pickaxe:a,translations:u,setValidationStatus:l}=i.usePickaxeContext(),{emailInput:c,redirectUrl:m,isSending:p,setIsSending:f,setIsSent:h,setIsResendDisabled:k,setIsPricingAuth:v}=t.useAuthContext();return{onSend:i=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!a)return;if(p)return;const e=c.trim().toLowerCase();if(!e)throw new Error((null==u?void 0:u["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==u?void 0:u["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!a.studioid)throw new Error(`Studio ID is missing for ${a.formid}. Please contact support.`);f(!0),i&&k(!0);const t=(yield r.pickaxeApi2.post("/auth/email",Object.assign(Object.assign({pickaxeId:a.formid,studioId:a.studioid,email:e},n&&{deploymentId:n}),{redirectUrl:m}))).data;if(!t.success)throw new Error(t.error||(null==u?void 0:u["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");f(!1),h(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),k(!1)),s.setAuthToken(`PXE-token-${a.studioid}`,t.token),v(!0)}catch(e){const i=o.default(e);if(d&&"You must be invited to use this tool"===i)return void l("access_denied");alert(i)}finally{f(!1)}}))}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js"),n=require("../../../../../common/embedAuthEvents.js");exports.useAuth=()=>{const{deploymentId:d,isEmbed:a,pickaxe:u,translations:l,setValidationStatus:c}=i.usePickaxeContext(),{emailInput:m,redirectUrl:p,isSending:f,setIsSending:h,setIsSent:k,setIsResendDisabled:v,setIsPricingAuth:x}=t.useAuthContext();return{onSend:i=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!u)return;if(f)return;const e=m.trim().toLowerCase();if(!e)throw new Error((null==l?void 0:l["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==l?void 0:l["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!u.studioid)throw new Error(`Studio ID is missing for ${u.formid}. Please contact support.`);h(!0),i&&v(!0);const t=(yield r.pickaxeApi2.post("/auth/email",Object.assign(Object.assign({pickaxeId:u.formid,studioId:u.studioid,email:e},d&&{deploymentId:d}),{redirectUrl:p}))).data;if(!t.success)throw new Error(t.error||(null==l?void 0:l["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");h(!1),k(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),s.setAuthToken(`PXE-token-${u.studioid}`,t.token),a&&n.rememberPendingEmbedAuth({deploymentId:d,pickaxeId:u.formid,studioId:u.studioid},t.token),x(!0)}catch(e){const i=o.default(e);if(a&&"You must be invited to use this tool"===i)return void c("access_denied");alert(i)}finally{h(!1)}}))}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),n=require("./useAuthVerify.js"),u=require("../../../../../common/embedSession.js");exports.useAuthBootstrap=()=>{const{deploymentId:r,pickaxe:d,setSender:a,setSenderType:c}=t.usePickaxeContext(),{setLimitData:l}=s.useResponseContext(),{token:k,isLoggedOut:h,isPricingAuth:f,setToken:g,setIsLoggingIn:p,setIsPricingAuth:x,setIsAuthBootstrapComplete:m}=i.useAuthContext(),A=(null==d?void 0:d.studioid)||"",v=A?`PXE-token-${A}`:"",I=o.getAuthToken(A)||"",C=n.useAuthVerify({token:I,enabled:h&&!!I,setIsLoggingIn:p});e.useEffect((()=>{A&&m(!1)}),[m,A]);const E=e.useCallback((e=>{o.setAuthToken(v,e),g(e),a(void 0),c("STUDIO_USER"),f&&(x(!1),l(null))}),[v,f,x,l,a,c,g]);e.useEffect((()=>{if(!v)return;if(!C.data)return;const{success:e,token:t,error:s}=C.data;if(!e||s)return r&&(null==d?void 0:d.formid)&&I&&u.clearAuthenticatedEmbedSession({deploymentId:r,pickaxeId:d.formid,authToken:I}),o.deleteAuthToken(v),x(!1),void m(!0);t&&(E(t),m(!0))}),[E,v,C.data,r,null==d?void 0:d.formid,m,x,I]),e.useEffect((()=>{var e;A&&(k?m(!0):I?C.isLoading||C.isFetching||(C.isError||C.isSuccess&&!(null===(e=C.data)||void 0===e?void 0:e.token))&&m(!0):m(!0))}),[C.data,C.isError,C.isFetching,C.isLoading,C.isSuccess,m,I,A,k])};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),u=require("./useAuthVerify.js"),n=require("../../../../../common/embedSession.js"),r=require("../../../../../common/embedAuthEvents.js");exports.useAuthBootstrap=()=>{const{deploymentId:d,isEmbed:c,pickaxe:a,setSender:l,setSenderType:m}=t.usePickaxeContext(),{setLimitData:k}=s.useResponseContext(),{token:h,isLoggedOut:p,isPricingAuth:f,setToken:g,setIsLoggingIn:x,setIsPricingAuth:A,setIsAuthBootstrapComplete:I}=i.useAuthContext(),v=(null==a?void 0:a.studioid)||"",E=v?`PXE-token-${v}`:"",b=o.getAuthToken(v)||"",j=u.useAuthVerify({token:b,enabled:p&&!!b,setIsLoggingIn:x});e.useEffect((()=>{v&&I(!1)}),[I,v]);const q=e.useCallback((e=>{o.setAuthToken(E,e),g(e),l(void 0),m("STUDIO_USER"),f&&(A(!1),k(null))}),[E,f,A,k,l,m,g]);e.useEffect((()=>{if(!E)return;if(!j.data)return;const{success:e,token:t,authOutcome:s,error:i}=j.data;if(!e||i)return d&&(null==a?void 0:a.formid)&&b&&n.clearAuthenticatedEmbedSession({deploymentId:d,pickaxeId:a.formid,authToken:b}),o.deleteAuthToken(E),A(!1),void I(!0);t&&(q(t),c&&r.emitPendingEmbedAuthOutcome({token:t,outcome:s,context:{deploymentId:d,pickaxeId:(null==a?void 0:a.formid)||"",studioId:v}}),I(!0))}),[q,E,j.data,d,c,null==a?void 0:a.formid,I,A,b,v]),e.useEffect((()=>{var e;v&&(h?I(!0):b?j.isLoading||j.isFetching||(j.isError||j.isSuccess&&!(null===(e=j.data)||void 0===e?void 0:e.token))&&I(!0):I(!0))}),[j.data,j.isError,j.isFetching,j.isLoading,j.isSuccess,I,b,v,h])};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/formatUserMessage.js"),t=require("../../common/PickaxeMarkdown/Renderer.js"),a=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),l=require("../../common/PickaxeMarkdown/index.js"),d=require("../../common/PickaxeIcon.js"),c=require("./Document.js"),m=require("../../common/PickaxeMessageActions.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../../../common/cn.js"),p=require("../../../../common/isoMap.js"),f=require("franc-min"),j=require("../../common/ComposioConnectView.js"),g=require("../../common/SmitheryConnectView.js"),h=require("../../../../hooks/pickaxe/useTextToSpeech.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=v(require("remove-markdown"));exports.default=({index:v,message:k,smitheryData:y,resubmitPrompt:w,isLastMessage:O=!1})=>{var q,N;const{pickaxeId:C,pickaxe:I,styles:P,colors:A,misc:M,responsiveBy:R,disableHtml:S,disableJs:T,disableCss:L,isNewChat:F,isRtl:H}=i.usePickaxeContext(),{isGenerating:J}=o.useResponseContext(),{onLoadArtifact:U}=n.useArtifact(),V=r.useStyleFontSize(),z=null!==(q=null==I?void 0:I.chaticon)&&void 0!==q?q:`https://cdn.mail.studio/chaticons/${C}.png`,B=O&&J,D=null==I?void 0:I.enablereadout,{isLoading:_,isSpeaking:E,speak:G,stop:$}=h.useTextToSpeech(D&&"assistant"===k.role,{provider:null==I?void 0:I.readoutprovider,pickaxeId:C,voiceName:null==I?void 0:I.readoutvoice}),K=()=>{if(_||E)return void $();const e=k.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=b.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=f.franc(s),a=p.convertToIso1(t);G(s,a)},Q=!k.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",H?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:x.default("flex flex-col w-full",0===v&&F&&"viewport"===R&&"min-[767px]:max-w-[80%]",0===v&&F&&"container"===R&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:x.default("flex gap-x-3",H&&"flex-row-reverse")},{children:[M.isChatImage&&"NONE"!==z&&e.jsx(d.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:A.text}),e.jsxs("div",Object.assign({className:x.default("flex flex-col flex-grow",H?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:x.default(V.b2,"chat-message pt-3 w-full",H?"text-right":"text-left")},{children:[e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:A,isStreaming:B},H&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},L&&{disableCss:!0},{disableReasoning:null!==(N=null==I?void 0:I.enablereasoningdisplay)&&void 0!==N&&N,onArtifactClick:U},{children:e.jsx(u.default,{parts:k.parts,isStreaming:B})})),O&&y&&w&&("composio"===y.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(j.default,{serverId:y.serverId,toolkitSlug:y.toolkitSlug||"",name:y.name,resubmitPrompt:()=>w()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(g.default,{serverId:y.serverId,smitheryId:y.smitheryId||"",name:y.name||y.smitheryId,resubmitPrompt:()=>w()})})))]})),e.jsx("div",Object.assign({className:x.default("flex flex-col gap-6 my-4",Q&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:x.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:A.secondaryText}},t)))})):e.jsx(m.default,Object.assign({content:k.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:v},"intromessage"===k.area&&{isHideFeedback:!0},{onReadOut:K,isReadOut:D||!1,isReadOutLoading:_,isReading:E}))}))]}))]}))}))})):"user"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",H?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:x.default("flex gap-x-3 max-w-[80%]",H?"pr-9":"pl-9","viewport"===R?H?"min-[767px]:pr-0":"min-[767px]:pl-0":H?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:x.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",H?"text-right":"text-left"),style:{backgroundColor:A.secondary+"80",color:A.secondaryText,borderRadius:P.cornerRadius}},{children:[k.documentIds&&k.documentIds.length>0&&e.jsx("div",Object.assign({className:x.default("flex flex-col gap-y-2",H?"items-start":"items-end")},{children:k.documentIds.map((s=>e.jsx(a.Fragment,{children:e.jsx(c.default,{documentId:s})},s)))})),e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:A},H&&{rtl:!0},{disableHtml:!0,disableJs:!0,disableCss:!0},{children:k.parts.map(((a,i)=>"text"===a.type?e.jsx(t.PickaxeMarkdownRenderer,{value:s.formatUserMessage(a.content)},i):null))}))]}))}))})):e.jsx("div",{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/formatUserMessage.js"),t=require("../../common/PickaxeMarkdown/Renderer.js"),i=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),l=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("./Document.js"),m=require("../../common/PickaxeMessageActions.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../../../common/cn.js"),p=require("../../../../common/isoMap.js"),f=require("franc-min"),j=require("../../common/ComposioConnectView.js"),g=require("../../common/SmitheryConnectView.js"),h=require("../../../../hooks/pickaxe/useTextToSpeech.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=v(require("remove-markdown"));exports.default=({index:v,message:k,smitheryData:y,resubmitPrompt:w,isLastMessage:O=!1})=>{var q,N;const{pickaxeId:C,pickaxe:I,styles:P,colors:R,misc:A,responsiveBy:M,disableHtml:S,disableJs:T,disableCss:L,isNewChat:H,isRtl:F}=a.usePickaxeContext(),{isGenerating:J}=o.useResponseContext(),{onLoadArtifact:U}=n.useArtifact(),V=r.useStyleFontSize(),z=null!==(q=null==I?void 0:I.chaticon)&&void 0!==q?q:`https://cdn.mail.studio/chaticons/${C}.png`,B=O&&J,D=null==I?void 0:I.enablereadout,{isLoading:_,isSpeaking:E,speak:G,stop:$}=h.useTextToSpeech(D&&"assistant"===k.role,{provider:null==I?void 0:I.readoutprovider,pickaxeId:C,voiceName:null==I?void 0:I.readoutvoice}),K=()=>{if(_||E)return void $();const e=k.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=b.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=f.franc(s),i=p.convertToIso1(t);G(s,i)},Q=!k.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",F?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:x.default("flex flex-col w-full",0===v&&H&&"viewport"===M&&"min-[767px]:max-w-[80%]",0===v&&H&&"container"===M&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:x.default("flex gap-x-3",F&&"flex-row-reverse")},{children:[A.isChatImage&&"NONE"!==z&&e.jsx(c.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:R.text}),e.jsxs("div",Object.assign({className:x.default("flex flex-col flex-grow",F?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:x.default(V.b2,"chat-message pt-3 w-full",F?"text-right":"text-left")},{children:[e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:R,isStreaming:B},F&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},L&&{disableCss:!0},{disableReasoning:null!==(N=null==I?void 0:I.enablereasoningdisplay)&&void 0!==N&&N,onArtifactClick:U},{children:e.jsx(u.default,{parts:k.parts,isStreaming:B})})),O&&y&&w&&("composio"===y.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(j.default,{serverId:y.serverId,toolkitSlug:y.toolkitSlug||"",name:y.name,resubmitPrompt:()=>w()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(g.default,{serverId:y.serverId,smitheryId:y.smitheryId||"",name:y.name||y.smitheryId,resubmitPrompt:()=>w()})})))]})),e.jsx("div",Object.assign({className:x.default("flex flex-col gap-6 my-4",Q&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:x.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:R.secondaryText}},t)))})):e.jsx(m.default,Object.assign({responseReference:k.responseReference,content:k.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:v},"intromessage"===k.area&&{isHideFeedback:!0,isHideResponseAction:!0},{onReadOut:K,isReadOut:D||!1,isReadOutLoading:_,isReading:E}))}))]}))]}))}))})):"user"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",F?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:x.default("flex gap-x-3 max-w-[80%]",F?"pr-9":"pl-9","viewport"===M?F?"min-[767px]:pr-0":"min-[767px]:pl-0":F?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:x.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",F?"text-right":"text-left"),style:{backgroundColor:R.secondary+"80",color:R.secondaryText,borderRadius:P.cornerRadius}},{children:[k.documentIds&&k.documentIds.length>0&&e.jsx("div",Object.assign({className:x.default("flex flex-col gap-y-2",F?"items-start":"items-end")},{children:k.documentIds.map((s=>e.jsx(i.Fragment,{children:e.jsx(d.default,{documentId:s})},s)))})),e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:R},F&&{rtl:!0},{disableHtml:!0,disableJs:!0,disableCss:!0},{children:k.parts.map(((i,a)=>"text"===i.type?e.jsx(t.PickaxeMarkdownRenderer,{value:s.formatUserMessage(i.content)},a):null))}))]}))}))})):e.jsx("div",{})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),o=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),h=require("../../common/PickaxeEmbedHead.js"),j=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),v=require("../../Addons/Scroll/ScrollLockView.js"),b=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js"),O=require("../../../../common/chatMessages.js"),q=require("../../Addons/Auth/VerificationCodeForm.js");exports.default=({additionalScrollHeight:A,smitheryAuthData:S,isForceHideInfo:P,isInputFocused:I,onSubmit:L,resubmitPrompt:M})=>{var H,R,D,F,B;const{sessionId:E,deploymentType:T,pickaxe:z,translations:W,misc:$,isNewChat:_,isRtl:V,isEmbed:U,isShowIceBreaker:G,setSessionId:J,setLastSessionId:K}=i.usePickaxeContext(),{emailInput:Q,isLoggedOut:X,isSending:Y,isResendDisabled:Z,isSent:ee,isPricingAuth:se}=a.useAuthContext(),{onSend:ie}=t.useAuth(),{scrollContainerRef:ae,isLocked:te}=o.useScrollContext(),{messages:le,limitData:ne,error:oe}=l.useResponseContext(),{height:re,width:ce}=n.useDimensionContext(),{currentArtifact:de,chatPopupType:ue,currentPopupType:xe}=d.useArtifactContext(),me=c.useConversation(),fe=r.useStyleFontSize(),he=s.useMemo((()=>(null==z?void 0:z.icebreakers)?z.icebreakers.slice(0,3):[]),[null==z?void 0:z.icebreakers]),je=s.useMemo((()=>{const e=!!me.data&&me.data.messages.length>1;return!P&&me.isSuccess&&_&&!e}),[P,me.isSuccess,_,me.data]),ge=s.useMemo((()=>!(null==z?void 0:z.chatflag)&&(null==z?void 0:z.enablechatresponses)&&le.length>0),[z,le]),pe=s.useMemo((()=>!!me.data&&me.data.messages.some((e=>"intromessage"===e.area))),[me.data]),ve="chat-input"===T&&se&&X&&ee,be=G&&!I&&!pe&&je&&ce>767,ye=G&&!I&&(pe||ce<=767),ke=s.useMemo((()=>{var e,s;const i=null!==(s=null===(e=me.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return O.mergeConversationMessages(le,i)}),[null===(H=me.data)||void 0===H?void 0:H.messages,le]),we=()=>{K(E),J("")};return s.useLayoutEffect((()=>{if(!te)return;const e=ae.current;e&&(e.scrollTop=e.scrollHeight)}),[A,null===(R=me.data)||void 0===R?void 0:R.messages.length,te,ae,ke.length]),e.jsxs("div",Object.assign({ref:ae,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4 [overflow-anchor:none]"},{children:[e.jsx(u.AnimatePresence,{children:!!de&&"inline"===xe&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",ue),style:{height:`calc(${re-A}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(b.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[je&&U&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===T&&"right-12")},{children:e.jsx(p.default,{tip:(null==W?void 0:W["chat-history"])||"Chat History",onClick:we})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",je&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),U&&!me.isLoading&&e.jsx(h.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!je&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==W?void 0:W["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",U&&!me.isLoading&&!je&&"mt-0")},{children:[be&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===he.length&&"grid-cols-2",1===he.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:he,onSend:L})})),ve?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:Q}))]}))})),e.jsxs(k.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(D=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==D?D:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Z||Y||ie(!0)}},{children:Y?null!==(F=null==W?void 0:W.resending)&&void 0!==F?F:"Resending...":null!==(B=null==W?void 0:W.resend)&&void 0!==B?B:"Resend"}))]})),e.jsx(q.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:me.isLoading&&!(null==z?void 0:z.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):me.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(fe.b2,"text-center font-semibold")},{children:[(null==W?void 0:W["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==W?void 0:W["contact-us"])||"contact us"}))," ",(null==W?void 0:W["for-help"])||"for help."]}))})):me.data||ge?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[ke.map(((s,i)=>e.jsx(y.default,{smitheryData:S,resubmitPrompt:M,index:i,message:s,isLastMessage:i===ke.length-1},`message-${i}`))),ne?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(j.default,{})})):oe?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",V?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:oe})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!$.isWhiteLabel||ye&&"mt-4")},{children:[!$.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",ye&&"mb-2")}),ye&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:he,onSend:L})})),e.jsx(v.default,{})]}))]})):null})]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/canChat.js"),a=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),l=require("../../Addons/Auth/hooks/useAuth.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),c=require("../../../../hooks/studio/useStyleFontSize.js"),d=require("../../../../hooks/pickaxe/useConversation.js"),u=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),h=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),g=require("../../common/PickaxeUpgradeCard.js"),p=require("../../common/PickaxeSkeleton.js"),v=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),y=require("../../Addons/Artifact/Renderer/index.js"),k=require("./Message.js"),w=require("./CustomMessage.js"),N=require("../../Addons/IceBreaker/index.js"),C=require("../../common/PickaxeBranding.js"),O=require("../../../../common/cn.js"),q=require("../../../../common/chatMessages.js"),A=require("../../Addons/Auth/VerificationCodeForm.js");exports.default=({additionalScrollHeight:S,smitheryAuthData:P,isForceHideInfo:I,isInputFocused:L,onSubmit:M,resubmitPrompt:H})=>{var R,D,F,B,E;const{sessionId:T,deploymentType:z,pickaxe:W,translations:$,misc:_,isNewChat:V,isRtl:U,isEmbed:G,isShowIceBreaker:J,setSessionId:K,setLastSessionId:Q}=i.usePickaxeContext(),{emailInput:X,isLoggedOut:Y,isSending:Z,isResendDisabled:ee,isSent:se,isPricingAuth:ae}=t.useAuthContext(),{onSend:ie}=l.useAuth(),{scrollContainerRef:te,isLocked:le}=r.useScrollContext(),{messages:ne,limitData:oe,error:re}=n.useResponseContext(),{height:ce,width:de}=o.useDimensionContext(),{currentArtifact:ue,chatPopupType:me,currentPopupType:xe}=u.useArtifactContext(),he=d.useConversation(),fe=c.useStyleFontSize(),je=a.useMemo((()=>(null==W?void 0:W.icebreakers)?W.icebreakers.slice(0,3):[]),[null==W?void 0:W.icebreakers]),ge=a.useMemo((()=>{const e=!!he.data&&he.data.messages.length>1;return!I&&he.isSuccess&&V&&!e}),[I,he.isSuccess,V,he.data]),pe=a.useMemo((()=>!(null==W?void 0:W.chatflag)&&(null==W?void 0:W.enablechatresponses)&&ne.length>0),[W,ne]),ve=a.useMemo((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),be="chat-input"===z&&ae&&Y&&se,ye=s.canChat(W),ke=ye&&J&&!L&&!ve&&ge&&de>767,we=ye&&J&&!L&&(ve||de<=767),Ne=a.useMemo((()=>{var e,s;const a=null!==(s=null===(e=he.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return q.mergeConversationMessages(ne,a)}),[null===(R=he.data)||void 0===R?void 0:R.messages,ne]),Ce=()=>{Q(T),K("")};return a.useLayoutEffect((()=>{if(!le)return;const e=te.current;e&&(e.scrollTop=e.scrollHeight)}),[S,null===(D=he.data)||void 0===D?void 0:D.messages.length,le,te,Ne.length]),e.jsxs("div",Object.assign({ref:te,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4 [overflow-anchor:none]"},{children:[e.jsx(m.AnimatePresence,{children:!!ue&&"inline"===xe&&e.jsx(m.motion.div,Object.assign({className:O.default("absolute top-0 z-20 w-full px-4 py-2",me),style:{height:`calc(${ce-S}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(y.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:ue.id,version:ue.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[ge&&G&&e.jsx("div",Object.assign({className:O.default("absolute right-4 top-3 flex items-center gap-2","popup"===z&&"right-12")},{children:e.jsx(v.default,{tip:(null==$?void 0:$["chat-history"])||"Chat History",onClick:Ce})})),e.jsx(f.default,Object.assign({className:O.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",ge&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!be&&{onIconClick:Ce})),G&&!he.isLoading&&e.jsx(j.default,Object.assign({className:O.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!ge&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==$?void 0:$["chat-history"])||"Chat History"},!be&&{onIconClick:Ce,onHistoryClick:Ce})),e.jsxs("div",Object.assign({className:O.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",G&&!he.isLoading&&!ge&&"mt-0")},{children:[ke&&e.jsx("div",Object.assign({className:O.default("grid grid-cols-3 gap-4",2===je.length&&"grid-cols-2",1===je.length&&"grid-cols-1")},{children:e.jsx(N.default,{type:"center",data:je,onSend:M})})),be?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(w.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:X}))]}))})),e.jsxs(w.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==$?void 0:$["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{ee||Z||ie(!0)}},{children:Z?null!==(B=null==$?void 0:$.resending)&&void 0!==B?B:"Resending...":null!==(E=null==$?void 0:$.resend)&&void 0!==E?E:"Resend"}))]})),e.jsx(A.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:he.isLoading&&!(null==W?void 0:W.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[V&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(p.default,{className:"w-[72px] h-[72px]"}),e.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(p.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(p.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(p.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(p.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:O.default(fe.b2,"text-center font-semibold")},{children:[(null==$?void 0:$["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==$?void 0:$["contact-us"])||"contact us"}))," ",(null==$?void 0:$["for-help"])||"for help."]}))})):he.data||pe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[Ne.map(((s,a)=>e.jsx(k.default,{smitheryData:P,resubmitPrompt:H,index:a,message:s,isLastMessage:a===Ne.length-1},`message-${a}`))),oe?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(g.default,{})})):re?e.jsx("div",Object.assign({className:O.default("flex items-center gap-x-3",U?"justify-end":"justify-start")},{children:e.jsx(h.default,{error:re})})):null]})),e.jsxs("div",Object.assign({className:O.default("flex flex-col",!_.isWhiteLabel||we&&"mt-4")},{children:[!_.isWhiteLabel&&e.jsx(C.default,{containerClassName:O.default("justify-end",we&&"mb-2")}),we&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(N.default,{type:"right",data:je,onSend:M})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../hooks/pickaxe/useEndUserModel.js"),n=require("../common/EndUserModelPicker.js"),i=require("../../../common/actionApproval.js"),r=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),d=require("../../../hooks/studio/useStyleFontSize.js"),c=require("../../../hooks/pickaxe/useConversation.js"),u=require("../../../hooks/pickaxe/useDimensionContext.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),g=require("../Addons/Artifact/hooks/useArtifactContext.js"),v=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),b=require("../../../common/documents.js"),x=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),I=require("../../Icons/arrow-right.svg.js"),j=require("../../Icons/microphone.svg.js"),S=require("../../Icons/message-clock.svg.js"),N=require("../../Icons/stop.svg.js"),O=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),k=require("../Addons/Document/List.js"),_=require("../../Core/Textarea.js"),E=require("../../Core/ErrorAlert.js"),T=require("../../Core/Menu/index.js"),C=require("../../Core/Menu/Button.js"),U=require("../../Core/Menu/List.js"),A=require("../../../common/error.js"),D=require("../../../common/api/pickaxe.js"),P=require("../../../common/validation.js"),L=require("../../../common/cn.js"),q=require("../../../common/utils.js"),M=require("../../../common/pickaxeConfig.js"),R=require("../../../common/agentPrefill.js"),F=require("../../../common/deploymentWebhooks.js"),V=require("../../../hooks/studio/useStudio.js"),$=require("../../../hooks/pickaxe/useSpeechToText.js"),B=require("../common/PickaxeCommon.js");const X=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},K=e=>"string"==typeof e&&e.trim().length>0,G=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,H=e=>e.map((e=>Object.assign({},e))),Y=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),W=(e,t)=>{if(e&&"object"==typeof e)return e[t]},z=(e,t)=>{const s=W(e,t);return K(s)?s:null},J=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Q=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(W(e,"uses"))?W(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>K(e)?{type:"deployment",id:e}:K(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},Z=r.forwardRef((({resubmitPrompt:W,onFocus:Z,onBlur:ee,onInputHeightChange:te,initSmitheryAuthData:se},ne)=>{var ie,re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he,be,xe,ye,Ie;const{origin:je,pickaxeId:Se,sessionId:Ne,sender:Oe,senderType:we,portalId:ke,deploymentId:_e,deploymentType:Ee,pickaxe:Te,styles:Ce,colors:Ue,translations:Ae,locale:De,forceMobile:Pe,isNewChat:Le,isRtl:qe,isEmbed:Me,isShowFeedbackMessage:Re,accessGroup:Fe,setIsNewChat:Ve,setIsShowIceBreaker:$e,setValidationStatus:Be,setValidationUpgradeGroups:Xe,setValidationUpgradeUrl:Ke,setAccessGroup:Ge,onUpgrade:He,onGenerateComplete:Ye}=o.usePickaxeContext(),{value:We,enabled:ze}=s.useEndUserModel(),{token:Je,isLoggedOut:Qe,isSent:Ze,isPricingAuth:et}=p.useAuthContext(),{messages:tt,isGenerating:st,setMessages:nt,setStatus:it,setLimitData:rt,setError:ot,setActionApprovalToken:at}=a.useResponseContext(),{documents:lt,isUploading:dt,documentError:ct,onFileUpload:ut,setDocuments:pt,setDocumentError:mt}=m.useDocument(),{studio:ft}=V.useStudio(),[gt]=h.useMediaQuery("(max-width: 480px)"),{scrollStartSession:vt,scrollEndSession:ht,scrollToBottom:bt}=f.useScroll({auto:!0,smooth:!(Pe||gt)}),{artifacts:xt,currentPopupType:yt,setArtifacts:It,setCurrentArtifact:jt}=g.useArtifactContext(),{height:St}=u.useDimensionContext(),Nt=c.useConversation(),[Ot,wt]=r.useState((()=>R.readAgentPrefill([_e,Se]).chatInput)),[kt,_t]=r.useState(!1),[Et,Tt]=r.useState(!1),[Ct,Ut]=r.useState(!1),[At,Dt]=r.useState(!1),[Pt,Lt]=r.useState([]),[qt,Mt]=r.useState(!1),[Rt,Ft]=r.useState(null),[Vt,$t]=r.useState(null),[Bt,Xt]=r.useState(null),[Kt,Gt]=r.useState(null),[Ht,Yt]=r.useState(!1),[Wt,zt]=r.useState(!1),[Jt,Qt]=r.useState(0),Zt=r.useRef(null),es=r.useRef(""),ts=r.useRef(null),ss=r.useRef(null),ns=r.useRef(null),is=r.useRef([]),rs=r.useRef(null),os=r.useRef(null),as=r.useRef(null),ls=r.useRef(null),ds=r.useRef(new Set),cs=r.useRef(null),us=Math.max(.4*St,100),{speechTranscript:ps,isSpeechListening:ms,isSpeechProcessing:fs,isSpeechSupported:gs,onStartListening:vs,onStopListening:hs}=$.useSpeechToText(),bs=v.useHover(),{isHover:xs}=bs,ys=e.__rest(bs,["isHover"]),Is=v.useHover(),{isHover:js}=Is,Ss=e.__rest(Is,["isHover"]),Ns=v.useHover(),{isHover:Os}=Ns,ws=e.__rest(Ns,["isHover"]),ks=d.useStyleFontSize(),_s=l.useStyleInput(),Es="undefined"!=typeof window?window.location.hostname:"",Ts="undefined"!=typeof window?window.location.href:"",Cs="undefined"!=typeof window&&window.self!==window.top,Us=Es.includes("pickaxe.co")&&!Ts.includes("https://studio.pickaxe.co/_embed")&&!Cs,As=null!==(re=null===(ie=null==Te?void 0:Te.documentuploadtype)||void 0===ie?void 0:ie.startsWith("enduserupload"))&&void 0!==re&&re,Ds=gs&&(null==Te?void 0:Te.enablevoicetotext),Ps=ms&&!Ot.trim(),Ls=K(_e),qs="chat-input"===Ee&&Le&&!Ze,Ms="chat-input"===Ee&&et&&Qe&&Ze,Rs=r.useCallback((e=>{const t=P.getValidationFailure(e);return!!t&&(ot(""),rt(null),Be(t.status),Ge(t.accessGroup),Xe(t.upgradeGroups),Ke(t.upgradeUrl),!0)}),[ot,at,rt,Be,Xe,Ke,Ge]),Fs=null!==(oe=null==Te?void 0:Te.placeholdertext)&&void 0!==oe?oe:qe?"بماذا تريد أن تتحدث؟":(null==Ae?void 0:Ae["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Vs=kt||Et,$s=r.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Yt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==Te?void 0:Te.studioid},Je?{studioSessionToken:Je}:Oe?{sender:Oe}:{sender:q.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Us&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Xt(t.studioUser),Gt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Yt(!0)}}))),[Us,null==Te?void 0:Te.studioid,Oe,Je]);r.useEffect((()=>{$s()}),[$s]);const Bs=Number(null!==(ae=null==Fe?void 0:Fe.limit)&&void 0!==ae?ae:0),Xs="string"==typeof(null==Fe?void 0:Fe.limitInterval)?Fe.limitInterval:null,Ks=!!(null==ft?void 0:ft.data.usage)&&ft.data.usage.isCredits,Gs=r.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=ke?ke:z(Bt,"portalId"))&&void 0!==e?e:z(Bt,"portalid"))&&void 0!==t?t:z(Fe,"portalId"))&&void 0!==s?s:z(Fe,"portalid"))&&void 0!==n?n:z(Te,"portalId"))&&void 0!==i?i:z(Te,"portalid")}),[Fe,ke,Te,Bt]),Hs=r.useMemo((()=>Q({studioUser:Bt,deploymentId:_e,portalId:Gs})),[_e,Gs,Bt]);r.useEffect((()=>{Ls&&Le&&Ne&&ds.current.add(Ne)}),[Le,Ne,Ls]);const Ys=r.useCallback((()=>{var e,t,s;return{studioId:null==Te?void 0:Te.studioid,userEmail:z(Bt,"email"),userId:null!==(e=z(Bt,"userId"))&&void 0!==e?e:z(Bt,"userid"),sessionId:Ne,deploymentId:_e,deploymentType:Ee,portalId:Gs,accessGroupId:null!==(t=null==Fe?void 0:Fe.accessGroupId)&&void 0!==t?t:null,pickaxeId:Se,sender:Oe,senderType:we,origin:je,metadata:null!==(s=M.getPickaxeConfigMetadata(_e))&&void 0!==s?s:null}}),[null==Fe?void 0:Fe.accessGroupId,_e,Ee,je,null==Te?void 0:Te.studioid,Se,Gs,Oe,we,Ne,Bt]),Ws=r.useCallback((()=>!!(Ls&&Ht&&Ne)&&(!!ds.current.has(Ne)&&(F.fireDeploymentSessionInitializedWebhook(Ys()),ds.current.delete(Ne),!0))),[Ys,Ht,Ne,Ls]);r.useEffect((()=>{if(!Ht||!Ne)return;Ws();const e=cs.current;(null==e?void 0:e.sessionId)===Ne&&(F.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ys()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),cs.current=null)}),[Ws,Ys,Ht,Ne]);const zs={currentUses:J(null==Bt?void 0:Bt.currentUses),extraUses:J(null==Bt?void 0:Bt.extraUses)},Js=Hs.scope?{currentUses:null!==(de=J(null===(le=Hs.record)||void 0===le?void 0:le.currentUses))&&void 0!==de?de:0,extraUses:null!==(ue=J(null===(ce=Hs.record)||void 0===ce?void 0:ce.extraUses))&&void 0!==ue?ue:0}:{currentUses:0,extraUses:0},Qs=z(Bt,"type"),Zs="guest"===Qs||!Qs&&Qe?Js:zs;r.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Ks&&(null===(e=null==ft?void 0:ft.data)||void 0===e?void 0:e.workspaceId))try{const e=yield D.pickaxeApi2.get(`/cost_per_run?workspaceId=${ft.data.workspaceId}`,{withCredentials:!1});t&&Qt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Qt(0)}else t&&Qt(0)})),()=>{t=!1}}),[Ks,null===(pe=null==ft?void 0:ft.data)||void 0===pe?void 0:pe.workspaceId]);const en=(({accessGroupType:e,currentUses:t,extraUses:s,limit:n,limitInterval:i})=>{const r=Number(null!=t?t:0),o=Number(null!=s?s:0);return"public"===e&&"one_time"===i?n===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,n-r):n===B.STUDIO_INFINITY_VALUE||o===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:"one_time"===i?Math.max(0,o-r):Math.max(0,n-r)+o})({accessGroupType:null==Fe?void 0:Fe.type,currentUses:Zs.currentUses,extraUses:Zs.extraUses,limit:Bs,limitInterval:Xs}),tn=en===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(en)),sn=(({accessGroupType:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=t?t:0);return"public"===e&&"one_time"===n?s===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,s):s===B.STUDIO_INFINITY_VALUE||i===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,i):Math.max(0,s)+Math.max(0,i)})({accessGroupType:null==Fe?void 0:Fe.type,extraUses:Zs.extraUses,limit:Bs,limitInterval:Xs}),nn=sn===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.ceil(.05*sn),rn=Ks?Math.ceil(5*Jt):5,on=nn===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(nn,rn),an=r.useMemo((()=>!!Bt&&(!Wt&&(tn!==B.STUDIO_INFINITY_VALUE&&(!(sn<=0||tn>=sn)&&tn<=on)))),[Wt,on,tn,Bt,sn]),ln=Boolean(null==Fe?void 0:Fe.hideUpgradeOptions),dn=Boolean(!ln&&((null===(me=null==Fe?void 0:Fe.upgrade)||void 0===me?void 0:me.isBuyMoreUses)||(null===(fe=null==Fe?void 0:Fe.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)||(null===(ge=null==Fe?void 0:Fe.upgrade)||void 0===ge?void 0:ge.isUpgradeToAnotherGroup)&&(null===(ve=Fe.upgrade.accessGroupIds)||void 0===ve?void 0:ve.length))),cn=!ln&&(null===(he=null==Fe?void 0:Fe.upgrade)||void 0===he?void 0:he.isLinkToCustomURL)&&"string"==typeof Fe.upgrade.limitLink&&Fe.upgrade.limitLink.trim().length>0?Fe.upgrade.limitLink.trim():null,un=cn&&"string"==typeof(null===(be=null==Fe?void 0:Fe.upgrade)||void 0===be?void 0:be.limitCTA)&&Fe.upgrade.limitCTA.trim().length>0?Fe.upgrade.limitCTA:(null==Ae?void 0:Ae["pricing.upgrade"])||(null==Ae?void 0:Ae.upgrade)||"Upgrade",pn=r.useMemo((()=>{var e,t,s;return!!Le&&(!!Te&&(!Nt.isLoading&&(!((null!==(t=null===(e=Nt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Te.icebreakers)||void 0===s?void 0:s.length)&&(!Re&&!qs)))))}),[Te,Le,Re,qs,Nt.data,Nt.isLoading]),mn=r.useMemo((()=>{if(dt||Ct)return!1;const e=As&&lt.length>0&&lt.every((e=>"finished"===e.status));return!(!Ot.trim()&&!e)&&lt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[As,dt,Ct,Ot,lt]);r.useImperativeHandle(ne,(()=>({onSubmit:bn}))),r.useEffect((()=>{$e(pn)}),[pn]),r.useEffect((()=>{var e;if(W){const t=Array.from(tt),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;bn(s,!0)}}),[W]),r.useEffect((()=>{if(!as.current||!te)return;const e=new ResizeObserver((e=>{for(const t of e)te(t.contentRect.height)}));return e.observe(as.current),()=>{e.disconnect()}}),[te]),r.useEffect((()=>{if(!ms)return;const e=es.current?`${es.current} `:"";wt(`${e}${ps}`)}),[ps,ms]),r.useEffect((()=>{if(!rs.current)return;(()=>{if(!rs.current)return;let e=rs.current.scrollHeight>52;Ot.includes("\n")||lt.length?e=!0:Ot.trim()||(e=!1),_t(e)})()}),[Ot,lt]),r.useEffect((()=>{const e=rs.current,t=os.current;if(!e||!t||ze||kt||Ot.includes("\n"))return void Tt(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Ot||Fs,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Tt(r>l)}),[Ot,kt,Fs,ze]);const fn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:ss.current))return!1;const e=H(is.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},Us&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),gn=e=>{ns.current=e,ls.current&&(ls.current.abort(),ls.current=null),ts.current&&(ts.current.cancel().catch((()=>{})),ts.current=null)},vn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}))},Us&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),hn=()=>{const e=ss.current;e&&!Ct&&!dt&&Ot.trim()&&(Lt((t=>{var s,n;return[...t,{id:G(),message:Ot,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),wt(""))},bn=(t,s=!1,n=!1,r,o=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,a,l,d,c;let u=null;try{if(st&&!n||dt)return;const p=lt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),m=p.map((e=>e.documentId)).filter(Boolean),f=p.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:Ot,v=null!==(a=null===(e=null==Te?void 0:Te.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==a&&a&&m.length>0;if(!g&&!v)return;ot(""),mt(""),rt(null),wt(""),Ve(!1),Dt(!1),it("fetching"),vt(),bt();const h=s?tt.slice(0,tt.length-1):tt,b=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),y=b+(s?0:1),I={id:y,role:"assistant",parts:[],documentIds:[]},j=[...h,...s?[]:[{id:b,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:v?m:[]}],I];nt(j),bt(),v&&pt([]);const S=M.getPickaxeConfigMetadata(_e),N=null!=r?r:G();u=N,ss.current=N,ns.current=null,is.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,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({supportsActionConfirmation:!0,selectedModel:We||void 0,origin:je,pickaxeId:Se,sessionId:Ne,submissionId:N},o&&{interactionType:"steer"}),{senderType:we,value:g}),v&&{documentIds:m}),Oe&&{sender:Oe}),Je&&{studioSessionToken:Je}),!Je&&!Oe&&{sender:q.initializeEmbedUserId()}),Gs&&{portalId:Gs}),_e&&{deploymentId:_e}),S&&{metadata:S}),v&&f.length>0?{uploadedModelImages:f}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Us&&{credentials:"include"})),w=yield O.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==Ae?void 0:Ae["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Rs(w))return;throw new Error(w.error||w.message||(null==Ae?void 0:Ae["failed-to-start-generation"])||"Failed to start generation")}at(null!==(l=w.actionApprovalToken)&&void 0!==l?l:null);const k=null!==(d=w.submissionId)&&void 0!==d?d:N;u=k,ss.current=k;const _=()=>ns.current===k;if(_())return;Ls&&Le&&Ne&&ds.current.add(Ne);const E=Object.assign(Object.assign({},Ys()),{message:g,documentIds:v?m:[],uploadedModelImages:v?f:[],hasUploadedDocuments:v,isHidden:s,metadata:null!=S?S:null});Ht?(Ws(),F.fireDeploymentFirstMessageSubmittedWebhook(E)):cs.current=E,it("streaming"),ls.current=new AbortController;const T=[];let C=[...null!=xt?xt:[]],U=0,A=!1,D="";for(;!A;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${k}?index=${U}`,{signal:null===(c=ls.current)||void 0===c?void 0:c.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ts.current=t;const s=new TextDecoder,n=x.createParser({onEvent:e=>{var t,s;if(_())A=!0;else if(e.event&&"ping"!==e.event&&U++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return rt(t.limitData),ot(""),void(A=!0);const s=t.error||t.message||(null==Ae?void 0:Ae["something-went-wrong"])||"Something went wrong.";return Rs(t)||ot(s),void(A=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void Dt(!0);if("data-error"===n.type&&se){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw A=!0,se({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw A=!0,se({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw A=!0,se({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw A=!0,se({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)D="",T.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)D+=n.delta,i.updateStreamTextPart(T,"text",D);else if("text-end"===n.type)D="";else if("reasoning-start"===n.type)D="",T.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)D+=n.delta,i.updateStreamTextPart(T,"reasoning",D);else if("reasoning-end"===n.type)D="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?i.upsertActionApprovalPart(T,e.data):T.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}is.current=H(T);const r=H(T);nt((e=>{const t=e.findIndex((e=>e.id===y)),s=Object.assign(Object.assign({},I),{parts:r});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),It([...C]),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),It(C),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),It(C),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");C=C.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),It(C)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);It(C.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);if(t.limitData)return rt(t.limitData),ot(""),void(A=!0);const s=t.error||t.message||(null==Ae?void 0:Ae["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Rs(t))return void(A=!0);ot(s)}else"stop"===e.event&&(A=!0)}else A=!0}});for(;;){if(_()){A=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(_()){A=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}A||_()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||Y(e)||_())return void(A=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Ye||Ye(Ne)}catch(e){if(Y(e))return;if(e.limitData)rt(e.limitData),ot("");else{let t=A.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==Ae?void 0:Ae["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Rs(t)||ot(t)}}finally{const e=!u||ss.current===u;bt(),e&&(it("idle"),ht(),ts.current=null),u&&e&&(ss.current=null,is.current=[]),yield $s()}}));return r.useEffect((()=>{if(st||Ct||qt||0===Pt.length)return;const t=Pt[0];Mt(!0),Ft(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield vn(t.predecessorSubmissionId)))return void ot((null==Ae?void 0:Ae["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");Lt((e=>e.filter((e=>e.id!==t.id)))),yield bn(t.message,!1,!0,t.id)}finally{Mt(!1),Ft(null)}}))}),[st,qt,Ct,Pt]),Ms?null:t.jsx("div",Object.assign({className:L.default("flex w-full flex-shrink-0 flex-col items-center",!qs&&"px-4 pb-8"),dir:qe?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Pt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ue.text+"18",backgroundColor:null!==(xe=_s.backgroundColor)&&void 0!==xe?xe:Ue.text+"08",color:Ue.text,borderTopLeftRadius:Math.max(Ce.cornerRadius-4,12),borderTopRightRadius:Math.max(Ce.cornerRadius-4,12)}},{children:Pt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<Pt.length-1?{borderBottom:`1px solid ${Ue.text}12`}:void 0},{children:[t.jsx(S.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),Vt===s.id||Rt===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),Vt===s.id?(null==Ae?void 0:Ae.steering)||"Steering...":(null==Ae?void 0:Ae.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:Ct||!st,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=ss.current;if(!e||Ct)return;const s=Pt.findIndex((e=>e.id===t.id));if(-1===s)return;Ut(!0),$t(t.id),ot(""),gn(e);let n=!1;try{if(!(yield fn(e)))throw new Error((null==Ae?void 0:Ae["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield vn(e)))throw new Error((null==Ae?void 0:Ae["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");it("idle"),Lt((e=>e.filter((e=>e.id!==t.id)))),n=!0,Ut(!1),$t(null),yield bn(t.message,!1,!0,t.id,!0)}catch(e){it("idle"),n&&Lt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),ot(A.default(e))}finally{Ut(!1),$t(null)}}))})(s)},"aria-label":`${(null==Ae?void 0:Ae["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ae?void 0:Ae.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:Ct,onClick:()=>{return e=s.id,void Lt((t=>X(t,e)));var e},"aria-label":`${(null==Ae?void 0:Ae["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(O.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(T.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(C.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ct,role:"button",tabIndex:Ct?-1:0,"aria-haspopup":"menu","aria-label":(null==Ae?void 0:Ae["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(U.default,Object.assign({role:"menu",align:qe?"bottom-start":"bottom-end",positionStrategy:Me?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=_s.backgroundColor)&&void 0!==i?i:Ue.primary,color:Ue.text,borderRadius:"12px"},border:`1px solid ${Ue.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{Lt((t=>X(t,e.id))),wt(e.message),requestAnimationFrame((()=>{const t=rs.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(w.default,{className:"h-4 w-4 shrink-0"}),(null==Ae?void 0:Ae["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:as,className:L.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ce.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},_s),{maxHeight:`${us}px`,overflowY:"auto"})},{children:[an&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:_s.backgroundColor?`${_s.backgroundColor}E6`:void 0,borderColor:Ue.text+"20",color:Ue.text,borderTopRightRadius:Ce.cornerRadius+"px",borderTopLeftRadius:Ce.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[tn.toLocaleString()," ",Ks?(null==Ae?void 0:Ae.credits)||"Credits":(null==Ae?void 0:Ae.uses)||"Uses"," ",(null==Ae?void 0:Ae.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[dn&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ue.accent,color:Ue.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),cn)return void window.open(cn,"_blank","noopener,noreferrer");if(He)return void He();const t=q.buildUpgradeUrl({baseUrl:Kt,accessGroupId:null==Fe?void 0:Fe.accessGroupId});t&&q.openAuthenticatedPricingUrl({deploymentId:_e,pricingUrl:t,studioId:null==Te?void 0:Te.studioid,studioSessionToken:Je})}},{children:un})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>zt(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!st&&lt.length>0&&t.jsx(k.default,{className:"p-4 pb-0",isDisabled:st}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ps&&t.jsxs("div",Object.assign({className:L.default(ze?"top-6":"top-1/2","pointer-events-none absolute z-10 flex -translate-y-1/2 select-none items-center gap-x-2",qe?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(ye=Ue.accent)&&void 0!==ye?ye:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ue.text+"90"}},{children:(null==Ae?void 0:Ae.listening)||"Listening..."}))]})),t.jsx(_.default,Object.assign({ref:rs,className:L.default(ks.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ot.trim()&&!Ot.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",qe?"text-right":"text-left",!ze&&Vs&&"mb-12"),value:Ot,placeholder:Ps?"":Fs,onChange:e=>{wt(e)},onKeyDown:e=>{Pe||gt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),dt||Ct||(st?hn():bn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!As)return;t.preventDefault(),Ve(!1),yield ut(e)}}))},Z&&{onFocus:Z},ee&&{onBlur:ee},{dir:qe?"rtl":"ltr"})),t.jsxs("div",Object.assign({ref:os,className:ze?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":L.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",Vs?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Vs&&_s.backgroundColor&&{backgroundColor:_s.backgroundColor}),{borderTopRightRadius:Ce.cornerRadius+"px",borderBottomRightRadius:Ce.cornerRadius+"px"})},{children:[!st&&!ms&&As&&t.jsxs("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:js?Ue.accent+"10":void 0,color:js?Ue.accent:Ue.accent+"80"},disabled:dt||st,"aria-label":null!==(Ie=null==Ae?void 0:Ae["attach-files"])&&void 0!==Ie?Ie:"Attach files",onClick:()=>{var e;return null===(e=Zt.current)||void 0===e?void 0:e.click()}},Ss,{children:[t.jsx("input",{id:"file-upload",ref:Zt,type:"file",accept:[...b.allowedFileMimeTypes,...b.allowedImageMimeTypes,...b.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Ve(!1),yield ut(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),t.jsx(n.default,{compact:!0}),st&&!At?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ae?void 0:Ae["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=ss.current;e&&(gn(e),fn(e)),it("idle")},style:{backgroundColor:Ue.accent+"10",color:Ue.accent}},{children:t.jsx(N.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ae?void 0:Ae["queue-message"])||"Queue message",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",disabled:Ct||dt||!Ot.trim(),onClick:hn,style:{backgroundColor:Ot.trim()?Ue.accent:Ue.accent+"10",color:Ot.trim()?Ue.accentText:Ue.accent+"80"}},{children:t.jsx(I.default,{className:L.default("h-6 w-6 shrink-0",qe&&"scale-x-[-1] transform")})}))]}):ms?t.jsx("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:hs,style:{backgroundColor:Ue.accent,color:Ue.accentText}},{children:t.jsx(N.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ds&&t.jsx("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:ms?Ue.accent:Os?Ue.accent+"10":void 0,color:ms?Ue.accentText:Os?Ue.accent:Ue.accent+"80"},disabled:dt||st||fs,onClick:()=>{ms?hs():(es.current=Ot,vs(De||"en-US"))}},ws,{children:t.jsx(j.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("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:xs||mn?Ue.accent:Ue.accent+"10",color:xs||mn?Ue.accentText:Ue.accent+"80"},disabled:!mn,onClick:()=>bn()},ys,{children:t.jsx(I.default,{className:L.default("h-6 w-6 shrink-0",qe&&"scale-x-[-1] transform")})}))]})]}))]}))]})),ct&&t.jsx(E.default,{error:ct,className:"mt-3"})]}))}))}));Z.displayName="Input",exports.default=Z;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../common/canChat.js"),n=require("../../../hooks/pickaxe/useEndUserModel.js"),i=require("../common/EndUserModelPicker.js"),r=require("../../../common/actionApproval.js"),o=require("react"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../hooks/pickaxe/useResponseContext.js"),d=require("../../../hooks/studio/useStyleInput.js"),c=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/pickaxe/useConversation.js"),p=require("../../../hooks/pickaxe/useDimensionContext.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("../Addons/Document/hooks/useDocument.js"),g=require("../Addons/Scroll/hooks/useScroll.js"),v=require("../Addons/Artifact/hooks/useArtifactContext.js"),h=require("../../../hooks/core/useHover.js"),b=require("../../../hooks/core/useMediaQuery.js"),x=require("../../../common/documents.js"),y=require("eventsource-parser"),I=require("../../Icons/attach-vertical.svg.js"),j=require("../../Icons/arrow-right.svg.js"),S=require("../../Icons/microphone.svg.js"),N=require("../../Icons/message-clock.svg.js"),O=require("../../Icons/stop.svg.js"),w=require("../../Icons/trash.svg.js"),k=require("../../Icons/pencil.svg.js"),_=require("../Addons/Document/List.js"),E=require("../../Core/Textarea.js"),T=require("../../Core/ErrorAlert.js"),C=require("../../Core/Menu/index.js"),U=require("../../Core/Menu/Button.js"),A=require("../../Core/Menu/List.js"),D=require("../../../common/error.js"),P=require("../../../common/api/pickaxe.js"),L=require("../../../common/validation.js"),q=require("../../../common/cn.js"),M=require("../../../common/utils.js"),R=require("../../../common/pickaxeConfig.js"),F=require("../../../common/agentPrefill.js"),V=require("../../../common/deploymentWebhooks.js"),$=require("../../../hooks/studio/useStudio.js"),B=require("../../../hooks/pickaxe/useSpeechToText.js"),X=require("../common/PickaxeCommon.js");const K=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},G=e=>"string"==typeof e&&e.trim().length>0,H=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,Y=e=>e.map((e=>Object.assign({},e))),W=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),z=(e,t)=>{if(e&&"object"==typeof e)return e[t]},J=(e,t)=>{const s=z(e,t);return G(s)?s:null},Q=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Z=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(z(e,"uses"))?z(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>G(e)?{type:"deployment",id:e}:G(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},ee=o.forwardRef((({resubmitPrompt:z,onFocus:ee,onBlur:te,onInputHeightChange:se,initSmitheryAuthData:ne},ie)=>{var re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he,be,xe,ye,Ie,je;const{origin:Se,pickaxeId:Ne,sessionId:Oe,sender:we,senderType:ke,portalId:_e,deploymentId:Ee,deploymentType:Te,pickaxe:Ce,styles:Ue,colors:Ae,translations:De,locale:Pe,forceMobile:Le,isNewChat:qe,isRtl:Me,isEmbed:Re,isShowFeedbackMessage:Fe,accessGroup:Ve,setIsNewChat:$e,setIsShowIceBreaker:Be,setValidationStatus:Xe,setValidationUpgradeGroups:Ke,setValidationUpgradeUrl:Ge,setAccessGroup:He,onUpgrade:Ye,onGenerateComplete:We}=a.usePickaxeContext(),{value:ze,enabled:Je}=n.useEndUserModel(),{token:Qe,isLoggedOut:Ze,isSent:et,isPricingAuth:tt}=m.useAuthContext(),{messages:st,isGenerating:nt,setMessages:it,setStatus:rt,setLimitData:ot,setError:at,setActionApprovalToken:lt}=l.useResponseContext(),{documents:dt,isUploading:ct,documentError:ut,onFileUpload:pt,setDocuments:mt,setDocumentError:ft}=f.useDocument(),{studio:gt}=$.useStudio(),[vt]=b.useMediaQuery("(max-width: 480px)"),{scrollStartSession:ht,scrollEndSession:bt,scrollToBottom:xt}=g.useScroll({auto:!0,smooth:!(Le||vt)}),{artifacts:yt,currentPopupType:It,setArtifacts:jt,setCurrentArtifact:St}=v.useArtifactContext(),{height:Nt}=p.useDimensionContext(),Ot=u.useConversation(),[wt,kt]=o.useState((()=>F.readAgentPrefill([Ee,Ne]).chatInput)),[_t,Et]=o.useState(!1),[Tt,Ct]=o.useState(!1),[Ut,At]=o.useState(!1),[Dt,Pt]=o.useState(!1),[Lt,qt]=o.useState([]),[Mt,Rt]=o.useState(!1),[Ft,Vt]=o.useState(null),[$t,Bt]=o.useState(null),[Xt,Kt]=o.useState(null),[Gt,Ht]=o.useState(null),[Yt,Wt]=o.useState(!1),[zt,Jt]=o.useState(!1),[Qt,Zt]=o.useState(0),es=o.useRef(null),ts=o.useRef(""),ss=o.useRef(null),ns=o.useRef(null),is=o.useRef(null),rs=o.useRef([]),os=o.useRef(null),as=o.useRef(null),ls=o.useRef(null),ds=o.useRef(null),cs=o.useRef(new Set),us=o.useRef(null),ps=Math.max(.4*Nt,100),{speechTranscript:ms,isSpeechListening:fs,isSpeechProcessing:gs,isSpeechSupported:vs,onStartListening:hs,onStopListening:bs}=B.useSpeechToText(),xs=h.useHover(),{isHover:ys}=xs,Is=e.__rest(xs,["isHover"]),js=h.useHover(),{isHover:Ss}=js,Ns=e.__rest(js,["isHover"]),Os=h.useHover(),{isHover:ws}=Os,ks=e.__rest(Os,["isHover"]),_s=c.useStyleFontSize(),Es=d.useStyleInput(),Ts="undefined"!=typeof window?window.location.hostname:"",Cs="undefined"!=typeof window?window.location.href:"",Us="undefined"!=typeof window&&window.self!==window.top,As=Ts.includes("pickaxe.co")&&!Cs.includes("https://studio.pickaxe.co/_embed")&&!Us,Ds=null!==(oe=null===(re=null==Ce?void 0:Ce.documentuploadtype)||void 0===re?void 0:re.startsWith("enduserupload"))&&void 0!==oe&&oe,Ps=vs&&(null==Ce?void 0:Ce.enablevoicetotext),Ls=fs&&!wt.trim(),qs=G(Ee),Ms="chat-input"===Te&&qe&&!et,Rs="chat-input"===Te&&tt&&Ze&&et,Fs=o.useCallback((e=>{const t=L.getValidationFailure(e);return!!t&&(at(""),ot(null),Xe(t.status),He(t.accessGroup),Ke(t.upgradeGroups),Ge(t.upgradeUrl),!0)}),[at,lt,ot,Xe,Ke,Ge,He]),Vs=null!==(ae=null==Ce?void 0:Ce.placeholdertext)&&void 0!==ae?ae:Me?"بماذا تريد أن تتحدث؟":(null==De?void 0:De["what-do-you-want-to-talk-about"])||"What do you want to talk about?",$s=_t||Tt,Bs=o.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Wt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==Ce?void 0:Ce.studioid},Qe?{studioSessionToken:Qe}:we?{sender:we}:{sender:M.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),As&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Kt(t.studioUser),Ht(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Wt(!0)}}))),[As,null==Ce?void 0:Ce.studioid,we,Qe]);o.useEffect((()=>{Bs()}),[Bs]);const Xs=Number(null!==(le=null==Ve?void 0:Ve.limit)&&void 0!==le?le:0),Ks="string"==typeof(null==Ve?void 0:Ve.limitInterval)?Ve.limitInterval:null,Gs=!!(null==gt?void 0:gt.data.usage)&&gt.data.usage.isCredits,Hs=o.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=_e?_e:J(Xt,"portalId"))&&void 0!==e?e:J(Xt,"portalid"))&&void 0!==t?t:J(Ve,"portalId"))&&void 0!==s?s:J(Ve,"portalid"))&&void 0!==n?n:J(Ce,"portalId"))&&void 0!==i?i:J(Ce,"portalid")}),[Ve,_e,Ce,Xt]),Ys=o.useMemo((()=>Z({studioUser:Xt,deploymentId:Ee,portalId:Hs})),[Ee,Hs,Xt]);o.useEffect((()=>{qs&&qe&&Oe&&cs.current.add(Oe)}),[qe,Oe,qs]);const Ws=o.useCallback((()=>{var e,t,s;return{studioId:null==Ce?void 0:Ce.studioid,userEmail:J(Xt,"email"),userId:null!==(e=J(Xt,"userId"))&&void 0!==e?e:J(Xt,"userid"),sessionId:Oe,deploymentId:Ee,deploymentType:Te,portalId:Hs,accessGroupId:null!==(t=null==Ve?void 0:Ve.accessGroupId)&&void 0!==t?t:null,pickaxeId:Ne,sender:we,senderType:ke,origin:Se,metadata:null!==(s=R.getPickaxeConfigMetadata(Ee))&&void 0!==s?s:null}}),[null==Ve?void 0:Ve.accessGroupId,Ee,Te,Se,null==Ce?void 0:Ce.studioid,Ne,Hs,we,ke,Oe,Xt]),zs=o.useCallback((()=>!!(qs&&Yt&&Oe)&&(!!cs.current.has(Oe)&&(V.fireDeploymentSessionInitializedWebhook(Ws()),cs.current.delete(Oe),!0))),[Ws,Yt,Oe,qs]);o.useEffect((()=>{if(!Yt||!Oe)return;zs();const e=us.current;(null==e?void 0:e.sessionId)===Oe&&(V.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ws()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),us.current=null)}),[zs,Ws,Yt,Oe]);const Js={currentUses:Q(null==Xt?void 0:Xt.currentUses),extraUses:Q(null==Xt?void 0:Xt.extraUses)},Qs=Ys.scope?{currentUses:null!==(ce=Q(null===(de=Ys.record)||void 0===de?void 0:de.currentUses))&&void 0!==ce?ce:0,extraUses:null!==(pe=Q(null===(ue=Ys.record)||void 0===ue?void 0:ue.extraUses))&&void 0!==pe?pe:0}:{currentUses:0,extraUses:0},Zs=J(Xt,"type"),en="guest"===Zs||!Zs&&Ze?Qs:Js;o.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Gs&&(null===(e=null==gt?void 0:gt.data)||void 0===e?void 0:e.workspaceId))try{const e=yield P.pickaxeApi2.get(`/cost_per_run?workspaceId=${gt.data.workspaceId}`,{withCredentials:!1});t&&Zt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Zt(0)}else t&&Zt(0)})),()=>{t=!1}}),[Gs,null===(me=null==gt?void 0:gt.data)||void 0===me?void 0:me.workspaceId]);const tn=(({accessGroupType:e,currentUses:t,extraUses:s,limit:n,limitInterval:i})=>{const r=Number(null!=t?t:0),o=Number(null!=s?s:0);return"public"===e&&"one_time"===i?n===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,n-r):n===X.STUDIO_INFINITY_VALUE||o===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:"one_time"===i?Math.max(0,o-r):Math.max(0,n-r)+o})({accessGroupType:null==Ve?void 0:Ve.type,currentUses:en.currentUses,extraUses:en.extraUses,limit:Xs,limitInterval:Ks}),sn=tn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(tn)),nn=(({accessGroupType:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=t?t:0);return"public"===e&&"one_time"===n?s===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,s):s===X.STUDIO_INFINITY_VALUE||i===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,i):Math.max(0,s)+Math.max(0,i)})({accessGroupType:null==Ve?void 0:Ve.type,extraUses:en.extraUses,limit:Xs,limitInterval:Ks}),rn=nn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.ceil(.05*nn),on=Gs?Math.ceil(5*Qt):5,an=rn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(rn,on),ln=o.useMemo((()=>!!Xt&&(!zt&&(sn!==X.STUDIO_INFINITY_VALUE&&(!(nn<=0||sn>=nn)&&sn<=an)))),[zt,an,sn,Xt,nn]),dn=Boolean(null==Ve?void 0:Ve.hideUpgradeOptions),cn=Boolean(!dn&&((null===(fe=null==Ve?void 0:Ve.upgrade)||void 0===fe?void 0:fe.isBuyMoreUses)||(null===(ge=null==Ve?void 0:Ve.upgrade)||void 0===ge?void 0:ge.isLinkToCustomURL)||(null===(ve=null==Ve?void 0:Ve.upgrade)||void 0===ve?void 0:ve.isUpgradeToAnotherGroup)&&(null===(he=Ve.upgrade.accessGroupIds)||void 0===he?void 0:he.length))),un=!dn&&(null===(be=null==Ve?void 0:Ve.upgrade)||void 0===be?void 0:be.isLinkToCustomURL)&&"string"==typeof Ve.upgrade.limitLink&&Ve.upgrade.limitLink.trim().length>0?Ve.upgrade.limitLink.trim():null,pn=un&&"string"==typeof(null===(xe=null==Ve?void 0:Ve.upgrade)||void 0===xe?void 0:xe.limitCTA)&&Ve.upgrade.limitCTA.trim().length>0?Ve.upgrade.limitCTA:(null==De?void 0:De["pricing.upgrade"])||(null==De?void 0:De.upgrade)||"Upgrade",mn=o.useMemo((()=>{var e,t,s;return!!qe&&(!!Ce&&(!Ot.isLoading&&(!((null!==(t=null===(e=Ot.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Ce.icebreakers)||void 0===s?void 0:s.length)&&(!Fe&&!Ms)))))}),[Ce,qe,Fe,Ms,Ot.data,Ot.isLoading]),fn=o.useMemo((()=>{if(ct||Ut)return!1;const e=Ds&&dt.length>0&&dt.every((e=>"finished"===e.status));return!(!wt.trim()&&!e)&&dt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ds,ct,Ut,wt,dt]);o.useImperativeHandle(ie,(()=>({onSubmit:xn}))),o.useEffect((()=>{Be(mn)}),[mn]),o.useEffect((()=>{var e;if(z){const t=Array.from(st),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;xn(s,!0)}}),[z]),o.useEffect((()=>{if(!ls.current||!se)return;const e=new ResizeObserver((e=>{for(const t of e)se(t.contentRect.height)}));return e.observe(ls.current),()=>{e.disconnect()}}),[se]),o.useEffect((()=>{if(!fs)return;const e=ts.current?`${ts.current} `:"";kt(`${e}${ms}`)}),[ms,fs]),o.useEffect((()=>{if(!os.current)return;(()=>{if(!os.current)return;let e=os.current.scrollHeight>52;wt.includes("\n")||dt.length?e=!0:wt.trim()||(e=!1),Et(e)})()}),[wt,dt]),o.useEffect((()=>{const e=os.current,t=as.current;if(!e||!t||Je||_t||wt.includes("\n"))return void Ct(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=wt||Vs,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ct(r>l)}),[wt,_t,Vs,Je]);const gn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:ns.current))return!1;const e=Y(rs.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},As&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),vn=e=>{is.current=e,ds.current&&(ds.current.abort(),ds.current=null),ss.current&&(ss.current.cancel().catch((()=>{})),ss.current=null)},hn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}))},As&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),bn=()=>{const e=ns.current;e&&!Ut&&!ct&&wt.trim()&&(qt((t=>{var s,n;return[...t,{id:H(),message:wt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),kt(""))},xn=(t,n=!1,i=!1,o,a=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,l,d,c,u;if(!s.canChat(Ce))return;let p=null;try{if(nt&&!i||ct)return;const s=dt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),m=s.map((e=>e.documentId)).filter(Boolean),f=s.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:wt,v=null!==(l=null===(e=null==Ce?void 0:Ce.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==l&&l&&m.length>0;if(!g&&!v)return;at(""),ft(""),ot(null),kt(""),$e(!1),Pt(!1),rt("fetching"),ht(),xt();const h=n?st.slice(0,st.length-1):st,b=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),x=b+(n?0:1),I={id:x,role:"assistant",parts:[],documentIds:[]},j=[...h,...n?[]:[{id:b,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:v?m:[]}],I];it(j),xt(),v&&mt([]);const S=R.getPickaxeConfigMetadata(Ee),N=null!=o?o:H();p=N,ns.current=N,is.current=null,rs.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,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({supportsActionConfirmation:!0,selectedModel:ze||void 0,origin:Se,pickaxeId:Ne,sessionId:Oe,submissionId:N},a&&{interactionType:"steer"}),{senderType:ke,value:g}),v&&{documentIds:m}),we&&{sender:we}),Qe&&{studioSessionToken:Qe}),!Qe&&!we&&{sender:M.initializeEmbedUserId()}),Hs&&{portalId:Hs}),Ee&&{deploymentId:Ee}),S&&{metadata:S}),v&&f.length>0?{uploadedModelImages:f}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},As&&{credentials:"include"})),w=yield O.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==De?void 0:De["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Fs(w))return;throw new Error(w.error||w.message||(null==De?void 0:De["failed-to-start-generation"])||"Failed to start generation")}lt(null!==(d=w.actionApprovalToken)&&void 0!==d?d:null);const k=null!==(c=w.submissionId)&&void 0!==c?c:N;p=k,ns.current=k;const _=()=>is.current===k;if(_())return;qs&&qe&&Oe&&cs.current.add(Oe);const E=Object.assign(Object.assign({},Ws()),{message:g,documentIds:v?m:[],uploadedModelImages:v?f:[],hasUploadedDocuments:v,isHidden:n,metadata:null!=S?S:null});Yt?(zs(),V.fireDeploymentFirstMessageSubmittedWebhook(E)):us.current=E,rt("streaming"),ds.current=new AbortController;const T=[];let C=[...null!=yt?yt:[]],U=0,A=!1,D="";for(;!A;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${k}?index=${U}`,{signal:null===(u=ds.current)||void 0===u?void 0:u.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ss.current=t;const s=new TextDecoder,n=y.createParser({onEvent:e=>{var t,s;if(_())A=!0;else if(e.event&&"ping"!==e.event&&U++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return ot(t.limitData),at(""),void(A=!0);const s=t.error||t.message||(null==De?void 0:De["something-went-wrong"])||"Something went wrong.";return Fs(t)||at(s),void(A=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void Pt(!0);if("data-error"===n.type&&ne){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw A=!0,ne({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw A=!0,ne({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw A=!0,ne({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw A=!0,ne({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)D="",T.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)D+=n.delta,r.updateStreamTextPart(T,"text",D);else if("text-end"===n.type)D="";else if("reasoning-start"===n.type)D="",T.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)D+=n.delta,r.updateStreamTextPart(T,"reasoning",D);else if("reasoning-end"===n.type)D="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?r.upsertActionApprovalPart(T,e.data):T.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}rs.current=Y(T);const i=Y(T);it((e=>{const t=e.findIndex((e=>e.id===x)),s=Object.assign(Object.assign({},I),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),jt([...C]),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),jt(C),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),jt(C),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");C=C.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),jt(C)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);jt(C.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);if(t.limitData)return ot(t.limitData),at(""),void(A=!0);const s=t.error||t.message||(null==De?void 0:De["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Fs(t))return void(A=!0);at(s)}else"stop"===e.event&&(A=!0)}else A=!0}});for(;;){if(_()){A=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(_()){A=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}A||_()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||W(e)||_())return void(A=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==We||We(Oe)}catch(e){if(W(e))return;if(e.limitData)ot(e.limitData),at("");else{let t=D.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==De?void 0:De["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Fs(t)||at(t)}}finally{const e=!p||ns.current===p;xt(),e&&(rt("idle"),bt(),ss.current=null),p&&e&&(ns.current=null,rs.current=[]),yield Bs()}}));return o.useEffect((()=>{if(nt||Ut||Mt||0===Lt.length)return;const t=Lt[0];Rt(!0),Vt(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield hn(t.predecessorSubmissionId)))return void at((null==De?void 0:De["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");qt((e=>e.filter((e=>e.id!==t.id)))),yield xn(t.message,!1,!0,t.id)}finally{Rt(!1),Vt(null)}}))}),[nt,Mt,Ut,Lt]),Rs?null:t.jsx("div",Object.assign({className:q.default("flex w-full flex-shrink-0 flex-col items-center",!Ms&&"px-4 pb-8"),dir:Me?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Lt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ae.text+"18",backgroundColor:null!==(ye=Es.backgroundColor)&&void 0!==ye?ye:Ae.text+"08",color:Ae.text,borderTopLeftRadius:Math.max(Ue.cornerRadius-4,12),borderTopRightRadius:Math.max(Ue.cornerRadius-4,12)}},{children:Lt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<Lt.length-1?{borderBottom:`1px solid ${Ae.text}12`}:void 0},{children:[t.jsx(N.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),$t===s.id||Ft===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),$t===s.id?(null==De?void 0:De.steering)||"Steering...":(null==De?void 0:De.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:Ut||!nt,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=ns.current;if(!e||Ut)return;const s=Lt.findIndex((e=>e.id===t.id));if(-1===s)return;At(!0),Bt(t.id),at(""),vn(e);let n=!1;try{if(!(yield gn(e)))throw new Error((null==De?void 0:De["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield hn(e)))throw new Error((null==De?void 0:De["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");rt("idle"),qt((e=>e.filter((e=>e.id!==t.id)))),n=!0,At(!1),Bt(null),yield xn(t.message,!1,!0,t.id,!0)}catch(e){rt("idle"),n&&qt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),at(D.default(e))}finally{At(!1),Bt(null)}}))})(s)},"aria-label":`${(null==De?void 0:De["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==De?void 0:De.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:Ut,onClick:()=>{return e=s.id,void qt((t=>K(t,e)));var e},"aria-label":`${(null==De?void 0:De["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(w.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(C.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(U.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ut,role:"button",tabIndex:Ut?-1:0,"aria-haspopup":"menu","aria-label":(null==De?void 0:De["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(A.default,Object.assign({role:"menu",align:Me?"bottom-start":"bottom-end",positionStrategy:Re?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=Es.backgroundColor)&&void 0!==i?i:Ae.primary,color:Ae.text,borderRadius:"12px"},border:`1px solid ${Ae.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{qt((t=>K(t,e.id))),kt(e.message),requestAnimationFrame((()=>{const t=os.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(k.default,{className:"h-4 w-4 shrink-0"}),(null==De?void 0:De["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:ls,className:q.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ue.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Es),{maxHeight:`${ps}px`,overflowY:"auto"})},{children:[ln&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Es.backgroundColor?`${Es.backgroundColor}E6`:void 0,borderColor:Ae.text+"20",color:Ae.text,borderTopRightRadius:Ue.cornerRadius+"px",borderTopLeftRadius:Ue.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[sn.toLocaleString()," ",Gs?(null==De?void 0:De.credits)||"Credits":(null==De?void 0:De.uses)||"Uses"," ",(null==De?void 0:De.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[cn&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ae.accent,color:Ae.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),un)return void window.open(un,"_blank","noopener,noreferrer");if(Ye)return void Ye();const t=M.buildUpgradeUrl({baseUrl:Gt,accessGroupId:null==Ve?void 0:Ve.accessGroupId});t&&M.openAuthenticatedPricingUrl({deploymentId:Ee,pricingUrl:t,studioId:null==Ce?void 0:Ce.studioid,studioSessionToken:Qe})}},{children:pn})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Jt(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!nt&&dt.length>0&&t.jsx(_.default,{className:"p-4 pb-0",isDisabled:nt}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ls&&t.jsxs("div",Object.assign({className:q.default(Je?"top-6":"top-1/2","pointer-events-none absolute z-10 flex -translate-y-1/2 select-none items-center gap-x-2",Me?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(Ie=Ae.accent)&&void 0!==Ie?Ie:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ae.text+"90"}},{children:(null==De?void 0:De.listening)||"Listening..."}))]})),t.jsx(E.default,Object.assign({ref:os,className:q.default(_s.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!wt.trim()&&!wt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Me?"text-right":"text-left",!Je&&$s&&"mb-12"),value:wt,placeholder:Ls?"":Vs,onChange:e=>{kt(e)},onKeyDown:e=>{Le||vt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ct||Ut||(nt?bn():xn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Ds)return;t.preventDefault(),$e(!1),yield pt(e)}}))},ee&&{onFocus:ee},te&&{onBlur:te},{dir:Me?"rtl":"ltr"})),t.jsxs("div",Object.assign({ref:as,className:Je?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":q.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",$s?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!$s&&Es.backgroundColor&&{backgroundColor:Es.backgroundColor}),{borderTopRightRadius:Ue.cornerRadius+"px",borderBottomRightRadius:Ue.cornerRadius+"px"})},{children:[!nt&&!fs&&Ds&&t.jsxs("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:Ss?Ae.accent+"10":void 0,color:Ss?Ae.accent:Ae.accent+"80"},disabled:ct||nt,"aria-label":null!==(je=null==De?void 0:De["attach-files"])&&void 0!==je?je:"Attach files",onClick:()=>{var e;return null===(e=es.current)||void 0===e?void 0:e.click()}},Ns,{children:[t.jsx("input",{id:"file-upload",ref:es,type:"file",accept:[...x.allowedFileMimeTypes,...x.allowedImageMimeTypes,...x.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){$e(!1),yield pt(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(I.default,{className:"h-6 w-6 shrink-0"})]})),t.jsx(i.default,{compact:!0}),nt&&!Dt?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==De?void 0:De["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=ns.current;e&&(vn(e),gn(e)),rt("idle")},style:{backgroundColor:Ae.accent+"10",color:Ae.accent}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==De?void 0:De["queue-message"])||"Queue message",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",disabled:Ut||ct||!wt.trim(),onClick:bn,style:{backgroundColor:wt.trim()?Ae.accent:Ae.accent+"10",color:wt.trim()?Ae.accentText:Ae.accent+"80"}},{children:t.jsx(j.default,{className:q.default("h-6 w-6 shrink-0",Me&&"scale-x-[-1] transform")})}))]}):fs?t.jsx("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:bs,style:{backgroundColor:Ae.accent,color:Ae.accentText}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ps&&t.jsx("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:fs?Ae.accent:ws?Ae.accent+"10":void 0,color:fs?Ae.accentText:ws?Ae.accent:Ae.accent+"80"},disabled:ct||nt||gs,onClick:()=>{fs?bs():(ts.current=wt,hs(Pe||"en-US"))}},ks,{children:t.jsx(S.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("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:ys||fn?Ae.accent:Ae.accent+"10",color:ys||fn?Ae.accentText:Ae.accent+"80"},disabled:!fn,onClick:()=>xn()},Is,{children:t.jsx(j.default,{className:q.default("h-6 w-6 shrink-0",Me&&"scale-x-[-1] transform")})}))]})]}))]}))]})),ut&&t.jsx(T.default,{error:ut,className:"mt-3"})]}))}))}));ee.displayName="Input",exports.default=ee;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:P,sender:A,pickaxe:T,styles:_,isEmbed:F,mcpEnabled:O,translations:E}=s.usePickaxeContext(),{isSent:R}=i.useAuthContext(),{width:H,height:z,setDimension:B}=n.useDimensionContext(),{setDocuments:L,onFileUpload:M}=r.useDocument(),{scrollContainerRef:G,hasScrolledRef:V,isLocked:U,setIsLocked:W}=a.useScrollContext(),{isGenerating:J,messages:K}=g.useResponseContext(),Q=l.useStyleFontSize(),[X,Y]=o.useState(0),[Z,$]=o.useState(!1),[ee,te]=o.useState(!1),oe=o.useRef(null),se=o.useRef(null),ie=o.useRef(0),[ne,re]=o.useState(null),[ae,le]=o.useState(!1),ue=(null==E?void 0:E["new-chat"])||"New chat",ce="chat-input"===w&&C&&!R,de=null!==(S=null===(y=null==T?void 0:T.documentuploadtype)||void 0===y?void 0:y.startsWith("enduserupload"))&&void 0!==S&&S,{hasScrollableContent:fe,isNearBottom:he}=u.default(G);o.useEffect((()=>()=>{L([])}),[]);const me=o.useCallback((()=>{if(!P||!A)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.pickaxeApi2.post("/conversation/title",{sessionId:I,userId:A});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void xe(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[P,A,I]);o.useEffect((()=>{J||C||!I||me()}),[J,C,I,me]),o.useEffect((()=>{if(!oe.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;B(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(oe.current),()=>{e.disconnect()}}),[B]);const[pe,xe]=o.useState(ue),ve=(null==T?void 0:T.formtitle)||"Pickaxe",je=(null==T?void 0:T.coverphoto)||void 0,[ge,be]=o.useState(!1);o.useEffect((()=>{const e=!ce&&!F&&_.portalTheme&&(K.filter((e=>"user"===e.role)).length>0||Z||!C);be(null!=e&&e)}),[ce,F,Z,C,K,_.portalTheme]);const ke=o.useCallback((()=>{V.current=!1,W(!0),requestAnimationFrame((()=>{const e=G.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[V,G,W]);return t.jsxs("div",Object.assign({ref:oe,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),de&&(ie.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&te(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),de&&(ie.current-=1,0===ie.current&&te(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),te(!1),ie.current=0,!de)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(q(!1),yield M(e))}))},{children:[ee&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(f.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:h.default(Q.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==E?void 0:E["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:h.default(Q.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!F&&O?t.jsx("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(j.default,{})}))})):null,ce?t.jsx(d.default,{}):t.jsxs(t.Fragment,{children:[ge&&t.jsxs("div",Object.assign({className:h.default("direct-link"===w?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[t.jsx(b.NavPill,{text:ve,icon:je}),C||pe===ue?t.jsx(b.NavPill,{text:pe}):t.jsx(b.EditableNavPill,{text:pe,sessionId:I,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I)try{yield m.pickaxeApi2.patch("/conversation/title",{sessionId:I,name:t,userId:A}),xe(t)}catch(e){console.error("Error renaming chat:",e),alert((null==E?void 0:E["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.pickaxeApi2.delete("/conversation",{data:{sessionId:I,userId:A}}),q(!0),D(p.v4()),xe(ue)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(x.StudioTip,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(b.HistoryPill,{icon:t.jsx(k.default,{}),onClick:()=>{D(""),N(I)}})}))]})),t.jsx(c.default,{additionalScrollHeight:X,isForceHideInfo:z<=545||H<=350||Z,isInputFocused:Z,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se.current&&se.current.onSubmit(t)})),smitheryAuthData:ne,resubmitPrompt:()=>{re(null),le(!0)}}),t.jsx(v.default,{isVisible:fe&&!U&&!he,bottom:X+65,onClick:ke}),t.jsx(d.default,{ref:se,onFocus:()=>$(!0),onBlur:()=>$(!1),onInputHeightChange:Y,initSmitheryAuthData:e=>re(e),resubmitPrompt:ae})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../common/canChat.js"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),a=require("../Addons/Document/hooks/useDocument.js"),l=require("../Addons/Scroll/hooks/useScrollContext.js"),u=require("../../../hooks/studio/useStyleFontSize.js"),c=require("../../../hooks/core/useScrollToBottomVisibility.js"),d=require("./History/index.js"),f=require("./Input.js"),h=require("../../Icons/attach-vertical.svg.js"),m=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),x=require("uuid"),v=require("../../Core/StudioTip.js"),j=require("../common/ScrollToBottomButton.js"),g=require("../common/PickaxeMCPButton.js"),b=require("../../../hooks/pickaxe/useResponseContext.js"),k=require("../Addons/Navbar/NavPill.js"),y=require("../../Icons/history.svg.js");exports.default=()=>{var S,w;const{deploymentType:C,isNewChat:q,setIsNewChat:I,sessionId:D,setSessionId:N,setLastSessionId:T,pickaxeId:P,sender:A,pickaxe:O,styles:_,isEmbed:F,mcpEnabled:E,translations:R}=i.usePickaxeContext(),{isSent:H,token:z}=n.useAuthContext(),{width:B,height:L,setDimension:M}=r.useDimensionContext(),{setDocuments:G,onFileUpload:V}=a.useDocument(),{scrollContainerRef:U,hasScrolledRef:W,isLocked:J,setIsLocked:K}=l.useScrollContext(),{isGenerating:Q,messages:X}=b.useResponseContext(),Y=u.useStyleFontSize(),[Z,$]=s.useState(0),[ee,te]=s.useState(!1),[oe,se]=s.useState(!1),ie=s.useRef(null),ne=s.useRef(null),re=s.useRef(0),[ae,le]=s.useState(null),[ue,ce]=s.useState(!1),de=(null==R?void 0:R["new-chat"])||"New chat",fe=o.canChat(O),he=fe&&"chat-input"===C&&q&&!H,me=fe&&null!==(w=null===(S=null==O?void 0:O.documentuploadtype)||void 0===S?void 0:S.startsWith("enduserupload"))&&void 0!==w&&w,{hasScrollableContent:pe,isNearBottom:xe}=c.default(U);s.useEffect((()=>()=>{G([])}),[]);const ve=s.useCallback((()=>{if(!P||!A&&!z)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield p.pickaxeApi2.post("/conversation/title",Object.assign({sessionId:D},z?{studioSessionToken:z}:A?{userId:A}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ge(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[P,A,D,z]);s.useEffect((()=>{Q||q||!D||ve()}),[Q,q,D,ve]),s.useEffect((()=>{if(!ie.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;M(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(ie.current),()=>{e.disconnect()}}),[M]);const[je,ge]=s.useState(de),be=(null==O?void 0:O.formtitle)||"Pickaxe",ke=(null==O?void 0:O.coverphoto)||void 0,[ye,Se]=s.useState(!1);s.useEffect((()=>{const e=!he&&!F&&_.portalTheme&&(X.filter((e=>"user"===e.role)).length>0||ee||!q);Se(null!=e&&e)}),[he,F,ee,q,X,_.portalTheme]);const we=s.useCallback((()=>{W.current=!1,K(!0),requestAnimationFrame((()=>{const e=U.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[W,U,K]);return t.jsxs("div",Object.assign({ref:ie,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),me&&(re.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&se(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),me&&(re.current-=1,0===re.current&&se(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),se(!1),re.current=0,!me)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(I(!1),yield V(e))}))},{children:[oe&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(h.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:m.default(Y.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==R?void 0:R["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:m.default(Y.b2,"mt-2 opacity-60 text-black")},{children:(null==R?void 0:R["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!F&&E?t.jsx("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(g.default,{})}))})):null,he?t.jsx(f.default,{}):t.jsxs(t.Fragment,{children:[ye&&t.jsxs("div",Object.assign({className:m.default("direct-link"===C?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[t.jsx(k.NavPill,{text:be,icon:ke}),q||je===de?t.jsx(k.NavPill,{text:je}):t.jsx(k.EditableNavPill,{text:je,sessionId:D,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(D)try{yield p.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:D,name:t},z?{studioSessionToken:z}:A?{userId:A}:{})),ge(t)}catch(e){console.error("Error renaming chat:",e),alert((null==R?void 0:R["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(D&&window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield p.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:D},z?{studioSessionToken:z}:A?{userId:A}:{})}),I(!0),N(fe?x.v4():""),ge(de)}catch(e){console.error("Error deleting chat:",e),alert((null==R?void 0:R["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(v.StudioTip,Object.assign({content:R["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(k.HistoryPill,{icon:t.jsx(y.default,{}),onClick:()=>{N(""),T(D)}})}))]})),t.jsx(d.default,{additionalScrollHeight:Z,isForceHideInfo:L<=545||B<=350||ee,isInputFocused:ee,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){fe&&ne.current&&ne.current.onSubmit(t)})),smitheryAuthData:ae,resubmitPrompt:()=>{le(null),ce(!0)}}),t.jsx(j.default,{isVisible:pe&&!J&&!xe,bottom:Z+65,onClick:we}),fe&&t.jsx(f.default,{ref:ne,onFocus:()=>te(!0),onBlur:()=>te(!1),onInputHeightChange:$,initSmitheryAuthData:e=>le(e),resubmitPrompt:ue})]})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),r=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),u=require("../../../Icons/copy.svg.js"),m=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),v=require("../../common/PickaxeMarkdown/Renderer.js"),g=require("../../common/PickaxeMessageParts/index.js"),b=require("../../../../common/cn.js");exports.default=({item:j,onDelete:f})=>{const{pickaxe:y,sender:k,colors:w,translations:N,styles:C,isRtl:O,disableCss:_,disableHtml:q,disableJs:P,setSessionId:M,setIsNewChat:I}=n.usePickaxeContext(),{setMessages:R}=a.useResponseContext(),{setDocuments:S}=o.useDocument(),[E,D]=t.useState(!1),[T,F]=t.useState(!1),[A,H]=t.useState(!1),[$,z]=t.useState(!1),[J,L]=t.useState(!1),U=t.useRef(null),[B,K]=t.useState(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name")}),[j.shortSummary,j.summary,N]),t.useEffect((()=>{const e=e=>{U.current&&!U.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>j?"FORM"===j.pickaxeType?j.question?0===j.messages.length?j.question.responseParts?j.question.responseParts.length:0:j.messages.length:0:j.messages.length:0),[j]),V=l.formatLocalDateTime(j.updatedAt,"MMM dd, yyyy hh:mm a"),W=t.useMemo((()=>{var e,s;const t=(null==N?void 0:N["not-available"])||"n/a";if("FORM"===j.pickaxeType){if(j.messages&&0!==j.messages.length){const e=j.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=j.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return J?n.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=j.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[j,J,N]),Y=t.useMemo((()=>{var e,s,t,n,a,o;return"FORM"===j.pickaxeType?j.messages&&0!==j.messages.length?null!==(s=null===(e=j.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=j.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(o=null===(a=j.messages.find((e=>"assistant"===e.role)))||void 0===a?void 0:a.parts)&&void 0!==o?o:[]}),[j]),Z=t.useMemo((()=>Y.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[Y]),ee=t.useMemo((()=>g.getSuppressedRichPreviewUrls(Y)),[Y]),se=()=>{F(!1),G("")},te=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){H(!0);try{yield i.pickaxeApi2.patch("/conversation/title",{sessionId:j.sessionId,name:X,userId:k}),K(X),F(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==N?void 0:N["failed-update-name"])||"Failed to update name.")}finally{H(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:w.secondary,borderRadius:C.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:w.primary,color:w.text}},{children:T?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&te(),"Escape"===e.key&&se()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:w.primary,borderColor:w.secondary}}),s.jsx("button",Object.assign({onClick:te,disabled:A,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.save)||"Save"},{children:s.jsx(r.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:se,disabled:A,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.cancel)||"Cancel"},{children:s.jsx(r.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),L(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:J?(null==N?void 0:N.collapse)||"Collapse":(null==N?void 0:N.expand)||"Expand"},{children:J?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),D(!E)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(r.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:U,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:w.secondary,color:w.secondaryText,borderColor:w.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),F(!0),D(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:w.primary}},{children:[s.jsx(r.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==N?void 0:N["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield i.pickaxeApi2.delete("/conversation",{data:{sessionId:j.sessionId,userId:k}}),f&&f(j.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==N?void 0:N["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:b.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",J?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:b.default("w-full",J?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:C.theme,colors:w},O&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},_&&{disableCss:!0},{children:s.jsx(v.PickaxeMarkdownRenderer,{style:{display:"block"},className:b.default("w-full",!J&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],J&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:W})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:C.theme,colors:w},O&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},_&&{disableCss:!0},{children:s.jsx(v.PickaxeMarkdownRenderer,{style:{display:"block"},className:b.default("w-full text-sm",!J&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],J&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:Z,suppressedRichPreviewUrls:ee})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==y?void 0:y.chatflag)||!(null==y?void 0:y.chatflag)&&(null==y?void 0:y.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=j.sessionId,S([]),R([]),I(!1),M(s)},title:(null==N?void 0:N["open-chat"])||"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+($?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(Z),z(!0),setTimeout((()=>{z(!1)}),2e3)},title:$?(null==N?void 0:N.copied)||"Copied!":(null==N?void 0:N["copy-assistant-message"])||"Copy assistant message"},{children:$?s.jsx(m.default,{className:"h-4 w-4",style:{color:w.accent},fill:w.accent}):s.jsx(u.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:V}))]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../../common/api/pickaxe.js"),r=require("../../../../common/date.js"),c=require("lucide-react"),d=require("../../../Icons/trash-2.svg.js"),u=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),p=require("../../../Icons/copied.svg.js"),x=require("../../../Icons/expand.svg.js"),h=require("../../../Icons/collapse.svg.js"),v=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),g=require("../../common/PickaxeMessageParts/index.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:y})=>{var k,w;const{pickaxe:N,pickaxeId:C,renderResponseAction:O,sender:_,colors:q,translations:P,styles:M,isRtl:I,disableCss:R,disableHtml:S,disableJs:T,setSessionId:A,setIsNewChat:E}=n.usePickaxeContext(),{token:D}=i.useAuthContext(),{setMessages:F}=o.useResponseContext(),{setDocuments:H}=a.useDocument(),[$,z]=t.useState(!1),[J,L]=t.useState(!1),[U,V]=t.useState(!1),[B,K]=t.useState(!1),[X,G]=t.useState(!1),Q=t.useRef(null),[W,Y]=t.useState(f.shortSummary||f.summary||(null==P?void 0:P["conversation-name"])||"Conversation name"),[Z,ee]=t.useState("");t.useEffect((()=>{Y(f.shortSummary||f.summary||(null==P?void 0:P["conversation-name"])||"Conversation name")}),[f.shortSummary,f.summary,P]),t.useEffect((()=>{const e=e=>{Q.current&&!Q.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const se=t.useMemo((()=>f?"FORM"===f.pickaxeType?f.question?0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0:f.messages.length:0),[f]),te=r.formatLocalDateTime(f.updatedAt,"MMM dd, yyyy hh:mm a"),ne=t.useMemo((()=>{var e,s;const t=(null==P?void 0:P["not-available"])||"n/a";if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=f.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return X?n.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=f.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[f,X,P]),oe=t.useMemo((()=>{var e,s,t,n,o,a;return"FORM"===f.pickaxeType?f.messages&&0!==f.messages.length?null!==(s=null===(e=f.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=f.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(a=null===(o=f.messages.find((e=>"assistant"===e.role)))||void 0===o?void 0:o.parts)&&void 0!==a?a:[]}),[f]),ae=t.useMemo((()=>oe.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[oe]),ie=t.useMemo((()=>g.getSuppressedRichPreviewUrls(oe)),[oe]),le=()=>{L(!1),ee("")},re=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(Z.trim()){V(!0);try{yield l.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:f.sessionId,name:Z},D?{studioSessionToken:D}:_?{userId:_}:{})),Y(Z),L(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==P?void 0:P["failed-update-name"])||"Failed to update name.")}finally{V(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:q.secondary,borderRadius:M.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:q.primary,color:q.text}},{children:J?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:Z,onChange:e=>ee(e.target.value),onKeyDown:e=>{"Enter"===e.key&&re(),"Escape"===e.key&&le()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:q.primary,borderColor:q.secondary}}),s.jsx("button",Object.assign({onClick:re,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==P?void 0:P.save)||"Save"},{children:s.jsx(c.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:le,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==P?void 0:P.cancel)||"Cancel"},{children:s.jsx(c.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:W})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),G(!X)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:X?(null==P?void 0:P.collapse)||"Collapse":(null==P?void 0:P.expand)||"Expand"},{children:X?s.jsx(h.default,{className:"h-4 w-4"}):s.jsx(x.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),z(!$)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(c.MoreHorizontal,{className:"h-6 w-6"})})),$&&s.jsxs("div",Object.assign({ref:Q,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:q.secondary,color:q.secondaryText,borderColor:q.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),ee(W),L(!0),z(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:q.primary}},{children:[s.jsx(c.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==P?void 0:P["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==P?void 0:P["delete-confirm"])||"Are you sure you want to delete this conversation?")){z(!1);try{yield l.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:f.sessionId},D?{studioSessionToken:D}:_?{userId:_}:{})}),y&&y(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==P?void 0:P["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==P?void 0:P["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:j.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",X?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:q.secondary,color:q.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",X?"mb-0":"mb-2")},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:M.theme,colors:q},I&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},R&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!X&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],X&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ne})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:M.theme,colors:q},I&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},R&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!X&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],X&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ae,suppressedRichPreviewUrls:ie})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==N?void 0:N.chatflag)||!(null==N?void 0:N.chatflag)&&(null==N?void 0:N.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=f.sessionId,H([]),F([]),E(!1),A(s)},title:(null==P?void 0:P["open-chat"])||"Open Chat"},{children:[s.jsx(u.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:se}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(B?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ae),K(!0),setTimeout((()=>{K(!1)}),2e3)},title:B?(null==P?void 0:P.copied)||"Copied!":(null==P?void 0:P["copy-assistant-message"])||"Copy assistant message"},{children:B?s.jsx(p.default,{className:"h-4 w-4",style:{color:q.accent},fill:q.accent}):s.jsx(m.default,{className:"h-4 w-4"})})),"FORM"===f.pickaxeType&&!(null==N?void 0:N.chatflag)&&!(null==N?void 0:N.enablechatresponses)&&(null===(w=null===(k=f.question)||void 0===k?void 0:k.responseParts)||void 0===w?void 0:w.some((e=>e.isVisible&&"text"===e.type&&e.content.trim())))&&(null==O?void 0:O({pickaxeId:C,sessionId:f.sessionId,kind:"form",responseReference:"form-result",agentName:(null==N?void 0:N.formtitle)||C,content:f.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n")}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:te}))]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,g,v;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:S,isRtl:A,setSessionId:I,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=i.useResponseContext(),{scrollTargetRef:R}=n.useScrollContext(),{setDocuments:T}=l.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=o.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).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||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w,isStreaming:M},A&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},S&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[],isStreaming:M})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{content:(null!==(v=null===(g=D.question)||void 0===g?void 0:g.responseParts)&&void 0!==v?v:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void I(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,g,v;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:S,isRtl:A,setSessionId:I,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=i.useResponseContext(),{scrollTargetRef:R}=n.useScrollContext(),{setDocuments:T}=l.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=o.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).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||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w,isStreaming:M},A&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},S&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[],isStreaming:M})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{responseKind:"form",content:(null!==(v=null===(g=D.question)||void 0===g?void 0:g.responseParts)&&void 0!==v?v:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void I(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../../common/formQuestionValidation.js"),n=require("../../../../hooks/pickaxe/useEndUserModel.js"),i=require("../../common/EndUserModelPicker.js"),o=require("../../../../common/actionApproval.js"),r=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),u=require("../../Addons/Document/hooks/useDocument.js"),c=require("../../Addons/Scroll/hooks/useScroll.js"),p=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../../common/utils.js"),f=require("eventsource-parser"),g=require("../../common/PickaxeBranding.js"),v=require("../../common/PickaxeButton.js"),h=require("../../../../common/error.js"),x=require("../../../../common/validation.js");exports.default=({navigation:b,paged:j=!1,questions:y,resetQuestions:O,onInvalidQuestion:w})=>{var S;const{origin:k,pickaxeId:I,sender:A,senderType:C,portalId:P,deploymentId:E,pickaxe:q,misc:_,translations:N,isRtl:T,setSessionId:U,setIsNewChat:D,setValidationStatus:L,setValidationUpgradeGroups:V,setValidationUpgradeUrl:B,setAccessGroup:J,onGenerateComplete:R}=a.usePickaxeContext(),{value:K}=n.useEndUserModel(),{token:W}=l.useAuthContext(),{isGenerating:X,setResponse:M,setMessages:G,setStatus:F,setLimitData:Q,setError:$,setActionApprovalToken:z,setIsSwitchedToChat:Y}=d.useResponseContext(),{documents:H,websiteLink:Z,isUploading:ee,onWebsiteUpload:te,setDocuments:se,setDocumentError:ne}=u.useDocument(),{scrollStartSession:ie,scrollEndSession:oe,scrollToTarget:re}=c.useScroll({auto:!(null==q?void 0:q.enablechatresponses)}),{artifacts:ae,currentPopupType:le,setArtifacts:de,setCurrentArtifact:ue}=p.useArtifactContext(),[ce,pe]=r.useState(!1),[me,fe]=r.useState(!1),ge=r.useRef(null),ve=e=>{const t=x.getValidationFailure(e);return!!t&&($(""),Q(null),L(t.status),J(t.accessGroup),V(t.upgradeGroups),B(t.upgradeUrl),!0)},he=r.useMemo((()=>y.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))),[y])&&t.jsx(v.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:ee||X||ce,onClick:O},{children:(null==N?void 0:N["form.clear-form"])||(null==N?void 0:N["clear-form"])||"Clear form"}));return t.jsxs("div",Object.assign({className:j?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:T?"rtl":"ltr"},{children:[j&&t.jsx(i.default,{}),t.jsxs("div",Object.assign({className:j?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!j&&t.jsx(i.default,{}),j&&b&&t.jsx("div",Object.assign({className:"me-auto shrink-0"},{children:b})),j&&he,t.jsx(v.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:ee||X||ce,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,n,i,r;try{if(X||ee||ce)return;$(""),ne(""),Q(null),M(null);for(const t of y){const n=s.getFormQuestionError(t);if(n)throw null==w||w(t.id),new Error(null!==(e=null==N?void 0:N[n])&&void 0!==e?e:"response-too-long"===n?"One or more of your responses is too long!":"You must fill out all required fields.")}const a=H.filter((e=>"finished"===e.status)),l=H.map((e=>e.name)),d=null!==(n=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n,u=y.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),c=m.extractUrlsFromText(Z).filter((e=>!l.includes(e)));if(c.length){const e=c[c.length-1];pe(!0);const t=yield te(e);t&&(a.push(t),yield new Promise((e=>setTimeout(e,5e3)))),pe(!1)}else if(u&&d&&!a.length)return null==w||w("userinput:documentupload"),void ne((null==N?void 0:N["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=a.map((e=>e.documentId||"")).filter(Boolean),g=d&&p.length>0,v={};y.forEach((e=>{v[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?a.map((e=>e.name)).join(",")||"":e.input})),fe(!1),F("fetching"),ie(),re();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:K||void 0,origin:k,pickaxeId:I,senderType:C,valueObj:v},g&&{documentIds:p}),A&&{sender:A}),W&&{studioSessionToken:W}),!W&&!A&&{sender:m.initializeEmbedUserId()}),P&&{portalId:P}),E&&{deploymentId:E}))}),x=yield h.json();if(!x.success){const e=new Error(x.error||x.message||(null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");if(x.limitData)throw e.limitData=x.limitData,e;if(ve(x))return;throw e}if(!x.submissionId||!x.sessionId)throw new Error((null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");z(null!==(i=x.actionApprovalToken)&&void 0!==i?i:null);const b=x.submissionId,j=x.sessionId,O={sessionId:j,documentIds:g?p:[],question:{inputs:y.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};M(O),(null==q?void 0:q.enablechatresponses)&&(U(j),D(!1),Y(!0),G([{id:0,role:"assistant",parts:[],documentIds:[]}])),g&&se([]),F("streaming"),ge.current=new AbortController;const S=[];let _=[...null!=ae?ae:[]],T=0,L=!1,V="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${T}`,{signal:null===(r=ge.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),s=new TextDecoder,n=f.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&T++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Q(t.limitData),$(""),void(L=!0);const s=t.error||t.message||(null==N?void 0:N["something-went-wrong"])||"Something went wrong.";return ve(t)||$(s),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void fe(!0);if("text-start"===n.type)V="",S.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)V+=n.delta,o.updateStreamTextPart(S,"text",V);else if("text-end"===n.type)V="";else if("reasoning-start"===n.type)V="",S.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)V+=n.delta,o.updateStreamTextPart(S,"reasoning",V);else if("reasoning-end"===n.type)V="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?o.upsertActionApprovalPart(S,e.data):S.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},O),{question:Object.assign(Object.assign({},O.question),{responseParts:[...S]})});M(i),(null==q?void 0:q.enablechatresponses)&&G([{id:0,role:"assistant",parts:[...S],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");_=_.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),de([..._])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);de(_.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else L=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}L||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==R||R(j)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Q(e.limitData),$(""),void re();let t=h.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==N?void 0:N["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ve(t)||$(t),re()}finally{F("idle"),pe(!1),oe()}}))},{children:ce?(null==N?void 0:N.processing)||"Processing...":ee?(null==N?void 0:N.uploading)||"Uploading...":X&&!me?(null==N?void 0:N.loading)||"Loading...":null!==(S=null==q?void 0:q.submittext)&&void 0!==S?S:"Submit"})),!j&&he]})),!_.isWhiteLabel&&t.jsx(g.default,{containerClassName:"justify-end"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../../common/formQuestionValidation.js"),n=require("../../../../hooks/pickaxe/useEndUserModel.js"),i=require("../../common/EndUserModelPicker.js"),o=require("../../../../common/actionApproval.js"),r=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),u=require("../../Addons/Document/hooks/useDocument.js"),c=require("../../Addons/Scroll/hooks/useScroll.js"),p=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../../common/utils.js"),f=require("eventsource-parser"),g=require("../../common/PickaxeBranding.js"),v=require("../../common/PickaxeButton.js"),h=require("../../../../common/error.js"),x=require("../../../../common/validation.js");exports.default=({navigation:b,paged:j=!1,questions:y,resetQuestions:O,onInvalidQuestion:w})=>{var S;const{origin:k,pickaxeId:I,sender:A,senderType:C,portalId:P,deploymentId:E,pickaxe:q,misc:_,translations:N,isRtl:T,setSessionId:U,setIsNewChat:D,setValidationStatus:L,setValidationUpgradeGroups:R,setValidationUpgradeUrl:V,setAccessGroup:B,onGenerateComplete:J}=a.usePickaxeContext(),{value:K}=n.useEndUserModel(),{token:W}=l.useAuthContext(),{isGenerating:X,setResponse:M,setMessages:G,setStatus:F,setLimitData:Q,setError:$,setActionApprovalToken:z,setIsSwitchedToChat:Y}=d.useResponseContext(),{documents:H,websiteLink:Z,isUploading:ee,onWebsiteUpload:te,setDocuments:se,setDocumentError:ne}=u.useDocument(),{scrollStartSession:ie,scrollEndSession:oe,scrollToTarget:re}=c.useScroll({auto:!(null==q?void 0:q.enablechatresponses)}),{artifacts:ae,currentPopupType:le,setArtifacts:de,setCurrentArtifact:ue}=p.useArtifactContext(),[ce,pe]=r.useState(!1),[me,fe]=r.useState(!1),ge=r.useRef(null),ve=e=>{const t=x.getValidationFailure(e);return!!t&&($(""),Q(null),L(t.status),B(t.accessGroup),R(t.upgradeGroups),V(t.upgradeUrl),!0)},he=r.useMemo((()=>y.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))),[y])&&t.jsx(v.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:ee||X||ce,onClick:O},{children:(null==N?void 0:N["form.clear-form"])||(null==N?void 0:N["clear-form"])||"Clear form"}));return t.jsxs("div",Object.assign({className:j?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:T?"rtl":"ltr"},{children:[j&&t.jsx(i.default,{}),t.jsxs("div",Object.assign({className:j?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!j&&t.jsx(i.default,{}),j&&b&&t.jsx("div",Object.assign({className:"me-auto shrink-0"},{children:b})),j&&he,t.jsx(v.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:ee||X||ce,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,n,i,r;try{if(X||ee||ce)return;$(""),ne(""),Q(null),M(null);for(const t of y){const n=s.getFormQuestionError(t);if(n)throw null==w||w(t.id),new Error(null!==(e=null==N?void 0:N[n])&&void 0!==e?e:"response-too-long"===n?"One or more of your responses is too long!":"You must fill out all required fields.")}const a=H.filter((e=>"finished"===e.status)),l=H.map((e=>e.name)),d=null!==(n=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n,u=y.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),c=m.extractUrlsFromText(Z).filter((e=>!l.includes(e)));if(c.length){const e=c[c.length-1];pe(!0);const t=yield te(e);t&&(a.push(t),yield new Promise((e=>setTimeout(e,5e3)))),pe(!1)}else if(u&&d&&!a.length)return null==w||w("userinput:documentupload"),void ne((null==N?void 0:N["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=a.map((e=>e.documentId||"")).filter(Boolean),g=d&&p.length>0,v={};y.forEach((e=>{v[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?a.map((e=>e.name)).join(",")||"":e.input})),fe(!1),F("fetching"),ie(),re();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:K||void 0,origin:k,pickaxeId:I,senderType:C,valueObj:v},g&&{documentIds:p}),A&&{sender:A}),W&&{studioSessionToken:W}),!W&&!A&&{sender:m.initializeEmbedUserId()}),P&&{portalId:P}),E&&{deploymentId:E}))}),x=yield h.json();if(!x.success){const e=new Error(x.error||x.message||(null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");if(x.limitData)throw e.limitData=x.limitData,e;if(ve(x))return;throw e}if(!x.submissionId||!x.sessionId)throw new Error((null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");z(null!==(i=x.actionApprovalToken)&&void 0!==i?i:null);const b=x.submissionId,j=x.sessionId,O={sessionId:j,documentIds:g?p:[],question:{inputs:y.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};M(O),(null==q?void 0:q.enablechatresponses)&&(U(j),D(!1),Y(!0),G([{id:0,role:"assistant",parts:[],documentIds:[],responseReference:"form-result"}])),g&&se([]),F("streaming"),ge.current=new AbortController;const S=[];let _=[...null!=ae?ae:[]],T=0,L=!1,R="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${T}`,{signal:null===(r=ge.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),s=new TextDecoder,n=f.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&T++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Q(t.limitData),$(""),void(L=!0);const s=t.error||t.message||(null==N?void 0:N["something-went-wrong"])||"Something went wrong.";return ve(t)||$(s),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void fe(!0);if("text-start"===n.type)R="",S.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)R+=n.delta,o.updateStreamTextPart(S,"text",R);else if("text-end"===n.type)R="";else if("reasoning-start"===n.type)R="",S.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)R+=n.delta,o.updateStreamTextPart(S,"reasoning",R);else if("reasoning-end"===n.type)R="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?o.upsertActionApprovalPart(S,e.data):S.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},O),{question:Object.assign(Object.assign({},O.question),{responseParts:[...S]})});M(i),(null==q?void 0:q.enablechatresponses)&&G([{id:0,responseReference:"form-result",role:"assistant",parts:[...S],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");_=_.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),de([..._])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);de(_.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else L=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}L||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==J||J(j)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Q(e.limitData),$(""),void re();let t=h.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==N?void 0:N["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ve(t)||$(t),re()}finally{F("idle"),pe(!1),oe()}}))},{children:ce?(null==N?void 0:N.processing)||"Processing...":ee?(null==N?void 0:N.uploading)||"Uploading...":X&&!me?(null==N?void 0:N.loading)||"Loading...":null!==(S=null==q?void 0:q.submittext)&&void 0!==S?S:"Submit"})),!j&&he]})),!_.isWhiteLabel&&t.jsx(g.default,{containerClassName:"justify-end"})]}))};