@pickaxeproject/react 6.3.1 → 6.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cjs/components/EmbedPreview/FAB.js +1 -1
  2. package/dist/cjs/components/EmbedPreview/Popup.js +1 -1
  3. package/dist/cjs/components/Icons/arrow-down.svg.js +1 -0
  4. package/dist/cjs/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Addons/Auth/index.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
  10. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  11. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  12. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  13. package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
  14. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  15. package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
  16. package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
  17. package/dist/cjs/components/Pickaxe/Form/Questions/Option.js +1 -1
  18. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  19. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  20. package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
  21. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
  22. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
  23. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
  24. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
  25. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
  26. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
  27. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
  28. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
  29. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
  30. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  31. package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  32. package/dist/cjs/components/Pickaxe/common/SmitheryConnectView.js +1 -1
  33. package/dist/cjs/components/Pickaxe/index.js +1 -1
  34. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  35. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  36. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  37. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  38. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
  39. package/dist/esm/components/EmbedPreview/FAB.js +1 -1
  40. package/dist/esm/components/EmbedPreview/Popup.js +1 -1
  41. package/dist/esm/components/Icons/arrow-down.svg.js +1 -0
  42. package/dist/esm/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
  43. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
  44. package/dist/esm/components/Pickaxe/Addons/Auth/index.js +1 -1
  45. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  46. package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
  47. package/dist/esm/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
  48. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  49. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  50. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  51. package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
  52. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  53. package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
  54. package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
  55. package/dist/esm/components/Pickaxe/Form/Questions/Option.js +1 -1
  56. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  57. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  58. package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
  59. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
  60. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
  61. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
  62. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
  63. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
  64. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
  65. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
  66. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
  67. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
  68. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  69. package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
  70. package/dist/esm/components/Pickaxe/common/SmitheryConnectView.js +1 -1
  71. package/dist/esm/components/Pickaxe/index.js +1 -1
  72. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  73. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  74. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  75. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  76. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
  77. package/package.json +1 -1
@@ -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"),a=require("@tanstack/react-query"),n=require("../Pickaxe/index.js"),r=require("../Pickaxe/Provider.js"),o=require("framer-motion"),c=require("../Pickaxe/Addons/Artifact/index.js"),l=require("../Icons/pickaxe.svg.js"),d=require("../Icons/spark.svg.js"),u=require("../Icons/x.svg.js"),x=require("../../common/cn.js");const h=new a.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),m=({isOpen:a,setIsOpen:n})=>{const{colors:r,deploymentMisc:o}=s.usePickaxeContext(),[c,x]=t.useState({src:"",isLarge:!1}),[h,m]=t.useState(!0);return t.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(null==o?void 0:o.fabImage))return;m(!0);const e=new Image;e.src=o.fabImage,yield e.decode();const i=e.width>200;x({src:o.fabImage,isLarge:i})}catch(e){console.error("[pxe] error loading FAB image:",e),x({src:"",isLarge:!1})}finally{m(!1)}}))}),[null==o?void 0:o.fabImage]),h?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:()=>n(!a)},{children:a?i.jsx(p,Object.assign({id:"close-btn"},{children:i.jsx(u.default,{className:"w-[28px] h-[28px] shrink-0 select-none"})})):i.jsx(p,Object.assign({id:"open-btn"},{children:c.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?i.jsx(d.default,{className:"h-6 w-6 shrink-0 select-none"}):c.src?i.jsx("img",{src:c.src,alt:"FAB Icon",width:c.isLarge?60:24,height:c.isLarge?60:24,className:"select-none"}):i.jsx(l.default,{className:"h-6 w-6 shrink-0 select-none"})}))}))},p=({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 l,d,u,p,{pickaxeId:g,className:b}=s,v=e.__rest(s,["pickaxeId","className"]);const[j,f]=t.useState(!1),[w,y]=t.useState({}),k=()=>{const e=v.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},a=e.minHeight,n=e.maxHeight,r=window.innerHeight-150,o=window.innerWidth-40;let c=0;c="px"===s.unit?s.value:n;let l=Math.min(c,r);l=Math.max(l,a,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);y({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((()=>(k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k))),[v.deploymentDimensions]),i.jsx(a.QueryClientProvider,Object.assign({client:h},{children:i.jsxs(r.PickaxeProvider,Object.assign({},v,{deploymentType:"fab",isEmbed:!0},{children:[i.jsxs(o.AnimatePresence,{children:[j&&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:x.default("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",v.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(d=null===(l=v.styles)||void 0===l?void 0:l.cornerRadius)&&void 0!==d?d:0,bottom:100,right:20},w)},{children:i.jsx("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin",style:{borderRadius:null!==(p=null===(u=v.styles)||void 0===u?void 0:u.cornerRadius)&&void 0!==p?p:0}},{children:i.jsx(n.Pickaxe,Object.assign({pickaxeId:g},b&&{className:b}))}))}),"fab-content"),i.jsx(m,{isOpen:j,setIsOpen:f})]}),i.jsx(c.PickaxeArtifact,{})]}))}))},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"),a=require("@tanstack/react-query"),n=require("../Pickaxe/index.js"),r=require("../Pickaxe/Provider.js"),o=require("framer-motion"),c=require("../Pickaxe/Addons/Artifact/index.js"),l=require("../Icons/pickaxe.svg.js"),d=require("../Icons/spark.svg.js"),u=require("../Icons/x.svg.js"),x=require("../../common/cn.js");const h=new a.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),m=({isOpen:a,setIsOpen:n})=>{const{colors:r,deploymentMisc:o,translations:c}=s.usePickaxeContext(),[x,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:()=>n(!a)},{children:a?i.jsx(p,Object.assign({id:"close-btn"},{children:i.jsx(u.default,{className:"w-[28px] h-[28px] shrink-0 select-none"})})):i.jsx(p,Object.assign({id:"open-btn"},{children:x.src===`https://${process.env.NEXT_PUBLIC_PICKAXE_DOMAIN}/builder/assets/images/pickaxe-chaticons/chaticon2.png`?i.jsx(d.default,{className:"h-6 w-6 shrink-0 select-none"}):x.src?i.jsx("img",{src:x.src,alt:(null==c?void 0:c["fab-icon"])||"FAB Icon",width:x.isLarge?60:24,height:x.isLarge?60:24,className:"select-none"}):i.jsx(l.default,{className:"h-6 w-6 shrink-0 select-none"})}))}))},p=({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 l,d,u,p,{pickaxeId:g,className:b}=s,v=e.__rest(s,["pickaxeId","className"]);const[j,f]=t.useState(!1),[w,y]=t.useState({}),k=()=>{const e=v.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},a=e.minHeight,n=e.maxHeight,r=window.innerHeight-150,o=window.innerWidth-40;let c=0;c="px"===s.unit?s.value:n;let l=Math.min(c,r);l=Math.max(l,a,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);y({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((()=>(k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k))),[v.deploymentDimensions]),i.jsx(a.QueryClientProvider,Object.assign({client:h},{children:i.jsxs(r.PickaxeProvider,Object.assign({},v,{deploymentType:"fab",isEmbed:!0},{children:[i.jsxs(o.AnimatePresence,{children:[j&&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:x.default("transition-h absolute z-50 flex flex-col overflow-hidden bg-transparent",v.isDropShadow&&"shadow-embed"),style:Object.assign({transformOrigin:"bottom right",borderRadius:null!==(d=null===(l=v.styles)||void 0===l?void 0:l.cornerRadius)&&void 0!==d?d:0,bottom:100,right:20},w)},{children:i.jsx("div",Object.assign({className:"flex flex-col overflow-auto h-full scrollbar scrollbar-thin",style:{borderRadius:null!==(p=null===(u=v.styles)||void 0===u?void 0:u.cornerRadius)&&void 0!==p?p:0}},{children:i.jsx(n.Pickaxe,Object.assign({pickaxeId:g},b&&{className:b}))}))}),"fab-content"),i.jsx(m,{isOpen:j,setIsOpen:f})]}),i.jsx(c.PickaxeArtifact,{})]}))}))},exports.FABButton=m;
@@ -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"),n=require("../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../hooks/pickaxe/usePickaxe.js"),o=require("../../hooks/studio/useStyleFontSize.js"),l=require("@tanstack/react-query"),a=require("../Pickaxe/index.js"),d=require("../Pickaxe/Provider.js"),r=require("../Pickaxe/Addons/Artifact/index.js"),u=require("../Icons/x.svg.js"),c=require("../Core/Modal/index.js"),h=require("../Core/Modal/Body.js"),p=require("../../common/cn.js");const m=new l.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),x=s=>{var o,l,d,m,x,j,y,g,b,{pickaxeId:f,className:w}=s,k=e.__rest(s,["pickaxeId","className"]);const{sessionId:O,deploymentType:P}=n.usePickaxeContext(),[q,D]=t.useState(!1),[C,I]=t.useState(!1),H=t.useCallback((()=>{const e=k.deploymentDimensions;if(!e)return;let i=0;"px"===e.width.unit?i=e.width.value:"%"===e.width.unit&&(i=Math.floor(e.maxWidth*(e.width.value/100)));let t=0;"px"===e.height.unit?t=e.height.value:"auto"===e.height.unit&&(t=e.maxHeight);const n=window.innerWidth<i+50,s=window.innerHeight<t+100,o=n||s;!C&&o&&I(!0),C&&!o&&I(!1)}),[C,k.deploymentDimensions]);return t.useEffect((()=>(H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H))),[q,C,k.deploymentDimensions]),i.jsxs(i.Fragment,{children:[i.jsx(v,{formId:f,setIsOpen:e=>{D(e),e&&H()}}),i.jsx(c.default,Object.assign({isOpen:q,onChange:()=>D(!1)},{children:i.jsxs(h.default,Object.assign({className:p.default("relative bg-transparent overflow-hidden",k.isDropShadow&&"shadow-embed",C&&"h-full w-full"),style:{borderRadius:C?0:(null!==(l=null===(o=k.styles)||void 0===o?void 0:o.cornerRadius)&&void 0!==l?l:0)+"px"}},{children:[i.jsx("div",Object.assign({className:"overflow-auto scrollbar scrollbar-thin",style:Object.assign({borderRadius:C?0:(null!==(m=null===(d=k.styles)||void 0===d?void 0:d.cornerRadius)&&void 0!==m?m:0)+"px"},C?{width:"100%",height:"100%"}:Object.assign(Object.assign({},"px"===(null===(x=k.deploymentDimensions)||void 0===x?void 0:x.width.unit)?{width:k.deploymentDimensions.width.value+k.deploymentDimensions.width.unit}:"%"===(null===(j=k.deploymentDimensions)||void 0===j?void 0:j.width.unit)?{width:Math.floor(k.deploymentDimensions.maxWidth*(k.deploymentDimensions.width.value/100))}:{}),"px"===(null===(y=k.deploymentDimensions)||void 0===y?void 0:y.height.unit)?{height:k.deploymentDimensions.height.value+"px"}:"auto"===(null===(g=k.deploymentDimensions)||void 0===g?void 0:g.height.unit)?{height:k.deploymentDimensions.minHeight+"px",maxHeight:k.deploymentDimensions.maxHeight+"px"}:{}))},{children:i.jsx(a.Pickaxe,Object.assign({pickaxeId:f},w&&{className:w}))})),i.jsx("button",Object.assign({className:"absolute z-10 outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>D(!1),style:{right:"popup"===P?24:O?14:24,top:14,color:(null===(b=k.colors)||void 0===b?void 0:b.accent)||"#000"}},{children:i.jsx(u.default,{className:"h-6 w-6 shrink-0"})}))]}))})),i.jsx(r.PickaxeArtifact,{})]})},v=({formId:e,setIsOpen:t})=>{var l;const{colors:a,styles:d,deploymentDimensions:r,deploymentMisc:u}=n.usePickaxeContext(),c=o.useStyleFontSize(),h=s.useInstantPickaxe(e);return h.isLoading?null:i.jsx("button",Object.assign({style:Object.assign(Object.assign(Object.assign({},"Real Head Pro"!==d.font&&{fontFamily:d.font}),{color:a.accentText,backgroundColor:a.accent,borderRadius:d.cornerRadius+"px",borderWidth:d.outlineThickness+"px",maxWidth:"%"===(null==r?void 0:r.width.unit)?(null==r?void 0:r.maxWidth)+"px":(null==r?void 0:r.width.value)+"px",minHeight:48}),"Real Head Pro"!==d.font&&{fontFamily:d.font}),className:p.default(c.b2,"flex w-max min-w-[130px] select-none items-center font-semibold justify-center gap-x-3 px-4 hover:duration-300 focus:outline focus:outline-black/30 active:opacity-90 disabled:cursor-not-allowed dark:focus:outline-white/30"),onClick:()=>t(!0)},{children:i.jsx("p",Object.assign({className:p.default(c.b2,"font-semibold"),style:Object.assign({color:a.accentText},"Real Head Pro"!==d.font&&{fontFamily:d.font})},{children:(null==u?void 0:u.popupText)||(null===(l=h.data)||void 0===l?void 0:l.formtitle)||"Open Tool"}))}))};exports.Popup=e=>i.jsx(l.QueryClientProvider,Object.assign({client:m},{children:i.jsx(d.PickaxeProvider,Object.assign({},e,{deploymentType:"popup",isEmbed:!0},{children:i.jsx(x,Object.assign({},e))}))})),exports.PopupCTAButton=v;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),n=require("../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../hooks/pickaxe/usePickaxe.js"),o=require("../../hooks/studio/useStyleFontSize.js"),l=require("@tanstack/react-query"),a=require("../Pickaxe/index.js"),d=require("../Pickaxe/Provider.js"),r=require("../Pickaxe/Addons/Artifact/index.js"),u=require("../Icons/x.svg.js"),c=require("../Core/Modal/index.js"),h=require("../Core/Modal/Body.js"),p=require("../../common/cn.js");const m=new l.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),x=s=>{var o,l,d,m,x,j,y,g,b,{pickaxeId:f,className:w}=s,k=e.__rest(s,["pickaxeId","className"]);const{sessionId:O,deploymentType:P}=n.usePickaxeContext(),[q,D]=t.useState(!1),[C,I]=t.useState(!1),H=t.useCallback((()=>{const e=k.deploymentDimensions;if(!e)return;let i=0;"px"===e.width.unit?i=e.width.value:"%"===e.width.unit&&(i=Math.floor(e.maxWidth*(e.width.value/100)));let t=0;"px"===e.height.unit?t=e.height.value:"auto"===e.height.unit&&(t=e.maxHeight);const n=window.innerWidth<i+50,s=window.innerHeight<t+100,o=n||s;!C&&o&&I(!0),C&&!o&&I(!1)}),[C,k.deploymentDimensions]);return t.useEffect((()=>(H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H))),[q,C,k.deploymentDimensions]),i.jsxs(i.Fragment,{children:[i.jsx(v,{formId:f,setIsOpen:e=>{D(e),e&&H()}}),i.jsx(c.default,Object.assign({isOpen:q,onChange:()=>D(!1)},{children:i.jsxs(h.default,Object.assign({className:p.default("relative bg-transparent overflow-hidden",k.isDropShadow&&"shadow-embed",C&&"h-full w-full"),style:{borderRadius:C?0:(null!==(l=null===(o=k.styles)||void 0===o?void 0:o.cornerRadius)&&void 0!==l?l:0)+"px"}},{children:[i.jsx("div",Object.assign({className:"overflow-auto scrollbar scrollbar-thin",style:Object.assign({borderRadius:C?0:(null!==(m=null===(d=k.styles)||void 0===d?void 0:d.cornerRadius)&&void 0!==m?m:0)+"px"},C?{width:"100%",height:"100%"}:Object.assign(Object.assign({},"px"===(null===(x=k.deploymentDimensions)||void 0===x?void 0:x.width.unit)?{width:k.deploymentDimensions.width.value+k.deploymentDimensions.width.unit}:"%"===(null===(j=k.deploymentDimensions)||void 0===j?void 0:j.width.unit)?{width:Math.floor(k.deploymentDimensions.maxWidth*(k.deploymentDimensions.width.value/100))}:{}),"px"===(null===(y=k.deploymentDimensions)||void 0===y?void 0:y.height.unit)?{height:k.deploymentDimensions.height.value+"px"}:"auto"===(null===(g=k.deploymentDimensions)||void 0===g?void 0:g.height.unit)?{height:k.deploymentDimensions.minHeight+"px",maxHeight:k.deploymentDimensions.maxHeight+"px"}:{}))},{children:i.jsx(a.Pickaxe,Object.assign({pickaxeId:f},w&&{className:w}))})),i.jsx("button",Object.assign({className:"absolute z-10 outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>D(!1),style:{right:"popup"===P?24:O?14:24,top:14,color:(null===(b=k.colors)||void 0===b?void 0:b.accent)||"#000"}},{children:i.jsx(u.default,{className:"h-6 w-6 shrink-0"})}))]}))})),i.jsx(r.PickaxeArtifact,{})]})},v=({formId:e,setIsOpen:t})=>{var l;const{colors:a,styles:d,deploymentDimensions:r,deploymentMisc:u,translations:c}=n.usePickaxeContext(),h=o.useStyleFontSize(),m=s.useInstantPickaxe(e);return m.isLoading?null:i.jsx("button",Object.assign({style:Object.assign(Object.assign(Object.assign({},"Real Head Pro"!==d.font&&{fontFamily:d.font}),{color:a.accentText,backgroundColor:a.accent,borderRadius:d.cornerRadius+"px",borderWidth:d.outlineThickness+"px",maxWidth:"%"===(null==r?void 0:r.width.unit)?(null==r?void 0:r.maxWidth)+"px":(null==r?void 0:r.width.value)+"px",minHeight:48}),"Real Head Pro"!==d.font&&{fontFamily:d.font}),className:p.default(h.b2,"flex w-max min-w-[130px] select-none items-center font-semibold justify-center gap-x-3 px-4 hover:duration-300 focus:outline focus:outline-black/30 active:opacity-90 disabled:cursor-not-allowed dark:focus:outline-white/30"),onClick:()=>t(!0)},{children:i.jsx("p",Object.assign({className:p.default(h.b2,"font-semibold"),style:Object.assign({color:a.accentText},"Real Head Pro"!==d.font&&{fontFamily:d.font})},{children:(null==u?void 0:u.popupText)||(null===(l=m.data)||void 0===l?void 0:l.formtitle)||(null==c?void 0:c["open-tool"])||"Open Tool"}))}))};exports.Popup=e=>i.jsx(l.QueryClientProvider,Object.assign({client:m},{children:i.jsx(d.PickaxeProvider,Object.assign({},e,{deploymentType:"popup",isEmbed:!0},{children:i.jsx(x,Object.assign({},e))}))})),exports.PopupCTAButton=v;
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var l=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16"},e),r||(r=t.createElement("path",{fill:"currentColor",d:"m0 8 1.41-1.41L7 12.17V0h2v12.17l5.59-5.58L16 8l-8 8z"})));exports.default=l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),a=require("../hooks/useArtifactContext.js"),n=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Scroll/hooks/useScroll.js"),r=require("../hooks/useArtifact.js"),l=require("react-to-print"),s=require("../../../common/PickaxeMarkdown/index.js"),c=require("../../../common/PickaxeMarkdown/Renderer.js"),d=require("react-syntax-highlighter"),p=require("../../../../../common/docx/index.js"),u=require("file-saver"),x=require("../../Scroll/ScrollLockView.js"),m=require("../../../../Icons/expand.svg.js"),y=require("../../../../Icons/shrink.svg.js"),v=require("../../../../Icons/collapse-new.svg.js"),f=require("../../../../Icons/copy-new.svg.js"),g=require("../../../../Icons/download-new.svg.js"),b=require("../../../common/PickaxeCopyButton.js"),h=require("../../../../Core/ScrollArea.js"),j=require("../../../../Core/TipContainer.js"),w=require("../MermaidRenderer.js"),C=require("./SaveMenu.js"),k=require("./ViewOptions.js"),T=require("csv-to-markdown-table"),F=require("copy-to-clipboard"),O=require("../../../../../common/cn.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=A(u),D=A(T),N=A(F);const q="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co";exports.default=u=>{var T,F,A,E;const{artifacts:M,currentPopupType:_,currentArtifact:B,setCurrentArtifact:P}=a.useArtifactContext(),{onLoadArtifact:R}=r.useArtifact(),{styles:$,colors:z,translations:L}=n.usePickaxeContext(),[W,H]=o.useState("code"),[I,V]=o.useState(!1),X=o.useRef(),G=o.useRef(null),J=o.useRef(null),K=l.useReactToPrint({contentRef:X}),{scrollContainerRef:Q,scrollStartSession:U,scrollToBottom:Y,scrollEndSession:Z}=i.useScroll({auto:"code"===W}),ee=null!==(F=null===(T=u.styling)||void 0===T?void 0:T.styles)&&void 0!==F?F:$,te=null!==(E=null===(A=u.styling)||void 0===A?void 0:A.colors)&&void 0!==E?E:z,oe=o.useMemo((()=>{var e,t,o,a,n;if(!u.artifact&&!B)return null;const i=null!==(t=null===(e=u.artifact)||void 0===e?void 0:e.id)&&void 0!==t?t:null==B?void 0:B.id,r=null!==(a=null===(o=u.artifact)||void 0===o?void 0:o.version)&&void 0!==a?a:null==B?void 0:B.version;return null!==(n=M.find((e=>e.id===i&&e.version===r)))&&void 0!==n?n:null}),[B,M,u.artifact]),ae=o.useMemo((()=>oe?"text/csv"===oe.type?D.default(oe.content,",",!0):"text/tab-separated-values"===oe.type?D.default(oe.content,"\t",!0):null:null),[oe]),ne=o.useMemo((()=>(te.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==te?void 0:te.secondaryText]),ie=o.useMemo((()=>{const e=u.artifact&&(null==B?void 0:B.id)===u.artifact.id&&(null==B?void 0:B.version)===u.artifact.version;return"inline"===u.type&&("inline-form"===_?!!B:e)}),[B,_,u.type,u.artifact]);o.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"inline"===u.type&&u.artifact&&(M.some((e=>u.artifact&&e.id===u.artifact.id&&e.version===u.artifact.version))||R({id:u.artifact.id,version:u.artifact.version}))}))}),[M,u.type,u.artifact]),o.useEffect((()=>{if("application/vnd.pxe.code"===(null==oe?void 0:oe.type)&&H("code"),"finished"!==(null==oe?void 0:oe.status))return H("code"),U(),void Y();Z(),"application/vnd.pxe.code"!==oe.type&&H("render")}),[null==oe?void 0:oe.status,null==oe?void 0:oe.type]),o.useEffect((()=>{var e;!J.current||"text/html"!==(null==oe?void 0:oe.type)&&"application/pdf"!==(null==oe?void 0:oe.type)&&"application/vnd.pxe.react"!==(null==oe?void 0:oe.type)||null===(e=J.current.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}),[null==oe?void 0:oe.content,null==oe?void 0:oe.type]);const re=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;if("text/html"===oe.type||"application/pdf"===oe.type){const e=oe.content,t=window.open("","_blank");return void(t&&(t.document.open(),t.document.write(e),t.document.close(),t.focus(),t.print()))}const e=W;"code"===e&&(H("render"),yield new Promise((e=>setTimeout(e,50)))),K(),"code"===e&&H(e)})),le=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;const e=yield p.convertMarkdownToDocx(oe.content);p.downloadDocx(e,`${oe.title}.docx`)})),se=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!oe)return;let o={mimeType:"text/plain",extension:".txt"};switch(t){case"text/markdown":o={mimeType:"text/markdown",extension:".md"};break;case"text/html":o={mimeType:"text/html",extension:".html"};break;case"text/csv":o={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":o={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":o={mimeType:"image/svg+xml",extension:".svg"};break;case"application/pdf":o={mimeType:"application/pdf",extension:".pdf"};break;case"application/vnd.pxe.code":o={mimeType:`application/${oe.programmingLanguage||"text"};charset=utf-8`,extension:`.${oe.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":o={mimeType:"text/typescript",extension:".tsx"};break;default:o={mimeType:"text/plain",extension:".txt"}}let a=null;if("application/vnd.pxe.mermaid"===oe.type){const t=W;"code"===t&&(H("render"),yield new Promise((e=>setTimeout(e,50))));const o=null===(e=G.current)||void 0===e?void 0:e.querySelector("svg");o&&(a=(new XMLSerializer).serializeToString(o)),"code"===t&&H(t)}const n=new Blob([null!=a?a:oe.content],{type:o.mimeType});S.default(n,`${oe.title}${o.extension}`)})),ce=()=>{"inline"!==u.type||!u.artifact||ie?P(null):P({id:u.artifact.id,version:u.artifact.version})},de=ie||!_.startsWith("inline");return oe?t.jsxs("div",Object.assign({className:O.default("pxe-artifact-renderer flex flex-col","inline"===u.type&&!ie&&"min-h-[320px] mb-6",u.className),style:Object.assign(Object.assign({backgroundColor:te.secondary,color:te.secondaryText},"auto"!==_&&{borderRadius:ee.cornerRadius}),u.style)},{children:[t.jsxs("div",Object.assign({className:"flex items-center gap-4 justify-between px-4 py-3 shadow-sm"},{children:[t.jsxs("div",Object.assign({className:"pxe-artifact-create-header flex min-w-0 items-center gap-4"},{children:[de&&t.jsx(k.default,{type:oe.type,view:W,colors:te,onChange:H}),t.jsx("p",Object.assign({className:"w-[220px] max-w-full truncate text-[18px] font-semilight leading-tight",title:oe.title},{children:oe.title}))]})),"inline"===u.type&&!de&&t.jsx("div",Object.assign({className:"shrink-0"},{children:t.jsx("button",Object.assign({type:"button",style:{color:te.secondaryText},onClick:ce,title:(null==L?void 0:L.expand)||"Expand","aria-label":(null==L?void 0:L.expand)||"Expand artifact"},{children:ie?t.jsx(y.default,{className:"w-6 h-6 shrink-0"}):t.jsx(m.default,{className:"w-6 h-6 shrink-0"})}))}))]})),de&&t.jsx("div",Object.assign({className:"flex items-center justify-between border-y px-4 py-2.5",style:{borderColor:te.primary}},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100",style:{color:te.secondaryText},onClick:ce,title:"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse":(null==L?void 0:L.close)||"Close","aria-label":"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse artifact":(null==L?void 0:L.close)||"Close artifact"},{children:t.jsx(v.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",style:{color:te.secondaryText},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(oe)try{N.default(oe.content),V(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{V(!1)}})),title:(null==L?void 0:L.copy)||"Copy","aria-label":(null==L?void 0:L.copy)||"Copy artifact content"},{children:t.jsx(f.default,{className:"h-[18px] w-[18px] shrink-0"})})),t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le,className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100"},{children:t.jsx("div",Object.assign({role:"button",className:"cursor-pointer",style:{color:te.secondaryText},title:(null==L?void 0:L.save)||"Download","aria-label":(null==L?void 0:L.save)||"Download artifact content"},{children:t.jsx(g.default,{className:"h-6 w-6 shrink-0"})}))}))]}))})),t.jsx("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:t.jsxs(h.default,Object.assign({ref:Q,innerClassName:"flex-grow w-full"},{children:["render"===W&&"application/vnd.pxe.code"!==oe.type?t.jsx("div",Object.assign({ref:X,className:O.default("p-4 pb-6 flex-grow flex flex-col","text/html"===oe.type&&"p-0","text/csv"===oe.type&&"p-0","application/pdf"===oe.type&&"p-0","application/vnd.pxe.react"===oe.type&&"p-0")},{children:"text/markdown"===oe.type||"text/csv"===oe.type||"text/tab-separated-values"===oe.type||"image/svg+xml"===oe.type?t.jsx(s.PickaxeMarkdown,Object.assign({theme:ee.theme,colors:te},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:null!=ae?ae:oe.content,className:O.default("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===oe.type||"text/tab-separated-values"===oe.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===oe.type?t.jsx(w.default,{ref:G,id:`mermaid-${oe.id}-${oe.version}`,data:oe.content}):"text/html"===oe.type||"application/pdf"===oe.type||"application/vnd.pxe.react"===oe.type?t.jsx("iframe",Object.assign({ref:J,title:oe.title,src:`${q}/${"application/vnd.pxe.react"!==oe.type?"html":"react"}?theme=${ne?"dark":"light"}&bg=${te.secondary}&accent=${te.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==te?void 0:te.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const t=e.target;setTimeout((()=>{var e;try{null===(e=t.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}catch(e){console.error("Error sending message to iframe:",e)}}),100),Y()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t.jsx(d.Prism,Object.assign({PreTag:"div",language:"text/markdown"===oe.type?"markdown":"text/html"===oe.type||"image/svg+xml"===oe.type?"xml":"application/vnd.pxe.react"===oe.type?"typescript":oe.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ne&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ne&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==te?void 0:te.secondary}),':not(pre) > code[class*="language-"]':{background:null==te?void 0:te.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!ne&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:oe.content})),t.jsx(x.default,{})]}))})),"inline"===u.type&&!ie&&t.jsxs("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t.jsx(j.default,Object.assign({id:`artifact-copy-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(b.default,{color:te.secondaryText,text:oe.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t.jsx(j.default,Object.assign({id:`artifact-save-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le},{children:t.jsx("button",Object.assign({style:{color:te.secondaryText}},{children:t.jsx(g.default,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),a=require("../hooks/useArtifactContext.js"),n=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Scroll/hooks/useScroll.js"),r=require("../hooks/useArtifact.js"),l=require("react-to-print"),s=require("../../../common/PickaxeMarkdown/index.js"),c=require("../../../common/PickaxeMarkdown/Renderer.js"),d=require("react-syntax-highlighter"),p=require("../../../../../common/docx/index.js"),u=require("file-saver"),x=require("../../Scroll/ScrollLockView.js"),m=require("../../../../Icons/expand.svg.js"),y=require("../../../../Icons/shrink.svg.js"),v=require("../../../../Icons/collapse-new.svg.js"),f=require("../../../../Icons/copy-new.svg.js"),g=require("../../../../Icons/download-new.svg.js"),b=require("../../../common/PickaxeCopyButton.js"),h=require("../../../../Core/ScrollArea.js"),j=require("../../../../Core/TipContainer.js"),w=require("../MermaidRenderer.js"),C=require("./SaveMenu.js"),k=require("./ViewOptions.js"),T=require("csv-to-markdown-table"),F=require("copy-to-clipboard"),O=require("../../../../../common/cn.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=A(u),D=A(T),N=A(F);const q="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co";exports.default=u=>{var T,F,A,E;const{artifacts:M,currentPopupType:_,currentArtifact:B,setCurrentArtifact:P}=a.useArtifactContext(),{onLoadArtifact:R}=r.useArtifact(),{styles:$,colors:z,translations:L}=n.usePickaxeContext(),[W,H]=o.useState("code"),[I,V]=o.useState(!1),X=o.useRef(),G=o.useRef(null),J=o.useRef(null),K=l.useReactToPrint({contentRef:X}),{scrollContainerRef:Q,scrollStartSession:U,scrollToBottom:Y,scrollEndSession:Z}=i.useScroll({auto:"code"===W}),ee=null!==(F=null===(T=u.styling)||void 0===T?void 0:T.styles)&&void 0!==F?F:$,te=null!==(E=null===(A=u.styling)||void 0===A?void 0:A.colors)&&void 0!==E?E:z,oe=o.useMemo((()=>{var e,t,o,a,n;if(!u.artifact&&!B)return null;const i=null!==(t=null===(e=u.artifact)||void 0===e?void 0:e.id)&&void 0!==t?t:null==B?void 0:B.id,r=null!==(a=null===(o=u.artifact)||void 0===o?void 0:o.version)&&void 0!==a?a:null==B?void 0:B.version;return null!==(n=M.find((e=>e.id===i&&e.version===r)))&&void 0!==n?n:null}),[B,M,u.artifact]),ae=o.useMemo((()=>oe?"text/csv"===oe.type?D.default(oe.content,",",!0):"text/tab-separated-values"===oe.type?D.default(oe.content,"\t",!0):null:null),[oe]),ne=o.useMemo((()=>(te.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==te?void 0:te.secondaryText]),ie=o.useMemo((()=>{const e=u.artifact&&(null==B?void 0:B.id)===u.artifact.id&&(null==B?void 0:B.version)===u.artifact.version;return"inline"===u.type&&("inline-form"===_?!!B:e)}),[B,_,u.type,u.artifact]);o.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"inline"===u.type&&u.artifact&&(M.some((e=>u.artifact&&e.id===u.artifact.id&&e.version===u.artifact.version))||R({id:u.artifact.id,version:u.artifact.version}))}))}),[M,u.type,u.artifact]),o.useEffect((()=>{if("application/vnd.pxe.code"===(null==oe?void 0:oe.type)&&H("code"),"finished"!==(null==oe?void 0:oe.status))return H("code"),U(),void Y();Z(),"application/vnd.pxe.code"!==oe.type&&H("render")}),[null==oe?void 0:oe.status,null==oe?void 0:oe.type]),o.useEffect((()=>{var e;!J.current||"text/html"!==(null==oe?void 0:oe.type)&&"application/pdf"!==(null==oe?void 0:oe.type)&&"application/vnd.pxe.react"!==(null==oe?void 0:oe.type)||null===(e=J.current.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}),[null==oe?void 0:oe.content,null==oe?void 0:oe.type]);const re=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;if("text/html"===oe.type||"application/pdf"===oe.type){const e=oe.content,t=window.open("","_blank");return void(t&&(t.document.open(),t.document.write(e),t.document.close(),t.focus(),t.print()))}const e=W;"code"===e&&(H("render"),yield new Promise((e=>setTimeout(e,50)))),K(),"code"===e&&H(e)})),le=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;const e=yield p.convertMarkdownToDocx(oe.content);p.downloadDocx(e,`${oe.title}.docx`)})),se=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!oe)return;let o={mimeType:"text/plain",extension:".txt"};switch(t){case"text/markdown":o={mimeType:"text/markdown",extension:".md"};break;case"text/html":o={mimeType:"text/html",extension:".html"};break;case"text/csv":o={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":o={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":o={mimeType:"image/svg+xml",extension:".svg"};break;case"application/pdf":o={mimeType:"application/pdf",extension:".pdf"};break;case"application/vnd.pxe.code":o={mimeType:`application/${oe.programmingLanguage||"text"};charset=utf-8`,extension:`.${oe.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":o={mimeType:"text/typescript",extension:".tsx"};break;default:o={mimeType:"text/plain",extension:".txt"}}let a=null;if("application/vnd.pxe.mermaid"===oe.type){const t=W;"code"===t&&(H("render"),yield new Promise((e=>setTimeout(e,50))));const o=null===(e=G.current)||void 0===e?void 0:e.querySelector("svg");o&&(a=(new XMLSerializer).serializeToString(o)),"code"===t&&H(t)}const n=new Blob([null!=a?a:oe.content],{type:o.mimeType});S.default(n,`${oe.title}${o.extension}`)})),ce=()=>{"inline"!==u.type||!u.artifact||ie?P(null):P({id:u.artifact.id,version:u.artifact.version})},de=ie||!_.startsWith("inline");return oe?t.jsxs("div",Object.assign({className:O.default("pxe-artifact-renderer flex flex-col","inline"===u.type&&!ie&&"min-h-[320px] mb-6",u.className),style:Object.assign(Object.assign({backgroundColor:te.secondary,color:te.secondaryText},"auto"!==_&&{borderRadius:ee.cornerRadius}),u.style)},{children:[t.jsxs("div",Object.assign({className:"flex items-center gap-4 justify-between px-4 py-3 shadow-sm"},{children:[t.jsxs("div",Object.assign({className:"pxe-artifact-create-header flex min-w-0 items-center gap-4"},{children:[de&&t.jsx(k.default,{type:oe.type,view:W,colors:te,onChange:H}),t.jsx("p",Object.assign({className:"w-[220px] max-w-full truncate text-[18px] font-semilight leading-tight",title:oe.title},{children:oe.title}))]})),"inline"===u.type&&!de&&t.jsx("div",Object.assign({className:"shrink-0"},{children:t.jsx("button",Object.assign({type:"button",style:{color:te.secondaryText},onClick:ce,title:(null==L?void 0:L.expand)||"Expand","aria-label":(null==L?void 0:L.expand)||"Expand artifact"},{children:ie?t.jsx(y.default,{className:"w-6 h-6 shrink-0"}):t.jsx(m.default,{className:"w-6 h-6 shrink-0"})}))}))]})),de&&t.jsx("div",Object.assign({className:"flex items-center justify-between border-y px-4 py-2.5",style:{borderColor:te.primary}},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100",style:{color:te.secondaryText},onClick:ce,title:"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse":(null==L?void 0:L.close)||"Close","aria-label":"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse artifact":(null==L?void 0:L.close)||"Close artifact"},{children:t.jsx(v.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",style:{color:te.secondaryText},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(oe)try{N.default(oe.content),V(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{V(!1)}})),title:(null==L?void 0:L.copy)||"Copy","aria-label":(null==L?void 0:L.copy)||"Copy artifact content"},{children:t.jsx(f.default,{className:"h-[18px] w-[18px] shrink-0"})})),t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le,className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100"},{children:t.jsx("div",Object.assign({role:"button",className:"cursor-pointer",style:{color:te.secondaryText},title:(null==L?void 0:L.save)||"Download","aria-label":(null==L?void 0:L.save)||"Download artifact content"},{children:t.jsx(g.default,{className:"h-6 w-6 shrink-0"})}))}))]}))})),t.jsx("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:t.jsxs(h.default,Object.assign({ref:Q,innerClassName:"flex-grow w-full"},{children:["render"===W&&"application/vnd.pxe.code"!==oe.type?t.jsx("div",Object.assign({ref:X,className:O.default("p-4 pb-6 flex-grow flex flex-col","text/html"===oe.type&&"p-0","text/csv"===oe.type&&"p-0","application/pdf"===oe.type&&"p-0","application/vnd.pxe.react"===oe.type&&"p-0")},{children:"text/markdown"===oe.type||"text/csv"===oe.type||"text/tab-separated-values"===oe.type||"image/svg+xml"===oe.type?t.jsx(s.PickaxeMarkdown,Object.assign({theme:ee.theme,colors:te},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:null!=ae?ae:oe.content,className:O.default("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===oe.type||"text/tab-separated-values"===oe.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===oe.type?t.jsx(w.default,{ref:G,id:`mermaid-${oe.id}-${oe.version}`,data:oe.content}):"text/html"===oe.type||"application/pdf"===oe.type||"application/vnd.pxe.react"===oe.type?t.jsx("iframe",Object.assign({ref:J,title:oe.title,src:`${q}/${"application/vnd.pxe.react"!==oe.type?"html":"react"}?theme=${ne?"dark":"light"}&bg=${te.secondary}&accent=${te.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==te?void 0:te.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const t=e.target;setTimeout((()=>{var e;try{null===(e=t.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}catch(e){console.error("Error sending message to iframe:",e)}}),100),Y()}},{children:(null==L?void 0:L["iframe-artifact-fallback"])||"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t.jsx(d.Prism,Object.assign({PreTag:"div",language:"text/markdown"===oe.type?"markdown":"text/html"===oe.type||"image/svg+xml"===oe.type?"xml":"application/vnd.pxe.react"===oe.type?"typescript":oe.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ne&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ne&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==te?void 0:te.secondary}),':not(pre) > code[class*="language-"]':{background:null==te?void 0:te.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!ne&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:oe.content})),t.jsx(x.default,{})]}))})),"inline"===u.type&&!ie&&t.jsxs("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t.jsx(j.default,Object.assign({id:`artifact-copy-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(b.default,{color:te.secondaryText,text:oe.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t.jsx(j.default,Object.assign({id:`artifact-save-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le},{children:t.jsx("button",Object.assign({style:{color:te.secondaryText}},{children:t.jsx(g.default,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("./useAuthContext.js"),r=require("./useAuthVerify.js"),o=require("../../../../../common/utils.js"),n=require("../../../../../common/api/pickaxe.js"),u=require("../../../../../common/error.js"),d=require("../../../../../hooks/pickaxe/useResponseContext.js");exports.useAuth=()=>{const{deploymentId:a,pickaxe:l,setSender:c,setSenderType:f}=i.usePickaxeContext(),{emailInput:m,redirectUrl:p,isSending:k,isLoggedOut:h,isPricingAuth:g,setToken:x,setIsLoggingIn:I,setIsSending:w,setIsSent:v,setIsResendDisabled:y,setIsPricingAuth:j}=s.useAuthContext(),A=r.useAuthVerify({token:o.getAuthToken((null==l?void 0:l.studioid)||"")||"",enabled:h,setIsLoggingIn:I}),{setLimitData:P}=d.useResponseContext();t.useEffect((()=>{if("undefined"==typeof window)return;if(!A.data)return;const{success:e,token:t,error:i}=A.data;if(!e||i)return o.deleteAuthToken(`PXE-token-${null==l?void 0:l.studioid}`),void j(!1);e&&t&&(x(t),c(void 0),f("STUDIO_USER"),g&&(j(!1),P(null)))}),[A.data,null==l?void 0:l.studioid]);return{onSend:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!l)return;if(k)return;const e=m.trim().toLowerCase();if(!e)throw new Error("Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error("Please enter a valid email address.");if(!l.studioid)throw new Error(`Studio ID is missing for ${l.formid}. Please contact support.`);w(!0),t&&y(!0);const i=(yield n.default.post("/auth/email",Object.assign(Object.assign({pickaxeId:l.formid,studioId:l.studioid,email:e},a&&{deploymentId:a}),{redirectUrl:p}))).data;if(!i.success)throw new Error(i.error||"Failed to send sign-in link.");w(!1),v(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),y(!1)),o.setAuthToken(`PXE-token-${l.studioid}`,i.token),j(!0)}catch(e){const t=u.default(e);alert(t)}finally{w(!1)}}))}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("./useAuthContext.js"),n=require("./useAuthVerify.js"),r=require("../../../../../common/utils.js"),o=require("../../../../../common/api/pickaxe.js"),d=require("../../../../../common/error.js"),u=require("../../../../../hooks/pickaxe/useResponseContext.js");exports.useAuth=()=>{const{deploymentId:a,pickaxe:l,translations:c,setSender:f,setSenderType:m}=i.usePickaxeContext(),{emailInput:p,redirectUrl:k,isSending:g,isLoggedOut:h,isPricingAuth:v,setToken:x,setIsLoggingIn:I,setIsSending:w,setIsSent:y,setIsResendDisabled:j,setIsPricingAuth:A}=s.useAuthContext(),P=n.useAuthVerify({token:r.getAuthToken((null==l?void 0:l.studioid)||"")||"",enabled:h,setIsLoggingIn:I}),{setLimitData:q}=u.useResponseContext();t.useEffect((()=>{if("undefined"==typeof window)return;if(!P.data)return;const{success:e,token:t,error:i}=P.data;if(!e||i)return r.deleteAuthToken(`PXE-token-${null==l?void 0:l.studioid}`),void A(!1);e&&t&&(x(t),f(void 0),m("STUDIO_USER"),v&&(A(!1),q(null)))}),[P.data,null==l?void 0:l.studioid]);return{onSend:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!l)return;if(g)return;const e=p.trim().toLowerCase();if(!e)throw new Error((null==c?void 0:c["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==c?void 0:c["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!l.studioid)throw new Error(`Studio ID is missing for ${l.formid}. Please contact support.`);w(!0),t&&j(!0);const i=(yield o.default.post("/auth/email",Object.assign(Object.assign({pickaxeId:l.formid,studioId:l.studioid,email:e},a&&{deploymentId:a}),{redirectUrl:k}))).data;if(!i.success)throw new Error(i.error||(null==c?void 0:c["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");w(!1),y(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),j(!1)),r.setAuthToken(`PXE-token-${l.studioid}`,i.token),A(!0)}catch(e){const t=d.default(e);alert(t)}finally{w(!1)}}))}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),l=require("../../../../hooks/core/useHover.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),t=require("../../../../hooks/studio/useStyleInput.js"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("./hooks/useAuthContext.js"),r=require("./hooks/useAuth.js"),c=require("../../../Icons/spinner-circle.svg.js"),u=require("../../../Icons/lock.svg.js"),d=require("../../../Icons/email.svg.js"),x=require("../../../Icons/arrow-right.svg.js"),m=require("../../common/PickaxeIcon.js"),p=require("../../common/PickaxeInput.js"),f=require("../../common/PickaxeButton.js"),h=require("../../common/PickaxeBranding.js"),j=require("../../../../common/cn.js");exports.default=()=>{var g,v,y,k,b,w,N,q,O,C,P;const{deploymentType:I,pickaxe:S,styles:R,colors:_,misc:A,responsiveBy:D,translations:E,isRtl:F}=o.usePickaxeContext(),{emailInput:H,isLoggingIn:T,isSending:B,isResendDisabled:L,isSent:W,setEmailInput:$}=a.useAuthContext(),{onSend:z}=r.useAuth(),K=n.useStyleFontSize(),M=t.useStyleInput(),G=l.useHover(),{isHover:J}=G,Q=e.__rest(G,["isHover"]),U=i.useMemo((()=>H.trim()&&!B&&!W),[H,B,W]);return"chat-input"===I?s.jsx("div",Object.assign({className:j.default("flex items-center gap-x-2 px-4 py-3 overflow-hidden","block"===R.formFieldStyle&&"shadow",W&&"justify-center"),style:M,dir:F?"rtl":"ltr"},{children:W?s.jsxs("p",Object.assign({className:"font-semilight text-center py-1"},{children:[`${null!==(v=null==E?void 0:E["we-sent-your-an-activation-link"])&&void 0!==v?v:"We sent you an activation link. Please be sure to check your spam folder too."} `,s.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{L||B||z(!0)}},{children:B?null!==(y=null==E?void 0:E.resending)&&void 0!==y?y:"Resending...":null!==(k=null==E?void 0:E.resend)&&void 0!==k?k:"Resend"}))]})):s.jsxs(s.Fragment,{children:[s.jsx(u.default,{className:"w-6 h-6 shrink-0",style:{color:_.accent}}),s.jsx("input",{id:"email",name:"email",type:"email",className:"outline-none ring-0 flex-grow bg-transparent",placeholder:null!==(g=null==E?void 0:E["enter-email-to-continue"])&&void 0!==g?g:"Enter here your email to continue",value:H,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(!1)},autoComplete:"off"}),s.jsx("button",Object.assign({className:j.default("outline-none rounded-full w-8 h-8 disabled:cursor-default items-center justify-center flex duration-200 transition-colors ease-in-out",B&&"disabled:cursor-wait"),style:{backgroundColor:J||U?_.accent:_.accent+"10",color:J||U?_.accentText:_.accent+"80"},disabled:!H.trim()||B,onClick:()=>z(!1)},Q,{children:s.jsx(x.default,{className:j.default("h-6 w-6 shrink-0",F&&"transform scale-x-[-1]")})}))]})})):s.jsxs("div",Object.assign({className:"flex flex-col items-center flex-grow relative justify-center p-4",style:{backgroundColor:_.primary,color:_.text,borderRadius:R.cornerRadius},dir:F?"rtl":"ltr"},{children:[!A.isWhiteLabel&&s.jsx(h.default,{className:j.default("absolute top-4 right-4","popup"===I&&"right-12")}),T||!S?s.jsx(c.default,{className:"h-6 w-6 animate-spin animate-spin",style:{fill:_.accent,color:_.primary}}):s.jsxs("div",Object.assign({className:"w-full flex flex-col items-center text-center max-w-[328px]"},{children:[A.isProfileImage&&s.jsx(m.default,{src:null==S?void 0:S.coverphoto,alt:`${null==S?void 0:S.formtitle}'s Profile Picture`,width:72,height:72,className:"h-[72px] w-[72px] rounded-full"}),s.jsx("h3",Object.assign({className:j.default(K.h3,"my-6")},{children:S.formtitle||"Tool"})),W?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-2"},{children:[s.jsx(d.default,{className:"w-6 h-6 shrink-0"}),s.jsx("p",Object.assign({className:"font-semilight text-[20px]"},{children:null!==(q=null==E?void 0:E["check-your-inbox"])&&void 0!==q?q:"Check your inbox"}))]})),s.jsxs("p",Object.assign({className:"font-semilight"},{children:[`${null!==(O=null==E?void 0:E["we-sent-your-an-activation-link"])&&void 0!==O?O:"We sent you an activation link. Please be sure to check your spam folder too."} `,s.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{L||B||z(!0)}},{children:B?null!==(C=null==E?void 0:E.resending)&&void 0!==C?C:"Resending...":null!==(P=null==E?void 0:E.resend)&&void 0!==P?P:"Resend"}))]}))]})):s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-2 flex-grow"},{children:[s.jsx(u.default,{className:"w-6 h-6 shrink-0"}),s.jsx("p",Object.assign({className:"font-semilight"},{children:null!==(b=null==E?void 0:E["please-enter-email-to-continue"])&&void 0!==b?b:"Please enter your email to continue:"}))]})),s.jsxs("div",Object.assign({className:j.default("flex flex-col items-center gap-x-3 gap-y-6 w-full","viewport"===D?"min-[899px]:flex-row":"@[420px]/pickaxe-root:flex-row")},{children:[s.jsx(p.default,{id:"email",name:"email",type:"email",className:j.default("w-full py-3","viewport"===D?"min-[899px]:flex-grow min-[899px]:py-2":"@[420px]/pickaxe-root:flex-grow @[420px]/pickaxe-root:py-2"),placeholder:"jane.doe@email.com",value:H,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(!1)}}),s.jsx(f.default,Object.assign({className:j.default("px-8 min-h-[40px]","viewport"===D?"min-[899px]:px-4":"@[420px]/pickaxe-root:px-4"),loadingText:null!==(w=null==E?void 0:E.sending)&&void 0!==w?w:"Sending...",isLoading:B,isDisabled:!H.trim(),onClick:()=>z(!1)},{children:null!==(N=null==E?void 0:E.submit)&&void 0!==N?N:"Submit"}))]}))]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),l=require("../../../../hooks/core/useHover.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),t=require("../../../../hooks/studio/useStyleInput.js"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("./hooks/useAuthContext.js"),r=require("./hooks/useAuth.js"),c=require("../../../Icons/spinner-circle.svg.js"),u=require("../../../Icons/lock.svg.js"),d=require("../../../Icons/email.svg.js"),x=require("../../../Icons/arrow-right.svg.js"),m=require("../../common/PickaxeIcon.js"),p=require("../../common/PickaxeInput.js"),f=require("../../common/PickaxeButton.js"),h=require("../../common/PickaxeBranding.js"),j=require("../../../../common/cn.js");exports.default=()=>{var g,v,y,k,b,w,N,q,O,C,P;const{deploymentType:I,pickaxe:S,styles:R,colors:_,misc:A,responsiveBy:D,translations:E,isRtl:F}=o.usePickaxeContext(),{emailInput:H,isLoggingIn:T,isSending:B,isResendDisabled:L,isSent:W,setEmailInput:$}=a.useAuthContext(),{onSend:z}=r.useAuth(),K=n.useStyleFontSize(),M=t.useStyleInput(),G=l.useHover(),{isHover:J}=G,Q=e.__rest(G,["isHover"]),U=i.useMemo((()=>H.trim()&&!B&&!W),[H,B,W]);return"chat-input"===I?s.jsx("div",Object.assign({className:j.default("flex items-center gap-x-2 px-4 py-3 overflow-hidden","block"===R.formFieldStyle&&"shadow",W&&"justify-center"),style:M,dir:F?"rtl":"ltr"},{children:W?s.jsxs("p",Object.assign({className:"font-semilight text-center py-1"},{children:[`${null!==(v=null==E?void 0:E["we-sent-your-an-activation-link"])&&void 0!==v?v:"We sent you an activation link. Please be sure to check your spam folder too."} `,s.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{L||B||z(!0)}},{children:B?null!==(y=null==E?void 0:E.resending)&&void 0!==y?y:"Resending...":null!==(k=null==E?void 0:E.resend)&&void 0!==k?k:"Resend"}))]})):s.jsxs(s.Fragment,{children:[s.jsx(u.default,{className:"w-6 h-6 shrink-0",style:{color:_.accent}}),s.jsx("input",{id:"email",name:"email",type:"email",className:"outline-none ring-0 flex-grow bg-transparent",placeholder:null!==(g=null==E?void 0:E["enter-email-to-continue"])&&void 0!==g?g:"Enter here your email to continue",value:H,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(!1)},autoComplete:"off"}),s.jsx("button",Object.assign({className:j.default("outline-none rounded-full w-8 h-8 disabled:cursor-default items-center justify-center flex duration-200 transition-colors ease-in-out",B&&"disabled:cursor-wait"),style:{backgroundColor:J||U?_.accent:_.accent+"10",color:J||U?_.accentText:_.accent+"80"},disabled:!H.trim()||B,onClick:()=>z(!1)},Q,{children:s.jsx(x.default,{className:j.default("h-6 w-6 shrink-0",F&&"transform scale-x-[-1]")})}))]})})):s.jsxs("div",Object.assign({className:"flex flex-col items-center flex-grow relative justify-center p-4",style:{backgroundColor:_.primary,color:_.text,borderRadius:R.cornerRadius},dir:F?"rtl":"ltr"},{children:[!A.isWhiteLabel&&s.jsx(h.default,{className:j.default("absolute top-4 right-4","popup"===I&&"right-12")}),T||!S?s.jsx(c.default,{className:"h-6 w-6 animate-spin animate-spin",style:{fill:_.accent,color:_.primary}}):s.jsxs("div",Object.assign({className:"w-full flex flex-col items-center text-center max-w-[328px]"},{children:[A.isProfileImage&&s.jsx(m.default,{src:null==S?void 0:S.coverphoto,alt:`${null==S?void 0:S.formtitle}'s Profile Picture`,width:72,height:72,className:"h-[72px] w-[72px] rounded-full"}),s.jsx("h3",Object.assign({className:j.default(K.h3,"my-6")},{children:S.formtitle||(null==E?void 0:E.tool)||"Tool"})),W?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-2"},{children:[s.jsx(d.default,{className:"w-6 h-6 shrink-0"}),s.jsx("p",Object.assign({className:"font-semilight text-[20px]"},{children:null!==(q=null==E?void 0:E["check-your-inbox"])&&void 0!==q?q:"Check your inbox"}))]})),s.jsxs("p",Object.assign({className:"font-semilight"},{children:[`${null!==(O=null==E?void 0:E["we-sent-your-an-activation-link"])&&void 0!==O?O:"We sent you an activation link. Please be sure to check your spam folder too."} `,s.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{L||B||z(!0)}},{children:B?null!==(C=null==E?void 0:E.resending)&&void 0!==C?C:"Resending...":null!==(P=null==E?void 0:E.resend)&&void 0!==P?P:"Resend"}))]}))]})):s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-2 flex-grow"},{children:[s.jsx(u.default,{className:"w-6 h-6 shrink-0"}),s.jsx("p",Object.assign({className:"font-semilight"},{children:null!==(b=null==E?void 0:E["please-enter-email-to-continue"])&&void 0!==b?b:"Please enter your email to continue:"}))]})),s.jsxs("div",Object.assign({className:j.default("flex flex-col items-center gap-x-3 gap-y-6 w-full","viewport"===D?"min-[899px]:flex-row":"@[420px]/pickaxe-root:flex-row")},{children:[s.jsx(p.default,{id:"email",name:"email",type:"email",className:j.default("w-full py-3","viewport"===D?"min-[899px]:flex-grow min-[899px]:py-2":"@[420px]/pickaxe-root:flex-grow @[420px]/pickaxe-root:py-2"),placeholder:"jane.doe@email.com",value:H,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z(!1)}}),s.jsx(f.default,Object.assign({className:j.default("px-8 min-h-[40px]","viewport"===D?"min-[899px]:px-4":"@[420px]/pickaxe-root:px-4"),loadingText:null!==(w=null==E?void 0:E.sending)&&void 0!==w?w:"Sending...",isLoading:B,isDisabled:!H.trim(),onClick:()=>z(!1)},{children:null!==(N=null==E?void 0:E.submit)&&void 0!==N?N:"Submit"}))]}))]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:a}={})=>{const{contextId:u,pickaxeId:c,sessionId:l,sender:m,senderType:p,pickaxe:f}=t.usePickaxeContext(),{token:w}=s.useAuthContext(),I=o.useDocumentContext(),h=i.useSubmitDocument(),b=e=>{const t=[...n.allowedFileMimeTypes,...n.allowedImageMimeTypes];if(e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&n.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}))){const e=new Error("You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again."),t=d.default(e);return I.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},I),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I.setDocumentError(""),!t.length)return null;if(b(t))return null;I.setIsUploading(!0),I.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{I.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield h.document(Object.assign(Object.assign(Object.assign({contextId:u,pickaxeId:c,sessionId:l,file:t},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}),"STUDIO_USER"===p&&{studioUserId:m}),w&&{studioSessionToken:w}));if(!e)throw new Error(null!=r?r:"Document processing failed");null==a||a({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.allowedImageMimeTypes.includes(t.type);return I.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return I.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),I.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){I.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.");I.setIsUploading(!0),I.setIsShowList(!0),I.setWebsiteLink(""),I.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield h.website(Object.assign(Object.assign(Object.assign({pickaxeId:c,sessionId:l,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}),"STUDIO_USER"===p&&{studioUserId:m}),w&&{studioSessionToken:w})),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");I.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes("Please paste a valid website URL"))return I.setDocumentError(s),null;I.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{I.setIsUploading(!1)}}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),o=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:a}={})=>{const{contextId:u,pickaxeId:l,sessionId:c,sender:m,senderType:p,pickaxe:f,translations:w}=t.usePickaxeContext(),{token:b}=s.useAuthContext(),I=n.useDocumentContext(),v=i.useSubmitDocument(),h=e=>{const t=[...o.allowedFileMimeTypes,...o.allowedImageMimeTypes];if(e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&o.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}))){const e=(null==w?void 0:w["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=d.default(t);return I.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},I),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I.setDocumentError(""),!t.length)return null;if(h(t))return null;I.setIsUploading(!0),I.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{I.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:n,error:r}=yield v.document(Object.assign(Object.assign(Object.assign({contextId:u,pickaxeId:l,sessionId:c,file:t},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}),"STUDIO_USER"===p&&{studioUserId:m}),b&&{studioSessionToken:b}));if(!e)throw new Error(r||(null==w?void 0:w["document-processing-failed"])||"Document processing failed");null==a||a({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||o.allowedImageMimeTypes.includes(t.type);return I.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&n&&{folder:n})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return I.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),I.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){I.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((null==w?void 0:w["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");I.setIsUploading(!0),I.setIsShowList(!0),I.setWebsiteLink(""),I.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield v.website(Object.assign(Object.assign(Object.assign({pickaxeId:l,sessionId:c,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}),"STUDIO_USER"===p&&{studioUserId:m}),b&&{studioSessionToken:b})),{success:s,documentId:i}=t;if(!s)throw new Error((null==w?void 0:w["website-processing-failed"])||"Website processing failed, please try again.");I.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes((null==w?void 0:w["invalid-website-url"])||"Please paste a valid website URL"))return I.setDocumentError(s),null;I.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{I.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("../../../../common/cn.js"),n=require("react"),a=require("lucide-react"),i=require("../../../Icons/trash-2.svg.js"),r=require("../../../Icons/pencil.svg.js");exports.EditableNavPill=({text:l,className:o,onRename:c,onDelete:u,isDarkGlass:d})=>{const[m,x]=n.useState(!1),[p,f]=n.useState(!1),[h,j]=n.useState(l),[g,b]=n.useState(!1),v=n.useRef(null),w=n.useRef(null);n.useEffect((()=>{p||j(l)}),[l,p]),n.useEffect((()=>{const e=e=>{w.current&&!w.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const N=()=>e.__awaiter(void 0,void 0,void 0,(function*(){h.trim()&&(b(!0),yield c(h),b(!1),f(!1))})),k=()=>{j(l),f(!1)};return s.jsxs("div",Object.assign({ref:w,className:"relative z-40 h-full shrink min-w-0",onMouseDown:e=>{e.preventDefault()}},{children:[s.jsx("div",Object.assign({className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",o),onClick:e=>{e.stopPropagation(),p||m?m&&x(!1):x(!0)}},{children:p?s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:h,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&k()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),s.jsx("button",Object.assign({onClick:N,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(a.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:k,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(a.X,{className:"h-4 w-4"})}))]})):s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:l})),s.jsx(a.MoreHorizontal,{className:t.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),m&&s.jsxs("div",Object.assign({className:t.default("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",d?"bg-[#313131] text-white":"bg-white text-black"),ref:v},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),x(!1),f(!0)},className:t.default("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",d?"border-current":"border-[#EBEAEB]")},{children:[s.jsx(r.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),x(!1),u()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[s.jsx(i.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))},exports.HistoryPill=({icon:e,className:n,onClick:a})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==a||a()},className:t.default("relative flex items-center justify-center h-full aspect-square p-2 md:p-3 shrink-0 transition-all duration-200 cursor-pointer","glass rounded-full",n),onMouseDown:e=>{e.preventDefault()}},{children:s.jsx("div",Object.assign({className:"flex items-center justify-center z-20"},{children:e}))})),exports.NavPill=({text:e,icon:n,className:a,onClick:i})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==i||i()},className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",a),onMouseDown:e=>{e.preventDefault()}},{children:s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[n&&s.jsx("img",{src:n,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../../../common/cn.js"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("react"),i=require("lucide-react"),r=require("../../../Icons/trash-2.svg.js"),l=require("../../../Icons/pencil.svg.js");exports.EditableNavPill=({text:o,className:c,onRename:u,onDelete:d,isDarkGlass:m})=>{const{translations:x}=a.usePickaxeContext(),[p,h]=n.useState(!1),[f,j]=n.useState(!1),[g,b]=n.useState(o),[v,w]=n.useState(!1),k=n.useRef(null),N=n.useRef(null);n.useEffect((()=>{f||b(o)}),[o,f]),n.useEffect((()=>{const e=e=>{N.current&&!N.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const y=()=>e.__awaiter(void 0,void 0,void 0,(function*(){g.trim()&&(w(!0),yield u(g),w(!1),j(!1))})),O=()=>{b(o),j(!1)};return s.jsxs("div",Object.assign({ref:N,className:"relative z-40 h-full shrink min-w-0",onMouseDown:e=>{e.preventDefault()}},{children:[s.jsx("div",Object.assign({className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",c),onClick:e=>{e.stopPropagation(),f||p?p&&h(!1):h(!0)}},{children:f?s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y(),"Escape"===e.key&&O()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),s.jsx("button",Object.assign({onClick:y,disabled:v,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(i.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:O,disabled:v,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(i.X,{className:"h-4 w-4"})}))]})):s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:o})),s.jsx(i.MoreHorizontal,{className:t.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),p&&s.jsxs("div",Object.assign({className:t.default("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",m?"bg-[#313131] text-white":"bg-white text-black"),ref:k},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),h(!1),j(!0)},className:t.default("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",m?"border-current":"border-[#EBEAEB]")},{children:[s.jsx(l.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==x?void 0:x["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),h(!1),d()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[s.jsx(r.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==x?void 0:x["delete-chat"])||"Delete chat"}))]}))]}))]}))},exports.HistoryPill=({icon:e,className:a,onClick:n})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==n||n()},className:t.default("relative flex items-center justify-center h-full aspect-square p-2 md:p-3 shrink-0 transition-all duration-200 cursor-pointer","glass rounded-full",a),onMouseDown:e=>{e.preventDefault()}},{children:s.jsx("div",Object.assign({className:"flex items-center justify-center z-20"},{children:e}))})),exports.NavPill=({text:e,icon:a,className:n,onClick:i})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==i||i()},className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",n),onMouseDown:e=>{e.preventDefault()}},{children:s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[a&&s.jsx("img",{src:a,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t,debug:n})=>{const{scrollContainerRef:l,scrollTargetRef:o,isLocked:s,isScrollSession:c,isScrollIncreasing:u,setIsLocked:i,setIsScrollSession:d,setIsScrolling:a,setIsScrollIncreasing:f}=r.useScrollContext(),[g,v]=e.useState(0),S=e.useRef(!1),w=e.useMemo((()=>null!=t&&t&&c),[t,c]),h=e.useMemo((()=>l&&l.current?l.current:"undefined"==typeof window?null:window),[l]);e.useEffect((()=>{if(!h)return;const e=e=>{c&&s&&("mousedown"===e.type||"wheel"===e.type||"DOMMouseScroll"===e.type||"mousewheel"===e.type)&&i(!1)};return null==h||h.addEventListener("scroll",e),null==h||h.addEventListener("mousedown",e),null==h||h.addEventListener("wheel",e),null==h||h.addEventListener("DOMMouseScroll",e),null==h||h.addEventListener("mousewheel",e),()=>{null==h||h.removeEventListener("scroll",e),null==h||h.removeEventListener("mousedown",e),null==h||h.removeEventListener("wheel",e),null==h||h.removeEventListener("DOMMouseScroll",e),null==h||h.removeEventListener("mousewheel",e)}}),[h,c,s]),e.useEffect((()=>{S.current=!s}),[s]),e.useEffect((()=>{const e=setInterval((()=>{if(!l.current)return;const e=l.current.scrollHeight;if(e===g)return;const r=e>g;n&&console.log("[useScroll] isIncreasing:",r,e,g),f(r),v(e),r&&t&&m()}),100);return()=>clearInterval(e)}),[l,g,t]),e.useEffect((()=>{const e=setInterval((()=>{if(l.current)return;if(!o.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;if(e===g)return;const r=e>g;f(r),v(e),r&&w&&E()}),100);return()=>clearInterval(e)}),[o,g,w]);const m=()=>{try{if(a(!0),!l.current)return void(n&&console.log("[useScroll] scrollContainerRef not detected"));if(S.current)return;const e=l.current.scrollHeight;l.current.scrollTo({top:e,behavior:"smooth"}),n&&console.log("[useScroll] scrolled scrollContainerRef")}finally{a(!1)}},E=()=>{try{if(a(!0),!o.current)return void(n&&console.log("[useScroll] scrollTargetRef not detected"));if(S.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;window.scrollTo({top:e-500,behavior:"smooth"}),n&&console.log("[useScroll] scrolled scrollTargetRef")}finally{a(!1)}};return{scrollContainerRef:l,scrollTargetRef:o,isScrollIncreasing:u,scrollStartSession:()=>{d(!0),i(!0),S.current=!1},scrollEndSession:()=>{d(!1)},scrollToBottom:m,scrollToTarget:E}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t,debug:n})=>{const{scrollContainerRef:o,scrollTargetRef:l,isLocked:s,isScrollSession:c,isScrollIncreasing:u,setIsLocked:i,setIsScrollSession:d,setIsScrolling:a,setIsScrollIncreasing:f}=r.useScrollContext(),[g,v]=e.useState(0),S=e.useRef(!1),h=e.useMemo((()=>null!=t&&t&&c),[t,c]),m=e.useMemo((()=>o&&o.current?o.current:"undefined"==typeof window?null:window),[o]);e.useEffect((()=>{if(!m)return;const e=e=>{!s||"mousedown"!==e.type&&"touchmove"!==e.type&&"wheel"!==e.type&&"DOMMouseScroll"!==e.type&&"mousewheel"!==e.type||i(!1)};return null==m||m.addEventListener("mousedown",e),null==m||m.addEventListener("touchmove",e),null==m||m.addEventListener("wheel",e),null==m||m.addEventListener("DOMMouseScroll",e),null==m||m.addEventListener("mousewheel",e),()=>{null==m||m.removeEventListener("mousedown",e),null==m||m.removeEventListener("touchmove",e),null==m||m.removeEventListener("wheel",e),null==m||m.removeEventListener("DOMMouseScroll",e),null==m||m.removeEventListener("mousewheel",e)}}),[m,s]),e.useEffect((()=>{S.current=!s}),[s]),e.useEffect((()=>{const e=setInterval((()=>{if(!o.current)return;const e=o.current.scrollHeight;if(e===g)return;const r=e>g;n&&console.log("[useScroll] isIncreasing:",r,e,g),f(r),v(e),r&&t&&w()}),100);return()=>clearInterval(e)}),[o,g,t]),e.useEffect((()=>{const e=setInterval((()=>{if(o.current)return;if(!l.current)return;const e=l.current.getBoundingClientRect().top+l.current.getBoundingClientRect().height+window.scrollY;if(e===g)return;const r=e>g;f(r),v(e),r&&h&&E()}),100);return()=>clearInterval(e)}),[l,g,h]);const w=()=>{try{if(a(!0),!o.current)return void(n&&console.log("[useScroll] scrollContainerRef not detected"));if(S.current)return;const e=o.current.scrollHeight;o.current.scrollTo({top:e,behavior:"smooth"}),n&&console.log("[useScroll] scrolled scrollContainerRef")}finally{a(!1)}},E=()=>{try{if(a(!0),!l.current)return void(n&&console.log("[useScroll] scrollTargetRef not detected"));if(S.current)return;const e=l.current.getBoundingClientRect().top+l.current.getBoundingClientRect().height+window.scrollY;window.scrollTo({top:e-500,behavior:"smooth"}),n&&console.log("[useScroll] scrolled scrollTargetRef")}finally{a(!1)}};return{scrollContainerRef:o,scrollTargetRef:l,isScrollIncreasing:u,scrollStartSession:()=>{d(!0),i(!0),S.current=!1},scrollEndSession:()=>{d(!1)},scrollToBottom:w,scrollToTarget:E}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),a=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:A,isInputFocused:S,onSubmit:P,resubmitPrompt:I})=>{var H,R,L,M,D;const{sessionId:F,deploymentType:B,pickaxe:E,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isShowIceBreaker:U,setSessionId:V,setLastSessionId:G}=i.usePickaxeContext(),{emailInput:J,isLoggedOut:K,isSending:Q,isResendDisabled:X,isSent:Y,isPricingAuth:Z}=t.useAuthContext(),{onSend:ee}=a.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:te,error:ae}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==E?void 0:E.icebreakers)?E.icebreakers.slice(0,3):[]),[null==E?void 0:E.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!A&&de.isSuccess&&W&&!e}),[A,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==E?void 0:E.chatflag)&&(null==E?void 0:E.enablechatresponses)&&ie.length>0),[E,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===B&&Z&&K&&Y,ge=U&&!S&&!je&&me&&ne>767,pe=U&&!S&&(je||ne<=767),be=()=>{G(F),V("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===B&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:J}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(L=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==L?L:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{X||Q||ee(!0)}},{children:Q?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==E?void 0:E.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(R=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==R?R:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var t,a;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(a=null===(t=de.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),te?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):ae?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:ae})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),a=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),h=require("../../common/PickaxeEmbedHead.js"),j=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),v=require("../../Addons/Scroll/ScrollLockView.js"),b=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:A,isInputFocused:S,onSubmit:P,resubmitPrompt:I})=>{var H,R,L,M,D;const{sessionId:F,deploymentType:B,pickaxe:E,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isShowIceBreaker:U,setSessionId:V,setLastSessionId:G}=i.usePickaxeContext(),{emailInput:J,isLoggedOut:K,isSending:Q,isResendDisabled:X,isSent:Y,isPricingAuth:Z}=t.useAuthContext(),{onSend:ee}=a.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:te,error:ae}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==E?void 0:E.icebreakers)?E.icebreakers.slice(0,3):[]),[null==E?void 0:E.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!A&&de.isSuccess&&W&&!e}),[A,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==E?void 0:E.chatflag)&&(null==E?void 0:E.enablechatresponses)&&ie.length>0),[E,ie]),he=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),je="chat-input"===B&&Z&&K&&Y,ge=U&&!S&&!he&&me&&ne>767,pe=U&&!S&&(he||ne<=767),ve=()=>{G(F),V("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(b.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===B&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:ve})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!je&&{onIconClick:ve})),$&&!de.isLoading&&e.jsx(h.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!je&&{onIconClick:ve,onHistoryClick:ve})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),je?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:J}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(L=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==L?L:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{X||Q||ee(!0)}},{children:Q?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==E?void 0:E.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:[(null==T?void 0:T["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==T?void 0:T["contact-us"])||"contact us"}))," ",(null==T?void 0:T["for-help"])||"for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(R=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==R?R:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var t,a;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(a=null===(t=de.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),te?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(j.default,{})})):ae?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:ae})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(v.default,{})]}))]})):null})]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),r=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),m=require("../../../common/documents.js"),g=require("eventsource-parser"),v=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),y=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),k=require("../../../common/validation.js"),C=require("../../../common/cn.js"),N=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js"),_=require("../../../hooks/pickaxe/useSpeech.js");const E=s.forwardRef((({resubmitPrompt:E,onFocus:T,onBlur:A,onInputHeightChange:P,initSmitheryAuthData:q},R)=>{var D,U,L;const{origin:M,pickaxeId:$,sessionId:F,sender:B,senderType:H,portalId:V,deploymentId:X,deploymentType:K,pickaxe:W,styles:J,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,setValidationStatus:ie,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:re,onGenerateComplete:ae}=n.usePickaxeContext(),{token:le,isLoggedOut:ce,isSent:de,isPricingAuth:ue}=c.useAuthContext(),{messages:pe,isGenerating:fe,setMessages:he,setStatus:me,setLimitData:ge,setError:ve}=i.useResponseContext(),{documents:be,isUploading:xe,documentError:je,onFileUpload:ye,setDocuments:we,setDocumentError:Oe}=d.useDocument(),{studio:Se}=I.useStudio(),{scrollStartSession:ke,scrollEndSession:Ce,scrollToBottom:Ne}=u.useScroll({auto:!0}),{artifacts:Ie,currentPopupType:_e,setArtifacts:Ee,setCurrentArtifact:Te}=p.useArtifactContext(),{height:Ae}=l.useDimensionContext(),Pe=a.useConversation(),[qe,Re]=s.useState(""),[De,Ue]=s.useState(!1),[Le,Me]=s.useState(!1),[$e,Fe]=s.useState(null),[Be,He]=s.useState(null),[Ve,Xe]=s.useState(!1),Ke=s.useRef(null),We=s.useRef(""),Je=s.useRef(null),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=Math.max(.4*Ae,100),{speechTranscript:et,isSpeechListening:tt,isSpeechProcessing:st,isSpeechSupported:nt,onStartListening:it,onStopListening:ot}=_.useSpeech(),[rt]=h.useMediaQuery("(max-width: 480px)"),at=f.useHover(),{isHover:lt}=at,ct=e.__rest(at,["isHover"]),dt=f.useHover(),{isHover:ut}=dt,pt=e.__rest(dt,["isHover"]),ft=f.useHover(),{isHover:ht}=ft,mt=e.__rest(ft,["isHover"]),gt=r.useStyleFontSize(),vt=o.useStyleInput(),bt="undefined"!=typeof window?window.location.hostname:"",xt="undefined"!=typeof window?window.location.href:"",jt="undefined"!=typeof window&&window.self!==window.top,yt=bt.includes("pickaxe.co")&&!xt.includes("https://studio.pickaxe.co/_embed")&&!jt,wt=null===(D=null==W?void 0:W.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),Ot=nt&&(null==W?void 0:W.enablevoicetotext),St="chat-input"===K&&Y&&!de,kt="chat-input"===K&&ue&&ce&&de,Ct=s.useCallback((e=>{const t=k.getValidationFailure(e);return!!t&&(ve(""),ge(null),ie(t.status),oe(t.upgradeGroups),re(t.upgradeUrl),!0)}),[ve,ge,ie,oe,re]),Nt=null!==(U=null==W?void 0:W.placeholdertext)&&void 0!==U?U:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",It=De||Le,_t=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==W?void 0:W.studioid},B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),yt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Fe(t.studioUser),He(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,F,H,B,le,V,X,yt]);s.useEffect((()=>{_t()}),[_t]);const Et=(null==te?void 0:te.limit)||0,Tt=(null==$e?void 0:$e.currentUses)||0,At=(null==$e?void 0:$e.extraUses)||0,Pt=!!(null==Se?void 0:Se.data.usage)&&Se.data.usage.isCredits,qt=Et>Tt?Et-Tt+At:At,Rt=s.useMemo((()=>!!$e&&(!Ve&&(!(Et<=0)&&qt<=.05*Et))),[$e,Ve,qt,Et]),Dt=s.useMemo((()=>{var e,t,s;return!!Y&&(!!W&&(!Pe.isLoading&&(!((null!==(t=null===(e=Pe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=W.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!St)))))}),[W,Y,ee,St,Pe.data,Pe.isLoading]),Ut=s.useMemo((()=>{if(fe||xe)return!1;const e=be.length>0&&be.every((e=>"finished"===e.status));return!(!qe.trim()&&!e)&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[fe,xe,qe,be]);s.useImperativeHandle(R,(()=>({onSubmit:Lt}))),s.useEffect((()=>{ne(Dt)}),[Dt]),s.useEffect((()=>{var e;if(E){const t=Array.from(pe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Lt(s,!0)}}),[E]),s.useEffect((()=>{if(!Qe.current||!P)return;const e=new ResizeObserver((e=>{for(const t of e)P(t.contentRect.height)}));return e.observe(Qe.current),()=>{e.disconnect()}}),[P]),s.useEffect((()=>{if(!tt)return;const e=We.current?`${We.current} `:"";Re(`${e}${et}`)}),[et,tt]),s.useEffect((()=>{if(!ze.current)return;(()=>{if(!ze.current)return;let e=ze.current.scrollHeight>52;qe.includes("\n")||be.length?e=!0:qe.trim()||(e=!1),Ue(e)})()}),[qe,be]),s.useEffect((()=>{const e=ze.current,t=Ge.current;if(!e||!t||De||qe.includes("\n"))return void Me(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=qe||Nt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Me(o>l)}),[qe,De,Nt]);const Lt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(fe||xe)return;const o=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:qe;if(!c&&!l)return;ve(""),Oe(""),ge(null),Re(""),se(!1),me("fetching"),ke(),Ne();const d=null!==(n=null===(e=null==W?void 0:W.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(pe.slice(0,pe.length-1)):Array.from(pe),...s?[]:[{id:pe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:pe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];he(u),Ne(),d&&we([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:F,senderType:H,value:c},d&&{documentIds:r}),B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}),V&&{portalId:V}),X&&{deploymentId:X}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},yt&&{credentials:"include"})),f=yield p.json();if(!f.success){if(Ct(f))return;const e=new Error(f.error||f.message||"Failed to start generation");throw f.limitData&&(e.limitData=f.limitData),e}const h=f.submissionId;me("streaming"),Ye.current=new AbortController;const m=u.length-1,v=[];let b=[...null!=Ie?Ie:[]],x=0,j=!1,y="";for(;!j;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${h}?index=${x}`,{signal:null===(i=Ye.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Je.current=t;const s=new TextDecoder,n=g.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ct(t)||ve(s),void(j=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw j=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw j=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",v.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",v.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;v.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}he([...u.slice(0,m),Object.assign(Object.assign({},u[u.length-1]),{id:pe.length+1,role:"assistant",parts:v})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee([...b]),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ee(b),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee(b),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ee(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ee(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong, please try again.";if(Ct(t))return void(j=!0);ve(s)}else"stop"===e.event&&(j=!0)}else j=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}j||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(j=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ae||ae(F)}catch(e){if(e.limitData)ge(e.limitData),ve("");else{let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ct(t)||ve(t)}}finally{Ne(),me("idle"),Ce(),Je.current=null,yield _t()}}));return kt?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!St&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Qe,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===J.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},vt),{maxHeight:`${Ze}px`,overflowY:"auto"})},{children:[Rt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:vt.backgroundColor?`${vt.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:J.cornerRadius+"px",borderTopLeftRadius:J.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[qt," ",Pt?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Be}${null==te?void 0:te.accessGroupId}`;N.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Xe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!fe&&be.length>0&&t.jsx(y.default,{className:"p-4 pb-0",isDisabled:fe}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[tt&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(L=z.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(w.default,Object.assign({ref:ze,className:C.default(gt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!qe.trim()&&!qe.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",It&&"mb-12",tt&&"text-transparent"),value:qe,placeholder:Nt,onChange:e=>{if(Re(e),P){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void P(0);if(t>=11)return;let s=0;t>1&&(s=50),P(24*(t-1)+s)}},onKeyDown:e=>{Q||rt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),xe||fe||Lt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield ye(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Ge,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",It?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!It&&vt.backgroundColor&&{backgroundColor:vt.backgroundColor}),{borderTopRightRadius:J.cornerRadius+"px",borderBottomRightRadius:J.cornerRadius+"px"})},{children:fe?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ye.current&&(Ye.current.abort(),Ye.current=null),Je.current&&(Je.current.cancel(),Je.current=null),me("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):tt?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:ot,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[wt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ut?z.accent+"10":void 0,color:ut?z.accent:z.accent+"80"},disabled:xe||fe,onClick:()=>{var e;return null===(e=Ke.current)||void 0===e?void 0:e.click()}},pt,{children:[t.jsx("input",{id:"file-upload",ref:Ke,type:"file",accept:[...m.allowedFileMimeTypes,...m.allowedImageMimeTypes,...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield ye(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(v.default,{className:"h-6 w-6 shrink-0"})]})),Ot&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:tt?z.accent:ht?z.accent+"10":void 0,color:tt?z.accentText:ht?z.accent:z.accent+"80"},disabled:xe||fe||st,onClick:()=>{tt?ot():(We.current=qe,it(G||"en-US"))}},mt,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:lt||Ut?z.accent:z.accent+"10",color:lt||Ut?z.accentText:z.accent+"80"},disabled:!Ut,onClick:()=>Lt()},ct,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),je&&t.jsx(O.default,{error:je,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),r=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),m=require("eventsource-parser"),v=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),j=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),k=require("../../../common/validation.js"),C=require("../../../common/cn.js"),N=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js"),_=require("../../../hooks/pickaxe/useSpeech.js");const E=s.forwardRef((({resubmitPrompt:E,onFocus:T,onBlur:A,onInputHeightChange:P,initSmitheryAuthData:q},R)=>{var D,U,L;const{origin:M,pickaxeId:$,sessionId:F,sender:B,senderType:H,portalId:V,deploymentId:X,deploymentType:K,pickaxe:W,styles:J,colors:z,translations:G,locale:Q,forceMobile:Y,isNewChat:Z,isRtl:ee,isShowFeedbackMessage:te,accessGroup:se,setIsNewChat:ne,setIsShowIceBreaker:ie,setValidationStatus:oe,setValidationUpgradeGroups:re,setValidationUpgradeUrl:ae,onGenerateComplete:le}=n.usePickaxeContext(),{token:ce,isLoggedOut:de,isSent:ue,isPricingAuth:pe}=c.useAuthContext(),{messages:fe,isGenerating:ge,setMessages:he,setStatus:me,setLimitData:ve,setError:be}=i.useResponseContext(),{documents:xe,isUploading:ye,documentError:je,onFileUpload:we,setDocuments:Oe,setDocumentError:Se}=d.useDocument(),{studio:ke}=I.useStudio(),{scrollStartSession:Ce,scrollEndSession:Ne,scrollToBottom:Ie}=u.useScroll({auto:!0}),{artifacts:_e,currentPopupType:Ee,setArtifacts:Te,setCurrentArtifact:Ae}=p.useArtifactContext(),{height:Pe}=l.useDimensionContext(),qe=a.useConversation(),[Re,De]=s.useState(""),[Ue,Le]=s.useState(!1),[Me,$e]=s.useState(!1),[Fe,Be]=s.useState(null),[He,Ve]=s.useState(null),[Xe,Ke]=s.useState(!1),We=s.useRef(null),Je=s.useRef(""),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=s.useRef(null),et=Math.max(.4*Pe,100),{speechTranscript:tt,isSpeechListening:st,isSpeechProcessing:nt,isSpeechSupported:it,onStartListening:ot,onStopListening:rt}=_.useSpeech(),[at]=g.useMediaQuery("(max-width: 480px)"),lt=f.useHover(),{isHover:ct}=lt,dt=e.__rest(lt,["isHover"]),ut=f.useHover(),{isHover:pt}=ut,ft=e.__rest(ut,["isHover"]),gt=f.useHover(),{isHover:ht}=gt,mt=e.__rest(gt,["isHover"]),vt=r.useStyleFontSize(),bt=o.useStyleInput(),xt="undefined"!=typeof window?window.location.hostname:"",yt="undefined"!=typeof window?window.location.href:"",jt="undefined"!=typeof window&&window.self!==window.top,wt=xt.includes("pickaxe.co")&&!yt.includes("https://studio.pickaxe.co/_embed")&&!jt,Ot=null===(D=null==W?void 0:W.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),St=it&&(null==W?void 0:W.enablevoicetotext),kt="chat-input"===K&&Z&&!ue,Ct="chat-input"===K&&pe&&de&&ue,Nt=s.useCallback((e=>{const t=k.getValidationFailure(e);return!!t&&(be(""),ve(null),oe(t.status),re(t.upgradeGroups),ae(t.upgradeUrl),!0)}),[be,ve,oe,re,ae]),It=null!==(U=null==W?void 0:W.placeholdertext)&&void 0!==U?U:ee?"بماذا تريد أن تتحدث؟":(null==G?void 0:G["what-do-you-want-to-talk-about"])||"What do you want to talk about?",_t=Ue||Me,Et=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==W?void 0:W.studioid},B&&{sender:B}),ce&&{studioSessionToken:ce}),!ce&&!B&&{sender:N.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),wt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Be(t.studioUser),Ve(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,F,H,B,ce,V,X,wt]);s.useEffect((()=>{Et()}),[Et]);const Tt=(null==se?void 0:se.limit)||0,At=(null==Fe?void 0:Fe.currentUses)||0,Pt=(null==Fe?void 0:Fe.extraUses)||0,qt=!!(null==ke?void 0:ke.data.usage)&&ke.data.usage.isCredits,Rt=Tt>At?Tt-At+Pt:Pt,Dt=s.useMemo((()=>!!Fe&&(!Xe&&(!(Tt<=0)&&Rt<=.05*Tt))),[Fe,Xe,Rt,Tt]),Ut=s.useMemo((()=>{var e,t,s;return!!Z&&(!!W&&(!qe.isLoading&&(!((null!==(t=null===(e=qe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=W.icebreakers)||void 0===s?void 0:s.length)&&(!te&&!kt)))))}),[W,Z,te,kt,qe.data,qe.isLoading]),Lt=s.useMemo((()=>{if(ge||ye)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Re.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ge,ye,Re,xe]);s.useImperativeHandle(R,(()=>({onSubmit:Mt}))),s.useEffect((()=>{ie(Ut)}),[Ut]),s.useEffect((()=>{var e;if(E){const t=Array.from(fe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Mt(s,!0)}}),[E]),s.useEffect((()=>{if(!Ye.current||!P)return;const e=new ResizeObserver((e=>{for(const t of e)P(t.contentRect.height)}));return e.observe(Ye.current),()=>{e.disconnect()}}),[P]),s.useEffect((()=>{if(!st)return;const e=Je.current?`${Je.current} `:"";De(`${e}${tt}`)}),[tt,st]),s.useEffect((()=>{if(!Ge.current)return;(()=>{if(!Ge.current)return;let e=Ge.current.scrollHeight>52;Re.includes("\n")||xe.length?e=!0:Re.trim()||(e=!1),Le(e)})()}),[Re,xe]),s.useEffect((()=>{const e=Ge.current,t=Qe.current;if(!e||!t||Ue||Re.includes("\n"))return void $e(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Re||It,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;$e(o>l)}),[Re,Ue,It]);const Mt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(ge||ye)return;const o=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:Re;if(!c&&!l)return;be(""),Se(""),ve(null),De(""),ne(!1),me("fetching"),Ce(),Ie();const d=null!==(n=null===(e=null==W?void 0:W.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...s?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:fe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];he(u),Ie(),d&&Oe([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:F,senderType:H,value:c},d&&{documentIds:r}),B&&{sender:B}),ce&&{studioSessionToken:ce}),!ce&&!B&&{sender:N.initializeEmbedUserId()}),V&&{portalId:V}),X&&{deploymentId:X}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},wt&&{credentials:"include"})),f=yield p.json();if(!f.success){if(Nt(f))return;const e=new Error(f.error||f.message||(null==G?void 0:G["failed-to-start-generation"])||"Failed to start generation");throw f.limitData&&(e.limitData=f.limitData),e}const g=f.submissionId;me("streaming"),Ze.current=new AbortController;const h=u.length-1,v=[];let b=[...null!=_e?_e:[]],x=0,y=!1,j="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${g}?index=${x}`,{signal:null===(i=Ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ze.current=t;const s=new TextDecoder,n=m.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||(null==G?void 0:G["something-went-wrong"])||"Something went wrong.";return Nt(t)||be(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",v.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,v[v.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",v.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,v[v.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;v.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}he([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:fe.length+1,role:"assistant",parts:v})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te([...b]),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Te(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||(null==G?void 0:G["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Nt(t))return void(y=!0);be(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==le||le(F)}catch(e){if(e.limitData)ve(e.limitData),be("");else{let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==G?void 0:G["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Nt(t)||be(t)}}finally{Ie(),me("idle"),Ne(),ze.current=null,yield Et()}}));return Ct?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!kt&&"px-4 pb-8"),dir:ee?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ye,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===J.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},bt),{maxHeight:`${et}px`,overflowY:"auto"})},{children:[Dt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:bt.backgroundColor?`${bt.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:J.cornerRadius+"px",borderTopLeftRadius:J.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Rt," ",qt?(null==G?void 0:G.credits)||"Credits":(null==G?void 0:G.uses)||"Uses"," ",(null==G?void 0:G.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${He}${null==se?void 0:se.accessGroupId}`;N.isInIframe()?window.open(t):location.href=t}},{children:(null==G?void 0:G.upgrade)||"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Ke(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!ge&&xe.length>0&&t.jsx(j.default,{className:"p-4 pb-0",isDisabled:ge}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[st&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(L=z.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:(null==G?void 0:G.listening)||"Listening..."}))]})),t.jsx(w.default,Object.assign({ref:Ge,className:C.default(vt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Re.trim()&&!Re.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ee?"text-right":"text-left",_t&&"mb-12",st&&"text-transparent"),value:Re,placeholder:It,onChange:e=>{De(e)},onKeyDown:e=>{Y||at||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ye||ge||Mt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ne(!1),yield we(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:ee?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Qe,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",_t?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!_t&&bt.backgroundColor&&{backgroundColor:bt.backgroundColor}),{borderTopRightRadius:J.cornerRadius+"px",borderBottomRightRadius:J.cornerRadius+"px"})},{children:ge?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ze.current&&(Ze.current.abort(),Ze.current=null),ze.current&&(ze.current.cancel(),ze.current=null),me("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):st?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:rt,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ot&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:pt?z.accent+"10":void 0,color:pt?z.accent:z.accent+"80"},disabled:ye||ge,onClick:()=>{var e;return null===(e=We.current)||void 0===e?void 0:e.click()}},ft,{children:[t.jsx("input",{id:"file-upload",ref:We,type:"file",accept:[...h.allowedFileMimeTypes,...h.allowedImageMimeTypes,...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ne(!1),yield we(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(v.default,{className:"h-6 w-6 shrink-0"})]})),St&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:st?z.accent:ht?z.accent+"10":void 0,color:st?z.accentText:ht?z.accent:z.accent+"80"},disabled:ye||ge||nt,onClick:()=>{st?rt():(Je.current=Re,ot(Q||"en-US"))}},mt,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ct||Lt?z.accent:z.accent+"10",color:ct||Lt?z.accentText:z.accent+"80"},disabled:!Lt,onClick:()=>Mt()},dt,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",ee&&"scale-x-[-1] transform")})}))]})}))]}))]})),je&&t.jsx(O.default,{error:je,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),u=require("./Input.js"),c=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),f=require("../../../common/api/pickaxe.js"),h=require("uuid"),m=require("../../Core/StudioTip.js"),p=require("../../../hooks/pickaxe/useResponseContext.js"),x=require("../Addons/Navbar/NavPill.js"),v=require("../../Icons/history.svg.js");exports.default=()=>{const{deploymentType:j,isNewChat:g,setIsNewChat:b,sessionId:k,setSessionId:y,setLastSessionId:w,pickaxeId:C,sender:D,pickaxe:I,styles:S,isEmbed:_,translations:q}=i.usePickaxeContext(),{isSent:N}=o.useAuthContext(),{width:P,height:F,setDimension:A}=r.useDimensionContext(),{setDocuments:T,onFileUpload:E}=n.useDocument(),{isGenerating:O,messages:R}=p.useResponseContext(),z=a.useStyleFontSize(),[H,G]=s.useState(0),[L,B]=s.useState(!1),[M,U]=s.useState(!1),J=s.useRef(null),K=s.useRef(null),Q=s.useRef(0),[V,W]=s.useState(null),[X,Y]=s.useState(!1),Z="chat-input"===j&&g&&!N;s.useEffect((()=>()=>{T([])}),[]);const $=s.useCallback((()=>{if(!C||!D)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield f.default.post("/get_pickaxe_conversation",{sessionId:k,userId:D});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void te(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[C,D,k]);s.useEffect((()=>{O||g||!k||$()}),[O,g,k,$]),s.useEffect((()=>{if(!J.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;A(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(J.current),()=>{e.disconnect()}}),[J.current]);const[ee,te]=s.useState("New Chat"),se=(null==I?void 0:I.formtitle)||"Pickaxe",ie=(null==I?void 0:I.coverphoto)||void 0,[oe,re]=s.useState(!1);s.useEffect((()=>{const e=!Z&&!_&&S.portalTheme&&(R.filter((e=>"user"===e.role)).length>0||L||!g);re(null!=e&&e)}),[R,L,g]);return t.jsxs("div",Object.assign({ref:J,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Q.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&U(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),Q.current-=1,0===Q.current&&U(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),U(!1),Q.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(b(!1),yield E(e))}))},{children:[M&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(c.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(z.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(z.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),Z?t.jsx(u.default,{}):t.jsxs(t.Fragment,{children:[oe&&t.jsxs("div",Object.assign({className:d.default("direct-link"===j?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===S.portalTheme?"glass-dark ":"")},{children:[t.jsx(x.NavPill,{text:se,icon:ie}),g||"New Chat"===ee?t.jsx(x.NavPill,{text:ee}):t.jsx(x.EditableNavPill,{text:ee,sessionId:k,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(k)try{yield f.default.post("/edit_conversation_name",{sessionId:k,name:t,userId:D}),te(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(k&&window.confirm("Are you sure you want to delete this conversation?"))try{yield f.default.post("/delete_pickaxe_conversation",{sessionId:k,userId:D}),b(!0),y(h.v4()),te("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===S.portalTheme}),t.jsx(m.StudioTip,Object.assign({content:q["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(x.HistoryPill,{icon:t.jsx(v.default,{}),onClick:()=>{y(""),w(k)}})}))]})),t.jsx(l.default,{additionalScrollHeight:H,isForceHideInfo:F<=545||P<=350||L,isInputFocused:L,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){K.current&&K.current.onSubmit(t)})),smitheryAuthData:V,resubmitPrompt:()=>{W(null),Y(!0)}}),t.jsx(u.default,{ref:K,onFocus:()=>B(!0),onBlur:()=>B(!1),onInputHeightChange:G,initSmitheryAuthData:e=>W(e),resubmitPrompt:X})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../Addons/Auth/hooks/useAuthContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),c=require("./History/index.js"),u=require("./Input.js"),d=require("../../Icons/attach-vertical.svg.js"),f=require("../../Icons/arrow-down.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),v=require("uuid"),p=require("../../Core/StudioTip.js"),x=require("../../../hooks/pickaxe/useResponseContext.js"),j=require("../Addons/Navbar/NavPill.js"),g=require("../../Icons/history.svg.js");exports.default=()=>{const{deploymentType:b,isNewChat:k,setIsNewChat:y,sessionId:w,setSessionId:S,setLastSessionId:C,pickaxeId:I,sender:q,pickaxe:D,styles:_,colors:N,isEmbed:T,translations:E}=s.usePickaxeContext(),{isSent:P}=n.useAuthContext(),{width:A,height:F,setDimension:H}=i.useDimensionContext(),{setDocuments:O,onFileUpload:R}=r.useDocument(),{scrollContainerRef:z,isLocked:L,setIsLocked:G}=a.useScrollContext(),{isGenerating:M,messages:B}=x.useResponseContext(),U=l.useStyleFontSize(),[$,J]=o.useState(0),[K,Q]=o.useState(!1),[V,W]=o.useState(!1),[X,Y]=o.useState(!1),[Z,ee]=o.useState(!0),te=o.useRef(null),oe=o.useRef(null),se=o.useRef(0),[ne,ie]=o.useState(null),[re,ae]=o.useState(!1),le=(null==E?void 0:E["new-chat"])||"New chat",ce="chat-input"===b&&k&&!P;o.useEffect((()=>()=>{O([])}),[]);const ue=o.useCallback((()=>{if(!I||!q)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.default.post("/get_pickaxe_conversation",{sessionId:w,userId:q});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void fe(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[I,q,w]);o.useEffect((()=>{M||k||!w||ue()}),[M,k,w,ue]),o.useEffect((()=>{if(!te.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;H(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(te.current),()=>{e.disconnect()}}),[H]);const[de,fe]=o.useState(le),he=(null==D?void 0:D.formtitle)||"Pickaxe",me=(null==D?void 0:D.coverphoto)||void 0,[ve,pe]=o.useState(!1);o.useEffect((()=>{const e=!ce&&!T&&_.portalTheme&&(B.filter((e=>"user"===e.role)).length>0||K||!k);pe(null!=e&&e)}),[ce,T,K,k,B,_.portalTheme]),o.useEffect((()=>{const e=z.current;if(!e)return;const t=()=>{const t=e.scrollHeight-e.scrollTop-e.clientHeight;Y(e.scrollHeight>e.clientHeight+8),ee(t<=24)};t(),e.addEventListener("scroll",t,{passive:!0});const o=new ResizeObserver((()=>{t()}));o.observe(e);const s=e.firstElementChild;return s instanceof HTMLElement&&o.observe(s),()=>{e.removeEventListener("scroll",t),o.disconnect()}}),[ce,z]);const xe=o.useCallback((()=>{z.current&&(G(!0),z.current.scrollTo({top:z.current.scrollHeight,behavior:"smooth"}))}),[z,G]);return t.jsxs("div",Object.assign({ref:te,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),se.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&W(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),se.current-=1,0===se.current&&W(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),W(!1),se.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(y(!1),yield R(e))}))},{children:[V&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(d.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:h.default(U.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==E?void 0:E["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:h.default(U.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),ce?t.jsx(u.default,{}):t.jsxs(t.Fragment,{children:[ve&&t.jsxs("div",Object.assign({className:h.default("direct-link"===b?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[t.jsx(j.NavPill,{text:he,icon:me}),k||de===le?t.jsx(j.NavPill,{text:de}):t.jsx(j.EditableNavPill,{text:de,sessionId:w,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w)try{yield m.default.post("/edit_conversation_name",{sessionId:w,name:t,userId:q}),fe(t)}catch(e){console.error("Error renaming chat:",e),alert((null==E?void 0:E["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.default.post("/delete_pickaxe_conversation",{sessionId:w,userId:q}),y(!0),S(v.v4()),fe(le)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(p.StudioTip,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(j.HistoryPill,{icon:t.jsx(g.default,{}),onClick:()=>{S(""),C(w)}})}))]})),t.jsx(c.default,{additionalScrollHeight:$,isForceHideInfo:F<=545||A<=350||K,isInputFocused:K,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){oe.current&&oe.current.onSubmit(t)})),smitheryAuthData:ne,resubmitPrompt:()=>{ie(null),ae(!0)}}),t.jsx("button",Object.assign({type:"button","aria-label":(null==E?void 0:E["scroll-to-bottom"])||"Scroll to bottom",className:h.default("absolute left-1/2 z-30 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full shadow-md outline-none transition-all duration-200 ease-in-out",!X||L||Z?"pointer-events-none translate-y-2 opacity-0":"opacity-100"),style:{bottom:`${$+65}px`,backgroundColor:N.accent,color:N.accentText},onClick:xe},{children:t.jsx(f.default,{className:"h-3 w-3 shrink-0"})})),t.jsx(u.default,{ref:oe,onFocus:()=>Q(!0),onBlur:()=>Q(!1),onInputHeightChange:J,initSmitheryAuthData:e=>ie(e),resubmitPrompt:re})]})]}))};
@@ -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"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("date-fns"),r=require("../../../../common/api/pickaxe.js"),l=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),u=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:g})=>{const{pickaxe:y,sender:v,colors:k,translations:w,styles:N,isRtl:_,disableCss:C,disableHtml:O,disableJs:q,setSessionId:P,setIsNewChat:M}=a.usePickaxeContext(),{setMessages:I}=n.useResponseContext(),{setDocuments:R}=o.useDocument(),[S,E]=t.useState(!1),[D,F]=t.useState(!1),[T,H]=t.useState(!1),[$,z]=t.useState(!1),[A,J]=t.useState(!1),L=t.useRef(null),[B,K]=t.useState(f.shortSummary||f.summary||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(f.shortSummary||f.summary||"Conversation name")}),[f.shortSummary,f.summary]),t.useEffect((()=>{const e=e=>{L.current&&!L.current.contains(e.target)&&E(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>f?"FORM"===f.pickaxeType&&0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0),[f]),U=t.useMemo((()=>i.format(new Date(f.updatedAt),"MMM dd, yyy hh:mm a")),[f]),V=t.useMemo((()=>{var e;if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const s=null!==(e=f.question.inputs)&&void 0!==e?e:[];return A?s.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||"n/a"}</p>\n</div>`)).join(""):s.map((e=>`${e.question}: ${e.answer||"n/a"}`)).join(" | ")}const s=f.messages.find((e=>"user"===e.role));return s?s.parts[0].content:""}),[f,A]),W=t.useMemo((()=>{if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return f.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=f.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[f]),Y=()=>{F(!1),G("")},Z=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){H(!0);try{yield r.default.post("/edit_conversation_name",{sessionId:f.sessionId,name:X,userId:v}),K(X),F(!1)}catch(e){console.error("Error updating conversation name:",e),alert("Failed to update name.")}finally{H(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:k.secondary,borderRadius:N.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:k.primary,color:k.text}},{children:D?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Z(),"Escape"===e.key&&Y()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:k.primary,borderColor:k.secondary}}),s.jsx("button",Object.assign({onClick:Z,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:"Save"},{children:s.jsx(l.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:Y,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:"Cancel"},{children:s.jsx(l.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),J(!A)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:A?"Collapse":"Expand"},{children:A?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),E(!S)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(l.MoreHorizontal,{className:"h-6 w-6"})})),S&&s.jsxs("div",Object.assign({ref:L,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:k.secondary,color:k.secondaryText,borderColor:k.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),F(!0),E(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:k.primary}},{children:[s.jsx(l.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==w?void 0:w["delete-confirm"])||"Are you sure you want to delete this conversation?")){E(!1);try{yield r.default.post("/delete_pickaxe_conversation",{sessionId:f.sessionId,userId:v}),g&&g(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert("Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:j.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",A?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",A?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!A&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],A&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:V})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!A&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],A&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:W})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==y?void 0:y.chatflag)||!(null==y?void 0:y.chatflag)&&(null==y?void 0:y.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=f.sessionId,R([]),I([]),M(!1),P(s)},title:"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+($?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(W),z(!0),setTimeout((()=>{z(!1)}),2e3)},title:$?"Copied!":"Copy assistant message"},{children:$?s.jsx(u.default,{className:"h-4 w-4",style:{color:k.accent},fill:k.accent}):s.jsx(m.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:U}))]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("date-fns"),r=require("../../../../common/api/pickaxe.js"),l=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),u=require("../../../Icons/copy.svg.js"),m=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),f=require("../../../../common/cn.js");exports.default=({item:g,onDelete:j})=>{const{pickaxe:v,sender:y,colors:k,translations:w,styles:N,isRtl:_,disableCss:C,disableHtml:O,disableJs:q,setSessionId:P,setIsNewChat:M}=n.usePickaxeContext(),{setMessages:I}=a.useResponseContext(),{setDocuments:R}=o.useDocument(),[S,E]=t.useState(!1),[D,F]=t.useState(!1),[T,H]=t.useState(!1),[$,z]=t.useState(!1),[A,J]=t.useState(!1),L=t.useRef(null),[B,K]=t.useState(g.shortSummary||g.summary||(null==w?void 0:w["conversation-name"])||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(g.shortSummary||g.summary||(null==w?void 0:w["conversation-name"])||"Conversation name")}),[g.shortSummary,g.summary,w]),t.useEffect((()=>{const e=e=>{L.current&&!L.current.contains(e.target)&&E(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>g?"FORM"===g.pickaxeType&&0===g.messages.length?g.question.responseParts?g.question.responseParts.length:0:g.messages.length:0),[g]),U=t.useMemo((()=>i.format(new Date(g.updatedAt),"MMM dd, yyy hh:mm a")),[g]),V=t.useMemo((()=>{var e;const s=(null==w?void 0:w["not-available"])||"n/a";if("FORM"===g.pickaxeType){if(g.messages&&0!==g.messages.length){const e=g.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=g.question.inputs)&&void 0!==e?e:[];return A?t.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=g.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[g,A,w]),W=t.useMemo((()=>{if("FORM"===g.pickaxeType){if(g.messages&&0!==g.messages.length){const e=g.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return g.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=g.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[g]),Y=()=>{F(!1),G("")},Z=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){H(!0);try{yield r.default.post("/edit_conversation_name",{sessionId:g.sessionId,name:X,userId:y}),K(X),F(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==w?void 0:w["failed-update-name"])||"Failed to update name.")}finally{H(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:k.secondary,borderRadius:N.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:k.primary,color:k.text}},{children:D?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Z(),"Escape"===e.key&&Y()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:k.primary,borderColor:k.secondary}}),s.jsx("button",Object.assign({onClick:Z,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==w?void 0:w.save)||"Save"},{children:s.jsx(l.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:Y,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==w?void 0:w.cancel)||"Cancel"},{children:s.jsx(l.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),J(!A)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:A?(null==w?void 0:w.collapse)||"Collapse":(null==w?void 0:w.expand)||"Expand"},{children:A?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),E(!S)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(l.MoreHorizontal,{className:"h-6 w-6"})})),S&&s.jsxs("div",Object.assign({ref:L,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:k.secondary,color:k.secondaryText,borderColor:k.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),F(!0),E(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:k.primary}},{children:[s.jsx(l.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==w?void 0:w["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==w?void 0:w["delete-confirm"])||"Are you sure you want to delete this conversation?")){E(!1);try{yield r.default.post("/delete_pickaxe_conversation",{sessionId:g.sessionId,userId:y}),j&&j(g.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==w?void 0:w["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==w?void 0:w["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:f.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",A?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:f.default("w-full",A?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:f.default("w-full",!A&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],A&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:V})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:f.default("w-full text-sm",!A&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],A&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:W})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==v?void 0:v.chatflag)||!(null==v?void 0:v.chatflag)&&(null==v?void 0:v.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=g.sessionId,R([]),I([]),M(!1),P(s)},title:(null==w?void 0:w["open-chat"])||"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+($?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(W),z(!0),setTimeout((()=>{z(!1)}),2e3)},title:$?(null==w?void 0:w.copied)||"Copied!":(null==w?void 0:w["copy-assistant-message"])||"Copy assistant message"},{children:$?s.jsx(m.default,{className:"h-4 w-4",style:{color:k.accent},fill:k.accent}):s.jsx(u.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:U}))]}))]}))]}))};
@@ -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"),i=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),a=require("../../Addons/Document/hooks/useDocument.js"),l=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("date-fns"),d=require("../../common/PickaxeIcon.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeMessageParts/index.js"),m=require("../../common/PickaxeMessageActions.js"),h=require("../../../../common/cn.js");exports.default=()=>{var p;const{pickaxe:f,styles:j,colors:b,misc:g,translations:y,disableHtml:v,disableJs:k,disableCss:w,isRtl:C,setSessionId:q,setIsNewChat:N}=t.usePickaxeContext(),{response:O,isGenerating:M}=o.useResponseContext(),{scrollTargetRef:A}=n.useScrollContext(),{setDocuments:I}=a.useDocument(),{onLoadArtifact:S}=l.useArtifact(),P=i.useStyleFontSize(),D=s.useMemo((()=>O?c.format(O.sentAt,"hh:mm a MMM dd, yy"):c.format(new Date,"hh:mm a MMM dd, yy")),[O]),R=s.useMemo((()=>{var e;if(!O)return"";return(null!==(e=O.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[O]);return O?e.jsxs("div",Object.assign({ref:A,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:b.primary,color:b.text}},{children: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:`${O.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:R.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:R}}),e.jsx("label",Object.assign({htmlFor:`${O.sessionId}-input`,className:h.default(P.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:b.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${O.sessionId}-input`,className:h.default(P.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:b.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:b.secondary,color:b.secondaryText}},{children:[g.isChatImage&&e.jsx(d.default,{src:null==f?void 0:f.chaticon,alt:`${null==f?void 0:f.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:b.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:j.theme,colors:b},C&&{rtl:!0},v&&{disableHtml:!0},k&&{disableJs:!0},w&&{disableCss:!0},{disableReasoning:null!==(p=null==f?void 0:f.enablereasoningdisplay)&&void 0!==p&&p,onArtifactClick:S},{children:e.jsx(x.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:O.question.responseParts})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:h.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:b.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(m.default,{content:O.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:O.sessionId,messagesCount:O.messageCount+1,onOpenChat:()=>{return e=O.sessionId,I([]),N(!1),void q(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:h.default(P.b3,"font-semibold uppercase opacity-30")},{children:D}))}))]}))}))]}))]})),e.jsx(u.default,{})]})):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"),i=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),a=require("../../Addons/Document/hooks/useDocument.js"),l=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("date-fns"),d=require("../../common/PickaxeIcon.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeMessageParts/index.js"),m=require("../../common/PickaxeMessageActions.js"),h=require("../../../../common/cn.js");exports.default=()=>{var p;const{pickaxe:f,styles:j,colors:b,misc:g,translations:v,disableHtml:y,disableJs:k,disableCss:w,isRtl:C,setSessionId:q,setIsNewChat:N}=t.usePickaxeContext(),{response:O,isGenerating:M}=o.useResponseContext(),{scrollTargetRef:A}=n.useScrollContext(),{setDocuments:I}=a.useDocument(),{onLoadArtifact:S}=l.useArtifact(),P=i.useStyleFontSize(),D=s.useMemo((()=>O?c.format(O.sentAt,"hh:mm a MMM dd, yy"):c.format(new Date,"hh:mm a MMM dd, yy")),[O]),R=s.useMemo((()=>{var e;if(!O)return"";const s=(null==v?void 0:v["not-available"])||"n/a";return(null!==(e=O.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||s}</p>\n</div>`)).join("")}),[O,v]);return O?e.jsxs("div",Object.assign({ref:A,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:b.primary,color:b.text}},{children: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:`${O.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:R.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:R}}),e.jsx("label",Object.assign({htmlFor:`${O.sessionId}-input`,className:h.default(P.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:b.accent}},{children:(null==v?void 0:v["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${O.sessionId}-input`,className:h.default(P.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:b.accent}},{children:(null==v?void 0:v["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[g.isChatImage&&e.jsx(d.default,{src:null==f?void 0:f.chaticon,alt:`${null==f?void 0:f.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:b.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:j.theme,colors:b},C&&{rtl:!0},y&&{disableHtml:!0},k&&{disableJs:!0},w&&{disableCss:!0},{disableReasoning:null!==(p=null==f?void 0:f.enablereasoningdisplay)&&void 0!==p&&p,onArtifactClick:S},{children:e.jsx(x.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:O.question.responseParts})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:h.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:b.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(m.default,{content:O.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:O.sessionId,messagesCount:O.messageCount+1,onOpenChat:()=>{return e=O.sessionId,I([]),N(!1),void q(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:h.default(P.b3,"font-semibold uppercase opacity-30")},{children:D}))}))]}))}))]}))]})),e.jsx(u.default,{})]})):null};