@pickaxeproject/react 6.3.1 → 6.3.3
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.
- package/dist/cjs/components/EmbedPreview/FAB.js +1 -1
- package/dist/cjs/components/EmbedPreview/Popup.js +1 -1
- package/dist/cjs/components/Icons/arrow-down.svg.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/common/SmitheryConnectView.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
- package/dist/esm/components/EmbedPreview/FAB.js +1 -1
- package/dist/esm/components/EmbedPreview/Popup.js +1 -1
- package/dist/esm/components/Icons/arrow-down.svg.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/index.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/common/SmitheryConnectView.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var T,E,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=o(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&te&&Z&&ie,ye=K&&!R&&!be&&xe&&me>767,ke=K&&!R&&(be||me<=767),we=()=>{X(W),Q("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||ae(!0)}},{children:ee?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(T=he.data)||void 0===T?void 0:T.messages)&&void 0!==E?E:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
|
|
1
|
+
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var T,E,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=o(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&te&&Z&&ie,ye=K&&!R&&!be&&xe&&me>767,ke=K&&!R&&(be||me<=767),we=()=>{X(W),Q("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||ae(!0)}},{children:ee?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:[(null==U?void 0:U["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==U?void 0:U["contact-us"])||"contact us"}))," ",(null==U?void 0:U["for-help"])||"for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(T=he.data)||void 0===T?void 0:T.messages)&&void 0!==E?E:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as n,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as v}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as y}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as w}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as k,allowedImageMimeTypes as N,additionalAllowedFileExtensions as S}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import _ from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import A from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import R from"../../../common/error.js";import{getValidationFailure as L}from"../../../common/validation.js";import U from"../../../common/cn.js";import{isInIframe as $,initializeEmbedUserId as B}from"../../../common/utils.js";import{useStudio as V}from"../../../hooks/studio/useStudio.js";import{useSpeech as X}from"../../../hooks/pickaxe/useSpeech.js";const K=i((({resubmitPrompt:i,onFocus:K,onBlur:W,onInputHeightChange:F,initSmitheryAuthData:H},J)=>{var M,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:se,deploymentType:ne,pickaxe:oe,styles:ie,colors:re,locale:ae,forceMobile:le,isNewChat:ce,isRtl:de,isShowFeedbackMessage:ue,accessGroup:pe,setIsNewChat:me,setIsShowIceBreaker:fe,setValidationStatus:he,setValidationUpgradeGroups:ge,setValidationUpgradeUrl:ve,onGenerateComplete:be}=p(),{token:ye,isLoggedOut:xe,isSent:je,isPricingAuth:Oe}=b(),{messages:we,isGenerating:ke,setMessages:Ne,setStatus:Se,setLimitData:Ce,setError:Ie}=m(),{documents:Ee,isUploading:_e,documentError:Te,onFileUpload:Ae,setDocuments:Pe,setDocumentError:De}=y(),{studio:Re}=V(),{scrollStartSession:Le,scrollEndSession:Ue,scrollToBottom:$e}=x({auto:!0}),{artifacts:Be,currentPopupType:Ve,setArtifacts:Xe,setCurrentArtifact:Ke}=j(),{height:We}=v(),Fe=g(),[He,Je]=r(""),[Me,ze]=r(!1),[Ge,qe]=r(!1),[Qe,Ye]=r(null),[Ze,et]=r(null),[tt,st]=r(!1),nt=a(null),ot=a(""),it=a(null),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=Math.max(.4*We,100),{speechTranscript:ut,isSpeechListening:pt,isSpeechProcessing:mt,isSpeechSupported:ft,onStartListening:ht,onStopListening:gt}=X(),[vt]=w("(max-width: 480px)"),bt=O(),{isHover:yt}=bt,xt=e(bt,["isHover"]),jt=O(),{isHover:Ot}=jt,wt=e(jt,["isHover"]),kt=O(),{isHover:Nt}=kt,St=e(kt,["isHover"]),Ct=h(),It=f(),Et="undefined"!=typeof window?window.location.hostname:"",_t="undefined"!=typeof window?window.location.href:"",Tt="undefined"!=typeof window&&window.self!==window.top,At=Et.includes("pickaxe.co")&&!_t.includes("https://studio.pickaxe.co/_embed")&&!Tt,Pt=null===(M=null==oe?void 0:oe.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),Dt=ft&&(null==oe?void 0:oe.enablevoicetotext),Rt="chat-input"===ne&&ce&&!je,Lt="chat-input"===ne&&Oe&&xe&&je,Ut=l((e=>{const t=L(e);return!!t&&(Ie(""),Ce(null),he(t.status),ge(t.upgradeGroups),ve(t.upgradeUrl),!0)}),[Ie,Ce,he,ge,ve]),$t=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:de?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Bt=Me||Ge,Vt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==oe?void 0:oe.studioid},Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}))},(!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}})),At&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ye(t.studioUser),et(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,ye,te,se,At]);c((()=>{Vt()}),[Vt]);const Xt=(null==pe?void 0:pe.limit)||0,Kt=(null==Qe?void 0:Qe.currentUses)||0,Wt=(null==Qe?void 0:Qe.extraUses)||0,Ft=!!(null==Re?void 0:Re.data.usage)&&Re.data.usage.isCredits,Ht=Xt>Kt?Xt-Kt+Wt:Wt,Jt=d((()=>!!Qe&&(!tt&&(!(Xt<=0)&&Ht<=.05*Xt))),[Qe,tt,Ht,Xt]),Mt=d((()=>{var e,t,s;return!!ce&&(!!oe&&(!Fe.isLoading&&(!((null!==(t=null===(e=Fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=oe.icebreakers)||void 0===s?void 0:s.length)&&(!ue&&!Rt)))))}),[oe,ce,ue,Rt,Fe.data,Fe.isLoading]),zt=d((()=>{if(ke||_e)return!1;const e=Ee.length>0&&Ee.every((e=>"finished"===e.status));return!(!He.trim()&&!e)&&Ee.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ke,_e,He,Ee]);u(J,(()=>({onSubmit:Gt}))),c((()=>{fe(Mt)}),[Mt]),c((()=>{var e;if(i){const t=Array.from(we),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Gt(s,!0)}}),[i]),c((()=>{if(!lt.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(lt.current),()=>{e.disconnect()}}),[F]),c((()=>{if(!pt)return;const e=ot.current?`${ot.current} `:"";Je(`${e}${ut}`)}),[ut,pt]),c((()=>{if(!rt.current)return;(()=>{if(!rt.current)return;let e=rt.current.scrollHeight>52;He.includes("\n")||Ee.length?e=!0:He.trim()||(e=!1),ze(e)})()}),[He,Ee]),c((()=>{const e=rt.current,t=at.current;if(!e||!t||Me||He.includes("\n"))return void qe(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=He||$t,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;qe(i>l)}),[He,Me,$t]);const Gt=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n,o;try{if(ke||_e)return;const i=Ee.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:He;if(!c&&!l)return;Ie(""),De(""),Ce(null),Je(""),me(!1),Se("fetching"),Le(),$e();const d=null!==(n=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(we.slice(0,we.length-1)):Array.from(we),...s?[]:[{id:we.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:we.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Ne(u),$e(),d&&Pe([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}),te&&{portalId:te}),se&&{deploymentId:se}),a.length>0&&{uploadedModelImages:a})),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()})},At&&{credentials:"include"})),m=yield p.json();if(!m.success){if(Ut(m))return;const e=new Error(m.error||m.message||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Se("streaming"),ct.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Be?Be:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=ct.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();it.current=t;const s=new TextDecoder,n=C({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ut(t)||Ie(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&H){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){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 y=!0,H({smitheryId: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 y=!0,H({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)x="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("text-end"===n.type)x="";else if("reasoning-start"===n.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("reasoning-end"===n.type)x="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Ne([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:we.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe([...v]),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Xe(v),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe(v),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Xe(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Xe(v.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),s=t.error||t.message||"Something went wrong, please try again.";if(Ut(t))return void(y=!0);Ie(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==be||be(Y)}catch(e){if(e.limitData)Ce(e.limitData),Ie("");else{let t=R(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ut(t)||Ie(t)}}finally{$e(),Se("idle"),Ue(),it.current=null,yield Vt()}}));return Lt?null:s("div",Object.assign({className:U("flex w-full flex-shrink-0 flex-col items-center",!Rt&&"px-4 pb-8"),dir:de?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:lt,className:U("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},It),{maxHeight:`${dt}px`,overflowY:"auto"})},{children:[Jt&&n("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:It.backgroundColor?`${It.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[s("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:n("span",{children:[Ht," ",Ft?"credits":"uses"," remaining"]})})),n("div",Object.assign({className:"flex items-center gap-3"},{children:[s("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:re.accent,color:re.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Ze}${null==pe?void 0:pe.accessGroupId}`;$()?window.open(t):location.href=t}},{children:"Upgrade"})),s("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>st(!0)},{children:s("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:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!ke&&Ee.length>0&&s(A,{className:"p-4 pb-0",isDisabled:ke}),n("div",Object.assign({className:"relative flex w-full flex-col"},{children:[pt&&n("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(G=re.accent)&&void 0!==G?G:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:"Listening..."}))]})),s(P,Object.assign({ref:rt,className:U(Ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!He.trim()&&!He.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",de?"text-right":"text-left",Bt&&"mb-12",pt&&"text-transparent"),value:He,placeholder:$t,onChange:e=>{if(Je(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let s=0;t>1&&(s=50),F(24*(t-1)+s)}},onKeyDown:e=>{le||vt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),_e||ke||Gt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),me(!1),yield Ae(t))}))},K&&{onFocus:K},W&&{onBlur:W},{dir:de?"rtl":"ltr"})),s("div",Object.assign({ref:at,className:U("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Bt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Bt&&It.backgroundColor&&{backgroundColor:It.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:ke?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ct.current&&(ct.current.abort(),ct.current=null),it.current&&(it.current.cancel(),it.current=null),Se("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):pt?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:gt,style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[Pt&&n("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ot?re.accent+"10":void 0,color:Ot?re.accent:re.accent+"80"},disabled:_e||ke,onClick:()=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.click()}},wt,{children:[s("input",{id:"file-upload",ref:nt,type:"file",accept:[...k,...N,...S].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){me(!1),yield Ae(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),Dt&&s("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:pt?re.accent:Nt?re.accent+"10":void 0,color:pt?re.accentText:Nt?re.accent:re.accent+"80"},disabled:_e||ke||mt,onClick:()=>{pt?gt():(ot.current=He,ht(ae||"en-US"))}},St,{children:s(_,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:yt||zt?re.accent:re.accent+"10",color:yt||zt?re.accentText:re.accent+"80"},disabled:!zt,onClick:()=>Gt()},xt,{children:s(E,{className:U("h-6 w-6 shrink-0",de&&"scale-x-[-1] transform")})}))]})}))]}))]})),Te&&s(D,{error:Te,className:"mt-3"})]}))}))}));K.displayName="Input";export{K as default};
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as n,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as h}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as v}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as y}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as O}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as k,allowedImageMimeTypes as N,additionalAllowedFileExtensions as S}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import _ from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import A from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import R from"../../../common/error.js";import{getValidationFailure as L}from"../../../common/validation.js";import U from"../../../common/cn.js";import{isInIframe as $,initializeEmbedUserId as B}from"../../../common/utils.js";import{useStudio as V}from"../../../hooks/studio/useStudio.js";import{useSpeech as X}from"../../../hooks/pickaxe/useSpeech.js";const K=i((({resubmitPrompt:i,onFocus:K,onBlur:W,onInputHeightChange:F,initSmitheryAuthData:H},J)=>{var M,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:se,deploymentType:ne,pickaxe:oe,styles:ie,colors:re,translations:ae,locale:le,forceMobile:ce,isNewChat:de,isRtl:ue,isShowFeedbackMessage:pe,accessGroup:me,setIsNewChat:fe,setIsShowIceBreaker:ge,setValidationStatus:he,setValidationUpgradeGroups:ve,setValidationUpgradeUrl:be,onGenerateComplete:ye}=p(),{token:xe,isLoggedOut:je,isSent:we,isPricingAuth:Oe}=b(),{messages:ke,isGenerating:Ne,setMessages:Se,setStatus:Ce,setLimitData:Ie,setError:Ee}=m(),{documents:_e,isUploading:Te,documentError:Ae,onFileUpload:Pe,setDocuments:De,setDocumentError:Re}=y(),{studio:Le}=V(),{scrollStartSession:Ue,scrollEndSession:$e,scrollToBottom:Be}=x({auto:!0}),{artifacts:Ve,currentPopupType:Xe,setArtifacts:Ke,setCurrentArtifact:We}=j(),{height:Fe}=v(),He=h(),[Je,Me]=r(""),[ze,Ge]=r(!1),[qe,Qe]=r(!1),[Ye,Ze]=r(null),[et,tt]=r(null),[st,nt]=r(!1),ot=a(null),it=a(""),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=a(null),ut=Math.max(.4*Fe,100),{speechTranscript:pt,isSpeechListening:mt,isSpeechProcessing:ft,isSpeechSupported:gt,onStartListening:ht,onStopListening:vt}=X(),[bt]=O("(max-width: 480px)"),yt=w(),{isHover:xt}=yt,jt=e(yt,["isHover"]),wt=w(),{isHover:Ot}=wt,kt=e(wt,["isHover"]),Nt=w(),{isHover:St}=Nt,Ct=e(Nt,["isHover"]),It=g(),Et=f(),_t="undefined"!=typeof window?window.location.hostname:"",Tt="undefined"!=typeof window?window.location.href:"",At="undefined"!=typeof window&&window.self!==window.top,Pt=_t.includes("pickaxe.co")&&!Tt.includes("https://studio.pickaxe.co/_embed")&&!At,Dt=null===(M=null==oe?void 0:oe.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),Rt=gt&&(null==oe?void 0:oe.enablevoicetotext),Lt="chat-input"===ne&&de&&!we,Ut="chat-input"===ne&&Oe&&je&&we,$t=l((e=>{const t=L(e);return!!t&&(Ee(""),Ie(null),he(t.status),ve(t.upgradeGroups),be(t.upgradeUrl),!0)}),[Ee,Ie,he,ve,be]),Bt=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:ue?"بماذا تريد أن تتحدث؟":(null==ae?void 0:ae["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Vt=ze||qe,Xt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==oe?void 0:oe.studioid},Z&&{sender:Z}),xe&&{studioSessionToken:xe}),!xe&&!Z&&{sender:B()}))},(!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}})),Pt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ze(t.studioUser),tt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,xe,te,se,Pt]);c((()=>{Xt()}),[Xt]);const Kt=(null==me?void 0:me.limit)||0,Wt=(null==Ye?void 0:Ye.currentUses)||0,Ft=(null==Ye?void 0:Ye.extraUses)||0,Ht=!!(null==Le?void 0:Le.data.usage)&&Le.data.usage.isCredits,Jt=Kt>Wt?Kt-Wt+Ft:Ft,Mt=d((()=>!!Ye&&(!st&&(!(Kt<=0)&&Jt<=.05*Kt))),[Ye,st,Jt,Kt]),zt=d((()=>{var e,t,s;return!!de&&(!!oe&&(!He.isLoading&&(!((null!==(t=null===(e=He.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=oe.icebreakers)||void 0===s?void 0:s.length)&&(!pe&&!Lt)))))}),[oe,de,pe,Lt,He.data,He.isLoading]),Gt=d((()=>{if(Ne||Te)return!1;const e=_e.length>0&&_e.every((e=>"finished"===e.status));return!(!Je.trim()&&!e)&&_e.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ne,Te,Je,_e]);u(J,(()=>({onSubmit:qt}))),c((()=>{ge(zt)}),[zt]),c((()=>{var e;if(i){const t=Array.from(ke),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;qt(s,!0)}}),[i]),c((()=>{if(!ct.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(ct.current),()=>{e.disconnect()}}),[F]),c((()=>{if(!mt)return;const e=it.current?`${it.current} `:"";Me(`${e}${pt}`)}),[pt,mt]),c((()=>{if(!at.current)return;(()=>{if(!at.current)return;let e=at.current.scrollHeight>52;Je.includes("\n")||_e.length?e=!0:Je.trim()||(e=!1),Ge(e)})()}),[Je,_e]),c((()=>{const e=at.current,t=lt.current;if(!e||!t||ze||Je.includes("\n"))return void Qe(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Je||Bt,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Qe(i>l)}),[Je,ze,Bt]);const qt=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n,o;try{if(Ne||Te)return;const i=_e.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:Je;if(!c&&!l)return;Ee(""),Re(""),Ie(null),Me(""),fe(!1),Ce("fetching"),Ue(),Be();const d=null!==(n=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ke.slice(0,ke.length-1)):Array.from(ke),...s?[]:[{id:ke.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ke.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Se(u),Be(),d&&De([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),xe&&{studioSessionToken:xe}),!xe&&!Z&&{sender:B()}),te&&{portalId:te}),se&&{deploymentId:se}),a.length>0&&{uploadedModelImages:a})),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()})},Pt&&{credentials:"include"})),m=yield p.json();if(!m.success){if($t(m))return;const e=new Error(m.error||m.message||(null==ae?void 0:ae["failed-to-start-generation"])||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Ce("streaming"),dt.current=new AbortController;const g=u.length-1,h=[];let v=[...null!=Ve?Ve:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=dt.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();rt.current=t;const s=new TextDecoder,n=C({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||(null==ae?void 0:ae["something-went-wrong"])||"Something went wrong.";return $t(t)||Ee(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&H){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){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 y=!0,H({smitheryId: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 y=!0,H({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)x="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)x+=n.delta,h[h.length-1].content=x;else if("text-end"===n.type)x="";else if("reasoning-start"===n.type)x="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)x+=n.delta,h[h.length-1].content=x;else if("reasoning-end"===n.type)x="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Se([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:ke.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke([...v]),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ke(v),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke(v),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ke(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ke(v.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),s=t.error||t.message||(null==ae?void 0:ae["something-went-wrong-try-again"])||"Something went wrong, please try again.";if($t(t))return void(y=!0);Ee(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ye||ye(Y)}catch(e){if(e.limitData)Ie(e.limitData),Ee("");else{let t=R(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."),$t(t)||Ee(t)}}finally{Be(),Ce("idle"),$e(),rt.current=null,yield Xt()}}));return Ut?null:s("div",Object.assign({className:U("flex w-full flex-shrink-0 flex-col items-center",!Lt&&"px-4 pb-8"),dir:ue?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:ct,className:U("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Et),{maxHeight:`${ut}px`,overflowY:"auto"})},{children:[Mt&&n("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:Et.backgroundColor?`${Et.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[s("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:n("span",{children:[Jt," ",Ht?(null==ae?void 0:ae.credits)||"Credits":(null==ae?void 0:ae.uses)||"Uses"," ",(null==ae?void 0:ae.remaining)||"remaining"]})})),n("div",Object.assign({className:"flex items-center gap-3"},{children:[s("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:re.accent,color:re.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${et}${null==me?void 0:me.accessGroupId}`;$()?window.open(t):location.href=t}},{children:(null==ae?void 0:ae.upgrade)||"Upgrade"})),s("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>nt(!0)},{children:s("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:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!Ne&&_e.length>0&&s(A,{className:"p-4 pb-0",isDisabled:Ne}),n("div",Object.assign({className:"relative flex w-full flex-col"},{children:[mt&&n("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(G=re.accent)&&void 0!==G?G:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:(null==ae?void 0:ae.listening)||"Listening..."}))]})),s(P,Object.assign({ref:at,className:U(It.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Je.trim()&&!Je.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ue?"text-right":"text-left",Vt&&"mb-12",mt&&"text-transparent"),value:Je,placeholder:Bt,onChange:e=>{Me(e)},onKeyDown:e=>{ce||bt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Te||Ne||qt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),fe(!1),yield Pe(t))}))},K&&{onFocus:K},W&&{onBlur:W},{dir:ue?"rtl":"ltr"})),s("div",Object.assign({ref:lt,className:U("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Vt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Vt&&Et.backgroundColor&&{backgroundColor:Et.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:Ne?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{dt.current&&(dt.current.abort(),dt.current=null),rt.current&&(rt.current.cancel(),rt.current=null),Ce("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):mt?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:vt,style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[Dt&&n("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ot?re.accent+"10":void 0,color:Ot?re.accent:re.accent+"80"},disabled:Te||Ne,onClick:()=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.click()}},kt,{children:[s("input",{id:"file-upload",ref:ot,type:"file",accept:[...k,...N,...S].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){fe(!1),yield Pe(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),Rt&&s("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:mt?re.accent:St?re.accent+"10":void 0,color:mt?re.accentText:St?re.accent:re.accent+"80"},disabled:Te||Ne||ft,onClick:()=>{mt?vt():(it.current=Je,ht(le||"en-US"))}},Ct,{children:s(_,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:xt||Gt?re.accent:re.accent+"10",color:xt||Gt?re.accentText:re.accent+"80"},disabled:!Gt,onClick:()=>qt()},jt,{children:s(E,{className:U("h-6 w-6 shrink-0",ue&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ae&&s(D,{error:Ae,className:"mt-3"})]}))}))}));K.displayName="Input";export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as n}from"react/jsx-runtime";import{useState as r,useRef as i,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useScrollContext as u}from"../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import f from"./History/index.js";import h from"./Input.js";import v from"../../Icons/attach-vertical.svg.js";import g from"../../Icons/arrow-down.svg.js";import b from"../../../common/cn.js";import x from"../../../common/api/pickaxe.js";import{v4 as k}from"uuid";import{StudioTip as y}from"../../Core/StudioTip.js";import{useResponseContext as j}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as w,EditableNavPill as I,HistoryPill as D}from"../Addons/Navbar/NavPill.js";import C from"../../Icons/history.svg.js";const N=()=>{const{deploymentType:N,isNewChat:T,setIsNewChat:S,sessionId:A,setSessionId:H,setLastSessionId:O,pickaxeId:F,sender:E,pickaxe:P,styles:_,colors:z,isEmbed:L,translations:R}=l(),{isSent:G}=c(),{width:B,height:M,setDimension:U}=d(),{setDocuments:$,onFileUpload:q}=m(),{scrollContainerRef:J,isLocked:K,setIsLocked:Q}=u(),{isGenerating:V,messages:W}=j(),X=p(),[Y,Z]=r(0),[ee,te]=r(!1),[oe,ne]=r(!1),[re,ie]=r(!1),[se,ae]=r(!0),le=i(null),ce=i(null),de=i(0),[me,ue]=r(null),[pe,fe]=r(!1),he=(null==R?void 0:R["new-chat"])||"New chat",ve="chat-input"===N&&T&&!G;s((()=>()=>{$([])}),[]);const ge=a((()=>{if(!F||!E)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield x.post("/get_pickaxe_conversation",{sessionId:A,userId:E});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void xe(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[F,E,A]);s((()=>{V||T||!A||ge()}),[V,T,A,ge]),s((()=>{if(!le.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;U(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(le.current),()=>{e.disconnect()}}),[U]);const[be,xe]=r(he),ke=(null==P?void 0:P.formtitle)||"Pickaxe",ye=(null==P?void 0:P.coverphoto)||void 0,[je,we]=r(!1);s((()=>{const e=!ve&&!L&&_.portalTheme&&(W.filter((e=>"user"===e.role)).length>0||ee||!T);we(null!=e&&e)}),[ve,L,ee,T,W,_.portalTheme]),s((()=>{const e=J.current;if(!e)return;const t=()=>{const t=e.scrollHeight-e.scrollTop-e.clientHeight;ie(e.scrollHeight>e.clientHeight+8),ae(t<=24)};t(),e.addEventListener("scroll",t,{passive:!0});const o=new ResizeObserver((()=>{t()}));o.observe(e);const n=e.firstElementChild;return n instanceof HTMLElement&&o.observe(n),()=>{e.removeEventListener("scroll",t),o.disconnect()}}),[ve,J]);const Ie=a((()=>{J.current&&(Q(!0),J.current.scrollTo({top:J.current.scrollHeight,behavior:"smooth"}))}),[J,Q]);return t("div",Object.assign({ref:le,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),de.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&ne(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),de.current-=1,0===de.current&&ne(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),ne(!1),de.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(S(!1),yield q(e))}))},{children:[oe&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(v,{className:"h-10 w-10"})})),o("h3",Object.assign({className:b(X.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==R?void 0:R["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:b(X.b2,"mt-2 opacity-60 text-black")},{children:(null==R?void 0:R["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),ve?o(h,{}):t(n,{children:[je&&t("div",Object.assign({className:b("direct-link"===N?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[o(w,{text:ke,icon:ye}),T||be===he?o(w,{text:be}):o(I,{text:be,sessionId:A,onRename:t=>e(void 0,void 0,void 0,(function*(){if(A)try{yield x.post("/edit_conversation_name",{sessionId:A,name:t,userId:E}),xe(t)}catch(e){console.error("Error renaming chat:",e),alert((null==R?void 0:R["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(A&&window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield x.post("/delete_pickaxe_conversation",{sessionId:A,userId:E}),S(!0),H(k()),xe(he)}catch(e){console.error("Error deleting chat:",e),alert((null==R?void 0:R["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),o(y,Object.assign({content:R["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(D,{icon:o(C,{}),onClick:()=>{H(""),O(A)}})}))]})),o(f,{additionalScrollHeight:Y,isForceHideInfo:M<=545||B<=350||ee,isInputFocused:ee,onSubmit:t=>e(void 0,void 0,void 0,(function*(){ce.current&&ce.current.onSubmit(t)})),smitheryAuthData:me,resubmitPrompt:()=>{ue(null),fe(!0)}}),o("button",Object.assign({type:"button","aria-label":(null==R?void 0:R["scroll-to-bottom"])||"Scroll to bottom",className:b("absolute left-1/2 z-30 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full shadow-md outline-none transition-all duration-200 ease-in-out",!re||K||se?"pointer-events-none translate-y-2 opacity-0":"opacity-100"),style:{bottom:`${Y+65}px`,backgroundColor:z.accent,color:z.accentText},onClick:Ie},{children:o(g,{className:"h-3 w-3 shrink-0"})})),o(h,{ref:ce,onFocus:()=>te(!0),onBlur:()=>te(!1),onInputHeightChange:Z,initSmitheryAuthData:e=>ue(e),resubmitPrompt:pe})]})]}))};export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as f}from"lucide-react";import g from"../../../Icons/trash-2.svg.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as f}from"lucide-react";import g from"../../../Icons/trash-2.svg.js";import v from"../../../Icons/chat.svg.js";import y from"../../../Icons/copy.svg.js";import x from"../../../Icons/copied.svg.js";import j from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as k}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as N}from"../../common/PickaxeMarkdown/Renderer.js";import C from"../../../../common/cn.js";const O=({item:O,onDelete:_})=>{const{pickaxe:I,sender:P,colors:M,translations:R,styles:D,isRtl:E,disableCss:T,disableHtml:q,disableJs:F,setSessionId:S,setIsNewChat:$}=l(),{setMessages:A}=c(),{setDocuments:H}=d(),[J,z]=n(!1),[L,B]=n(!1),[K,G]=n(!1),[Q,U]=n(!1),[V,W]=n(!1),X=a(null),[Y,Z]=n(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name"),[ee,se]=n("");i((()=>{Z(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name")}),[O.shortSummary,O.summary,R]),i((()=>{const e=e=>{X.current&&!X.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const te=r((()=>O?"FORM"===O.pickaxeType&&0===O.messages.length?O.question.responseParts?O.question.responseParts.length:0:O.messages.length:0),[O]),oe=r((()=>m(new Date(O.updatedAt),"MMM dd, yyy hh:mm a")),[O]),ne=r((()=>{var e;const s=(null==R?void 0:R["not-available"])||"n/a";if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=O.question.inputs)&&void 0!==e?e:[];return V?t.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=O.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[O,V,R]),ae=r((()=>{if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return O.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[O]),ie=()=>{B(!1),se("")},re=()=>e(void 0,void 0,void 0,(function*(){if(ee.trim()){G(!0);try{yield p.post("/edit_conversation_name",{sessionId:O.sessionId,name:ee,userId:P}),Z(ee),B(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==R?void 0:R["failed-update-name"])||"Failed to update name.")}finally{G(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:M.secondary,borderRadius:D.cornerRadius}},{children:[t("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:M.primary,color:M.text}},{children:L?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[t("input",{autoFocus:!0,type:"text",value:ee,onChange:e=>se(e.target.value),onKeyDown:e=>{"Enter"===e.key&&re(),"Escape"===e.key&&ie()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:M.primary,borderColor:M.secondary}}),t("button",Object.assign({onClick:re,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.save)||"Save"},{children:t(u,{className:"h-4 w-4"})})),t("button",Object.assign({onClick:ie,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.cancel)||"Cancel"},{children:t(h,{className:"h-4 w-4"})}))]})):s(o,{children:[t("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:Y})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),W(!V)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:V?(null==R?void 0:R.collapse)||"Collapse":(null==R?void 0:R.expand)||"Expand"},{children:t(V?w:j,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),z(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:t(b,{className:"h-6 w-6"})})),J&&s("div",Object.assign({ref:X,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:M.secondary,color:M.secondaryText,borderColor:M.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),se(Y),B(!0),z(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:M.primary}},{children:[t(f,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?")){z(!1);try{yield p.post("/delete_pickaxe_conversation",{sessionId:O.sessionId,userId:P}),_&&_(O.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==R?void 0:R["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[t(g,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:C("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",V?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:M.secondary,color:M.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[t("div",Object.assign({className:C("w-full",V?"mb-0":"mb-2")},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full",!V&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],V&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ne})}))})),t("div",Object.assign({className:"w-full"},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full text-sm",!V&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],V&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ae})}))}))]})),s("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==I?void 0:I.chatflag)||!(null==I?void 0:I.chatflag)&&(null==I?void 0:I.enablechatresponses))&&s("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=O.sessionId,H([]),A([]),$(!1),S(s)},title:(null==R?void 0:R["open-chat"])||"Open Chat"},{children:[t(v,{className:"h-4 w-4"}),t("span",Object.assign({className:"text-sm font-medium"},{children:te}))]})),t("button",Object.assign({className:"transition-colors "+(Q?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ae),U(!0),setTimeout((()=>{U(!1)}),2e3)},title:Q?(null==R?void 0:R.copied)||"Copied!":(null==R?void 0:R["copy-assistant-message"])||"Copy assistant message"},{children:Q?t(x,{className:"h-4 w-4",style:{color:M.accent},fill:M.accent}):t(y,{className:"h-4 w-4"})}))]})),t("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:oe}))]}))]}))]}))};export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as a}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as r}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{format as d}from"date-fns";import m from"../../common/PickaxeIcon.js";import p from"../../Addons/Scroll/ScrollLockView.js";import h from"../../common/PickaxeMessageParts/index.js";import f from"../../common/PickaxeMessageActions.js";import u from"../../../../common/cn.js";const x=()=>{var x;const{pickaxe:b,styles:g,colors:
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as a}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as r}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{format as d}from"date-fns";import m from"../../common/PickaxeIcon.js";import p from"../../Addons/Scroll/ScrollLockView.js";import h from"../../common/PickaxeMessageParts/index.js";import f from"../../common/PickaxeMessageActions.js";import u from"../../../../common/cn.js";const x=()=>{var x;const{pickaxe:b,styles:g,colors:v,misc:j,translations:y,disableHtml:k,disableJs:w,disableCss:N,isRtl:C,setSessionId:O,setIsNewChat:I}=t(),{response:A,isGenerating:S}=i(),{scrollTargetRef:D}=a(),{setDocuments:P}=l(),{onLoadArtifact:M}=r(),$=n(),R=o((()=>d(A?A.sentAt:new Date,"hh:mm a MMM dd, yy")),[A]),T=o((()=>{var e;if(!A)return"";const s=(null==y?void 0:y["not-available"])||"n/a";return(null!==(e=A.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||s}</p>\n</div>`)).join("")}),[A,y]);return A?e("div",Object.assign({ref:D,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[s("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:v.primary,color:v.text}},{children:e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${A.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:T.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:T}}),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:u($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:u($.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:v.secondary,color:v.secondaryText}},{children:[j.isChatImage&&s(m,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:v.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[s(c,Object.assign({theme:g.theme,colors:v},C&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},N&&{disableCss:!0},{disableReasoning:null!==(x=null==b?void 0:b.enablereasoningdisplay)&&void 0!==x&&x,onArtifactClick:M},{children:s(h,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:A.question.responseParts})})),s("div",Object.assign({className:"flex flex-col"},{children:S?s("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((e,o)=>s("div",{className:u("h-1.5 w-1.5 animate-dot rounded-full",1===o&&"animate-dot-down"),style:{backgroundColor:v.secondaryText}},o)))})):e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s("div",Object.assign({className:"flex items-center gap-3"},{children:s(f,{content:A.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:A.sessionId,messagesCount:A.messageCount+1,onOpenChat:()=>{return e=A.sessionId,P([]),I(!1),void O(e);var e},isReadOut:!1})})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:u($.b3,"font-semibold uppercase opacity-30")},{children:R}))}))]}))}))]}))]})),s(p,{})]})):null};export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as s,useMemo as i,useState as n}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import a from"../../../Icons/check.svg.js";import l from"./Dropdown.js";import d from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:m,isRtl:b,translations:f}=r(),{setError:h}=o(),g=c(),j=s(null),x=i((()=>p.example.split("S3P32X")),[p.example]),y=i((()=>p.input?p.input.split(","):[]),[p.input]),[O,v]=n((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""}));return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:b?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:d(g.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:m.error}},{children:"*"}))]})),t(l,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input.replace(/,/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((s,i)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{h("");const t=y.includes(e),s=p.input?p.input.split(","):[],i=new Set(s);t&&i.has(e)?i.delete(e):t||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(s)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(s)?m.accent:m.accent+"80"},y.includes(s)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(s)&&"opacity-100"),style:{color:m.accentText}})})),t("p",Object.assign({className:d(g.b2,"select-none")},{children:s}))]}),i))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{h("");const e=y.includes(O.trim()),t=p.input?p.input.split(","):[],s=Array.from(new Set(t)).filter((e=>""!==e.trim()&&x.includes(e)));e||s.push(O.trim()),u(Object.assign(Object.assign({},p),{input:s.join(",")})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(O)?m.accent:m.accent+"80"},y.includes(O)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(O)&&"opacity-100"),style:{color:m.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:d(g.b2,"select-none opacity-80 min-w-fit")},{children:[(null==f?void 0:f.other)||"Other",":"]})),t("input",{ref:j,type:"text",className:d(g.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y.includes(O)?m.accent:"rgba(0,0,0,0.2)"},value:O,onChange:e=>(e=>{h(""),v(e);const t=y.includes(e.trim()),s=p.input?p.input.split(","):[],i=new Set(s.filter((e=>x.includes(e))));t?i.delete(e.trim()):i.add(e.trim());const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(e.target.value),placeholder:"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as s,useMemo as i,useState as n}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import a from"../../../Icons/check.svg.js";import l from"./Dropdown.js";import d from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:m,isRtl:b,translations:f}=r(),{setError:h}=o(),g=c(),j=s(null),x=i((()=>p.example.split("S3P32X")),[p.example]),y=i((()=>p.input?p.input.split(","):[]),[p.input]),[O,v]=n((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""}));return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:b?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:d(g.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:m.error}},{children:"*"}))]})),t(l,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input.replace(/,/g,", "),placeholder:(null==f?void 0:f["select-options"])||"Select option(s)",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((s,i)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{h("");const t=y.includes(e),s=p.input?p.input.split(","):[],i=new Set(s);t&&i.has(e)?i.delete(e):t||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(s)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(s)?m.accent:m.accent+"80"},y.includes(s)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(s)&&"opacity-100"),style:{color:m.accentText}})})),t("p",Object.assign({className:d(g.b2,"select-none")},{children:s}))]}),i))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{h("");const e=y.includes(O.trim()),t=p.input?p.input.split(","):[],s=Array.from(new Set(t)).filter((e=>""!==e.trim()&&x.includes(e)));e||s.push(O.trim()),u(Object.assign(Object.assign({},p),{input:s.join(",")})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(O)?m.accent:m.accent+"80"},y.includes(O)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(O)&&"opacity-100"),style:{color:m.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:d(g.b2,"select-none opacity-80 min-w-fit")},{children:[(null==f?void 0:f.other)||"Other",":"]})),t("input",{ref:j,type:"text",className:d(g.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y.includes(O)?m.accent:"rgba(0,0,0,0.2)"},value:O,onChange:e=>(e=>{h(""),v(e);const t=y.includes(e.trim()),s=p.input?p.input.split(","):[],i=new Set(s.filter((e=>x.includes(e))));t?i.delete(e.trim()):i.add(e.trim());const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(e.target.value),placeholder:(null==f?void 0:f["type-your-answer"])||"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as r}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import{useSpeech as m}from"../../../../hooks/pickaxe/useSpeech.js";import u from"../../../Core/Textarea.js";import h from"../../../Icons/microphone.svg.js";import g from"../../../Icons/stop.svg.js";import f from"../../../../common/cn.js";const b=({field:b,update:
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as r}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import{useSpeech as m}from"../../../../hooks/pickaxe/useSpeech.js";import u from"../../../Core/Textarea.js";import h from"../../../Icons/microphone.svg.js";import g from"../../../Icons/stop.svg.js";import f from"../../../../common/cn.js";const b=({field:b,update:v,activeVoiceId:x,setActiveVoiceId:j})=>{var y;const{styles:k,colors:N,isRtl:O,pickaxe:w,locale:S,translations:C}=a(),{setError:L}=c(),[I,T]=n(!1),R=p(),z=l(),{speechTranscript:F,isSpeechListening:H,isSpeechProcessing:P,isSpeechSupported:$,onStartListening:B,onStopListening:D}=m(),V=i(""),_=d(),{isHover:q}=_,A=e(_,["isHover"]),E=$&&(null==w?void 0:w.enablevoicetotext),U=H&&x===b.id,Y=e=>{L("");const t=e.length;v(Object.assign(Object.assign({},b),{input:e,length:t}))};return r((()=>{if(!H||x!==b.id)return;const e=V.current?`${V.current} `:"";Y(`${e}${F}`)}),[F,H,x,b.id]),o("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:O?"rtl":"ltr"},{children:[o("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("div",Object.assign({className:"flex items-center gap-1"},{children:[s("p",Object.assign({className:f(R.b3,"font-semibold opacity-70")},{children:b.main})),b.isRequired&&s("span",Object.assign({className:"select-none font-semibold",style:{color:N.accent}},{children:"*"}))]})),o("div",Object.assign({className:"relative w-full"},{children:[U&&o("div",Object.assign({className:f("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",O?"right-4":"left-4")},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(y=N.accent)&&void 0!==y?y:"#ff0000"}}),s("span",Object.assign({className:"text-sm font-semilight",style:{color:N.text+"90"}},{children:(null==C?void 0:C.listening)||"Listening..."}))]})),s(u,{className:f(R.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",O?E?"pl-10 pr-4":"px-4":E?"pl-4 pr-10":"px-4",b.maxLength<10&&"max-w-[400px]","block"===k.formFieldStyle&&"shadow hover:shadow-none",U&&"caret-transparent"),style:Object.assign(Object.assign({},z),U&&{color:"transparent"}),placeholder:U?"":b.placeholder,rows:1,value:b.input,tabIndex:b.order,onChange:Y,onFocus:()=>T(!0),onBlur:()=>T(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const t=e.target;setTimeout((()=>{const e=t.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),E&&s("div",Object.assign({className:f("absolute top-2 z-20",O?"left-2":"right-2")},{children: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",style:{backgroundColor:U?N.accent:q?N.accent+"10":void 0,color:U?N.accentText:q?N.accent:N.accent+"80"},disabled:P,onClick:()=>t(void 0,void 0,void 0,(function*(){H?(yield D(),j(b.id)):(j(b.id),V.current=b.input||"",yield B(S||"en-US"),T(!0))}))},A,{type:"button"},{children:U?s(g,{className:"h-4 w-4 shrink-0"}):s(h,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),s("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:o("p",Object.assign({className:f(R.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",b.length>b.maxLength&&"text-c-red opacity-100",I&&"opacity-100")},{children:[b.length,"/",b.maxLength]}))}))]}))};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{usePickaxeContext as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as s}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useRef as o,useMemo as r,useState as a}from"react";import c from"./Dropdown.js";import l from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:d,isRtl:m,translations:b}=n(),{setError:g}=s(),h=i(),f=o(null),x=r((()=>p.example.split("S3P32X")),[p.example]),[j,O]=a((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""})),y=r((()=>!!p.allowOther&&(!x.includes(p.input)&&""!==p.input)),[p.allowOther,p.input,x]);return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:m?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:l(h.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:d.error}},{children:"*"}))]})),t(c,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input,placeholder:(null==b?void 0:b["select-an-option"])||"Select an option",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((n,s)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{g(""),u(Object.assign(Object.assign({},p),{input:e}))})(n)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:p.input===n?d.accent:d.accent+"80"},p.input===n&&{backgroundColor:d.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",p.input===n&&"opacity-100"),style:{backgroundColor:d.accentText}})})),t("p",Object.assign({className:l(h.b2,"select-none")},{children:n}))]}),s))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{g(""),u(Object.assign(Object.assign({},p),{input:j})),setTimeout((()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:y?d.accent:d.accent+"80"},y&&{backgroundColor:d.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",y&&"opacity-100"),style:{backgroundColor:d.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:l(h.b2,"select-none opacity-80 min-w-fit")},{children:[(null==b?void 0:b.other)||"Other",":"]})),t("input",{ref:f,type:"text",className:l(h.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y?d.accent:"rgba(0,0,0,0.2)"},value:j,onChange:e=>{return t=e.target.value,g(""),O(t),void u(Object.assign(Object.assign({},p),{input:t}));var t},onFocus:()=>{y||u(Object.assign(Object.assign({},p),{input:j}))},placeholder:(null==b?void 0:b["type-your-answer"])||"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as c}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as c}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as p,initializeEmbedUserId as m}from"../../../../common/utils.js";import{encode as g}from"@nem035/gpt-3-encoder";import{createParser as f}from"eventsource-parser";import h from"../../common/PickaxeBranding.js";import v from"../../common/PickaxeButton.js";import b from"../../../../common/error.js";import{getValidationFailure as y}from"../../../../common/validation.js";const j=({questions:j,resetQuestions:O})=>{var x;const{origin:w,pickaxeId:I,sender:S,senderType:k,portalId:C,deploymentId:N,pickaxe:E,misc:P,translations:_,isRtl:A,setSessionId:T,setIsNewChat:U,setValidationStatus:D,setValidationUpgradeGroups:L,setValidationUpgradeUrl:q,onGenerateComplete:J}=r(),{token:B}=a(),{isGenerating:K,setResponse:R,setMessages:V,setStatus:W,setLimitData:X,setError:G,setIsSwitchedToChat:$}=l(),{documents:F,websiteLink:M,isUploading:Q,onWebsiteUpload:Y,setDocuments:z,setDocumentError:H}=d(),{scrollStartSession:Z,scrollEndSession:ee,scrollToTarget:te}=c({auto:!(null==E?void 0:E.enablechatresponses)}),{artifacts:se,currentPopupType:ne,setArtifacts:ie,setCurrentArtifact:oe}=u(),[re,ae]=n(!1),le=i(null),de=e=>{const t=y(e);return!!t&&(G(""),X(null),D(t.status),L(t.upgradeGroups),q(t.upgradeUrl),!0)},ce=o((()=>j.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[j]);return t("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:A?"rtl":"ltr"},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s(v,Object.assign({className:"px-5 min-h-[42px]",isDisabled:Q||K||re,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,t,s;try{if(K||Q||re)return;G(""),H(""),X(null),R(null);const n=["Multiple Choice","Checkbox"];for(const e of j){if(g(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error((null==_?void 0:_["response-too-long"])||"One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error((null==_?void 0:_["required-fields-missing"])||"You must fill out all required fields.")}const i=F.filter((e=>"finished"===e.status)),o=F.map((e=>e.name)),r=null!==(t=null===(e=null==E?void 0:E.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=j.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=p(M).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];ae(!0);const t=yield Y(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),ae(!1)}else if(a&&r&&!i.length)return void H((null==_?void 0:_["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const d=i.map((e=>e.documentId||"")).filter(Boolean),c=r&&d.length>0,u={};j.forEach((e=>{u[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),W("fetching"),Z(),te();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/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({origin:w,pickaxeId:I,senderType:k,valueObj:u},c&&{documentIds:d}),S&&{sender:S}),B&&{studioSessionToken:B}),!B&&!S&&{sender:m()}),C&&{portalId:C}),N&&{deploymentId:N}))}),v=yield h.json();if(!v.success){if(de(v))return;const e=new Error(v.error||v.message||(null==_?void 0:_["failed-to-start-generation"])||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}if(!v.submissionId||!v.sessionId)throw new Error((null==_?void 0:_["failed-to-start-generation"])||"Failed to start generation");const b=v.submissionId,y=v.sessionId,O={sessionId:y,documentIds:c?d:[],question:{inputs:j.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};R(O),(null==E?void 0:E.enablechatresponses)&&(T(y),U(!1),$(!0),V([{id:0,role:"assistant",parts:[],documentIds:[]}])),c&&z([]),W("streaming"),le.current=new AbortController;const x=[];let P=[...null!=se?se:[]],A=0,D=!1,L="";for(;!D;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${b}?index=${A}`,{signal:null===(s=le.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=f({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),s=t.error||t.message||(null==_?void 0:_["something-went-wrong"])||"Something went wrong.";return de(t)||G(s),void(D=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)L="",x.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)L+=n.delta,x[x.length-1].content=L;else if("text-end"===n.type)L="";else if("reasoning-start"===n.type)L="",x.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)L+=n.delta,x[x.length-1].content=L;else if("reasoning-end"===n.type)L="";else if(n.type.startsWith("data-")){const e=n;x.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:[...x]})});R(i),(null==E?void 0:E.enablechatresponses)&&V([{id:0,role:"assistant",parts:[...x],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);P=P.filter((e=>!(e.id===t.id&&e.version===t.version))),P.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ie([...P]),ne.startsWith("inline")||oe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);P=P.filter((e=>!(e.id===t.id&&e.version===t.version))),P.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ie([...P]),ne.startsWith("inline")||oe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);P=P.filter((e=>!(e.id===t.id&&e.version===t.version))),P.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ie([...P]),ne.startsWith("inline")||oe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");P=P.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ie([...P])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ie(P.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else D=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}D||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(D=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==J||J(y)}catch(e){let t=b(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==_?void 0:_["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),de(t)||G(t),te()}finally{W("idle"),ae(!1),ee()}}))},{children:re?(null==_?void 0:_.processing)||"Processing...":Q?(null==_?void 0:_.uploading)||"Uploading...":K?(null==_?void 0:_.loading)||"Loading...":null!==(x=null==E?void 0:E.submittext)&&void 0!==x?x:"Submit"})),ce&&s(v,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:Q||K||re,onClick:O},{children:(null==_?void 0:_["clear-form"])||"Clear form"}))]})),!P.isWhiteLabel&&s(h,{containerClassName:"justify-end"})]}))};export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{createContext as o,useState as i,useEffect as a}from"react";import{ArtifactProvider as n}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=o({}),u=({children:o,origin:u,sender:p,senderType:f,deploymentId:h,portalId:m,deploymentType:g,deploymentDimensions:y,deploymentMisc:b,styles:w,colors:v,limits:k={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:C,artifact:F={popupType:"auto"},responsiveBy:I="viewport",locale:P="en",opacity:x=1,forceMobile:T=!1,disableHtml:D=!1,disableJs:A=!1,disableCss:U=!1,loadFont:q=!0,isRtl:R=!1,isEmbed:O=!1,isDropShadow:j=!1,allowGuestUsage:L=!0,preventInitialSessionId:E=!1,onGenerateComplete:G,onSessionIdChange:H})=>{const[M,W]=i(""),[B,N]=i(""),[X,V]=i(""),[Y,J]=i(""),[_,z]=i(p),[K,Q]=i(null),[Z,$]=i(f),[ee,te]=i("loading"),[oe,ie]=i([]),[ae,ne]=i(null),[se,re]=i(null),[le,de]=i(null),[ce,ue]=i(null),[pe,fe]=i(!1),[he,me]=i(!0),[ge,ye]=i(!0),[be,we]=i(!1);return a((()=>{fe(!1)}),[null==w?void 0:w.font]),a((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!pe&&(null==w?void 0:w.font)&&"Real Head Pro"!==w.font)try{(yield import("webfontloader")).default.load({google:{families:[w.font]},active:()=>{fe(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),fe(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),fe(!0)}}))}),[q,pe,null==w?void 0:w.font]),a((()=>{z(p)}),[p]),t(c.Provider,Object.assign({value:Object.assign({origin:u,contextId:M,pickaxeId:B,sessionId:X,lastSessionId:Y,sender:_,senderType:Z,portalId:m,deploymentId:h,deploymentType:g,validationStatus:ee,validationUpgradeGroups:oe,validationUpgradeUrl:ae,deploymentDimensions:y,deploymentMisc:b,accessGroup:K,pickaxe:ce,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},w),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:S,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","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",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.",listening:"Listening...",remaining:"remaining",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, 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:F,responsiveBy:I,locale:P,opacity:x,forceMobile:T,loadFont:q,disableHtml:D,disableJs:A,disableCss:U,isFontLoaded:pe,isNewChat:he,isShowIceBreaker:ge,isShowFeedbackMessage:be,isRtl:R,isEmbed:O,isDropShadow:j,allowGuestUsage:L,clientSecret:le,stripeAccountId:se,preventInitialSessionId:E,setClientSecret:de,setStripeAccountId:re,setContextId:W,setValidationStatus:te,setValidationUpgradeGroups:ie,setValidationUpgradeUrl:ne,setPickaxeId:N,setSessionId:e=>{V((t=>{const o="function"==typeof e?e(t):e;return null==H||H(o),o}))},setLastSessionId:J,setSender:z,setSenderType:$,setAccessGroup:Q,setPickaxe:ue,setIsFontLoaded:fe,setIsNewChat:me,setIsShowIceBreaker:ye,setIsShowFeedbackMessage:we},G&&{onGenerateComplete:G})},{children:t(d,{children:t(s,{children:t(r,Object.assign({limits:k},{children:t(l,{children:t(n,Object.assign({},F,{children:o}))})}))})})}))};export{c as PickaxeContext,u as PickaxeProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import r from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as n,intervalToSuffix as l}from"./PickaxeCommon.js";import{currencyOptions as a}from"./PickaxeCurrency.js";import{Avatar as c,AvatarImage as d,AvatarFallback as m}from"./PickaxeAvatar.js";import{useAuthContext as u}from"../Addons/Auth/hooks/useAuthContext.js";import p from"../../../common/api/pickaxe.js";import{isInIframe as f}from"../../../common/utils.js";import{useResponseContext as x}from"../../../hooks/pickaxe/useResponseContext.js";import{useStudio as v}from"../../../hooks/studio/useStudio.js";const h=({data:h,children:b,upgradeUrl:j})=>{var g;const{limitData:k}=x(),{studio:y}=v(),{colors:N,sender:O,pickaxe:w,translations:C,setValidationStatus:S,setStripeAccountId:I,setClientSecret:U}=o(),{token:_,setRedirectUrl:A}=u(),L=s((()=>{var e;return null!==(e=h.displayName)&&void 0!==e?e:h.name}),[h]),T=s((()=>{var e;return null!==(e=h.displayDescription)&&void 0!==e?e:h.description}),[h]),P=!!(null==y?void 0:y.data.usage)&&y.data.usage.isCredits,R=s((()=>{var e;const{price:i,priceInterval:t,currency:s}=h;if(!i)return{price:(null==C?void 0:C.free)||"Free",suffix:""};const o=l(t,!0);return{price:`${(null!==(e=a.find((e=>e.id===s)))&&void 0!==e?e:a[0]).symbol}${i.toLocaleString()}`,suffix:o}}),[h]),$=s((()=>{const{limit:e,limitInterval:i}=h;if(e===n)return{limit:(null==C?void 0:C.unlimited)||"Unlimited",suffix:""};const t=l(i,!0);return{limit:e.toLocaleString(),suffix:t}}),[h]);return i("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:N.secondary,color:N.secondaryText}},{children:[b,i("div",Object.assign({className:"flex flex-col"},{children:[i("div",Object.assign({className:"flex flex-col"},{children:[i(c,Object.assign({className:"h-8 w-8"},{children:[t(d,{src:null!==(g=h.image)&&void 0!==g?g:"",alt:L}),t(m,{})]})),t("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:L},{children:L})),Boolean(T)&&t("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:T})),i("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[R.price,t("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:R.suffix}))]}))]})),i("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:N.secondaryText}},{children:[t("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:P?(null==C?void 0:C.credits_upper)||"CREDITS":(null==C?void 0:C.uses_upper)||"USES"})),i("p",Object.assign({className:"text-base font-semibold"},{children:[$.limit,t("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:$.suffix}))]}))]}))]})),t(r,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>e(void 0,void 0,void 0,(function*(){if(_)e(void 0,void 0,void 0,(function*(){try{const e=yield p.post("/access_group_checkout",{data:{studioUserId:O||void 0,studioId:null==w?void 0:w.studioid,accessGroupId:h.accessGroupId,successUrl:document.URL,isEmbed:f(),studioSessionToken:_}}),{success:i,url:t,clientSecret:s,stripeAccountId:o,error:r}=e.data;i?f()?s&&o?(I(o),U(s),S("stripe_checkout")):t&&window.open(t,"_blank"):t&&(window.location.href=t):alert(r)}catch(e){alert(e)}}));else if(f()){const e=j||(null==k?void 0:k.limitLink);A(e||null),S("login_required")}else window.location.href=j||`${null==k?void 0:k.limitLink}?redirectUrl=${document.URL}`}))},{children:h.ctaButtonText}))]}))};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import o from"../../common/Modal/index.js";import r from"../../common/Modal/Body.js";const s=({src:s,isOpen:
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import o from"../../common/Modal/index.js";import r from"../../common/Modal/Body.js";import{usePickaxeContext as i}from"../../../../../../../hooks/pickaxe/usePickaxeContext.js";const s=({src:s,isOpen:t,onChangeIsOpen:n})=>{const{translations:a}=i();return e(o,Object.assign({isOpen:t,onChange:n},{children:e(r,Object.assign({style:{width:"90vw",height:"90vh",border:"none"},avoidOverflow:!0},{children:e("iframe",{src:s,title:(null==a?void 0:a["html-preview"])||"HTML preview",className:"scrollbar scrollbar-thin",style:{width:"100%",height:"100%",flex:1,borderRadius:"8px"}})}))}))};export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as i}from"react";import{
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as i}from"react";import{usePickaxeContext as o}from"../../../../../../../hooks/pickaxe/usePickaxeContext.js";import{usePickaxeMarkdownContext as s}from"../../../hooks/usePickaxeMarkdownContext.js";import n from"../../../../../../Icons/eye.svg.js";import l from"../../../../../../Icons/arrow-up-right.svg.js";import a from"./HtmlModal.js";const c=({url:c})=>{const{theme:h,colors:m}=s(),{translations:d}=o(),[p,f]=i(!1);return e(r,{children:[p&&t(a,{src:c,isOpen:p,onChangeIsOpen:f}),e("div",Object.assign({style:{display:"flex",alignItems:"flex-start",gap:"1rem",minHeight:"200px",overflow:"hidden",borderRadius:"8px"}},{children:[t("iframe",{src:c,title:(null==d?void 0:d["html-preview"])||"HTML preview",className:"scrollbar scrollbar-thin",style:{width:"100%",minHeight:"200px",border:"1px solid "+("dark"===h?"#30363D":"#D0D7DE")}}),e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:".75rem"}},{children:[t("button",Object.assign({style:{outline:"none",color:m.accent},onClick:()=>f(!0)},{children:t(n,{width:24,height:24,style:{flexShrink:0}})})),t("a",Object.assign({href:c,rel:"noreferrer",target:"_blank"},{children:t("button",Object.assign({style:{outline:"none",color:m.accent}},{children:t(l,{width:24,height:24,style:{flexShrink:0}})}))}))]}))]}))]})};export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as r,useEffect as i}from"react";import{usePickaxeMarkdownContext as a}from"../../hooks/usePickaxeMarkdownContext.js";import{useArtifactContext as n}from"../../../../Addons/Artifact/hooks/useArtifactContext.js";import{motion as s}from"framer-motion";import
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as r,useEffect as i}from"react";import{usePickaxeMarkdownContext as a}from"../../hooks/usePickaxeMarkdownContext.js";import{useArtifactContext as n}from"../../../../Addons/Artifact/hooks/useArtifactContext.js";import{usePickaxeContext as o}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{motion as s}from"framer-motion";import d from"../../../../../Icons/spinner-lines.svg.js";import c from"../../../../Addons/Artifact/Renderer/index.js";const l=({node:i})=>{const{theme:l,colors:p,styles:m,onArtifactClick:u}=a(),{translations:f}=o(),{artifacts:v,currentPopupType:x,currentArtifact:h}=n(),C=r((()=>{const{dataId:e,dataCommand:t,dataTitle:r,dataType:a,dataVersion:n}=(null==i?void 0:i.properties)||{};return e?{id:e,command:t||"create",title:r||(null==f?void 0:f["untitled-artifact"])||"Untitled Artifact",type:a||"text/markdown",version:n?parseInt(n,10):1}:null}),[f]),g=r((()=>{var e,t,r,i;if(!C)return null;const{command:a,type:n,version:o}=C;let s=`${null!==(t=null!==(e={create:(null==f?void 0:f.created)||"Created",update:(null==f?void 0:f.updated)||"Updated",rewrite:(null==f?void 0:f.rewrote)||"Rewrote"}[a])&&void 0!==e?e:null==f?void 0:f.created)&&void 0!==t?t:"Created"} ${null!==(i=null!==(r={"text/markdown":"Markdown","text/html":"HTML","text/csv":"CSV","text/tab-separated-values":"TSV","image/svg+xml":"SVG","application/pdf":"PDF","application/vnd.pxe.code":"Code","application/vnd.pxe.mermaid":"Diagram","application/vnd.pxe.react":"React Component"}[n])&&void 0!==r?r:null==f?void 0:f.artifact)&&void 0!==i?i:"Artifact"}`;return o>1&&(s+=` (v${o})`),s}),[C,f]),b=r((()=>{if(!C)return"finished";const e=v.find((e=>e.id===C.id&&e.version===C.version));return e?e.status:"finished"}),[v,C]);return C?x.startsWith("inline")&&"finished"===b?h?null:e(c,{type:"inline",className:"pxe-artifact-inline",styling:{colors:p,styles:m},artifact:{id:C.id,version:C.version}}):t(s.div,Object.assign({className:"pxe-artifact-create-container p-4 flex items-center gap-8 flex-wrap justify-between mb-4 select-none",style:Object.assign({borderColor:"dark"===l?"#444444":"#CCCCCC",backgroundColor:p.secondary+"80",color:p.secondaryText,borderRadius:m.cornerRadius},!!u&&{cursor:"pointer"}),initial:{opacity:0,x:10,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.5,ease:"easeOut",staggerChildren:.1},whileHover:{borderColor:"dark"===l?"#666666":"#AAAAAA",backgroundColor:p.secondary}},u&&{onClick:()=>u({id:C.id,version:C.version})},{children:[t("div",Object.assign({className:"pxe-artifact-create-header flex flex-col gap-2 text-[10pt]"},{children:[e("p",Object.assign({className:"font-semibold"},{children:C.title})),e("p",Object.assign({className:"opacity-90"},{children:g}))]})),"finished"!==b&&e("div",{children:e(d,{className:"pxe-spin w-5 h-5 shrink-0"})})]})):null},p=({node:t,children:r})=>{const{setArtifacts:a}=n();return i((()=>{if(!t||!t.properties)return;const e=t.properties.dataId;e&&a((t=>t.map((t=>t.id===e?Object.assign(Object.assign({},t),{status:"error"}):t))))}),[]),e("div",Object.assign({className:"pxe-red pxe-artifact-error"},{children:r}))};export{l as Artifact,p as ArtifactError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as t}from"../../../../../../_virtual/_tslib.js";import{jsx as e}from"react/jsx-runtime";const r=r=>{var{title:
|
|
1
|
+
import{__rest as t}from"../../../../../../_virtual/_tslib.js";import{jsx as e}from"react/jsx-runtime";import{usePickaxeContext as i}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";const r=r=>{var{title:l,children:s,style:o}=r,n=t(r,["title","children","style"]);const{translations:a}=i();return e("iframe",Object.assign({title:l||(null==a?void 0:a["html-preview"])||"HTML preview",style:Object.assign({borderRadius:"8px",width:"100%"},o),allowFullScreen:!0},n,{children:s}))};export{r as Iframe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o,__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useState as r}from"react";import{usePickaxeMarkdownContext as n}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as s}from"../../../../../../hooks/core/useHover.js";import{motion as a}from"framer-motion";import
|
|
1
|
+
import{__rest as o,__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useState as r}from"react";import{usePickaxeMarkdownContext as n}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as s}from"../../../../../../hooks/core/useHover.js";import{motion as a}from"framer-motion";import l from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copied.svg.js";import p from"../../../../../Icons/copy.svg.js";import d from"./ImgModal.js";import m from"copy-to-clipboard";import{usePickaxeContext as b}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";const x=({src:x,alt:h})=>{const{colors:g,readOnly:y}=n(),{translations:u}=b(),[f,v]=r(!1),[k,w]=r(!1),[j,O]=r(!1),C=s(),{isHover:S}=C,I=o(C,["isHover"]);return i("div",Object.assign({className:"pxe-markdown-image",style:Object.assign({display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px"},!y&&{transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:S?"translateY(-5px)":"translateY(0)"})},!y&&Object.assign({},I),{children:[k&&t(d,{src:x,isOpen:k,onChangeIsOpen:w}),f?t("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:(null==u?void 0:u["image-link-is-broken"])||"[Image link is broken]"})):i("div",Object.assign({style:{position:"relative"}},{children:[!y&&i(a.div,Object.assign({initial:"hidden",animate:S||j?"visible":"hidden",variants:{hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[t(a.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:g.accent,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>{o.stopPropagation(),window.open(x,"_blank")}},{children:t(l,{width:24,height:24,style:{color:g.accentText,flexShrink:0}})})),t(a.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:g.accent,opacity:j?1:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>{o.stopPropagation(),e(void 0,void 0,void 0,(function*(){try{O(!0),m(x||""),yield new Promise((o=>setTimeout(o,1500)))}finally{O(!1)}}))}},{children:t(j?c:p,{width:24,height:24,style:{color:g.accentText,flexShrink:0}})}))]})),t("img",Object.assign({src:x,alt:h,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:S?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>v(!0)},!y&&{onClick:()=>w(!0)}))]}))]}))};export{x as Img};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";const
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{usePickaxeContext as t}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";const r=({title:r,src:s,fallback:a})=>{const{translations:i}=t();return e("div",Object.assign({className:"pxe-markdown-video"},{children:e("iframe",Object.assign({title:r,src:s,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:a||(null==i?void 0:i["iframe-not-supported-use-different-browser"])||"Iframe not supported, use a different browser."}))}))};export{r as default};
|
package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{usePickaxeContext as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import i from"./TextShimmer.js";const e=({caption:e,isLoading:r})=>{const{colors:s,translations:n}=o();return r?t(i,Object.assign({theme:"#000000"===s.text?"light":"dark",isDisabled:!r},{children:e||((null==n?void 0:n.loading)||"Loading...")})):null};export{e as default};
|