@pickaxeproject/react 6.21.1 → 6.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".doc",".md",".html",".htm",".wav"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/x-markdown","text/html","application/xml","text/xml","audio/mpeg","audio/wav","audio/x-wav","audio/wave","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".doc",".md",".html",".htm",".wav"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/x-markdown","application/x-markdown","text/html","application/xml","text/xml","audio/mpeg","audio/mp4","audio/x-m4a","audio/m4a","audio/wav","audio/x-wav","audio/wave","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:u}={})=>{var a,l;const{contextId:c,pickaxeId:p,sessionId:m,sender:f,senderType:w,pickaxe:v,translations:b}=t.usePickaxeContext(),{token:I}=s.useAuthContext(),h=o.useDocumentContext(),g=i.useSubmitDocument(),y=null!==(l=null===(a=null==v?void 0:v.documentuploadtype)||void 0===a?void 0:a.startsWith("enduserupload"))&&void 0!==l&&l,k=(null==b?void 0:b["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",D=e=>{const t=[...n.allowedFileMimeTypes,...n.allowedImageMimeTypes],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&n.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==b?void 0:b["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOC, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=d.default(t);return h.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},h),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(!y)return h.setDocumentError(k),null;if(D(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield g.document(Object.assign(Object.assign(Object.assign({contextId:c,pickaxeId:p,sessionId:m,file:t},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I}));if(!e)throw new Error(r||(null==b?void 0:b["document-processing-failed"])||"Document processing failed");null==u||u({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.allowedImageMimeTypes.includes(t.type);return h.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;if(!y)return h.setDocumentError(k),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==b?void 0:b["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website(Object.assign(Object.assign(Object.assign({pickaxeId:p,sessionId:m,website:e},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I})),{success:s,documentId:i}=t;if(!s)throw new Error((null==b?void 0:b["website-processing-failed"])||"Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes((null==b?void 0:b["invalid-website-url"])||"Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:u}={})=>{var a,l;const{contextId:c,pickaxeId:p,sessionId:m,sender:f,senderType:w,pickaxe:v,translations:b}=t.usePickaxeContext(),{token:I}=s.useAuthContext(),h=o.useDocumentContext(),g=i.useSubmitDocument(),y=null!==(l=null===(a=null==v?void 0:v.documentuploadtype)||void 0===a?void 0:a.startsWith("enduserupload"))&&void 0!==l&&l,k=(null==b?void 0:b["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",D=e=>{const t=[...n.allowedFileMimeTypes,...n.allowedImageMimeTypes],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&n.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==b?void 0:b["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOC, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.",t=new Error(e),s=d.default(t);return h.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},h),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(!y)return h.setDocumentError(k),null;if(D(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield g.document(Object.assign(Object.assign(Object.assign({contextId:c,pickaxeId:p,sessionId:m,file:t},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I}));if(!e)throw new Error(r||(null==b?void 0:b["document-processing-failed"])||"Document processing failed");null==u||u({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.allowedImageMimeTypes.includes(t.type);return h.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;if(!y)return h.setDocumentError(k),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==b?void 0:b["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website(Object.assign(Object.assign(Object.assign({pickaxeId:p,sessionId:m,website:e},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I})),{success:s,documentId:i}=t;if(!s)throw new Error((null==b?void 0:b["website-processing-failed"])||"Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes((null==b?void 0:b["invalid-website-url"])||"Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
@@ -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-step"===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("../../../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 +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-step"===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: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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:g,portalId:h,deploymentType:m,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:I="en",opacity:F=1,forceMobile:A=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:j=!1,loadFont:D=!0,isRtl:O=!1,isEmbed:U=!1,mcpEnabled:E=!1,studioSessionToken:R,isDropShadow:M=!1,allowGuestUsage:L=!0,persistActiveConversation:G=!1,preventInitialSessionId:H=!1,onUpgrade:W,onGenerateComplete:_,onSessionIdChange:B})=>{const[N,V]=i.useState(""),[Y,X]=i.useState(""),[z,J]=i.useState(""),[Q,K]=i.useState(""),[Z,$]=i.useState(p),[ee,te]=i.useState(null),[ie,oe]=i.useState(f),[ne,ae]=i.useState("loading"),[se,re]=i.useState([]),[le,de]=i.useState(null),[ce,ue]=i.useState(null),[pe,fe]=i.useState(null),[ge,he]=i.useState(null),[me,ye]=i.useState("");i.useEffect((()=>ye("")),[Y]);const[ve,be]=i.useState(!1),[we,Se]=i.useState(!0),[ke,Pe]=i.useState(!0),[Ce,xe]=i.useState(!1);return i.useEffect((()=>{be(!1)}),[null==b?void 0:b.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!ve&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[b.font]},active:()=>{be(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),be(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),be(!0)}}))}),[D,ve,null==b?void 0:b.font]),i.useEffect((()=>{$(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:N,pickaxeId:Y,sessionId:z,lastSessionId:Q,sender:Z,senderType:ie,portalId:h,deploymentId:g,deploymentType:m,validationStatus:ne,validationUpgradeGroups:se,validationUpgradeUrl:le,deploymentDimensions:y,deploymentMisc:v,accessGroup:ee,pickaxe:ge,selectedModel:me,setSelectedModel:ye,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:C,responsiveBy:x,locale:I,opacity:F,forceMobile:A,loadFont:D,disableHtml:q,disableJs:T,disableCss:j,isFontLoaded:ve,isNewChat:we,isShowIceBreaker:ke,isShowFeedbackMessage:Ce,isRtl:O,isEmbed:U,mcpEnabled:E,isDropShadow:M,allowGuestUsage:L,persistActiveConversation:G,clientSecret:pe,stripeAccountId:ce,preventInitialSessionId:H,setClientSecret:fe,setStripeAccountId:ue,setContextId:V,setValidationStatus:ae,setValidationUpgradeGroups:re,setValidationUpgradeUrl:de,setPickaxeId:X,setSessionId:e=>{J((t=>{const i="function"==typeof e?e(t):e;return null==B||B(i),i}))},setLastSessionId:K,setSender:$,setSenderType:oe,setAccessGroup:te,setPickaxe:he,setIsFontLoaded:be,setIsNewChat:Se,setIsShowIceBreaker:Pe,setIsShowFeedbackMessage:xe},W&&{onUpgrade:W}),_&&{onGenerateComplete:_})},{children:t.jsx(r.default,Object.assign({initialToken:R},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:g,portalId:h,deploymentType:m,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:I="en",opacity:F=1,forceMobile:A=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:j=!1,loadFont:D=!0,isRtl:O=!1,isEmbed:U=!1,mcpEnabled:E=!1,studioSessionToken:M,isDropShadow:R=!1,allowGuestUsage:L=!0,persistActiveConversation:G=!1,preventInitialSessionId:H=!1,onUpgrade:W,onGenerateComplete:_,onSessionIdChange:B})=>{const[N,V]=i.useState(""),[Y,X]=i.useState(""),[z,J]=i.useState(""),[Q,K]=i.useState(""),[Z,$]=i.useState(p),[ee,te]=i.useState(null),[ie,oe]=i.useState(f),[ne,ae]=i.useState("loading"),[se,re]=i.useState([]),[le,de]=i.useState(null),[ce,ue]=i.useState(null),[pe,fe]=i.useState(null),[ge,he]=i.useState(null),[me,ye]=i.useState("");i.useEffect((()=>ye("")),[Y]);const[ve,be]=i.useState(!1),[we,Se]=i.useState(!0),[ke,Pe]=i.useState(!0),[Ce,xe]=i.useState(!1);return i.useEffect((()=>{be(!1)}),[null==b?void 0:b.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!ve&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[b.font]},active:()=>{be(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),be(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),be(!0)}}))}),[D,ve,null==b?void 0:b.font]),i.useEffect((()=>{$(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:N,pickaxeId:Y,sessionId:z,lastSessionId:Q,sender:Z,senderType:ie,portalId:h,deploymentId:g,deploymentType:m,validationStatus:ne,validationUpgradeGroups:se,validationUpgradeUrl:le,deploymentDimensions:y,deploymentMisc:v,accessGroup:ee,pickaxe:ge,selectedModel:me,setSelectedModel:ye,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:C,responsiveBy:x,locale:I,opacity:F,forceMobile:A,loadFont:D,disableHtml:q,disableJs:T,disableCss:j,isFontLoaded:ve,isNewChat:we,isShowIceBreaker:ke,isShowFeedbackMessage:Ce,isRtl:O,isEmbed:U,mcpEnabled:E,isDropShadow:R,allowGuestUsage:L,persistActiveConversation:G,clientSecret:pe,stripeAccountId:ce,preventInitialSessionId:H,setClientSecret:fe,setStripeAccountId:ue,setContextId:V,setValidationStatus:ae,setValidationUpgradeGroups:re,setValidationUpgradeUrl:de,setPickaxeId:X,setSessionId:e=>{J((t=>{const i="function"==typeof e?e(t):e;return null==B||B(i),i}))},setLastSessionId:K,setSender:$,setSenderType:oe,setAccessGroup:te,setPickaxe:he,setIsFontLoaded:be,setIsNewChat:Se,setIsShowIceBreaker:Pe,setIsShowFeedbackMessage:xe},W&&{onUpgrade:W}),_&&{onGenerateComplete:_})},{children:t.jsx(r.default,Object.assign({initialToken:M},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})}))}))};
@@ -54,7 +54,7 @@ type PickaxeHistoryStreamPartDelta = {
54
54
  delta: string;
55
55
  };
56
56
  type PickaxeHistoryStreamFinish = {
57
- type: "finish-step";
57
+ type: "finish" | "finish-step";
58
58
  };
59
59
  export type PickaxeHistoryStreamDataActionToolCaption = {
60
60
  type: "data-action-tool-caption";
@@ -1 +1 @@
1
- const e=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/x-markdown","text/html","application/xml","text/xml","audio/mpeg","audio/wav","audio/x-wav","audio/wave","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],o=["image/png","image/jpeg","image/webp","image/gif"],i=[".doc",".md",".html",".htm",".wav"];export{i as additionalAllowedFileExtensions,e as allowedFileMimeTypes,o as allowedImageMimeTypes};
1
+ const o=["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/x-markdown","application/x-markdown","text/html","application/xml","text/xml","audio/mpeg","audio/mp4","audio/x-m4a","audio/m4a","audio/wav","audio/x-wav","audio/wave","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],i=["image/png","image/jpeg","image/webp","image/gif"],a=[".doc",".md",".html",".htm",".wav"];export{a as additionalAllowedFileExtensions,o as allowedFileMimeTypes,i as allowedImageMimeTypes};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../../Auth/hooks/useAuthContext.js";import{useSubmitDocument as i}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as o}from"./useDocumentContext.js";import{allowedImageMimeTypes as n,additionalAllowedFileExtensions as r,allowedFileMimeTypes as d}from"../../../../../common/documents.js";import{v4 as u}from"uuid";import a from"../../../../../common/error.js";const l=({onQuestionChange:l}={})=>{var c,m;const{contextId:p,pickaxeId:f,sessionId:v,sender:b,senderType:h,pickaxe:w,translations:I}=t(),{token:g}=s(),k=o(),y=i(),D=null!==(m=null===(c=null==w?void 0:w.documentuploadtype)||void 0===c?void 0:c.startsWith("enduserupload"))&&void 0!==m&&m,j=(null==I?void 0:I["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",E=e=>{const t=[...d,...n],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&r.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==I?void 0:I["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOC, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=a(t);return k.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},k),{onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(k.setDocumentError(""),!t.length)return null;if(!D)return k.setDocumentError(j),null;if(E(t))return null;k.setIsUploading(!0),k.setIsShowList(!0);const s=t.map((e=>({file:e,id:u()})));s.forEach((({file:e,id:t})=>{k.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield y.document(Object.assign(Object.assign(Object.assign({contextId:p,pickaxeId:f,sessionId:v,file:t},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===h&&{studioUserId:b}),g&&{studioSessionToken:g}));if(!e)throw new Error(r||(null==I?void 0:I["document-processing-failed"])||"Document processing failed");null==l||l({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.includes(t.type);return k.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=a(e);return k.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),k.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){k.setDocumentError("");let e=t.trim();if(!e)return null;if(!D)return k.setDocumentError(j),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==I?void 0:I["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");k.setIsUploading(!0),k.setIsShowList(!0),k.setWebsiteLink(""),k.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield y.website(Object.assign(Object.assign(Object.assign({pickaxeId:f,sessionId:v,website:e},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===h&&{studioUserId:b}),g&&{studioSessionToken:g})),{success:s,documentId:i}=t;if(!s)throw new Error((null==I?void 0:I["website-processing-failed"])||"Website processing failed, please try again.");k.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=a(t);if(s.includes((null==I?void 0:I["invalid-website-url"])||"Please paste a valid website URL"))return k.setDocumentError(s),null;k.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{k.setIsUploading(!1)}}))})};export{l as useDocument};
1
+ import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../../Auth/hooks/useAuthContext.js";import{useSubmitDocument as i}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as o}from"./useDocumentContext.js";import{allowedImageMimeTypes as n,additionalAllowedFileExtensions as r,allowedFileMimeTypes as d}from"../../../../../common/documents.js";import{v4 as u}from"uuid";import a from"../../../../../common/error.js";const l=({onQuestionChange:l}={})=>{var c,m;const{contextId:p,pickaxeId:f,sessionId:v,sender:b,senderType:h,pickaxe:w,translations:I}=t(),{token:g}=s(),k=o(),y=i(),D=null!==(m=null===(c=null==w?void 0:w.documentuploadtype)||void 0===c?void 0:c.startsWith("enduserupload"))&&void 0!==m&&m,j=(null==I?void 0:I["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",E=e=>{const t=[...d,...n],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&r.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==I?void 0:I["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOC, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.",t=new Error(e),s=a(t);return k.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},k),{onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(k.setDocumentError(""),!t.length)return null;if(!D)return k.setDocumentError(j),null;if(E(t))return null;k.setIsUploading(!0),k.setIsShowList(!0);const s=t.map((e=>({file:e,id:u()})));s.forEach((({file:e,id:t})=>{k.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield y.document(Object.assign(Object.assign(Object.assign({contextId:p,pickaxeId:f,sessionId:v,file:t},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===h&&{studioUserId:b}),g&&{studioSessionToken:g}));if(!e)throw new Error(r||(null==I?void 0:I["document-processing-failed"])||"Document processing failed");null==l||l({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.includes(t.type);return k.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=a(e);return k.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),k.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){k.setDocumentError("");let e=t.trim();if(!e)return null;if(!D)return k.setDocumentError(j),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==I?void 0:I["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");k.setIsUploading(!0),k.setIsShowList(!0),k.setWebsiteLink(""),k.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield y.website(Object.assign(Object.assign(Object.assign({pickaxeId:f,sessionId:v,website:e},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===h&&{studioUserId:b}),g&&{studioSessionToken:g})),{success:s,documentId:i}=t;if(!s)throw new Error((null==I?void 0:I["website-processing-failed"])||"Website processing failed, please try again.");k.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=a(t);if(s.includes((null==I?void 0:I["invalid-website-url"])||"Please paste a valid website URL"))return k.setDocumentError(s),null;k.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{k.setIsUploading(!1)}}))})};export{l as useDocument};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{useEndUserModel as i}from"../../../hooks/pickaxe/useEndUserModel.js";import r from"../common/EndUserModelPicker.js";import{updateStreamTextPart as a,upsertActionApprovalPart as l}from"../../../common/actionApproval.js";import{forwardRef as d,useState as c,useRef as u,useCallback as p,useEffect as m,useMemo as g,useImperativeHandle as f}from"react";import{usePickaxeContext as v}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as h}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as b}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as y}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as x}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as j}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as I}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as w}from"../Addons/Document/hooks/useDocument.js";import{useScroll as k}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as N}from"../../../hooks/core/useHover.js";import{useMediaQuery as S}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as C,allowedImageMimeTypes as E,additionalAllowedFileExtensions as _}from"../../../common/documents.js";import{createParser as T}from"eventsource-parser";import U from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import P from"../../Icons/microphone.svg.js";import D from"../../Icons/message-clock.svg.js";import L from"../../Icons/stop.svg.js";import M from"../../Icons/trash.svg.js";import R from"../../Icons/pencil.svg.js";import $ from"../Addons/Document/List.js";import B from"../../Core/Textarea.js";import X from"../../Core/ErrorAlert.js";import K from"../../Core/Menu/index.js";import F from"../../Core/Menu/Button.js";import G from"../../Core/Menu/List.js";import V from"../../../common/error.js";import{pickaxeApi2 as H}from"../../../common/api/pickaxe.js";import{getValidationFailure as W}from"../../../common/validation.js";import q from"../../../common/cn.js";import{buildUpgradeUrl as J,openAuthenticatedPricingUrl as z,initializeEmbedUserId as Q}from"../../../common/utils.js";import{getPickaxeConfigMetadata as Y}from"../../../common/pickaxeConfig.js";import{readAgentPrefill as Z}from"../../../common/agentPrefill.js";import{fireDeploymentSessionInitializedWebhook as ee,fireDeploymentFirstMessageSubmittedWebhook as te}from"../../../common/deploymentWebhooks.js";import{useStudio as ne}from"../../../hooks/studio/useStudio.js";import{useSpeechToText as se}from"../../../hooks/pickaxe/useSpeechToText.js";import{STUDIO_INFINITY_VALUE as oe}from"../common/PickaxeCommon.js";const ie=(e,t)=>{const n=e.find((e=>e.id===t));return n?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:n.predecessorSubmissionId}):e)):e},re=e=>"string"==typeof e&&e.trim().length>0,ae=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,le=e=>e.map((e=>Object.assign({},e))),de=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),ce=(e,t)=>{if(e&&"object"==typeof e)return e[t]},ue=(e,t)=>{const n=ce(e,t);return re(n)?n:null},pe=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},me=({studioUser:e,deploymentId:t,portalId:n})=>{var s,o;const i=Array.isArray(ce(e,"uses"))?ce(e,"uses"):[],r=(({deploymentId:e,portalId:t})=>re(e)?{type:"deployment",id:e}:re(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:n});if(!r)return{scope:r,record:null};const a=null!==(o=null!==(s=i.find((e=>e.id===r.id&&e.type===r.type)))&&void 0!==s?s:i.find((e=>e.id===r.id)))&&void 0!==o?o:null;return{scope:r,record:a}},ge=d((({resubmitPrompt:d,onFocus:ce,onBlur:ge,onInputHeightChange:fe,initSmitheryAuthData:ve},he)=>{var be,ye,xe,je,Ie,we,ke,Oe,Ne,Se,Ce,Ee,_e,Te,Ue,Ae,Pe,De;const{origin:Le,pickaxeId:Me,sessionId:Re,sender:$e,senderType:Be,portalId:Xe,deploymentId:Ke,deploymentType:Fe,pickaxe:Ge,styles:Ve,colors:He,translations:We,locale:qe,forceMobile:Je,isNewChat:ze,isRtl:Qe,isEmbed:Ye,isShowFeedbackMessage:Ze,accessGroup:et,setIsNewChat:tt,setIsShowIceBreaker:nt,setValidationStatus:st,setValidationUpgradeGroups:ot,setValidationUpgradeUrl:it,setAccessGroup:rt,onUpgrade:at,onGenerateComplete:lt}=v(),{value:dt,enabled:ct}=i(),{token:ut,isLoggedOut:pt,isSent:mt,isPricingAuth:gt}=I(),{messages:ft,isGenerating:vt,setMessages:ht,setStatus:bt,setLimitData:yt,setError:xt,setActionApprovalToken:jt}=h(),{documents:It,isUploading:wt,documentError:kt,onFileUpload:Ot,setDocuments:Nt,setDocumentError:St}=w(),{studio:Ct}=ne(),[Et]=S("(max-width: 480px)"),{scrollStartSession:_t,scrollEndSession:Tt,scrollToBottom:Ut}=k({auto:!0,smooth:!(Je||Et)}),{artifacts:At,currentPopupType:Pt,setArtifacts:Dt,setCurrentArtifact:Lt}=O(),{height:Mt}=j(),Rt=x(),[$t,Bt]=c((()=>Z([Ke,Me]).chatInput)),[Xt,Kt]=c(!1),[Ft,Gt]=c(!1),[Vt,Ht]=c(!1),[Wt,qt]=c(!1),[Jt,zt]=c([]),[Qt,Yt]=c(!1),[Zt,en]=c(null),[tn,nn]=c(null),[sn,on]=c(null),[rn,an]=c(null),[ln,dn]=c(!1),[cn,un]=c(!1),[pn,mn]=c(0),gn=u(null),fn=u(""),vn=u(null),hn=u(null),bn=u(null),yn=u([]),xn=u(null),jn=u(null),In=u(null),wn=u(null),kn=u(new Set),On=u(null),Nn=Math.max(.4*Mt,100),{speechTranscript:Sn,isSpeechListening:Cn,isSpeechProcessing:En,isSpeechSupported:_n,onStartListening:Tn,onStopListening:Un}=se(),An=N(),{isHover:Pn}=An,Dn=e(An,["isHover"]),Ln=N(),{isHover:Mn}=Ln,Rn=e(Ln,["isHover"]),$n=N(),{isHover:Bn}=$n,Xn=e($n,["isHover"]),Kn=y(),Fn=b(),Gn="undefined"!=typeof window?window.location.hostname:"",Vn="undefined"!=typeof window?window.location.href:"",Hn="undefined"!=typeof window&&window.self!==window.top,Wn=Gn.includes("pickaxe.co")&&!Vn.includes("https://studio.pickaxe.co/_embed")&&!Hn,qn=null!==(ye=null===(be=null==Ge?void 0:Ge.documentuploadtype)||void 0===be?void 0:be.startsWith("enduserupload"))&&void 0!==ye&&ye,Jn=_n&&(null==Ge?void 0:Ge.enablevoicetotext),zn=Cn&&!$t.trim(),Qn=re(Ke),Yn="chat-input"===Fe&&ze&&!mt,Zn="chat-input"===Fe&&gt&&pt&&mt,es=p((e=>{const t=W(e);return!!t&&(xt(""),yt(null),st(t.status),rt(t.accessGroup),ot(t.upgradeGroups),it(t.upgradeUrl),!0)}),[xt,jt,yt,st,ot,it,rt]),ts=null!==(xe=null==Ge?void 0:Ge.placeholdertext)&&void 0!==xe?xe:Qe?"بماذا تريد أن تتحدث؟":(null==We?void 0:We["what-do-you-want-to-talk-about"])||"What do you want to talk about?",ns=Xt||Ft,ss=p((()=>t(void 0,void 0,void 0,(function*(){dn(!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==Ge?void 0:Ge.studioid},ut?{studioSessionToken:ut}:$e?{sender:$e}:{sender:Q()}))},(!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}})),Wn&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(on(t.studioUser),an(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{dn(!0)}}))),[Wn,null==Ge?void 0:Ge.studioid,$e,ut]);m((()=>{ss()}),[ss]);const os=Number(null!==(je=null==et?void 0:et.limit)&&void 0!==je?je:0),is="string"==typeof(null==et?void 0:et.limitInterval)?et.limitInterval:null,rs=!!(null==Ct?void 0:Ct.data.usage)&&Ct.data.usage.isCredits,as=g((()=>{var e,t,n,s,o;return null!==(o=null!==(s=null!==(n=null!==(t=null!==(e=null!=Xe?Xe:ue(sn,"portalId"))&&void 0!==e?e:ue(sn,"portalid"))&&void 0!==t?t:ue(et,"portalId"))&&void 0!==n?n:ue(et,"portalid"))&&void 0!==s?s:ue(Ge,"portalId"))&&void 0!==o?o:ue(Ge,"portalid")}),[et,Xe,Ge,sn]),ls=g((()=>me({studioUser:sn,deploymentId:Ke,portalId:as})),[Ke,as,sn]);m((()=>{Qn&&ze&&Re&&kn.current.add(Re)}),[ze,Re,Qn]);const ds=p((()=>{var e,t,n;return{studioId:null==Ge?void 0:Ge.studioid,userEmail:ue(sn,"email"),userId:null!==(e=ue(sn,"userId"))&&void 0!==e?e:ue(sn,"userid"),sessionId:Re,deploymentId:Ke,deploymentType:Fe,portalId:as,accessGroupId:null!==(t=null==et?void 0:et.accessGroupId)&&void 0!==t?t:null,pickaxeId:Me,sender:$e,senderType:Be,origin:Le,metadata:null!==(n=Y(Ke))&&void 0!==n?n:null}}),[null==et?void 0:et.accessGroupId,Ke,Fe,Le,null==Ge?void 0:Ge.studioid,Me,as,$e,Be,Re,sn]),cs=p((()=>!!(Qn&&ln&&Re)&&(!!kn.current.has(Re)&&(ee(ds()),kn.current.delete(Re),!0))),[ds,ln,Re,Qn]);m((()=>{if(!ln||!Re)return;cs();const e=On.current;(null==e?void 0:e.sessionId)===Re&&(te(Object.assign(Object.assign(Object.assign({},e),ds()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),On.current=null)}),[cs,ds,ln,Re]);const us={currentUses:pe(null==sn?void 0:sn.currentUses),extraUses:pe(null==sn?void 0:sn.extraUses)},ps=ls.scope?{currentUses:null!==(we=pe(null===(Ie=ls.record)||void 0===Ie?void 0:Ie.currentUses))&&void 0!==we?we:0,extraUses:null!==(Oe=pe(null===(ke=ls.record)||void 0===ke?void 0:ke.extraUses))&&void 0!==Oe?Oe:0}:{currentUses:0,extraUses:0},ms=ue(sn,"type"),gs="guest"===ms||!ms&&pt?ps:us;m((()=>{let e=!0;return t(void 0,void 0,void 0,(function*(){var t;if(rs&&(null===(t=null==Ct?void 0:Ct.data)||void 0===t?void 0:t.workspaceId))try{const t=yield H.get(`/cost_per_run?workspaceId=${Ct.data.workspaceId}`,{withCredentials:!1});e&&mn(1e4*(Number(t.data.costPerRun)||0))}catch(t){console.error("Failed to fetch average cost per run:",t),e&&mn(0)}else e&&mn(0)})),()=>{e=!1}}),[rs,null===(Ne=null==Ct?void 0:Ct.data)||void 0===Ne?void 0:Ne.workspaceId]);const fs=(({accessGroupType:e,currentUses:t,extraUses:n,limit:s,limitInterval:o})=>{const i=Number(null!=t?t:0),r=Number(null!=n?n:0);return"public"===e&&"one_time"===o?s===oe?oe:Math.max(0,s-i):s===oe||r===oe?oe:"one_time"===o?Math.max(0,r-i):Math.max(0,s-i)+r})({accessGroupType:null==et?void 0:et.type,currentUses:gs.currentUses,extraUses:gs.extraUses,limit:os,limitInterval:is}),vs=fs===oe?oe:Math.max(0,Math.ceil(fs)),hs=(({accessGroupType:e,extraUses:t,limit:n,limitInterval:s})=>{const o=Number(null!=t?t:0);return"public"===e&&"one_time"===s?n===oe?oe:Math.max(0,n):n===oe||o===oe?oe:"one_time"===s?Math.max(0,o):Math.max(0,n)+Math.max(0,o)})({accessGroupType:null==et?void 0:et.type,extraUses:gs.extraUses,limit:os,limitInterval:is}),bs=hs===oe?oe:Math.ceil(.05*hs),ys=rs?Math.ceil(5*pn):5,xs=bs===oe?oe:Math.max(bs,ys),js=g((()=>!!sn&&(!cn&&(vs!==oe&&(!(hs<=0||vs>=hs)&&vs<=xs)))),[cn,xs,vs,sn,hs]),Is=Boolean(null==et?void 0:et.hideUpgradeOptions),ws=Boolean(!Is&&((null===(Se=null==et?void 0:et.upgrade)||void 0===Se?void 0:Se.isBuyMoreUses)||(null===(Ce=null==et?void 0:et.upgrade)||void 0===Ce?void 0:Ce.isLinkToCustomURL)||(null===(Ee=null==et?void 0:et.upgrade)||void 0===Ee?void 0:Ee.isUpgradeToAnotherGroup)&&(null===(_e=et.upgrade.accessGroupIds)||void 0===_e?void 0:_e.length))),ks=!Is&&(null===(Te=null==et?void 0:et.upgrade)||void 0===Te?void 0:Te.isLinkToCustomURL)&&"string"==typeof et.upgrade.limitLink&&et.upgrade.limitLink.trim().length>0?et.upgrade.limitLink.trim():null,Os=ks&&"string"==typeof(null===(Ue=null==et?void 0:et.upgrade)||void 0===Ue?void 0:Ue.limitCTA)&&et.upgrade.limitCTA.trim().length>0?et.upgrade.limitCTA:(null==We?void 0:We["pricing.upgrade"])||(null==We?void 0:We.upgrade)||"Upgrade",Ns=g((()=>{var e,t,n;return!!ze&&(!!Ge&&(!Rt.isLoading&&(!((null!==(t=null===(e=Rt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Ge.icebreakers)||void 0===n?void 0:n.length)&&(!Ze&&!Yn)))))}),[Ge,ze,Ze,Yn,Rt.data,Rt.isLoading]),Ss=g((()=>{if(wt||Vt)return!1;const e=qn&&It.length>0&&It.every((e=>"finished"===e.status));return!(!$t.trim()&&!e)&&It.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[qn,wt,Vt,$t,It]);f(he,(()=>({onSubmit:Us}))),m((()=>{nt(Ns)}),[Ns]),m((()=>{var e;if(d){const t=Array.from(ft),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Us(n,!0)}}),[d]),m((()=>{if(!In.current||!fe)return;const e=new ResizeObserver((e=>{for(const t of e)fe(t.contentRect.height)}));return e.observe(In.current),()=>{e.disconnect()}}),[fe]),m((()=>{if(!Cn)return;const e=fn.current?`${fn.current} `:"";Bt(`${e}${Sn}`)}),[Sn,Cn]),m((()=>{if(!xn.current)return;(()=>{if(!xn.current)return;let e=xn.current.scrollHeight>52;$t.includes("\n")||It.length?e=!0:$t.trim()||(e=!1),Kt(e)})()}),[$t,It]),m((()=>{const e=xn.current,t=jn.current;if(!e||!t||ct||Xt||$t.includes("\n"))return void Gt(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=$t||ts,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Gt(i>l)}),[$t,Xt,ts,ct]);const Cs=e=>t(void 0,void 0,void 0,(function*(){if(!(e=null!=e?e:hn.current))return!1;const t=le(yn.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${e}`,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:t})},Wn&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),Es=e=>{bn.current=e,wn.current&&(wn.current.abort(),wn.current=null),vn.current&&(vn.current.cancel().catch((()=>{})),vn.current=null)},_s=e=>t(void 0,void 0,void 0,(function*(){const t=Date.now()+3e4;for(;Date.now()<t;){try{const t=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${e}`,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}))},Wn&&{credentials:"include"}));if(t.ok){if((yield t.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),Ts=()=>{const e=hn.current;e&&!Vt&&!wt&&$t.trim()&&(zt((t=>{var n,s;return[...t,{id:ae(),message:$t,predecessorSubmissionId:null!==(s=null===(n=t[t.length-1])||void 0===n?void 0:n.id)&&void 0!==s?s:e}]})),Bt(""))},Us=(e,n=!1,s=!1,o,i=!1)=>t(void 0,void 0,void 0,(function*(){var t,r,d,c,u;let p=null;try{if(vt&&!s||wt)return;const m=It.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),g=m.map((e=>e.documentId)).filter(Boolean),f=m.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),v=null!=e?e:$t,h=null!==(r=null===(t=null==Ge?void 0:Ge.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==r&&r&&g.length>0;if(!v&&!h)return;xt(""),St(""),yt(null),Bt(""),tt(!1),qt(!1),bt("fetching"),_t(),Ut();const b=n?ft.slice(0,ft.length-1):ft,y=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(b),x=y+(n?0:1),j={id:x,role:"assistant",parts:[],documentIds:[]},I=[...b,...n?[]:[{id:y,role:"user",parts:[{type:"text",content:v,isVisible:!0}],documentIds:h?g:[]}],j];ht(I),Ut(),h&&Nt([]);const w=Y(Ke),k=null!=o?o:ae();p=k,hn.current=k,bn.current=null,yn.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:dt||void 0,origin:Le,pickaxeId:Me,sessionId:Re,submissionId:k},i&&{interactionType:"steer"}),{senderType:Be,value:v}),h&&{documentIds:g}),$e&&{sender:$e}),ut&&{studioSessionToken:ut}),!ut&&!$e&&{sender:Q()}),as&&{portalId:as}),Ke&&{deploymentId:Ke}),w&&{metadata:w}),h&&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()})},Wn&&{credentials:"include"})),N=yield O.json();if(!N.success){if(N.limitData){const e=new Error(N.error||N.message||(null==We?void 0:We["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=N.limitData,e}if(es(N))return;throw new Error(N.error||N.message||(null==We?void 0:We["failed-to-start-generation"])||"Failed to start generation")}jt(null!==(d=N.actionApprovalToken)&&void 0!==d?d:null);const S=null!==(c=N.submissionId)&&void 0!==c?c:k;p=S,hn.current=S;const C=()=>bn.current===S;if(C())return;Qn&&ze&&Re&&kn.current.add(Re);const E=Object.assign(Object.assign({},ds()),{message:v,documentIds:h?g:[],uploadedModelImages:h?f:[],hasUploadedDocuments:h,isHidden:n,metadata:null!=w?w:null});ln?(cs(),te(E)):On.current=E,bt("streaming"),wn.current=new AbortController;const _=[];let U=[...null!=At?At:[]],A=0,P=!1,D="";for(;!P;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${S}?index=${A}`,{signal:null===(u=wn.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();vn.current=t;const n=new TextDecoder,s=T({onEvent:e=>{var t,n;if(C())P=!0;else if(e.event&&"ping"!==e.event&&A++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return yt(t.limitData),xt(""),void(P=!0);const n=t.error||t.message||(null==We?void 0:We["something-went-wrong"])||"Something went wrong.";return es(t)||xt(n),void(P=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("finish-step"===s.type)return void qt(!0);if("data-error"===s.type&&ve){const e=s.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),n=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw P=!0,ve({provider:"smithery",smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}else if(n){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw P=!0,ve({provider:"composio",toolkitSlug:t[1],serverId:n[1],name:s[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 P=!0,ve({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 P=!0,ve({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)D="",_.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)D+=s.delta,a(_,"text",D);else if("text-end"===s.type)D="";else if("reasoning-start"===s.type)D="",_.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)D+=s.delta,a(_,"reasoning",D);else if("reasoning-end"===s.type)D="";else if(s.type.startsWith("data-")){const e=s;"data-action-approval"===e.type?l(_,e.data):_.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}yn.current=le(_);const o=le(_);ht((e=>{const t=e.findIndex((e=>e.id===x)),n=Object.assign(Object.assign({},j),{parts:o});return-1===t?[...e,n]:e.map(((e,s)=>s===t?n:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Dt([...U]),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Dt(U),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Dt(U),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");U=U.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),Dt(U)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Dt(U.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return yt(t.limitData),xt(""),void(P=!0);const n=t.error||t.message||(null==We?void 0:We["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(es(t))return void(P=!0);xt(n)}else"stop"===e.event&&(P=!0)}else P=!0}});for(;;){if(C()){P=!0,t.cancel().catch((()=>{}));break}const{value:e,done:o}=yield t.read();if(C()){P=!0,t.cancel().catch((()=>{}));break}if(o)break;s.feed(n.decode(e))}P||C()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||de(e)||C())return void(P=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==lt||lt(Re)}catch(e){if(de(e))return;if(e.limitData)yt(e.limitData),xt("");else{let t=V(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==We?void 0:We["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),es(t)||xt(t)}}finally{const e=!p||hn.current===p;Ut(),e&&(bt("idle"),Tt(),vn.current=null),p&&e&&(hn.current=null,yn.current=[]),yield ss()}}));return m((()=>{if(vt||Vt||Qt||0===Jt.length)return;const e=Jt[0];Yt(!0),en(e.id),t(void 0,void 0,void 0,(function*(){try{if(!(yield _s(e.predecessorSubmissionId)))return void xt((null==We?void 0:We["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");zt((t=>t.filter((t=>t.id!==e.id)))),yield Us(e.message,!1,!0,e.id)}finally{Yt(!1),en(null)}}))}),[vt,Qt,Vt,Jt]),Zn?null:n("div",Object.assign({className:q("flex w-full flex-shrink-0 flex-col items-center",!Yn&&"px-4 pb-8"),dir:Qe?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Jt.length>0&&n("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:He.text+"18",backgroundColor:null!==(Ae=Fn.backgroundColor)&&void 0!==Ae?Ae:He.text+"08",color:He.text,borderTopLeftRadius:Math.max(Ve.cornerRadius-4,12),borderTopRightRadius:Math.max(Ve.cornerRadius-4,12)}},{children:Jt.map(((e,i)=>{var r;return s("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:i<Jt.length-1?{borderBottom:`1px solid ${He.text}12`}:void 0},{children:[n(D,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),n("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:e.message},{children:e.message})),tn===e.id||Zt===e.id?s("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[n("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),tn===e.id?(null==We?void 0:We.steering)||"Steering...":(null==We?void 0:We.starting)||"Starting..."]})):s(o,{children:[s("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:Vt||!vt,onClick:()=>{(e=>{t(void 0,void 0,void 0,(function*(){const t=hn.current;if(!t||Vt)return;const n=Jt.findIndex((t=>t.id===e.id));if(-1===n)return;Ht(!0),nn(e.id),xt(""),Es(t);let s=!1;try{if(!(yield Cs(t)))throw new Error((null==We?void 0:We["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield _s(t)))throw new Error((null==We?void 0:We["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");bt("idle"),zt((t=>t.filter((t=>t.id!==e.id)))),s=!0,Ht(!1),nn(null),yield Us(e.message,!1,!0,e.id,!0)}catch(t){bt("idle"),s&&zt((t=>{if(t.some((t=>t.id===e.id)))return t;const s=[...t];return s.splice(n,0,e),s})),xt(V(t))}finally{Ht(!1),nn(null)}}))})(e)},"aria-label":`${(null==We?void 0:We["steer-with"])||"Steer with"}: ${e.message}`},{children:[n("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==We?void 0:We.steer)||"Steer"]})),n("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:Vt,onClick:()=>{return t=e.id,void zt((e=>ie(e,t)));var t},"aria-label":`${(null==We?void 0:We["remove-queued-message"])||"Remove queued message"}: ${e.message}`},{children:n(M,{className:"h-4 w-4","aria-hidden":"true"})})),s(K,Object.assign({id:`queued-message-menu-${e.id}`,className:"shrink-0"},{children:[n(F,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Vt,role:"button",tabIndex:Vt?-1:0,"aria-haspopup":"menu","aria-label":(null==We?void 0:We["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:s("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[n("circle",{cx:"5",cy:"12",r:"1.6"}),n("circle",{cx:"12",cy:"12",r:"1.6"}),n("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),n(G,Object.assign({role:"menu",align:Qe?"bottom-start":"bottom-end",positionStrategy:Ye?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(r=Fn.backgroundColor)&&void 0!==r?r:He.primary,color:He.text,borderRadius:"12px"},border:`1px solid ${He.text}20`},{children:s("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=>{zt((t=>ie(t,e.id))),Bt(e.message),requestAnimationFrame((()=>{const t=xn.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(e)},{children:[n(R,{className:"h-4 w-4 shrink-0"}),(null==We?void 0:We["edit-message"])||"Edit message"]}))}))]}))]})]}),e.id)}))})),s("div",Object.assign({ref:In,className:q("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ve.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Fn),{maxHeight:`${Nn}px`,overflowY:"auto"})},{children:[js&&s("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:Fn.backgroundColor?`${Fn.backgroundColor}E6`:void 0,borderColor:He.text+"20",color:He.text,borderTopRightRadius:Ve.cornerRadius+"px",borderTopLeftRadius:Ve.cornerRadius+"px"}},{children:[n("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:s("span",{children:[vs.toLocaleString()," ",rs?(null==We?void 0:We.credits)||"Credits":(null==We?void 0:We.uses)||"Uses"," ",(null==We?void 0:We.remaining)||"remaining"]})})),s("div",Object.assign({className:"flex items-center gap-3"},{children:[ws&&n("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:He.accent,color:He.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),ks)return void window.open(ks,"_blank","noopener,noreferrer");if(at)return void at();const t=J({baseUrl:rn,accessGroupId:null==et?void 0:et.accessGroupId});t&&z({deploymentId:Ke,pricingUrl:t,studioId:null==Ge?void 0:Ge.studioid,studioSessionToken:ut})}},{children:Os})),n("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>un(!0)},{children:n("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:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!vt&&It.length>0&&n($,{className:"p-4 pb-0",isDisabled:vt}),s("div",Object.assign({className:"relative flex w-full flex-col"},{children:[zn&&s("div",Object.assign({className:q(ct?"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:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(Pe=He.accent)&&void 0!==Pe?Pe:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:He.text+"90"}},{children:(null==We?void 0:We.listening)||"Listening..."}))]})),n(B,Object.assign({ref:xn,className:q(Kn.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!$t.trim()&&!$t.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Qe?"text-right":"text-left",!ct&&ns&&"mb-12"),value:$t,placeholder:zn?"":ts,onChange:e=>{Bt(e)},onKeyDown:e=>{Je||Et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),wt||Vt||(vt?Ts():Us())))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);if(t.length>0){if(!qn)return;e.preventDefault(),tt(!1),yield Ot(t)}}))},ce&&{onFocus:ce},ge&&{onBlur:ge},{dir:Qe?"rtl":"ltr"})),s("div",Object.assign({ref:jn,className:ct?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":q("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",ns?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ns&&Fn.backgroundColor&&{backgroundColor:Fn.backgroundColor}),{borderTopRightRadius:Ve.cornerRadius+"px",borderBottomRightRadius:Ve.cornerRadius+"px"})},{children:[!vt&&!Cn&&qn&&s("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:Mn?He.accent+"10":void 0,color:Mn?He.accent:He.accent+"80"},disabled:wt||vt,"aria-label":null!==(De=null==We?void 0:We["attach-files"])&&void 0!==De?De:"Attach files",onClick:()=>{var e;return null===(e=gn.current)||void 0===e?void 0:e.click()}},Rn,{children:[n("input",{id:"file-upload",ref:gn,type:"file",accept:[...C,...E,..._].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){tt(!1),yield Ot(Array.from(e.target.files||[])),e.target.value=""}))}),n(U,{className:"h-6 w-6 shrink-0"})]})),n(r,{compact:!0}),vt&&!Wt?s(o,{children:[n("button",Object.assign({"aria-label":(null==We?void 0:We["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=hn.current;e&&(Es(e),Cs(e)),bt("idle")},style:{backgroundColor:He.accent+"10",color:He.accent}},{children:n(L,{className:"h-4 w-4 shrink-0"})})),n("button",Object.assign({"aria-label":(null==We?void 0:We["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:Vt||wt||!$t.trim(),onClick:Ts,style:{backgroundColor:$t.trim()?He.accent:He.accent+"10",color:$t.trim()?He.accentText:He.accent+"80"}},{children:n(A,{className:q("h-6 w-6 shrink-0",Qe&&"scale-x-[-1] transform")})}))]}):Cn?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Un,style:{backgroundColor:He.accent,color:He.accentText}},{children:n(L,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[Jn&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Cn?He.accent:Bn?He.accent+"10":void 0,color:Cn?He.accentText:Bn?He.accent:He.accent+"80"},disabled:wt||vt||En,onClick:()=>{Cn?Un():(fn.current=$t,Tn(qe||"en-US"))}},Xn,{children:n(P,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Pn||Ss?He.accent:He.accent+"10",color:Pn||Ss?He.accentText:He.accent+"80"},disabled:!Ss,onClick:()=>Us()},Dn,{children:n(A,{className:q("h-6 w-6 shrink-0",Qe&&"scale-x-[-1] transform")})}))]})]}))]}))]})),kt&&n(X,{error:kt,className:"mt-3"})]}))}))}));ge.displayName="Input";export{ge as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{useEndUserModel as i}from"../../../hooks/pickaxe/useEndUserModel.js";import r from"../common/EndUserModelPicker.js";import{updateStreamTextPart as a,upsertActionApprovalPart as l}from"../../../common/actionApproval.js";import{forwardRef as d,useState as c,useRef as u,useCallback as p,useEffect as m,useMemo as g,useImperativeHandle as f}from"react";import{usePickaxeContext as v}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as h}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as b}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as y}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as x}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as j}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as I}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as w}from"../Addons/Document/hooks/useDocument.js";import{useScroll as k}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as N}from"../../../hooks/core/useHover.js";import{useMediaQuery as S}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as C,allowedImageMimeTypes as E,additionalAllowedFileExtensions as _}from"../../../common/documents.js";import{createParser as T}from"eventsource-parser";import U from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import P from"../../Icons/microphone.svg.js";import D from"../../Icons/message-clock.svg.js";import L from"../../Icons/stop.svg.js";import M from"../../Icons/trash.svg.js";import R from"../../Icons/pencil.svg.js";import $ from"../Addons/Document/List.js";import B from"../../Core/Textarea.js";import X from"../../Core/ErrorAlert.js";import K from"../../Core/Menu/index.js";import F from"../../Core/Menu/Button.js";import G from"../../Core/Menu/List.js";import V from"../../../common/error.js";import{pickaxeApi2 as H}from"../../../common/api/pickaxe.js";import{getValidationFailure as W}from"../../../common/validation.js";import q from"../../../common/cn.js";import{buildUpgradeUrl as J,openAuthenticatedPricingUrl as z,initializeEmbedUserId as Q}from"../../../common/utils.js";import{getPickaxeConfigMetadata as Y}from"../../../common/pickaxeConfig.js";import{readAgentPrefill as Z}from"../../../common/agentPrefill.js";import{fireDeploymentSessionInitializedWebhook as ee,fireDeploymentFirstMessageSubmittedWebhook as te}from"../../../common/deploymentWebhooks.js";import{useStudio as ne}from"../../../hooks/studio/useStudio.js";import{useSpeechToText as se}from"../../../hooks/pickaxe/useSpeechToText.js";import{STUDIO_INFINITY_VALUE as oe}from"../common/PickaxeCommon.js";const ie=(e,t)=>{const n=e.find((e=>e.id===t));return n?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:n.predecessorSubmissionId}):e)):e},re=e=>"string"==typeof e&&e.trim().length>0,ae=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,le=e=>e.map((e=>Object.assign({},e))),de=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),ce=(e,t)=>{if(e&&"object"==typeof e)return e[t]},ue=(e,t)=>{const n=ce(e,t);return re(n)?n:null},pe=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},me=({studioUser:e,deploymentId:t,portalId:n})=>{var s,o;const i=Array.isArray(ce(e,"uses"))?ce(e,"uses"):[],r=(({deploymentId:e,portalId:t})=>re(e)?{type:"deployment",id:e}:re(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:n});if(!r)return{scope:r,record:null};const a=null!==(o=null!==(s=i.find((e=>e.id===r.id&&e.type===r.type)))&&void 0!==s?s:i.find((e=>e.id===r.id)))&&void 0!==o?o:null;return{scope:r,record:a}},ge=d((({resubmitPrompt:d,onFocus:ce,onBlur:ge,onInputHeightChange:fe,initSmitheryAuthData:ve},he)=>{var be,ye,xe,je,Ie,we,ke,Oe,Ne,Se,Ce,Ee,_e,Te,Ue,Ae,Pe,De;const{origin:Le,pickaxeId:Me,sessionId:Re,sender:$e,senderType:Be,portalId:Xe,deploymentId:Ke,deploymentType:Fe,pickaxe:Ge,styles:Ve,colors:He,translations:We,locale:qe,forceMobile:Je,isNewChat:ze,isRtl:Qe,isEmbed:Ye,isShowFeedbackMessage:Ze,accessGroup:et,setIsNewChat:tt,setIsShowIceBreaker:nt,setValidationStatus:st,setValidationUpgradeGroups:ot,setValidationUpgradeUrl:it,setAccessGroup:rt,onUpgrade:at,onGenerateComplete:lt}=v(),{value:dt,enabled:ct}=i(),{token:ut,isLoggedOut:pt,isSent:mt,isPricingAuth:gt}=I(),{messages:ft,isGenerating:vt,setMessages:ht,setStatus:bt,setLimitData:yt,setError:xt,setActionApprovalToken:jt}=h(),{documents:It,isUploading:wt,documentError:kt,onFileUpload:Ot,setDocuments:Nt,setDocumentError:St}=w(),{studio:Ct}=ne(),[Et]=S("(max-width: 480px)"),{scrollStartSession:_t,scrollEndSession:Tt,scrollToBottom:Ut}=k({auto:!0,smooth:!(Je||Et)}),{artifacts:At,currentPopupType:Pt,setArtifacts:Dt,setCurrentArtifact:Lt}=O(),{height:Mt}=j(),Rt=x(),[$t,Bt]=c((()=>Z([Ke,Me]).chatInput)),[Xt,Kt]=c(!1),[Ft,Gt]=c(!1),[Vt,Ht]=c(!1),[Wt,qt]=c(!1),[Jt,zt]=c([]),[Qt,Yt]=c(!1),[Zt,en]=c(null),[tn,nn]=c(null),[sn,on]=c(null),[rn,an]=c(null),[ln,dn]=c(!1),[cn,un]=c(!1),[pn,mn]=c(0),gn=u(null),fn=u(""),vn=u(null),hn=u(null),bn=u(null),yn=u([]),xn=u(null),jn=u(null),In=u(null),wn=u(null),kn=u(new Set),On=u(null),Nn=Math.max(.4*Mt,100),{speechTranscript:Sn,isSpeechListening:Cn,isSpeechProcessing:En,isSpeechSupported:_n,onStartListening:Tn,onStopListening:Un}=se(),An=N(),{isHover:Pn}=An,Dn=e(An,["isHover"]),Ln=N(),{isHover:Mn}=Ln,Rn=e(Ln,["isHover"]),$n=N(),{isHover:Bn}=$n,Xn=e($n,["isHover"]),Kn=y(),Fn=b(),Gn="undefined"!=typeof window?window.location.hostname:"",Vn="undefined"!=typeof window?window.location.href:"",Hn="undefined"!=typeof window&&window.self!==window.top,Wn=Gn.includes("pickaxe.co")&&!Vn.includes("https://studio.pickaxe.co/_embed")&&!Hn,qn=null!==(ye=null===(be=null==Ge?void 0:Ge.documentuploadtype)||void 0===be?void 0:be.startsWith("enduserupload"))&&void 0!==ye&&ye,Jn=_n&&(null==Ge?void 0:Ge.enablevoicetotext),zn=Cn&&!$t.trim(),Qn=re(Ke),Yn="chat-input"===Fe&&ze&&!mt,Zn="chat-input"===Fe&&gt&&pt&&mt,es=p((e=>{const t=W(e);return!!t&&(xt(""),yt(null),st(t.status),rt(t.accessGroup),ot(t.upgradeGroups),it(t.upgradeUrl),!0)}),[xt,jt,yt,st,ot,it,rt]),ts=null!==(xe=null==Ge?void 0:Ge.placeholdertext)&&void 0!==xe?xe:Qe?"بماذا تريد أن تتحدث؟":(null==We?void 0:We["what-do-you-want-to-talk-about"])||"What do you want to talk about?",ns=Xt||Ft,ss=p((()=>t(void 0,void 0,void 0,(function*(){dn(!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==Ge?void 0:Ge.studioid},ut?{studioSessionToken:ut}:$e?{sender:$e}:{sender:Q()}))},(!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}})),Wn&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(on(t.studioUser),an(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{dn(!0)}}))),[Wn,null==Ge?void 0:Ge.studioid,$e,ut]);m((()=>{ss()}),[ss]);const os=Number(null!==(je=null==et?void 0:et.limit)&&void 0!==je?je:0),is="string"==typeof(null==et?void 0:et.limitInterval)?et.limitInterval:null,rs=!!(null==Ct?void 0:Ct.data.usage)&&Ct.data.usage.isCredits,as=g((()=>{var e,t,n,s,o;return null!==(o=null!==(s=null!==(n=null!==(t=null!==(e=null!=Xe?Xe:ue(sn,"portalId"))&&void 0!==e?e:ue(sn,"portalid"))&&void 0!==t?t:ue(et,"portalId"))&&void 0!==n?n:ue(et,"portalid"))&&void 0!==s?s:ue(Ge,"portalId"))&&void 0!==o?o:ue(Ge,"portalid")}),[et,Xe,Ge,sn]),ls=g((()=>me({studioUser:sn,deploymentId:Ke,portalId:as})),[Ke,as,sn]);m((()=>{Qn&&ze&&Re&&kn.current.add(Re)}),[ze,Re,Qn]);const ds=p((()=>{var e,t,n;return{studioId:null==Ge?void 0:Ge.studioid,userEmail:ue(sn,"email"),userId:null!==(e=ue(sn,"userId"))&&void 0!==e?e:ue(sn,"userid"),sessionId:Re,deploymentId:Ke,deploymentType:Fe,portalId:as,accessGroupId:null!==(t=null==et?void 0:et.accessGroupId)&&void 0!==t?t:null,pickaxeId:Me,sender:$e,senderType:Be,origin:Le,metadata:null!==(n=Y(Ke))&&void 0!==n?n:null}}),[null==et?void 0:et.accessGroupId,Ke,Fe,Le,null==Ge?void 0:Ge.studioid,Me,as,$e,Be,Re,sn]),cs=p((()=>!!(Qn&&ln&&Re)&&(!!kn.current.has(Re)&&(ee(ds()),kn.current.delete(Re),!0))),[ds,ln,Re,Qn]);m((()=>{if(!ln||!Re)return;cs();const e=On.current;(null==e?void 0:e.sessionId)===Re&&(te(Object.assign(Object.assign(Object.assign({},e),ds()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),On.current=null)}),[cs,ds,ln,Re]);const us={currentUses:pe(null==sn?void 0:sn.currentUses),extraUses:pe(null==sn?void 0:sn.extraUses)},ps=ls.scope?{currentUses:null!==(we=pe(null===(Ie=ls.record)||void 0===Ie?void 0:Ie.currentUses))&&void 0!==we?we:0,extraUses:null!==(Oe=pe(null===(ke=ls.record)||void 0===ke?void 0:ke.extraUses))&&void 0!==Oe?Oe:0}:{currentUses:0,extraUses:0},ms=ue(sn,"type"),gs="guest"===ms||!ms&&pt?ps:us;m((()=>{let e=!0;return t(void 0,void 0,void 0,(function*(){var t;if(rs&&(null===(t=null==Ct?void 0:Ct.data)||void 0===t?void 0:t.workspaceId))try{const t=yield H.get(`/cost_per_run?workspaceId=${Ct.data.workspaceId}`,{withCredentials:!1});e&&mn(1e4*(Number(t.data.costPerRun)||0))}catch(t){console.error("Failed to fetch average cost per run:",t),e&&mn(0)}else e&&mn(0)})),()=>{e=!1}}),[rs,null===(Ne=null==Ct?void 0:Ct.data)||void 0===Ne?void 0:Ne.workspaceId]);const fs=(({accessGroupType:e,currentUses:t,extraUses:n,limit:s,limitInterval:o})=>{const i=Number(null!=t?t:0),r=Number(null!=n?n:0);return"public"===e&&"one_time"===o?s===oe?oe:Math.max(0,s-i):s===oe||r===oe?oe:"one_time"===o?Math.max(0,r-i):Math.max(0,s-i)+r})({accessGroupType:null==et?void 0:et.type,currentUses:gs.currentUses,extraUses:gs.extraUses,limit:os,limitInterval:is}),vs=fs===oe?oe:Math.max(0,Math.ceil(fs)),hs=(({accessGroupType:e,extraUses:t,limit:n,limitInterval:s})=>{const o=Number(null!=t?t:0);return"public"===e&&"one_time"===s?n===oe?oe:Math.max(0,n):n===oe||o===oe?oe:"one_time"===s?Math.max(0,o):Math.max(0,n)+Math.max(0,o)})({accessGroupType:null==et?void 0:et.type,extraUses:gs.extraUses,limit:os,limitInterval:is}),bs=hs===oe?oe:Math.ceil(.05*hs),ys=rs?Math.ceil(5*pn):5,xs=bs===oe?oe:Math.max(bs,ys),js=g((()=>!!sn&&(!cn&&(vs!==oe&&(!(hs<=0||vs>=hs)&&vs<=xs)))),[cn,xs,vs,sn,hs]),Is=Boolean(null==et?void 0:et.hideUpgradeOptions),ws=Boolean(!Is&&((null===(Se=null==et?void 0:et.upgrade)||void 0===Se?void 0:Se.isBuyMoreUses)||(null===(Ce=null==et?void 0:et.upgrade)||void 0===Ce?void 0:Ce.isLinkToCustomURL)||(null===(Ee=null==et?void 0:et.upgrade)||void 0===Ee?void 0:Ee.isUpgradeToAnotherGroup)&&(null===(_e=et.upgrade.accessGroupIds)||void 0===_e?void 0:_e.length))),ks=!Is&&(null===(Te=null==et?void 0:et.upgrade)||void 0===Te?void 0:Te.isLinkToCustomURL)&&"string"==typeof et.upgrade.limitLink&&et.upgrade.limitLink.trim().length>0?et.upgrade.limitLink.trim():null,Os=ks&&"string"==typeof(null===(Ue=null==et?void 0:et.upgrade)||void 0===Ue?void 0:Ue.limitCTA)&&et.upgrade.limitCTA.trim().length>0?et.upgrade.limitCTA:(null==We?void 0:We["pricing.upgrade"])||(null==We?void 0:We.upgrade)||"Upgrade",Ns=g((()=>{var e,t,n;return!!ze&&(!!Ge&&(!Rt.isLoading&&(!((null!==(t=null===(e=Rt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Ge.icebreakers)||void 0===n?void 0:n.length)&&(!Ze&&!Yn)))))}),[Ge,ze,Ze,Yn,Rt.data,Rt.isLoading]),Ss=g((()=>{if(wt||Vt)return!1;const e=qn&&It.length>0&&It.every((e=>"finished"===e.status));return!(!$t.trim()&&!e)&&It.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[qn,wt,Vt,$t,It]);f(he,(()=>({onSubmit:Us}))),m((()=>{nt(Ns)}),[Ns]),m((()=>{var e;if(d){const t=Array.from(ft),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Us(n,!0)}}),[d]),m((()=>{if(!In.current||!fe)return;const e=new ResizeObserver((e=>{for(const t of e)fe(t.contentRect.height)}));return e.observe(In.current),()=>{e.disconnect()}}),[fe]),m((()=>{if(!Cn)return;const e=fn.current?`${fn.current} `:"";Bt(`${e}${Sn}`)}),[Sn,Cn]),m((()=>{if(!xn.current)return;(()=>{if(!xn.current)return;let e=xn.current.scrollHeight>52;$t.includes("\n")||It.length?e=!0:$t.trim()||(e=!1),Kt(e)})()}),[$t,It]),m((()=>{const e=xn.current,t=jn.current;if(!e||!t||ct||Xt||$t.includes("\n"))return void Gt(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=$t||ts,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Gt(i>l)}),[$t,Xt,ts,ct]);const Cs=e=>t(void 0,void 0,void 0,(function*(){if(!(e=null!=e?e:hn.current))return!1;const t=le(yn.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${e}`,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:t})},Wn&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),Es=e=>{bn.current=e,wn.current&&(wn.current.abort(),wn.current=null),vn.current&&(vn.current.cancel().catch((()=>{})),vn.current=null)},_s=e=>t(void 0,void 0,void 0,(function*(){const t=Date.now()+3e4;for(;Date.now()<t;){try{const t=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${e}`,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}))},Wn&&{credentials:"include"}));if(t.ok){if((yield t.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),Ts=()=>{const e=hn.current;e&&!Vt&&!wt&&$t.trim()&&(zt((t=>{var n,s;return[...t,{id:ae(),message:$t,predecessorSubmissionId:null!==(s=null===(n=t[t.length-1])||void 0===n?void 0:n.id)&&void 0!==s?s:e}]})),Bt(""))},Us=(e,n=!1,s=!1,o,i=!1)=>t(void 0,void 0,void 0,(function*(){var t,r,d,c,u;let p=null;try{if(vt&&!s||wt)return;const m=It.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),g=m.map((e=>e.documentId)).filter(Boolean),f=m.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),v=null!=e?e:$t,h=null!==(r=null===(t=null==Ge?void 0:Ge.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==r&&r&&g.length>0;if(!v&&!h)return;xt(""),St(""),yt(null),Bt(""),tt(!1),qt(!1),bt("fetching"),_t(),Ut();const b=n?ft.slice(0,ft.length-1):ft,y=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(b),x=y+(n?0:1),j={id:x,role:"assistant",parts:[],documentIds:[]},I=[...b,...n?[]:[{id:y,role:"user",parts:[{type:"text",content:v,isVisible:!0}],documentIds:h?g:[]}],j];ht(I),Ut(),h&&Nt([]);const w=Y(Ke),k=null!=o?o:ae();p=k,hn.current=k,bn.current=null,yn.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:dt||void 0,origin:Le,pickaxeId:Me,sessionId:Re,submissionId:k},i&&{interactionType:"steer"}),{senderType:Be,value:v}),h&&{documentIds:g}),$e&&{sender:$e}),ut&&{studioSessionToken:ut}),!ut&&!$e&&{sender:Q()}),as&&{portalId:as}),Ke&&{deploymentId:Ke}),w&&{metadata:w}),h&&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()})},Wn&&{credentials:"include"})),N=yield O.json();if(!N.success){if(N.limitData){const e=new Error(N.error||N.message||(null==We?void 0:We["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=N.limitData,e}if(es(N))return;throw new Error(N.error||N.message||(null==We?void 0:We["failed-to-start-generation"])||"Failed to start generation")}jt(null!==(d=N.actionApprovalToken)&&void 0!==d?d:null);const S=null!==(c=N.submissionId)&&void 0!==c?c:k;p=S,hn.current=S;const C=()=>bn.current===S;if(C())return;Qn&&ze&&Re&&kn.current.add(Re);const E=Object.assign(Object.assign({},ds()),{message:v,documentIds:h?g:[],uploadedModelImages:h?f:[],hasUploadedDocuments:h,isHidden:n,metadata:null!=w?w:null});ln?(cs(),te(E)):On.current=E,bt("streaming"),wn.current=new AbortController;const _=[];let U=[...null!=At?At:[]],A=0,P=!1,D="";for(;!P;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${S}?index=${A}`,{signal:null===(u=wn.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();vn.current=t;const n=new TextDecoder,s=T({onEvent:e=>{var t,n;if(C())P=!0;else if(e.event&&"ping"!==e.event&&A++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return yt(t.limitData),xt(""),void(P=!0);const n=t.error||t.message||(null==We?void 0:We["something-went-wrong"])||"Something went wrong.";return es(t)||xt(n),void(P=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("finish"===s.type)return void qt(!0);if("data-error"===s.type&&ve){const e=s.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),n=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw P=!0,ve({provider:"smithery",smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}else if(n){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw P=!0,ve({provider:"composio",toolkitSlug:t[1],serverId:n[1],name:s[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 P=!0,ve({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 P=!0,ve({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)D="",_.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)D+=s.delta,a(_,"text",D);else if("text-end"===s.type)D="";else if("reasoning-start"===s.type)D="",_.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)D+=s.delta,a(_,"reasoning",D);else if("reasoning-end"===s.type)D="";else if(s.type.startsWith("data-")){const e=s;"data-action-approval"===e.type?l(_,e.data):_.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}yn.current=le(_);const o=le(_);ht((e=>{const t=e.findIndex((e=>e.id===x)),n=Object.assign(Object.assign({},j),{parts:o});return-1===t?[...e,n]:e.map(((e,s)=>s===t?n:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Dt([...U]),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Dt(U),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);U=U.filter((e=>!(e.id===t.id&&e.version===t.version))),U.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Dt(U),Pt.startsWith("inline")||Lt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");U=U.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),Dt(U)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Dt(U.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return yt(t.limitData),xt(""),void(P=!0);const n=t.error||t.message||(null==We?void 0:We["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(es(t))return void(P=!0);xt(n)}else"stop"===e.event&&(P=!0)}else P=!0}});for(;;){if(C()){P=!0,t.cancel().catch((()=>{}));break}const{value:e,done:o}=yield t.read();if(C()){P=!0,t.cancel().catch((()=>{}));break}if(o)break;s.feed(n.decode(e))}P||C()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||de(e)||C())return void(P=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==lt||lt(Re)}catch(e){if(de(e))return;if(e.limitData)yt(e.limitData),xt("");else{let t=V(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==We?void 0:We["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),es(t)||xt(t)}}finally{const e=!p||hn.current===p;Ut(),e&&(bt("idle"),Tt(),vn.current=null),p&&e&&(hn.current=null,yn.current=[]),yield ss()}}));return m((()=>{if(vt||Vt||Qt||0===Jt.length)return;const e=Jt[0];Yt(!0),en(e.id),t(void 0,void 0,void 0,(function*(){try{if(!(yield _s(e.predecessorSubmissionId)))return void xt((null==We?void 0:We["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");zt((t=>t.filter((t=>t.id!==e.id)))),yield Us(e.message,!1,!0,e.id)}finally{Yt(!1),en(null)}}))}),[vt,Qt,Vt,Jt]),Zn?null:n("div",Object.assign({className:q("flex w-full flex-shrink-0 flex-col items-center",!Yn&&"px-4 pb-8"),dir:Qe?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Jt.length>0&&n("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:He.text+"18",backgroundColor:null!==(Ae=Fn.backgroundColor)&&void 0!==Ae?Ae:He.text+"08",color:He.text,borderTopLeftRadius:Math.max(Ve.cornerRadius-4,12),borderTopRightRadius:Math.max(Ve.cornerRadius-4,12)}},{children:Jt.map(((e,i)=>{var r;return s("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:i<Jt.length-1?{borderBottom:`1px solid ${He.text}12`}:void 0},{children:[n(D,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),n("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:e.message},{children:e.message})),tn===e.id||Zt===e.id?s("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[n("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),tn===e.id?(null==We?void 0:We.steering)||"Steering...":(null==We?void 0:We.starting)||"Starting..."]})):s(o,{children:[s("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:Vt||!vt,onClick:()=>{(e=>{t(void 0,void 0,void 0,(function*(){const t=hn.current;if(!t||Vt)return;const n=Jt.findIndex((t=>t.id===e.id));if(-1===n)return;Ht(!0),nn(e.id),xt(""),Es(t);let s=!1;try{if(!(yield Cs(t)))throw new Error((null==We?void 0:We["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield _s(t)))throw new Error((null==We?void 0:We["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");bt("idle"),zt((t=>t.filter((t=>t.id!==e.id)))),s=!0,Ht(!1),nn(null),yield Us(e.message,!1,!0,e.id,!0)}catch(t){bt("idle"),s&&zt((t=>{if(t.some((t=>t.id===e.id)))return t;const s=[...t];return s.splice(n,0,e),s})),xt(V(t))}finally{Ht(!1),nn(null)}}))})(e)},"aria-label":`${(null==We?void 0:We["steer-with"])||"Steer with"}: ${e.message}`},{children:[n("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==We?void 0:We.steer)||"Steer"]})),n("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:Vt,onClick:()=>{return t=e.id,void zt((e=>ie(e,t)));var t},"aria-label":`${(null==We?void 0:We["remove-queued-message"])||"Remove queued message"}: ${e.message}`},{children:n(M,{className:"h-4 w-4","aria-hidden":"true"})})),s(K,Object.assign({id:`queued-message-menu-${e.id}`,className:"shrink-0"},{children:[n(F,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Vt,role:"button",tabIndex:Vt?-1:0,"aria-haspopup":"menu","aria-label":(null==We?void 0:We["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:s("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[n("circle",{cx:"5",cy:"12",r:"1.6"}),n("circle",{cx:"12",cy:"12",r:"1.6"}),n("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),n(G,Object.assign({role:"menu",align:Qe?"bottom-start":"bottom-end",positionStrategy:Ye?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(r=Fn.backgroundColor)&&void 0!==r?r:He.primary,color:He.text,borderRadius:"12px"},border:`1px solid ${He.text}20`},{children:s("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=>{zt((t=>ie(t,e.id))),Bt(e.message),requestAnimationFrame((()=>{const t=xn.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(e)},{children:[n(R,{className:"h-4 w-4 shrink-0"}),(null==We?void 0:We["edit-message"])||"Edit message"]}))}))]}))]})]}),e.id)}))})),s("div",Object.assign({ref:In,className:q("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ve.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Fn),{maxHeight:`${Nn}px`,overflowY:"auto"})},{children:[js&&s("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:Fn.backgroundColor?`${Fn.backgroundColor}E6`:void 0,borderColor:He.text+"20",color:He.text,borderTopRightRadius:Ve.cornerRadius+"px",borderTopLeftRadius:Ve.cornerRadius+"px"}},{children:[n("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:s("span",{children:[vs.toLocaleString()," ",rs?(null==We?void 0:We.credits)||"Credits":(null==We?void 0:We.uses)||"Uses"," ",(null==We?void 0:We.remaining)||"remaining"]})})),s("div",Object.assign({className:"flex items-center gap-3"},{children:[ws&&n("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:He.accent,color:He.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),ks)return void window.open(ks,"_blank","noopener,noreferrer");if(at)return void at();const t=J({baseUrl:rn,accessGroupId:null==et?void 0:et.accessGroupId});t&&z({deploymentId:Ke,pricingUrl:t,studioId:null==Ge?void 0:Ge.studioid,studioSessionToken:ut})}},{children:Os})),n("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>un(!0)},{children:n("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:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!vt&&It.length>0&&n($,{className:"p-4 pb-0",isDisabled:vt}),s("div",Object.assign({className:"relative flex w-full flex-col"},{children:[zn&&s("div",Object.assign({className:q(ct?"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:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(Pe=He.accent)&&void 0!==Pe?Pe:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:He.text+"90"}},{children:(null==We?void 0:We.listening)||"Listening..."}))]})),n(B,Object.assign({ref:xn,className:q(Kn.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!$t.trim()&&!$t.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Qe?"text-right":"text-left",!ct&&ns&&"mb-12"),value:$t,placeholder:zn?"":ts,onChange:e=>{Bt(e)},onKeyDown:e=>{Je||Et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),wt||Vt||(vt?Ts():Us())))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);if(t.length>0){if(!qn)return;e.preventDefault(),tt(!1),yield Ot(t)}}))},ce&&{onFocus:ce},ge&&{onBlur:ge},{dir:Qe?"rtl":"ltr"})),s("div",Object.assign({ref:jn,className:ct?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":q("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",ns?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ns&&Fn.backgroundColor&&{backgroundColor:Fn.backgroundColor}),{borderTopRightRadius:Ve.cornerRadius+"px",borderBottomRightRadius:Ve.cornerRadius+"px"})},{children:[!vt&&!Cn&&qn&&s("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:Mn?He.accent+"10":void 0,color:Mn?He.accent:He.accent+"80"},disabled:wt||vt,"aria-label":null!==(De=null==We?void 0:We["attach-files"])&&void 0!==De?De:"Attach files",onClick:()=>{var e;return null===(e=gn.current)||void 0===e?void 0:e.click()}},Rn,{children:[n("input",{id:"file-upload",ref:gn,type:"file",accept:[...C,...E,..._].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){tt(!1),yield Ot(Array.from(e.target.files||[])),e.target.value=""}))}),n(U,{className:"h-6 w-6 shrink-0"})]})),n(r,{compact:!0}),vt&&!Wt?s(o,{children:[n("button",Object.assign({"aria-label":(null==We?void 0:We["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=hn.current;e&&(Es(e),Cs(e)),bt("idle")},style:{backgroundColor:He.accent+"10",color:He.accent}},{children:n(L,{className:"h-4 w-4 shrink-0"})})),n("button",Object.assign({"aria-label":(null==We?void 0:We["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:Vt||wt||!$t.trim(),onClick:Ts,style:{backgroundColor:$t.trim()?He.accent:He.accent+"10",color:$t.trim()?He.accentText:He.accent+"80"}},{children:n(A,{className:q("h-6 w-6 shrink-0",Qe&&"scale-x-[-1] transform")})}))]}):Cn?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Un,style:{backgroundColor:He.accent,color:He.accentText}},{children:n(L,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[Jn&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Cn?He.accent:Bn?He.accent+"10":void 0,color:Cn?He.accentText:Bn?He.accent:He.accent+"80"},disabled:wt||vt||En,onClick:()=>{Cn?Un():(fn.current=$t,Tn(qe||"en-US"))}},Xn,{children:n(P,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Pn||Ss?He.accent:He.accent+"10",color:Pn||Ss?He.accentText:He.accent+"80"},disabled:!Ss,onClick:()=>Us()},Dn,{children:n(A,{className:q("h-6 w-6 shrink-0",Qe&&"scale-x-[-1] transform")})}))]})]}))]}))]})),kt&&n(X,{error:kt,className:"mt-3"})]}))}))}));ge.displayName="Input";export{ge as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{getFormQuestionError as n}from"../../../../common/formQuestionValidation.js";import{useEndUserModel as i}from"../../../../hooks/pickaxe/useEndUserModel.js";import o from"../../common/EndUserModelPicker.js";import{updateStreamTextPart as r,upsertActionApprovalPart as a}from"../../../../common/actionApproval.js";import{useState as l,useRef as d,useMemo as c}from"react";import{usePickaxeContext as p}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as u}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as f}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as v}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as h,initializeEmbedUserId as b}from"../../../../common/utils.js";import{createParser as j}from"eventsource-parser";import y from"../../common/PickaxeBranding.js";import O from"../../common/PickaxeButton.js";import x from"../../../../common/error.js";import{getValidationFailure as w}from"../../../../common/validation.js";const k=({navigation:k,paged:I=!1,questions:S,resetQuestions:A,onInvalidQuestion:C})=>{var E;const{origin:N,pickaxeId:P,sender:_,senderType:T,portalId:U,deploymentId:D,pickaxe:L,misc:q,translations:B,isRtl:J,setSessionId:V,setIsNewChat:K,setValidationStatus:W,setValidationUpgradeGroups:X,setValidationUpgradeUrl:R,setAccessGroup:G,onGenerateComplete:M}=p(),{value:$}=i(),{token:Q}=u(),{isGenerating:F,setResponse:Y,setMessages:z,setStatus:H,setLimitData:Z,setError:ee,setActionApprovalToken:te,setIsSwitchedToChat:se}=m(),{documents:ne,websiteLink:ie,isUploading:oe,onWebsiteUpload:re,setDocuments:ae,setDocumentError:le}=f(),{scrollStartSession:de,scrollEndSession:ce,scrollToTarget:pe}=g({auto:!(null==L?void 0:L.enablechatresponses)}),{artifacts:ue,currentPopupType:me,setArtifacts:fe,setCurrentArtifact:ge}=v(),[ve,he]=l(!1),[be,je]=l(!1),ye=d(null),Oe=e=>{const t=w(e);return!!t&&(ee(""),Z(null),W(t.status),G(t.accessGroup),X(t.upgradeGroups),R(t.upgradeUrl),!0)},xe=c((()=>S.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))),[S])&&t(O,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:oe||F||ve,onClick:A},{children:(null==B?void 0:B["form.clear-form"])||(null==B?void 0:B["clear-form"])||"Clear form"}));return s("div",Object.assign({className:I?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:J?"rtl":"ltr"},{children:[I&&t(o,{}),s("div",Object.assign({className:I?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!I&&t(o,{}),I&&k&&t("div",Object.assign({className:"me-auto shrink-0"},{children:k})),I&&xe,t(O,Object.assign({className:"px-5 min-h-[42px]",isDisabled:oe||F||ve,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,t,s,i,o;try{if(F||oe||ve)return;ee(""),le(""),Z(null),Y(null);for(const t of S){const s=n(t);if(s)throw null==C||C(t.id),new Error(null!==(e=null==B?void 0:B[s])&&void 0!==e?e:"response-too-long"===s?"One or more of your responses is too long!":"You must fill out all required fields.")}const l=ne.filter((e=>"finished"===e.status)),d=ne.map((e=>e.name)),c=null!==(s=null===(t=null==L?void 0:L.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s,p=S.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),u=h(ie).filter((e=>!d.includes(e)));if(u.length){const e=u[u.length-1];he(!0);const t=yield re(e);t&&(l.push(t),yield new Promise((e=>setTimeout(e,5e3)))),he(!1)}else if(p&&c&&!l.length)return null==C||C("userinput:documentupload"),void le((null==B?void 0:B["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const m=l.map((e=>e.documentId||"")).filter(Boolean),f=c&&m.length>0,g={};S.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?l.map((e=>e.name)).join(",")||"":e.input})),je(!1),H("fetching"),de(),pe();const v=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:$||void 0,origin:N,pickaxeId:P,senderType:T,valueObj:g},f&&{documentIds:m}),_&&{sender:_}),Q&&{studioSessionToken:Q}),!Q&&!_&&{sender:b()}),U&&{portalId:U}),D&&{deploymentId:D}))}),y=yield v.json();if(!y.success){const e=new Error(y.error||y.message||(null==B?void 0:B["failed-to-start-generation"])||"Failed to start generation");if(y.limitData)throw e.limitData=y.limitData,e;if(Oe(y))return;throw e}if(!y.submissionId||!y.sessionId)throw new Error((null==B?void 0:B["failed-to-start-generation"])||"Failed to start generation");te(null!==(i=y.actionApprovalToken)&&void 0!==i?i:null);const O=y.submissionId,x=y.sessionId,w={sessionId:x,documentIds:f?m:[],question:{inputs:S.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};Y(w),(null==L?void 0:L.enablechatresponses)&&(V(x),K(!1),se(!0),z([{id:0,role:"assistant",parts:[],documentIds:[]}])),f&&ae([]),H("streaming"),ye.current=new AbortController;const k=[];let I=[...null!=ue?ue:[]],A=0,E=!1,q="";for(;!E;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${O}?index=${A}`,{signal:null===(o=ye.current)||void 0===o?void 0:o.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=j({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&A++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Z(t.limitData),ee(""),void(E=!0);const s=t.error||t.message||(null==B?void 0:B["something-went-wrong"])||"Something went wrong.";return Oe(t)||ee(s),void(E=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish-step"===n.type)return void je(!0);if("text-start"===n.type)q="",k.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)q+=n.delta,r(k,"text",q);else if("text-end"===n.type)q="";else if("reasoning-start"===n.type)q="",k.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)q+=n.delta,r(k,"reasoning",q);else if("reasoning-end"===n.type)q="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?a(k,e.data):k.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},w),{question:Object.assign(Object.assign({},w.question),{responseParts:[...k]})});Y(i),(null==L?void 0:L.enablechatresponses)&&z([{id:0,role:"assistant",parts:[...k],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");I=I.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),fe([...I])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);fe(I.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else E=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}E||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(E=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==M||M(x)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Z(e.limitData),ee(""),void pe();let t=x(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==B?void 0:B["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Oe(t)||ee(t),pe()}finally{H("idle"),he(!1),ce()}}))},{children:ve?(null==B?void 0:B.processing)||"Processing...":oe?(null==B?void 0:B.uploading)||"Uploading...":F&&!be?(null==B?void 0:B.loading)||"Loading...":null!==(E=null==L?void 0:L.submittext)&&void 0!==E?E:"Submit"})),!I&&xe]})),!q.isWhiteLabel&&t(y,{containerClassName:"justify-end"})]}))};export{k as default};
1
+ import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{getFormQuestionError as n}from"../../../../common/formQuestionValidation.js";import{useEndUserModel as i}from"../../../../hooks/pickaxe/useEndUserModel.js";import o from"../../common/EndUserModelPicker.js";import{updateStreamTextPart as r,upsertActionApprovalPart as a}from"../../../../common/actionApproval.js";import{useState as l,useRef as d,useMemo as c}from"react";import{usePickaxeContext as u}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as p}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as f}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as v}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as h,initializeEmbedUserId as b}from"../../../../common/utils.js";import{createParser as j}from"eventsource-parser";import y from"../../common/PickaxeBranding.js";import O from"../../common/PickaxeButton.js";import x from"../../../../common/error.js";import{getValidationFailure as w}from"../../../../common/validation.js";const k=({navigation:k,paged:I=!1,questions:S,resetQuestions:A,onInvalidQuestion:C})=>{var E;const{origin:N,pickaxeId:P,sender:_,senderType:T,portalId:U,deploymentId:D,pickaxe:L,misc:q,translations:B,isRtl:J,setSessionId:V,setIsNewChat:K,setValidationStatus:W,setValidationUpgradeGroups:X,setValidationUpgradeUrl:R,setAccessGroup:G,onGenerateComplete:M}=u(),{value:$}=i(),{token:Q}=p(),{isGenerating:F,setResponse:Y,setMessages:z,setStatus:H,setLimitData:Z,setError:ee,setActionApprovalToken:te,setIsSwitchedToChat:se}=m(),{documents:ne,websiteLink:ie,isUploading:oe,onWebsiteUpload:re,setDocuments:ae,setDocumentError:le}=f(),{scrollStartSession:de,scrollEndSession:ce,scrollToTarget:ue}=g({auto:!(null==L?void 0:L.enablechatresponses)}),{artifacts:pe,currentPopupType:me,setArtifacts:fe,setCurrentArtifact:ge}=v(),[ve,he]=l(!1),[be,je]=l(!1),ye=d(null),Oe=e=>{const t=w(e);return!!t&&(ee(""),Z(null),W(t.status),G(t.accessGroup),X(t.upgradeGroups),R(t.upgradeUrl),!0)},xe=c((()=>S.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))),[S])&&t(O,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:oe||F||ve,onClick:A},{children:(null==B?void 0:B["form.clear-form"])||(null==B?void 0:B["clear-form"])||"Clear form"}));return s("div",Object.assign({className:I?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:J?"rtl":"ltr"},{children:[I&&t(o,{}),s("div",Object.assign({className:I?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!I&&t(o,{}),I&&k&&t("div",Object.assign({className:"me-auto shrink-0"},{children:k})),I&&xe,t(O,Object.assign({className:"px-5 min-h-[42px]",isDisabled:oe||F||ve,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,t,s,i,o;try{if(F||oe||ve)return;ee(""),le(""),Z(null),Y(null);for(const t of S){const s=n(t);if(s)throw null==C||C(t.id),new Error(null!==(e=null==B?void 0:B[s])&&void 0!==e?e:"response-too-long"===s?"One or more of your responses is too long!":"You must fill out all required fields.")}const l=ne.filter((e=>"finished"===e.status)),d=ne.map((e=>e.name)),c=null!==(s=null===(t=null==L?void 0:L.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s,u=S.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),p=h(ie).filter((e=>!d.includes(e)));if(p.length){const e=p[p.length-1];he(!0);const t=yield re(e);t&&(l.push(t),yield new Promise((e=>setTimeout(e,5e3)))),he(!1)}else if(u&&c&&!l.length)return null==C||C("userinput:documentupload"),void le((null==B?void 0:B["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const m=l.map((e=>e.documentId||"")).filter(Boolean),f=c&&m.length>0,g={};S.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?l.map((e=>e.name)).join(",")||"":e.input})),je(!1),H("fetching"),de(),ue();const v=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:$||void 0,origin:N,pickaxeId:P,senderType:T,valueObj:g},f&&{documentIds:m}),_&&{sender:_}),Q&&{studioSessionToken:Q}),!Q&&!_&&{sender:b()}),U&&{portalId:U}),D&&{deploymentId:D}))}),y=yield v.json();if(!y.success){const e=new Error(y.error||y.message||(null==B?void 0:B["failed-to-start-generation"])||"Failed to start generation");if(y.limitData)throw e.limitData=y.limitData,e;if(Oe(y))return;throw e}if(!y.submissionId||!y.sessionId)throw new Error((null==B?void 0:B["failed-to-start-generation"])||"Failed to start generation");te(null!==(i=y.actionApprovalToken)&&void 0!==i?i:null);const O=y.submissionId,x=y.sessionId,w={sessionId:x,documentIds:f?m:[],question:{inputs:S.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};Y(w),(null==L?void 0:L.enablechatresponses)&&(V(x),K(!1),se(!0),z([{id:0,role:"assistant",parts:[],documentIds:[]}])),f&&ae([]),H("streaming"),ye.current=new AbortController;const k=[];let I=[...null!=pe?pe:[]],A=0,E=!1,q="";for(;!E;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${O}?index=${A}`,{signal:null===(o=ye.current)||void 0===o?void 0:o.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=j({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&A++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Z(t.limitData),ee(""),void(E=!0);const s=t.error||t.message||(null==B?void 0:B["something-went-wrong"])||"Something went wrong.";return Oe(t)||ee(s),void(E=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void je(!0);if("text-start"===n.type)q="",k.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)q+=n.delta,r(k,"text",q);else if("text-end"===n.type)q="";else if("reasoning-start"===n.type)q="",k.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)q+=n.delta,r(k,"reasoning",q);else if("reasoning-end"===n.type)q="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?a(k,e.data):k.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},w),{question:Object.assign(Object.assign({},w.question),{responseParts:[...k]})});Y(i),(null==L?void 0:L.enablechatresponses)&&z([{id:0,role:"assistant",parts:[...k],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);I=I.filter((e=>!(e.id===t.id&&e.version===t.version))),I.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),fe([...I]),me.startsWith("inline")||ge({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");I=I.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),fe([...I])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);fe(I.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else E=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}E||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(E=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==M||M(x)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Z(e.limitData),ee(""),void ue();let t=x(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==B?void 0:B["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Oe(t)||ee(t),ue()}finally{H("idle"),he(!1),ce()}}))},{children:ve?(null==B?void 0:B.processing)||"Processing...":oe?(null==B?void 0:B.uploading)||"Uploading...":F&&!be?(null==B?void 0:B.loading)||"Loading...":null!==(E=null==L?void 0:L.submittext)&&void 0!==E?E:"Submit"})),!I&&xe]})),!q.isWhiteLabel&&t(y,{containerClassName:"justify-end"})]}))};export{k as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as n}from"react";import{ArtifactProvider as a}from"./Addons/Artifact/Provider.js";import s from"./DimensionProvider.js";import r from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=i({}),p=({children:i,origin:p,sender:u,senderType:m,deploymentId:g,portalId:f,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:k={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:C,artifact:I={popupType:"auto"},responsiveBy:P="viewport",locale:F="en",opacity:x=1,forceMobile:A=!1,disableHtml:T=!1,disableJs:D=!1,disableCss:U=!1,loadFont:q=!0,isRtl:R=!1,isEmbed:O=!1,mcpEnabled:j=!1,studioSessionToken:E,isDropShadow:M=!1,allowGuestUsage:L=!0,persistActiveConversation:G=!1,preventInitialSessionId:H=!1,onUpgrade:W,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=o(""),[X,J]=o(""),[_,z]=o(""),[Q,K]=o(""),[Z,$]=o(u),[ee,te]=o(null),[ie,oe]=o(m),[ne,ae]=o("loading"),[se,re]=o([]),[le,de]=o(null),[ce,pe]=o(null),[ue,me]=o(null),[ge,fe]=o(null),[he,ye]=o("");n((()=>ye("")),[X]);const[ve,be]=o(!1),[we,ke]=o(!0),[Se,Ce]=o(!0),[Ie,Pe]=o(!1);return n((()=>{be(!1)}),[null==b?void 0:b.font]),n((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!ve&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield import("webfontloader")).default.load({google:{families:[b.font]},active:()=>{be(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),be(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),be(!0)}}))}),[q,ve,null==b?void 0:b.font]),n((()=>{$(u)}),[u]),t(c.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:V,pickaxeId:X,sessionId:_,lastSessionId:Q,sender:Z,senderType:ie,portalId:f,deploymentId:g,deploymentType:h,validationStatus:ne,validationUpgradeGroups:se,validationUpgradeUrl:le,deploymentDimensions:y,deploymentMisc:v,accessGroup:ee,pickaxe:ge,selectedModel:he,setSelectedModel:ye,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:S,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},C),artifact:I,responsiveBy:P,locale:F,opacity:x,forceMobile:A,loadFont:q,disableHtml:T,disableJs:D,disableCss:U,isFontLoaded:ve,isNewChat:we,isShowIceBreaker:Se,isShowFeedbackMessage:Ie,isRtl:R,isEmbed:O,mcpEnabled:j,isDropShadow:M,allowGuestUsage:L,persistActiveConversation:G,clientSecret:ue,stripeAccountId:ce,preventInitialSessionId:H,setClientSecret:me,setStripeAccountId:pe,setContextId:Y,setValidationStatus:ae,setValidationUpgradeGroups:re,setValidationUpgradeUrl:de,setPickaxeId:J,setSessionId:e=>{z((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:K,setSender:$,setSenderType:oe,setAccessGroup:te,setPickaxe:fe,setIsFontLoaded:be,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Pe},W&&{onUpgrade:W}),B&&{onGenerateComplete:B})},{children:t(d,Object.assign({initialToken:E},{children:t(s,{children:t(r,Object.assign({limits:k},{children:t(l,{children:t(a,Object.assign({},I,{children:i}))})}))})}))}))};export{c as PickaxeContext,p as PickaxeProvider};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as n}from"react";import{ArtifactProvider as a}from"./Addons/Artifact/Provider.js";import s from"./DimensionProvider.js";import r from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=i({}),p=({children:i,origin:p,sender:u,senderType:m,deploymentId:g,portalId:f,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:k={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:C,artifact:I={popupType:"auto"},responsiveBy:P="viewport",locale:F="en",opacity:A=1,forceMobile:x=!1,disableHtml:T=!1,disableJs:D=!1,disableCss:U=!1,loadFont:q=!0,isRtl:R=!1,isEmbed:O=!1,mcpEnabled:M=!1,studioSessionToken:j,isDropShadow:E=!1,allowGuestUsage:L=!0,persistActiveConversation:G=!1,preventInitialSessionId:H=!1,onUpgrade:W,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=o(""),[X,J]=o(""),[_,z]=o(""),[Q,K]=o(""),[Z,$]=o(u),[ee,te]=o(null),[ie,oe]=o(m),[ne,ae]=o("loading"),[se,re]=o([]),[le,de]=o(null),[ce,pe]=o(null),[ue,me]=o(null),[ge,fe]=o(null),[he,ye]=o("");n((()=>ye("")),[X]);const[ve,be]=o(!1),[we,ke]=o(!0),[Se,Ce]=o(!0),[Ie,Pe]=o(!1);return n((()=>{be(!1)}),[null==b?void 0:b.font]),n((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!ve&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield import("webfontloader")).default.load({google:{families:[b.font]},active:()=>{be(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),be(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),be(!0)}}))}),[q,ve,null==b?void 0:b.font]),n((()=>{$(u)}),[u]),t(c.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:V,pickaxeId:X,sessionId:_,lastSessionId:Q,sender:Z,senderType:ie,portalId:f,deploymentId:g,deploymentType:h,validationStatus:ne,validationUpgradeGroups:se,validationUpgradeUrl:le,deploymentDimensions:y,deploymentMisc:v,accessGroup:ee,pickaxe:ge,selectedModel:he,setSelectedModel:ye,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:S,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},C),artifact:I,responsiveBy:P,locale:F,opacity:A,forceMobile:x,loadFont:q,disableHtml:T,disableJs:D,disableCss:U,isFontLoaded:ve,isNewChat:we,isShowIceBreaker:Se,isShowFeedbackMessage:Ie,isRtl:R,isEmbed:O,mcpEnabled:M,isDropShadow:E,allowGuestUsage:L,persistActiveConversation:G,clientSecret:ue,stripeAccountId:ce,preventInitialSessionId:H,setClientSecret:me,setStripeAccountId:pe,setContextId:Y,setValidationStatus:ae,setValidationUpgradeGroups:re,setValidationUpgradeUrl:de,setPickaxeId:J,setSessionId:e=>{z((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:K,setSender:$,setSenderType:oe,setAccessGroup:te,setPickaxe:fe,setIsFontLoaded:be,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Pe},W&&{onUpgrade:W}),B&&{onGenerateComplete:B})},{children:t(d,Object.assign({initialToken:j},{children:t(s,{children:t(r,Object.assign({limits:k},{children:t(l,{children:t(a,Object.assign({},I,{children:i}))})}))})}))}))};export{c as PickaxeContext,p as PickaxeProvider};
@@ -54,7 +54,7 @@ type PickaxeHistoryStreamPartDelta = {
54
54
  delta: string;
55
55
  };
56
56
  type PickaxeHistoryStreamFinish = {
57
- type: "finish-step";
57
+ type: "finish" | "finish-step";
58
58
  };
59
59
  export type PickaxeHistoryStreamDataActionToolCaption = {
60
60
  type: "data-action-tool-caption";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.21.1",
3
+ "version": "6.22.0",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",