@pickaxeproject/react 2.7.0 → 2.7.2

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 (29) hide show
  1. package/dist/cjs/components/Core/Menu/Button.js +1 -1
  2. package/dist/cjs/components/EmbedPreview/FAB.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Form/Questions/Document.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Form/index.js +1 -1
  9. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Code/index.js +1 -1
  10. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  11. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  12. package/dist/cjs/hooks/pickaxe/useSubmitDocument.js +1 -1
  13. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +1 -0
  14. package/dist/esm/components/Core/Menu/Button.js +1 -1
  15. package/dist/esm/components/EmbedPreview/FAB.js +1 -1
  16. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  17. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  18. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  19. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  20. package/dist/esm/components/Pickaxe/Form/Questions/Document.js +1 -1
  21. package/dist/esm/components/Pickaxe/Form/index.js +1 -1
  22. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Code/index.js +1 -1
  23. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  24. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  25. package/dist/esm/hooks/pickaxe/useSubmitDocument.js +1 -1
  26. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +1 -0
  27. package/package.json +1 -1
  28. package/dist/cjs/src/components/Core/ScrollArea.d.ts +0 -12
  29. package/dist/esm/src/components/Core/ScrollArea.d.ts +0 -12
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./index.js"),r=require("../../Icons/chevron-down.svg.js"),n=require("../../../common/cn.js");const o=i.forwardRef(((o,a)=>{var{children:l,variant:c="default",isDisabled:d=!1,style:u,className:v,anchorClassName:f}=o,p=e.__rest(o,["children","variant","isDisabled","style","className","anchorClassName"]);const{id:m,isOpen:j,setIsOpen:x}=i.useContext(s.MenuContext);return"anchor"===c?t.jsxs("div",Object.assign({ref:a,id:m},p,{className:n.default("flex cursor-pointer items-center gap-2",v),style:Object.assign({cursor:d?"not-allowed":"pointer",pointerEvents:d?"none":"auto"},u),onClick:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.stopPropagation(),t.preventDefault(),!d){if(p.onClick)return p.onClick(t),void x(!j);x(!j),yield new Promise((e=>setTimeout(e,100)))}}))},{children:[l,t.jsx(r.default,{className:n.default("duration:300 h-5 w-5 shrink-0 rotate-0 transition-rotate",j&&"rotate-180",f)})]})):t.jsx("div",Object.assign({ref:a,id:m},p,{className:n.default("flex items-center",v),style:Object.assign({cursor:d?"not-allowed":"pointer",pointerEvents:d?"none":"auto"},u),onClick:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.stopPropagation(),t.preventDefault(),d||(p.onClick?p.onClick(t):(x(!j),yield new Promise((e=>setTimeout(e,100)))))}))},{children:l}))}));o.displayName="MenuButton",exports.default=o;
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("./index.js"),r=require("../../Icons/chevron-down.svg.js"),n=require("../../../common/cn.js");const o=i.forwardRef(((o,a)=>{var{children:l,variant:c="default",isDisabled:d=!1,style:u,className:v,anchorClassName:f}=o,p=e.__rest(o,["children","variant","isDisabled","style","className","anchorClassName"]);const{id:m,isOpen:j,setIsOpen:x}=i.useContext(s.MenuContext);return"anchor"===c?t.jsxs("div",Object.assign({ref:a,id:m},p,{className:n.default("flex cursor-pointer items-center gap-2",v),style:Object.assign({cursor:d?"not-allowed":"pointer",pointerEvents:d?"none":"auto"},u),onClick:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.stopPropagation(),t.preventDefault(),!d){if(p.onClick)return p.onClick(t),void x(!j);x(!j),yield new Promise((e=>setTimeout(e,100)))}}))},{children:[l,t.jsx(r.default,{className:n.default("duration-300 h-5 w-5 shrink-0 rotate-0 transition-rotate",j&&"rotate-180",f)})]})):t.jsx("div",Object.assign({ref:a,id:m},p,{className:n.default("flex items-center",v),style:Object.assign({cursor:d?"not-allowed":"pointer",pointerEvents:d?"none":"auto"},u),onClick:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.stopPropagation(),t.preventDefault(),d||(p.onClick?p.onClick(t):(x(!j),yield new Promise((e=>setTimeout(e,100)))))}))},{children:l}))}));o.displayName="MenuButton",exports.default=o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/pickaxe/usePickaxeContext.js"),n=require("@tanstack/react-query"),a=require("../Pickaxe/index.js"),r=require("../Pickaxe/Provider.js"),o=require("framer-motion"),c=require("../Icons/pickaxe.svg.js"),l=require("../Icons/spark.svg.js"),d=require("../Icons/x.svg.js"),u=require("../../common/cn.js");const h=new n.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),m=({isOpen:n,setIsOpen:a})=>{const{colors:r,deploymentMisc:o}=s.usePickaxeContext(),[u,h]=t.useState({src:"",isLarge:!1}),[m,g]=t.useState(!0);return t.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(null==o?void 0:o.fabImage))return;g(!0);const e=new Image;e.src=o.fabImage,yield e.decode();const i=e.width>200;h({src:o.fabImage,isLarge:i})}catch(e){console.error("[pxe] error loading FAB image:",e),h({src:"",isLarge:!1})}finally{g(!1)}}))}),[null==o?void 0:o.fabImage]),m?null:i.jsx("button",Object.assign({className:"absolute z-50 flex h-[60px] w-[60px] cursor-pointer items-center justify-center overflow-hidden rounded-full bg-white dark:bg-black",style:{boxShadow:"0px 6px 6px rgba(0, 0, 0, 0.12)",background:r.primary,color:r.text,bottom:20,right:20},onClick:()=>a(!n)},{children:n?i.jsx(x,Object.assign({id:"close-btn"},{children:i.jsx(d.default,{className:"shrink-0 select-none",style:{width:28,height:28}})})):i.jsx(x,Object.assign({id:"open-btn"},{children:u.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?i.jsx(l.default,{className:"h-6 w-6 shrink-0 select-none"}):u.src?i.jsx("img",{src:u.src,alt:"FAB Icon",width:u.isLarge?60:24,height:u.isLarge?60:24,className:"select-none"}):i.jsx(c.default,{className:"h-6 w-6 shrink-0 select-none"})}))}))},x=({id:e,children:t})=>i.jsx(o.motion.div,Object.assign({initial:{opacity:0,rotate:-10},animate:{opacity:1,rotate:0},exit:{opacity:0,rotate:10},transition:{duration:.3}},{children:t}),e);exports.FAB=s=>{var c,l,d,x,{formId:g,className:b}=s,p=e.__rest(s,["formId","className"]);const[v,f]=t.useState(!1),[j,w]=t.useState({}),y=()=>{const e=p.deploymentDimensions;if(!e)return;const i={value:e.width.value,unit:e.width.unit},t=e.maxWidth,s={value:e.height.value,unit:e.height.unit},n=e.minHeight,a=e.maxHeight,r=window.innerHeight-150,o=window.innerWidth-40;let c=0;c="px"===s.unit?s.value:a;let l=Math.min(c,r);l=Math.max(l,n,100),l=Math.min(l,r);let d=0;d="px"===i.unit?i.value:t;let u=Math.min(d,o,t);u=Math.max(u,150),u=Math.min(u,o);w({width:"%"===i.unit?i.value+"%":u+"px",minWidth:150,maxWidth:u,height:"auto"===s.unit?s.value:l+"px",minHeight:100,maxHeight:l})};return t.useEffect((()=>(y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y))),[p.deploymentDimensions]),i.jsx(n.QueryClientProvider,Object.assign({client:h},{children:i.jsx(r.PickaxeProvider,Object.assign({},p,{deploymentType:"fab",isEmbed:!0},{children:i.jsxs(o.AnimatePresence,{children:[v&&i.jsx(o.motion.div,Object.assign({initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.1},className:u.default("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",p.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(l=null===(c=p.styles)||void 0===c?void 0:c.cornerRadius)&&void 0!==l?l:0,bottom:100,right:20},j)},{children:i.jsx("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin dark:bg-black",style:{borderRadius:null!==(x=null===(d=p.styles)||void 0===d?void 0:d.cornerRadius)&&void 0!==x?x:0}},{children:i.jsx(a.Pickaxe,Object.assign({formId:g},b&&{className:b}))}))}),"fab-content"),i.jsx(m,{isOpen:v,setIsOpen:f})]})}))}))},exports.FABButton=m;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/pickaxe/usePickaxeContext.js"),n=require("@tanstack/react-query"),a=require("../Pickaxe/index.js"),r=require("../Pickaxe/Provider.js"),o=require("framer-motion"),c=require("../Icons/pickaxe.svg.js"),l=require("../Icons/spark.svg.js"),d=require("../Icons/x.svg.js"),u=require("../../common/cn.js");const h=new n.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),m=({isOpen:n,setIsOpen:a})=>{const{colors:r,deploymentMisc:o}=s.usePickaxeContext(),[u,h]=t.useState({src:"",isLarge:!1}),[m,g]=t.useState(!0);return t.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(null==o?void 0:o.fabImage))return;g(!0);const e=new Image;e.src=o.fabImage,yield e.decode();const i=e.width>200;h({src:o.fabImage,isLarge:i})}catch(e){console.error("[pxe] error loading FAB image:",e),h({src:"",isLarge:!1})}finally{g(!1)}}))}),[null==o?void 0:o.fabImage]),m?null:i.jsx("button",Object.assign({className:"absolute z-50 flex h-[60px] w-[60px] cursor-pointer items-center justify-center overflow-hidden rounded-full bg-white dark:bg-black",style:{boxShadow:"0px 6px 6px rgba(0, 0, 0, 0.12)",background:r.primary,color:r.text,bottom:20,right:20},onClick:()=>a(!n)},{children:n?i.jsx(x,Object.assign({id:"close-btn"},{children:i.jsx(d.default,{className:"w-[28px] h-[28px] shrink-0 select-none"})})):i.jsx(x,Object.assign({id:"open-btn"},{children:u.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?i.jsx(l.default,{className:"h-6 w-6 shrink-0 select-none"}):u.src?i.jsx("img",{src:u.src,alt:"FAB Icon",width:u.isLarge?60:24,height:u.isLarge?60:24,className:"select-none"}):i.jsx(c.default,{className:"h-6 w-6 shrink-0 select-none"})}))}))},x=({id:e,children:t})=>i.jsx(o.motion.div,Object.assign({initial:{opacity:0,rotate:-10},animate:{opacity:1,rotate:0},exit:{opacity:0,rotate:10},transition:{duration:.3}},{children:t}),e);exports.FAB=s=>{var c,l,d,x,{formId:g,className:p}=s,b=e.__rest(s,["formId","className"]);const[v,f]=t.useState(!1),[j,w]=t.useState({}),y=()=>{const e=b.deploymentDimensions;if(!e)return;const i={value:e.width.value,unit:e.width.unit},t=e.maxWidth,s={value:e.height.value,unit:e.height.unit},n=e.minHeight,a=e.maxHeight,r=window.innerHeight-150,o=window.innerWidth-40;let c=0;c="px"===s.unit?s.value:a;let l=Math.min(c,r);l=Math.max(l,n,100),l=Math.min(l,r);let d=0;d="px"===i.unit?i.value:t;let u=Math.min(d,o,t);u=Math.max(u,150),u=Math.min(u,o);w({width:"%"===i.unit?i.value+"%":u+"px",minWidth:150,maxWidth:u,height:"auto"===s.unit?s.value:l+"px",minHeight:100,maxHeight:l})};return t.useEffect((()=>(y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y))),[b.deploymentDimensions]),i.jsx(n.QueryClientProvider,Object.assign({client:h},{children:i.jsx(r.PickaxeProvider,Object.assign({},b,{deploymentType:"fab",isEmbed:!0},{children:i.jsxs(o.AnimatePresence,{children:[v&&i.jsx(o.motion.div,Object.assign({initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.1},className:u.default("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",b.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(l=null===(c=b.styles)||void 0===c?void 0:c.cornerRadius)&&void 0!==l?l:0,bottom:100,right:20},j)},{children:i.jsx("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin dark:bg-black",style:{borderRadius:null!==(x=null===(d=b.styles)||void 0===d?void 0:d.cornerRadius)&&void 0!==x?x:0}},{children:i.jsx(a.Pickaxe,Object.assign({formId:g},p&&{className:p}))}))}),"fab-content"),i.jsx(m,{isOpen:v,setIsOpen:f})]})}))}))},exports.FABButton=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js"),u=require("uuid");const a=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"];exports.useDocument=({onQuestionChange:d}={})=>{const{formId:l,chatId:c,sessionId:m,pickaxe:p}=s.usePickaxeContext(),f=o.useDocumentContext(),g=i.useSubmitDocument(),w=t.useMemo((()=>{var e;return a.includes(null!==(e=null==p?void 0:p.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[p]),h=e=>{const t=[...n.allowedFileMimeTypes,...w?n.allowedImageMimeTypes:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(w?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=r.default(e);return f.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},f),{isImageUploadAllowed:w,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(f.setDocumentError(""),!t.length)return null;if(h(t))return null;f.setIsUploading(!0),f.setIsShowList(!0);const s=t.map((e=>({file:e,id:u.v4()})));s.forEach((({file:e,id:t})=>{f.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,error:o}=yield g.document({formId:l,responseId:c,file:t,sessionId:m});if(!e)throw new Error(null!=o?o:"Document processing failed");null==d||d({input:t.name,documentId:i});const n=i.startsWith("IMAGE-");return f.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i}),{name:t.name,documentId:i}}catch(e){const i=r.default(e);return f.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}})))),o=yield Promise.allSettled(i),n=new Set;for(const e of o)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&f.setDocumentError([...n].join(", ")),f.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){f.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");f.setIsUploading(!0),f.setIsShowList(!0),f.setWebsiteLink(""),f.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website({formId:l,responseId:c,website:e}),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");f.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=r.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return f.setDocumentError(s),null;f.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{f.setIsUploading(!1)}}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js"),a=require("uuid");const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"];exports.useDocument=({onQuestionChange:d}={})=>{const{formId:l,chatId:c,sessionId:m,pickaxe:p}=s.usePickaxeContext(),f=o.useDocumentContext(),w=i.useSubmitDocument(),g=t.useMemo((()=>{var e;return u.includes(null!==(e=null==p?void 0:p.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[p]),I=e=>{const t=[...n.allowedFileMimeTypes,...g?n.allowedImageMimeTypes:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(g?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=r.default(e);return f.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},f),{isImageUploadAllowed:g,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(f.setDocumentError(""),!t.length)return null;if(I(t))return null;f.setIsUploading(!0),f.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{f.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,error:o}=yield w.document(Object.assign({formId:l,responseId:c,file:t,sessionId:m},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid}));if(!e)throw new Error(null!=o?o:"Document processing failed");null==d||d({input:t.name,documentId:i});const n=i.startsWith("IMAGE-");return f.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i}),{name:t.name,documentId:i}}catch(e){const i=r.default(e);return f.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}})))),o=yield Promise.allSettled(i),n=new Set;for(const e of o)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&f.setDocumentError([...n].join(", ")),f.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){f.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");f.setIsUploading(!0),f.setIsShowList(!0),f.setWebsiteLink(""),f.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:l,responseId:c,website:e},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid})),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");f.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=r.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return f.setDocumentError(s),null;f.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{f.setIsUploading(!1)}}))})};
@@ -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"),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"),j=require("../../Icons/x.svg.js"),b=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),w=require("../../../common/error.js"),N=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:O,onBlur:C})=>{var q;const{formId:S,chatId:R,userId:T,studioUserId:_,embedUserId:A,deploymentId:D,deploymentType:B,pickaxe:E,styles:F,colors:U,responsiveBy:H,isNewChat:z,isRtl:M,setIsNewChat:P,setIsShowIceBreaker:L,onGenerateComplete:$}=r.usePickaxeContext(),{messages:G,status:J,limits:K,isGenerating:W,setMessages:Q,setStatus:V,setLimitData:X,setError:Y}=o.useResponseContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,documentError:te,onFileUpload:re,setDocuments:oe,setDocumentError:le,removeDocument:ae}=d.useDocument(),{scrollStartSession:ie,scrollEndSession:ne,scrollToBottom:de}=c.useScroll({auto:!0}),ce=i.useConversation(),ue=n.useSubmit(),[me,fe]=t.useState(""),xe=t.useRef(null),pe=u.useHover(),{isHover:he}=pe,ge=e.__rest(pe,["isHover"]),je=u.useHover(),{isHover:be}=je,ve=e.__rest(je,["isHover"]),ye=a.useStyleFontSize(),ke=l.useStyleInput(),we=t.useMemo((()=>{var e,s,t;return!!z&&(!!E&&(!ce.isLoading&&(!((null!==(s=null===(e=ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=E.icebreakers)||void 0===t?void 0:t.length))))}),[E,z,ce.data,ce.isLoading]),Ne=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==J||ee)return;const e=null!=s?s:me;if(!e)return;Y(""),le(""),X(null),fe(""),P(!1),V("fetching"),ie(),de();const t=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r="enduserupload"===(null==E?void 0:E.documentuploadtype)&&t.length>0,o=[...Array.from(G),Object.assign({id:G.length+1,role:"user",content:e},r&&{documentIds:t})];Q(o),de(),r&&oe([]);const l=(yield ue.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:S,responseId:R,value:e},r&&{documentIds:t}),T&&{userId:T}),_&&{studioUserId:_}),A&&{embedUserId:A}),D&&{deploymentId:D}))).body;if(!l)throw new Error("Streaming error");const a=o.length,i=new TextDecoder,n=l.getReader();let d="",c=!0,u=!1;const m=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=s,Q([...o.slice(0,a),{id:G.length+1,role:"assistant",content:d}])}else if("error"===e.event){const s=JSON.parse(e.data);Y(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(c=!1)}});for(;c;){const{value:e,done:s}=yield n.read();if(s){c=!1;break}const t=i.decode(e);t&&(u||(V("streaming"),u=!0),m.feed(t))}null==$||$(R)}catch(e){let s=w.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(K).find((([e])=>s.includes(e)));t?X(t[1]):Y(s)}finally{de(),V("idle"),ne()}}));return t.useEffect((()=>{L(we)}),[we]),s.jsx("div",Object.assign({className:N.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===B&&z)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===B&&z)&&s.jsx("div",Object.assign({className:N.default("absolute bottom-full",M?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:N.default("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===H?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:we&&!I&&s.jsx(v.default,{data:(null==E?void 0:E.icebreakers)||[],onSend:Ne})}))})),s.jsxs("div",Object.assign({className:N.default("flex flex-col gap-y-2 px-4 py-3","block"===F.formFieldStyle&&"shadow"),style:ke},{children:["idle"===J&&Z.length>0&&s.jsx("div",Object.assign({className:N.default("grid grid-cols-1","viewport"===H?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:s.jsx("div",Object.assign({className:"flex flex-row gap-x-2"},{children:Z.filter((e=>"failed"!==e.status)).map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:N.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",M&&"flex-row-reverse"),style:{borderRadius:ke.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:ke.borderRadius}},{children:ee?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:N.default("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(N.default(ye.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:N.default(ye.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:N.default("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:U.accent,borderColor:ke.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.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:ke.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ke.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:ke.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:N.default("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:U.accent,borderColor:ke.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))}))})),s.jsxs("div",Object.assign({className:N.default("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:N.default(ye.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:me,placeholder:M?"بماذا تريد أن تتحدث؟":null!==(q=null==E?void 0:E.placeholdertext)&&void 0!==q?q:"What do you want to talk about?",onChange:e=>fe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==J||Ne()))}},O&&{onFocus:O},C&&{onBlur:C},{dir:M?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:N.default("flex items-center gap-x-2")},{children:["enduserupload"===(null==E?void 0:E.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:be?U.accent+"10":void 0},disabled:ee||"idle"!==J,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...f.allowedFileMimeTypes,...se?f.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){P(!1),yield re(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:be?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:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accent:U.accent+"10"},disabled:ee||"idle"!==J,onClick:()=>Ne()},ge,{children:s.jsx(b.default,{className:N.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accentText:U.accent+"80"}})}))]}))]}))]})),te&&s.jsx(k.default,{error:te,className:"mt-3"})]}))}))};
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"),j=require("../../Icons/x.svg.js"),b=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),N=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:O,onBlur:C})=>{var q;const{formId:S,chatId:R,userId:T,studioUserId:_,embedUserId:A,deploymentId:D,deploymentType:B,pickaxe:E,styles:F,colors:U,responsiveBy:H,isNewChat:z,isRtl:M,setIsNewChat:P,setIsShowIceBreaker:L,onGenerateComplete:$}=r.usePickaxeContext(),{messages:G,status:J,limits:K,isGenerating:W,setMessages:Q,setStatus:V,setLimitData:X,setError:Y}=o.useResponseContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,documentError:te,onFileUpload:re,setDocuments:oe,setDocumentError:le,removeDocument:ae}=d.useDocument(),{scrollStartSession:ie,scrollEndSession:ne,scrollToBottom:de}=c.useScroll({auto:!0}),ce=i.useConversation(),ue=n.useSubmit(),[me,fe]=t.useState(""),xe=t.useRef(null),pe=u.useHover(),{isHover:he}=pe,ge=e.__rest(pe,["isHover"]),je=u.useHover(),{isHover:be}=je,ve=e.__rest(je,["isHover"]),ye=a.useStyleFontSize(),we=l.useStyleInput(),ke=t.useMemo((()=>{var e,s,t;return!!z&&(!!E&&(!ce.isLoading&&(!((null!==(s=null===(e=ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=E.icebreakers)||void 0===t?void 0:t.length))))}),[E,z,ce.data,ce.isLoading]),Ne=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==J||ee)return;const e=null!=s?s:me;if(!e)return;Y(""),le(""),X(null),fe(""),P(!1),V("fetching"),ie(),de();const t=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r="enduserupload"===(null==E?void 0:E.documentuploadtype)&&t.length>0,o=[...Array.from(G),Object.assign({id:G.length+1,role:"user",content:e},r&&{documentIds:t})];Q(o),de(),r&&oe([]);const l=(yield ue.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:S,responseId:R,value:e},r&&{documentIds:t}),T&&{userId:T}),_&&{studioUserId:_}),A&&{embedUserId:A}),D&&{deploymentId:D}))).body;if(!l)throw new Error("Streaming error");const a=o.length,i=new TextDecoder,n=l.getReader();let d="",c=!0,u=!1;const m=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=s,Q([...o.slice(0,a),{id:G.length+1,role:"assistant",content:d}])}else if("error"===e.event){const s=JSON.parse(e.data);Y(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(c=!1)}});for(;c;){const{value:e,done:s}=yield n.read();if(s){c=!1;break}const t=i.decode(e);t&&(u||(V("streaming"),u=!0),m.feed(t))}null==$||$(R)}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(K).find((([e])=>s.includes(e)));t?X(t[1]):Y(s)}finally{de(),V("idle"),ne()}}));return t.useEffect((()=>{L(ke)}),[ke]),s.jsx("div",Object.assign({className:N.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===B&&z)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===B&&z)&&s.jsx("div",Object.assign({className:N.default("absolute bottom-full",M?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:N.default("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===H?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:ke&&!I&&s.jsx(v.default,{data:(null==E?void 0:E.icebreakers)||[],onSend:Ne})}))})),s.jsxs("div",Object.assign({className:N.default("flex flex-col gap-y-2 px-4 py-3","block"===F.formFieldStyle&&"shadow"),style:we},{children:["idle"===J&&Z.length>0&&s.jsx("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:Z.filter((e=>"failed"!==e.status)).map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:N.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",M&&"flex-row-reverse"),style:{borderRadius:we.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:we.borderRadius}},{children:ee?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:N.default("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(N.default(ye.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:N.default(ye.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:N.default("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:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.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:we.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:we.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:we.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:N.default("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:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:N.default("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:N.default(ye.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:me,placeholder:null!==(q=null==E?void 0:E.placeholdertext)&&void 0!==q?q:M?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>fe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==J||Ne()))}},O&&{onFocus:O},C&&{onBlur:C},{dir:M?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==E?void 0:E.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:be?U.accent+"10":void 0},disabled:ee||"idle"!==J,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...f.allowedFileMimeTypes,...se?f.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){P(!1),yield re(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:be?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:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accent:U.accent+"10"},disabled:ee||"idle"!==J,onClick:()=>Ne()},ge,{children:s.jsx(b.default,{className:N.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accentText:U.accent+"80"}})}))]}))]}))]})),te&&s.jsx(w.default,{error:te,className:"mt-3"})]}))}))};
@@ -1 +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
+ "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<=350||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("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../Addons/Scroll/hooks/useScrollContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),r=require("../../common/PickaxeMarkdown/index.js"),i=require("../../common/PickaxeMarkdown/Renderer.js"),c=require("date-fns"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),m=require("../../common/PickaxeCopyButton.js"),p=require("../../common/PickaxeSimpleButton.js"),h=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:b,styles:g,colors:k,misc:v,translations:y,disableHtml:w,disableJs:q,disableCss:N,isRtl:C,setChatId:O,setIsNewChat:M}=t.usePickaxeContext(),{response:I}=o.useResponseContext(),{scrollTargetRef:S}=l.useScrollContext(),{setDocuments:P}=a.useDocument(),D=n.useStyleFontSize(),R=s.useMemo((()=>I?c.format(I.sentAt,"hh:mm a MMM dd, yy"):c.format(new Date,"hh:mm a MMM dd, yy")),[I]),$=s.useMemo((()=>{var e;if(!I)return"";return(null!==(e=I.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[I]);return I?e.jsxs("div",Object.assign({ref:S,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(u.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${I.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:$.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:$}}),e.jsx("label",Object.assign({htmlFor:`${I.responseId}-input`,className:j.default(D.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${I.responseId}-input`,className:j.default(D.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[v.isChatImage&&e.jsx(x.default,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:g.theme,accentColor:k.accent,actions:!0},C&&{rtl:!0},w&&{disableHtml:!0},q&&{disableJs:!0},N&&{disableCss:!0},{children:e.jsx(i.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:I.questionResponse})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==b?void 0:b.enablechatresponses)&&e.jsxs(p.default,Object.assign({color:k.accent,onClick:()=>{return e=I.responseId,P([]),M(!1),void O(e);var e}},{children:[e.jsx(d.default,{className:"pxe-h-4 pxe-w-4 pxe-shrink-0"}),e.jsx("p",Object.assign({className:j.default(D.b3,"pxe-font-semibold")},{children:I.messageCount+1}))]})),e.jsx(m.default,{color:k.accent,text:null!==(f=I.questionResponse)&&void 0!==f?f:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:j.default(D.b3,"font-semibold uppercase opacity-30")},{children:R}))}))]}))]}))]})),e.jsx(h.default,{className:"w-full"})]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../Addons/Scroll/hooks/useScrollContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),r=require("../../common/PickaxeMarkdown/index.js"),i=require("../../common/PickaxeMarkdown/Renderer.js"),c=require("date-fns"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),m=require("../../common/PickaxeCopyButton.js"),h=require("../../common/PickaxeSimpleButton.js"),p=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:b,styles:g,colors:k,misc:v,translations:y,disableHtml:w,disableJs:q,disableCss:N,isRtl:C,setChatId:O,setIsNewChat:M}=t.usePickaxeContext(),{response:I}=o.useResponseContext(),{scrollTargetRef:S}=l.useScrollContext(),{setDocuments:P}=a.useDocument(),D=n.useStyleFontSize(),R=s.useMemo((()=>I?c.format(I.sentAt,"hh:mm a MMM dd, yy"):c.format(new Date,"hh:mm a MMM dd, yy")),[I]),$=s.useMemo((()=>{var e;if(!I)return"";return(null!==(e=I.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[I]);return I?e.jsxs("div",Object.assign({ref:S,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(u.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${I.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:$.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:$}}),e.jsx("label",Object.assign({htmlFor:`${I.responseId}-input`,className:j.default(D.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${I.responseId}-input`,className:j.default(D.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[v.isChatImage&&e.jsx(x.default,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:g.theme,accentColor:k.accent,actions:!0},C&&{rtl:!0},w&&{disableHtml:!0},q&&{disableJs:!0},N&&{disableCss:!0},{children:e.jsx(i.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:I.questionResponse})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==b?void 0:b.enablechatresponses)&&e.jsxs(h.default,Object.assign({color:k.accent,onClick:()=>{return e=I.responseId,P([]),M(!1),void O(e);var e}},{children:[e.jsx(d.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:j.default(D.b3,"font-semibold")},{children:I.messageCount+1}))]})),e.jsx(m.default,{color:k.accent,text:null!==(f=I.questionResponse)&&void 0!==f?f:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:j.default(D.b3,"font-semibold uppercase opacity-30")},{children:R}))}))]}))]}))]})),e.jsx(p.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"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../Addons/Document/hooks/useDocument.js"),o=require("../../../../hooks/core/useHover.js"),n=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),m=require("../../../Icons/spinner-lines.svg.js"),b=require("../../../Icons/file.svg.js"),x=require("../../../Icons/x.svg.js"),j=require("../../../Icons/link.svg.js"),f=require("../../../Core/ErrorAlert.js"),p=require("../../../../common/cn.js");exports.default=({field:h,update:g})=>{var y;const v=r.useStyleFontSize(),{colors:w,styles:N,translations:k,responsiveBy:O}=l.usePickaxeContext(),C=o.useHover(),{isHover:q}=C,I=e.__rest(C,["isHover"]),{documents:R,documentError:T,websiteLink:_,isUploading:D,isImageUploadAllowed:F,removeDocument:S,setDocumentError:A,setWebsiteLink:U,onFileUpload:z,onWebsiteUpload:E}=i.useDocument({onQuestionChange:e=>{g(Object.assign(Object.assign({},h),e))}}),[H,P]=t.useState(!1),B=t.useRef(null),L=a.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:p.default(v.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:w.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:B,type:"file",accept:[...n.allowedFileMimeTypes,...F?n.allowedImageMimeTypes:[]].join(", "),id:h.id,hidden:!0,multiple:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield z(Array.from(s.target.files||[])),s.target.value=""})),disabled:D}),s.jsxs("div",Object.assign({className:p.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",H&&"block"===N.formFieldStyle&&"shadow","block"===N.formFieldStyle&&"shadow hover:shadow-none"),style:L},{children:[s.jsx("input",{type:"text",value:_,className:p.default(v.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(y=null==k?void 0:k["form-doc-placeholder"])&&void 0!==y?y:"Paste a website/video link or drag a file",onChange:e=>U(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield z(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),E(_))},onFocus:()=>P(!0),onBlur:()=>P(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>E(_)},{children:s.jsx(u.default,{className:"h-5 w-5 shrink-0",style:{color:w.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>{U(""),A("")}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0",style:{color:w.accent}})}))]}):s.jsx("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",disabled:D,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:q?w.accent+"10":void 0}},I,{children:s.jsx(d.default,{className:"h-6 w-6 shrink-0",style:{color:q?w.accent:w.accent+"80"}})}))}))]}))]}))]})),R.length>0&&s.jsx("div",Object.assign({className:p.default("flex gap-4","viewport"===O?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:s.jsx("div",Object.assign({className:"flex flex-row gap-x-2"},{children:R.filter((e=>"failed"!==e.status)).map((e=>{var l,a,r;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(b.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:c.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:L.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:L.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}/${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[1]}.${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:L.borderRadius,backgroundColor:w.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"website"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:(null==k?void 0:k.website)||"Website"}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):null},e.id)}))}))})),T&&s.jsx(f.default,{error:T,className:"mt-3"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../Addons/Document/hooks/useDocument.js"),n=require("../../../../hooks/core/useHover.js"),o=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),m=require("../../../Icons/spinner-lines.svg.js"),b=require("../../../Icons/file.svg.js"),x=require("../../../Icons/x.svg.js"),j=require("../../../Icons/link.svg.js"),f=require("../../../Core/ErrorAlert.js"),h=require("../../../../common/cn.js");exports.default=({field:p,update:g})=>{var y;const v=r.useStyleFontSize(),{colors:k,styles:w,translations:N,responsiveBy:O}=l.usePickaxeContext(),C=n.useHover(),{isHover:q}=C,I=e.__rest(C,["isHover"]),{documents:R,documentError:T,websiteLink:_,isUploading:D,isImageUploadAllowed:F,removeDocument:S,setDocumentError:A,setWebsiteLink:U,onFileUpload:z,onWebsiteUpload:E}=i.useDocument({onQuestionChange:e=>{g(Object.assign(Object.assign({},p),e))}}),[H,P]=t.useState(!1),B=t.useRef(null),L=a.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:h.default(v.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:k.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:B,type:"file",accept:[...o.allowedFileMimeTypes,...F?o.allowedImageMimeTypes:[]].join(", "),id:p.id,hidden:!0,multiple:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield z(Array.from(s.target.files||[])),s.target.value=""})),disabled:D}),s.jsxs("div",Object.assign({className:h.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",H&&"block"===w.formFieldStyle&&"shadow","block"===w.formFieldStyle&&"shadow hover:shadow-none"),style:L},{children:[s.jsx("input",{type:"text",value:_,className:h.default(v.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(y=null==N?void 0:N["form-doc-placeholder"])&&void 0!==y?y:"Paste a website/video link or drag a file",onChange:e=>U(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield z(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),E(_))},onFocus:()=>P(!0),onBlur:()=>P(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>E(_)},{children:s.jsx(u.default,{className:"h-5 w-5 shrink-0",style:{color:k.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>{U(""),A("")}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0",style:{color:k.accent}})}))]}):s.jsx("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",disabled:D,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:q?k.accent+"10":void 0}},I,{children:s.jsx(d.default,{className:"h-6 w-6 shrink-0",style:{color:q?k.accent:k.accent+"80"}})}))}))]}))]}))]})),R.length>0&&s.jsx("div",Object.assign({className:h.default("flex gap-4","viewport"===O?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:s.jsx("div",Object.assign({className:"flex flex-row gap-x-2"},{children:R.filter((e=>"failed"!==e.status)).map((e=>{var l,a,r;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:k.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 shrink-0 animate-spin",style:{color:k.accentText}}):s.jsx(b.default,{className:"w-5 h-5 shrink-0",style:{color:k.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(h.default(v.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:h.default(v.b4,"opacity-80 truncate")},{children:c.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:L.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:L.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}/${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[1]}.${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:L.borderRadius,backgroundColor:k.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):"website"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:k.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin shrink-0",style:{color:k.accentText}}):s.jsx(j.default,{className:"w-5 h-5 shrink-0",style:{color:k.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(h.default(v.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),s.jsx("p",Object.assign({className:h.default(v.b4,"opacity-80 truncate")},{children:(null==N?void 0:N.website)||"Website"}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):null},e.id)}))}))})),T&&s.jsx(f.default,{error:T,className:"mt-3"})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Core/Skeleton.js"),x=require("../common/PickaxeHead.js"),a=require("./History/index.js"),t=require("./NewChat.js"),i=require("./Questions/index.js"),r=require("../../../common/cn.js");exports.default=()=>{const{pickaxe:c,responsiveBy:u}=s.usePickaxeContext();return e.jsx("div",Object.assign({className:r.default("flex w-full flex-col items-center pt-12 px-4 pb-10","viewport"===u?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:c?e.jsxs("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[e.jsx(x.default,{}),e.jsxs("div",Object.assign({className:r.default("flex flex-col gap-y-8","viewport"===u?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==c?void 0:c.chatflag)?e.jsx(t.default,{}):e.jsx(i.default,{}),e.jsx(a.default,{})]}))]})):e.jsxs("div",Object.assign({className:"flex w-full max-w-[700px] flex-col items-center"},{children:[e.jsx(l.default,{className:"w-[72px] h-[72px]"}),e.jsx(l.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(l.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(l.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Core/Skeleton.js"),x=require("../common/PickaxeHead.js"),a=require("./History/index.js"),t=require("./NewChat.js"),i=require("./Questions/index.js"),r=require("../../../common/cn.js");exports.default=()=>{const{pickaxe:c,responsiveBy:u}=s.usePickaxeContext();return e.jsx("div",Object.assign({className:r.default("flex w-full flex-col items-center pt-12 px-6 pb-10","viewport"===u?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:c?e.jsxs("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[e.jsx(x.default,{}),e.jsxs("div",Object.assign({className:r.default("flex flex-col gap-y-8","viewport"===u?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==c?void 0:c.chatflag)?e.jsx(t.default,{}):e.jsx(i.default,{}),e.jsx(a.default,{})]}))]})):e.jsxs("div",Object.assign({className:"flex w-full max-w-[700px] flex-col items-center"},{children:[e.jsx(l.default,{className:"w-[72px] h-[72px]"}),e.jsx(l.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(l.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(l.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),r=require("react-syntax-highlighter"),i=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../PickaxeCopyButton.js");exports.Code=t=>{var a,l,{children:c,className:d}=t,o=e.__rest(t,["children","className"]);const{syntaxTheme:u}=i.usePickaxeMarkdownContext(),x=/language-(\w+)/.exec(d||"");return x?s.jsx("div",Object.assign({className:"pxe-markdown-code"},{children:s.jsxs("div",{children:[s.jsx("div",{children:s.jsx(n.default,{color:"#FFFFFF",text:null!==(a=null==c?void 0:c.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),s.jsx("div",{children:s.jsx(r.Prism,Object.assign({},o,{PreTag:"div",language:null!==(l=null==x?void 0:x[1])&&void 0!==l?l:"js",style:u,showLineNumbers:!0},{children:String(c).replace(/\n$/,"")}))})]})})):s.jsx("code",Object.assign({},o,{className:"pxe-markdown-code-inline"},{children:c}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),r=require("react-syntax-highlighter"),i=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../PickaxeCopyButton.js");exports.Code=t=>{var a,l,{node:c,children:d,className:o}=t,u=e.__rest(t,["node","children","className"]);const{syntaxTheme:x}=i.usePickaxeMarkdownContext(),h=/language-(\w+)/.exec(o||"");return h?s.jsx("div",Object.assign({className:"pxe-markdown-code"},{children:s.jsxs("div",{children:[s.jsx("div",{children:s.jsx(n.default,{color:"#FFFFFF",text:null!==(a=null==d?void 0:d.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),s.jsx("div",{children:s.jsx(r.Prism,Object.assign({},u,{PreTag:"div",language:null!==(l=null==h?void 0:h[1])&&void 0!==l?l:"js",style:x,showLineNumbers:!0},{children:String(d).replace(/\n$/,"")}))})]})})):s.jsx("code",Object.assign({},u,{className:"pxe-markdown-code-inline"},{children:d}))};
@@ -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"),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
+ "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"),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(o),y=q(a),v=q(l),A=q(u);exports.PickaxeMarkdownRenderer=({className:i,style:o,children:a,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"},o)},M&&{dir:"rtl"},{children:[r.jsx(k.default,Object.assign({className:C.default(!H&&"pxe-prose",i),components:z,remarkPlugins:[w.default,[y.default,{singleDollarTextMath:!1}]],rehypePlugins:[s.rehypeCode,v.default,...$?[]:[A.default],[s.rehypeSanitize,{disableJs:T,disableCss:_}],s.rehypePickaxeAction]},{children:F})),a]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"];exports.rehypePickaxeAction=()=>r=>(e.visit(r,"element",(e=>{const i=e.tagName;if(t.includes(i)){const t=i.split("-");e.tagName=t.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e.visit(r,"element",((t,r,o)=>{if("p"===t.tagName){const s=t.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===s.length){const t=s[0];if("element"===t.type&&i.includes(t.tagName)&&o&&"children"in o&&o.children&&void 0!==r)return o.children.splice(r,1,t),[e.SKIP,r]}}})),r),exports.rehypeSanitize=(t={})=>i=>{e.visit(i,"element",((i,r,o)=>{if(t.disableJs){if("script"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r];if(i.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{i.properties[e]&&delete i.properties[e]})),i.properties.href&&"string"==typeof i.properties.href&&i.properties.href.toLowerCase().startsWith("javascript:")&&delete i.properties.href}}if(t.disableCss&&"style"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"];exports.rehypeCode=()=>t=>{e.visit(t,"code",(e=>{var t;e.lang=null!==(t=e.lang)&&void 0!==t?t:"plaintext"}))},exports.rehypePickaxeAction=()=>r=>(e.visit(r,"element",(e=>{const i=e.tagName;if(t.includes(i)){const t=i.split("-");e.tagName=t.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e.visit(r,"element",((t,r,o)=>{if("p"===t.tagName){const n=t.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===n.length){const t=n[0];if("element"===t.type&&i.includes(t.tagName)&&o&&"children"in o&&o.children&&void 0!==r)return o.children.splice(r,1,t),[e.SKIP,r]}}})),r),exports.rehypeSanitize=(t={})=>i=>{e.visit(i,"element",((i,r,o)=>{if(t.disableJs){if("script"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r];if(i.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{i.properties[e]&&delete i.properties[e]})),i.properties.href&&"string"==typeof i.properties.href&&i.properties.href.toLowerCase().startsWith("javascript:")&&delete i.properties.href}}if(t.disableCss&&"style"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("../../common/utils.js");exports.useSubmitDocument=()=>({document:({formId:s,workspaceId:o,responseId:i,file:t,isKnowledge:n,isBlocking:r,sessionId:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=t.name.split(".").pop(),_=t.type,l={formid:s,mimetype:_,extension:a,responseid:i,workspaceid:o,sessionid:c},p=new URLSearchParams(Object.entries(l).filter((e=>void 0!==e[1]))),u=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${p.toString()}`,O=yield fetch(u),g=yield O.json();if(!g.success)throw new Error(null!==(e=g.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const f=new FormData;Object.entries(Object.assign(Object.assign({},g.fields),{file:t})).forEach((([e,s])=>{f.append(e,s)}));const m=yield fetch(g.url,{method:"POST",body:f});if(!m.ok)throw new Error(m.statusText);const w=`${g.url}${g.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),_.startsWith("image"))return{success:!0,documentId:`IMAGE-${g.documentId}-${g.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:g.documentId}),i&&{responseId:i}),{fileName:t.name,fileSize:t.size}),n&&{isKnowledge:n}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),b=yield I.json();if(!b.success)throw new Error(null!==(d=b.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return b})),website:({formId:o,workspaceId:i,responseId:t,website:n,isKnowledge:r,isBlocking:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s.generateId(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},i&&{workspaceId:i}),{documentId:d}),t&&{responseId:t}),{website:n}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),_=yield a.json();if(!_.success)throw new Error(null!==(e=_.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return _}))});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("../../common/utils.js");exports.useSubmitDocument=()=>({document:({formId:s,workspaceId:o,responseId:i,file:n,isKnowledge:t,isBlocking:r,sessionId:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=n.name.split(".").pop(),l=n.type,_={formid:s,mimetype:l,extension:a,responseid:i,workspaceid:o,sessionid:c},p=new URLSearchParams(Object.entries(_).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),u=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${p.toString()}`,O=yield fetch(u),g=yield O.json();if(!g.success)throw new Error(null!==(e=g.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const f=new FormData;Object.entries(Object.assign(Object.assign({},g.fields),{file:n})).forEach((([e,s])=>{f.append(e,s)}));const m=yield fetch(g.url,{method:"POST",body:f});if(!m.ok)throw new Error(m.statusText);const w=`${g.url}${g.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),l.startsWith("image"))return{success:!0,documentId:`IMAGE-${g.documentId}-${g.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:g.documentId}),i&&{responseId:i}),{fileName:n.name,fileSize:n.size}),t&&{isKnowledge:t}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),b=yield I.json();if(!b.success)throw new Error(null!==(d=b.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return b})),website:({formId:o,workspaceId:i,responseId:n,website:t,isKnowledge:r,isBlocking:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s.generateId(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},i&&{workspaceId:i}),{documentId:d}),n&&{responseId:n}),{website:t}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),l=yield a.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return l}))});
@@ -3,3 +3,4 @@ export declare const rehypeSanitize: (options?: {
3
3
  disableJs?: boolean;
4
4
  disableCss?: boolean;
5
5
  }) => (tree: any) => void;
6
+ export declare const rehypeCode: () => (tree: any) => void;
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as o}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{forwardRef as n,useContext as s}from"react";import{MenuContext as r}from"./index.js";import a from"../../Icons/chevron-down.svg.js";import l from"../../../common/cn.js";const c=n(((n,c)=>{var{children:m,variant:d="default",isDisabled:p=!1,style:u,className:v,anchorClassName:f}=n,h=e(n,["children","variant","isDisabled","style","className","anchorClassName"]);const{id:j,isOpen:g,setIsOpen:C}=s(r);return"anchor"===d?t("div",Object.assign({ref:c,id:j},h,{className:l("flex cursor-pointer items-center gap-2",v),style:Object.assign({cursor:p?"not-allowed":"pointer",pointerEvents:p?"none":"auto"},u),onClick:e=>o(void 0,void 0,void 0,(function*(){if(e.stopPropagation(),e.preventDefault(),!p){if(h.onClick)return h.onClick(e),void C(!g);C(!g),yield new Promise((e=>setTimeout(e,100)))}}))},{children:[m,i(a,{className:l("duration:300 h-5 w-5 shrink-0 rotate-0 transition-rotate",g&&"rotate-180",f)})]})):i("div",Object.assign({ref:c,id:j},h,{className:l("flex items-center",v),style:Object.assign({cursor:p?"not-allowed":"pointer",pointerEvents:p?"none":"auto"},u),onClick:e=>o(void 0,void 0,void 0,(function*(){e.stopPropagation(),e.preventDefault(),p||(h.onClick?h.onClick(e):(C(!g),yield new Promise((e=>setTimeout(e,100)))))}))},{children:m}))}));c.displayName="MenuButton";export{c as default};
1
+ import{__rest as e,__awaiter as o}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{forwardRef as n,useContext as s}from"react";import{MenuContext as r}from"./index.js";import a from"../../Icons/chevron-down.svg.js";import l from"../../../common/cn.js";const c=n(((n,c)=>{var{children:m,variant:d="default",isDisabled:p=!1,style:u,className:v,anchorClassName:f}=n,h=e(n,["children","variant","isDisabled","style","className","anchorClassName"]);const{id:j,isOpen:g,setIsOpen:C}=s(r);return"anchor"===d?t("div",Object.assign({ref:c,id:j},h,{className:l("flex cursor-pointer items-center gap-2",v),style:Object.assign({cursor:p?"not-allowed":"pointer",pointerEvents:p?"none":"auto"},u),onClick:e=>o(void 0,void 0,void 0,(function*(){if(e.stopPropagation(),e.preventDefault(),!p){if(h.onClick)return h.onClick(e),void C(!g);C(!g),yield new Promise((e=>setTimeout(e,100)))}}))},{children:[m,i(a,{className:l("duration-300 h-5 w-5 shrink-0 rotate-0 transition-rotate",g&&"rotate-180",f)})]})):i("div",Object.assign({ref:c,id:j},h,{className:l("flex items-center",v),style:Object.assign({cursor:p?"not-allowed":"pointer",pointerEvents:p?"none":"auto"},u),onClick:e=>o(void 0,void 0,void 0,(function*(){e.stopPropagation(),e.preventDefault(),p||(h.onClick?h.onClick(e):(C(!g),yield new Promise((e=>setTimeout(e,100)))))}))},{children:m}))}));c.displayName="MenuButton";export{c as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as i}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as s,useEffect as o}from"react";import{usePickaxeContext as a}from"../../hooks/pickaxe/usePickaxeContext.js";import{QueryClient as r,QueryClientProvider as c}from"@tanstack/react-query";import{Pickaxe as l}from"../Pickaxe/index.js";import{PickaxeProvider as d}from"../Pickaxe/Provider.js";import{AnimatePresence as m,motion as h}from"framer-motion";import u from"../Icons/pickaxe.svg.js";import p from"../Icons/spark.svg.js";import g from"../Icons/x.svg.js";import b from"../../common/cn.js";const f=new r({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),x=i=>{var a,r,u,p,{formId:g,className:x}=i,w=e(i,["formId","className"]);const[y,j]=s(!1),[k,O]=s({}),I=()=>{const e=w.deploymentDimensions;if(!e)return;const i={value:e.width.value,unit:e.width.unit},t=e.maxWidth,n={value:e.height.value,unit:e.height.unit},s=e.minHeight,o=e.maxHeight,a=window.innerHeight-150,r=window.innerWidth-40;let c=0;c="px"===n.unit?n.value:o;let l=Math.min(c,a);l=Math.max(l,s,100),l=Math.min(l,a);let d=0;d="px"===i.unit?i.value:t;let m=Math.min(d,r,t);m=Math.max(m,150),m=Math.min(m,r);O({width:"%"===i.unit?i.value+"%":m+"px",minWidth:150,maxWidth:m,height:"auto"===n.unit?n.value:l+"px",minHeight:100,maxHeight:l})};return o((()=>(I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I))),[w.deploymentDimensions]),t(c,Object.assign({client:f},{children:t(d,Object.assign({},w,{deploymentType:"fab",isEmbed:!0},{children:n(m,{children:[y&&t(h.div,Object.assign({initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.1},className:b("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",w.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(r=null===(a=w.styles)||void 0===a?void 0:a.cornerRadius)&&void 0!==r?r:0,bottom:100,right:20},k)},{children:t("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin dark:bg-black",style:{borderRadius:null!==(p=null===(u=w.styles)||void 0===u?void 0:u.cornerRadius)&&void 0!==p?p:0}},{children:t(l,Object.assign({formId:g},x&&{className:x}))}))}),"fab-content"),t(v,{isOpen:y,setIsOpen:j})]})}))}))},v=({isOpen:e,setIsOpen:n})=>{const{colors:r,deploymentMisc:c}=a(),[l,d]=s({src:"",isLarge:!1}),[m,h]=s(!0);return o((()=>{i(void 0,void 0,void 0,(function*(){try{if(!(null==c?void 0:c.fabImage))return;h(!0);const e=new Image;e.src=c.fabImage,yield e.decode();const i=e.width>200;d({src:c.fabImage,isLarge:i})}catch(e){console.error("[pxe] error loading FAB image:",e),d({src:"",isLarge:!1})}finally{h(!1)}}))}),[null==c?void 0:c.fabImage]),m?null:t("button",Object.assign({className:"absolute z-50 flex h-[60px] w-[60px] cursor-pointer items-center justify-center overflow-hidden rounded-full bg-white dark:bg-black",style:{boxShadow:"0px 6px 6px rgba(0, 0, 0, 0.12)",background:r.primary,color:r.text,bottom:20,right:20},onClick:()=>n(!e)},{children:t(w,e?Object.assign({id:"close-btn"},{children:t(g,{className:"shrink-0 select-none",style:{width:28,height:28}})}):Object.assign({id:"open-btn"},{children:l.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?t(p,{className:"h-6 w-6 shrink-0 select-none"}):l.src?t("img",{src:l.src,alt:"FAB Icon",width:l.isLarge?60:24,height:l.isLarge?60:24,className:"select-none"}):t(u,{className:"h-6 w-6 shrink-0 select-none"})}))}))},w=({id:e,children:i})=>t(h.div,Object.assign({initial:{opacity:0,rotate:-10},animate:{opacity:1,rotate:0},exit:{opacity:0,rotate:10},transition:{duration:.3}},{children:i}),e);export{x as FAB,v as FABButton};
1
+ import{__rest as e,__awaiter as i}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as s,useEffect as o}from"react";import{usePickaxeContext as a}from"../../hooks/pickaxe/usePickaxeContext.js";import{QueryClient as r,QueryClientProvider as c}from"@tanstack/react-query";import{Pickaxe as l}from"../Pickaxe/index.js";import{PickaxeProvider as d}from"../Pickaxe/Provider.js";import{AnimatePresence as m,motion as h}from"framer-motion";import p from"../Icons/pickaxe.svg.js";import u from"../Icons/spark.svg.js";import g from"../Icons/x.svg.js";import b from"../../common/cn.js";const f=new r({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),x=i=>{var a,r,p,u,{formId:g,className:x}=i,w=e(i,["formId","className"]);const[y,j]=s(!1),[k,O]=s({}),I=()=>{const e=w.deploymentDimensions;if(!e)return;const i={value:e.width.value,unit:e.width.unit},t=e.maxWidth,n={value:e.height.value,unit:e.height.unit},s=e.minHeight,o=e.maxHeight,a=window.innerHeight-150,r=window.innerWidth-40;let c=0;c="px"===n.unit?n.value:o;let l=Math.min(c,a);l=Math.max(l,s,100),l=Math.min(l,a);let d=0;d="px"===i.unit?i.value:t;let m=Math.min(d,r,t);m=Math.max(m,150),m=Math.min(m,r);O({width:"%"===i.unit?i.value+"%":m+"px",minWidth:150,maxWidth:m,height:"auto"===n.unit?n.value:l+"px",minHeight:100,maxHeight:l})};return o((()=>(I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I))),[w.deploymentDimensions]),t(c,Object.assign({client:f},{children:t(d,Object.assign({},w,{deploymentType:"fab",isEmbed:!0},{children:n(m,{children:[y&&t(h.div,Object.assign({initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.1},className:b("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",w.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(r=null===(a=w.styles)||void 0===a?void 0:a.cornerRadius)&&void 0!==r?r:0,bottom:100,right:20},k)},{children:t("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin dark:bg-black",style:{borderRadius:null!==(u=null===(p=w.styles)||void 0===p?void 0:p.cornerRadius)&&void 0!==u?u:0}},{children:t(l,Object.assign({formId:g},x&&{className:x}))}))}),"fab-content"),t(v,{isOpen:y,setIsOpen:j})]})}))}))},v=({isOpen:e,setIsOpen:n})=>{const{colors:r,deploymentMisc:c}=a(),[l,d]=s({src:"",isLarge:!1}),[m,h]=s(!0);return o((()=>{i(void 0,void 0,void 0,(function*(){try{if(!(null==c?void 0:c.fabImage))return;h(!0);const e=new Image;e.src=c.fabImage,yield e.decode();const i=e.width>200;d({src:c.fabImage,isLarge:i})}catch(e){console.error("[pxe] error loading FAB image:",e),d({src:"",isLarge:!1})}finally{h(!1)}}))}),[null==c?void 0:c.fabImage]),m?null:t("button",Object.assign({className:"absolute z-50 flex h-[60px] w-[60px] cursor-pointer items-center justify-center overflow-hidden rounded-full bg-white dark:bg-black",style:{boxShadow:"0px 6px 6px rgba(0, 0, 0, 0.12)",background:r.primary,color:r.text,bottom:20,right:20},onClick:()=>n(!e)},{children:t(w,e?Object.assign({id:"close-btn"},{children:t(g,{className:"w-[28px] h-[28px] shrink-0 select-none"})}):Object.assign({id:"open-btn"},{children:l.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?t(u,{className:"h-6 w-6 shrink-0 select-none"}):l.src?t("img",{src:l.src,alt:"FAB Icon",width:l.isLarge?60:24,height:l.isLarge?60:24,className:"select-none"}):t(p,{className:"h-6 w-6 shrink-0 select-none"})}))}))},w=({id:e,children:i})=>t(h.div,Object.assign({initial:{opacity:0,rotate:-10},animate:{opacity:1,rotate:0},exit:{opacity:0,rotate:10},transition:{duration:.3}},{children:i}),e);export{x as FAB,v as FABButton};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as i}from"./useDocumentContext.js";import{allowedFileMimeTypes as n,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import d from"../../../../../common/error.js";import{v4 as a}from"uuid";const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"],l=({onQuestionChange:l}={})=>{const{formId:m,chatId:c,sessionId:p,pickaxe:f}=o(),g=i(),h=s(),I=t((()=>{var e;return u.includes(null!==(e=null==f?void 0:f.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[f]),w=e=>{const t=[...n,...I?r:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(I?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=d(e);return g.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},g),{isImageUploadAllowed:I,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(g.setDocumentError(""),!t.length)return null;if(w(t))return null;g.setIsUploading(!0),g.setIsShowList(!0);const o=t.map((e=>({file:e,id:a()})));o.forEach((({file:e,id:t})=>{g.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const s=o.map((({file:t,id:o})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:s,error:i}=yield h.document({formId:m,responseId:c,file:t,sessionId:p});if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:s});const n=s.startsWith("IMAGE-");return g.editDocument({id:o,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:s}),{name:t.name,documentId:s}}catch(e){const s=d(e);return g.editDocument({id:o,name:t.name,size:t.size,status:"failed",error:s}),{error:s}}})))),i=yield Promise.allSettled(s),n=new Set;for(const e of i)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&g.setDocumentError([...n].join(", ")),g.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){g.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");g.setIsUploading(!0),g.setIsShowList(!0),g.setWebsiteLink(""),g.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield h.website({formId:m,responseId:c,website:e}),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");g.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:s}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:s}}catch(t){const o=d(t);if(console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL"))return g.setDocumentError(o),null;g.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:o});return{type:"website",id:e,size:0,name:e,status:"failed",error:o}}finally{g.setIsUploading(!1)}}))})};export{l as useDocument};
1
+ import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as i}from"./useDocumentContext.js";import{allowedFileMimeTypes as n,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import d from"../../../../../common/error.js";import{v4 as a}from"uuid";const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"],l=({onQuestionChange:l}={})=>{const{formId:c,chatId:m,sessionId:p,pickaxe:f}=o(),g=i(),w=s(),I=t((()=>{var e;return u.includes(null!==(e=null==f?void 0:f.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[f]),h=e=>{const t=[...n,...I?r:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(I?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=d(e);return g.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},g),{isImageUploadAllowed:I,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(g.setDocumentError(""),!t.length)return null;if(h(t))return null;g.setIsUploading(!0),g.setIsShowList(!0);const o=t.map((e=>({file:e,id:a()})));o.forEach((({file:e,id:t})=>{g.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const s=o.map((({file:t,id:o})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:s,error:i}=yield w.document(Object.assign({formId:c,responseId:m,file:t,sessionId:p},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:s});const n=s.startsWith("IMAGE-");return g.editDocument({id:o,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:s}),{name:t.name,documentId:s}}catch(e){const s=d(e);return g.editDocument({id:o,name:t.name,size:t.size,status:"failed",error:s}),{error:s}}})))),i=yield Promise.allSettled(s),n=new Set;for(const e of i)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&g.setDocumentError([...n].join(", ")),g.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){g.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");g.setIsUploading(!0),g.setIsShowList(!0),g.setWebsiteLink(""),g.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:c,responseId:m,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid})),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");g.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:s}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:s}}catch(t){const o=d(t);if(console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL"))return g.setDocumentError(o),null;g.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:o});return{type:"website",id:e,size:0,name:e,status:"failed",error:o}}finally{g.setIsUploading(!1)}}))})};export{l as useDocument};
@@ -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"../../Core/ErrorAlert.js";import A from"../../../common/error.js";import T from"../../../common/cn.js";const D=({isFocused:D,onFocus:B,onBlur:E})=>{var U;const{formId:F,chatId:H,userId:z,studioUserId:L,embedUserId:$,deploymentId:G,deploymentType:J,pickaxe:K,styles:P,colors:W,responsiveBy:_,isNewChat:M,isRtl:q,setIsNewChat:Q,setIsShowIceBreaker:V,onGenerateComplete:X}=c(),{messages:Y,status:Z,limits:ee,isGenerating:te,setMessages:se,setStatus:oe,setLimitData:re,setError:ie}=d(),{documents:ne,isUploading:le,isImageUploadAllowed:ae,documentError:ce,onFileUpload:de,setDocuments:ue,setDocumentError:me,removeDocument:pe}=h(),{scrollStartSession:fe,scrollEndSession:he,scrollToBottom:ge}=g({auto:!0}),be=p(),ve=f(),[xe,ye]=r(""),je=i(null),ke=b(),{isHover:we}=ke,Ne=e(ke,["isHover"]),Ie=b(),{isHover:Oe}=Ie,Ce=e(Ie,["isHover"]),Se=m(),Re=u(),Ae=n((()=>{var e,t,s;return!!M&&(!!K&&(!be.isLoading&&(!((null!==(t=null===(e=be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=K.icebreakers)||void 0===s?void 0:s.length))))}),[K,M,be.data,be.isLoading]),Te=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Z||le)return;const t=null!=e?e:xe;if(!t)return;ie(""),me(""),re(null),ye(""),Q(!1),oe("fetching"),fe(),ge();const s=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o="enduserupload"===(null==K?void 0:K.documentuploadtype)&&s.length>0,r=[...Array.from(Y),Object.assign({id:Y.length+1,role:"user",content:t},o&&{documentIds:s})];se(r),ge(),o&&ue([]);const i=(yield ve.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:H,value:t},o&&{documentIds:s}),z&&{userId:z}),L&&{studioUserId:L}),$&&{embedUserId:$}),G&&{deploymentId:G}))).body;if(!i)throw new Error("Streaming error");const n=r.length,l=new TextDecoder,a=i.getReader();let c="",d=!0,u=!1;const m=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=t,se([...r.slice(0,n),{id:Y.length+1,role:"assistant",content:c}])}else if("error"===e.event){const t=JSON.parse(e.data);ie(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(d=!1)}});for(;d;){const{value:e,done:t}=yield a.read();if(t){d=!1;break}const s=l.decode(e);s&&(u||(oe("streaming"),u=!0),m.feed(s))}null==X||X(H)}catch(e){let t=A(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(ee).find((([e])=>t.includes(e)));s?re(s[1]):ie(t)}finally{ge(),oe("idle"),he()}}));return l((()=>{V(Ae)}),[Ae]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===J&&M)&&"px-4 pb-4"),dir:q?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===J&&M)&&s("div",Object.assign({className:T("absolute bottom-full",q?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",q?"justify-start":"justify-end","viewport"===_?q?"min-[767px]:items-start":"min-[767px]:items-end":q?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Ae&&!D&&s(C,{data:(null==K?void 0:K.icebreakers)||[],onSend:Te})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===P.formFieldStyle&&"shadow"),style:Re},{children:["idle"===Z&&ne.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===_?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:s("div",Object.assign({className:"flex flex-row gap-x-2"},{children:ne.filter((e=>"failed"!==e.status)).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",q&&"flex-row-reverse"),style:{borderRadius:Re.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:Re.borderRadius}},{children:le?s(w,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",q?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Se.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Se.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",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Re.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Re.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:Re.borderRadius,backgroundColor:W.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",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",q&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Se.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",q?"text-right":"text-left"),value:xe,placeholder:q?"بماذا تريد أن تتحدث؟":null!==(U=null==K?void 0:K.placeholdertext)&&void 0!==U?U:"What do you want to talk about?",onChange:e=>ye(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),le||"idle"!==Z||Te()))}},B&&{onFocus:B},E&&{onBlur:E},{dir:q?"rtl":"ltr"})),o("div",Object.assign({className:T("flex items-center gap-x-2")},{children:["enduserupload"===(null==K?void 0:K.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:Oe?W.accent+"10":void 0},disabled:le||"idle"!==Z,onClick:()=>{var e;return null===(e=je.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:je,type:"file",accept:[...x,...ae?y:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){Q(!1),yield de(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:Oe?W.accent:W.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:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accent:W.accent+"10"},disabled:le||"idle"!==Z,onClick:()=>Te()},Ne,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",q&&"transform scale-x-[-1]"),style:{color:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accentText:W.accent+"80"}})}))]}))]}))]})),ce&&s(R,{error:ce,className:"mt-3"})]}))}))};export{D 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"../../Core/ErrorAlert.js";import A from"../../../common/error.js";import T from"../../../common/cn.js";const D=({isFocused:D,onFocus:B,onBlur:E})=>{var U;const{formId:F,chatId:H,userId:z,studioUserId:L,embedUserId:$,deploymentId:G,deploymentType:J,pickaxe:K,styles:P,colors:W,responsiveBy:_,isNewChat:M,isRtl:q,setIsNewChat:Q,setIsShowIceBreaker:V,onGenerateComplete:X}=c(),{messages:Y,status:Z,limits:ee,isGenerating:te,setMessages:se,setStatus:oe,setLimitData:re,setError:ie}=d(),{documents:ne,isUploading:le,isImageUploadAllowed:ae,documentError:ce,onFileUpload:de,setDocuments:ue,setDocumentError:me,removeDocument:pe}=h(),{scrollStartSession:fe,scrollEndSession:he,scrollToBottom:ge}=g({auto:!0}),be=p(),ve=f(),[xe,ye]=r(""),je=i(null),ke=b(),{isHover:we}=ke,Ne=e(ke,["isHover"]),Ie=b(),{isHover:Oe}=Ie,Ce=e(Ie,["isHover"]),Se=m(),Re=u(),Ae=n((()=>{var e,t,s;return!!M&&(!!K&&(!be.isLoading&&(!((null!==(t=null===(e=be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=K.icebreakers)||void 0===s?void 0:s.length))))}),[K,M,be.data,be.isLoading]),Te=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Z||le)return;const t=null!=e?e:xe;if(!t)return;ie(""),me(""),re(null),ye(""),Q(!1),oe("fetching"),fe(),ge();const s=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o="enduserupload"===(null==K?void 0:K.documentuploadtype)&&s.length>0,r=[...Array.from(Y),Object.assign({id:Y.length+1,role:"user",content:t},o&&{documentIds:s})];se(r),ge(),o&&ue([]);const i=(yield ve.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:H,value:t},o&&{documentIds:s}),z&&{userId:z}),L&&{studioUserId:L}),$&&{embedUserId:$}),G&&{deploymentId:G}))).body;if(!i)throw new Error("Streaming error");const n=r.length,l=new TextDecoder,a=i.getReader();let c="",d=!0,u=!1;const m=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=t,se([...r.slice(0,n),{id:Y.length+1,role:"assistant",content:c}])}else if("error"===e.event){const t=JSON.parse(e.data);ie(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(d=!1)}});for(;d;){const{value:e,done:t}=yield a.read();if(t){d=!1;break}const s=l.decode(e);s&&(u||(oe("streaming"),u=!0),m.feed(s))}null==X||X(H)}catch(e){let t=A(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(ee).find((([e])=>t.includes(e)));s?re(s[1]):ie(t)}finally{ge(),oe("idle"),he()}}));return l((()=>{V(Ae)}),[Ae]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===J&&M)&&"px-4 pb-4"),dir:q?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===J&&M)&&s("div",Object.assign({className:T("absolute bottom-full",q?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",q?"justify-start":"justify-end","viewport"===_?q?"min-[767px]:items-start":"min-[767px]:items-end":q?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Ae&&!D&&s(C,{data:(null==K?void 0:K.icebreakers)||[],onSend:Te})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===P.formFieldStyle&&"shadow"),style:Re},{children:["idle"===Z&&ne.length>0&&s("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:ne.filter((e=>"failed"!==e.status)).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",q&&"flex-row-reverse"),style:{borderRadius:Re.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:Re.borderRadius}},{children:le?s(w,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",q?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Se.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Se.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",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Re.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Re.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:Re.borderRadius,backgroundColor:W.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",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",q&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Se.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",q?"text-right":"text-left"),value:xe,placeholder:null!==(U=null==K?void 0:K.placeholdertext)&&void 0!==U?U:q?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>ye(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),le||"idle"!==Z||Te()))}},B&&{onFocus:B},E&&{onBlur:E},{dir:q?"rtl":"ltr"})),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==K?void 0:K.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:Oe?W.accent+"10":void 0},disabled:le||"idle"!==Z,onClick:()=>{var e;return null===(e=je.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:je,type:"file",accept:[...x,...ae?y:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){Q(!1),yield de(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:Oe?W.accent:W.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:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accent:W.accent+"10"},disabled:le||"idle"!==Z,onClick:()=>Te()},Ne,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",q&&"transform scale-x-[-1]"),style:{color:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accentText:W.accent+"80"}})}))]}))]}))]})),ce&&s(R,{error:ce,className:"mt-3"})]}))}))};export{D as default};
@@ -1 +1 @@
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
+ 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<=350||h,isInputFocused:h}),e(u,{isFocused:h,onFocus:()=>j(!0),onBlur:()=>j(!1)})]}))};export{f as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as i}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as l}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as r}from"../../Addons/Document/hooks/useDocument.js";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as c}from"../../common/PickaxeMarkdown/Renderer.js";import{format as m}from"date-fns";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeCopyButton.js";import u from"../../common/PickaxeSimpleButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import b from"../../../../common/cn.js";const g=()=>{var g;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,disableHtml:N,disableJs:C,disableCss:O,isRtl:I,setChatId:S,setIsNewChat:D}=t(),{response:M}=n(),{scrollTargetRef:P}=i(),{setDocuments:R}=r(),$=l(),q=o((()=>m(M?M.sentAt:new Date,"hh:mm a MMM dd, yy")),[M]),A=o((()=>{var e;if(!M)return"";return(null!==(e=M.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[M]);return M?e("div",Object.assign({ref:P,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${M.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:A.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:A}}),s("label",Object.assign({htmlFor:`${M.responseId}-input`,className:b($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${M.responseId}-input`,className:b($.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[y.isChatImage&&s(h,{src:null==v?void 0:v.chaticon,alt:`${null==v?void 0:v.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(a,Object.assign({theme:j.theme,accentColor:k.accent,actions:!0},I&&{rtl:!0},N&&{disableHtml:!0},C&&{disableJs:!0},O&&{disableCss:!0},{children:s(c,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:M.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==v?void 0:v.enablechatresponses)&&e(u,Object.assign({color:k.accent,onClick:()=>{return e=M.responseId,R([]),D(!1),void S(e);var e}},{children:[s(d,{className:"pxe-h-4 pxe-w-4 pxe-shrink-0"}),s("p",Object.assign({className:b($.b3,"pxe-font-semibold")},{children:M.messageCount+1}))]})),s(f,{color:k.accent,text:null!==(g=M.questionResponse)&&void 0!==g?g:""})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:b($.b3,"font-semibold uppercase opacity-30")},{children:q}))}))]}))]}))]})),s(x,{className:"w-full"})]})):null};export{g as default};
1
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as i}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as l}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as r}from"../../Addons/Document/hooks/useDocument.js";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as c}from"../../common/PickaxeMarkdown/Renderer.js";import{format as m}from"date-fns";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeCopyButton.js";import u from"../../common/PickaxeSimpleButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import b from"../../../../common/cn.js";const g=()=>{var g;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,disableHtml:N,disableJs:C,disableCss:O,isRtl:I,setChatId:S,setIsNewChat:D}=t(),{response:M}=n(),{scrollTargetRef:P}=i(),{setDocuments:R}=r(),$=l(),q=o((()=>m(M?M.sentAt:new Date,"hh:mm a MMM dd, yy")),[M]),A=o((()=>{var e;if(!M)return"";return(null!==(e=M.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[M]);return M?e("div",Object.assign({ref:P,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${M.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:A.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:A}}),s("label",Object.assign({htmlFor:`${M.responseId}-input`,className:b($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${M.responseId}-input`,className:b($.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[y.isChatImage&&s(h,{src:null==v?void 0:v.chaticon,alt:`${null==v?void 0:v.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(a,Object.assign({theme:j.theme,accentColor:k.accent,actions:!0},I&&{rtl:!0},N&&{disableHtml:!0},C&&{disableJs:!0},O&&{disableCss:!0},{children:s(c,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:M.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==v?void 0:v.enablechatresponses)&&e(u,Object.assign({color:k.accent,onClick:()=>{return e=M.responseId,R([]),D(!1),void S(e);var e}},{children:[s(d,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:b($.b3,"font-semibold")},{children:M.messageCount+1}))]})),s(f,{color:k.accent,text:null!==(g=M.questionResponse)&&void 0!==g?g:""})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:b($.b3,"font-semibold uppercase opacity-30")},{children:q}))}))]}))]}))]})),s(x,{className:"w-full"})]})):null};export{g as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as i,Fragment as r}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as u}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as p}from"../../../../common/documents.js";import{formatBytes as f}from"../../../../common/utils.js";import h from"../../../Icons/attach-vertical.svg.js";import g from"../../../Icons/check.svg.js";import y from"../../../Icons/spinner-lines.svg.js";import v from"../../../Icons/file.svg.js";import x from"../../../Icons/x.svg.js";import j from"../../../Icons/link.svg.js";import w from"../../../Core/ErrorAlert.js";import N from"../../../../common/cn.js";const k=({field:k,update:O})=>{var C;const R=d(),{colors:I,styles:D,translations:T,responsiveBy:F}=n(),A=m(),{isHover:S}=A,U=e(A,["isHover"]),{documents:E,documentError:z,websiteLink:H,isUploading:L,isImageUploadAllowed:W,removeDocument:$,setDocumentError:B,setWebsiteLink:P,onFileUpload:_,onWebsiteUpload:q}=u({onQuestionChange:e=>{O(Object.assign(Object.assign({},k),e))}}),[K,Q]=a(!1),G=i(null),J=c();return t("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:N(R.b3,"font-semibold opacity-70")},{children:k.main})),k.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:I.error}},{children:"*"}))]})),t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("input",{ref:G,type:"file",accept:[...b,...W?p:[]].join(", "),id:k.id,hidden:!0,multiple:!0,className:"hidden",onChange:e=>s(void 0,void 0,void 0,(function*(){yield _(Array.from(e.target.files||[])),e.target.value=""})),disabled:L}),t("div",Object.assign({className:N("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",K&&"block"===D.formFieldStyle&&"shadow","block"===D.formFieldStyle&&"shadow hover:shadow-none"),style:J},{children:[o("input",{type:"text",value:H,className:N(R.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(C=null==T?void 0:T["form-doc-placeholder"])&&void 0!==C?C:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield _(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),q(H))},onFocus:()=>Q(!0),onBlur:()=>Q(!1)}),o("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:H.length>0?t(l,{children:[o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>q(H)},{children:o(g,{className:"h-5 w-5 shrink-0",style:{color:I.accent}})})),o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>{P(""),B("")}},{children:o(x,{className:"h-6 w-6 shrink-0",style:{color:I.accent}})}))]}):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",disabled:L,onClick:()=>{var e;null===(e=G.current)||void 0===e||e.click()},style:{backgroundColor:S?I.accent+"10":void 0}},U,{children:o(h,{className:"h-6 w-6 shrink-0",style:{color:S?I.accent:I.accent+"80"}})}))}))]}))]}))]})),E.length>0&&o("div",Object.assign({className:N("flex gap-4","viewport"===F?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:o("div",Object.assign({className:"flex flex-row gap-x-2"},{children:E.filter((e=>"failed"!==e.status)).map((e=>{var s,l,a;return o(r,{children:"document"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(v,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(N(R.b3),"font-medium truncate")},{children:e.name})),o("p",Object.assign({className:N(R.b4,"opacity-80 truncate")},{children:f(e.size)}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"image"===e.type?t("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:J.borderRadius}},{children:["finished"===e.status?o("img",{style:{borderRadius:J.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(s=e.documentId)||void 0===s?void 0:s.split("-")[2]}/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[1]}.${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[2]}`,alt:""}):o("div",{className:"h-full w-full animate-pulse",style:{borderRadius:J.borderRadius,backgroundColor:I.secondary}}),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"website"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(j,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(N(R.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),o("p",Object.assign({className:N(R.b4,"opacity-80 truncate")},{children:(null==T?void 0:T.website)||"Website"}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):null},e.id)}))}))})),z&&o(w,{error:z,className:"mt-3"})]}))};export{k as default};
1
+ import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as i,useRef as r,Fragment as a}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as u}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as p}from"../../../../common/documents.js";import{formatBytes as f}from"../../../../common/utils.js";import h from"../../../Icons/attach-vertical.svg.js";import g from"../../../Icons/check.svg.js";import y from"../../../Icons/spinner-lines.svg.js";import v from"../../../Icons/file.svg.js";import x from"../../../Icons/x.svg.js";import j from"../../../Icons/link.svg.js";import k from"../../../Core/ErrorAlert.js";import w from"../../../../common/cn.js";const N=({field:N,update:O})=>{var C;const R=d(),{colors:I,styles:D,translations:T,responsiveBy:F}=n(),A=m(),{isHover:S}=A,U=e(A,["isHover"]),{documents:E,documentError:z,websiteLink:H,isUploading:L,isImageUploadAllowed:W,removeDocument:$,setDocumentError:B,setWebsiteLink:P,onFileUpload:_,onWebsiteUpload:q}=u({onQuestionChange:e=>{O(Object.assign(Object.assign({},N),e))}}),[K,Q]=i(!1),G=r(null),J=c();return t("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:w(R.b3,"font-semibold opacity-70")},{children:N.main})),N.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:I.error}},{children:"*"}))]})),t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("input",{ref:G,type:"file",accept:[...b,...W?p:[]].join(", "),id:N.id,hidden:!0,multiple:!0,className:"hidden",onChange:e=>s(void 0,void 0,void 0,(function*(){yield _(Array.from(e.target.files||[])),e.target.value=""})),disabled:L}),t("div",Object.assign({className:w("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",K&&"block"===D.formFieldStyle&&"shadow","block"===D.formFieldStyle&&"shadow hover:shadow-none"),style:J},{children:[o("input",{type:"text",value:H,className:w(R.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(C=null==T?void 0:T["form-doc-placeholder"])&&void 0!==C?C:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield _(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),q(H))},onFocus:()=>Q(!0),onBlur:()=>Q(!1)}),o("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:H.length>0?t(l,{children:[o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>q(H)},{children:o(g,{className:"h-5 w-5 shrink-0",style:{color:I.accent}})})),o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>{P(""),B("")}},{children:o(x,{className:"h-6 w-6 shrink-0",style:{color:I.accent}})}))]}):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",disabled:L,onClick:()=>{var e;null===(e=G.current)||void 0===e||e.click()},style:{backgroundColor:S?I.accent+"10":void 0}},U,{children:o(h,{className:"h-6 w-6 shrink-0",style:{color:S?I.accent:I.accent+"80"}})}))}))]}))]}))]})),E.length>0&&o("div",Object.assign({className:w("flex gap-4","viewport"===F?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:o("div",Object.assign({className:"flex flex-row gap-x-2"},{children:E.filter((e=>"failed"!==e.status)).map((e=>{var s,l,i;return o(a,{children:"document"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 shrink-0 animate-spin",style:{color:I.accentText}}):o(v,{className:"w-5 h-5 shrink-0",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:e.name})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:f(e.size)}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):"image"===e.type?t("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:J.borderRadius}},{children:["finished"===e.status?o("img",{style:{borderRadius:J.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(s=e.documentId)||void 0===s?void 0:s.split("-")[2]}/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):o("div",{className:"h-full w-full animate-pulse",style:{borderRadius:J.borderRadius,backgroundColor:I.secondary}}),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):"website"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin shrink-0",style:{color:I.accentText}}):o(j,{className:"w-5 h-5 shrink-0",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:(null==T?void 0:T.website)||"Website"}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):null},e.id)}))}))})),z&&o(k,{error:z,className:"mt-3"})]}))};export{N as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import l from"../../Core/Skeleton.js";import m from"../common/PickaxeHead.js";import t from"./History/index.js";import i from"./NewChat.js";import a from"./Questions/index.js";import c from"../../../common/cn.js";const x=()=>{const{pickaxe:x,responsiveBy:p}=o();return e("div",Object.assign({className:c("flex w-full flex-col items-center pt-12 px-4 pb-10","viewport"===p?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s("div",x?Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[e(m,{}),s("div",Object.assign({className:c("flex flex-col gap-y-8","viewport"===p?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==x?void 0:x.chatflag)?e(i,{}):e(a,{}),e(t,{})]}))]}):Object.assign({className:"flex w-full max-w-[700px] flex-col items-center"},{children:[e(l,{className:"w-[72px] h-[72px]"}),e(l,{className:"h-[20px] mt-6 w-full"}),e(l,{className:"h-[20px] mt-2 w-full"}),e(l,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]}))}))};export{x as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import l from"../../Core/Skeleton.js";import m from"../common/PickaxeHead.js";import t from"./History/index.js";import i from"./NewChat.js";import a from"./Questions/index.js";import c from"../../../common/cn.js";const x=()=>{const{pickaxe:x,responsiveBy:p}=o();return e("div",Object.assign({className:c("flex w-full flex-col items-center pt-12 px-6 pb-10","viewport"===p?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s("div",x?Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[e(m,{}),s("div",Object.assign({className:c("flex flex-col gap-y-8","viewport"===p?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[(null==x?void 0:x.chatflag)?e(i,{}):e(a,{}),e(t,{})]}))]}):Object.assign({className:"flex w-full max-w-[700px] flex-col items-center"},{children:[e(l,{className:"w-[72px] h-[72px]"}),e(l,{className:"h-[20px] mt-6 w-full"}),e(l,{className:"h-[20px] mt-2 w-full"}),e(l,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]}))}))};export{x as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as i,jsxs as r}from"react/jsx-runtime";import{Prism as n}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as o}from"../../hooks/usePickaxeMarkdownContext.js";import t from"../../../PickaxeCopyButton.js";const s=s=>{var a,l,{children:c,className:d}=s,m=e(s,["children","className"]);const{syntaxTheme:h}=o(),g=/language-(\w+)/.exec(d||"");return g?i("div",Object.assign({className:"pxe-markdown-code"},{children:r("div",{children:[i("div",{children:i(t,{color:"#FFFFFF",text:null!==(a=null==c?void 0:c.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),i("div",{children:i(n,Object.assign({},m,{PreTag:"div",language:null!==(l=null==g?void 0:g[1])&&void 0!==l?l:"js",style:h,showLineNumbers:!0},{children:String(c).replace(/\n$/,"")}))})]})})):i("code",Object.assign({},m,{className:"pxe-markdown-code-inline"},{children:c}))};export{s as Code};
1
+ import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{Prism as r}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as o}from"../../hooks/usePickaxeMarkdownContext.js";import t from"../../../PickaxeCopyButton.js";const s=s=>{var a,l,{node:c,children:d,className:m}=s,h=e(s,["node","children","className"]);const{syntaxTheme:g}=o(),u=/language-(\w+)/.exec(m||"");return u?i("div",Object.assign({className:"pxe-markdown-code"},{children:n("div",{children:[i("div",{children:i(t,{color:"#FFFFFF",text:null!==(a=null==d?void 0:d.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),i("div",{children:i(r,Object.assign({},h,{PreTag:"div",language:null!==(l=null==u?void 0:u[1])&&void 0!==l?l:"js",style:g,showLineNumbers:!0},{children:String(d).replace(/\n$/,"")}))})]})})):i("code",Object.assign({},h,{className:"pxe-markdown-code-inline"},{children:d}))};export{s as Code};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as o,useMemo as s,useEffect as i}from"react";import{usePickaxeMarkdownContext as m}from"./hooks/usePickaxeMarkdownContext.js";import{rehypeSanitize as a,rehypePickaxeAction as l}from"./utils/custom-plugins.js";import p from"react-markdown";import c from"remark-gfm";import d from"remark-math";import h from"rehype-katex";import f from"rehype-raw";import{A as u}from"./Components/A/index.js";import{P as g}from"./Components/P/index.js";import{Img as x}from"./Components/Img/index.js";import{Iframe as b}from"./Components/Iframe/index.js";import{Code as j}from"./Components/Code/index.js";import{H1 as C,H2 as k,H3 as w,H4 as v,H5 as y}from"./Components/Headings/index.js";import{Ol as O,Ul as $,Li as S}from"./Components/List/index.js";import{Table as A,Th as L,Tr as M,Td as N}from"./Components/Table/index.js";import{Hr as P,Br as H,Blockquote as I}from"./Components/Others/index.js";import{ActionCaption as T,ActionFinished as B,ActionError as E}from"./Components/Action/index.js";import J from"../../../../common/cn.js";const R=({className:R,style:W,children:_,value:q,maxLines:z,maxChars:D,multiLineBreaks:F,recursion:G,onExpandClick:K})=>{const{accentColor:Q,rtl:U,disableHtml:V,disableJs:X,disableCss:Y}=m(),[Z,ee]=t({width:0,height:0}),[re,ne]=t(null),te=o(null),oe=s((()=>{if(!q)return"";let e=q.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)+"$$")),F&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[q,F]);i((()=>{if(D)return void ne(oe.length>D?oe.slice(0,D)+'<span class="pxe-expand-btn">...</span>':null);if(!z)return void ne(null);if(!te.current||!oe||re)return;const e=te.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=z*r;if(!(Z.height>n))return;const t=Math.floor(Z.width/8),o=Math.floor(t*z);ne(oe.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[oe,z,D,Z,re]);const se={h1:C,h2:k,h3:w,h4:v,h5:y,p:g,a:u,img:x,iframe:b,code:j,ol:O,ul:$,li:S,table:A,th:L,tr:M,td:N,hr:P,br:H,blockquote:I,span:r=>{var{children:t}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:Q,marginLeft:".25rem",userSelect:"none"},K&&{cursor:"pointer"})},K&&{onClick:K},{children:t})):n("span",Object.assign({},o,{children:t}))},ActionCaption:T,ActionFinished:B,ActionError:E};i((()=>{if(!te.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;ee({width:e,height:n})}}));return e.observe(te.current),()=>{e.disconnect()}}),[]);const ie=re||oe;return r("div",Object.assign({className:"pxe-markdown",ref:te,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},W)},U&&{dir:"rtl"},{children:[n(p,Object.assign({className:J(!G&&"pxe-prose",R),components:se,remarkPlugins:[c,[d,{singleDollarTextMath:!1}]],rehypePlugins:[h,...V?[]:[f],[a,{disableJs:X,disableCss:Y}],l]},{children:ie})),_]}))};export{R as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as o,useMemo as s,useEffect as i}from"react";import{usePickaxeMarkdownContext as m}from"./hooks/usePickaxeMarkdownContext.js";import{rehypeCode as a,rehypeSanitize as l,rehypePickaxeAction as p}from"./utils/custom-plugins.js";import c from"react-markdown";import d from"remark-gfm";import h from"remark-math";import f from"rehype-katex";import u from"rehype-raw";import{A as g}from"./Components/A/index.js";import{P as x}from"./Components/P/index.js";import{Img as b}from"./Components/Img/index.js";import{Iframe as j}from"./Components/Iframe/index.js";import{Code as C}from"./Components/Code/index.js";import{H1 as k,H2 as w,H3 as v,H4 as y,H5 as O}from"./Components/Headings/index.js";import{Ol as $,Ul as S,Li as A}from"./Components/List/index.js";import{Table as L,Th as M,Tr as N,Td as P}from"./Components/Table/index.js";import{Hr as H,Br as I,Blockquote as T}from"./Components/Others/index.js";import{ActionCaption as B,ActionFinished as E,ActionError as J}from"./Components/Action/index.js";import R from"../../../../common/cn.js";const W=({className:W,style:_,children:q,value:z,maxLines:D,maxChars:F,multiLineBreaks:G,recursion:K,onExpandClick:Q})=>{const{accentColor:U,rtl:V,disableHtml:X,disableJs:Y,disableCss:Z}=m(),[ee,re]=t({width:0,height:0}),[ne,te]=t(null),oe=o(null),se=s((()=>{if(!z)return"";let e=z.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)+"$$")),G&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[z,G]);i((()=>{if(F)return void te(se.length>F?se.slice(0,F)+'<span class="pxe-expand-btn">...</span>':null);if(!D)return void te(null);if(!oe.current||!se||ne)return;const e=oe.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=D*r;if(!(ee.height>n))return;const t=Math.floor(ee.width/8),o=Math.floor(t*D);te(se.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[se,D,F,ee,ne]);const ie={h1:k,h2:w,h3:v,h4:y,h5:O,p:x,a:g,img:b,iframe:j,code:C,ol:$,ul:S,li:A,table:L,th:M,tr:N,td:P,hr:H,br:I,blockquote:T,span:r=>{var{children:t}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:U,marginLeft:".25rem",userSelect:"none"},Q&&{cursor:"pointer"})},Q&&{onClick:Q},{children:t})):n("span",Object.assign({},o,{children:t}))},ActionCaption:B,ActionFinished:E,ActionError:J};i((()=>{if(!oe.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;re({width:e,height:n})}}));return e.observe(oe.current),()=>{e.disconnect()}}),[]);const me=ne||se;return r("div",Object.assign({className:"pxe-markdown",ref:oe,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},_)},V&&{dir:"rtl"},{children:[n(c,Object.assign({className:R(!K&&"pxe-prose",W),components:ie,remarkPlugins:[d,[h,{singleDollarTextMath:!1}]],rehypePlugins:[a,f,...X?[]:[u],[l,{disableJs:Y,disableCss:Z}],p]},{children:me})),q]}))};export{W as PickaxeMarkdownRenderer};
@@ -1 +1 @@
1
- import{visit as e,SKIP as t}from"unist-util-visit";const r=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"],o=()=>o=>(e(o,"element",(e=>{const t=e.tagName;if(r.includes(t)){const r=t.split("-");e.tagName=r.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e(o,"element",((e,r,o)=>{if("p"===e.tagName){const n=e.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===n.length){const e=n[0];if("element"===e.type&&i.includes(e.tagName)&&o&&"children"in o&&o.children&&void 0!==r)return o.children.splice(r,1,e),[t,r]}}})),o),n=(r={})=>i=>{e(i,"element",((e,i,o)=>{if(r.disableJs){if("script"===e.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[t,i];if(e.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((t=>{e.properties[t]&&delete e.properties[t]})),e.properties.href&&"string"==typeof e.properties.href&&e.properties.href.toLowerCase().startsWith("javascript:")&&delete e.properties.href}}if(r.disableCss&&"style"===e.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[t,i]}))};export{o as rehypePickaxeAction,n as rehypeSanitize};
1
+ import{visit as e,SKIP as t}from"unist-util-visit";const i=["action-caption","action-finished","action-error"],r=["ActionCaption","ActionFinished","ActionError"],o=()=>o=>(e(o,"element",(e=>{const t=e.tagName;if(i.includes(t)){const i=t.split("-");e.tagName=i.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e(o,"element",((e,i,o)=>{if("p"===e.tagName){const n=e.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===n.length){const e=n[0];if("element"===e.type&&r.includes(e.tagName)&&o&&"children"in o&&o.children&&void 0!==i)return o.children.splice(i,1,e),[t,i]}}})),o),n=(i={})=>r=>{e(r,"element",((e,r,o)=>{if(i.disableJs){if("script"===e.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[t,r];if(e.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((t=>{e.properties[t]&&delete e.properties[t]})),e.properties.href&&"string"==typeof e.properties.href&&e.properties.href.toLowerCase().startsWith("javascript:")&&delete e.properties.href}}if(i.disableCss&&"style"===e.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[t,r]}))},s=()=>t=>{e(t,"code",(e=>{var t;e.lang=null!==(t=e.lang)&&void 0!==t?t:"plaintext"}))};export{s as rehypeCode,o as rehypePickaxeAction,n as rehypeSanitize};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({formId:s,workspaceId:o,responseId:n,file:i,isKnowledge:t,isBlocking:r,sessionId:c})=>e(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=i.name.split(".").pop(),l=i.type,p={formid:s,mimetype:l,extension:a,responseid:n,workspaceid:o,sessionid:c},_=new URLSearchParams(Object.entries(p).filter((e=>void 0!==e[1]))),O=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${_.toString()}`,g=yield fetch(O),f=yield g.json();if(!f.success)throw new Error(null!==(e=f.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const m=new FormData;Object.entries(Object.assign(Object.assign({},f.fields),{file:i})).forEach((([e,s])=>{m.append(e,s)}));const u=yield fetch(f.url,{method:"POST",body:m});if(!u.ok)throw new Error(u.statusText);const w=`${f.url}${f.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),l.startsWith("image"))return{success:!0,documentId:`IMAGE-${f.documentId}-${f.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:f.documentId}),n&&{responseId:n}),{fileName:i.name,fileSize:i.size}),t&&{isKnowledge:t}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),P=yield I.json();if(!P.success)throw new Error(null!==(d=P.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return P})),website:({formId:o,workspaceId:n,responseId:i,website:t,isKnowledge:r,isBlocking:c})=>e(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},n&&{workspaceId:n}),{documentId:d}),i&&{responseId:i}),{website:t}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),l=yield a.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return l}))});export{o as useSubmitDocument};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({formId:s,workspaceId:o,responseId:n,file:i,isKnowledge:t,isBlocking:r,sessionId:c})=>e(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=i.name.split(".").pop(),l=i.type,p={formid:s,mimetype:l,extension:a,responseid:n,workspaceid:o,sessionid:c},_=new URLSearchParams(Object.entries(p).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),O=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${_.toString()}`,g=yield fetch(O),f=yield g.json();if(!f.success)throw new Error(null!==(e=f.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const m=new FormData;Object.entries(Object.assign(Object.assign({},f.fields),{file:i})).forEach((([e,s])=>{m.append(e,s)}));const u=yield fetch(f.url,{method:"POST",body:m});if(!u.ok)throw new Error(u.statusText);const w=`${f.url}${f.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),l.startsWith("image"))return{success:!0,documentId:`IMAGE-${f.documentId}-${f.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:f.documentId}),n&&{responseId:n}),{fileName:i.name,fileSize:i.size}),t&&{isKnowledge:t}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),P=yield I.json();if(!P.success)throw new Error(null!==(d=P.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return P})),website:({formId:o,workspaceId:n,responseId:i,website:t,isKnowledge:r,isBlocking:c})=>e(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},n&&{workspaceId:n}),{documentId:d}),i&&{responseId:i}),{website:t}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),l=yield a.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return l}))});export{o as useSubmitDocument};
@@ -3,3 +3,4 @@ export declare const rehypeSanitize: (options?: {
3
3
  disableJs?: boolean;
4
4
  disableCss?: boolean;
5
5
  }) => (tree: any) => void;
6
+ export declare const rehypeCode: () => (tree: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,12 +0,0 @@
1
- import { type ReactNode, type DetailedHTMLProps, type HTMLAttributes } from "react";
2
- interface ScrollAreaProps {
3
- id?: string;
4
- className?: string;
5
- innerClassName?: string;
6
- children?: ReactNode;
7
- variant?: "height" | "maxHeight";
8
- hideScrollbar?: boolean;
9
- inner?: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
10
- }
11
- declare const ScrollArea: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>>;
12
- export default ScrollArea;
@@ -1,12 +0,0 @@
1
- import { type ReactNode, type DetailedHTMLProps, type HTMLAttributes } from "react";
2
- interface ScrollAreaProps {
3
- id?: string;
4
- className?: string;
5
- innerClassName?: string;
6
- children?: ReactNode;
7
- variant?: "height" | "maxHeight";
8
- hideScrollbar?: boolean;
9
- inner?: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
10
- }
11
- declare const ScrollArea: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>>;
12
- export default ScrollArea;