@pickaxeproject/react 6.3.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../common/cn.js");const a=({containerClassName:a,className:l,content:o,children:n,strategy:c="absolute",align:i="bottom"})=>{const{colors:u}=r.usePickaxeContext(),[f,x]=t.useState(!1),[d,p]=t.useState({top:0,left:0}),h=t.useRef(null);t.useEffect((()=>{if(f&&"fixed"===c&&h.current){const e=h.current.getBoundingClientRect();let t=0,r=0;switch(i){case"top":t=e.top-8,r=e.left+e.width/2;break;case"bottom":t=e.bottom+8,r=e.left+e.width/2;break;case"left":t=e.top+e.height/2,r=e.left-8;break;case"right":t=e.top+e.height/2,r=e.right+8}p({top:t,left:r})}}),[f,c,i]);return e.jsxs("div",Object.assign({ref:h,className:s.default("relative",a),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1)},{children:[n,f&&e.jsx("div",Object.assign({className:s.default("fixed"===c?`fixed ${(()=>{switch(i){case"top":return"-translate-x-1/2 -translate-y-full";case"bottom":return"-translate-x-1/2";case"left":return"-translate-x-full -translate-y-1/2";case"right":return"-translate-y-1/2"}})()}`:`absolute ${(()=>{switch(i){case"top":return"left-1/2 bottom-full mb-2 -translate-x-1/2";case"bottom":return"left-1/2 top-full mt-2 -translate-x-1/2";case"left":return"right-full top-1/2 mr-2 -translate-y-1/2";case"right":return"left-full top-1/2 ml-2 -translate-y-1/2"}})()}`,"select-none z-[1337] whitespace-nowrap rounded-lg px-3 py-2 text-xs font-semibold shadow-lg",l),style:Object.assign({backgroundColor:u.secondary,color:u.secondaryText},"fixed"===c&&{top:`${d.top}px`,left:`${d.left}px`})},{children:o}))]}))};exports.StudioTip=a,exports.default=a;
@@ -1 +1 @@
1
- "use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t,r=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},n.apply(null,arguments)}var a=e=>r.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),t||(t=r.createElement("path",{fill:"#000",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));exports.default=a;
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t,r=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},n.apply(null,arguments)}var a=e=>r.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),t||(t=r.createElement("path",{fill:"currentColor",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));exports.default=a;
@@ -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"),m=require("uuid"),h=require("../../../hooks/pickaxe/useResponseContext.js"),p=require("../Addons/Navbar/NavPill.js"),x=require("../../Icons/history.svg.js");exports.default=()=>{const{deploymentType:v,isNewChat:j,setIsNewChat:g,sessionId:b,setSessionId:k,setLastSessionId:y,pickaxeId:w,sender:D,pickaxe:I,styles:_,isEmbed:S}=i.usePickaxeContext(),{isSent:q}=o.useAuthContext(),{width:C,height:N,setDimension:P}=r.useDimensionContext(),{setDocuments:F,onFileUpload:A}=n.useDocument(),{isGenerating:E,messages:O}=h.useResponseContext(),T=a.useStyleFontSize(),[R,z]=s.useState(0),[H,G]=s.useState(!1),[L,B]=s.useState(!1),M=s.useRef(null),U=s.useRef(null),J=s.useRef(0),[K,Q]=s.useState(null),[V,W]=s.useState(!1),X="chat-input"===v&&j&&!q;s.useEffect((()=>()=>{F([])}),[]);const Y=s.useCallback((()=>{if(!w||!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:b,userId:D});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void $(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()}),[w,D,b]);s.useEffect((()=>{E||j||!b||Y()}),[E,j,b,Y]),s.useEffect((()=>{if(!M.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;P(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(M.current),()=>{e.disconnect()}}),[M.current]);const[Z,$]=s.useState("New Chat"),ee=(null==I?void 0:I.formtitle)||"Pickaxe",te=(null==I?void 0:I.coverphoto)||void 0,[se,ie]=s.useState(!1);s.useEffect((()=>{const e=!X&&!S&&_.portalTheme&&(O.filter((e=>"user"===e.role)).length>0||H||!j);ie(null!=e&&e)}),[O,H,j]);return t.jsxs("div",Object.assign({ref:M,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),J.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&B(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),J.current-=1,0===J.current&&B(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),B(!1),J.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(g(!1),yield A(e))}))},{children:[L&&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(T.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(T.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),X?t.jsx(u.default,{}):t.jsxs(t.Fragment,{children:[se&&t.jsxs("div",Object.assign({className:d.default("direct-link"===v?"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(p.NavPill,{text:ee,icon:te}),j||"New Chat"===Z?t.jsx(p.NavPill,{text:Z}):t.jsx(p.EditableNavPill,{text:Z,sessionId:b,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b)try{yield f.default.post("/edit_conversation_name",{sessionId:b,name:t,userId:D}),$(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(b&&window.confirm("Are you sure you want to delete this conversation?"))try{yield f.default.post("/delete_pickaxe_conversation",{sessionId:b,userId:D}),g(!0),k(m.v4()),$("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(p.HistoryPill,{icon:t.jsx(x.default,{}),onClick:()=>{k(""),y(b)}})]})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:N<=545||C<=350||H,isInputFocused:H,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){U.current&&U.current.onSubmit(t)})),smitheryAuthData:K,resubmitPrompt:()=>{Q(null),W(!0)}}),t.jsx(u.default,{ref:U,onFocus:()=>G(!0),onBlur:()=>G(!1),onInputHeightChange:z,initSmitheryAuthData:e=>Q(e),resubmitPrompt:V})]})]}))};
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})]})]}))};
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ interface StudioTipProps {
3
+ containerClassName?: string;
4
+ className?: string;
5
+ content: string;
6
+ children: ReactNode;
7
+ strategy?: "absolute" | "fixed";
8
+ align?: "top" | "bottom" | "left" | "right";
9
+ }
10
+ export declare const StudioTip: ({ containerClassName, className, content, children, strategy, align, }: StudioTipProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default StudioTip;
@@ -0,0 +1 @@
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useState as r,useRef as o,useEffect as a}from"react";import{usePickaxeContext as s}from"../../hooks/pickaxe/usePickaxeContext.js";import l from"../../common/cn.js";const n=({containerClassName:n,className:c,content:i,children:f,strategy:u="absolute",align:m="bottom"})=>{const{colors:p}=s(),[d,h]=r(!1),[x,b]=r({top:0,left:0}),g=o(null);a((()=>{if(d&&"fixed"===u&&g.current){const t=g.current.getBoundingClientRect();let e=0,r=0;switch(m){case"top":e=t.top-8,r=t.left+t.width/2;break;case"bottom":e=t.bottom+8,r=t.left+t.width/2;break;case"left":e=t.top+t.height/2,r=t.left-8;break;case"right":e=t.top+t.height/2,r=t.right+8}b({top:e,left:r})}}),[d,u,m]);return t("div",Object.assign({ref:g,className:l("relative",n),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1)},{children:[f,d&&e("div",Object.assign({className:l("fixed"===u?`fixed ${(()=>{switch(m){case"top":return"-translate-x-1/2 -translate-y-full";case"bottom":return"-translate-x-1/2";case"left":return"-translate-x-full -translate-y-1/2";case"right":return"-translate-y-1/2"}})()}`:`absolute ${(()=>{switch(m){case"top":return"left-1/2 bottom-full mb-2 -translate-x-1/2";case"bottom":return"left-1/2 top-full mt-2 -translate-x-1/2";case"left":return"right-full top-1/2 mr-2 -translate-y-1/2";case"right":return"left-full top-1/2 ml-2 -translate-y-1/2"}})()}`,"select-none z-[1337] whitespace-nowrap rounded-lg px-3 py-2 text-xs font-semibold shadow-lg",c),style:Object.assign({backgroundColor:p.secondary,color:p.secondaryText},"fixed"===u&&{top:`${x.top}px`,left:`${x.left}px`})},{children:i}))]}))};export{n as StudioTip,n as default};
@@ -1 +1 @@
1
- import*as a from"react";var t;function r(){return r=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var e in r)({}).hasOwnProperty.call(r,e)&&(a[e]=r[e])}return a},r.apply(null,arguments)}var e=e=>a.createElement("svg",r({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),t||(t=a.createElement("path",{fill:"#000",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));export{e as default};
1
+ import*as a from"react";var r;function t(){return t=Object.assign?Object.assign.bind():function(a){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var e in t)({}).hasOwnProperty.call(t,e)&&(a[e]=t[e])}return a},t.apply(null,arguments)}var e=e=>a.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),r||(r=a.createElement("path",{fill:"currentColor",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));export{e as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import f from"./Input.js";import h from"../../Icons/attach-vertical.svg.js";import v from"../../../common/cn.js";import g from"../../../common/api/pickaxe.js";import{v4 as x}from"uuid";import{useResponseContext as b}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as k,EditableNavPill as j,HistoryPill as y}from"../Addons/Navbar/NavPill.js";import w from"../../Icons/history.svg.js";const I=()=>{const{deploymentType:I,isNewChat:D,setIsNewChat:N,sessionId:C,setSessionId:A,setLastSessionId:F,pickaxeId:P,sender:S,pickaxe:T,styles:O,isEmbed:_}=c(),{isSent:z}=l(),{width:E,height:H,setDimension:R}=d(),{setDocuments:G,onFileUpload:L}=m(),{isGenerating:B,messages:U}=b(),q=u(),[J,K]=r(0),[M,Q]=r(!1),[V,W]=r(!1),X=n(null),Y=n(null),Z=n(0),[$,ee]=r(null),[te,oe]=r(!1),ie="chat-input"===I&&D&&!z;s((()=>()=>{G([])}),[]);const re=a((()=>{if(!P||!S)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield g.post("/get_pickaxe_conversation",{sessionId:C,userId:S});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void se(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()}),[P,S,C]);s((()=>{B||D||!C||re()}),[B,D,C,re]),s((()=>{if(!X.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;R(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(X.current),()=>{e.disconnect()}}),[X.current]);const[ne,se]=r("New Chat"),ae=(null==T?void 0:T.formtitle)||"Pickaxe",ce=(null==T?void 0:T.coverphoto)||void 0,[le,de]=r(!1);s((()=>{const e=!ie&&!_&&O.portalTheme&&(U.filter((e=>"user"===e.role)).length>0||M||!D);de(null!=e&&e)}),[U,M,D]);return t("div",Object.assign({ref:X,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Z.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&W(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),Z.current-=1,0===Z.current&&W(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),W(!1),Z.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(N(!1),yield L(e))}))},{children:[V&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(h,{className:"h-10 w-10"})})),o("h3",Object.assign({className:v(q.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),o("p",Object.assign({className:v(q.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),ie?o(f,{}):t(i,{children:[le&&t("div",Object.assign({className:v("direct-link"===I?"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"===O.portalTheme?"glass-dark ":"")},{children:[o(k,{text:ae,icon:ce}),D||"New Chat"===ne?o(k,{text:ne}):o(j,{text:ne,sessionId:C,onRename:t=>e(void 0,void 0,void 0,(function*(){if(C)try{yield g.post("/edit_conversation_name",{sessionId:C,name:t,userId:S}),se(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(C&&window.confirm("Are you sure you want to delete this conversation?"))try{yield g.post("/delete_pickaxe_conversation",{sessionId:C,userId:S}),N(!0),A(x()),se("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===O.portalTheme}),o(y,{icon:o(w,{}),onClick:()=>{A(""),F(C)}})]})),o(p,{additionalScrollHeight:J,isForceHideInfo:H<=545||E<=350||M,isInputFocused:M,onSubmit:t=>e(void 0,void 0,void 0,(function*(){Y.current&&Y.current.onSubmit(t)})),smitheryAuthData:$,resubmitPrompt:()=>{ee(null),oe(!0)}}),o(f,{ref:Y,onFocus:()=>Q(!0),onBlur:()=>Q(!1),onInputHeightChange:K,initSmitheryAuthData:e=>ee(e),resubmitPrompt:te})]})]}))};export{I as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import f from"./Input.js";import h from"../../Icons/attach-vertical.svg.js";import v from"../../../common/cn.js";import g from"../../../common/api/pickaxe.js";import{v4 as x}from"uuid";import{StudioTip as b}from"../../Core/StudioTip.js";import{useResponseContext as k}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as j,EditableNavPill as y,HistoryPill as w}from"../Addons/Navbar/NavPill.js";import I from"../../Icons/history.svg.js";const D=()=>{const{deploymentType:D,isNewChat:C,setIsNewChat:N,sessionId:A,setSessionId:F,setLastSessionId:S,pickaxeId:T,sender:O,pickaxe:P,styles:_,isEmbed:z,translations:E}=l(),{isSent:H}=c(),{width:R,height:G,setDimension:L}=d(),{setDocuments:B,onFileUpload:U}=m(),{isGenerating:q,messages:J}=k(),K=u(),[M,Q]=r(0),[V,W]=r(!1),[X,Y]=r(!1),Z=n(null),$=n(null),ee=n(0),[te,oe]=r(null),[ie,re]=r(!1),ne="chat-input"===D&&C&&!H;s((()=>()=>{B([])}),[]);const se=a((()=>{if(!T||!O)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield g.post("/get_pickaxe_conversation",{sessionId:A,userId:O});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void le(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()}),[T,O,A]);s((()=>{q||C||!A||se()}),[q,C,A,se]),s((()=>{if(!Z.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;L(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(Z.current),()=>{e.disconnect()}}),[Z.current]);const[ae,le]=r("New Chat"),ce=(null==P?void 0:P.formtitle)||"Pickaxe",de=(null==P?void 0:P.coverphoto)||void 0,[me,ue]=r(!1);s((()=>{const e=!ne&&!z&&_.portalTheme&&(J.filter((e=>"user"===e.role)).length>0||V||!C);ue(null!=e&&e)}),[J,V,C]);return t("div",Object.assign({ref:Z,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ee.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Y(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ee.current-=1,0===ee.current&&Y(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Y(!1),ee.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(N(!1),yield U(e))}))},{children:[X&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(h,{className:"h-10 w-10"})})),o("h3",Object.assign({className:v(K.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),o("p",Object.assign({className:v(K.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),ne?o(f,{}):t(i,{children:[me&&t("div",Object.assign({className:v("direct-link"===D?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[o(j,{text:ce,icon:de}),C||"New Chat"===ae?o(j,{text:ae}):o(y,{text:ae,sessionId:A,onRename:t=>e(void 0,void 0,void 0,(function*(){if(A)try{yield g.post("/edit_conversation_name",{sessionId:A,name:t,userId:O}),le(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(A&&window.confirm("Are you sure you want to delete this conversation?"))try{yield g.post("/delete_pickaxe_conversation",{sessionId:A,userId:O}),N(!0),F(x()),le("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),o(b,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(w,{icon:o(I,{}),onClick:()=>{F(""),S(A)}})}))]})),o(p,{additionalScrollHeight:M,isForceHideInfo:G<=545||R<=350||V,isInputFocused:V,onSubmit:t=>e(void 0,void 0,void 0,(function*(){$.current&&$.current.onSubmit(t)})),smitheryAuthData:te,resubmitPrompt:()=>{oe(null),re(!0)}}),o(f,{ref:$,onFocus:()=>W(!0),onBlur:()=>W(!1),onInputHeightChange:Q,initSmitheryAuthData:e=>oe(e),resubmitPrompt:ie})]})]}))};export{D as default};
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ interface StudioTipProps {
3
+ containerClassName?: string;
4
+ className?: string;
5
+ content: string;
6
+ children: ReactNode;
7
+ strategy?: "absolute" | "fixed";
8
+ align?: "top" | "bottom" | "left" | "right";
9
+ }
10
+ export declare const StudioTip: ({ containerClassName, className, content, children, strategy, align, }: StudioTipProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default StudioTip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",