@pickaxeproject/react 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) 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/Chat/index.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  5. package/dist/cjs/components/Pickaxe/common/PickaxeHead.js +1 -1
  6. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  7. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
  8. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  9. package/dist/cjs/components/Pickaxe/index.js +1 -1
  10. package/dist/cjs/hooks/pickaxe/usePickaxe.js +1 -1
  11. package/dist/cjs/index.js +1 -1
  12. package/dist/cjs/prose.css +1 -1
  13. package/dist/cjs/src/components/EmbedPreview/ChatInput.d.ts +9 -0
  14. package/dist/cjs/src/components/EmbedPreview/FAB.d.ts +10 -0
  15. package/dist/cjs/src/components/EmbedPreview/Inline.d.ts +5 -0
  16. package/dist/cjs/src/components/EmbedPreview/Popup.d.ts +10 -0
  17. package/dist/cjs/src/components/Pickaxe/Chat/Input.d.ts +3 -3
  18. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +31 -5
  19. package/dist/cjs/src/components/Pickaxe/common/PickaxeHead.d.ts +2 -2
  20. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
  21. package/dist/cjs/src/hooks/pickaxe/usePickaxe.d.ts +1 -0
  22. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +6 -2
  23. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  24. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  25. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  26. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  27. package/dist/esm/components/Pickaxe/common/PickaxeHead.js +1 -1
  28. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  29. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
  30. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  31. package/dist/esm/components/Pickaxe/index.js +1 -1
  32. package/dist/esm/hooks/pickaxe/usePickaxe.js +1 -1
  33. package/dist/esm/index.js +1 -1
  34. package/dist/esm/prose.css +1 -1
  35. package/dist/esm/src/components/EmbedPreview/ChatInput.d.ts +9 -0
  36. package/dist/esm/src/components/EmbedPreview/FAB.d.ts +10 -0
  37. package/dist/esm/src/components/EmbedPreview/Inline.d.ts +5 -0
  38. package/dist/esm/src/components/EmbedPreview/Popup.d.ts +10 -0
  39. package/dist/esm/src/components/Pickaxe/Chat/Input.d.ts +3 -3
  40. package/dist/esm/src/components/Pickaxe/Provider.d.ts +31 -5
  41. package/dist/esm/src/components/Pickaxe/common/PickaxeHead.d.ts +2 -2
  42. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
  43. package/dist/esm/src/hooks/pickaxe/usePickaxe.d.ts +1 -0
  44. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +6 -2
  45. package/package.json +1 -1
  46. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledAttachmentGrid.d.ts +0 -7
  47. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledIconButton.d.ts +0 -10
  48. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledImagePreview.d.ts +0 -12
  49. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledInputContainer.d.ts +0 -13
  50. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledInputWrapper.d.ts +0 -13
  51. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledRemoveButton.d.ts +0 -13
  52. package/dist/cjs/src/components/Pickaxe/ui/Input/StyledTextareaWrapper.d.ts +0 -8
  53. package/dist/cjs/src/components/Pickaxe/ui/Message/StyledIconWrapper.d.ts +0 -11
  54. package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessage.d.ts +0 -10
  55. package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessageBubble.d.ts +0 -14
  56. package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessageContainer.d.ts +0 -10
  57. package/dist/cjs/src/components/Pickaxe/ui/StyledCopyButton.d.ts +0 -12
  58. package/dist/cjs/src/components/Pickaxe/ui/StyledDocumentCard.d.ts +0 -25
  59. package/dist/cjs/src/components/Pickaxe/ui/StyledIceBreaker.d.ts +0 -20
  60. package/dist/cjs/src/components/Pickaxe/ui/StyledLoadingDots.d.ts +0 -9
  61. package/dist/cjs/src/components/Pickaxe/ui/index.d.ts +0 -20
  62. package/dist/cjs/src/components/Pickaxe/ui/types.d.ts +0 -5
  63. package/dist/esm/src/components/Pickaxe/ui/Input/StyledAttachmentGrid.d.ts +0 -7
  64. package/dist/esm/src/components/Pickaxe/ui/Input/StyledIconButton.d.ts +0 -10
  65. package/dist/esm/src/components/Pickaxe/ui/Input/StyledImagePreview.d.ts +0 -12
  66. package/dist/esm/src/components/Pickaxe/ui/Input/StyledInputContainer.d.ts +0 -13
  67. package/dist/esm/src/components/Pickaxe/ui/Input/StyledInputWrapper.d.ts +0 -13
  68. package/dist/esm/src/components/Pickaxe/ui/Input/StyledRemoveButton.d.ts +0 -13
  69. package/dist/esm/src/components/Pickaxe/ui/Input/StyledTextareaWrapper.d.ts +0 -8
  70. package/dist/esm/src/components/Pickaxe/ui/Message/StyledIconWrapper.d.ts +0 -11
  71. package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessage.d.ts +0 -10
  72. package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessageBubble.d.ts +0 -14
  73. package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessageContainer.d.ts +0 -10
  74. package/dist/esm/src/components/Pickaxe/ui/StyledCopyButton.d.ts +0 -12
  75. package/dist/esm/src/components/Pickaxe/ui/StyledDocumentCard.d.ts +0 -25
  76. package/dist/esm/src/components/Pickaxe/ui/StyledIceBreaker.d.ts +0 -20
  77. package/dist/esm/src/components/Pickaxe/ui/StyledLoadingDots.d.ts +0 -9
  78. package/dist/esm/src/components/Pickaxe/ui/index.d.ts +0 -20
  79. package/dist/esm/src/components/Pickaxe/ui/types.d.ts +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),t=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:v})=>{var w;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:O,isRtl:q,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:L,status:E,limitData:M,error:A}=l.useResponseContext(),{height:H}=t.useDimensionContext(),R=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),z=s.useMemo((()=>!g&&N.isSuccess&&O&&!R),[g,N.isSuccess,O,R]),D=s.useMemo((()=>{var e,s;return!!L.length&&!(null!==(s=null===(e=null==L?void 0:L[L.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[L]);return e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${H}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(z||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!z&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",z&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!z&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!z&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[O&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.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."]}))})):N.data?e.jsxs("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:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),L.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===E||D?e.jsx("div",Object.assign({className:p.default("flex w-full",q?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:"flex flex-col"},{children:e.jsxs("div",Object.assign({className:p.default("flex gap-x-3",q&&"flex-row-reverse")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(w=null==k?void 0:k.chaticon)&&void 0!==w?w:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]}))}))})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",q?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:v})=>{var w;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:O,isRtl:q,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:E,status:L,limitData:M,error:A}=t.useResponseContext(),{height:D}=l.useDimensionContext(),H=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),R=s.useMemo((()=>!g&&N.isSuccess&&O&&!H),[g,N.isSuccess,O,H]),z=s.useMemo((()=>{var e,s;return!!E.length&&!(null!==(s=null===(e=null==E?void 0:E[E.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[E]);return e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${D}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(R||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!R&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",R&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!R&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!R&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[O&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.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."]}))})):N.data?e.jsxs("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:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),E.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===L||z?e.jsx("div",Object.assign({className:p.default("flex w-full",q?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:"flex flex-col"},{children:e.jsxs("div",Object.assign({className:p.default("flex gap-x-3",q&&"flex-row-reverse")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(w=null==k?void 0:k.chaticon)&&void 0!==w?w:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]}))}))})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",q?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),i=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),u=require("../../../hooks/core/useHover.js"),m=require("../../../common/utils.js"),f=require("../../../common/documents.js"),x=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),p=require("../../Icons/spinner-lines.svg.js"),g=require("../../Icons/file.svg.js"),b=require("../../Icons/x.svg.js"),j=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),k=require("../../../common/error.js"),w=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:N,onBlur:O})=>{var C;const{formId:q,chatId:S,userId:R,studioUserId:_,embedUserId:T,deploymentId:A,pickaxe:F,styles:B,colors:D,responsiveBy:U,isNewChat:H,isRtl:E,setIsNewChat:z,setIsShowIceBreaker:M,onGenerateComplete:P}=r.usePickaxeContext(),{messages:L,status:$,limits:G,isGenerating:J,setMessages:K,setStatus:W,setLimitData:Q,setError:V}=o.useResponseContext(),{documents:X,isUploading:Y,isImageUploadAllowed:Z,setDocuments:ee,onFileUpload:se}=d.useDocument(),{scrollStartSession:te,scrollEndSession:re,scrollToBottom:oe}=c.useScroll({auto:!0}),le=a.useConversation(),ie=n.useSubmit(),[ae,ne]=t.useState(""),de=t.useRef(null),ce=u.useHover(),{isHover:ue}=ce,me=e.__rest(ce,["isHover"]),fe=u.useHover(),{isHover:xe}=fe,he=e.__rest(fe,["isHover"]),pe=i.useStyleFontSize(),ge=l.useStyleInput(),be=t.useMemo((()=>{var e,s,t;return!!H&&(!!F&&(!le.isLoading&&(!((null!==(s=null===(e=le.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=F.icebreakers)||void 0===t?void 0:t.length))))}),[F,H,le.data,le.isLoading]),je=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==$||Y)return;const e=null!=s?s:ae;if(!e)return;V(""),Q(null),ne(""),z(!1),W("fetching"),te(),oe();const t=X.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=t.length?t[t.length-1].documentId:"",o="enduserupload"===(null==F?void 0:F.documentuploadtype)&&r,l=[...Array.from(L),Object.assign({id:L.length+1,role:"user",content:e},o&&{documentIds:[r]})];K(l),oe(),o&&ee([]);const i=(yield ie.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:q,responseId:S,value:e},o&&{documentId:r}),R&&{userId:R}),_&&{studioUserId:_}),T&&{embedUserId:T}),A&&{deploymentId:A}))).body;if(!i)throw new Error("Streaming error");const a=l.length,n=new TextDecoder,d=i.getReader();let c="",u=!0,m=!1;const f=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=s,K([...l.slice(0,a),{id:L.length+1,role:"assistant",content:c}])}else if("error"===e.event){const s=JSON.parse(e.data);V(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:s}=yield d.read();if(s){u=!1;break}const t=n.decode(e);t&&(m||(W("streaming"),m=!0),f.feed(t))}null==P||P(S)}catch(e){let s=k.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s)}finally{oe(),W("idle"),re()}}));return t.useEffect((()=>{M(be)}),[be]),s.jsx("div",Object.assign({className:"px-4 pb-4 w-full flex flex-col items-center absolute bottom-0 left-0 z-1",dir:E?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[s.jsx("div",Object.assign({className:w.default("absolute bottom-full",E?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:w.default("flex flex-col gap-2 pb-4 px-2",E?"justify-start":"justify-end","viewport"===U?E?"min-[767px]:items-start":"min-[767px]:items-end":E?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:be&&!I&&s.jsx(v.default,{data:(null==F?void 0:F.icebreakers)||[],onSend:je})}))})),s.jsxs("div",Object.assign({className:w.default("flex flex-col gap-y-2 px-4 py-3","block"===B.formFieldStyle&&"shadow"),style:ge},{children:["idle"===$&&X.length>0&&s.jsx("div",Object.assign({className:w.default("grid grid-cols-1","viewport"===U?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:X.map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:w.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",E&&"flex-row-reverse"),style:{borderRadius:ge.borderRadius,borderColor:D.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:D.accent,borderRadius:ge.borderRadius}},{children:Y?s.jsx(p.default,{className:"w-5 h-5 animate-spin",style:{color:D.accentText}}):s.jsx(g.default,{className:"w-5 h-5",style:{color:D.accentText}})})),s.jsxs("div",Object.assign({className:w.default("flex flex-col justify-center truncate",E?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(w.default(pe.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:w.default(pe.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",E?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:D.accent,borderColor:ge.backgroundColor},disabled:Y||"idle"!==$,onClick:()=>ee([])},{children:s.jsx(b.default,{className:"w-4 h-4",style:{color:D.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ge.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ge.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[1]}.${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ge.borderRadius,backgroundColor:D.secondary}}),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",E?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:D.accent,borderColor:ge.backgroundColor},disabled:Y||"idle"!==$,onClick:()=>ee([])},{children:s.jsx(b.default,{className:"w-4 h-4",style:{color:D.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:w.default("flex items-end gap-x-2",E&&"flex-row-reverse")},{children:[s.jsx(y.default,{className:w.default(pe.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!ae.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",E?"text-right":"text-left"),value:ae,placeholder:E?"بماذا تريد أن تتحدث؟":null!==(C=null==F?void 0:F.placeholdertext)&&void 0!==C?C:"What do you want to talk about?",onChange:e=>ne(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Y||"idle"!==$||je()))},onFocus:N,onBlur:O,dir:E?"rtl":"ltr"}),s.jsxs("div",Object.assign({className:w.default("flex items-center gap-x-2")},{children:["enduserupload"===(null==F?void 0:F.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:xe?D.accent+"10":void 0},disabled:Y||"idle"!==$,onClick:()=>{var e;return null===(e=de.current)||void 0===e?void 0:e.click()}},he,{children:[s.jsx("input",{id:"file-upload",ref:de,type:"file",accept:[...f.allowedFileMimeTypes,...Z?f.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield se(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(h.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:xe?D.accent:D.accent+"80"}})]})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(ue||ae.length||X.length&&X.every((e=>"finished"===e.status)))&&!J?D.accent:D.accent+"10"},disabled:Y||"idle"!==$,onClick:()=>je()},me,{children:s.jsx(j.default,{className:w.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",E&&"transform scale-x-[-1]"),style:{color:(ue||ae.length||X.length&&X.every((e=>"finished"===e.status)))&&!J?D.accentText:D.accent+"80"}})}))]}))]}))]}))]}))}))};
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("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),u=require("../../../hooks/core/useHover.js"),m=require("../../../common/utils.js"),f=require("../../../common/documents.js"),x=require("eventsource-parser"),p=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),g=require("../../Icons/file.svg.js"),b=require("../../Icons/x.svg.js"),j=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),k=require("../../../common/error.js"),w=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:N,onBlur:O})=>{var C;const{formId:q,chatId:S,userId:R,studioUserId:T,embedUserId:_,deploymentId:A,deploymentType:F,pickaxe:B,styles:D,colors:U,responsiveBy:H,isNewChat:E,isRtl:z,setIsNewChat:M,setIsShowIceBreaker:P,onGenerateComplete:L}=r.usePickaxeContext(),{messages:$,status:G,limits:J,isGenerating:K,setMessages:W,setStatus:Q,setLimitData:V,setError:X}=o.useResponseContext(),{documents:Y,isUploading:Z,isImageUploadAllowed:ee,setDocuments:se,onFileUpload:te}=d.useDocument(),{scrollStartSession:re,scrollEndSession:oe,scrollToBottom:le}=c.useScroll({auto:!0}),ae=i.useConversation(),ie=n.useSubmit(),[ne,de]=t.useState(""),ce=t.useRef(null),ue=u.useHover(),{isHover:me}=ue,fe=e.__rest(ue,["isHover"]),xe=u.useHover(),{isHover:pe}=xe,he=e.__rest(xe,["isHover"]),ge=a.useStyleFontSize(),be=l.useStyleInput(),je=t.useMemo((()=>{var e,s,t;return!!E&&(!!B&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=B.icebreakers)||void 0===t?void 0:t.length))))}),[B,E,ae.data,ae.isLoading]),ve=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==G||Z)return;const e=null!=s?s:ne;if(!e)return;X(""),V(null),de(""),M(!1),Q("fetching"),re(),le();const t=Y.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=t.length?t[t.length-1].documentId:"",o="enduserupload"===(null==B?void 0:B.documentuploadtype)&&r,l=[...Array.from($),Object.assign({id:$.length+1,role:"user",content:e},o&&{documentIds:[r]})];W(l),le(),o&&se([]);const a=(yield ie.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:q,responseId:S,value:e},o&&{documentId:r}),R&&{userId:R}),T&&{studioUserId:T}),_&&{embedUserId:_}),A&&{deploymentId:A}))).body;if(!a)throw new Error("Streaming error");const i=l.length,n=new TextDecoder,d=a.getReader();let c="",u=!0,m=!1;const f=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=s,W([...l.slice(0,i),{id:$.length+1,role:"assistant",content:c}])}else if("error"===e.event){const s=JSON.parse(e.data);X(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:s}=yield d.read();if(s){u=!1;break}const t=n.decode(e);t&&(m||(Q("streaming"),m=!0),f.feed(t))}null==L||L(S)}catch(e){let s=k.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(J).find((([e])=>s.includes(e)));t?V(t[1]):X(s)}finally{le(),Q("idle"),oe()}}));return t.useEffect((()=>{P(je)}),[je]),s.jsx("div",Object.assign({className:w.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===F&&E)&&"px-4 pb-4"),dir:z?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===F&&E)&&s.jsx("div",Object.assign({className:w.default("absolute bottom-full",z?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:w.default("flex flex-col gap-2 pb-4 px-2",z?"justify-start":"justify-end","viewport"===H?z?"min-[767px]:items-start":"min-[767px]:items-end":z?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:je&&!I&&s.jsx(v.default,{data:(null==B?void 0:B.icebreakers)||[],onSend:ve})}))})),s.jsxs("div",Object.assign({className:w.default("flex flex-col gap-y-2 px-4 py-3","block"===D.formFieldStyle&&"shadow"),style:be},{children:["idle"===G&&Y.length>0&&s.jsx("div",Object.assign({className:w.default("grid grid-cols-1","viewport"===H?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Y.map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:w.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",z&&"flex-row-reverse"),style:{borderRadius:be.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:be.borderRadius}},{children:Z?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(g.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:w.default("flex flex-col justify-center truncate",z?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(w.default(ge.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:w.default(ge.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",z?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:be.backgroundColor},disabled:Z||"idle"!==G,onClick:()=>se([])},{children:s.jsx(b.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:be.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:be.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[1]}.${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:be.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",z?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:be.backgroundColor},disabled:Z||"idle"!==G,onClick:()=>se([])},{children:s.jsx(b.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:w.default("flex items-end gap-x-2",z&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:w.default(ge.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!ne.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",z?"text-right":"text-left"),value:ne,placeholder:z?"بماذا تريد أن تتحدث؟":null!==(C=null==B?void 0:B.placeholdertext)&&void 0!==C?C:"What do you want to talk about?",onChange:e=>de(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Z||"idle"!==G||ve()))}},N&&{onFocus:N},O&&{onBlur:O},{dir:z?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:w.default("flex items-center gap-x-2")},{children:["enduserupload"===(null==B?void 0:B.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:pe?U.accent+"10":void 0},disabled:Z||"idle"!==G,onClick:()=>{var e;return null===(e=ce.current)||void 0===e?void 0:e.click()}},he,{children:[s.jsx("input",{id:"file-upload",ref:ce,type:"file",accept:[...f.allowedFileMimeTypes,...ee?f.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){M(!1),yield te(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(p.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:pe?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(me||ne.length||Y.length&&Y.every((e=>"finished"===e.status)))&&!K?U.accent:U.accent+"10"},disabled:Z||"idle"!==G,onClick:()=>ve()},fe,{children:s.jsx(j.default,{className:w.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",z&&"transform scale-x-[-1]"),style:{color:(me||ne.length||Y.length&&Y.every((e=>"finished"===e.status)))&&!K?U.accentText:U.accent+"80"}})}))]}))]}))]}))]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),n=require("./History/index.js"),o=require("./Input.js");exports.default=()=>{const{width:u,height:i,setDimension:c}=s.useDimensionContext(),{setDocuments:d}=r.useDocument(),[f,x]=t.useState(!1),a=t.useRef(null);return t.useEffect((()=>()=>{d([])}),[]),t.useEffect((()=>{if(!a.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;c(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(a.current),()=>{e.disconnect()}}),[a.current]),e.jsxs("div",Object.assign({ref:a,className:"flex flex-grow flex-col items-center"},{children:[e.jsx(n.default,{hideInfo:i<=545||u<=500||f,isInputFocused:f}),e.jsx(o.default,{isFocused:f,onFocus:()=>x(!0),onBlur:()=>x(!1)})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),i=require("./History/index.js"),o=require("./Input.js");exports.default=()=>{const{deploymentType:u,isNewChat:c}=s.usePickaxeContext(),{width:x,height:a,setDimension:l}=r.useDimensionContext(),{setDocuments:d}=n.useDocument(),[f,h]=t.useState(!1),j=t.useRef(null);return t.useEffect((()=>()=>{d([])}),[]),t.useEffect((()=>{if(!j.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;l(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(j.current),()=>{e.disconnect()}}),[j.current]),"chat-input"===u&&c?e.jsx("div",Object.assign({className:"relative flex flex-grow flex-col items-center"},{children:e.jsx(o.default,{})})):e.jsxs("div",Object.assign({ref:j,className:"flex flex-grow flex-col items-center"},{children:[e.jsx(i.default,{hideInfo:a<=545||x<=500||f,isInputFocused:f}),e.jsx(o.default,{isFocused:f,onFocus:()=>h(!0),onBlur:()=>h(!1)})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=s.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:d="",studioUserId:n="",deploymentId:l="",embedUserId:c="",styles:u,colors:b,limits:m={},misc:p={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:h,responsiveBy:F="viewport",forceMobile:x=!1,disableHtml:I=!1,disableJs:f=!1,disableCss:y=!1,loadFont:g=!0,isEmbed:j=!1,isRtl:P=!1,onGenerateComplete:v})=>{const[S,w]=s.useState(""),[k,C]=s.useState(""),[O,q]=s.useState(null),[D,H]=s.useState(!1),[R,U]=s.useState(!0),[B,E]=s.useState(!0);return s.useEffect((()=>{H(!1)}),[null==u?void 0:u.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:S,chatId:k,userId:d,studioUserId:n,deploymentId:l,embedUserId:c,pickaxe:O,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},u),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},b),misc:p,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"},h),responsiveBy:F,forceMobile:x,loadFont:g,disableHtml:I,disableJs:f,disableCss:y,isFontLoaded:D,isNewChat:R,isShowIceBreaker:B,isEmbed:j,isRtl:P,setIsFontLoaded:H,setFormId:w,setChatId:C,setPickaxe:q,setIsNewChat:U,setIsShowIceBreaker:E},v&&{onGenerateComplete:v})},{children:e.jsx(i.default,Object.assign({limits:m},{children:e.jsx(r.default,{children:e.jsx(t.default,{children:a})})}))}))};
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/Document/Provider.js"),o=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");function n(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:a,userId:l="",studioUserId:c="",deploymentId:u="",embedUserId:f="",deploymentType:p,deploymentDimensions:m,deploymentMisc:b,styles:y,colors:h,limits:v={},misc:x={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,responsiveBy:g="viewport",forceMobile:j=!1,disableHtml:I=!1,disableJs:P=!1,disableCss:w=!1,loadFont:S=!0,isRtl:O=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:D})=>{const[_,q]=i.useState(""),[E,H]=i.useState(""),[M,R]=i.useState(null),[T,U]=i.useState(!1),[B,L]=i.useState(!0),[N,z]=i.useState(!0);return i.useEffect((()=>{U(!1)}),[null==y?void 0:y.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!T&&(null==y?void 0:y.font)&&"Real Head Pro"!==y.font)try{(yield Promise.resolve().then((function(){return n(require("webfontloader"))}))).default.load({google:{families:[y.font]},active:()=>{U(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),U(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),U(!0)}}))}),[S,T,null==y?void 0:y.font]),t.jsx(d.Provider,Object.assign({value:Object.assign({formId:_,chatId:E,userId:l,studioUserId:c,embedUserId:f,deploymentId:u,deploymentType:p,deploymentDimensions:m,deploymentMisc:b,pickaxe:M,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},y),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:x,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"},F),responsiveBy:g,forceMobile:j,loadFont:S,disableHtml:I,disableJs:P,disableCss:w,isFontLoaded:T,isNewChat:B,isShowIceBreaker:N,isRtl:O,isEmbed:k,isDropShadow:C,setIsFontLoaded:U,setFormId:q,setChatId:H,setPickaxe:R,setIsNewChat:L,setIsShowIceBreaker:z},D&&{onGenerateComplete:D})},{children:t.jsx(o.default,Object.assign({limits:v},{children:t.jsx(r.default,{children:t.jsx(s.default,{children:a})})}))}))};
@@ -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"),t=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./PickaxeMarkdown/Renderer.js"),r=require("./PickaxeIcon.js"),a=require("./PickaxeInfoModal.js"),o=require("./PickaxeMarkdown/index.js"),n=require("../../../common/cn.js");exports.default=({className:c,iconClassName:d,maxLines:u,onIconClick:x})=>{const{pickaxe:m,styles:j,colors:k,misc:p,disableHtml:f,disableJs:h,disableCss:b,isRtl:P}=i.usePickaxeContext(),[v,C]=s.useState(!1),g=t.useStyleFontSize(),q=s.useMemo((()=>({title:(null==m?void 0:m.formtitle)||"",description:(null==m?void 0:m.formdescription)||""})),[m]);return e.jsxs("div",Object.assign({className:n.default("flex flex-col items-center",c)},{children:[v&&e.jsx(a.default,{isOpen:v,onChangeIsOpen:C}),p.isProfileImage&&e.jsx(r.default,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:72,height:72,className:n.default("h-[72px] w-[72px] rounded-full",d,!!x&&"cursor-pointer")},x&&{onClick:x})),p.isTitle&&!!q.title&&e.jsx("h2",Object.assign({className:n.default(g.h2,"mt-6 text-center font-semilight opacity-90",!u&&"line-clamp-2")},{children:null==m?void 0:m.formtitle})),p.isDescription&&!!q.description&&e.jsx(o.PickaxeMarkdown,Object.assign({theme:j.theme,accentColor:k.accent},P&&{rtl:!0},f&&{disableHtml:!0},h&&{disableJs:!0},b&&{disableCss:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,Object.assign({className:"mt-2 text-center",value:q.description},u&&{maxLines:u},{onExpandClick:()=>C(!0)}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/studio/useStyleFontSize.js"),r=require("./PickaxeMarkdown/Renderer.js"),l=require("./PickaxeIcon.js"),a=require("./PickaxeInfoModal.js"),o=require("./PickaxeMarkdown/index.js"),c=require("../../../common/cn.js");exports.default=({className:n,iconClassName:d,maxDescriptionChars:u,onIconClick:x})=>{const{pickaxe:m,styles:p,colors:j,misc:k,disableHtml:f,disableJs:h,disableCss:b,isRtl:C}=i.usePickaxeContext(),[P,v]=s.useState(!1),g=t.useStyleFontSize(),q=s.useMemo((()=>({title:(null==m?void 0:m.formtitle)||"",description:(null==m?void 0:m.formdescription)||""})),[m]);return e.jsxs("div",Object.assign({className:c.default("flex flex-col items-center",n)},{children:[P&&e.jsx(a.default,{isOpen:P,onChangeIsOpen:v}),k.isProfileImage&&e.jsx(l.default,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:72,height:72,className:c.default("h-[72px] w-[72px] rounded-full",d,!!x&&"cursor-pointer")},x&&{onClick:x})),k.isTitle&&!!q.title&&e.jsx("h2",Object.assign({className:c.default(g.h2,"mt-6 text-center font-semilight opacity-90",!u&&"line-clamp-2")},{children:null==m?void 0:m.formtitle})),k.isDescription&&!!q.description&&e.jsx(o.PickaxeMarkdown,Object.assign({theme:p.theme,accentColor:j.accent},C&&{rtl:!0},f&&{disableHtml:!0},h&&{disableJs:!0},b&&{disableCss:!0},{children:e.jsx(r.PickaxeMarkdownRenderer,Object.assign({className:"mt-2 text-center",value:q.description},u&&{maxDescriptionChars:u},{onExpandClick:()=>v(!0)}))}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/usePickaxeMarkdownContext.js"),r=require("../Img/index.js"),a=require("../common/Action.js"),i=require("./Audio.js"),o=require("./Html/index.js");exports.A=({href:l="",children:n})=>{const{accentColor:u,actions:c}=s.usePickaxeMarkdownContext(),m=t.useMemo((()=>{if(!l)return"";return l.startsWith("http://")?`https://${l.slice(7)}`:l.startsWith("www.")?`https://${l}`:l}),[l]),d=t.useMemo((()=>{var e;const t=m.match(/(?:https?:\/\/)?(?:www\.)?loom\.com\/(?:share|embed)\/([\w-]+)/i);return t&&null!==(e=null==t?void 0:t[1])&&void 0!==e?e:null}),[m]),p=t.useMemo((()=>{var e;const t=m.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);return t&&null!==(e=null==t?void 0:t[1])&&void 0!==e?e:null}),[m]),w=t.useMemo((()=>m.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/)),[m]),f=t.useMemo((()=>m.includes("action_generated_files")&&m.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/)),[m]),h=t.useMemo((()=>m.includes("action_generated_files")&&m.match(/\.html$/)),[m]),j=t.useMemo((()=>c&&m.includes("pickaxe")&&(m.includes("/api/fn/result")||m.includes("/api/function_call_results"))),[c,m]);return d?e.jsx("div",Object.assign({className:"pxe-markdown-loom"},{children:e.jsx("iframe",Object.assign({title:"loom-embed",src:`https://www.loom.com/embed/${d}`,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):p?e.jsx("div",Object.assign({className:"pxe-markdown-youtube"},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${p}`,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):w?e.jsx(r.Img,{src:m,alt:"string"==typeof n?n:"Markdown Image"}):f?e.jsx(i.default,{url:m}):h?e.jsx(o.default,{url:m}):j?e.jsx(a.default,{jobUrl:m}):e.jsx("a",Object.assign({href:m,target:"_blank",rel:"noopener noreferrer",style:{color:u}},{children:n}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../Img/index.js"),i=require("../common/Action.js"),o=require("./Audio.js"),a=require("./Html/index.js");exports.A=({href:c="",children:m})=>{const{accentColor:l,actions:n}=r.usePickaxeMarkdownContext(),u=t.useMemo((()=>{if(!c)return"";return c.startsWith("http://")?`https://${c.slice(7)}`:c.startsWith("www.")?`https://${c}`:c}),[c]),d=t.useMemo((()=>{const e=u.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=u.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=u.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const s=u.match(/streamable\.com\/([\w-]+)/i);return s?{title:"streamable-embed",src:`https://streamable.com/e/${s[1]}`}:null}),[u]),p=t.useMemo((()=>u.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/)),[u]),f=t.useMemo((()=>u.includes("action_generated_files")&&u.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/)),[u]),h=t.useMemo((()=>u.includes("action_generated_files")&&u.match(/\.html$/)),[u]),b=t.useMemo((()=>n&&u.includes("pickaxe")&&(u.includes("/api/fn/result")||u.includes("/api/function_call_results"))),[n,u]);return d?e.jsx("div",Object.assign({className:"pxe-markdown-video"},{children:e.jsx("iframe",Object.assign({title:d.title,src:d.src,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):p?e.jsx(s.Img,{src:u,alt:"string"==typeof m?m:"Markdown Image"}):f?e.jsx(o.default,{url:u}):h?e.jsx(a.default,{url:u}):b?e.jsx(i.default,{jobUrl:u}):e.jsx("a",Object.assign({href:u,target:"_blank",rel:"noopener noreferrer",style:{color:l}},{children:m}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/usePickaxeMarkdownContext.js"),r=require("../common/Action.js");exports.P=({children:i})=>{const{actions:l}=s.usePickaxeMarkdownContext(),n=t.useMemo((()=>{var e;if("string"!=typeof i)return null;const t=i.match(/(?:https?:\/\/)?(?:www\.)?loom\.com\/(?:share|embed)\/([\w-]+)/i);return t&&null!==(e=null==t?void 0:t[1])&&void 0!==e?e:null}),[i]),o=t.useMemo((()=>{var e;if("string"!=typeof i)return null;const t=i.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);return t&&null!==(e=null==t?void 0:t[1])&&void 0!==e?e:null}),[i]);if(n)return e.jsx("div",Object.assign({className:"pxe-markdown-loom"},{children:e.jsx("iframe",Object.assign({title:"loom-embed",src:`https://www.loom.com/embed/${n}`,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))}));if(o)return e.jsx("div",Object.assign({className:"pxe-markdown-youtube"},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${o}`,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))}));if(l&&"string"==typeof i&&i.includes("pickaxe")&&(i.includes("/api/fn/result")||i.includes("/api/function_call_results"))){const t=i.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),s=i.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx("p",{children:t}),e.jsx(r.default,{jobUrl:(null==s?void 0:s[0])||""})]}))}return e.jsx("p",{children:i})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");exports.P=({children:r})=>{const o=t.useMemo((()=>{if("string"!=typeof r)return null;const e=r.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=r.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const o=r.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(o)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${o[1]}`};const s=r.match(/streamable\.com\/([\w-]+)/i);return s?{title:"streamable-embed",src:`https://streamable.com/e/${s[1]}`}:null}),[r]);return o?e.jsx("div",Object.assign({className:"pxe-markdown-video"},{children:e.jsx("iframe",Object.assign({title:o.title,src:o.src,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):e.jsx("p",{children:r})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),o=require("remark-gfm"),a=require("remark-math"),l=require("rehype-katex"),u=require("rehype-raw"),c=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),m=require("./Components/Iframe/index.js"),h=require("./Components/Code/index.js"),g=require("./Components/Headings/index.js"),f=require("./Components/List/index.js"),x=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),j=require("./Components/Action/index.js"),q=require("../../../../common/cn.js");function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=C(i),w=C(o),y=C(a),v=C(l),A=C(u);exports.PickaxeMarkdownRenderer=({className:i,style:o,children:a,value:l,maxLines:u,multiLineBreaks:C,recursion:O,onExpandClick:H})=>{const{accentColor:P,rtl:S,disableHtml:M,disableJs:$,disableCss:T}=t.usePickaxeMarkdownContext(),[_,E]=n.useState({width:0,height:0}),[I,L]=n.useState(null),B=n.useRef(null),N=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),C&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,C]);n.useEffect((()=>{if(!u)return void L(null);if(!B.current||!N||I)return;const e=B.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=u*r;if(!(_.height>n))return;const t=Math.floor(_.width/8),s=Math.floor(t*u);L(N.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[N,u,_,I]);const R={h1:g.H1,h2:g.H2,h3:g.H3,h4:g.H4,h5:g.H5,p:d.P,a:c.A,img:p.Img,iframe:m.Iframe,code:h.Code,ol:f.Ol,ul:f.Ul,li:f.Li,table:x.Table,th:x.Th,tr:x.Tr,td:x.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,s=e.__rest(n,["children"]);return"pxe-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:P,marginLeft:".25rem",userSelect:"none"},H&&{cursor:"pointer"})},H&&{onClick:H},{children:t})):r.jsx("span",Object.assign({},s,{children:t}))},ActionCaption:j.ActionCaption,ActionFinished:j.ActionFinished,ActionError:j.ActionError};n.useEffect((()=>{if(!B.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;E({width:e,height:n})}}));return e.observe(B.current),()=>{e.disconnect()}}),[]);const z=I||N;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:B,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},o)},S&&{dir:"rtl"},{children:[r.jsx(k.default,Object.assign({className:q.default(!O&&"pxe-prose",i),components:R,remarkPlugins:[w.default,[y.default,{singleDollarTextMath:!1}]],rehypePlugins:[v.default,...M?[]:[A.default],[s.rehypeSanitize,{disableJs:$,disableCss:T}],s.rehypePickaxeAction]},{children:z})),a]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),u=require("rehype-raw"),c=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),f=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),j=require("./Components/Action/index.js"),C=require("../../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=q(i),w=q(a),v=q(o),y=q(l),A=q(u);exports.PickaxeMarkdownRenderer=({className:i,style:a,children:o,value:l,maxLines:u,maxChars:q,multiLineBreaks:O,recursion:H,onExpandClick:P})=>{const{accentColor:S,rtl:M,disableHtml:$,disableJs:T,disableCss:_}=t.usePickaxeMarkdownContext(),[E,I]=n.useState({width:0,height:0}),[L,B]=n.useState(null),N=n.useRef(null),R=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,O]);n.useEffect((()=>{if(q)return void B(R.length>q?R.slice(0,q)+'<span class="pxe-expand-btn">...</span>':null);if(!u)return void B(null);if(!N.current||!R||L)return;const e=N.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=u*r;if(!(E.height>n))return;const t=Math.floor(E.width/8),s=Math.floor(t*u);B(R.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[R,u,q,E,L]);const z={h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:d.P,a:c.A,img:p.Img,iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:f.Table,th:f.Th,tr:f.Tr,td:f.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,s=e.__rest(n,["children"]);return"pxe-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:S,marginLeft:".25rem",userSelect:"none"},P&&{cursor:"pointer"})},P&&{onClick:P},{children:t})):r.jsx("span",Object.assign({},s,{children:t}))},ActionCaption:j.ActionCaption,ActionFinished:j.ActionFinished,ActionError:j.ActionError};n.useEffect((()=>{if(!N.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;I({width:e,height:n})}}));return e.observe(N.current),()=>{e.disconnect()}}),[]);const F=L||R;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:N,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},a)},M&&{dir:"rtl"},{children:[r.jsx(k.default,Object.assign({className:C.default(!H&&"pxe-prose",i),components:z,remarkPlugins:[w.default,[v.default,{singleDollarTextMath:!1}]],rehypePlugins:[y.default,...$?[]:[A.default],[s.rehypeSanitize,{disableJs:T,disableCss:_}],s.rehypePickaxeAction]},{children:F})),o]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),r=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),o=require("../../common/utils.js"),i=require("./Addons/Scroll/Provider.js"),n=require("../Core/Skeleton.js"),u=require("./Chat/index.js"),c=require("./Form/index.js"),d=require("../../common/cn.js");function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}exports.Pickaxe=({formId:x,className:p})=>{const{chatId:m,styles:j,colors:h,loadFont:w,responsiveBy:k,isFontLoaded:b,setFormId:g,setChatId:v,setPickaxe:q,setIsFontLoaded:P}=r.usePickaxeContext(),{setMessages:y,setResponse:O,setError:N,setLimitData:C,setStatus:_}=l.useResponseContext(),[F,E]=a.useState(!1),I=s.usePickaxe();return a.useEffect((()=>{g(x)}),[x]),a.useEffect((()=>{if(!I.data)return;const e=I.data.chatflag;v(e?o.generateId(15):""),e?y([]):O(null),N(""),C(null),q(I.data),E(!0)}),[I.data]),a.useEffect((()=>{y([]),O(null),_("idle"),C(null),N("")}),[m]),a.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"undefined"!=typeof window&&(b||w&&"Real Head Pro"!==j.font&&((yield Promise.resolve().then((function(){return f(require("webfontloader"))}))).default.load({google:{families:[j.font]}}),P(!0)))}))}),[j.font,w,b]),I.data?t.jsx("div",Object.assign({className:d.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full",p,"dark"===j.theme&&"dark"),style:Object.assign({backgroundColor:h.primary,color:h.text},j.font&&"Real Head Pro"!==j.font&&{fontFamily:j.font})},{children:I.isLoading||!F?t.jsx("div",Object.assign({className:d.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:t.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t.jsx(n.default,{className:"w-[72px] h-[72px]"}),t.jsx(n.default,{className:"h-[20px] mt-6 w-full"}),t.jsx(n.default,{className:"h-[20px] mt-2 w-full"}),t.jsx(n.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t.jsx(n.default,{className:d.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t.jsx(t.Fragment,{children:m?t.jsx(i.default,{children:t.jsx(u.default,{})}):t.jsx(i.default,{children:t.jsx(c.default,{})})})})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),t=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),r=require("../../common/utils.js"),i=require("./Addons/Scroll/Provider.js"),x=require("../Core/Skeleton.js"),o=require("./Chat/index.js"),c=require("./Form/index.js"),u=require("../../common/cn.js");exports.Pickaxe=({formId:n,className:d})=>{const{chatId:f,styles:p,colors:m,responsiveBy:j,deploymentType:h,isNewChat:k,setFormId:w,setChatId:g,setPickaxe:q}=a.usePickaxeContext(),{setMessages:v,setResponse:N,setError:b,setLimitData:y,setStatus:C}=l.useResponseContext(),[P,O]=t.useState(!1),I=s.usePickaxe();return t.useEffect((()=>{w(n)}),[n]),t.useEffect((()=>{if(!I.data)return;const e=I.data.chatflag;g(e?r.generateId(15):""),e?v([]):N(null),b(""),y(null),q(I.data),O(!0)}),[I.data]),t.useEffect((()=>{v([]),N(null),C("idle"),y(null),b("")}),[f]),I.data?e.jsx("div",Object.assign({className:u.default("relative @container/pickaxe-root flex flex-col flex-grow w-full",!h&&"h-full","popup"===h&&f&&"h-full","dark"===p.theme&&"dark",d),style:Object.assign({backgroundColor:"chat-input"===h&&k?"transparent":m.primary,color:m.text},p.font&&"Real Head Pro"!==p.font&&{fontFamily:p.font})},{children:I.isLoading||!P?e.jsx("div",Object.assign({className:u.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===j?"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(x.default,{className:"w-[72px] h-[72px]"}),e.jsx(x.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(x.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(x.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(x.default,{className:u.default("w-full min-h-[48px]","viewport"===j?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):e.jsx(e.Fragment,{children:f?e.jsx(i.default,{children:e.jsx(o.default,{})}):e.jsx(i.default,{children:e.jsx(c.default,{})})})})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("@tanstack/react-query"),t=require("./usePickaxeContext.js");exports.usePickaxe=()=>{const{formId:i}=t.usePickaxeContext();return r.useQuery({queryKey:["form",i],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return(r=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!r)return null;const e=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe?formid=${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}),{success:t,data:i,error:o}=yield e.json();if(!t)throw new Error(o||"Failed to fetch pickaxe");return i})))(i)})),enabled:!!i,staleTime:18e4})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("@tanstack/react-query"),t=require("./usePickaxeContext.js");const i=r=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!r)return null;const e=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe?formid=${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}),{success:t,data:i,error:o}=yield e.json();if(!t)throw new Error(o||"Failed to fetch pickaxe");return i}));exports.useInstantPickaxe=t=>r.useQuery({queryKey:["form",t],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return i(t)})),enabled:!!t,staleTime:18e4}),exports.usePickaxe=()=>{const{formId:o}=t.usePickaxeContext();return r.useQuery({queryKey:["form",o],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return i(o)})),enabled:!!o,staleTime:18e4})};
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),s=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),i=require("./components/Pickaxe/common/PickaxeMarkdown/Renderer.js"),t=require("./hooks/pickaxe/useConversation.js"),x=require("./hooks/pickaxe/useHistory.js"),n=require("./hooks/pickaxe/usePickaxe.js"),k=require("./hooks/pickaxe/usePickaxeContext.js"),u=require("./hooks/pickaxe/useResponseContext.js"),a=require("./hooks/pickaxe/useDimensionContext.js"),c=require("./hooks/pickaxe/useSubmit.js"),p=require("./hooks/pickaxe/useSubmitDocument.js");exports.Pickaxe=e.Pickaxe,exports.PickaxeContext=o.PickaxeContext,exports.PickaxeProvider=o.PickaxeProvider,exports.ResponseContext=s.ResponseContext,exports.PickaxeMarkdown=r.PickaxeMarkdown,exports.PickaxeMarkdownContext=r.PickaxeMarkdownContext,exports.PickaxeMarkdownRenderer=i.PickaxeMarkdownRenderer,exports.useConversation=t.useConversation,exports.useHistory=x.useHistory,exports.usePickaxe=n.usePickaxe,exports.usePickaxeContext=k.usePickaxeContext,exports.useResponseContext=u.useResponseContext,exports.useDimensionContext=a.useDimensionContext,exports.useSubmit=c.useSubmit,exports.useSubmitDocument=p.useSubmitDocument;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),s=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),t=require("./components/Pickaxe/common/PickaxeMarkdown/Renderer.js"),i=require("./hooks/pickaxe/useConversation.js"),x=require("./hooks/pickaxe/useHistory.js"),n=require("./hooks/pickaxe/usePickaxe.js"),k=require("./hooks/pickaxe/usePickaxeContext.js"),u=require("./hooks/pickaxe/useResponseContext.js"),a=require("./hooks/pickaxe/useDimensionContext.js"),c=require("./hooks/pickaxe/useSubmit.js"),p=require("./hooks/pickaxe/useSubmitDocument.js");exports.Pickaxe=e.Pickaxe,exports.PickaxeContext=o.PickaxeContext,exports.PickaxeProvider=o.PickaxeProvider,exports.ResponseContext=s.ResponseContext,exports.PickaxeMarkdown=r.PickaxeMarkdown,exports.PickaxeMarkdownContext=r.PickaxeMarkdownContext,exports.PickaxeMarkdownRenderer=t.PickaxeMarkdownRenderer,exports.useConversation=i.useConversation,exports.useHistory=x.useHistory,exports.useInstantPickaxe=n.useInstantPickaxe,exports.usePickaxe=n.usePickaxe,exports.usePickaxeContext=k.usePickaxeContext,exports.useResponseContext=u.useResponseContext,exports.useDimensionContext=a.useDimensionContext,exports.useSubmit=c.useSubmit,exports.useSubmitDocument=p.useSubmitDocument;
@@ -1 +1 @@
1
- .pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-loom{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-loom,.pxe-prose .pxe-markdown-youtube{display:flex;justify-content:center;width:100%}.pxe-prose .pxe-markdown-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-code{margin-bottom:1.5rem}.pxe-prose ol{list-style-type:decimal}.pxe-prose ol,.pxe-prose ul{list-style-position:inside;margin-bottom:1.5rem;padding-left:1rem}.pxe-prose ul{list-style-type:disc}.pxe-prose li{margin:10px 10px 14px}.pxe-prose li>p{display:inline}.pxe-prose .pxe-markdown-table{margin-bottom:2.5rem;overflow:auto;position:relative}.pxe-prose table{font-size:.875rem;line-height:1.24rem;table-layout:fixed}.pxe-prose th{font-weight:600;text-align:left}.pxe-prose td,.pxe-prose th{padding:.75em 1em}.pxe-prose h1{font-size:2.25rem;line-height:2.5rem;margin-bottom:1.5rem}.pxe-prose h2{font-size:1.875rem;line-height:2.25rem;margin-bottom:1.5rem}.pxe-prose h3{font-size:1.5rem;line-height:2rem;margin-bottom:1.5rem}.pxe-prose h4{font-size:1.25rem}.pxe-prose h4,.pxe-prose h5{line-height:1.75rem;margin-bottom:1rem}.pxe-prose h5{font-size:1.125rem}.pxe-prose h2:not(:first-child){margin-top:2.5rem}.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose>pre:not(:first-child){margin-top:1rem}.pxe-prose .pxe-markdown-code{display:flex;flex-direction:column}.pxe-prose .pxe-markdown-code>div:first-child{background-color:#1d1f21;border-radius:.3em;display:flex;flex-direction:column;max-width:min-content;padding-top:1em;position:relative}.pxe-prose .pxe-markdown-code>div:first-child>div:first-child{display:flex;justify-content:flex-end;padding:0 1em}.pxe-prose .pxe-markdown-code>div:first-child>div:last-child{overflow:auto}.pxe-prose .pxe-action[data-action-id]:not(:nth-child(2)){margin-top:1rem}.pxe-prose .pxe-markdown-code-inline{background-color:#1d1f21;border-radius:.3em;color:#fff;font-size:10pt;padding:.15em .4em}.pxe-link-previews{display:flex;flex-direction:column;gap:2rem}.pxe-prose>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-youtube{margin-top:0}.pxe-prose .pxe-blink{animation:blink 1s ease-in-out infinite}.pxe-prose .pxe-red{color:red}.pxe-prose .pxe-action-error{display:flex;flex-direction:column}.pxe-prose .pxe-animated-token{animation:fadeIn .3s ease-out forwards;display:inline-block;opacity:0}@keyframes fadeIn{0%{opacity:0;transform:translateX(5px)}to{opacity:1;transform:translateX(0)}}@keyframes blink{0%{opacity:1}50%{opacity:.5}to{opacity:1}}
1
+ .pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-video{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-video{display:flex;justify-content:center;width:100%}.pxe-prose .pxe-markdown-code{margin-bottom:1.5rem}.pxe-prose ol{list-style-type:decimal}.pxe-prose ol,.pxe-prose ul{list-style-position:inside;margin-bottom:1.5rem;padding-left:1rem}.pxe-prose ul{list-style-type:disc}.pxe-prose li{margin:10px 10px 14px}.pxe-prose li>p{display:inline}.pxe-prose .pxe-markdown-table{margin-bottom:2.5rem;overflow:auto;position:relative}.pxe-prose table{font-size:.875rem;line-height:1.24rem;table-layout:fixed}.pxe-prose th{font-weight:600;text-align:left}.pxe-prose td,.pxe-prose th{padding:.75em 1em}.pxe-prose h1{font-size:2.25rem;line-height:2.5rem;margin-bottom:1.5rem}.pxe-prose h2{font-size:1.875rem;line-height:2.25rem;margin-bottom:1.5rem}.pxe-prose h3{font-size:1.5rem;line-height:2rem;margin-bottom:1.5rem}.pxe-prose h4{font-size:1.25rem}.pxe-prose h4,.pxe-prose h5{line-height:1.75rem;margin-bottom:1rem}.pxe-prose h5{font-size:1.125rem}.pxe-prose h2:not(:first-child){margin-top:2.5rem}.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose>pre:not(:first-child){margin-top:1rem}.pxe-prose .pxe-markdown-code{display:flex;flex-direction:column}.pxe-prose .pxe-markdown-code>div:first-child{background-color:#1d1f21;border-radius:.3em;display:flex;flex-direction:column;max-width:min-content;padding-top:1em;position:relative}.pxe-prose .pxe-markdown-code>div:first-child>div:first-child{display:flex;justify-content:flex-end;padding:0 1em}.pxe-prose .pxe-markdown-code>div:first-child>div:last-child{overflow:auto}.pxe-prose .pxe-action[data-action-id]:not(:nth-child(2)){margin-top:1rem}.pxe-prose .pxe-markdown-code-inline{background-color:#1d1f21;border-radius:.3em;color:#fff;font-size:10pt;padding:.15em .4em}.pxe-link-previews{display:flex;flex-direction:column;gap:2rem}.pxe-prose>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-video{margin-top:0}.pxe-prose .pxe-blink{animation:blink 1s ease-in-out infinite}.pxe-prose .pxe-red{color:red}.pxe-prose .pxe-action-error{display:flex;flex-direction:column}.pxe-prose .pxe-animated-token{animation:fadeIn .3s ease-out forwards;display:inline-block;opacity:0}@keyframes fadeIn{0%{opacity:0;transform:translateX(5px)}to{opacity:1;transform:translateX(0)}}@keyframes blink{0%{opacity:1}50%{opacity:.5}to{opacity:1}}
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import { PickaxeProps } from "../Pickaxe";
3
+ import { IPickaxeProviderProps } from "../Pickaxe/Provider";
4
+ type ChatInputProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
5
+ export declare const ChatInput: ({ formId, className, ...props }: ChatInputProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const ChatInputWrapper: ({ children }: {
7
+ children: ReactNode;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { SetState } from "../../types/common";
2
+ import { PickaxeProps } from "../Pickaxe";
3
+ import { IPickaxeProviderProps } from "../Pickaxe/Provider";
4
+ type FABProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
5
+ export declare const FAB: ({ formId, className, ...props }: FABProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const FABButton: ({ isOpen, setIsOpen, }: {
7
+ isOpen: boolean;
8
+ setIsOpen: SetState<boolean>;
9
+ }) => import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ import { PickaxeProps } from "../Pickaxe";
2
+ import { IPickaxeProviderProps } from "../Pickaxe/Provider";
3
+ type InlineProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
4
+ export declare const Inline: ({ formId, className, ...props }: InlineProps) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { SetState } from "../../types/common";
2
+ import { PickaxeProps } from "../Pickaxe";
3
+ import { IPickaxeProviderProps } from "../Pickaxe/Provider";
4
+ type PopupProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
5
+ export declare const Popup: ({ formId, className, ...props }: PopupProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const PopupCTAButton: ({ formId, setIsOpen, }: {
7
+ formId: string;
8
+ setIsOpen: SetState<boolean>;
9
+ }) => import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -1,7 +1,7 @@
1
1
  interface InputProps {
2
- isFocused: boolean;
3
- onFocus: () => void;
4
- onBlur: () => void;
2
+ isFocused?: boolean;
3
+ onFocus?: () => void;
4
+ onBlur?: () => void;
5
5
  }
6
6
  declare const Input: ({ isFocused, onFocus, onBlur }: InputProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Input;
@@ -33,13 +33,34 @@ export type PickaxeMisc = {
33
33
  isDescription: boolean;
34
34
  isHistory?: boolean;
35
35
  };
36
+ export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input";
37
+ export type PickaxeDeploymentDimensions = {
38
+ width: {
39
+ value: number;
40
+ unit: "%" | "px";
41
+ };
42
+ maxWidth: number;
43
+ height: {
44
+ value: number;
45
+ unit: "px" | "auto";
46
+ };
47
+ minHeight: number;
48
+ maxHeight: number;
49
+ };
50
+ export type PickaxeDeploymentMisc = {
51
+ popupText?: string;
52
+ fabImage?: string;
53
+ };
36
54
  type PickaxeContextType = {
37
55
  formId: string;
38
56
  chatId: string;
39
57
  userId: string;
40
58
  studioUserId: string;
41
- deploymentId: string;
42
59
  embedUserId: string;
60
+ deploymentId: string;
61
+ deploymentType?: PickaxeDeploymentEmbedType;
62
+ deploymentDimensions?: PickaxeDeploymentDimensions;
63
+ deploymentMisc?: PickaxeDeploymentMisc;
43
64
  pickaxe: LimitedPickaxe | null;
44
65
  styles: PickaxeProviderStyles;
45
66
  colors: PickaxeProviderColors;
@@ -54,8 +75,9 @@ type PickaxeContextType = {
54
75
  isFontLoaded: boolean;
55
76
  isNewChat: boolean;
56
77
  isShowIceBreaker: boolean;
57
- isEmbed: boolean;
58
78
  isRtl: boolean;
79
+ isEmbed: boolean;
80
+ isDropShadow: boolean;
59
81
  setFormId: SetState<string>;
60
82
  setChatId: SetState<string>;
61
83
  setPickaxe: SetState<LimitedPickaxe | null>;
@@ -68,8 +90,11 @@ export interface IPickaxeProviderProps {
68
90
  children: ReactNode;
69
91
  userId?: string;
70
92
  studioUserId?: string;
71
- deploymentId?: string;
72
93
  embedUserId?: string;
94
+ deploymentId?: string;
95
+ deploymentType?: PickaxeDeploymentEmbedType;
96
+ deploymentDimensions?: PickaxeDeploymentDimensions;
97
+ deploymentMisc?: PickaxeDeploymentMisc;
73
98
  styles?: Partial<PickaxeProviderStyles>;
74
99
  colors?: Partial<PickaxeProviderColors>;
75
100
  limits?: Record<string, PickaxeLimitData>;
@@ -81,10 +106,11 @@ export interface IPickaxeProviderProps {
81
106
  disableHtml?: boolean;
82
107
  disableJs?: boolean;
83
108
  disableCss?: boolean;
84
- isEmbed?: boolean;
85
109
  isRtl?: boolean;
110
+ isEmbed?: boolean;
111
+ isDropShadow?: boolean;
86
112
  onGenerateComplete?: (responseId: string) => void;
87
113
  }
88
114
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
89
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isEmbed, isRtl, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
115
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
90
116
  export {};
@@ -1,8 +1,8 @@
1
1
  interface PickaxeHeadProps {
2
2
  className?: string;
3
3
  iconClassName?: string;
4
- maxLines?: number;
4
+ maxDescriptionChars?: number;
5
5
  onIconClick?: () => void;
6
6
  }
7
- declare const PickaxeHead: ({ className, iconClassName, maxLines, onIconClick, }: PickaxeHeadProps) => import("react/jsx-runtime").JSX.Element;
7
+ declare const PickaxeHead: ({ className, iconClassName, maxDescriptionChars, onIconClick, }: PickaxeHeadProps) => import("react/jsx-runtime").JSX.Element;
8
8
  export default PickaxeHead;
@@ -5,8 +5,9 @@ export interface PickaxeMarkdownRendererProps {
5
5
  children?: ReactNode;
6
6
  value?: string | null;
7
7
  maxLines?: number;
8
+ maxChars?: number;
8
9
  multiLineBreaks?: boolean;
9
10
  recursion?: boolean;
10
11
  onExpandClick?: () => void;
11
12
  }
12
- export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, multiLineBreaks, recursion, onExpandClick, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, recursion, onExpandClick, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,3 @@
1
1
  import type { LimitedPickaxe } from "../../types/pickaxe";
2
2
  export declare const usePickaxe: () => import("@tanstack/react-query").UseQueryResult<LimitedPickaxe | null, Error>;
3
+ export declare const useInstantPickaxe: (formId: string) => import("@tanstack/react-query").UseQueryResult<LimitedPickaxe | null, Error>;
@@ -3,8 +3,11 @@ export declare const usePickaxeContext: () => {
3
3
  chatId: string;
4
4
  userId: string;
5
5
  studioUserId: string;
6
- deploymentId: string;
7
6
  embedUserId: string;
7
+ deploymentId: string;
8
+ deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
9
+ deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
10
+ deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
8
11
  pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
9
12
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
10
13
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
@@ -19,8 +22,9 @@ export declare const usePickaxeContext: () => {
19
22
  isFontLoaded: boolean;
20
23
  isNewChat: boolean;
21
24
  isShowIceBreaker: boolean;
22
- isEmbed: boolean;
23
25
  isRtl: boolean;
26
+ isEmbed: boolean;
27
+ isDropShadow: boolean;
24
28
  setFormId: import("../../types/common").SetState<string>;
25
29
  setChatId: import("../../types/common").SetState<string>;
26
30
  setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import f from"../../Addons/Scroll/ScrollLockView.js";import p from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:L}=o(),{scrollContainerRef:E}=l(),{messages:A,status:H,limitData:R,error:$}=t(),{height:z}=i(),D=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!D),[w,b.isSuccess,S,D]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return e("div",Object.assign({ref:E,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${z}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(p,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>L("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>L("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?e("div",Object.assign({className:j("flex w-full",I?"justify-end":"justify-start")},{children:e("div",Object.assign({className:"flex flex-col"},{children:s("div",Object.assign({className:j("flex gap-x-3",I&&"flex-row-reverse")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]}))}))})):R?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):$?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:$})})):null]})),e(f,{className:"w-full"})]})):null}))]}))}))};export{w as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import p from"../../Addons/Scroll/ScrollLockView.js";import f from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:E}=o(),{scrollContainerRef:L}=l(),{messages:A,status:H,limitData:D,error:R}=t(),{height:$}=i(),z=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!z),[w,b.isSuccess,S,z]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return e("div",Object.assign({ref:L,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${$}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(f,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500,onIconClick:()=>E("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>E("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?e("div",Object.assign({className:j("flex w-full",I?"justify-end":"justify-start")},{children:e("div",Object.assign({className:"flex flex-col"},{children:s("div",Object.assign({className:j("flex gap-x-3",I&&"flex-row-reverse")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]}))}))})):D?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):R?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:R})})):null]})),e(p,{className:"w-full"})]})):null}))]}))}))};export{w as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as l,Fragment as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as b}from"../../../hooks/core/useHover.js";import{formatBytes as v}from"../../../common/utils.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as y}from"../../../common/documents.js";import{createParser as j}from"eventsource-parser";import k from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import I from"../../Icons/x.svg.js";import O from"../../Icons/arrow-right.svg.js";import C from"../Addons/IceBreaker/index.js";import S from"../../Core/Textarea.js";import R from"../../../common/error.js";import A from"../../../common/cn.js";const T=({isFocused:T,onFocus:U,onBlur:B})=>{var D;const{formId:F,chatId:E,userId:H,studioUserId:z,embedUserId:L,deploymentId:$,pickaxe:G,styles:J,colors:K,responsiveBy:P,isNewChat:W,isRtl:_,setIsNewChat:M,setIsShowIceBreaker:q,onGenerateComplete:Q}=c(),{messages:V,status:X,limits:Y,isGenerating:Z,setMessages:ee,setStatus:te,setLimitData:se,setError:oe}=d(),{documents:re,isUploading:ie,isImageUploadAllowed:ne,setDocuments:le,onFileUpload:ae}=h(),{scrollStartSession:ce,scrollEndSession:de,scrollToBottom:ue}=g({auto:!0}),me=p(),pe=f(),[fe,he]=r(""),ge=i(null),be=b(),{isHover:ve}=be,xe=e(be,["isHover"]),ye=b(),{isHover:je}=ye,ke=e(ye,["isHover"]),we=m(),Ne=u(),Ie=n((()=>{var e,t,s;return!!W&&(!!G&&(!me.isLoading&&(!((null!==(t=null===(e=me.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=G.icebreakers)||void 0===s?void 0:s.length))))}),[G,W,me.data,me.isLoading]),Oe=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==X||ie)return;const t=null!=e?e:fe;if(!t)return;oe(""),se(null),he(""),M(!1),te("fetching"),ce(),ue();const s=re.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=s.length?s[s.length-1].documentId:"",r="enduserupload"===(null==G?void 0:G.documentuploadtype)&&o,i=[...Array.from(V),Object.assign({id:V.length+1,role:"user",content:t},r&&{documentIds:[o]})];ee(i),ue(),r&&le([]);const n=(yield pe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:E,value:t},r&&{documentId:o}),H&&{userId:H}),z&&{studioUserId:z}),L&&{embedUserId:L}),$&&{deploymentId:$}))).body;if(!n)throw new Error("Streaming error");const l=i.length,a=new TextDecoder,c=n.getReader();let d="",u=!0,m=!1;const p=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,ee([...i.slice(0,l),{id:V.length+1,role:"assistant",content:d}])}else if("error"===e.event){const t=JSON.parse(e.data);oe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:t}=yield c.read();if(t){u=!1;break}const s=a.decode(e);s&&(m||(te("streaming"),m=!0),p.feed(s))}null==Q||Q(E)}catch(e){let t=R(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(Y).find((([e])=>t.includes(e)));s?se(s[1]):oe(t)}finally{ue(),te("idle"),de()}}));return l((()=>{q(Ie)}),[Ie]),s("div",Object.assign({className:"px-4 pb-4 w-full flex flex-col items-center absolute bottom-0 left-0 z-1",dir:_?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[s("div",Object.assign({className:A("absolute bottom-full",_?"left-0":"right-0")},{children:s("div",Object.assign({className:A("flex flex-col gap-2 pb-4 px-2",_?"justify-start":"justify-end","viewport"===P?_?"min-[767px]:items-start":"min-[767px]:items-end":_?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Ie&&!T&&s(C,{data:(null==G?void 0:G.icebreakers)||[],onSend:Oe})}))})),o("div",Object.assign({className:A("flex flex-col gap-y-2 px-4 py-3","block"===J.formFieldStyle&&"shadow"),style:Ne},{children:["idle"===X&&re.length>0&&s("div",Object.assign({className:A("grid grid-cols-1","viewport"===P?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:re.map((e=>{var t,r,i;return s(a,{children:"document"===e.type?o("div",Object.assign({className:A("relative gap-x-[10px] flex items-center px-2 h-[56px] border",_&&"flex-row-reverse"),style:{borderRadius:Ne.borderRadius,borderColor:K.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:K.accent,borderRadius:Ne.borderRadius}},{children:ie?s(w,{className:"w-5 h-5 animate-spin",style:{color:K.accentText}}):s(N,{className:"w-5 h-5",style:{color:K.accentText}})})),o("div",Object.assign({className:A("flex flex-col justify-center truncate",_?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(A(we.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:A(we.b4,"opacity-80 truncate")},{children:v(e.size)}))]})),s("button",Object.assign({type:"button",className:A("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",_?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:K.accent,borderColor:Ne.backgroundColor},disabled:ie||"idle"!==X,onClick:()=>le([])},{children:s(I,{className:"w-4 h-4",style:{color:K.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Ne.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Ne.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:Ne.borderRadius,backgroundColor:K.secondary}}),s("button",Object.assign({type:"button",className:A("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",_?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:K.accent,borderColor:Ne.backgroundColor},disabled:ie||"idle"!==X,onClick:()=>le([])},{children:s(I,{className:"w-4 h-4",style:{color:K.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:A("flex items-end gap-x-2",_&&"flex-row-reverse")},{children:[s(S,{className:A(we.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!fe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",_?"text-right":"text-left"),value:fe,placeholder:_?"بماذا تريد أن تتحدث؟":null!==(D=null==G?void 0:G.placeholdertext)&&void 0!==D?D:"What do you want to talk about?",onChange:e=>he(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ie||"idle"!==X||Oe()))},onFocus:U,onBlur:B,dir:_?"rtl":"ltr"}),o("div",Object.assign({className:A("flex items-center gap-x-2")},{children:["enduserupload"===(null==G?void 0:G.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:je?K.accent+"10":void 0},disabled:ie||"idle"!==X,onClick:()=>{var e;return null===(e=ge.current)||void 0===e?void 0:e.click()}},ke,{children:[s("input",{id:"file-upload",ref:ge,type:"file",accept:[...x,...ne?y:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){yield ae(Array.from(e.target.files||[])),e.target.value=""}))}),s(k,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:je?K.accent:K.accent+"80"}})]})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(ve||fe.length||re.length&&re.every((e=>"finished"===e.status)))&&!Z?K.accent:K.accent+"10"},disabled:ie||"idle"!==X,onClick:()=>Oe()},xe,{children:s(O,{className:A("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",_&&"transform scale-x-[-1]"),style:{color:(ve||fe.length||re.length&&re.every((e=>"finished"===e.status)))&&!Z?K.accentText:K.accent+"80"}})}))]}))]}))]}))]}))}))};export{T as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as l,Fragment as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as b}from"../../../hooks/core/useHover.js";import{formatBytes as v}from"../../../common/utils.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as y}from"../../../common/documents.js";import{createParser as j}from"eventsource-parser";import k from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import I from"../../Icons/x.svg.js";import O from"../../Icons/arrow-right.svg.js";import C from"../Addons/IceBreaker/index.js";import S from"../../Core/Textarea.js";import R from"../../../common/error.js";import T from"../../../common/cn.js";const A=({isFocused:A,onFocus:U,onBlur:B})=>{var D;const{formId:F,chatId:E,userId:H,studioUserId:z,embedUserId:L,deploymentId:$,deploymentType:G,pickaxe:J,styles:K,colors:P,responsiveBy:W,isNewChat:_,isRtl:M,setIsNewChat:q,setIsShowIceBreaker:Q,onGenerateComplete:V}=c(),{messages:X,status:Y,limits:Z,isGenerating:ee,setMessages:te,setStatus:se,setLimitData:oe,setError:re}=d(),{documents:ie,isUploading:ne,isImageUploadAllowed:le,setDocuments:ae,onFileUpload:ce}=h(),{scrollStartSession:de,scrollEndSession:ue,scrollToBottom:me}=g({auto:!0}),pe=p(),fe=f(),[he,ge]=r(""),be=i(null),ve=b(),{isHover:xe}=ve,ye=e(ve,["isHover"]),je=b(),{isHover:ke}=je,we=e(je,["isHover"]),Ne=m(),Ie=u(),Oe=n((()=>{var e,t,s;return!!_&&(!!J&&(!pe.isLoading&&(!((null!==(t=null===(e=pe.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))))}),[J,_,pe.data,pe.isLoading]),Ce=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Y||ne)return;const t=null!=e?e:he;if(!t)return;re(""),oe(null),ge(""),q(!1),se("fetching"),de(),me();const s=ie.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=s.length?s[s.length-1].documentId:"",r="enduserupload"===(null==J?void 0:J.documentuploadtype)&&o,i=[...Array.from(X),Object.assign({id:X.length+1,role:"user",content:t},r&&{documentIds:[o]})];te(i),me(),r&&ae([]);const n=(yield fe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:E,value:t},r&&{documentId:o}),H&&{userId:H}),z&&{studioUserId:z}),L&&{embedUserId:L}),$&&{deploymentId:$}))).body;if(!n)throw new Error("Streaming error");const l=i.length,a=new TextDecoder,c=n.getReader();let d="",u=!0,m=!1;const p=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,te([...i.slice(0,l),{id:X.length+1,role:"assistant",content:d}])}else if("error"===e.event){const t=JSON.parse(e.data);re(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:t}=yield c.read();if(t){u=!1;break}const s=a.decode(e);s&&(m||(se("streaming"),m=!0),p.feed(s))}null==V||V(E)}catch(e){let t=R(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(Z).find((([e])=>t.includes(e)));s?oe(s[1]):re(t)}finally{me(),se("idle"),ue()}}));return l((()=>{Q(Oe)}),[Oe]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===G&&_)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===G&&_)&&s("div",Object.assign({className:T("absolute bottom-full",M?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===W?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Oe&&!A&&s(C,{data:(null==J?void 0:J.icebreakers)||[],onSend:Ce})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===K.formFieldStyle&&"shadow"),style:Ie},{children:["idle"===Y&&ie.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===W?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ie.map((e=>{var t,r,i;return s(a,{children:"document"===e.type?o("div",Object.assign({className:T("relative gap-x-[10px] flex items-center px-2 h-[56px] border",M&&"flex-row-reverse"),style:{borderRadius:Ie.borderRadius,borderColor:P.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:P.accent,borderRadius:Ie.borderRadius}},{children:ne?s(w,{className:"w-5 h-5 animate-spin",style:{color:P.accentText}}):s(N,{className:"w-5 h-5",style:{color:P.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Ne.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Ne.b4,"opacity-80 truncate")},{children:v(e.size)}))]})),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:P.accent,borderColor:Ie.backgroundColor},disabled:ne||"idle"!==Y,onClick:()=>ae([])},{children:s(I,{className:"w-4 h-4",style:{color:P.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Ie.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Ie.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:Ie.borderRadius,backgroundColor:P.secondary}}),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:P.accent,borderColor:Ie.backgroundColor},disabled:ne||"idle"!==Y,onClick:()=>ae([])},{children:s(I,{className:"w-4 h-4",style:{color:P.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Ne.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!he.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:he,placeholder:M?"بماذا تريد أن تتحدث؟":null!==(D=null==J?void 0:J.placeholdertext)&&void 0!==D?D:"What do you want to talk about?",onChange:e=>ge(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ne||"idle"!==Y||Ce()))}},U&&{onFocus:U},B&&{onBlur:B},{dir:M?"rtl":"ltr"})),o("div",Object.assign({className:T("flex items-center gap-x-2")},{children:["enduserupload"===(null==J?void 0:J.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:ke?P.accent+"10":void 0},disabled:ne||"idle"!==Y,onClick:()=>{var e;return null===(e=be.current)||void 0===e?void 0:e.click()}},we,{children:[s("input",{id:"file-upload",ref:be,type:"file",accept:[...x,...le?y:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){q(!1),yield ce(Array.from(e.target.files||[])),e.target.value=""}))}),s(k,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:ke?P.accent:P.accent+"80"}})]})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(xe||he.length||ie.length&&ie.every((e=>"finished"===e.status)))&&!ee?P.accent:P.accent+"10"},disabled:ne||"idle"!==Y,onClick:()=>Ce()},ye,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(xe||he.length||ie.length&&ie.every((e=>"finished"===e.status)))&&!ee?P.accentText:P.accent+"80"}})}))]}))]}))]}))]}))}))};export{A as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as r,useEffect as n}from"react";import{useDimensionContext as s}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as i}from"../Addons/Document/hooks/useDocument.js";import c from"./History/index.js";import m from"./Input.js";const u=()=>{const{width:u,height:f,setDimension:d}=s(),{setDocuments:p}=i(),[a,h]=o(!1),l=r(null);return n((()=>()=>{p([])}),[]),n((()=>{if(!l.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;d(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(l.current),()=>{e.disconnect()}}),[l.current]),e("div",Object.assign({ref:l,className:"flex flex-grow flex-col items-center"},{children:[t(c,{hideInfo:f<=545||u<=500||a,isInputFocused:a}),t(m,{isFocused:a,onFocus:()=>h(!0),onBlur:()=>h(!1)})]}))};export{u as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as s,useEffect as r}from"react";import{usePickaxeContext as n}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useDimensionContext as i}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as c}from"../Addons/Document/hooks/useDocument.js";import m from"./History/index.js";import u from"./Input.js";const f=()=>{const{deploymentType:f,isNewChat:a}=n(),{width:l,height:d,setDimension:p}=i(),{setDocuments:x}=c(),[h,j]=o(!1),g=s(null);return r((()=>()=>{x([])}),[]),r((()=>{if(!g.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;p(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(g.current),()=>{e.disconnect()}}),[g.current]),"chat-input"===f&&a?e("div",Object.assign({className:"relative flex flex-grow flex-col items-center"},{children:e(u,{})})):t("div",Object.assign({ref:g,className:"flex flex-grow flex-col items-center"},{children:[e(m,{hideInfo:d<=545||l<=500||h,isInputFocused:h}),e(u,{isFocused:h,onFocus:()=>j(!0),onBlur:()=>j(!1)})]}))};export{f as default};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as i,useEffect as t}from"react";import o from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import d from"./DimensionProvider.js";const n=s({}),a=({children:s,userId:a="",studioUserId:l="",deploymentId:c="",embedUserId:m="",styles:p,colors:b,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,responsiveBy:u="viewport",forceMobile:f=!1,disableHtml:g=!1,disableJs:y=!1,disableCss:w=!1,loadFont:P=!0,isEmbed:j=!1,isRtl:v=!1,onGenerateComplete:x})=>{const[k,C]=i(""),[S,O]=i(""),[D,H]=i(null),[R,U]=i(!1),[B,L]=i(!0),[T,E]=i(!0);return t((()=>{U(!1)}),[null==p?void 0:p.font]),e(n.Provider,Object.assign({value:Object.assign({formId:k,chatId:S,userId:a,studioUserId:l,deploymentId:c,embedUserId:m,pickaxe:D,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},p),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},b),misc:F,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"},I),responsiveBy:u,forceMobile:f,loadFont:P,disableHtml:g,disableJs:y,disableCss:w,isFontLoaded:R,isNewChat:B,isShowIceBreaker:T,isEmbed:j,isRtl:v,setIsFontLoaded:U,setFormId:C,setChatId:O,setPickaxe:H,setIsNewChat:L,setIsShowIceBreaker:E},x&&{onGenerateComplete:x})},{children:e(r,Object.assign({limits:h},{children:e(d,{children:e(o,{children:s})})}))}))};export{n as PickaxeContext,a as PickaxeProvider};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as i,useState as s,useEffect as t}from"react";import r from"./Addons/Document/Provider.js";import n from"./ResponseProvider.js";import d from"./DimensionProvider.js";const l=i({}),a=({children:i,userId:a="",studioUserId:c="",deploymentId:m="",embedUserId:p="",deploymentType:f,deploymentDimensions:b,deploymentMisc:y,styles:h,colors:u,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:g,responsiveBy:v="viewport",forceMobile:w=!1,disableHtml:x=!1,disableJs:P=!1,disableCss:j=!1,loadFont:D=!0,isRtl:S=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:H})=>{const[O,R]=s(""),[T,U]=s(""),[B,L]=s(null),[M,E]=s(!1),[N,A]=s(!0),[G,J]=s(!0);return t((()=>{E(!1)}),[null==h?void 0:h.font]),t((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!M&&(null==h?void 0:h.font)&&"Real Head Pro"!==h.font)try{(yield import("webfontloader")).default.load({google:{families:[h.font]},active:()=>{E(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),E(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),E(!0)}}))}),[D,M,null==h?void 0:h.font]),o(l.Provider,Object.assign({value:Object.assign({formId:O,chatId:T,userId:a,studioUserId:c,embedUserId:p,deploymentId:m,deploymentType:f,deploymentDimensions:b,deploymentMisc:y,pickaxe:B,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},h),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},g),responsiveBy:v,forceMobile:w,loadFont:D,disableHtml:x,disableJs:P,disableCss:j,isFontLoaded:M,isNewChat:N,isShowIceBreaker:G,isRtl:S,isEmbed:k,isDropShadow:C,setIsFontLoaded:E,setFormId:R,setChatId:U,setPickaxe:L,setIsNewChat:A,setIsShowIceBreaker:J},H&&{onGenerateComplete:H})},{children:o(n,Object.assign({limits:F},{children:o(d,{children:o(r,{children:i})})}))}))};export{l as PickaxeContext,a as PickaxeProvider};