@pickaxeproject/react 6.23.6 → 6.23.8
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/canChat.js +1 -0
- package/dist/cjs/common/embedAuthEvents.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.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/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/src/common/canChat.d.ts +5 -0
- package/dist/cjs/src/common/embedAuthEvents.d.ts +8 -3
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +16 -2
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/cjs/src/index.d.ts +5 -0
- package/dist/cjs/src/types/history.d.ts +3 -0
- package/dist/esm/common/canChat.js +1 -0
- package/dist/esm/common/embedAuthEvents.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.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/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/src/common/canChat.d.ts +5 -0
- package/dist/esm/src/common/embedAuthEvents.d.ts +8 -3
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +16 -2
- package/dist/esm/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/esm/src/index.d.ts +5 -0
- package/dist/esm/src/types/history.d.ts +3 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useCallback as s,useMemo as o}from"react";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import n from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as l,intervalToSuffix as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useCallback as s,useMemo as o}from"react";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import n from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as l,intervalToSuffix as c}from"./PickaxeCommon.js";import{currencyOptions as a}from"./PickaxeCurrency.js";import{Avatar as d,AvatarImage as m,AvatarFallback as u}from"./PickaxeAvatar.js";import{useAuthContext as p}from"../Addons/Auth/hooks/useAuthContext.js";import{pickaxeApi2 as f}from"../../../common/api/pickaxe.js";import{buildUpgradeUrl as x,isInIframe as v}from"../../../common/utils.js";import{useResponseContext as b}from"../../../hooks/pickaxe/useResponseContext.js";import{useStudio as h}from"../../../hooks/studio/useStudio.js";import{getEmbedCheckoutSuccessUrl as g,getEmbedCheckoutId as j,getEmbedCheckoutCancelUrl as k,rememberPendingEmbedCheckout as y}from"../../../common/embedAuthEvents.js";const I=({data:I,children:O,upgradeUrl:N})=>{const{limitData:S}=b(),{studio:U}=h(),{colors:w,deploymentId:C,isEmbed:A,sender:_,pickaxe:T,translations:E,setValidationStatus:L,setStripeAccountId:P,setClientSecret:R}=r(),{token:G,setRedirectUrl:B}=p(),D=s(((e,i)=>{var t;return null!==(t=null==E?void 0:E[e])&&void 0!==t?t:i}),[E]),$=o((()=>{var e,i;return null!==(i=null!==(e=I.displayName)&&void 0!==e?e:I.name)&&void 0!==i?i:""}),[I]),q=o((()=>{var e,i;return null!==(i=null!==(e=I.displayDescription)&&void 0!==e?e:I.description)&&void 0!==i?i:""}),[I]),F=!!(null==U?void 0:U.data.usage)&&U.data.usage.isCredits,V=o((()=>{var e;const{price:i,priceInterval:t,currency:s}=I;if(!i)return{price:D("pricing.free",D("free","Free")),suffix:""};const o=c(null!=t?t:null,!0);return{price:`${(null!==(e=a.find((e=>e.id===s)))&&void 0!==e?e:a[0]).symbol}${i.toLocaleString()}`,suffix:o}}),[I,D]),z=o((()=>{const{limit:e,limitInterval:i}=I;if(e===l)return{limit:D("pricing.unlimited",D("unlimited","Unlimited")),suffix:""};const t=c(null!=i?i:null,!0);return{limit:e.toLocaleString(),suffix:t}}),[I,D]);return i("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[O,i("div",Object.assign({className:"flex flex-col"},{children:[i("div",Object.assign({className:"flex flex-col"},{children:[I.image&&i(d,Object.assign({className:"h-8 w-8"},{children:[t(m,{src:I.image,alt:$}),t(u,{})]})),t("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:$},{children:$})),Boolean(q)&&t("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:q})),i("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[V.price,t("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:V.suffix}))]}))]})),i("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:w.secondaryText}},{children:[t("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:F?(null==E?void 0:E.credits_upper)||"CREDITS":(null==E?void 0:E.uses_upper)||"USES"})),i("p",Object.assign({className:"text-base font-semibold"},{children:[z.limit,t("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:z.suffix}))]}))]}))]})),t(n,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>e(void 0,void 0,void 0,(function*(){if(G)e(void 0,void 0,void 0,(function*(){try{const e={deploymentId:C,pickaxeId:(null==T?void 0:T.formid)||"",studioId:(null==T?void 0:T.studioid)||""},i=A?g(e):document.URL,t=A?j(i):void 0,s=yield f.post("/access/checkout",{data:Object.assign(Object.assign({studioUserId:_||void 0,studioId:null==T?void 0:T.studioid,accessGroupId:I.accessGroupId,checkoutId:t,successUrl:i},A&&{cancelUrl:k()}),{isEmbed:v(),studioSessionToken:G})}),{success:o,url:r,clientSecret:n,checkoutSessionId:l,stripeAccountId:c,error:a}=s.data;A&&y(e,l,i),o?v()?n&&c?(P(c),R(n),L("stripe_checkout")):r&&window.open(r,"_blank"):r&&(window.location.href=r):alert(a)}catch(e){alert(e)}}));else{const e=x(Object.assign({baseUrl:N||(null==S?void 0:S.limitLink),accessGroupId:I.accessGroupId},!v()&&{redirectUrl:document.URL}));v()?(B(e||null),L("login_required")):e&&(window.location.href=e)}}))},{children:I.ctaButtonText||D("pricing.upgrade",D("upgrade","Upgrade"))}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as o}from"../../../_virtual/_tslib.js";import{jsx as r}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{__awaiter as o}from"../../../_virtual/_tslib.js";import{jsx as r,Fragment as t}from"react/jsx-runtime";import{useState as i,useEffect as e}from"react";import c from"copy-to-clipboard";import n from"../../Icons/copy.svg.js";import s from"../../Icons/copied.svg.js";import a from"./PickaxeSimpleButton.js";import l from"../../../common/cn.js";const m=({color:m,text:p="",className:f,iconClassName:h,renderButton:d})=>{const[u,g]=i(p),[j,y]=i(!1),[v,x]=i(!1);e((()=>{g(p)}),[p]);const b=()=>o(void 0,void 0,void 0,(function*(){var o;try{if(j)return;y(!0);const r=null!==(o=[...Array.from(p.matchAll(/https:\/\/streaming\.pickaxeproject\.com\/api\/function_call_results\?.*?&name=[^&]+/g)),...Array.from(p.matchAll(/https:\/\/utils\.pickaxe\.co\/api\/fn\/result\?.*?&name=[^&]+/g))].map((o=>o[0])))&&void 0!==o?o:[],t=[];if(r.length){for(const o of r)try{const r=yield fetch(o),i=yield r.json(),e=i.text||i.url||"";t.push(e)}catch(o){console.error(o)}t.length&&g(t.join("\n"))}let i=t.length>0?t.join("\n"):u;/<action-(caption|finished|error)/.test(i)&&(i=i.replace(/<action-caption\b[^>]*>([\s\S]*?)<\/action-caption>/g,"$1"),i=i.replace(/<action-finished\b[^>]*>[\s\S]*?<\/action-finished>/g,""),i=i.replace(/<action-error\b[^>]*>[\s\S]*?<\/action-error>/g,"")),c(i),y(!1),x(!0),yield new Promise((o=>setTimeout(o,1500)))}catch(o){console.error(o)}finally{y(!1),x(!1)}}));return d?r(t,{children:d({onClick:b,isCopying:j,isCopied:v})}):r(a,Object.assign({color:m},f&&{className:f},{isForceColor:v,onClick:b},{children:r(j||v?s:n,{className:l("w-4 h-4 shrink-0",h)})}))};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as v}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as x}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../../common/cn.js";import j from"../../Icons/download.svg.js";import A from"../../Core/Menu/index.js";import C from"../../Core/Menu/List.js";const D=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:O,disabled:S=!1,studioId:I,className:N,menuContainer:P,menuColors:M})=>{var $,B;const{translations:E,colors:F,styles:L,isRtl:_,sender:H,senderType:K,pickaxe:R}=w(),{artifacts:U=[]}=h(),{token:X}=b(),W=y(),[q,z]=n(""),[G,J]=n(!1),[Q,V]=n(),[Y,Z]=n(!1),ee=r(!1),oe=r(null),te=r(null),ne=r([]),re=r(0),ie=(null==E?void 0:E.download)||"Download",se=S||Y||!O.trim();i((()=>{z(`response-download-${l()}`)}),[]),i((()=>{se&&J(!1)}),[se]),i((()=>{G&&oe.current&&V(getComputedStyle(oe.current).fontFamily)}),[G,L.font]),g({ref:[oe,te],callback:()=>J(!1)});const le=()=>{var e;J(!1),null===(e=oe.current)||void 0===e||e.focus({preventScroll:!0})},ae=e=>{var o;if(!se)if("Escape"===e.key&&G)e.preventDefault(),e.stopPropagation(),le();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=ne.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;re.current=i,J(!0),null===(o=ne.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&J(!1)},de=e=>{e.relatedTarget===oe.current||ne.current.some((o=>o===e.relatedTarget))||J(!1)};return o(A,Object.assign({id:q,className:k("h-4 w-4 shrink-0",N),isOpen:G&&!se,onChange:J,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:oe,id:q||void 0,type:"button",className:k("flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",N),style:{color:T},title:ie,"aria-label":ie,"aria-haspopup":"menu","aria-busy":Y,"aria-expanded":G&&!se,"aria-controls":G&&!se?`${q}-menu`:void 0,disabled:se,onClick:e=>{e.stopPropagation(),re.current=0,J((e=>!e))},onKeyDown:ae,onBlur:de},{children:t(j,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),q&&!se&&s(t("div",Object.assign({ref:te,style:{fontFamily:Q},dir:_?"rtl":"ltr"},{children:t(C,Object.assign({id:`${q}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:null!==($=null==M?void 0:M.background)&&void 0!==$?$:F.primary,color:null!==(B=null==M?void 0:M.text)&&void 0!==B?B:F.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=ne.current[re.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{ne.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),se||ee.current)return;let r;le();try{const o=f(O);let i;if(o.length){if(ee.current=!0,Z(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==E?void 0:E.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield v(O,o,(o=>e(void 0,void 0,void 0,(function*(){const e=U.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:W.mutateAsync({artifactId:o.id,version:o.version,studioId:null!=I?I:null==R?void 0:R.studioid,senderType:K,sender:H||void 0,studioSessionToken:X||void 0})}))),t.extension,(e=>x(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){ee.current=!0,Z(!0);const e=yield d(O,i);return void a(e,"response.docx")}if("pdf"===t.extension)return ee.current=!0,Z(!0),void(i?yield u(i,r):yield m(O));"html"===t.extension&&(ee.current=!0,Z(!0));let s=null!=i?i:"html"===t.extension?yield p(O):O;"html"===t.extension&&(ee.current=!0,Z(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==E?void 0:E["something-went-wrong"])||"Something went wrong.")}finally{ee.current=!1,Z(!1)}}))})(t,o)},onKeyDown:ae,onBlur:de},{children:o.label}),o.extension)))}))})),null!=P?P:document.body)]}))};export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as o}from"react";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as
|
|
1
|
+
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as o}from"react";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as n}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useFeedback as a}from"../../../hooks/pickaxe/useFeedback.js";import{AnimatePresence as l,motion as c}from"framer-motion";import r from"../../Icons/message-square-notes.svg.js";import m from"../../Icons/thumbs-down.svg.js";import p from"../../Icons/speaker.svg.js";import d from"../../Icons/stop.svg.js";import u from"../../Icons/spinner-lines.svg.js";import b from"../../Icons/thumbs-up.svg.js";import f from"./PickaxeSimpleButton.js";import h from"./PickaxeCopyButton.js";import g from"./PickaxeDownloadButton.js";import x from"./PickaxeFeedbackThumbsDownReasons.js";import{prepareResponseDownloadText as v}from"../../../common/responseDownload.js";import k from"../../../common/cn.js";const j=({content:j,responseKind:y="chat",responseReference:O,isHideResponseAction:w,sessionId:N,index:I=0,messagesCount:R,isHideFeedback:T,isReadOut:D,isReadOutLoading:C,isReading:S,onOpenChat:z,onReadOut:F})=>{var P,U,B,H;const{colors:A,translations:W,pickaxe:q,pickaxeId:K,sessionId:L,renderResponseAction:M,misc:E,setIsShowFeedbackMessage:G}=n(),J=t(),Q=!0===E.isResponseDownload,V=o((()=>Q?v(j):""),[j,Q]),{toggleThumb:X,submitThumbsDown:Y,submitThumbsUp:Z,isThumbsUpSelected:$,isThumbsDownSelected:_,showThumbsDownOptions:ee,showThumbsUpOptions:se,showSuccess:ie}=a({content:j,index:I,sessionId:N,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>G(!0),onThumbsDownReasonClose:()=>G(!1)}),oe="function"==typeof z&&((null==q?void 0:q.chatflag)||!!(null==q?void 0:q.enablechatresponses))&&void 0!==N&&void 0!==R,te=Boolean(((null==q?void 0:q.chatflag)||(null==q?void 0:q.enablechatresponses))&&!z||!(null==q?void 0:q.chatflag)&&!(null==q?void 0:q.enablechatresponses))&&!T;return e("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e("div",Object.assign({className:k("flex items-center gap-3",Q?"min-h-4 flex-wrap":"h-4")},{children:[oe&&e(f,Object.assign({color:A.accent,onClick:z},{children:[s(r,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:k(J.b3,"font-semibold")},{children:R}))]})),s(h,{color:A.accent,text:j}),Q&&s(g,{color:A.accent,text:V}),!w&&!oe&&j.trim()&&(N||L)&&(null==M?void 0:M(Object.assign(Object.assign({pickaxeId:K,sessionId:N||L,kind:y,responseReference:"form"===y?"form-result":O},"chat"===y?{messageIndex:I}:{}),{agentName:(null==q?void 0:q.formtitle)||K,content:j}))),te&&e(i,{children:[s(f,Object.assign({color:A.accent,onClick:()=>X("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:s(b,{className:"size-4",style:{fill:A.text,fillOpacity:$?.3:0}})})),s(f,Object.assign({color:A.accent,onClick:()=>X("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:s(m,{className:"size-4",style:{fill:A.text,fillOpacity:_?.3:0}})})),D&&F&&s(f,Object.assign({color:A.accent,onClick:()=>F(),className:"transition-all active:-rotate-12 active:scale-90"},{children:C?s(u,{className:"size-4 animate-spin"}):S?s(d,{className:"size-4 rounded-full border p-[1.5px]",style:{borderColor:A.accent}}):s(p,{className:"size-4"})})),s(l,{children:ie&&s(c.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:s("p",Object.assign({className:k(J.b4,A.secondary,"opacity-75")},{children:null!==(P=null==W?void 0:W["feedback-thanks"])&&void 0!==P?P:"Thanks for the feedback!"}))}))})]})]})),s(l,{children:(ee||se)&&e(c.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e("div",Object.assign({className:"space-y-0.5"},{children:[s("p",Object.assign({className:k(J.b3,A.text)},{children:se?null!==(U=null==W?void 0:W["feedback-like-title"])&&void 0!==U?U:"What went right?":null!==(B=null==W?void 0:W["feedback-dislike-title"])&&void 0!==B?B:"What went wrong?"})),s("p",Object.assign({className:k(J.b3,A.secondary,"opacity-75")},{children:null!==(H=null==W?void 0:W["feedback-dislike-message"])&&void 0!==H?H:"Help us improve our answers"}))]})),s(c.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:s(x,{isUp:se,submitThumbsDown:Y,submitThumbsUp:Z})}))]}))})]}))};export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useState as i,useMemo as t,useEffect as r}from"react";import{AnimatePresence as l}from"framer-motion";import{usePickaxeContext as n}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as a}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../hooks/studio/useStyleFontSize.js";import{isInIframe as d,buildUpgradeUrl as u}from"../../../common/utils.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useState as i,useMemo as t,useEffect as r}from"react";import{AnimatePresence as l}from"framer-motion";import{usePickaxeContext as n}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as a}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../hooks/studio/useStyleFontSize.js";import{isInIframe as d,buildUpgradeUrl as u}from"../../../common/utils.js";import m from"../../Icons/circle-exclamation.svg.js";import p from"../../Core/SpringTransition.js";import v from"../../Core/HtmlRenderer.js";import f from"./PickaxeButton.js";import b from"../../../common/cn.js";import{pickaxeApi2 as g}from"../../../common/api/pickaxe.js";import{useAuthContext as x}from"../Addons/Auth/hooks/useAuthContext.js";import h from"./AccessGroupCardPreview.js";import y from"./HorizontalScrollCue.js";import{useStudio as k}from"../../../hooks/studio/useStudio.js";import{currencyOptions as j}from"./PickaxeCurrency.js";import{getEmbedCheckoutSuccessUrl as C,getEmbedCheckoutId as w,getEmbedCheckoutCancelUrl as N,rememberPendingEmbedCheckout as O}from"../../../common/embedAuthEvents.js";const S=({price:e,uses:i,isCredits:t,isSelected:r,costPerRun:l,onClick:n,colors:a,currencySymbol:c})=>{const d=`${c}${e}`,u={backgroundColor:a.secondary,color:a.secondaryText,borderColor:r?a.secondaryText:"rgba(0,0,0,0.1)"},m=t&&l?Math.ceil(i/l):0;return s("button",t?Object.assign({onClick:n,className:b("flex min-w-[200px] shrink-0 cursor-pointer flex-col rounded-[16px] px-6 py-5 text-left transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:u},{children:[s("div",Object.assign({className:"mb-4 flex items-center gap-2"},{children:[o("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:d})),s("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," credits"]}))]})),o("div",{className:"mb-4 h-[1px] w-full",style:{backgroundColor:a.secondaryText,opacity:.15}}),s("span",Object.assign({className:"text-[14px] italic opacity-70"},{children:["~ ",void 0!==m&&m>0?m.toLocaleString():"..."," ","runs"]}))]}):Object.assign({onClick:n,className:b("flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-[16px] px-5 py-3 transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:u},{children:[o("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:d})),s("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," uses"]}))]}))},U=(e,o)=>{var s,i;const t=Number(o?null!==(s=e.credits)&&void 0!==s?s:e.uses:null!==(i=e.uses)&&void 0!==i?i:e.credits);return Number.isFinite(t)?t:0},A=e=>{const o=Number(e.price);return Number.isFinite(o)?o:0},I=({className:I,iconClassName:_,htmlClassName:L})=>{var P,R,G,B,T;const{colors:F,deploymentId:E,isEmbed:M,pickaxe:$,accessGroup:z,sender:H,translations:q,setValidationStatus:D,setClientSecret:V,setStripeAccountId:J}=n(),{token:K,setRedirectUrl:Q}=x(),{limitData:W}=a(),{studio:X}=k(),Y=c(),[Z,ee]=i(0),[oe,se]=i(null),ie=Boolean(null==W?void 0:W.hideUpgradeOptions),te=null==X?void 0:X.data,re=null==te?void 0:te.usage,le=Boolean(null==re?void 0:re.isCredits),ne=null!==(R=null===(P=j.find((e=>e.id===(null==te?void 0:te.currency))))||void 0===P?void 0:P.symbol)&&void 0!==R?R:j[0].symbol,ae=ie||"string"!=typeof(null==W?void 0:W.customLink)?"":W.customLink.trim(),ce=t((()=>{if(ie)return[];if(ae)return[];const e=le?null==re?void 0:re.availableCredits:null==re?void 0:re.availableUses;if(Array.isArray(e)&&e.length>0)return e;const o=null==W?void 0:W.buyUses;return Array.isArray(o)?o:[]}),[ae,le,null==W?void 0:W.buyUses,ie,null==re?void 0:re.availableCredits,null==re?void 0:re.availableUses]);r((()=>{ee(0)}),[ce]);const de=!0===(null===(G=null==z?void 0:z.upgrade)||void 0===G?void 0:G.isBuyMoreUses)&&ce.length>0,ue=de?ce[Z]:void 0,me=ue?U(ue,le):0,pe=ue?A(ue):0;r((()=>{let o=!0;return e(void 0,void 0,void 0,(function*(){if(ae)se(null);else if(null==te?void 0:te.workspaceId)try{const e=yield g.get(`/cost_per_run?workspaceId=${te.workspaceId}`,{withCredentials:!1});if(o){const o=1e4*e.data.costPerRun||0;se(o)}}catch(e){console.error("Failed to fetch cost per run:",e),o&&se(0)}else se(0)})),()=>{o=!1}}),[ae,null==te?void 0:te.workspaceId,se]);const ve=ae,fe=(null===(B=null==W?void 0:W.limitCTA)||void 0===B?void 0:B.trim())||(null==q?void 0:q["pricing.upgrade"])||(null==q?void 0:q.upgrade)||"Upgrade",be=!ie&&!ae&&Array.isArray(null==W?void 0:W.upgradeGroups)&&(null==W?void 0:W.upgradeGroups)&&(null==W?void 0:W.upgradeGroups.length)>0;return W?o(l,{children:s(p,Object.assign({className:b("flex flex-col gap-5 w-full",I)},{children:[s("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:F.secondary}},{children:[s("div",Object.assign({className:"flex gap-3 items-start"},{children:[o(m,{className:b("h-5 w-5 shrink-0 mt-0.5",_),style:{color:F.accent}}),o(v,{className:b(Y.b2,"font-semibold leading-relaxed text-sm",L),style:{color:F.text},html:W.limitMessage||""})]})),ve&&o(f,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>e(void 0,void 0,void 0,(function*(){window.open(ve,"_blank","noopener,noreferrer")}))},{children:fe}))]})),be&&s("div",Object.assign({className:"flex flex-col gap-2"},{children:[o("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:F.text}},{children:(null==q?void 0:q["available-plans"])||"Available Plans"})),o(y,Object.assign({contentClassName:"gap-3 pb-4 pt-1",edgeColor:F.primary},{children:null===(T=W.upgradeGroups)||void 0===T?void 0:T.map(((e,s)=>o(h,{data:e},e.accessGroupId||s)))}))]})),de&&ue&&s("div",Object.assign({className:"flex flex-col gap-3"},{children:[s("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:F.text}},{children:[(null==q?void 0:q.buy)||"Buy"," ",le?(null==q?void 0:q.credits)||"Credits":(null==q?void 0:q.uses)||"Uses"]})),o("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:ce.map(((e,s)=>o(S,{price:A(e),uses:U(e,le),isCredits:le,costPerRun:oe||void 0,isSelected:s===Z,onClick:()=>ee(s),colors:F,currencySymbol:ne},s)))})),s(f,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>e(void 0,void 0,void 0,(function*(){if(K){var o,s;o=me,s=pe,e(void 0,void 0,void 0,(function*(){try{const e={deploymentId:E,pickaxeId:(null==$?void 0:$.formid)||"",studioId:(null==$?void 0:$.studioid)||""},i=M?C(e):document.URL,t=M?w(i):void 0,r=yield g.post("/billing/extra_usage_payment_link",{data:Object.assign({sender:H||void 0,studioSessionToken:K,studioId:null==$?void 0:$.studioid,cost:s,checkoutId:t,isEmbed:d(),extraUses:o,successUrl:i},M&&{cancelUrl:N()})}),{success:l,url:n,clientSecret:a,checkoutSessionId:c,stripeAccountId:u,error:m}=r.data;M&&O(e,c,i),l?d()?a&&u?(J(u),V(a),D("stripe_checkout")):n&&window.open(n,"_blank"):n&&(window.location.href=n):alert(m)}catch(e){alert(e)}}))}else{const e=W.limitLink||ve;if(d())Q(e||null),D("login_required");else{const o=u({baseUrl:e,redirectUrl:document.URL});o&&(window.location.href=o)}}}))},{children:[(null==q?void 0:q.buy)||"Buy"," ",me.toLocaleString()," ",le?(null==q?void 0:q.credits)||"Credits":(null==q?void 0:q.uses)||"Uses"," ","for ",ne,pe]}))]}))]}))}):null};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/pickaxe/usePickaxe.js";import{useState as i,useMemo as a,useEffect as r}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useAuthBootstrap as c}from"./Addons/Auth/hooks/useAuthBootstrap.js";import{useResponseContext as d}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as u}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as m}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as p}from"uuid";import{ScrollProvider as f}from"./Addons/Scroll/Provider.js";import g from"./common/PickaxeSkeleton.js";import h from"./Chat/index.js";import x from"./Form/index.js";import v from"./Addons/Auth/index.js";import b from"../../common/cn.js";import{pickaxeApi2 as j}from"../../common/api/pickaxe.js";import k from"../../common/error.js";import{getValidationFailure as y}from"../../common/validation.js";import w from"./common/AccessGroupCardPreview.js";import N from"./common/HorizontalScrollCue.js";import O from"./common/PickaxeButton.js";import{Avatar as I,AvatarImage as C,AvatarFallback as A}from"./common/PickaxeAvatar.js";import S from"../Icons/lock.svg.js";import{EmbeddedCheckoutProvider as _,EmbeddedCheckout as q}from"../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js";import{loadStripe as U}from"../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js";import{clearAuthenticatedEmbedSession as L,writeAuthenticatedEmbedSession as P,readAuthenticatedEmbedSession as T}from"../../common/embedSession.js";const G=({className:e})=>s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s("polyline",{points:"15 18 9 12 15 6"})})),R=({pickaxeId:R,className:B})=>{var E,D,M,$;const{sessionId:F,styles:V,colors:z,responsiveBy:H,deploymentType:W,isNewChat:J,isEmbed:K,opacity:X,deploymentId:Y,sender:Q,portalId:Z,validationStatus:ee,validationUpgradeGroups:se,validationUpgradeUrl:te,accessGroup:oe,stripeAccountId:ie,clientSecret:ae,translations:re,preventInitialSessionId:ne,persistActiveConversation:le,setClientSecret:ce,setStripeAccountId:de,setValidationStatus:ue,setValidationUpgradeGroups:me,setValidationUpgradeUrl:pe,setContextId:fe,setPickaxeId:ge,setSessionId:he,setLastSessionId:xe,setIsNewChat:ve,setPickaxe:be,setAccessGroup:je}=n(),{emailInput:ke,isSent:ye,token:we,isAuthBootstrapComplete:Ne}=l(),{setMessages:Oe,setResponse:Ie,setError:Ce,setLimitData:Ae,setIsSwitchedToChat:Se}=d(),{setDocumentError:_e}=u(),{setCurrentArtifact:qe}=m(),[Ue,Le]=i(!1),Pe=o();c();const Te=Boolean(K&&Y&&le&&!ne&&(null===(E=Pe.data)||void 0===E?void 0:E.chatflag)&&!Pe.data.enablechatresponses),Ge=Te?we:null,Re=!Te||Ne,Be="chat-input"===W&&J&&!ye,Ee=a((()=>ie?U(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:ie}):null),[ie]);r((()=>{ge(R)}),[R]);r((()=>{if(!Y&&!Z||!Pe.data)return;if(!Ne)return;if("stripe_checkout"===ee)return;e(void 0,void 0,void 0,(function*(){var e;ue("loading");try{const s=yield j.post("/access/validate",{data:{deploymentId:Y,sender:Q||void 0,studioSessionToken:we,portalId:Z,studioId:null===(e=Pe.data)||void 0===e?void 0:e.studioid}});if(s.data.success)ue("success"),me([]),pe(null),je(((e,s)=>e&&s?Object.assign(Object.assign({},e),{hideUpgradeOptions:!0}):e)(s.data.accessGroup,s.data.hideUpgradeOptions));else{const e=y(s.data);if(!e)return ue("login_required"),me([]),void pe(null);ue(e.status),je(e.accessGroup),me(e.upgradeGroups),pe(e.upgradeUrl),Le(!0)}}catch(e){console.error("Failed to validate deployment:",e),ue("success")}}))}),[Y,Ne,Q,we,Z,Pe.data]),r((()=>{if(!Pe.data)return;const s=Pe.data;be(s);const t=s.chatflag;if(!Re)return void Le(!1);let o=!1;return e(void 0,void 0,void 0,(function*(){let e="";if(Ge&&Y){const t={deploymentId:Y,pickaxeId:s.formid,authToken:Ge},o=T(t);if(null==o?void 0:o.sessionId)try{const t=new URLSearchParams({pickaxeId:s.formid,sessionId:o.sessionId,deploymentId:Y,studioSessionToken:Ge,resume:"true"});yield j.get(`/conversation?${t.toString()}`),e=o.sessionId}catch(e){L(t)}}o||(ne||(he(e||(t?p():"")),xe(e),ve(!e)),fe(p()),t?Oe([]):Ie(null),Ce(""),_e(""),Ae(null),qe(null),Se(!1),Le(!0))})),()=>{o=!0}}),[Te,Y,K,Re,Ge,le,Pe.data,ne]),r((()=>{var e;if(!K||!Y||!we||!(null===(e=Pe.data)||void 0===e?void 0:e.formid)||ne)return;const s={deploymentId:Y,pickaxeId:Pe.data.formid,authToken:we};le&&Pe.data.chatflag&&!Pe.data.enablechatresponses&&!J&&F?P(Object.assign(Object.assign({},s),{sessionId:F})):L(s)}),[Y,K,J,le,null===(D=Pe.data)||void 0===D?void 0:D.chatflag,null===(M=Pe.data)||void 0===M?void 0:M.enablechatresponses,null===($=Pe.data)||void 0===$?void 0:$.formid,ne,F,we]),r((()=>{Ce(""),_e(""),Ae(null),Oe([]),Ie(null),qe(null)}),[F]);const De=a((()=>{const e=null!=X?X:1;if(!z.primary||!z.primary.startsWith("#")||e<0||e>1)return z.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${z.primary}${s}`}),[z.primary,X]);if(!Pe.data)return null;return s("div",Object.assign({className:b("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===V.theme&&"dark",B),style:Object.assign({backgroundColor:Be?"transparent":De,color:z.text},V.font&&"Real Head Pro"!==V.font&&{fontFamily:V.font})},{children:(()=>{var o,i,a,r,n;if("stripe_checkout"===ee&&ae&&Ee)return t("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:z.secondary||"#ffffff",color:z.secondaryText||"#000000"}},{children:[s("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:t("button",Object.assign({onClick:()=>{ce&&ce(null),de&&de(null),ue("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:z.text}},{children:[s(G,{className:"w-5 h-5"}),s("span",{children:(null==re?void 0:re.back)||"Back"})]}))})),s("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s(_,Object.assign({stripe:Ee,options:{clientSecret:ae}},{children:s(q,{})}))}))]}));if(Pe.isLoading||!Ue||"loading"===ee)return s("div",Object.assign({className:b("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===H?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s(g,{className:"w-[72px] h-[72px]"}),s(g,{className:"h-[20px] mt-6 w-full"}),s(g,{className:"h-[20px] mt-2 w-full"}),s(g,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s(g,{className:b("w-full min-h-[48px]","viewport"===H?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===ee){const e=null==oe?void 0:oe.hideUpgradeOptions,r=!e&&se.length>0,n=!e&&(null===(o=null==oe?void 0:oe.upgrade)||void 0===o?void 0:o.isLinkToCustomURL)&&"string"==typeof oe.upgrade.limitLink&&oe.upgrade.limitLink.trim().length>0?oe.upgrade.limitLink.trim():null,l="string"==typeof(null===(i=null==oe?void 0:oe.upgrade)||void 0===i?void 0:i.limitMessage)&&oe.upgrade.limitMessage.trim().length>0?oe.upgrade.limitMessage:(null==re?void 0:re["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",c="string"==typeof(null===(a=null==oe?void 0:oe.upgrade)||void 0===a?void 0:a.limitCTA)&&oe.upgrade.limitCTA.trim().length>0?oe.upgrade.limitCTA:(null==re?void 0:re["pricing.upgrade"])||(null==re?void 0:re.upgrade)||"Upgrade";return s("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:t("div",n?Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==re?void 0:re["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:l})),s(O,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(n,"_blank","noopener,noreferrer")}},{children:c}))]}):r?Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[t("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==re?void 0:re["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"break-words opacity-80"},{children:(null==re?void 0:re["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s(N,Object.assign({className:"w-full",contentClassName:b("gap-4 pb-4",se.length<=3&&("viewport"===H?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:se.map(((e,t)=>s(w,{data:e,upgradeUrl:te},e.accessGroupId||e.id||t)))}))]}):e?Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==re?void 0:re["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:l}))]}):Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==re?void 0:re["access-locked"])||"Access Locked"})),s("p",Object.assign({className:"opacity-80"},{children:(null==re?void 0:re["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===ee&&K?s(v,{}):"login_required"!==ee||K?"access_denied"===ee?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[t(I,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s(C,{src:null===(r=Pe.data)||void 0===r?void 0:r.coverphoto,alt:`${null===(n=Pe.data)||void 0===n?void 0:n.formtitle} Logo`}),s(A,{})]})),t("div",Object.assign({className:"text-center mb-6"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==re?void 0:re["access-denied"])||"Access Denied"})),t("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s(S,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s("p",Object.assign({className:"ml-1"},{children:(null==re?void 0:re["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:z.accent,color:z.accentText,borderRadius:V.cornerRadius},onClick:()=>{e(void 0,void 0,void 0,(function*(){var e,s;const t=(null==oe?void 0:oe.accessGroupId)?[oe.accessGroupId]:[],o=ke.trim().toLowerCase();if(o)try{const i=yield j.post("/access/request",{data:{email:o,studioId:null===(e=Pe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=Pe.data)||void 0===s?void 0:s.formid,deploymentId:Y,accessGroupIds:t})}});i.data.success?alert((null==re?void 0:re["access-requested-successfully"])||"Successfully requested access!"):alert(i.data.error)}catch(e){const s=k(e);alert(((null==re?void 0:re["request-access-error"])||"Couldn't request access. Error: {error}").replace("{error}",s||String(e)))}else alert((null==re?void 0:re["email-address-cannot-be-empty"])||"Email address cannot be empty.")}))}},{children:(null==re?void 0:re["request-access"])||"Request Access"})),s("span",Object.assign({className:"mt-4 mb-2"},{children:(null==re?void 0:re.or)||"or"})),s("span",Object.assign({className:"font-medium text-lg"},{children:(null==re?void 0:re["sign-in-with-different-account"])||"Sign in with a different account"}))]})):s(f,F?{children:s(h,{})}:{children:s(x,{})}):s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==re?void 0:re["access-denied"])||"Access Denied"})),s("p",Object.assign({className:"opacity-80"},{children:(null==re?void 0:re["login-is-required"])||"Login is required."}))]}))}))})()}))};export{R as Pickaxe};
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/pickaxe/usePickaxe.js";import{useState as i,useMemo as a,useEffect as r,useCallback as n}from"react";import{usePickaxeContext as l}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"./Addons/Auth/hooks/useAuthContext.js";import{useAuthBootstrap as d}from"./Addons/Auth/hooks/useAuthBootstrap.js";import{useResponseContext as u}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as m}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as p}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as f}from"uuid";import{ScrollProvider as g}from"./Addons/Scroll/Provider.js";import x from"./common/PickaxeSkeleton.js";import h from"./Chat/index.js";import v from"./Form/index.js";import b from"./Addons/Auth/index.js";import j from"../../common/cn.js";import{pickaxeApi2 as k}from"../../common/api/pickaxe.js";import y from"../../common/error.js";import{getValidationFailure as w}from"../../common/validation.js";import N from"./common/AccessGroupCardPreview.js";import I from"./common/HorizontalScrollCue.js";import O from"./common/PickaxeButton.js";import{Avatar as C,AvatarImage as A,AvatarFallback as S}from"./common/PickaxeAvatar.js";import _ from"../Icons/lock.svg.js";import{EmbeddedCheckoutProvider as q,EmbeddedCheckout as U}from"../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js";import{loadStripe as L}from"../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js";import{clearAuthenticatedEmbedSession as P,writeAuthenticatedEmbedSession as T,readAuthenticatedEmbedSession as G}from"../../common/embedSession.js";import{emitPendingEmbedCheckout as R,emitEmbedCheckout as E}from"../../common/embedAuthEvents.js";const B=({className:e})=>s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s("polyline",{points:"15 18 9 12 15 6"})})),D=({pickaxeId:D,className:M})=>{var $,F,V,z,H;const{sessionId:W,styles:J,colors:K,responsiveBy:X,deploymentType:Y,isNewChat:Q,isEmbed:Z,opacity:ee,deploymentId:se,pickaxeId:te,sender:oe,portalId:ie,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:ne,accessGroup:le,stripeAccountId:ce,clientSecret:de,translations:ue,preventInitialSessionId:me,persistActiveConversation:pe,setClientSecret:fe,setStripeAccountId:ge,setValidationStatus:xe,setValidationUpgradeGroups:he,setValidationUpgradeUrl:ve,setContextId:be,setPickaxeId:je,setSessionId:ke,setLastSessionId:ye,setIsNewChat:we,setPickaxe:Ne,setAccessGroup:Ie}=l(),{emailInput:Oe,isSent:Ce,token:Ae,isAuthBootstrapComplete:Se}=c(),{setMessages:_e,setResponse:qe,setError:Ue,setLimitData:Le,setIsSwitchedToChat:Pe}=u(),{setDocumentError:Te}=m(),{setCurrentArtifact:Ge}=p(),[Re,Ee]=i(!1),Be=o();d();const De=a((()=>{var e;return{deploymentId:se,pickaxeId:te,studioId:(null===(e=Be.data)||void 0===e?void 0:e.studioid)||""}}),[se,null===($=Be.data)||void 0===$?void 0:$.studioid,te]);r((()=>{Z&&De.pickaxeId&&De.studioId&&R(De,Ae)}),[De,Z,Ae]);const Me=n((()=>{Z&&De.pickaxeId&&De.studioId&&E(De,de||void 0)}),[De,de,Z]),$e=Boolean(Z&&se&&pe&&!me&&(null===(F=Be.data)||void 0===F?void 0:F.chatflag)&&!Be.data.enablechatresponses),Fe=$e?Ae:null,Ve=!$e||Se,ze="chat-input"===Y&&Q&&!Ce,He=a((()=>ce?L(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:ce}):null),[ce]);r((()=>{je(D)}),[D]);r((()=>{if(!se&&!ie||!Be.data)return;if(!Se)return;if("stripe_checkout"===ae)return;e(void 0,void 0,void 0,(function*(){var e;xe("loading");try{const s=yield k.post("/access/validate",{data:{deploymentId:se,sender:oe||void 0,studioSessionToken:Ae,portalId:ie,studioId:null===(e=Be.data)||void 0===e?void 0:e.studioid}});if(s.data.success)xe("success"),he([]),ve(null),Ie(((e,s)=>e&&s?Object.assign(Object.assign({},e),{hideUpgradeOptions:!0}):e)(s.data.accessGroup,s.data.hideUpgradeOptions));else{const e=w(s.data);if(!e)return xe("login_required"),he([]),void ve(null);xe(e.status),Ie(e.accessGroup),he(e.upgradeGroups),ve(e.upgradeUrl),Ee(!0)}}catch(e){console.error("Failed to validate deployment:",e),xe("success")}}))}),[se,Se,oe,Ae,ie,Be.data]),r((()=>{if(!Be.data)return;const s=Be.data;Ne(s);const t=s.chatflag;if(!Ve)return void Ee(!1);let o=!1;return e(void 0,void 0,void 0,(function*(){let e="";if(Fe&&se){const t={deploymentId:se,pickaxeId:s.formid,authToken:Fe},o=G(t);if(null==o?void 0:o.sessionId)try{const t=new URLSearchParams({pickaxeId:s.formid,sessionId:o.sessionId,deploymentId:se,studioSessionToken:Fe,resume:"true"});yield k.get(`/conversation?${t.toString()}`),e=o.sessionId}catch(e){P(t)}}o||(me||(ke(e||(t?f():"")),ye(e),we(!e)),be(f()),t?_e([]):qe(null),Ue(""),Te(""),Le(null),Ge(null),Pe(!1),Ee(!0))})),()=>{o=!0}}),[$e,se,Z,Ve,Fe,pe,Be.data,me]),r((()=>{var e;if(!Z||!se||!Ae||!(null===(e=Be.data)||void 0===e?void 0:e.formid)||me)return;const s={deploymentId:se,pickaxeId:Be.data.formid,authToken:Ae};pe&&Be.data.chatflag&&!Be.data.enablechatresponses&&!Q&&W?T(Object.assign(Object.assign({},s),{sessionId:W})):P(s)}),[se,Z,Q,pe,null===(V=Be.data)||void 0===V?void 0:V.chatflag,null===(z=Be.data)||void 0===z?void 0:z.enablechatresponses,null===(H=Be.data)||void 0===H?void 0:H.formid,me,W,Ae]),r((()=>{Ue(""),Te(""),Le(null),_e([]),qe(null),Ge(null)}),[W]);const We=a((()=>{const e=null!=ee?ee:1;if(!K.primary||!K.primary.startsWith("#")||e<0||e>1)return K.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${K.primary}${s}`}),[K.primary,ee]);if(!Be.data)return null;return s("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===J.theme&&"dark",M),style:Object.assign({backgroundColor:ze?"transparent":We,color:K.text},J.font&&"Real Head Pro"!==J.font&&{fontFamily:J.font})},{children:(()=>{var o,i,a,r,n;if("stripe_checkout"===ae&&de&&He)return t("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:K.secondary||"#ffffff",color:K.secondaryText||"#000000"}},{children:[s("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:t("button",Object.assign({onClick:()=>{fe&&fe(null),ge&&ge(null),xe("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:K.text}},{children:[s(B,{className:"w-5 h-5"}),s("span",{children:(null==ue?void 0:ue.back)||"Back"})]}))})),s("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s(q,Object.assign({stripe:He,options:{clientSecret:de,onComplete:Me}},{children:s(U,{})}))}))]}));if(Be.isLoading||!Re||"loading"===ae)return s("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===X?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s(x,{className:"w-[72px] h-[72px]"}),s(x,{className:"h-[20px] mt-6 w-full"}),s(x,{className:"h-[20px] mt-2 w-full"}),s(x,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s(x,{className:j("w-full min-h-[48px]","viewport"===X?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===ae){const e=null==le?void 0:le.hideUpgradeOptions,r=!e&&re.length>0,n=!e&&(null===(o=null==le?void 0:le.upgrade)||void 0===o?void 0:o.isLinkToCustomURL)&&"string"==typeof le.upgrade.limitLink&&le.upgrade.limitLink.trim().length>0?le.upgrade.limitLink.trim():null,l="string"==typeof(null===(i=null==le?void 0:le.upgrade)||void 0===i?void 0:i.limitMessage)&&le.upgrade.limitMessage.trim().length>0?le.upgrade.limitMessage:(null==ue?void 0:ue["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",c="string"==typeof(null===(a=null==le?void 0:le.upgrade)||void 0===a?void 0:a.limitCTA)&&le.upgrade.limitCTA.trim().length>0?le.upgrade.limitCTA:(null==ue?void 0:ue["pricing.upgrade"])||(null==ue?void 0:ue.upgrade)||"Upgrade";return s("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:t("div",n?Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==ue?void 0:ue["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:l})),s(O,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(n,"_blank","noopener,noreferrer")}},{children:c}))]}):r?Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[t("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==ue?void 0:ue["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"break-words opacity-80"},{children:(null==ue?void 0:ue["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s(I,Object.assign({className:"w-full",contentClassName:j("gap-4 pb-4",re.length<=3&&("viewport"===X?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:re.map(((e,t)=>s(N,{data:e,upgradeUrl:ne},e.accessGroupId||e.id||t)))}))]}):e?Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==ue?void 0:ue["upgrade-required"])||"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:l}))]}):Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==ue?void 0:ue["access-locked"])||"Access Locked"})),s("p",Object.assign({className:"opacity-80"},{children:(null==ue?void 0:ue["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===ae&&Z?s(b,{}):"login_required"!==ae||Z?"access_denied"===ae?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[t(C,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s(A,{src:null===(r=Be.data)||void 0===r?void 0:r.coverphoto,alt:`${null===(n=Be.data)||void 0===n?void 0:n.formtitle} Logo`}),s(S,{})]})),t("div",Object.assign({className:"text-center mb-6"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==ue?void 0:ue["access-denied"])||"Access Denied"})),t("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s(_,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s("p",Object.assign({className:"ml-1"},{children:(null==ue?void 0:ue["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:K.accent,color:K.accentText,borderRadius:J.cornerRadius},onClick:()=>{e(void 0,void 0,void 0,(function*(){var e,s;const t=(null==le?void 0:le.accessGroupId)?[le.accessGroupId]:[],o=Oe.trim().toLowerCase();if(o)try{const i=yield k.post("/access/request",{data:{email:o,studioId:null===(e=Be.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=Be.data)||void 0===s?void 0:s.formid,deploymentId:se,accessGroupIds:t})}});i.data.success?alert((null==ue?void 0:ue["access-requested-successfully"])||"Successfully requested access!"):alert(i.data.error)}catch(e){const s=y(e);alert(((null==ue?void 0:ue["request-access-error"])||"Couldn't request access. Error: {error}").replace("{error}",s||String(e)))}else alert((null==ue?void 0:ue["email-address-cannot-be-empty"])||"Email address cannot be empty.")}))}},{children:(null==ue?void 0:ue["request-access"])||"Request Access"})),s("span",Object.assign({className:"mt-4 mb-2"},{children:(null==ue?void 0:ue.or)||"or"})),s("span",Object.assign({className:"font-medium text-lg"},{children:(null==ue?void 0:ue["sign-in-with-different-account"])||"Sign in with a different account"}))]})):s(g,W?{children:s(h,{})}:{children:s(v,{})}):s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==ue?void 0:ue["access-denied"])||"Access Denied"})),s("p",Object.assign({className:"opacity-80"},{children:(null==ue?void 0:ue["login-is-required"])||"Login is required."}))]}))}))})()}))};export{D as Pickaxe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as s}from"@tanstack/react-query";import{usePickaxeContext as t}from"./usePickaxeContext.js";import{useResponseContext as o}from"./useResponseContext.js";import{pickaxeApi2 as n}from"../../common/api/pickaxe.js";import{normalizeHistoryMessages as r}from"../../common/chatMessages.js";import{useAuthContext as i}from"../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js";const a=e=>e.filter(((s,t)=>"user"!==s.role||!(e=>"assistant"===(null==e?void 0:e.role)&&"scheduled_followup"===e.area)(e[t+1]))),c=()=>{var c;const{pickaxeId:d,sessionId:l,deploymentId:m,sender:u,pickaxe:p,renderResponseAction:f}=t(),{token:g}=i(),{isGenerating:v,isSwitchedToChat:h}=o(),j="string"==typeof(null==p?void 0:p.intromessage)&&0===p.intromessage.trim().length,k=f?!v:!h,x=s({queryKey:["form",d,"chat",l,m,null!==(c=null!=g?g:u)&&void 0!==c?c:null,...f?["response-references"]:[]],queryFn:()=>e(void 0,void 0,void 0,(function*(){return((s,t,o,r,i,a=!1)=>e(void 0,void 0,void 0,(function*(){const e=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pickaxeId:s},a&&{includeResponseReferences:"true"}),{sessionId:t}),o&&{deploymentId:o}),r&&{sender:r}),i&&{studioSessionToken:i})),c=yield n.get(`/conversation?${e.toString()}`),d=c.data;if(200!==c.status)throw new Error("[_getChat] Failed to fetch chat conversation "+d);return d})))(d,l,m,g?void 0:u,null!=g?g:void 0,!!f)})),select:e=>{const s=r(e.messages),t=j?s.filter((e=>"intromessage"!==e.area)):s;return Object.assign(Object.assign({},e),{messages:a(t)})},enabled:!!d&&!!l&&k,refetchInterval:!!(!!d&&!!l&&k&&!v)&&15e3,refetchIntervalInBackground:!1});return x};export{c as useConversation};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Pickaxe}from"./components/Pickaxe/index.js";export{PickaxeContext,PickaxeProvider}from"./components/Pickaxe/Provider.js";export{ResponseContext}from"./components/Pickaxe/ResponseProvider.js";export{ScrollContext,ScrollProvider}from"./components/Pickaxe/Addons/Scroll/Provider.js";export{PickaxeMarkdown,PickaxeMarkdownContext}from"./components/Pickaxe/common/PickaxeMarkdown/index.js";export{PickaxeMarkdownRenderer}from"./components/Pickaxe/common/PickaxeMarkdown/Renderer.js";export{default as PickaxeMessageParts}from"./components/Pickaxe/common/PickaxeMessageParts/index.js";export{useConversation}from"./hooks/pickaxe/useConversation.js";export{useHistory}from"./hooks/pickaxe/useHistory.js";export{useInstantPickaxe,usePickaxe}from"./hooks/pickaxe/usePickaxe.js";export{usePickaxeContext}from"./hooks/pickaxe/usePickaxeContext.js";export{useResponseContext}from"./hooks/pickaxe/useResponseContext.js";export{useDimensionContext}from"./hooks/pickaxe/useDimensionContext.js";export{useSubmitDocument}from"./hooks/pickaxe/useSubmitDocument.js";export{Inline}from"./components/EmbedPreview/Inline.js";export{FAB,FABButton}from"./components/EmbedPreview/FAB.js";export{Popup,PopupCTAButton}from"./components/EmbedPreview/Popup.js";export{ChatInput,ChatInputWrapper}from"./components/EmbedPreview/ChatInput.js";export{PickaxeArtifact}from"./components/Pickaxe/Addons/Artifact/index.js";export{default as PickaxeArtifactRenderer}from"./components/Pickaxe/Addons/Artifact/Renderer/index.js";export{ArtifactContext,ArtifactProvider}from"./components/Pickaxe/Addons/Artifact/Provider.js";export{useArtifactContext}from"./components/Pickaxe/Addons/Artifact/hooks/useArtifactContext.js";export{useArtifact}from"./components/Pickaxe/Addons/Artifact/hooks/useArtifact.js";export{ActionApprovalPart}from"./components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.js";
|
|
1
|
+
export{Pickaxe}from"./components/Pickaxe/index.js";export{PickaxeContext,PickaxeProvider}from"./components/Pickaxe/Provider.js";export{ResponseContext}from"./components/Pickaxe/ResponseProvider.js";export{ScrollContext,ScrollProvider}from"./components/Pickaxe/Addons/Scroll/Provider.js";export{PickaxeMarkdown,PickaxeMarkdownContext}from"./components/Pickaxe/common/PickaxeMarkdown/index.js";export{PickaxeMarkdownRenderer}from"./components/Pickaxe/common/PickaxeMarkdown/Renderer.js";export{default as PickaxeMessageParts}from"./components/Pickaxe/common/PickaxeMessageParts/index.js";export{default as PickaxeDownloadButton}from"./components/Pickaxe/common/PickaxeDownloadButton.js";export{default as PickaxeCopyButton}from"./components/Pickaxe/common/PickaxeCopyButton.js";export{prepareResponseDownloadText}from"./common/responseDownload.js";export{normalizeMessageParts}from"./common/chatMessages.js";export{findResponseArtifacts}from"./common/responseDownloadArtifacts.js";export{useConversation}from"./hooks/pickaxe/useConversation.js";export{useHistory}from"./hooks/pickaxe/useHistory.js";export{useInstantPickaxe,usePickaxe}from"./hooks/pickaxe/usePickaxe.js";export{usePickaxeContext}from"./hooks/pickaxe/usePickaxeContext.js";export{useResponseContext}from"./hooks/pickaxe/useResponseContext.js";export{useDimensionContext}from"./hooks/pickaxe/useDimensionContext.js";export{useSubmitDocument}from"./hooks/pickaxe/useSubmitDocument.js";export{Inline}from"./components/EmbedPreview/Inline.js";export{FAB,FABButton}from"./components/EmbedPreview/FAB.js";export{Popup,PopupCTAButton}from"./components/EmbedPreview/Popup.js";export{ChatInput,ChatInputWrapper}from"./components/EmbedPreview/ChatInput.js";export{PickaxeArtifact}from"./components/Pickaxe/Addons/Artifact/index.js";export{default as PickaxeArtifactRenderer}from"./components/Pickaxe/Addons/Artifact/Renderer/index.js";export{ArtifactContext,ArtifactProvider}from"./components/Pickaxe/Addons/Artifact/Provider.js";export{useArtifactContext}from"./components/Pickaxe/Addons/Artifact/hooks/useArtifactContext.js";export{useArtifact}from"./components/Pickaxe/Addons/Artifact/hooks/useArtifact.js";export{ActionApprovalPart}from"./components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.js";
|
|
@@ -4,9 +4,9 @@ export type EmbedAuthEvent = {
|
|
|
4
4
|
event: EmbedAuthOutcome;
|
|
5
5
|
method: EmbedAuthMethod;
|
|
6
6
|
} | {
|
|
7
|
-
event: "logout";
|
|
7
|
+
event: "logout" | "checkout";
|
|
8
8
|
};
|
|
9
|
-
type EmbedAuthEventContext = {
|
|
9
|
+
export type EmbedAuthEventContext = {
|
|
10
10
|
deploymentId?: string;
|
|
11
11
|
pickaxeId: string;
|
|
12
12
|
studioId: string;
|
|
@@ -23,4 +23,9 @@ export declare const emitSsoEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
|
23
23
|
context: EmbedAuthEventContext;
|
|
24
24
|
}) => void;
|
|
25
25
|
export declare const emitEmbedLogout: (context: EmbedAuthEventContext) => void;
|
|
26
|
-
export
|
|
26
|
+
export declare const getEmbedCheckoutSuccessUrl: (context: EmbedAuthEventContext) => string;
|
|
27
|
+
export declare const getEmbedCheckoutId: (successUrl: string) => string | undefined;
|
|
28
|
+
export declare const rememberPendingEmbedCheckout: (context: EmbedAuthEventContext, checkoutSessionId: string | undefined, successUrl: string) => void;
|
|
29
|
+
export declare const getEmbedCheckoutCancelUrl: () => string;
|
|
30
|
+
export declare const emitEmbedCheckout: (context: EmbedAuthEventContext, checkoutId?: string, parentOrigin?: string) => void;
|
|
31
|
+
export declare const emitPendingEmbedCheckout: (context: EmbedAuthEventContext, studioSessionToken?: string | null) => Promise<void>;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import type { PickaxeHistoryOriginType, PickaxeHistorySenderType } from "../../types/history";
|
|
1
|
+
import type { PickaxeHistoryOriginType, PickaxeHistorySenderType, PickaxeResponseReference } from "../../types/history";
|
|
2
2
|
import type { SetState } from "../../types/common";
|
|
3
3
|
import type { LimitedPickaxe } from "../../types/pickaxe";
|
|
4
4
|
import type { StudioFontSize, StudioFormFieldStyle, StudioButtonStyle } from "../../types/studio";
|
|
5
5
|
import { type ReactNode } from "react";
|
|
6
6
|
import { IArtifactProviderProps } from "./Addons/Artifact/Provider";
|
|
7
7
|
import { type PickaxeLimitData } from "./ResponseProvider";
|
|
8
|
+
/** A rendered response action target. messageIndex is local UI identity only,
|
|
9
|
+
* not a durable database message identifier. */
|
|
10
|
+
export type PickaxeResponseActionTarget = {
|
|
11
|
+
pickaxeId: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
kind: "chat" | "form";
|
|
14
|
+
messageIndex?: number;
|
|
15
|
+
responseReference?: PickaxeResponseReference;
|
|
16
|
+
agentName: string;
|
|
17
|
+
content: string;
|
|
18
|
+
};
|
|
19
|
+
export type PickaxeResponseActionRenderer = (target: PickaxeResponseActionTarget) => ReactNode;
|
|
8
20
|
export type PickaxeTranslations = {
|
|
9
21
|
[key: string]: string;
|
|
10
22
|
};
|
|
@@ -73,6 +85,7 @@ export type AccessGroup = {
|
|
|
73
85
|
} | null;
|
|
74
86
|
};
|
|
75
87
|
type PickaxeContextType = {
|
|
88
|
+
renderResponseAction?: PickaxeResponseActionRenderer;
|
|
76
89
|
origin: PickaxeHistoryOriginType;
|
|
77
90
|
contextId: string;
|
|
78
91
|
pickaxeId: string;
|
|
@@ -140,6 +153,7 @@ type PickaxeContextType = {
|
|
|
140
153
|
onGenerateComplete?: (responseId: string) => void;
|
|
141
154
|
};
|
|
142
155
|
export interface IPickaxeProviderProps {
|
|
156
|
+
renderResponseAction?: PickaxeResponseActionRenderer;
|
|
143
157
|
children: ReactNode;
|
|
144
158
|
origin: PickaxeHistoryOriginType;
|
|
145
159
|
sender?: string;
|
|
@@ -177,5 +191,5 @@ export interface IPickaxeProviderProps {
|
|
|
177
191
|
onSessionIdChange?: (sessionId: string) => void;
|
|
178
192
|
}
|
|
179
193
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
180
|
-
export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, portalId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, mcpEnabled, mcpGuestId, studioSessionToken, isDropShadow, allowGuestUsage, persistActiveConversation, preventInitialSessionId, onUpgrade, onGenerateComplete, onSessionIdChange, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
194
|
+
export declare const PickaxeProvider: ({ children, renderResponseAction, origin, sender: _sender, senderType: _senderType, deploymentId, portalId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, mcpEnabled, mcpGuestId, studioSessionToken, isDropShadow, allowGuestUsage, persistActiveConversation, preventInitialSessionId, onUpgrade, onGenerateComplete, onSessionIdChange, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
181
195
|
export {};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
interface PickaxeCopyButtonProps {
|
|
2
3
|
color: string;
|
|
3
4
|
text?: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
iconClassName?: string;
|
|
7
|
+
renderButton?: (state: {
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
isCopying: boolean;
|
|
10
|
+
isCopied: boolean;
|
|
11
|
+
}) => ReactNode;
|
|
6
12
|
}
|
|
7
|
-
declare const PickaxeCopyButton: ({ color, text, className, iconClassName, }: PickaxeCopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const PickaxeCopyButton: ({ color, text, className, iconClassName, renderButton, }: PickaxeCopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
14
|
export default PickaxeCopyButton;
|
|
@@ -3,6 +3,15 @@ interface PickaxeDownloadButtonProps {
|
|
|
3
3
|
/** Prepared response text; Markdown and HTML source are preserved. */
|
|
4
4
|
text: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
/** Use the saved response's workspace even when no agent is open. */
|
|
7
|
+
studioId?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Keep the menu inside a host modal's focus and pointer boundary. */
|
|
10
|
+
menuContainer?: HTMLElement | null;
|
|
11
|
+
menuColors?: {
|
|
12
|
+
background: string;
|
|
13
|
+
text: string;
|
|
14
|
+
};
|
|
6
15
|
}
|
|
7
|
-
declare const PickaxeDownloadButton: ({ color, text, disabled, }: PickaxeDownloadButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const PickaxeDownloadButton: ({ color, text, disabled, studioId, className, menuContainer, menuColors, }: PickaxeDownloadButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
17
|
export default PickaxeDownloadButton;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { PickaxeResponseReference } from "../../../types/history";
|
|
1
2
|
interface PickaxeMessageActionsProps {
|
|
2
3
|
content: string;
|
|
4
|
+
responseKind?: "chat" | "form";
|
|
5
|
+
responseReference?: PickaxeResponseReference;
|
|
6
|
+
isHideResponseAction?: boolean;
|
|
3
7
|
sessionId?: string;
|
|
4
8
|
index?: number;
|
|
5
9
|
messagesCount?: number;
|
|
@@ -10,5 +14,5 @@ interface PickaxeMessageActionsProps {
|
|
|
10
14
|
onOpenChat?: () => void;
|
|
11
15
|
onReadOut?: () => void;
|
|
12
16
|
}
|
|
13
|
-
declare const PickaxeMessageActions: ({ content, sessionId, index, messagesCount, isHideFeedback, isReadOut, isReadOutLoading, isReading, onOpenChat, onReadOut, }: PickaxeMessageActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const PickaxeMessageActions: ({ content, responseKind, responseReference, isHideResponseAction, sessionId, index, messagesCount, isHideFeedback, isReadOut, isReadOutLoading, isReading, onOpenChat, onReadOut, }: PickaxeMessageActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
18
|
export default PickaxeMessageActions;
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export * from "./components/Pickaxe/Addons/Scroll/Provider";
|
|
|
6
6
|
export * from "./components/Pickaxe/common/PickaxeMarkdown";
|
|
7
7
|
export * from "./components/Pickaxe/common/PickaxeMarkdown/Renderer";
|
|
8
8
|
export { default as PickaxeMessageParts } from "./components/Pickaxe/common/PickaxeMessageParts";
|
|
9
|
+
export { default as PickaxeDownloadButton } from "./components/Pickaxe/common/PickaxeDownloadButton";
|
|
10
|
+
export { default as PickaxeCopyButton } from "./components/Pickaxe/common/PickaxeCopyButton";
|
|
11
|
+
export { prepareResponseDownloadText } from "./common/responseDownload";
|
|
12
|
+
export { normalizeMessageParts } from "./common/chatMessages";
|
|
13
|
+
export { findResponseArtifacts } from "./common/responseDownloadArtifacts";
|
|
9
14
|
export * from "./hooks/pickaxe/useConversation";
|
|
10
15
|
export * from "./hooks/pickaxe/useHistory";
|
|
11
16
|
export * from "./hooks/pickaxe/usePickaxe";
|
|
@@ -30,7 +30,10 @@ export type PickaxeHistoryFormQuestionInputs = {
|
|
|
30
30
|
question: string;
|
|
31
31
|
answer: string;
|
|
32
32
|
};
|
|
33
|
+
/** Scoped by Pickaxe ID and session ID. Form results live on the conversation. */
|
|
34
|
+
export type PickaxeResponseReference = "form-result" | `message:${string}`;
|
|
33
35
|
export type PickaxeHistoryMessage = {
|
|
36
|
+
responseReference?: PickaxeResponseReference;
|
|
34
37
|
documentIds: string[];
|
|
35
38
|
role: PickaxeHistoryMessageRole;
|
|
36
39
|
parts: PickaxeHistoryMessagePart[];
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickaxeproject/react",
|
|
3
|
-
"version": "6.23.
|
|
3
|
+
"version": "6.23.8",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/pickaxeproject/v2-pickaxe-react.git"
|
|
8
8
|
},
|
|
9
9
|
"sideEffects": [
|
|
10
|
-
"./dist/**/node_modules/**/vscode-jsonrpc/lib/common/events.js"
|
|
10
|
+
"./dist/**/node_modules/**/vscode-jsonrpc/lib/common/events.js",
|
|
11
|
+
"./dist/**/node_modules/**/d3-transition/src/selection/index.js"
|
|
11
12
|
],
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|