@pickaxeproject/react 6.23.5 → 6.23.6
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.
- package/dist/cjs/common/embedAuthEvents.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
- package/dist/cjs/src/common/embedAuthEvents.d.ts +26 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
- package/dist/esm/common/embedAuthEvents.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
- package/dist/esm/src/common/embedAuthEvents.d.ts +26 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new Map,t=new Set,o=({deploymentId:e,pickaxeId:t,studioId:o})=>[o,t,e||""].map((e=>encodeURIComponent(e))).join(":"),n=e=>`PXE-pending-auth-${e}`,r=e=>`PXE-emitted-auth-${e}`,d=(e,t)=>{if("undefined"==typeof window)return;const o=`pickaxe:${e.event}`,n=Object.assign(Object.assign({},e),t);window.parent===window?window.dispatchEvent(new CustomEvent(o,{detail:n})):window.parent.postMessage({type:o,detail:n},(()=>{if("undefined"==typeof document||!document.referrer)return"";try{return new URL(document.referrer).origin}catch(e){return""}})()||"*")};exports.emitEmbedLogout=i=>{const a=o(i);e.delete(a),t.clear();try{window.localStorage.removeItem(n(a)),window.localStorage.removeItem(r(a))}catch(e){}d({event:"logout"},i)},exports.emitPendingEmbedAuthOutcome=({token:i,outcome:a,context:c})=>{if("undefined"==typeof window||!a)return;const w=o(c),m=`${w}:${i}`;let s=e.get(w);try{const e=n(w);if(s=window.localStorage.getItem(e)||s,s!==i)return;window.localStorage.removeItem(e),window.localStorage.setItem(r(w),i)}catch(e){}s!==i||t.has(m)||(e.delete(w),t.add(m),d({event:a,method:"email"},c))},exports.rememberPendingEmbedAuth=(t,r)=>{if("undefined"==typeof window)return;const d=o(t);e.set(d,r);try{window.localStorage.setItem(n(d),r)}catch(e){}};
|
|
@@ -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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),o=require("../../../../common/cn.js"),r=require("../../../../common/error.js"),n=require("../../../../common/api/pickaxe.js"),a=require("../../../../common/utils.js"),s=require("../../../Core/ErrorAlert.js"),c=require("../../../../hooks/pickaxe/usePickaxeContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../common/PickaxeButton.js"),u=require("../../common/PickaxeInput.js"),m=require("./hooks/useAuthContext.js"),v=require("../../../../common/embedAuthEvents.js");const f=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]);exports.default=({compact:x=!1})=>{const{deploymentId:h,isEmbed:p,pickaxe:g,translations:j,setSender:k,setSenderType:b}=c.usePickaxeContext(),{setLimitData:y}=d.useResponseContext(),{isPricingAuth:q,setToken:I,setIsPricingAuth:A}=m.useAuthContext(),[C,O]=t.useState(""),[P,S]=t.useState(""),[w,E]=t.useState(!1),T=(null==g?void 0:g.studioid)||"",_=(e,i)=>{var t;return null!==(t=null==j?void 0:j[e])&&void 0!==t?t:i};return i.jsxs("form",Object.assign({className:o.default("flex w-full flex-col items-center gap-2",x&&"max-w-[328px]"),onSubmit:i=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==C.length||w||!T)return;const e=a.getAuthToken(T);if(e){S(""),E(!0);try{const i=yield n.pickaxeApi2.post("/auth/verify",{token:e,code:C});if(!i.data.success)throw new Error(i.data.error||_("verification-code-invalid","Invalid verification code."));a.setAuthToken(`PXE-token-${T}`,e),I(e),k(void 0),b("STUDIO_USER"),p&&v.emitPendingEmbedAuthOutcome({token:e,outcome:i.data.authOutcome,context:{deploymentId:h,pickaxeId:(null==g?void 0:g.formid)||"",studioId:T}}),q&&(A(!1),y(null))}catch(e){const i=r.default(e);S(f.has(i)?_("verification-code-invalid","Invalid verification code."):i||_("verification-code-invalid","Invalid verification code."))}finally{E(!1)}}else S(_("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[i.jsx("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:_("enter-verification-code","Or enter the 6-digit code from the email")})),i.jsxs("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[i.jsx(u.default,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:C,"aria-invalid":!!P,"aria-describedby":P?"email-verification-code-error":void 0,onChange:e=>{O(e.target.value.replace(/\D/g,"").slice(0,6)),S("")}}),i.jsx(l.default,Object.assign({className:o.default("shrink-0",x&&"min-h-[44px]"),loadingText:_("verifying","Verifying..."),isLoading:w,isDisabled:6!==C.length},{children:_("verify","Verify")}))]})),i.jsx("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:i.jsx(s.default,{error:P})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js");exports.useAuth=()=>{const{deploymentId:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js"),n=require("../../../../../common/embedAuthEvents.js");exports.useAuth=()=>{const{deploymentId:d,isEmbed:a,pickaxe:u,translations:l,setValidationStatus:c}=i.usePickaxeContext(),{emailInput:m,redirectUrl:p,isSending:f,setIsSending:h,setIsSent:k,setIsResendDisabled:v,setIsPricingAuth:x}=t.useAuthContext();return{onSend:i=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!u)return;if(f)return;const e=m.trim().toLowerCase();if(!e)throw new Error((null==l?void 0:l["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==l?void 0:l["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!u.studioid)throw new Error(`Studio ID is missing for ${u.formid}. Please contact support.`);h(!0),i&&v(!0);const t=(yield r.pickaxeApi2.post("/auth/email",Object.assign(Object.assign({pickaxeId:u.formid,studioId:u.studioid,email:e},d&&{deploymentId:d}),{redirectUrl:p}))).data;if(!t.success)throw new Error(t.error||(null==l?void 0:l["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");h(!1),k(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),s.setAuthToken(`PXE-token-${u.studioid}`,t.token),a&&n.rememberPendingEmbedAuth({deploymentId:d,pickaxeId:u.formid,studioId:u.studioid},t.token),x(!0)}catch(e){const i=o.default(e);if(a&&"You must be invited to use this tool"===i)return void c("access_denied");alert(i)}finally{h(!1)}}))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),u=require("./useAuthVerify.js"),n=require("../../../../../common/embedSession.js"),r=require("../../../../../common/embedAuthEvents.js");exports.useAuthBootstrap=()=>{const{deploymentId:d,isEmbed:c,pickaxe:a,setSender:l,setSenderType:m}=t.usePickaxeContext(),{setLimitData:k}=s.useResponseContext(),{token:h,isLoggedOut:p,isPricingAuth:f,setToken:g,setIsLoggingIn:x,setIsPricingAuth:A,setIsAuthBootstrapComplete:I}=i.useAuthContext(),v=(null==a?void 0:a.studioid)||"",E=v?`PXE-token-${v}`:"",b=o.getAuthToken(v)||"",j=u.useAuthVerify({token:b,enabled:p&&!!b,setIsLoggingIn:x});e.useEffect((()=>{v&&I(!1)}),[I,v]);const q=e.useCallback((e=>{o.setAuthToken(E,e),g(e),l(void 0),m("STUDIO_USER"),f&&(A(!1),k(null))}),[E,f,A,k,l,m,g]);e.useEffect((()=>{if(!E)return;if(!j.data)return;const{success:e,token:t,authOutcome:s,error:i}=j.data;if(!e||i)return d&&(null==a?void 0:a.formid)&&b&&n.clearAuthenticatedEmbedSession({deploymentId:d,pickaxeId:a.formid,authToken:b}),o.deleteAuthToken(E),A(!1),void I(!0);t&&(q(t),c&&r.emitPendingEmbedAuthOutcome({token:t,outcome:s,context:{deploymentId:d,pickaxeId:(null==a?void 0:a.formid)||"",studioId:v}}),I(!0))}),[q,E,j.data,d,c,null==a?void 0:a.formid,I,A,b,v]),e.useEffect((()=>{var e;v&&(h?I(!0):b?j.isLoading||j.isFetching||(j.isError||j.isSuccess&&!(null===(e=j.data)||void 0===e?void 0:e.token))&&I(!0):I(!0))}),[j.data,j.isError,j.isFetching,j.isLoading,j.isSuccess,I,b,v,h])};
|
|
@@ -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"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=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"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:
|
|
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"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=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"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:T,sender:P,pickaxe:A,styles:O,isEmbed:_,mcpEnabled:F,translations:E}=s.usePickaxeContext(),{isSent:R,token:H}=i.useAuthContext(),{width:z,height:B,setDimension:L}=n.useDimensionContext(),{setDocuments:M,onFileUpload:G}=r.useDocument(),{scrollContainerRef:V,hasScrolledRef:U,isLocked:W,setIsLocked:J}=a.useScrollContext(),{isGenerating:K,messages:Q}=g.useResponseContext(),X=l.useStyleFontSize(),[Y,Z]=o.useState(0),[$,ee]=o.useState(!1),[te,oe]=o.useState(!1),se=o.useRef(null),ie=o.useRef(null),ne=o.useRef(0),[re,ae]=o.useState(null),[le,ue]=o.useState(!1),ce=(null==E?void 0:E["new-chat"])||"New chat",de="chat-input"===w&&C&&!R,fe=null!==(S=null===(y=null==A?void 0:A.documentuploadtype)||void 0===y?void 0:y.startsWith("enduserupload"))&&void 0!==S&&S,{hasScrollableContent:he,isNearBottom:me}=u.default(V);o.useEffect((()=>()=>{M([])}),[]);const pe=o.useCallback((()=>{if(!T||!P&&!H)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.pickaxeApi2.post("/conversation/title",Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ve(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,P,I,H]);o.useEffect((()=>{K||C||!I||pe()}),[K,C,I,pe]),o.useEffect((()=>{if(!se.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(se.current),()=>{e.disconnect()}}),[L]);const[xe,ve]=o.useState(ce),je=(null==A?void 0:A.formtitle)||"Pickaxe",ge=(null==A?void 0:A.coverphoto)||void 0,[be,ke]=o.useState(!1);o.useEffect((()=>{const e=!de&&!_&&O.portalTheme&&(Q.filter((e=>"user"===e.role)).length>0||$||!C);ke(null!=e&&e)}),[de,_,$,C,Q,O.portalTheme]);const ye=o.useCallback((()=>{U.current=!1,J(!0),requestAnimationFrame((()=>{const e=V.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[U,V,J]);return t.jsxs("div",Object.assign({ref:se,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&oe(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current-=1,0===ne.current&&oe(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),oe(!1),ne.current=0,!fe)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(q(!1),yield G(e))}))},{children:[te&&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(f.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:h.default(X.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(X.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!_&&F?t.jsx("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(j.default,{})}))})):null,de?t.jsx(d.default,{}):t.jsxs(t.Fragment,{children:[be&&t.jsxs("div",Object.assign({className:h.default("direct-link"===w?"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:[t.jsx(b.NavPill,{text:je,icon:ge}),C||xe===ce?t.jsx(b.NavPill,{text:xe}):t.jsx(b.EditableNavPill,{text:xe,sessionId:I,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I)try{yield m.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:I,name:t},H?{studioSessionToken:H}:P?{userId:P}:{})),ve(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(I&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{})}),q(!0),D(p.v4()),ve(ce)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===O.portalTheme}),t.jsx(x.StudioTip,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(b.HistoryPill,{icon:t.jsx(k.default,{}),onClick:()=>{D(""),N(I)}})}))]})),t.jsx(c.default,{additionalScrollHeight:Y,isForceHideInfo:B<=545||z<=350||$,isInputFocused:$,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ie.current&&ie.current.onSubmit(t)})),smitheryAuthData:re,resubmitPrompt:()=>{ae(null),ue(!0)}}),t.jsx(v.default,{isVisible:he&&!W&&!me,bottom:Y+65,onClick:ye}),t.jsx(d.default,{ref:ie,onFocus:()=>ee(!0),onBlur:()=>ee(!1),onInputHeightChange:Z,initSmitheryAuthData:e=>ae(e),resubmitPrompt:le})]})]}))};
|
|
@@ -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"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),
|
|
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("../../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),c=require("lucide-react"),d=require("../../../Icons/trash-2.svg.js"),u=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),p=require("../../../Icons/copied.svg.js"),x=require("../../../Icons/expand.svg.js"),h=require("../../../Icons/collapse.svg.js"),v=require("../../common/PickaxeMarkdown/index.js"),g=require("../../common/PickaxeMarkdown/Renderer.js"),b=require("../../common/PickaxeMessageParts/index.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:y})=>{const{pickaxe:k,sender:w,colors:N,translations:C,styles:O,isRtl:_,disableCss:q,disableHtml:P,disableJs:M,setSessionId:I,setIsNewChat:R}=n.usePickaxeContext(),{token:S}=i.useAuthContext(),{setMessages:T}=a.useResponseContext(),{setDocuments:A}=o.useDocument(),[E,D]=t.useState(!1),[F,H]=t.useState(!1),[$,z]=t.useState(!1),[J,L]=t.useState(!1),[U,B]=t.useState(!1),K=t.useRef(null),[X,G]=t.useState(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name"),[Q,V]=t.useState("");t.useEffect((()=>{G(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name")}),[f.shortSummary,f.summary,C]),t.useEffect((()=>{const e=e=>{K.current&&!K.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const W=t.useMemo((()=>f?"FORM"===f.pickaxeType?f.question?0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0:f.messages.length:0),[f]),Y=l.formatLocalDateTime(f.updatedAt,"MMM dd, yyyy hh:mm a"),Z=t.useMemo((()=>{var e,s;const t=(null==C?void 0:C["not-available"])||"n/a";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 n=null!==(s=null===(e=f.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return U?n.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||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=f.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[f,U,C]),ee=t.useMemo((()=>{var e,s,t,n,a,o;return"FORM"===f.pickaxeType?f.messages&&0!==f.messages.length?null!==(s=null===(e=f.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=f.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(o=null===(a=f.messages.find((e=>"assistant"===e.role)))||void 0===a?void 0:a.parts)&&void 0!==o?o:[]}),[f]),se=t.useMemo((()=>ee.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[ee]),te=t.useMemo((()=>b.getSuppressedRichPreviewUrls(ee)),[ee]),ne=()=>{H(!1),V("")},ae=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(Q.trim()){z(!0);try{yield r.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:f.sessionId,name:Q},S?{studioSessionToken:S}:w?{userId:w}:{})),G(Q),H(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==C?void 0:C["failed-update-name"])||"Failed to update name.")}finally{z(!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:N.secondary,borderRadius:O.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:N.primary,color:N.text}},{children:F?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:Q,onChange:e=>V(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ae(),"Escape"===e.key&&ne()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:N.primary,borderColor:N.secondary}}),s.jsx("button",Object.assign({onClick:ae,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.save)||"Save"},{children:s.jsx(c.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:ne,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.cancel)||"Cancel"},{children:s.jsx(c.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:X})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),B(!U)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:U?(null==C?void 0:C.collapse)||"Collapse":(null==C?void 0:C.expand)||"Expand"},{children:U?s.jsx(h.default,{className:"h-4 w-4"}):s.jsx(x.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),D(!E)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(c.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:K,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:N.secondary,color:N.secondaryText,borderColor:N.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),V(X),H(!0),D(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:N.primary}},{children:[s.jsx(c.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["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==C?void 0:C["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield r.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:f.sessionId},S?{studioSessionToken:S}:w?{userId:w}:{})}),y&&y(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==C?void 0:C["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(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["delete-chat"])||"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",U?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:N.secondary,color:N.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",U?"mb-0":"mb-2")},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!U&&["[&_*]:!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"],U&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:Z})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!U&&["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"],U&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:se,suppressedRichPreviewUrls:te})}))}))]})),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==k?void 0:k.chatflag)||!(null==k?void 0:k.chatflag)&&(null==k?void 0:k.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,A([]),T([]),R(!1),I(s)},title:(null==C?void 0:C["open-chat"])||"Open Chat"},{children:[s.jsx(u.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:W}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(J?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(se),L(!0),setTimeout((()=>{L(!1)}),2e3)},title:J?(null==C?void 0:C.copied)||"Copied!":(null==C?void 0:C["copy-assistant-message"])||"Copy assistant message"},{children:J?s.jsx(p.default,{className:"h-4 w-4",style:{color:N.accent},fill:N.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:Y}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../hooks/core/useHover.js"),s=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("framer-motion"),n=require("../../../common/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../hooks/core/useHover.js"),s=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("framer-motion"),n=require("../../../common/utils.js"),d=require("../../../common/embedSession.js"),a=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../../Icons/logout.svg.js"),c=require("./PickaxeSimpleButton.js"),l=require("../../../common/embedAuthEvents.js");exports.default=({tip:m})=>{const{colors:x,styles:j,pickaxe:k,deploymentId:v,isEmbed:h}=i.usePickaxeContext(),{token:p}=a.useAuthContext(),b=o.useHover(),{isHover:g}=b,y=e.__rest(b,["isHover"]),f=s.usePressed(),{isActive:q}=f,I=e.__rest(f,["isActive"]);return t.jsxs("div",Object.assign({className:"relative"},{children:[t.jsx(c.default,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:x.accent,style:{backgroundColor:q?x.accent+"30":g?x.accent+"10":void 0},onClick:()=>{p&&v&&(null==k?void 0:k.formid)&&d.clearAuthenticatedEmbedSession({deploymentId:v,pickaxeId:k.formid,authToken:p});const e=`PXE-token-${null==k?void 0:k.studioid}`;localStorage.getItem(e)?localStorage.removeItem(`PXE-token-${null==k?void 0:k.studioid}`):n.deleteCookie(e),h&&(null==k?void 0:k.studioid)&&k.formid&&l.emitEmbedLogout({deploymentId:v,pickaxeId:k.formid,studioId:k.studioid}),location.reload()},reversed:!0},y,I,{children:t.jsx(u.default,{className:"h-5 w-5 shrink-0"})})),t.jsx(r.AnimatePresence,{children:g&&!!m&&t.jsx(r.motion.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:x.accent,color:x.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:j.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:m}))})]}))};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type EmbedAuthOutcome = "signup" | "login";
|
|
2
|
+
export type EmbedAuthMethod = "email" | "sso";
|
|
3
|
+
export type EmbedAuthEvent = {
|
|
4
|
+
event: EmbedAuthOutcome;
|
|
5
|
+
method: EmbedAuthMethod;
|
|
6
|
+
} | {
|
|
7
|
+
event: "logout";
|
|
8
|
+
};
|
|
9
|
+
type EmbedAuthEventContext = {
|
|
10
|
+
deploymentId?: string;
|
|
11
|
+
pickaxeId: string;
|
|
12
|
+
studioId: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const rememberPendingEmbedAuth: (context: EmbedAuthEventContext, token: string) => void;
|
|
15
|
+
export declare const emitPendingEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
16
|
+
token: string;
|
|
17
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
18
|
+
context: EmbedAuthEventContext;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare const emitSsoEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
21
|
+
token: string;
|
|
22
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
23
|
+
context: EmbedAuthEventContext;
|
|
24
|
+
}) => void;
|
|
25
|
+
export declare const emitEmbedLogout: (context: EmbedAuthEventContext) => void;
|
|
26
|
+
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SetState } from "../../../../../types/common";
|
|
2
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import type { EmbedAuthOutcome } from "../../../../../common/embedAuthEvents";
|
|
3
4
|
type QueryResponse = {
|
|
4
5
|
success: boolean;
|
|
5
6
|
token: string;
|
|
7
|
+
authOutcome?: EmbedAuthOutcome;
|
|
6
8
|
error?: string;
|
|
7
9
|
};
|
|
8
10
|
interface UseAuthVerifyQueryProps {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map,t=new Set,n=({deploymentId:e,pickaxeId:t,studioId:n})=>[n,t,e||""].map((e=>encodeURIComponent(e))).join(":"),o=e=>`PXE-pending-auth-${e}`,d=e=>`PXE-emitted-auth-${e}`,r=(e,t)=>{if("undefined"==typeof window)return;const n=`pickaxe:${e.event}`,o=Object.assign(Object.assign({},e),t);window.parent===window?window.dispatchEvent(new CustomEvent(n,{detail:o})):window.parent.postMessage({type:n,detail:o},(()=>{if("undefined"==typeof document||!document.referrer)return"";try{return new URL(document.referrer).origin}catch(e){return""}})()||"*")},i=(t,d)=>{if("undefined"==typeof window)return;const r=n(t);e.set(r,d);try{window.localStorage.setItem(o(r),d)}catch(e){}},a=({token:i,outcome:a,context:c})=>{if("undefined"==typeof window||!a)return;const w=n(c),l=`${w}:${i}`;let m=e.get(w);try{const e=o(w);if(m=window.localStorage.getItem(e)||m,m!==i)return;window.localStorage.removeItem(e),window.localStorage.setItem(d(w),i)}catch(e){}m!==i||t.has(l)||(e.delete(w),t.add(l),r({event:a,method:"email"},c))},c=i=>{const a=n(i);e.delete(a),t.clear();try{window.localStorage.removeItem(o(a)),window.localStorage.removeItem(d(a))}catch(e){}r({event:"logout"},i)};export{c as emitEmbedLogout,a as emitPendingEmbedAuthOutcome,i as rememberPendingEmbedAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import r from"../../../../common/cn.js";import n from"../../../../common/error.js";import{pickaxeApi2 as a}from"../../../../common/api/pickaxe.js";import{getAuthToken as c,setAuthToken as s}from"../../../../common/utils.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import r from"../../../../common/cn.js";import n from"../../../../common/error.js";import{pickaxeApi2 as a}from"../../../../common/api/pickaxe.js";import{getAuthToken as c,setAuthToken as s}from"../../../../common/utils.js";import m from"../../../Core/ErrorAlert.js";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../../hooks/pickaxe/useResponseContext.js";import f from"../../common/PickaxeButton.js";import u from"../../common/PickaxeInput.js";import{useAuthContext as v}from"./hooks/useAuthContext.js";import{emitPendingEmbedAuthOutcome as p}from"../../../../common/embedAuthEvents.js";const h=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]),x=({compact:x=!1})=>{const{deploymentId:g,isEmbed:k,pickaxe:j,translations:y,setSender:b,setSenderType:I}=l(),{setLimitData:O}=d(),{isPricingAuth:w,setToken:C,setIsPricingAuth:P}=v(),[E,S]=t(""),[A,D]=t(""),[N,T]=t(!1),L=(null==j?void 0:j.studioid)||"",Y=(e,i)=>{var o;return null!==(o=null==y?void 0:y[e])&&void 0!==o?o:i};return i("form",Object.assign({className:r("flex w-full flex-col items-center gap-2",x&&"max-w-[328px]"),onSubmit:i=>e(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==E.length||N||!L)return;const e=c(L);if(e){D(""),T(!0);try{const i=yield a.post("/auth/verify",{token:e,code:E});if(!i.data.success)throw new Error(i.data.error||Y("verification-code-invalid","Invalid verification code."));s(`PXE-token-${L}`,e),C(e),b(void 0),I("STUDIO_USER"),k&&p({token:e,outcome:i.data.authOutcome,context:{deploymentId:g,pickaxeId:(null==j?void 0:j.formid)||"",studioId:L}}),w&&(P(!1),O(null))}catch(e){const i=n(e);D(h.has(i)?Y("verification-code-invalid","Invalid verification code."):i||Y("verification-code-invalid","Invalid verification code."))}finally{T(!1)}}else D(Y("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[o("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:Y("enter-verification-code","Or enter the 6-digit code from the email")})),i("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[o(u,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:E,"aria-invalid":!!A,"aria-describedby":A?"email-verification-code-error":void 0,onChange:e=>{S(e.target.value.replace(/\D/g,"").slice(0,6)),D("")}}),o(f,Object.assign({className:r("shrink-0",x&&"min-h-[44px]"),loadingText:Y("verifying","Verifying..."),isLoading:N,isDisabled:6!==E.length},{children:Y("verify","Verify")}))]})),o("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:o(m,{error:A})}))]}))};export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as t}from"./useAuthContext.js";import{setAuthToken as o}from"../../../../../common/utils.js";import{pickaxeApi2 as s}from"../../../../../common/api/pickaxe.js";import r from"../../../../../common/error.js";const
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as t}from"./useAuthContext.js";import{setAuthToken as o}from"../../../../../common/utils.js";import{pickaxeApi2 as s}from"../../../../../common/api/pickaxe.js";import r from"../../../../../common/error.js";import{rememberPendingEmbedAuth as n}from"../../../../../common/embedAuthEvents.js";const d=()=>{const{deploymentId:d,isEmbed:a,pickaxe:m,translations:l,setValidationStatus:c}=i(),{emailInput:u,redirectUrl:p,isSending:f,setIsSending:I,setIsSent:k,setIsResendDisabled:v,setIsPricingAuth:h}=t();return{onSend:i=>e(void 0,void 0,void 0,(function*(){try{if(!m)return;if(f)return;const e=u.trim().toLowerCase();if(!e)throw new Error((null==l?void 0:l["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==l?void 0:l["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!m.studioid)throw new Error(`Studio ID is missing for ${m.formid}. Please contact support.`);I(!0),i&&v(!0);const t=(yield s.post("/auth/email",Object.assign(Object.assign({pickaxeId:m.formid,studioId:m.studioid,email:e},d&&{deploymentId:d}),{redirectUrl:p}))).data;if(!t.success)throw new Error(t.error||(null==l?void 0:l["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");I(!1),k(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),o(`PXE-token-${m.studioid}`,t.token),a&&n({deploymentId:d,pickaxeId:m.formid,studioId:m.studioid},t.token),h(!0)}catch(e){const i=r(e);if(a&&"You must be invited to use this tool"===i)return void c("access_denied");alert(i)}finally{I(!1)}}))}};export{d as useAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as o,useCallback as e}from"react";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../../hooks/pickaxe/useResponseContext.js";import{getAuthToken as s,setAuthToken as n,deleteAuthToken as r}from"../../../../../common/utils.js";import{useAuthContext as d}from"./useAuthContext.js";import{useAuthVerify as m}from"./useAuthVerify.js";import{clearAuthenticatedEmbedSession as
|
|
1
|
+
import{useEffect as o,useCallback as e}from"react";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../../hooks/pickaxe/useResponseContext.js";import{getAuthToken as s,setAuthToken as n,deleteAuthToken as r}from"../../../../../common/utils.js";import{useAuthContext as d}from"./useAuthContext.js";import{useAuthVerify as m}from"./useAuthVerify.js";import{clearAuthenticatedEmbedSession as u}from"../../../../../common/embedSession.js";import{emitPendingEmbedAuthOutcome as c}from"../../../../../common/embedAuthEvents.js";const a=()=>{const{deploymentId:a,isEmbed:p,pickaxe:l,setSender:f,setSenderType:k}=t(),{setLimitData:g}=i(),{token:I,isLoggedOut:h,isPricingAuth:x,setToken:v,setIsLoggingIn:j,setIsPricingAuth:S,setIsAuthBootstrapComplete:A}=d(),E=(null==l?void 0:l.studioid)||"",L=E?`PXE-token-${E}`:"",y=s(E)||"",b=m({token:y,enabled:h&&!!y,setIsLoggingIn:j});o((()=>{E&&A(!1)}),[A,E]);const C=e((o=>{n(L,o),v(o),f(void 0),k("STUDIO_USER"),x&&(S(!1),g(null))}),[L,x,S,g,f,k,v]);o((()=>{if(!L)return;if(!b.data)return;const{success:o,token:e,authOutcome:t,error:i}=b.data;if(!o||i)return a&&(null==l?void 0:l.formid)&&y&&u({deploymentId:a,pickaxeId:l.formid,authToken:y}),r(L),S(!1),void A(!0);e&&(C(e),p&&c({token:e,outcome:t,context:{deploymentId:a,pickaxeId:(null==l?void 0:l.formid)||"",studioId:E}}),A(!0))}),[C,L,b.data,a,p,null==l?void 0:l.formid,A,S,y,E]),o((()=>{var o;E&&(I?A(!0):y?b.isLoading||b.isFetching||(b.isError||b.isSuccess&&!(null===(o=b.data)||void 0===o?void 0:o.token))&&A(!0):A(!0))}),[b.data,b.isError,b.isFetching,b.isLoading,b.isSuccess,A,y,E,I])};export{a as useAuthBootstrap};
|
|
@@ -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 n,useRef as
|
|
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 n,useRef as s,useEffect as r,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{useScrollContext as u}from"../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import f from"../../../hooks/core/useScrollToBottomVisibility.js";import h from"./History/index.js";import v from"./Input.js";import g from"../../Icons/attach-vertical.svg.js";import x from"../../../common/cn.js";import{pickaxeApi2 as b}from"../../../common/api/pickaxe.js";import{v4 as j}from"uuid";import{StudioTip as k}from"../../Core/StudioTip.js";import y from"../common/ScrollToBottomButton.js";import w from"../common/PickaxeMCPButton.js";import{useResponseContext as I}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as S,EditableNavPill as D,HistoryPill as C}from"../Addons/Navbar/NavPill.js";import T from"../../Icons/history.svg.js";const N=()=>{var N,O;const{deploymentType:A,isNewChat:F,setIsNewChat:P,sessionId:H,setSessionId:z,setLastSessionId:B,pickaxeId:E,sender:R,pickaxe:L,styles:G,isEmbed:M,mcpEnabled:V,translations:_}=l(),{isSent:q,token:U}=c(),{width:W,height:J,setDimension:K}=d(),{setDocuments:Q,onFileUpload:X}=m(),{scrollContainerRef:Y,hasScrolledRef:Z,isLocked:$,setIsLocked:ee}=u(),{isGenerating:te,messages:oe}=I(),ie=p(),[ne,se]=n(0),[re,ae]=n(!1),[le,ce]=n(!1),de=s(null),me=s(null),ue=s(0),[pe,fe]=n(null),[he,ve]=n(!1),ge=(null==_?void 0:_["new-chat"])||"New chat",xe="chat-input"===A&&F&&!q,be=null!==(O=null===(N=null==L?void 0:L.documentuploadtype)||void 0===N?void 0:N.startsWith("enduserupload"))&&void 0!==O&&O,{hasScrollableContent:je,isNearBottom:ke}=f(Y);r((()=>()=>{Q([])}),[]);const ye=a((()=>{if(!E||!R&&!U)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield b.post("/conversation/title",Object.assign({sessionId:H},U?{studioSessionToken:U}:R?{userId:R}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void Ie(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()}),[E,R,H,U]);r((()=>{te||F||!H||ye()}),[te,F,H,ye]),r((()=>{if(!de.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;K(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(de.current),()=>{e.disconnect()}}),[K]);const[we,Ie]=n(ge),Se=(null==L?void 0:L.formtitle)||"Pickaxe",De=(null==L?void 0:L.coverphoto)||void 0,[Ce,Te]=n(!1);r((()=>{const e=!xe&&!M&&G.portalTheme&&(oe.filter((e=>"user"===e.role)).length>0||re||!F);Te(null!=e&&e)}),[xe,M,re,F,oe,G.portalTheme]);const Ne=a((()=>{Z.current=!1,ee(!0),requestAnimationFrame((()=>{const e=Y.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[Z,Y,ee]);return t("div",Object.assign({ref:de,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),be&&(ue.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&ce(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),be&&(ue.current-=1,0===ue.current&&ce(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),ce(!1),ue.current=0,!be)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(P(!1),yield X(e))}))},{children:[le&&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(g,{className:"h-10 w-10"})})),o("h3",Object.assign({className:x(ie.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==_?void 0:_["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:x(ie.b2,"mt-2 opacity-60 text-black")},{children:(null==_?void 0:_["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!M&&V?o("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:o("div",Object.assign({className:"pointer-events-auto"},{children:o(w,{})}))})):null,xe?o(v,{}):t(i,{children:[Ce&&t("div",Object.assign({className:x("direct-link"===A?"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"===G.portalTheme?"glass-dark ":"")},{children:[o(S,{text:Se,icon:De}),F||we===ge?o(S,{text:we}):o(D,{text:we,sessionId:H,onRename:t=>e(void 0,void 0,void 0,(function*(){if(H)try{yield b.patch("/conversation/title",Object.assign({sessionId:H,name:t},U?{studioSessionToken:U}:R?{userId:R}:{})),Ie(t)}catch(e){console.error("Error renaming chat:",e),alert((null==_?void 0:_["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(H&&window.confirm((null==_?void 0:_["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield b.delete("/conversation",{data:Object.assign({sessionId:H},U?{studioSessionToken:U}:R?{userId:R}:{})}),P(!0),z(j()),Ie(ge)}catch(e){console.error("Error deleting chat:",e),alert((null==_?void 0:_["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===G.portalTheme}),o(k,Object.assign({content:_["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(C,{icon:o(T,{}),onClick:()=>{z(""),B(H)}})}))]})),o(h,{additionalScrollHeight:ne,isForceHideInfo:J<=545||W<=350||re,isInputFocused:re,onSubmit:t=>e(void 0,void 0,void 0,(function*(){me.current&&me.current.onSubmit(t)})),smitheryAuthData:pe,resubmitPrompt:()=>{fe(null),ve(!0)}}),o(y,{isVisible:je&&!$&&!ke,bottom:ne+65,onClick:Ne}),o(v,{ref:me,onFocus:()=>ae(!0),onBlur:()=>ae(!1),onInputHeightChange:se,initSmitheryAuthData:e=>fe(e),resubmitPrompt:he})]})]}))};export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as o,Fragment as t}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as l}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as o,Fragment as t}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as l}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useAuthContext as m}from"../../Addons/Auth/hooks/useAuthContext.js";import{pickaxeApi2 as p}from"../../../../common/api/pickaxe.js";import{formatLocalDateTime as u}from"../../../../common/date.js";import{Check as h,X as b,MoreHorizontal as g,Pencil as v}from"lucide-react";import f from"../../../Icons/trash-2.svg.js";import y from"../../../Icons/chat.svg.js";import x from"../../../Icons/copy.svg.js";import j from"../../../Icons/copied.svg.js";import k from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as N}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as O}from"../../common/PickaxeMarkdown/Renderer.js";import{getSuppressedRichPreviewUrls as C}from"../../common/PickaxeMessageParts/index.js";import _ from"../../../../common/cn.js";const I=({item:I,onDelete:P})=>{const{pickaxe:M,sender:R,colors:T,translations:q,styles:E,isRtl:S,disableCss:A,disableHtml:D,disableJs:F,setSessionId:$,setIsNewChat:H}=r(),{token:J}=m(),{setMessages:z}=c(),{setDocuments:L}=d(),[B,K]=n(!1),[U,G]=n(!1),[Q,V]=n(!1),[W,X]=n(!1),[Y,Z]=n(!1),ee=a(null),[se,oe]=n(I.shortSummary||I.summary||(null==q?void 0:q["conversation-name"])||"Conversation name"),[te,ne]=n("");i((()=>{oe(I.shortSummary||I.summary||(null==q?void 0:q["conversation-name"])||"Conversation name")}),[I.shortSummary,I.summary,q]),i((()=>{const e=e=>{ee.current&&!ee.current.contains(e.target)&&K(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const ae=l((()=>I?"FORM"===I.pickaxeType?I.question?0===I.messages.length?I.question.responseParts?I.question.responseParts.length:0:I.messages.length:0:I.messages.length:0),[I]),ie=u(I.updatedAt,"MMM dd, yyyy hh:mm a"),le=l((()=>{var e,s;const o=(null==q?void 0:q["not-available"])||"n/a";if("FORM"===I.pickaxeType){if(I.messages&&0!==I.messages.length){const e=I.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(s=null===(e=I.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return Y?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||o}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||o}`)).join(" | ")}const t=I.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[I,Y,q]),re=l((()=>{var e,s,o,t,n,a;return"FORM"===I.pickaxeType?I.messages&&0!==I.messages.length?null!==(s=null===(e=I.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(t=null===(o=I.question)||void 0===o?void 0:o.responseParts)&&void 0!==t?t:[]:null!==(a=null===(n=I.messages.find((e=>"assistant"===e.role)))||void 0===n?void 0:n.parts)&&void 0!==a?a:[]}),[I]),ce=l((()=>re.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[re]),de=l((()=>C(re)),[re]),me=()=>{G(!1),ne("")},pe=()=>e(void 0,void 0,void 0,(function*(){if(te.trim()){V(!0);try{yield p.patch("/conversation/title",Object.assign({sessionId:I.sessionId,name:te},J?{studioSessionToken:J}:R?{userId:R}:{})),oe(te),G(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==q?void 0:q["failed-update-name"])||"Failed to update name.")}finally{V(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:T.secondary,borderRadius:E.cornerRadius}},{children:[o("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:T.primary,color:T.text}},{children:U?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[o("input",{autoFocus:!0,type:"text",value:te,onChange:e=>ne(e.target.value),onKeyDown:e=>{"Enter"===e.key&&pe(),"Escape"===e.key&&me()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:T.primary,borderColor:T.secondary}}),o("button",Object.assign({onClick:pe,disabled:Q,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==q?void 0:q.save)||"Save"},{children:o(h,{className:"h-4 w-4"})})),o("button",Object.assign({onClick:me,disabled:Q,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==q?void 0:q.cancel)||"Cancel"},{children:o(b,{className:"h-4 w-4"})}))]})):s(t,{children:[o("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:se})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),Z(!Y)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:Y?(null==q?void 0:q.collapse)||"Collapse":(null==q?void 0:q.expand)||"Expand"},{children:o(Y?w:k,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),K(!B)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:o(g,{className:"h-6 w-6"})})),B&&s("div",Object.assign({ref:ee,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:T.secondary,color:T.secondaryText,borderColor:T.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),ne(se),G(!0),K(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:T.primary}},{children:[o(v,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==q?void 0:q["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==q?void 0:q["delete-confirm"])||"Are you sure you want to delete this conversation?")){K(!1);try{yield p.delete("/conversation",{data:Object.assign({sessionId:I.sessionId},J?{studioSessionToken:J}:R?{userId:R}:{})}),P&&P(I.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==q?void 0:q["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:[o(f,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==q?void 0:q["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:_("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",Y?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:T.secondary,color:T.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[o("div",Object.assign({className:_("w-full",Y?"mb-0":"mb-2")},{children:o(N,Object.assign({theme:E.theme,colors:T},S&&{rtl:!0},D&&{disableHtml:!0},F&&{disableJs:!0},A&&{disableCss:!0},{children:o(O,{style:{display:"block"},className:_("w-full",!Y&&["[&_*]:!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"],Y&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:le})}))})),o("div",Object.assign({className:"w-full"},{children:o(N,Object.assign({theme:E.theme,colors:T},S&&{rtl:!0},D&&{disableHtml:!0},F&&{disableJs:!0},A&&{disableCss:!0},{children:o(O,{style:{display:"block"},className:_("w-full text-sm",!Y&&["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"],Y&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ce,suppressedRichPreviewUrls:de})}))}))]})),s("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==M?void 0:M.chatflag)||!(null==M?void 0:M.chatflag)&&(null==M?void 0:M.enablechatresponses))&&s("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=I.sessionId,L([]),z([]),H(!1),$(s)},title:(null==q?void 0:q["open-chat"])||"Open Chat"},{children:[o(y,{className:"h-4 w-4"}),o("span",Object.assign({className:"text-sm font-medium"},{children:ae}))]})),o("button",Object.assign({className:"transition-colors "+(W?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ce),X(!0),setTimeout((()=>{X(!1)}),2e3)},title:W?(null==q?void 0:q.copied)||"Copied!":(null==q?void 0:q["copy-assistant-message"])||"Copy assistant message"},{children:W?o(j,{className:"h-4 w-4",style:{color:T.accent},fill:T.accent}):o(x,{className:"h-4 w-4"})}))]})),o("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:ie}))]}))]}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useHover as i}from"../../../hooks/core/useHover.js";import{usePressed as
|
|
1
|
+
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useHover as i}from"../../../hooks/core/useHover.js";import{usePressed as s}from"../../../hooks/core/usePressed.js";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import{AnimatePresence as n,motion as m}from"framer-motion";import{deleteCookie as d}from"../../../common/utils.js";import{clearAuthenticatedEmbedSession as a}from"../../../common/embedSession.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import l from"../../Icons/logout.svg.js";import u from"./PickaxeSimpleButton.js";import{emitEmbedLogout as p}from"../../../common/embedAuthEvents.js";const f=({tip:f})=>{const{colors:k,styles:h,pickaxe:v,deploymentId:j,isEmbed:x}=r(),{token:g}=c(),y=i(),{isHover:b}=y,I=o(y,["isHover"]),A=s(),{isActive:P}=A,C=o(A,["isActive"]);return e("div",Object.assign({className:"relative"},{children:[t(u,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:k.accent,style:{backgroundColor:P?k.accent+"30":b?k.accent+"10":void 0},onClick:()=>{g&&j&&(null==v?void 0:v.formid)&&a({deploymentId:j,pickaxeId:v.formid,authToken:g});const o=`PXE-token-${null==v?void 0:v.studioid}`;localStorage.getItem(o)?localStorage.removeItem(`PXE-token-${null==v?void 0:v.studioid}`):d(o),x&&(null==v?void 0:v.studioid)&&v.formid&&p({deploymentId:j,pickaxeId:v.formid,studioId:v.studioid}),location.reload()},reversed:!0},I,C,{children:t(l,{className:"h-5 w-5 shrink-0"})})),t(n,{children:b&&!!f&&t(m.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:k.accent,color:k.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:h.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:f}))})]}))};export{f as default};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type EmbedAuthOutcome = "signup" | "login";
|
|
2
|
+
export type EmbedAuthMethod = "email" | "sso";
|
|
3
|
+
export type EmbedAuthEvent = {
|
|
4
|
+
event: EmbedAuthOutcome;
|
|
5
|
+
method: EmbedAuthMethod;
|
|
6
|
+
} | {
|
|
7
|
+
event: "logout";
|
|
8
|
+
};
|
|
9
|
+
type EmbedAuthEventContext = {
|
|
10
|
+
deploymentId?: string;
|
|
11
|
+
pickaxeId: string;
|
|
12
|
+
studioId: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const rememberPendingEmbedAuth: (context: EmbedAuthEventContext, token: string) => void;
|
|
15
|
+
export declare const emitPendingEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
16
|
+
token: string;
|
|
17
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
18
|
+
context: EmbedAuthEventContext;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare const emitSsoEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
21
|
+
token: string;
|
|
22
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
23
|
+
context: EmbedAuthEventContext;
|
|
24
|
+
}) => void;
|
|
25
|
+
export declare const emitEmbedLogout: (context: EmbedAuthEventContext) => void;
|
|
26
|
+
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SetState } from "../../../../../types/common";
|
|
2
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import type { EmbedAuthOutcome } from "../../../../../common/embedAuthEvents";
|
|
3
4
|
type QueryResponse = {
|
|
4
5
|
success: boolean;
|
|
5
6
|
token: string;
|
|
7
|
+
authOutcome?: EmbedAuthOutcome;
|
|
6
8
|
error?: string;
|
|
7
9
|
};
|
|
8
10
|
interface UseAuthVerifyQueryProps {
|