@pickaxeproject/react 5.6.0 → 5.6.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  2. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  5. package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
  6. package/dist/cjs/components/Pickaxe/common/PickaxeAvatar.js +1 -0
  7. package/dist/cjs/components/Pickaxe/common/PickaxeCommon.js +1 -0
  8. package/dist/cjs/components/Pickaxe/common/PickaxeCurrency.js +1 -0
  9. package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  10. package/dist/cjs/components/Pickaxe/index.js +1 -1
  11. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +3 -1
  12. package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +6 -3
  13. package/dist/cjs/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
  14. package/dist/cjs/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
  15. package/dist/cjs/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
  16. package/dist/cjs/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
  17. package/dist/cjs/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
  18. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  19. package/dist/cjs/src/types/response.d.ts +8 -0
  20. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  21. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  22. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  23. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  24. package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
  25. package/dist/esm/components/Pickaxe/common/PickaxeAvatar.js +1 -0
  26. package/dist/esm/components/Pickaxe/common/PickaxeCommon.js +1 -0
  27. package/dist/esm/components/Pickaxe/common/PickaxeCurrency.js +1 -0
  28. package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  29. package/dist/esm/components/Pickaxe/index.js +1 -1
  30. package/dist/esm/src/components/Pickaxe/Provider.d.ts +3 -1
  31. package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +6 -3
  32. package/dist/esm/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
  33. package/dist/esm/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
  34. package/dist/esm/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
  35. package/dist/esm/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
  36. package/dist/esm/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
  37. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  38. package/dist/esm/src/types/response.d.ts +8 -0
  39. package/package.json +205 -202
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:S,isInputFocused:A,onSubmit:P,resubmitPrompt:I})=>{var H,L,R,M,D;const{sessionId:E,deploymentType:F,pickaxe:B,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isEmailLogin:U,isShowIceBreaker:V,setSessionId:G,setLastSessionId:J}=i.usePickaxeContext(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=a.useAuthContext(),{onSend:ee}=t.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:ae,error:te}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==B?void 0:B.icebreakers)?B.icebreakers.slice(0,3):[]),[null==B?void 0:B.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!S&&de.isSuccess&&W&&!e}),[S,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==B?void 0:B.chatflag)&&(null==B?void 0:B.enablechatresponses)&&ie.length>0),[B,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===F&&U&&Q&&Z,ge=V&&!A&&!je&&me&&ne>767,pe=V&&!A&&(je||ne<=767),be=()=>{J(E),G("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===F&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:K}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(R=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==R?R:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Y||X||ee(!0)}},{children:X?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==B?void 0:B.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(L=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==L?L:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var a,t;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(t=null===(a=de.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),ae?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):te?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:te})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:S,isInputFocused:A,onSubmit:P,resubmitPrompt:I})=>{var H,L,R,M,D;const{sessionId:E,deploymentType:F,pickaxe:B,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isEmailLogin:U,isShowIceBreaker:V,setSessionId:G,setLastSessionId:J}=i.usePickaxeContext(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=a.useAuthContext(),{onSend:ee}=t.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:ae,error:te}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==B?void 0:B.icebreakers)?B.icebreakers.slice(0,3):[]),[null==B?void 0:B.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!S&&de.isSuccess&&W&&!e}),[S,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==B?void 0:B.chatflag)&&(null==B?void 0:B.enablechatresponses)&&ie.length>0),[B,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===F&&U&&Q&&Z,ge=V&&!A&&!je&&me&&ne>767,pe=V&&!A&&(je||ne<=767),be=()=>{J(E),G("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===F&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:K}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(R=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==R?R:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Y||X||ee(!0)}},{children:X?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==B?void 0:B.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(L=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==L?L:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var a,t;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(t=null===(a=de.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),ae?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):te?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:te})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),h=require("../../../hooks/core/useHover.js"),m=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=N(n);const _=s.forwardRef((({resubmitPrompt:N,onFocus:_,onBlur:E,onInputHeightChange:A,initSmitheryAuthData:q},R)=>{var T,P,D;const{origin:L,pickaxeId:H,sessionId:M,sender:F,senderType:$,deploymentId:W,deploymentType:B,pickaxe:J,styles:U,colors:V,locale:K,forceMobile:X,isNewChat:z,isRtl:G,isEmailLogin:Q,isShowFeedbackMessage:Y,setIsNewChat:Z,setIsShowIceBreaker:ee,onGenerateComplete:te}=r.usePickaxeContext(),{token:se,isLoggedOut:ne,isSent:re}=u.useAuthContext(),{messages:ie,limits:oe,isGenerating:ae,setMessages:le,setStatus:ce,setLimitData:ue,setError:de}=i.useResponseContext(),{documents:fe,isUploading:pe,documentError:he,onFileUpload:me,setDocuments:ge,setDocumentError:ve}=d.useDocument(),{scrollStartSession:ye,scrollEndSession:be,scrollToBottom:xe}=f.useScroll({auto:!0}),{artifacts:je,currentPopupType:we,setArtifacts:Oe,setCurrentArtifact:Se}=p.useArtifactContext(),{height:ke}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,Ie]=s.useState(""),[_e,Ee]=s.useState(!1),[Ae,qe]=s.useState(!1),Re=s.useRef(null),Te=s.useRef(""),Pe=s.useRef(null),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=s.useRef(null),Fe=Math.max(.4*ke,100),{transcript:$e,listening:We,resetTranscript:Be,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ue]=m.useMediaQuery("(max-width: 480px)"),Ve=h.useHover(),{isHover:Ke}=Ve,Xe=e.__rest(Ve,["isHover"]),ze=h.useHover(),{isHover:Ge}=ze,Qe=e.__rest(ze,["isHover"]),Ye=h.useHover(),{isHover:Ze}=Ye,et=e.__rest(Ye,["isHover"]),tt=a.useStyleFontSize(),st=o.useStyleInput(),nt="undefined"!=typeof window?window.location.hostname:"",rt="undefined"!=typeof window?window.location.href:"",it="undefined"!=typeof window&&window.self!==window.top,ot=nt.includes("pickaxe.co")&&!rt.includes("https://studio.pickaxe.co/_embed")&&!it,at=null===(T=null==J?void 0:J.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"),lt=Je&&(null==J?void 0:J.enablevoicetotext),ct="chat-input"===B&&z&&!re,ut="chat-input"===B&&Q&&ne&&re,dt=null!==(P=null==J?void 0:J.placeholdertext)&&void 0!==P?P:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",ft=_e||Ae,pt=s.useMemo((()=>{var e,t,s;return!!z&&(!!J&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!Y&&!ct)))))}),[J,z,Y,ct,Ce.data,Ce.isLoading]),ht=s.useMemo((()=>{if(ae||pe)return!1;const e=fe.length>0&&fe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&fe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ae,pe,Ne,fe]);s.useImperativeHandle(R,(()=>({onSubmit:mt}))),s.useEffect((()=>{ee(pt)}),[pt]),s.useEffect((()=>{var e;if(N){const t=Array.from(ie),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;mt(s,!0)}}),[N]),s.useEffect((()=>{if(!He.current||!A)return;const e=new ResizeObserver((e=>{for(const t of e)A(t.contentRect.height)}));return e.observe(He.current),()=>{e.disconnect()}}),[A]),s.useEffect((()=>{if(!We)return;const e=Te.current?`${Te.current} `:"";Ie(`${e}${$e}`)}),[$e,We]),s.useEffect((()=>{if(!De.current)return;(()=>{if(!De.current)return;let e=De.current.scrollHeight>52;Ne.includes("\n")||fe.length?e=!0:Ne.trim()||(e=!1),Ee(e)})()}),[Ne,fe]),s.useEffect((()=>{const e=De.current,t=Le.current;if(!e||!t||_e||Ne.includes("\n"))return void qe(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,r=document.createElement("span");Object.assign(r.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),r.textContent=Ne||dt,document.body.appendChild(r);const i=r.offsetWidth;r.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;qe(i>l)}),[Ne,_e,dt]);const mt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,r;try{if(ae||pe)return;const i=fe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=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=o.length>0,c=null!=t?t:Ne;if(!c&&!l)return;de(""),ve(""),ue(null),Ie(""),Z(!1),ce("fetching"),ye(),xe();const u=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(ie.slice(0,ie.length-1)):Array.from(ie),...s?[]:[{id:ie.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:ie.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];le(d),xe(),u&&ge([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:H,sessionId:M,senderType:$,value:c},u&&{documentIds:o}),F&&{sender:F}),se&&{studioSessionToken:se}),W&&{deploymentId:W}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ot&&{credentials:"include"})),p=yield f.json();if(!p.success)throw new Error(p.error||"Failed to start generation");const h=p.submissionId;ce("streaming"),Me.current=new AbortController;const m=d.length-1,g=[];let y=[...null!=je?je:[]],b=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${h}?index=${b}`,{signal:null===(r=Me.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Pe.current=t;const s=new TextDecoder,n=v.createParser({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).error||"Something went wrong.";return de(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){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 x=!0,q({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 x=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}le([...d.slice(0,m),Object.assign(Object.assign({},d[d.length-1]),{id:ie.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe([...y]),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Oe(y),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe(y),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");y=y.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Oe(y)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Oe(y.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);de(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:r}=yield t.read();if(r)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==te||te(M)}catch(e){let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(oe).find((([e])=>t.includes(e)));s?ue(s[1]):de(t)}finally{xe(),ce("idle"),be(),Pe.current=null}}));return ut?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!ct&&"px-4 pb-8"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:He,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===U.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},st),{maxHeight:`${Fe}px`,overflowY:"auto"})},{children:[We&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(D=V.accent)&&void 0!==D?D:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:V.text+"90"}},{children:"Listening..."}))]})),!ae&&fe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:ae}),t.jsx(O.default,Object.assign({ref:De,className:C.default(tt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",G?"text-right":"text-left",ft&&"mb-12",We&&"text-transparent"),value:Ne,placeholder:dt,onChange:e=>{if(Ie(e),A){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void A(0);if(t>=11)return;let s=0;t>1&&(s=50),A(24*(t-1)+s)}},onKeyDown:e=>{X||Ue||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),pe||ae||mt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Z(!1),yield me(e))}))},_&&{onFocus:_},E&&{onBlur:E},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Le,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ft?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ft&&st.backgroundColor&&{backgroundColor:st.backgroundColor}),{borderTopRightRadius:U.cornerRadius+"px",borderBottomRightRadius:U.cornerRadius+"px"})},{children:ae?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Me.current&&(Me.current.abort(),Me.current=null),Pe.current&&(Pe.current.cancel(),Pe.current=null),ce("idle")},style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):We?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:I.default.stopListening,style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[at&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ge?V.accent+"10":void 0,color:Ge?V.accent:V.accent+"80"},disabled:pe||ae,onClick:()=>{var e;return null===(e=Re.current)||void 0===e?void 0:e.click()}},Qe,{children:[t.jsx("input",{id:"file-upload",ref:Re,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Z(!1),yield me(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),lt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:We?V.accent:Ze?V.accent+"10":void 0,color:We?V.accentText:Ze?V.accent:V.accent+"80"},disabled:pe||ae,onClick:()=>{We?I.default.stopListening():(Te.current=Ne,Be(),I.default.startListening({continuous:!0,interimResults:!0,language:K||"en-US"}))}},et,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ke||ht?V.accent:V.accent+"10",color:Ke||ht?V.accentText:V.accent+"80"},disabled:!ht,onClick:()=>mt()},Xe,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));_.displayName="Input",exports.default=_;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=N(n);const _=s.forwardRef((({resubmitPrompt:N,onFocus:_,onBlur:E,onInputHeightChange:A,initSmitheryAuthData:q},R)=>{var T,P,D;const{origin:L,pickaxeId:H,sessionId:M,sender:F,senderType:$,deploymentId:W,deploymentType:B,pickaxe:J,styles:U,colors:V,locale:K,forceMobile:X,isNewChat:z,isRtl:G,isEmailLogin:Q,isShowFeedbackMessage:Y,setIsNewChat:Z,setIsShowIceBreaker:ee,onGenerateComplete:te}=i.usePickaxeContext(),{token:se,isLoggedOut:ne,isSent:ie}=u.useAuthContext(),{messages:re,isGenerating:oe,setMessages:ae,setStatus:le,setLimitData:ce,setError:ue}=r.useResponseContext(),{documents:de,isUploading:fe,documentError:pe,onFileUpload:me,setDocuments:he,setDocumentError:ge}=d.useDocument(),{scrollStartSession:ve,scrollEndSession:ye,scrollToBottom:be}=f.useScroll({auto:!0}),{artifacts:xe,currentPopupType:je,setArtifacts:we,setCurrentArtifact:Oe}=p.useArtifactContext(),{height:Se}=c.useDimensionContext(),ke=l.useConversation(),[Ce,Ne]=s.useState(""),[Ie,_e]=s.useState(!1),[Ee,Ae]=s.useState(!1),qe=s.useRef(null),Re=s.useRef(""),Te=s.useRef(null),Pe=s.useRef(null),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=Math.max(.4*Se,100),{transcript:Fe,listening:$e,resetTranscript:We,browserSupportsSpeechRecognition:Be}=n.useSpeechRecognition(),[Je]=h.useMediaQuery("(max-width: 480px)"),Ue=m.useHover(),{isHover:Ve}=Ue,Ke=e.__rest(Ue,["isHover"]),Xe=m.useHover(),{isHover:ze}=Xe,Ge=e.__rest(Xe,["isHover"]),Qe=m.useHover(),{isHover:Ye}=Qe,Ze=e.__rest(Qe,["isHover"]),et=a.useStyleFontSize(),tt=o.useStyleInput(),st="undefined"!=typeof window?window.location.hostname:"",nt="undefined"!=typeof window?window.location.href:"",it="undefined"!=typeof window&&window.self!==window.top,rt=st.includes("pickaxe.co")&&!nt.includes("https://studio.pickaxe.co/_embed")&&!it,ot=null===(T=null==J?void 0:J.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"),at=Be&&(null==J?void 0:J.enablevoicetotext),lt="chat-input"===B&&z&&!ie,ct="chat-input"===B&&Q&&ne&&ie,ut=null!==(P=null==J?void 0:J.placeholdertext)&&void 0!==P?P:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",dt=Ie||Ee,ft=s.useMemo((()=>{var e,t,s;return!!z&&(!!J&&(!ke.isLoading&&(!((null!==(t=null===(e=ke.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!Y&&!lt)))))}),[J,z,Y,lt,ke.data,ke.isLoading]),pt=s.useMemo((()=>{if(oe||fe)return!1;const e=de.length>0&&de.every((e=>"finished"===e.status));return!(!Ce.trim()&&!e)&&de.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[oe,fe,Ce,de]);s.useImperativeHandle(R,(()=>({onSubmit:mt}))),s.useEffect((()=>{ee(ft)}),[ft]),s.useEffect((()=>{var e;if(N){const t=Array.from(re),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;mt(s,!0)}}),[N]),s.useEffect((()=>{if(!Le.current||!A)return;const e=new ResizeObserver((e=>{for(const t of e)A(t.contentRect.height)}));return e.observe(Le.current),()=>{e.disconnect()}}),[A]),s.useEffect((()=>{if(!$e)return;const e=Re.current?`${Re.current} `:"";Ne(`${e}${Fe}`)}),[Fe,$e]),s.useEffect((()=>{if(!Pe.current)return;(()=>{if(!Pe.current)return;let e=Pe.current.scrollHeight>52;Ce.includes("\n")||de.length?e=!0:Ce.trim()||(e=!1),_e(e)})()}),[Ce,de]),s.useEffect((()=>{const e=Pe.current,t=De.current;if(!e||!t||Ie||Ce.includes("\n"))return void Ae(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Ce||ut,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ae(r>l)}),[Ce,Ie,ut]);const mt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(oe||fe)return;const r=de.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Ce;if(!c&&!l)return;ue(""),ge(""),ce(null),Ne(""),Z(!1),le("fetching"),ve(),be();const u=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(re.slice(0,re.length-1)):Array.from(re),...s?[]:[{id:re.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:re.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ae(d),be(),u&&he([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:H,sessionId:M,senderType:$,value:c},u&&{documentIds:o}),F&&{sender:F}),se&&{studioSessionToken:se}),W&&{deploymentId:W}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),rt&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;le("streaming"),He.current=new AbortController;const h=d.length-1,g=[];let y=[...null!=xe?xe:[]],b=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${b}`,{signal:null===(i=He.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Te.current=t;const s=new TextDecoder,n=v.createParser({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).error||"Something went wrong.";return ue(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){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 x=!0,q({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 x=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ae([...d.slice(0,h),Object.assign(Object.assign({},d[d.length-1]),{id:re.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we([...y]),je.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),we(y),je.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(y),je.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,"");y=y.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),we(y)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);we(y.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);ue(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==te||te(M)}catch(e){if(e.limitData)ce(e.limitData),ue("");else{let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),ue(t)}}finally{be(),le("idle"),ye(),Te.current=null}}));return ct?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!lt&&"px-4 pb-8"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Le,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===U.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},tt),{maxHeight:`${Me}px`,overflowY:"auto"})},{children:[$e&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(D=V.accent)&&void 0!==D?D:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:V.text+"90"}},{children:"Listening..."}))]})),!oe&&de.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:oe}),t.jsx(O.default,Object.assign({ref:Pe,className:C.default(et.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ce.trim()&&!Ce.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",G?"text-right":"text-left",dt&&"mb-12",$e&&"text-transparent"),value:Ce,placeholder:ut,onChange:e=>{if(Ne(e),A){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void A(0);if(t>=11)return;let s=0;t>1&&(s=50),A(24*(t-1)+s)}},onKeyDown:e=>{X||Je||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),fe||oe||mt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Z(!1),yield me(e))}))},_&&{onFocus:_},E&&{onBlur:E},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:De,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",dt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!dt&&tt.backgroundColor&&{backgroundColor:tt.backgroundColor}),{borderTopRightRadius:U.cornerRadius+"px",borderBottomRightRadius:U.cornerRadius+"px"})},{children:oe?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{He.current&&(He.current.abort(),He.current=null),Te.current&&(Te.current.cancel(),Te.current=null),le("idle")},style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):$e?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:I.default.stopListening,style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[ot&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ze?V.accent+"10":void 0,color:ze?V.accent:V.accent+"80"},disabled:fe||oe,onClick:()=>{var e;return null===(e=qe.current)||void 0===e?void 0:e.click()}},Ge,{children:[t.jsx("input",{id:"file-upload",ref:qe,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Z(!1),yield me(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),at&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:$e?V.accent:Ye?V.accent+"10":void 0,color:$e?V.accentText:Ye?V.accent:V.accent+"80"},disabled:fe||oe,onClick:()=>{$e?I.default.stopListening():(Re.current=Ce,We(),I.default.startListening({continuous:!0,interimResults:!0,language:K||"en-US"}))}},Ze,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ve||pt?V.accent:V.accent+"10",color:Ve||pt?V.accentText:V.accent+"80"},disabled:!pt,onClick:()=>mt()},Ke,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),pe&&t.jsx(S.default,{error:pe,className:"mt-3"})]}))}))}));_.displayName="Input",exports.default=_;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:y,senderType:j,deploymentId:O,pickaxe:w,misc:C,translations:S,isRtl:k,setSessionId:I,setIsNewChat:_,onGenerateComplete:P}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{limits:N,isGenerating:q,setResponse:E,setMessages:T,setStatus:U,setLimitData:L,setError:D,setIsSwitchedToChat:R}=o.useResponseContext(),{documents:J,websiteLink:B,isUploading:K,onWebsiteUpload:W,setDocuments:X,setDocumentError:V}=r.useDocument(),{scrollStartSession:M,scrollEndSession:$,scrollToTarget:F}=a.useScroll({auto:!(null==w?void 0:w.enablechatresponses)}),{artifacts:G,currentPopupType:Q,setArtifacts:Y,setCurrentArtifact:z}=l.useArtifactContext(),[H,Z]=s.useState(!1),ee=s.useRef(null),te=s.useMemo((()=>f.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))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||q||H,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(q||K||H)return;D(""),V(""),L(null),E(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=J.filter((e=>"finished"===e.status)),o=J.map((e=>e.name)),r=null!==(t=null===(e=null==w?void 0:w.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(B).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];Z(!0);const t=yield W(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Z(!1)}else if(a&&r&&!i.length)return void V("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),U("fetching"),M(),F();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:j,valueObj:g},m&&{documentIds:p}),y&&{sender:y}),A&&{studioSessionToken:A}),O&&{deploymentId:O}))}),v=yield h.json();if(!v.success)throw new Error(v.error||"Failed to start generation");const C=v.submissionId,S=v.sessionId,k={sessionId:S,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};E(k),(null==w?void 0:w.enablechatresponses)&&(I(S),_(!1),R(!0),T([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&X([]),U("streaming"),ee.current=new AbortController;const N=[];let $=[...null!=G?G:[]],te=0,se=!1,ne="";for(;!se;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${C}?index=${te}`,{signal:null===(s=ee.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=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&te++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return D(t),void(se=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ne="",N.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ne+=n.delta,N[N.length-1].content=ne;else if("text-end"===n.type)ne="";else if("reasoning-start"===n.type)ne="",N.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ne+=n.delta,N[N.length-1].content=ne;else if("reasoning-end"===n.type)ne="";else if(n.type.startsWith("data-")){const e=n;N.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[...N]})});E(i),(null==w?void 0:w.enablechatresponses)&&T([{id:0,role:"assistant",parts:[...N],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");$=$.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Y([...$])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Y($.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else se=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}se||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(se=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==P||P(S)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(N).find((([e])=>t.includes(e)));s?L(s[1]):D(t),F()}finally{U("idle"),Z(!1),$()}}))},{children:H?(null==S?void 0:S.processing)||"Processing...":K?(null==S?void 0:S.uploading)||"Uploading...":q?(null==S?void 0:S.loading)||"Loading...":null!==(v=null==w?void 0:w.submittext)&&void 0!==v?v:"Submit"})),te&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||q||H,onClick:h},{children:(null==S?void 0:S["clear-form"])||"Clear form"}))]})),!C.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:y,senderType:j,deploymentId:O,pickaxe:w,misc:C,translations:S,isRtl:k,setSessionId:I,setIsNewChat:_,onGenerateComplete:P}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{isGenerating:N,setResponse:q,setMessages:E,setStatus:T,setLimitData:D,setError:U,setIsSwitchedToChat:L}=o.useResponseContext(),{documents:R,websiteLink:J,isUploading:B,onWebsiteUpload:K,setDocuments:W,setDocumentError:X}=r.useDocument(),{scrollStartSession:V,scrollEndSession:M,scrollToTarget:$}=a.useScroll({auto:!(null==w?void 0:w.enablechatresponses)}),{artifacts:F,currentPopupType:G,setArtifacts:Q,setCurrentArtifact:Y}=l.useArtifactContext(),[z,H]=s.useState(!1),Z=s.useRef(null),ee=s.useMemo((()=>f.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))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:B||N||z,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(N||B||z)return;U(""),X(""),D(null),q(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=R.filter((e=>"finished"===e.status)),o=R.map((e=>e.name)),r=null!==(t=null===(e=null==w?void 0:w.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(J).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];H(!0);const t=yield K(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),H(!1)}else if(a&&r&&!i.length)return void X("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),T("fetching"),V(),$();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:j,valueObj:g},m&&{documentIds:p}),y&&{sender:y}),A&&{studioSessionToken:A}),O&&{deploymentId:O}))}),v=yield h.json();if(!v.success){const e=new Error(v.error||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}const C=v.submissionId,S=v.sessionId,k={sessionId:S,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};q(k),(null==w?void 0:w.enablechatresponses)&&(I(S),_(!1),L(!0),E([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&W([]),T("streaming"),Z.current=new AbortController;const M=[];let ee=[...null!=F?F:[]],te=0,se=!1,ne="";for(;!se;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${C}?index=${te}`,{signal:null===(s=Z.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=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&te++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return U(t),void(se=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ne="",M.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ne+=n.delta,M[M.length-1].content=ne;else if("text-end"===n.type)ne="";else if("reasoning-start"===n.type)ne="",M.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ne+=n.delta,M[M.length-1].content=ne;else if("reasoning-end"===n.type)ne="";else if(n.type.startsWith("data-")){const e=n;M.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[...M]})});q(i),(null==w?void 0:w.enablechatresponses)&&E([{id:0,role:"assistant",parts:[...M],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");ee=ee.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Q([...ee])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Q(ee.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else se=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}se||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(se=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==P||P(S)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),U(t),$()}finally{T("idle"),H(!1),M()}}))},{children:z?(null==S?void 0:S.processing)||"Processing...":B?(null==S?void 0:S.uploading)||"Uploading...":N?(null==S?void 0:S.loading)||"Loading...":null!==(v=null==w?void 0:w.submittext)&&void 0!==v?v:"Submit"})),ee&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:B||N||z,onClick:h},{children:(null==S?void 0:S["clear-form"])||"Clear form"}))]})),!C.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,deploymentId:y,deploymentType:h,deploymentDimensions:m,deploymentMisc:b,styles:g,colors:v,limits:x={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:j,artifact:P={popupType:"auto"},responsiveBy:w="viewport",locale:F="en",opacity:k=1,forceMobile:I=!1,disableHtml:C=!1,disableJs:O=!1,disableCss:E=!1,loadFont:D=!0,isRtl:T=!1,isEmbed:q=!1,isDropShadow:H=!1,isEmailLogin:L=!1,allowGuestUsage:M=!0,onGenerateComplete:R})=>{const[_,A]=i.useState(""),[B,G]=i.useState(""),[N,U]=i.useState(""),[W,z]=i.useState(""),[J,Y]=i.useState(f),[K,Q]=i.useState(p),[V,X]=i.useState(null),[Z,$]=i.useState(!1),[ee,te]=i.useState(!0),[ie,se]=i.useState(!0),[oe,re]=i.useState(!1);return i.useEffect((()=>{$(!1)}),[null==g?void 0:g.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!Z&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[g.font]},active:()=>{$(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),$(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),$(!0)}}))}),[D,Z,null==g?void 0:g.font]),i.useEffect((()=>{Y(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:_,pickaxeId:B,sessionId:N,lastSessionId:W,sender:J,senderType:K,deploymentId:y,deploymentType:h,deploymentDimensions:m,deploymentMisc:b,pickaxe:V,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc: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"},j),artifact:P,responsiveBy:w,locale:F,opacity:k,forceMobile:I,loadFont:D,disableHtml:C,disableJs:O,disableCss:E,isFontLoaded:Z,isNewChat:ee,isShowIceBreaker:ie,isShowFeedbackMessage:oe,isRtl:T,isEmbed:q,isDropShadow:H,isEmailLogin:L,allowGuestUsage:M,setContextId:A,setPickaxeId:G,setSessionId:U,setLastSessionId:z,setSender:Y,setSenderType:Q,setPickaxe:X,setIsFontLoaded:$,setIsNewChat:te,setIsShowIceBreaker:se,setIsShowFeedbackMessage:re},R&&{onGenerateComplete:R})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:x},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},P,{children:c}))})}))})})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:x,limits:S={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:k="en",opacity:I=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:E=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:H=!1,isDropShadow:L=!1,isEmailLogin:M=!1,allowGuestUsage:R=!0,onGenerateComplete:_})=>{const[A,B]=i.useState(""),[G,N]=i.useState(""),[U,W]=i.useState(""),[z,J]=i.useState(""),[Y,K]=i.useState(f),[Q,V]=i.useState(p),[X,Z]=i.useState(null),[$,ee]=i.useState(!1),[te,ie]=i.useState(!0),[se,oe]=i.useState(!0),[re,ne]=i.useState(!1);return i.useEffect((()=>{ee(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!$&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{ee(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ee(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ee(!0)}}))}),[T,$,null==v?void 0:v.font]),i.useEffect((()=>{K(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:A,pickaxeId:G,sessionId:U,lastSessionId:z,sender:Y,senderType:Q,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,pickaxe:X,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},x),misc:j,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"},P),artifact:w,responsiveBy:F,locale:k,opacity:I,forceMobile:C,loadFont:T,disableHtml:O,disableJs:E,disableCss:D,isFontLoaded:$,isNewChat:te,isShowIceBreaker:se,isShowFeedbackMessage:re,isRtl:q,isEmbed:H,isDropShadow:L,isEmailLogin:M,allowGuestUsage:R,setContextId:B,setPickaxeId:N,setSessionId:W,setLastSessionId:J,setSender:K,setSenderType:V,setPickaxe:Z,setIsFontLoaded:ee,setIsNewChat:ie,setIsShowIceBreaker:oe,setIsShowFeedbackMessage:ne},_&&{onGenerateComplete:_})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("./PickaxeButton.js"),r=require("./PickaxeCommon.js"),n=require("./PickaxeCurrency.js"),o=require("./PickaxeAvatar.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../common/api/pickaxe.js"),d=require("../../../common/utils.js"),u=require("../../../hooks/pickaxe/useResponseContext.js");exports.default=({data:x,children:m,upgradeUrl:p})=>{var f;const{limitData:j}=u.useResponseContext(),{colors:b,sender:v,pickaxe:h}=t.usePickaxeContext(),{token:k}=c.useAuthContext(),y=i.useMemo((()=>{var e;return null!==(e=x.displayName)&&void 0!==e?e:x.name}),[x]),g=i.useMemo((()=>{var e;return null!==(e=x.displayDescription)&&void 0!==e?e:x.description}),[x]),O=i.useMemo((()=>{var e;const{price:s,priceInterval:i,currency:t}=x;if(!s)return{price:"Free",suffix:""};const a=r.intervalToSuffix(i,!0);return{price:`${(null!==(e=n.currencyOptions.find((e=>e.id===t)))&&void 0!==e?e:n.currencyOptions[0]).symbol}${s.toLocaleString()}`,suffix:a}}),[x]),w=i.useMemo((()=>{const{limit:e,limitInterval:s}=x;if(e===r.STUDIO_INFINITY_VALUE)return{limit:"Unlimited",suffix:""};const i=r.intervalToSuffix(s,!0);return{limit:e.toLocaleString(),suffix:i}}),[x]);return s.jsxs("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:b.secondary,color:b.secondaryText}},{children:[m,s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs(o.Avatar,Object.assign({className:"h-8 w-8"},{children:[s.jsx(o.AvatarImage,{src:null!==(f=x.image)&&void 0!==f?f:"",alt:y}),s.jsx(o.AvatarFallback,{})]})),s.jsx("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:y},{children:y})),Boolean(g)&&s.jsx("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:g})),s.jsxs("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[O.price,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:O.suffix}))]}))]})),s.jsxs("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:b.secondaryText}},{children:[s.jsx("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:"USES"})),s.jsxs("p",Object.assign({className:"text-base font-semibold"},{children:[w.limit,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:w.suffix}))]}))]}))]})),s.jsx(a.default,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>{v||k?e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield l.default.post("/access_group_checkout",{data:{studioUserId:v||void 0,studioId:null==h?void 0:h.studioid,accessGroupId:x.accessGroupId,successUrl:document.URL,isEmbed:d.isInIframe(),studioSessionToken:k}});if(e.data.success){const s=e.data.url;if(s)if(d.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s;else window.location.reload()}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}})):window.open(p||(null==j?void 0:j.limitLink))}},{children:x.ctaButtonText}))]}))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),a=require("react/jsx-runtime"),s=require("react"),r=require("../../../common/cn.js"),t=require("@radix-ui/react-avatar");function l(e){if(e&&e.__esModule)return e;var a=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:function(){return e[s]}})}})),a.default=e,Object.freeze(a)}var c=l(s),n=l(t);const d=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Root,Object.assign({ref:t,className:r.default("relative flex h-6 w-6 shrink-0 overflow-hidden rounded-full",l)},c))}));d.displayName=n.Root.displayName;const i=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Image,Object.assign({ref:t,className:r.default("aspect-square h-full w-full",l)},c))}));i.displayName=n.Image.displayName;const u=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Fallback,Object.assign({ref:t,className:r.default("flex h-full w-full select-none items-center justify-center rounded-full bg-muted text-sm text-muted-foreground",l)},c))}));u.displayName=n.Fallback.displayName;const o=c.forwardRef(((s,t)=>{var{className:l,data:c,max:n=5,avatarClassName:o}=s,m=e.__rest(s,["className","data","max","avatarClassName"]);const f=n&&c.length>n,x=f?c.slice(0,n):c,j=f?c.length-n:0;return a.jsxs("div",Object.assign({ref:t,className:r.default("flex items-center",l)},m,{children:[x.map((({src:e,initials:s},t)=>a.jsx("div",Object.assign({className:r.default(0!==t&&"-ml-2","rounded-full border-2 border-background"),style:{zIndex:x.length-t}},{children:a.jsxs(d,Object.assign({},o&&{className:o},{children:[a.jsx(i,{src:e}),a.jsx(u,Object.assign({className:"text-xs"},{children:s}))]}))}),t))),f&&a.jsxs("div",Object.assign({className:r.default("text-sm text-muted-foreground",0!==x.length&&"ml-1"),style:{zIndex:0}},{children:["+",j]}))]}))}));o.displayName="AvatarGroup",exports.Avatar=d,exports.AvatarFallback=u,exports.AvatarGroup=o,exports.AvatarImage=i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.STUDIO_INFINITY_VALUE=-1337,exports.intervalToSuffix=(e,r=!1)=>"day"===e?r?"/daily":"/day":"week"===e?r?"/weekly":"/wk":"month"===e?r?"/monthly":"/mo":"year"===e?r?"/yearly":"/yr":"";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.currencyOptions=[{id:"usd",label:"US Dollar ($)",min:.5,symbol:"$",decimals:2},{id:"eur",label:"Euro (€)",min:.5,symbol:"€",decimals:2},{id:"gbp",label:"British Pound (£)",min:.3,symbol:"£",decimals:2},{id:"jpy",label:"Japanese Yen (¥)",min:50,symbol:"¥",decimals:0},{id:"aud",label:"Australian Dollar ($)",min:.5,symbol:"A$",decimals:2},{id:"cad",label:"Canadian Dollar ($)",min:.5,symbol:"C$",decimals:2},{id:"cny",label:"Chinese Yuan (¥)",min:3,symbol:"CN¥",decimals:2},{id:"chf",label:"Swiss Franc (Fr)",min:.5,symbol:"Fr",decimals:2},{id:"inr",label:"Indian Rupee (₹)",min:.5,symbol:"₹",decimals:2},{id:"sgd",label:"Singapore Dollar ($)",min:.5,symbol:"S$",decimals:2},{id:"hkd",label:"Hong Kong Dollar ($)",min:4,symbol:"HK$",decimals:2},{id:"krw",label:"South Korean Won (₩)",min:500,symbol:"₩",decimals:0},{id:"nzd",label:"New Zealand Dollar ($)",min:.5,symbol:"NZ$",decimals:2},{id:"zar",label:"South African Rand (R)",min:5,symbol:"R",decimals:2},{id:"brl",label:"Brazilian Real (R$)",min:.5,symbol:"R$",decimals:2},{id:"mxn",label:"Mexican Peso ($)",min:10,symbol:"MX$",decimals:2},{id:"sek",label:"Swedish Krona (kr)",min:3,symbol:"kr",decimals:2},{id:"nok",label:"Norwegian Krone (kr)",min:3,symbol:"kr",decimals:2},{id:"try",label:"Turkish Lira (₺)",min:.5,symbol:"₺",decimals:2},{id:"thb",label:"Thai Baht (฿)",min:10,symbol:"฿",decimals:2},{id:"pln",label:"Polish Złoty (zł)",min:2,symbol:"zł",decimals:2},{id:"myr",label:"Malaysian Ringgit (RM)",min:2,symbol:"RM",decimals:2},{id:"idr",label:"Indonesian Rupiah (Rp)",min:5e3,symbol:"Rp",decimals:2},{id:"czk",label:"Czech Koruna (Kč)",min:15,symbol:"Kč",decimals:2},{id:"bgn",label:"Bulgarian Lev (лв)",min:1,symbol:"лв",decimals:2},{id:"rub",label:"Russian Ruble (₽)",min:30,symbol:"₽",decimals:2}];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("framer-motion"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../common/utils.js"),l=require("../../Icons/circle-exclamation.svg.js"),n=require("../../Core/SpringTransition.js"),o=require("../../Core/HtmlRenderer.js"),c=require("./PickaxeButton.js"),u=require("../../../common/cn.js");exports.default=({className:m,iconClassName:x,htmlClassName:d})=>{const{colors:j}=t.usePickaxeContext(),{limitData:f}=r.useResponseContext(),h=a.useStyleFontSize(),p=window.location.href.includes("_embed");return e.jsx(s.AnimatePresence,{children:!!f&&e.jsxs(n.default,Object.assign({className:u.default("flex gap-3",m)},{children:[e.jsx(l.default,{className:u.default("h-5 w-5 shrink-0",x),style:{color:j.accent}}),e.jsxs("div",Object.assign({className:"flex flex-col gap-4"},{children:[e.jsx(o.default,{className:u.default(h.b2,"font-semibold",d),style:{color:j.text},html:f.html}),!!f.cta&&e.jsx("a",Object.assign({href:f.ctaLink,target:i.isInIframe()&&!p?"_self":"_top",rel:"noreferrer"},{children:e.jsx(c.default,Object.assign({variant:"primary",className:"min-h-[38px]",style:{minHeight:"38px"}},{children:f.cta}))}))]}))]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("framer-motion"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),u=require("../../Core/HtmlRenderer.js"),d=require("./PickaxeButton.js"),x=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("./AccessGroupCardPreview.js");const j=({price:e,uses:t,isSelected:r,onClick:a,colors:o})=>s.jsxs("button",Object.assign({onClick:a,className:x.default("flex items-center gap-2 rounded-xl border px-4 py-3 shadow-sm transition-all duration-200 shrink-0",r?"border-2":"border opacity-80 hover:opacity-100"),style:{backgroundColor:o.secondary,color:o.secondaryText,borderColor:r?o.secondaryText:"rgba(0,0,0,0.1)"}},{children:[s.jsxs("span",Object.assign({className:"text-xl font-bold"},{children:["$",e]})),s.jsxs("span",Object.assign({className:"text-sm opacity-70"},{children:["/ ",t.toLocaleString()," uses"]}))]}));exports.default=({className:b,iconClassName:h,htmlClassName:g})=>{var y,v;const{colors:w,pickaxe:k,sender:C}=a.usePickaxeContext(),{token:N}=m.useAuthContext(),{limitData:q}=o.useResponseContext(),O=l.useStyleFontSize(),[_,A]=t.useState(0),S=window.location.href.includes("_embed"),U=i.isInIframe()&&!S?"_self":"_top";if(t.useEffect((()=>{var e;(null===(e=null==q?void 0:q.buyUses)||void 0===e?void 0:e.length)&&A(0)}),[q]),!q)return null;const I=q.limitLink,P=q.limitCTA,G=Array.isArray(q.upgradeGroups)&&q.upgradeGroups.length>0,T=Array.isArray(q.buyUses)&&q.buyUses.length>0,L=T&&Array.isArray(q.buyUses)&&q.buyUses[_];return s.jsx(r.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:x.default("flex flex-col gap-5 w-full",b)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:w.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:x.default("h-5 w-5 shrink-0 mt-0.5",h),style:{color:w.accent}}),s.jsx(u.default,{className:x.default(O.b2,"font-semibold leading-relaxed text-sm",g),style:{color:w.text},html:q.limitMessage||""})]})),P&&s.jsx("a",Object.assign({href:I,target:U,rel:"noreferrer",className:"shrink-0 w-full sm:w-auto"},{children:s.jsx(d.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm"},{children:P}))}))]})),G&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Available Plans"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(y=q.upgradeGroups)||void 0===y?void 0:y.map(((e,t)=>s.jsx(f.default,{data:e},e.accessGroupId||t)))}))]})),T&&L&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Buy Credits"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null===(v=q.buyUses)||void 0===v?void 0:v.map(((e,t)=>s.jsx(j,{price:e.price,uses:e.uses,isSelected:t===_,onClick:()=>A(t),colors:w},t)))})),s.jsxs(d.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>{return s=L.uses,t=L.price,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield p.default.post("/get_extra_usage_payment_link",{data:{sender:C||void 0,studioSessionToken:N,studioId:null==k?void 0:k.studioid,cost:t,extraUses:s,successUrl:document.URL}});if(e.data.success){const s=e.data.url;if(i.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}}));var s,t}},{children:["Buy ",L.uses.toLocaleString()," Uses for $",L.price]}))]}))]}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),s=require("react"),r=require("../../hooks/pickaxe/usePickaxeContext.js"),a=require("./Addons/Auth/hooks/useAuthContext.js"),i=require("../../hooks/pickaxe/useResponseContext.js"),l=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),u=require("./Addons/Scroll/Provider.js"),c=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),d=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js");exports.Pickaxe=({pickaxeId:m,className:j})=>{const{sessionId:h,styles:k,colors:w,responsiveBy:g,deploymentType:C,isNewChat:q,isEmailLogin:v,opacity:y,setContextId:A,setPickaxeId:P,setSessionId:N,setPickaxe:b}=r.usePickaxeContext(),{isLoggedOut:S,isSent:O}=a.useAuthContext(),{setMessages:E,setResponse:I,setError:D,setLimitData:F,setIsSwitchedToChat:L}=i.useResponseContext(),{setDocumentError:M}=l.useDocumentContext(),{setCurrentArtifact:R}=o.useArtifactContext(),[T,$]=s.useState(!1),_=t.usePickaxe(),B="chat-input"===C&&q&&!O,H="chat-input"!==C||!O;s.useEffect((()=>{P(m)}),[m]),s.useEffect((()=>{if(!_.data)return;const e=_.data.chatflag;N(e?n.v4():""),A(n.v4()),e?E([]):I(null),D(""),M(""),F(null),R(null),L(!1),b(_.data),$(!0)}),[_.data]),s.useEffect((()=>{D(""),M(""),F(null),E([]),I(null),R(null)}),[h]);const W=s.useMemo((()=>{const e=null!=y?y:1;if(!w.primary||!w.primary.startsWith("#")||e<0||e>1)return w.primary;const t=Math.round(255*e).toString(16).padStart(2,"0");return`${w.primary}${t}`}),[w.primary,y]);return _.data?e.jsx("div",Object.assign({className:f.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===k.theme&&"dark",j),style:Object.assign({backgroundColor:B?"transparent":W,color:w.text},k.font&&"Real Head Pro"!==k.font&&{fontFamily:k.font})},{children:v&&S&&H?e.jsx(p.default,{}):e.jsx(e.Fragment,{children:_.isLoading||!T?e.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===g?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:e.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[e.jsx(c.default,{className:"w-[72px] h-[72px]"}),e.jsx(c.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(c.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(c.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),e.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:e.jsx(c.default,{className:f.default("w-full min-h-[48px]","viewport"===g?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):e.jsx(e.Fragment,{children:h?e.jsx(u.ScrollProvider,{children:e.jsx(x.default,{})}):e.jsx(u.ScrollProvider,{children:e.jsx(d.default,{})})})})})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js");exports.Pickaxe=({pickaxeId:g,className:b})=>{const{sessionId:v,styles:w,colors:y,responsiveBy:k,deploymentType:q,isNewChat:N,isEmailLogin:O,isEmbed:C,opacity:A,deploymentId:_,sender:P,portalId:S,setContextId:I,setPickaxeId:E,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isLoggedOut:R,isSent:M,token:T}=l.useAuthContext(),{setMessages:U,setResponse:F,setError:G,setLimitData:$,setIsSwitchedToChat:B}=r.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:W}=o.useArtifactContext(),[z,J]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===q&&N&&!M,te="chat-input"!==q||!M;a.useEffect((()=>{E(g)}),[g]),a.useEffect((()=>{if(!_||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:_,sender:P||void 0,studioSessionToken:T,portalId:S,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),J(!0)):"Access denied."===s.data.message?(Q("access_denied"),J(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),J(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[_,P,T,S,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),I(n.v4()),e?U([]):F(null),G(""),H(""),$(null),W(null),B(!1),L(ee.data),J(!0)}),[ee.data]),a.useEffect((()=>{G(""),H(""),$(null),U([]),F(null),W(null)}),[v]);const ae=a.useMemo((()=>{const e=null!=A?A:1;if(!y.primary||!y.primary.startsWith("#")||e<0||e>1)return y.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${y.primary}${s}`}),[y.primary,A]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",b),style:Object.assign({backgroundColor:se?"transparent":ae,color:y.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!z||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===k?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C||O&&R&&te?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):v?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};
@@ -65,6 +65,7 @@ type PickaxeContextType = {
65
65
  deploymentType?: PickaxeDeploymentEmbedType;
66
66
  deploymentDimensions?: PickaxeDeploymentDimensions;
67
67
  deploymentMisc?: PickaxeDeploymentMisc;
68
+ portalId?: string;
68
69
  pickaxe: LimitedPickaxe | null;
69
70
  styles: PickaxeProviderStyles;
70
71
  colors: PickaxeProviderColors;
@@ -107,6 +108,7 @@ export interface IPickaxeProviderProps {
107
108
  sender?: string;
108
109
  senderType: PickaxeHistorySenderType;
109
110
  deploymentId?: string;
111
+ portalId?: string;
110
112
  deploymentType?: PickaxeDeploymentEmbedType;
111
113
  deploymentDimensions?: PickaxeDeploymentDimensions;
112
114
  deploymentMisc?: PickaxeDeploymentMisc;
@@ -132,5 +134,5 @@ export interface IPickaxeProviderProps {
132
134
  onGenerateComplete?: (responseId: string) => void;
133
135
  }
134
136
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
135
- export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, isEmailLogin, allowGuestUsage, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
137
+ export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, portalId, deploymentId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, isEmailLogin, allowGuestUsage, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
136
138
  export {};
@@ -3,9 +3,12 @@ import type { MemoryStoredChatMessage, MemoryStoredFormResponse } from "../../ty
3
3
  import { type ReactNode } from "react";
4
4
  export type ResponseStatus = "fetching" | "streaming" | "idle";
5
5
  export type PickaxeLimitData = {
6
- html: string;
7
- cta: string;
8
- ctaLink: string;
6
+ limitMessage: string;
7
+ buyUses?: any[];
8
+ upgradeGroups?: any[];
9
+ limitLink?: string;
10
+ limitCTA: string;
11
+ accessGroupId: string;
9
12
  };
10
13
  type ResponseContextType = {
11
14
  messages: MemoryStoredChatMessage[];
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+ interface AccessGroupCardPreviewProps {
3
+ data: any;
4
+ accessGroupId?: string;
5
+ upgradeUrl?: string | null;
6
+ children?: ReactNode;
7
+ }
8
+ declare const AccessGroupCardPreview: ({ data, children, upgradeUrl, }: AccessGroupCardPreviewProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default AccessGroupCardPreview;
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import * as AvatarPrimitive from "@radix-ui/react-avatar";
3
+ declare const Avatar: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
4
+ declare const AvatarImage: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
5
+ declare const AvatarFallback: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
6
+ export type AvatarGroupItem = {
7
+ src?: string;
8
+ initials: string;
9
+ };
10
+ export interface AvatarGroupProps extends React.HTMLAttributes<HTMLDivElement> {
11
+ data: AvatarGroupItem[];
12
+ max?: number;
13
+ avatarClassName?: string;
14
+ }
15
+ declare const AvatarGroup: React.ForwardRefExoticComponent<AvatarGroupProps & React.RefAttributes<HTMLDivElement>>;
16
+ export { Avatar, AvatarImage, AvatarFallback, AvatarGroup };
@@ -0,0 +1,2 @@
1
+ export declare const intervalToSuffix: (interval: string | null, isFullText?: boolean) => "/daily" | "/day" | "/weekly" | "/wk" | "/monthly" | "/mo" | "/yearly" | "/yr" | "";
2
+ export declare const STUDIO_INFINITY_VALUE = -1337;
@@ -0,0 +1,7 @@
1
+ export declare const currencyOptions: {
2
+ id: string;
3
+ label: string;
4
+ min: number;
5
+ symbol: string;
6
+ decimals: number;
7
+ }[];
@@ -3,5 +3,5 @@ interface PickaxeUpgradeCardProps {
3
3
  iconClassName?: string;
4
4
  htmlClassName?: string;
5
5
  }
6
- declare const PickaxeUpgradeCard: ({ className, iconClassName, htmlClassName, }: PickaxeUpgradeCardProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const PickaxeUpgradeCard: ({ className, iconClassName, htmlClassName, }: PickaxeUpgradeCardProps) => import("react/jsx-runtime").JSX.Element | null;
7
7
  export default PickaxeUpgradeCard;
@@ -10,6 +10,7 @@ export declare const usePickaxeContext: () => {
10
10
  deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
11
11
  deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
12
12
  deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
13
+ portalId?: string | undefined;
13
14
  pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
14
15
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
15
16
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
@@ -9,3 +9,11 @@ export type MemoryStoredFormResponse = {
9
9
  messageCount: number;
10
10
  sentAt: Date;
11
11
  };
12
+ export interface LimitData {
13
+ limitMessage: string;
14
+ buyUses?: any[];
15
+ upgradeGroups?: any[];
16
+ limitLink?: string;
17
+ accessGroupId?: string;
18
+ limitCTA?: string;
19
+ }
@@ -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 E,T,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isEmailLogin:K,isShowIceBreaker:Q,setSessionId:X,setLastSessionId:Y}=o(),{emailInput:Z,isLoggedOut:ee,isSending:se,isResendDisabled:ie,isSent: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"===$&&K&&ee&&te,ye=Q&&!R&&!be&&xe&&me>767,ke=Q&&!R&&(be||me<=767),we=()=>{Y(W),X("")};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:Z}))]}))})),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:()=>{ie||se||ae(!0)}},{children:se?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!==(T=null===(E=he.data)||void 0===E?void 0:E.messages)&&void 0!==T?T:[]).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-[80%] 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 E,T,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isEmailLogin:K,isShowIceBreaker:Q,setSessionId:X,setLastSessionId:Y}=o(),{emailInput:Z,isLoggedOut:ee,isSending:se,isResendDisabled:ie,isSent: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"===$&&K&&ee&&te,ye=Q&&!R&&!be&&xe&&me>767,ke=Q&&!R&&(be||me<=767),we=()=>{Y(W),X("")};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:Z}))]}))})),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:()=>{ie||se||ae(!0)}},{children:se?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!==(T=null===(E=he.data)||void 0===E?void 0:E.messages)&&void 0!==T?T:[]).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 n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as x}from"../Addons/Document/hooks/useDocument.js";import{useScroll as j}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as w}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as N,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import _ from"../../Icons/arrow-right.svg.js";import A from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import R from"../../Core/Textarea.js";import L from"../../Core/ErrorAlert.js";import D from"../../../common/error.js";import $ from"../../../common/cn.js";const W=i((({resubmitPrompt:i,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,M,V;const{origin:K,pickaxeId:X,sessionId:z,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:ie,isEmailLogin:re,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,limits:he,isGenerating:ge,setMessages:ve,setStatus:be,setLimitData:ye,setError:xe}=f(),{documents:je,isUploading:we,documentError:Oe,onFileUpload:ke,setDocuments:Se,setDocumentError:Ne}=x(),{scrollStartSession:Ie,scrollEndSession:Ce,scrollToBottom:Ee}=j({auto:!0}),{artifacts:_e,currentPopupType:Ae,setArtifacts:Te,setCurrentArtifact:Pe}=w(),{height:Re}=b(),Le=v(),[De,$e]=r(""),[We,Be]=r(!1),[He,Fe]=r(!1),Je=a(null),Ue=a(""),Me=a(null),Ve=a(null),Ke=a(null),Xe=a(null),ze=a(null),qe=Math.max(.4*Re,100),{transcript:Ge,listening:Qe,resetTranscript:Ye,browserSupportsSpeechRecognition:Ze}=m(),[et]=k("(max-width: 480px)"),tt=O(),{isHover:nt}=tt,st=e(tt,["isHover"]),ot=O(),{isHover:it}=ot,rt=e(ot,["isHover"]),at=O(),{isHover:lt}=at,ct=e(at,["isHover"]),dt=g(),ut=h(),mt="undefined"!=typeof window?window.location.hostname:"",pt="undefined"!=typeof window?window.location.href:"",ft="undefined"!=typeof window&&window.self!==window.top,ht=mt.includes("pickaxe.co")&&!pt.includes("https://studio.pickaxe.co/_embed")&&!ft,gt=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),vt=Ze&&(null==Z?void 0:Z.enablevoicetotext),bt="chat-input"===Y&&oe&&!pe,yt="chat-input"===Y&&re&&me&&pe,xt=null!==(M=null==Z?void 0:Z.placeholdertext)&&void 0!==M?M:ie?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",jt=We||He,wt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!Le.isLoading&&(!((null!==(t=null===(e=Le.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!bt)))))}),[Z,oe,ae,bt,Le.data,Le.isLoading]),Ot=l((()=>{if(ge||we)return!1;const e=je.length>0&&je.every((e=>"finished"===e.status));return!(!De.trim()&&!e)&&je.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ge,we,De,je]);c(J,(()=>({onSubmit:kt}))),d((()=>{ce(wt)}),[wt]),d((()=>{var e;if(i){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;kt(n,!0)}}),[i]),d((()=>{if(!Xe.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(Xe.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Qe)return;const e=Ue.current?`${Ue.current} `:"";$e(`${e}${Ge}`)}),[Ge,Qe]),d((()=>{if(!Ve.current)return;(()=>{if(!Ve.current)return;let e=Ve.current.scrollHeight>52;De.includes("\n")||je.length?e=!0:De.trim()||(e=!1),Be(e)})()}),[De,je]),d((()=>{const e=Ve.current,t=Ke.current;if(!e||!t||We||De.includes("\n"))return void Fe(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=De||xt,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Fe(i>l)}),[De,We,xt]);const kt=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(ge||we)return;const i=je.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:De;if(!c&&!l)return;xe(""),Ne(""),ye(null),$e(""),le(!1),be("fetching"),Ie(),Ee();const d=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ve(u),Ee(),d&&Se([]);const m=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:K,pickaxeId:X,sessionId:z,senderType:G,value:c},d&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ht&&{credentials:"include"})),p=yield m.json();if(!p.success)throw new Error(p.error||"Failed to start generation");const f=p.submissionId;be("streaming"),ze.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=_e?_e:[]],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=ze.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();Me.current=t;const n=new TextDecoder,s=C({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return xe(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ve([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:fe.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"})),Te([...v]),Ae.startsWith("inline")||Pe({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"})),Te(v),Ae.startsWith("inline")||Pe({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"})),Te(v),Ae.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=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+n,status:"streaming"}):e)),Te(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(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);xe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.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==de||de(z)}catch(e){let t=D(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(he).find((([e])=>t.includes(e)));n?ye(n[1]):xe(t)}finally{Ee(),be("idle"),Ce(),Me.current=null}}));return yt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!bt&&"px-4 pb-8"),dir:ie?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:Xe,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ut),{maxHeight:`${qe}px`,overflowY:"auto"})},{children:[Qe&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(V=te.accent)&&void 0!==V?V:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!ge&&je.length>0&&n(P,{className:"p-4 pb-0",isDisabled:ge}),n(R,Object.assign({ref:Ve,className:$(dt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!De.trim()&&!De.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ie?"text-right":"text-left",jt&&"mb-12",Qe&&"text-transparent"),value:De,placeholder:xt,onChange:e=>{if($e(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),we||ge||kt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield ke(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:ie?"rtl":"ltr"})),n("div",Object.assign({ref:Ke,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",jt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!jt&&ut.backgroundColor&&{backgroundColor:ut.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:ge?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ze.current&&(ze.current.abort(),ze.current=null),Me.current&&(Me.current.cancel(),Me.current=null),be("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):Qe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[gt&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:it?te.accent+"10":void 0,color:it?te.accent:te.accent+"80"},disabled:we||ge,onClick:()=>{var e;return null===(e=Je.current)||void 0===e?void 0:e.click()}},rt,{children:[n("input",{id:"file-upload",ref:Je,type:"file",accept:[...S,...N,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),vt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Qe?te.accent:lt?te.accent+"10":void 0,color:Qe?te.accentText:lt?te.accent:te.accent+"80"},disabled:we||ge,onClick:()=>{Qe?u.stopListening():(Ue.current=De,Ye(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},ct,{children:n(A,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||Ot?te.accent:te.accent+"10",color:nt||Ot?te.accentText:te.accent+"80"},disabled:!Ot,onClick:()=>kt()},st,{children:n(_,{className:$("h-6 w-6 shrink-0",ie&&"scale-x-[-1] transform")})}))]})}))]})),Oe&&n(L,{error:Oe,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as x}from"../Addons/Document/hooks/useDocument.js";import{useScroll as j}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as w}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as N,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import _ from"../../Icons/arrow-right.svg.js";import A from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import D from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const W=i((({resubmitPrompt:i,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,M,V;const{origin:K,pickaxeId:X,sessionId:z,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:ie,isEmailLogin:re,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,isGenerating:he,setMessages:ge,setStatus:ve,setLimitData:be,setError:ye}=f(),{documents:xe,isUploading:je,documentError:we,onFileUpload:Oe,setDocuments:ke,setDocumentError:Se}=x(),{scrollStartSession:Ne,scrollEndSession:Ie,scrollToBottom:Ce}=j({auto:!0}),{artifacts:Ee,currentPopupType:_e,setArtifacts:Ae,setCurrentArtifact:Te}=w(),{height:De}=b(),Pe=v(),[Re,Le]=r(""),[$e,We]=r(!1),[Be,He]=r(!1),Fe=a(null),Je=a(""),Ue=a(null),Me=a(null),Ve=a(null),Ke=a(null),Xe=a(null),ze=Math.max(.4*De,100),{transcript:qe,listening:Ge,resetTranscript:Qe,browserSupportsSpeechRecognition:Ye}=m(),[Ze]=k("(max-width: 480px)"),et=O(),{isHover:tt}=et,nt=e(et,["isHover"]),st=O(),{isHover:ot}=st,it=e(st,["isHover"]),rt=O(),{isHover:at}=rt,lt=e(rt,["isHover"]),ct=g(),dt=h(),ut="undefined"!=typeof window?window.location.hostname:"",mt="undefined"!=typeof window?window.location.href:"",pt="undefined"!=typeof window&&window.self!==window.top,ft=ut.includes("pickaxe.co")&&!mt.includes("https://studio.pickaxe.co/_embed")&&!pt,ht=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),gt=Ye&&(null==Z?void 0:Z.enablevoicetotext),vt="chat-input"===Y&&oe&&!pe,bt="chat-input"===Y&&re&&me&&pe,yt=null!==(M=null==Z?void 0:Z.placeholdertext)&&void 0!==M?M:ie?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",xt=$e||Be,jt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!Pe.isLoading&&(!((null!==(t=null===(e=Pe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!vt)))))}),[Z,oe,ae,vt,Pe.data,Pe.isLoading]),wt=l((()=>{if(he||je)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Re.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[he,je,Re,xe]);c(J,(()=>({onSubmit:Ot}))),d((()=>{ce(jt)}),[jt]),d((()=>{var e;if(i){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ot(n,!0)}}),[i]),d((()=>{if(!Ke.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(Ke.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Ge)return;const e=Je.current?`${Je.current} `:"";Le(`${e}${qe}`)}),[qe,Ge]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;Re.includes("\n")||xe.length?e=!0:Re.trim()||(e=!1),We(e)})()}),[Re,xe]),d((()=>{const e=Me.current,t=Ve.current;if(!e||!t||$e||Re.includes("\n"))return void He(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Re||yt,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;He(i>l)}),[Re,$e,yt]);const Ot=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(he||je)return;const i=xe.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:Re;if(!c&&!l)return;ye(""),Se(""),be(null),Le(""),le(!1),ve("fetching"),Ne(),Ce();const d=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ge(u),Ce(),d&&ke([]);const m=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:K,pickaxeId:X,sessionId:z,senderType:G,value:c},d&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ft&&{credentials:"include"})),p=yield m.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const f=p.submissionId;ve("streaming"),Xe.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Ee?Ee:[]],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=Xe.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();Ue.current=t;const n=new TextDecoder,s=C({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return ye(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ge([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:fe.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"})),Ae([...v]),_e.startsWith("inline")||Te({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"})),Ae(v),_e.startsWith("inline")||Te({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"})),Ae(v),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),Ae(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ae(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);ye(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.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==de||de(z)}catch(e){if(e.limitData)be(e.limitData),ye("");else{let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),ye(t)}}finally{Ce(),ve("idle"),Ie(),Ue.current=null}}));return bt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!vt&&"px-4 pb-8"),dir:ie?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:Ke,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},dt),{maxHeight:`${ze}px`,overflowY:"auto"})},{children:[Ge&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(V=te.accent)&&void 0!==V?V:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!he&&xe.length>0&&n(D,{className:"p-4 pb-0",isDisabled:he}),n(P,Object.assign({ref:Me,className:$(ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Re.trim()&&!Re.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ie?"text-right":"text-left",xt&&"mb-12",Ge&&"text-transparent"),value:Re,placeholder:yt,onChange:e=>{if(Le(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||Ze||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),je||he||Ot()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield Oe(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:ie?"rtl":"ltr"})),n("div",Object.assign({ref:Ve,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",xt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!xt&&dt.backgroundColor&&{backgroundColor:dt.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:he?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Xe.current&&(Xe.current.abort(),Xe.current=null),Ue.current&&(Ue.current.cancel(),Ue.current=null),ve("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):Ge?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[ht&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ot?te.accent+"10":void 0,color:ot?te.accent:te.accent+"80"},disabled:je||he,onClick:()=>{var e;return null===(e=Fe.current)||void 0===e?void 0:e.click()}},it,{children:[n("input",{id:"file-upload",ref:Fe,type:"file",accept:[...S,...N,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield Oe(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),gt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ge?te.accent:at?te.accent+"10":void 0,color:Ge?te.accentText:at?te.accent:te.accent+"80"},disabled:je||he,onClick:()=>{Ge?u.stopListening():(Je.current=Re,Qe(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},lt,{children:n(A,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:tt||wt?te.accent:te.accent+"10",color:tt||wt?te.accentText:te.accent+"80"},disabled:!wt,onClick:()=>Ot()},nt,{children:n(_,{className:$("h-6 w-6 shrink-0",ie&&"scale-x-[-1] transform")})}))]})}))]})),we&&n(R,{error:we,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};