@pickaxeproject/react 6.1.1-0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/validation.js +1 -0
- package/dist/cjs/components/Icons/collapse-new.svg.js +1 -0
- package/dist/cjs/components/Icons/copy-new.svg.js +1 -0
- package/dist/cjs/components/Icons/download-new.svg.js +1 -0
- package/dist/cjs/components/Icons/history.svg.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.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/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/src/common/validation.d.ts +7 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +7 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +4 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +4 -0
- package/dist/esm/common/validation.js +1 -0
- package/dist/esm/components/Icons/collapse-new.svg.js +1 -0
- package/dist/esm/components/Icons/copy-new.svg.js +1 -0
- package/dist/esm/components/Icons/download-new.svg.js +1 -0
- package/dist/esm/components/Icons/history.svg.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.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/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/src/common/validation.d.ts +7 -0
- package/dist/esm/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +7 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +4 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +4 -0
- package/package.json +207 -209
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r={"login required":"login_required","upgrade required":"upgrade_required","access denied":"access_denied"},e=e=>{var u;if("string"!=typeof e)return null;const t=e.trim().toLowerCase().replace(/[.!]+$/g,"");return null!==(u=r[t])&&void 0!==u?u:null};exports.getValidationFailure=r=>{var u;if("string"==typeof r){const u=e(r);return u?{status:u,upgradeGroups:[],upgradeUrl:null}:null}if(!r||"object"!=typeof r)return null;const t=r,l=null!==(u=e(t.message))&&void 0!==u?u:e(t.error);return l?{status:l,upgradeGroups:Array.isArray(t.upgradeGroups)?t.upgradeGroups:[],upgradeUrl:"string"==typeof t.upgradeUrl?t.upgradeUrl:null}:null};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t,n=e(require("react"));function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(null,arguments)}var a=e=>n.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 17a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"})),t||(t=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 13h-4V9M11 13l5-5"})));exports.default=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t,n=e(require("react"));function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(null,arguments)}var a=e=>n.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2"})),t||(t=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})));exports.default=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var c=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=t.createElement("path",{fill:"currentColor",d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5z"})));exports.default=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t,r=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},n.apply(null,arguments)}var a=e=>r.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),t||(t=r.createElement("path",{fill:"#000",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));exports.default=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("../hooks/useArtifactContext.js"),r=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Scroll/hooks/useScroll.js"),i=require("../hooks/useArtifact.js"),l=require("react-to-print"),s=require("../../../common/PickaxeMarkdown/index.js"),c=require("../../../common/PickaxeMarkdown/Renderer.js"),d=require("react-syntax-highlighter"),p=require("../../../../../common/docx/index.js"),u=require("file-saver"),m=require("../../Scroll/ScrollLockView.js"),x=require("../../../../Icons/x.svg.js"),v=require("../../../../Icons/save.svg.js"),f=require("../../../../Icons/expand.svg.js"),y=require("../../../../Icons/shrink.svg.js"),g=require("../../../../Icons/copy.svg.js"),h=require("../../../common/PickaxeCopyButton.js"),b=require("../../../../Core/ScrollArea.js"),j=require("../../../../Core/TipContainer.js"),w=require("../MermaidRenderer.js"),C=require("./SaveMenu.js"),k=require("./ViewOptions.js"),F=require("csv-to-markdown-table"),T=require("copy-to-clipboard"),O=require("../../../../../common/cn.js");function S(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var A=S(u),q=S(F),D=S(T);const E="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co";exports.default=u=>{var F,T,S,N;const{artifacts:M,currentPopupType:_,currentArtifact:B,setCurrentArtifact:P}=n.useArtifactContext(),{onLoadArtifact:R}=i.useArtifact(),{styles:$,colors:z,translations:W}=r.usePickaxeContext(),[L,H]=o.useState("code"),[I,V]=o.useState(!1),X=o.useRef(),G=o.useRef(null),J=o.useRef(null),K=l.useReactToPrint({contentRef:X}),{scrollContainerRef:Q,scrollStartSession:U,scrollToBottom:Y,scrollEndSession:Z}=a.useScroll({auto:"code"===L}),ee=null!==(T=null===(F=u.styling)||void 0===F?void 0:F.styles)&&void 0!==T?T:$,te=null!==(N=null===(S=u.styling)||void 0===S?void 0:S.colors)&&void 0!==N?N:z,oe=o.useMemo((()=>{var e,t,o,n,r;if(!u.artifact&&!B)return null;const a=null!==(t=null===(e=u.artifact)||void 0===e?void 0:e.id)&&void 0!==t?t:null==B?void 0:B.id,i=null!==(n=null===(o=u.artifact)||void 0===o?void 0:o.version)&&void 0!==n?n:null==B?void 0:B.version;return null!==(r=M.find((e=>e.id===a&&e.version===i)))&&void 0!==r?r:null}),[B,M,u.artifact]),ne=o.useMemo((()=>oe?"text/csv"===oe.type?q.default(oe.content,",",!0):"text/tab-separated-values"===oe.type?q.default(oe.content,"\t",!0):null:null),[oe]),re=o.useMemo((()=>(te.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==te?void 0:te.secondaryText]),ae=o.useMemo((()=>{const e=u.artifact&&(null==B?void 0:B.id)===u.artifact.id&&(null==B?void 0:B.version)===u.artifact.version;return"inline"===u.type&&("inline-form"===_?!!B:e)}),[B,_,u.type,u.artifact]);o.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"inline"===u.type&&u.artifact&&(M.some((e=>u.artifact&&e.id===u.artifact.id&&e.version===u.artifact.version))||R({id:u.artifact.id,version:u.artifact.version}))}))}),[M,u.type,u.artifact]),o.useEffect((()=>{if("application/vnd.pxe.code"===(null==oe?void 0:oe.type)&&H("code"),"finished"!==(null==oe?void 0:oe.status))return H("code"),U(),void Y();Z(),"application/vnd.pxe.code"!==oe.type&&H("render")}),[null==oe?void 0:oe.status,null==oe?void 0:oe.type]),o.useEffect((()=>{var e;!J.current||"text/html"!==(null==oe?void 0:oe.type)&&"application/vnd.pxe.react"!==(null==oe?void 0:oe.type)||null===(e=J.current.contentWindow)||void 0===e||e.postMessage({type:"text/html"===oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},E)}),[null==oe?void 0:oe.content,null==oe?void 0:oe.type]);const ie=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;if("text/html"===oe.type){const e=oe.content,t=window.open("","_blank");return void(t&&(t.document.open(),t.document.write(e),t.document.close(),t.focus(),t.print()))}const e=L;"code"===e&&(H("render"),yield new Promise((e=>setTimeout(e,50)))),K(),"code"===e&&H(e)})),le=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;const e=yield p.convertMarkdownToDocx(oe.content);p.downloadDocx(e,`${oe.title}.docx`)})),se=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!oe)return;let o={mimeType:"text/plain",extension:".txt"};switch(t){case"text/markdown":o={mimeType:"text/markdown",extension:".md"};break;case"text/html":o={mimeType:"text/html",extension:".html"};break;case"text/csv":o={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":o={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":o={mimeType:"image/svg+xml",extension:".svg"};break;case"application/vnd.pxe.code":o={mimeType:`application/${oe.programmingLanguage||"text"};charset=utf-8`,extension:`.${oe.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":o={mimeType:"text/typescript",extension:".tsx"};break;default:o={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===oe.type){const t=L;"code"===t&&(H("render"),yield new Promise((e=>setTimeout(e,50))));const o=null===(e=G.current)||void 0===e?void 0:e.querySelector("svg");o&&(n=(new XMLSerializer).serializeToString(o)),"code"===t&&H(t)}const r=new Blob([null!=n?n:oe.content],{type:o.mimeType});A.default(r,`${oe.title}${o.extension}`)}));return oe?t.jsxs("div",Object.assign({className:O.default("pxe-artifact-renderer flex flex-col","inline"===u.type&&!ae&&"min-h-[320px] mb-6",u.className),style:Object.assign(Object.assign({backgroundColor:te.secondary,color:te.secondaryText},"auto"!==_&&{borderRadius:ee.cornerRadius}),u.style)},{children:[t.jsxs("div",Object.assign({className:"flex items-center gap-6 justify-between p-4 shadow-sm"},{children:[t.jsxs("div",Object.assign({className:"pxe-artifact-create-header flex items-center gap-4 truncate"},{children:[(ae||!_.startsWith("inline"))&&t.jsx(k.default,{type:oe.type,view:L,colors:te,onChange:H}),t.jsx("p",Object.assign({className:"font-semilight truncate text-xl"},{children:oe.title}))]})),t.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:["code"===L&&(ae||!_.startsWith("inline"))&&t.jsxs("button",Object.assign({className:"font-semibold text-sm select-none flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-50 shrink-0",style:{color:te.secondaryText},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{D.default(oe.content),V(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{V(!1)}}))},{children:[t.jsx(g.default,{className:"w-5 h-5 shrink-0"}),(null==W?void 0:W.copy)||"Copy"]})),(ae||!_.startsWith("inline"))&&t.jsx(C.default,Object.assign({variant:"anchor",className:"px-3 py-1.5 shrink-0",data:oe,colors:te,onDownload:se,onSaveAsPDF:ie,onSaveAsDOCX:le},{children:t.jsx("span",Object.assign({className:"shrink-0 font-semibold text-sm select-none"},{children:(null==W?void 0:W["save-as"])||"Save as"}))})),t.jsx("button",Object.assign({style:{color:te.secondaryText},onClick:()=>{"inline"!==u.type||!u.artifact||ae?P(null):P({id:u.artifact.id,version:u.artifact.version})}},{children:"inline"===u.type?ae?t.jsx(y.default,{className:"w-6 h-6 shrink-0"}):t.jsx(f.default,{className:"w-6 h-6 shrink-0"}):t.jsx(x.default,{className:"w-6 h-6 shrink-0"})}))]}))]})),t.jsx("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:t.jsxs(b.default,Object.assign({ref:Q,innerClassName:"flex-grow w-full"},{children:["render"===L&&"application/vnd.pxe.code"!==oe.type?t.jsx("div",Object.assign({ref:X,className:O.default("p-4 pb-6 flex-grow flex flex-col","application/vnd.pxe.react"===oe.type&&"p-0","text/html"===oe.type&&"p-0","text/csv"===oe.type&&"p-0")},{children:"text/markdown"===oe.type||"text/csv"===oe.type||"text/tab-separated-values"===oe.type||"image/svg+xml"===oe.type?t.jsx(s.PickaxeMarkdown,Object.assign({theme:ee.theme,colors:te},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:null!=ne?ne:oe.content,className:O.default("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===oe.type||"text/tab-separated-values"===oe.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===oe.type?t.jsx(w.default,{ref:G,id:`mermaid-${oe.id}-${oe.version}`,data:oe.content}):"text/html"===oe.type||"application/vnd.pxe.react"===oe.type?t.jsx("iframe",Object.assign({ref:J,title:oe.title,src:`${E}/${"text/html"===oe.type?"html":"react"}?theme=${re?"dark":"light"}&bg=${te.secondary}&accent=${te.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==te?void 0:te.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const t=e.target;setTimeout((()=>{var e;try{null===(e=t.contentWindow)||void 0===e||e.postMessage({type:"text/html"===oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},E)}catch(e){console.error("Error sending message to iframe:",e)}}),100),Y()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t.jsx(d.Prism,Object.assign({PreTag:"div",language:"text/markdown"===oe.type?"markdown":"text/html"===oe.type||"image/svg+xml"===oe.type?"xml":"application/vnd.pxe.react"===oe.type?"typescript":oe.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},re&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},re&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==te?void 0:te.secondary}),':not(pre) > code[class*="language-"]':{background:null==te?void 0:te.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!re&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:oe.content})),t.jsx(m.default,{})]}))})),"inline"===u.type&&!ae&&t.jsxs("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t.jsx(j.default,Object.assign({id:`artifact-copy-${oe.id}-${oe.version}`,tip:(null==W?void 0:W.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(h.default,{color:te.secondaryText,text:oe.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t.jsx(j.default,Object.assign({id:`artifact-save-${oe.id}-${oe.version}`,tip:(null==W?void 0:W.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:ie,onSaveAsDOCX:le},{children:t.jsx("button",Object.assign({style:{color:te.secondaryText}},{children:t.jsx(v.default,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("../hooks/useArtifactContext.js"),a=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Scroll/hooks/useScroll.js"),r=require("../hooks/useArtifact.js"),l=require("react-to-print"),s=require("../../../common/PickaxeMarkdown/index.js"),c=require("../../../common/PickaxeMarkdown/Renderer.js"),d=require("react-syntax-highlighter"),p=require("../../../../../common/docx/index.js"),u=require("file-saver"),x=require("../../Scroll/ScrollLockView.js"),m=require("../../../../Icons/expand.svg.js"),y=require("../../../../Icons/shrink.svg.js"),v=require("../../../../Icons/collapse-new.svg.js"),f=require("../../../../Icons/copy-new.svg.js"),g=require("../../../../Icons/download-new.svg.js"),b=require("../../../common/PickaxeCopyButton.js"),h=require("../../../../Core/ScrollArea.js"),j=require("../../../../Core/TipContainer.js"),w=require("../MermaidRenderer.js"),C=require("./SaveMenu.js"),k=require("./ViewOptions.js"),T=require("csv-to-markdown-table"),F=require("copy-to-clipboard"),O=require("../../../../../common/cn.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=A(u),D=A(T),N=A(F);const q="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co";exports.default=u=>{var T,F,A,E;const{artifacts:M,currentPopupType:_,currentArtifact:B,setCurrentArtifact:P}=n.useArtifactContext(),{onLoadArtifact:R}=r.useArtifact(),{styles:$,colors:z,translations:L}=a.usePickaxeContext(),[W,H]=o.useState("code"),[I,V]=o.useState(!1),X=o.useRef(),G=o.useRef(null),J=o.useRef(null),K=l.useReactToPrint({contentRef:X}),{scrollContainerRef:Q,scrollStartSession:U,scrollToBottom:Y,scrollEndSession:Z}=i.useScroll({auto:"code"===W}),ee=null!==(F=null===(T=u.styling)||void 0===T?void 0:T.styles)&&void 0!==F?F:$,te=null!==(E=null===(A=u.styling)||void 0===A?void 0:A.colors)&&void 0!==E?E:z,oe=o.useMemo((()=>{var e,t,o,n,a;if(!u.artifact&&!B)return null;const i=null!==(t=null===(e=u.artifact)||void 0===e?void 0:e.id)&&void 0!==t?t:null==B?void 0:B.id,r=null!==(n=null===(o=u.artifact)||void 0===o?void 0:o.version)&&void 0!==n?n:null==B?void 0:B.version;return null!==(a=M.find((e=>e.id===i&&e.version===r)))&&void 0!==a?a:null}),[B,M,u.artifact]),ne=o.useMemo((()=>oe?"text/csv"===oe.type?D.default(oe.content,",",!0):"text/tab-separated-values"===oe.type?D.default(oe.content,"\t",!0):null:null),[oe]),ae=o.useMemo((()=>(te.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==te?void 0:te.secondaryText]),ie=o.useMemo((()=>{const e=u.artifact&&(null==B?void 0:B.id)===u.artifact.id&&(null==B?void 0:B.version)===u.artifact.version;return"inline"===u.type&&("inline-form"===_?!!B:e)}),[B,_,u.type,u.artifact]);o.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"inline"===u.type&&u.artifact&&(M.some((e=>u.artifact&&e.id===u.artifact.id&&e.version===u.artifact.version))||R({id:u.artifact.id,version:u.artifact.version}))}))}),[M,u.type,u.artifact]),o.useEffect((()=>{if("application/vnd.pxe.code"===(null==oe?void 0:oe.type)&&H("code"),"finished"!==(null==oe?void 0:oe.status))return H("code"),U(),void Y();Z(),"application/vnd.pxe.code"!==oe.type&&H("render")}),[null==oe?void 0:oe.status,null==oe?void 0:oe.type]),o.useEffect((()=>{var e;!J.current||"text/html"!==(null==oe?void 0:oe.type)&&"application/vnd.pxe.react"!==(null==oe?void 0:oe.type)||null===(e=J.current.contentWindow)||void 0===e||e.postMessage({type:"text/html"===oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}),[null==oe?void 0:oe.content,null==oe?void 0:oe.type]);const re=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;if("text/html"===oe.type){const e=oe.content,t=window.open("","_blank");return void(t&&(t.document.open(),t.document.write(e),t.document.close(),t.focus(),t.print()))}const e=W;"code"===e&&(H("render"),yield new Promise((e=>setTimeout(e,50)))),K(),"code"===e&&H(e)})),le=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!oe)return;const e=yield p.convertMarkdownToDocx(oe.content);p.downloadDocx(e,`${oe.title}.docx`)})),se=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!oe)return;let o={mimeType:"text/plain",extension:".txt"};switch(t){case"text/markdown":o={mimeType:"text/markdown",extension:".md"};break;case"text/html":o={mimeType:"text/html",extension:".html"};break;case"text/csv":o={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":o={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":o={mimeType:"image/svg+xml",extension:".svg"};break;case"application/vnd.pxe.code":o={mimeType:`application/${oe.programmingLanguage||"text"};charset=utf-8`,extension:`.${oe.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":o={mimeType:"text/typescript",extension:".tsx"};break;default:o={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===oe.type){const t=W;"code"===t&&(H("render"),yield new Promise((e=>setTimeout(e,50))));const o=null===(e=G.current)||void 0===e?void 0:e.querySelector("svg");o&&(n=(new XMLSerializer).serializeToString(o)),"code"===t&&H(t)}const a=new Blob([null!=n?n:oe.content],{type:o.mimeType});S.default(a,`${oe.title}${o.extension}`)})),ce=()=>{"inline"!==u.type||!u.artifact||ie?P(null):P({id:u.artifact.id,version:u.artifact.version})},de=ie||!_.startsWith("inline");return oe?t.jsxs("div",Object.assign({className:O.default("pxe-artifact-renderer flex flex-col","inline"===u.type&&!ie&&"min-h-[320px] mb-6",u.className),style:Object.assign(Object.assign({backgroundColor:te.secondary,color:te.secondaryText},"auto"!==_&&{borderRadius:ee.cornerRadius}),u.style)},{children:[t.jsxs("div",Object.assign({className:"flex items-center gap-4 justify-between px-4 py-3 shadow-sm"},{children:[t.jsxs("div",Object.assign({className:"pxe-artifact-create-header flex min-w-0 items-center gap-4"},{children:[de&&t.jsx(k.default,{type:oe.type,view:W,colors:te,onChange:H}),t.jsx("p",Object.assign({className:"w-[220px] max-w-full truncate text-[18px] font-semilight leading-tight",title:oe.title},{children:oe.title}))]})),"inline"===u.type&&!de&&t.jsx("div",Object.assign({className:"shrink-0"},{children:t.jsx("button",Object.assign({type:"button",style:{color:te.secondaryText},onClick:ce,title:(null==L?void 0:L.expand)||"Expand","aria-label":(null==L?void 0:L.expand)||"Expand artifact"},{children:ie?t.jsx(y.default,{className:"w-6 h-6 shrink-0"}):t.jsx(m.default,{className:"w-6 h-6 shrink-0"})}))}))]})),de&&t.jsx("div",Object.assign({className:"flex items-center justify-between border-y px-4 py-2.5",style:{borderColor:te.primary}},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100",style:{color:te.secondaryText},onClick:ce,title:"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse":(null==L?void 0:L.close)||"Close","aria-label":"inline"===u.type?(null==L?void 0:L.collapse)||"Collapse artifact":(null==L?void 0:L.close)||"Close artifact"},{children:t.jsx(v.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",style:{color:te.secondaryText},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(oe)try{N.default(oe.content),V(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{V(!1)}})),title:(null==L?void 0:L.copy)||"Copy","aria-label":(null==L?void 0:L.copy)||"Copy artifact content"},{children:t.jsx(f.default,{className:"h-[18px] w-[18px] shrink-0"})})),t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le,className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100"},{children:t.jsx("div",Object.assign({role:"button",className:"cursor-pointer",style:{color:te.secondaryText},title:(null==L?void 0:L.save)||"Download","aria-label":(null==L?void 0:L.save)||"Download artifact content"},{children:t.jsx(g.default,{className:"h-6 w-6 shrink-0"})}))}))]}))})),t.jsx("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:t.jsxs(h.default,Object.assign({ref:Q,innerClassName:"flex-grow w-full"},{children:["render"===W&&"application/vnd.pxe.code"!==oe.type?t.jsx("div",Object.assign({ref:X,className:O.default("p-4 pb-6 flex-grow flex flex-col","application/vnd.pxe.react"===oe.type&&"p-0","text/html"===oe.type&&"p-0","text/csv"===oe.type&&"p-0")},{children:"text/markdown"===oe.type||"text/csv"===oe.type||"text/tab-separated-values"===oe.type||"image/svg+xml"===oe.type?t.jsx(s.PickaxeMarkdown,Object.assign({theme:ee.theme,colors:te},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:null!=ne?ne:oe.content,className:O.default("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===oe.type||"text/tab-separated-values"===oe.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===oe.type?t.jsx(w.default,{ref:G,id:`mermaid-${oe.id}-${oe.version}`,data:oe.content}):"text/html"===oe.type||"application/vnd.pxe.react"===oe.type?t.jsx("iframe",Object.assign({ref:J,title:oe.title,src:`${q}/${"text/html"===oe.type?"html":"react"}?theme=${ae?"dark":"light"}&bg=${te.secondary}&accent=${te.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==te?void 0:te.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const t=e.target;setTimeout((()=>{var e;try{null===(e=t.contentWindow)||void 0===e||e.postMessage({type:"text/html"===oe.type?"HTML_CODE":"REACT_CODE",content:oe.content},q)}catch(e){console.error("Error sending message to iframe:",e)}}),100),Y()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t.jsx(d.Prism,Object.assign({PreTag:"div",language:"text/markdown"===oe.type?"markdown":"text/html"===oe.type||"image/svg+xml"===oe.type?"xml":"application/vnd.pxe.react"===oe.type?"typescript":oe.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ae&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==te?void 0:te.secondaryText},ae&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==te?void 0:te.secondary}),':not(pre) > code[class*="language-"]':{background:null==te?void 0:te.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!ae&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==te?void 0:te.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:oe.content})),t.jsx(x.default,{})]}))})),"inline"===u.type&&!ie&&t.jsxs("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t.jsx(j.default,Object.assign({id:`artifact-copy-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(b.default,{color:te.secondaryText,text:oe.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t.jsx(j.default,Object.assign({id:`artifact-save-${oe.id}-${oe.version}`,tip:(null==L?void 0:L.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:te.secondary,color:te.secondaryText,fontSize:"12px"},align:"bottom"},{children:t.jsx(C.default,Object.assign({data:oe,colors:te,onDownload:se,onSaveAsPDF:re,onSaveAsDOCX:le},{children:t.jsx("button",Object.assign({style:{color:te.secondaryText}},{children:t.jsx(g.default,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../../../common/cn.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../../../common/cn.js"),n=require("react"),a=require("lucide-react"),i=require("../../../Icons/trash-2.svg.js"),r=require("../../../Icons/pencil.svg.js");exports.EditableNavPill=({text:l,className:o,onRename:c,onDelete:u,isDarkGlass:d})=>{const[m,x]=n.useState(!1),[p,f]=n.useState(!1),[h,j]=n.useState(l),[g,b]=n.useState(!1),v=n.useRef(null),w=n.useRef(null);n.useEffect((()=>{p||j(l)}),[l,p]),n.useEffect((()=>{const e=e=>{w.current&&!w.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const N=()=>e.__awaiter(void 0,void 0,void 0,(function*(){h.trim()&&(b(!0),yield c(h),b(!1),f(!1))})),k=()=>{j(l),f(!1)};return s.jsxs("div",Object.assign({ref:w,className:"relative z-40 h-full shrink min-w-0",onMouseDown:e=>{e.preventDefault()}},{children:[s.jsx("div",Object.assign({className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",o),onClick:e=>{e.stopPropagation(),p||m?m&&x(!1):x(!0)}},{children:p?s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:h,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&k()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),s.jsx("button",Object.assign({onClick:N,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(a.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:k,disabled:g,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(a.X,{className:"h-4 w-4"})}))]})):s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:l})),s.jsx(a.MoreHorizontal,{className:t.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),m&&s.jsxs("div",Object.assign({className:t.default("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",d?"bg-[#313131] text-white":"bg-white text-black"),ref:v},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),x(!1),f(!0)},className:t.default("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",d?"border-current":"border-[#EBEAEB]")},{children:[s.jsx(r.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),x(!1),u()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[s.jsx(i.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))},exports.HistoryPill=({icon:e,className:n,onClick:a})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==a||a()},className:t.default("relative flex items-center justify-center h-full aspect-square p-2 md:p-3 shrink-0 transition-all duration-200 cursor-pointer","glass rounded-full",n),onMouseDown:e=>{e.preventDefault()}},{children:s.jsx("div",Object.assign({className:"flex items-center justify-center z-20"},{children:e}))})),exports.NavPill=({text:e,icon:n,className:a,onClick:i})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==i||i()},className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",a),onMouseDown:e=>{e.preventDefault()}},{children:s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[n&&s.jsx("img",{src:n,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),N=require("../../../common/cn.js"),C=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=_(n);const T=s.forwardRef((({resubmitPrompt:_,onFocus:T,onBlur:A,onInputHeightChange:R,initSmitheryAuthData:q},P)=>{var D,L,U;const{origin:M,pickaxeId:$,sessionId:B,sender:F,senderType:H,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:V,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,onGenerateComplete:ie}=i.usePickaxeContext(),{token:oe,isLoggedOut:re,isSent:ae,isPricingAuth:le}=d.useAuthContext(),{messages:ce,isGenerating:de,setMessages:ue,setStatus:fe,setLimitData:pe,setError:me}=o.useResponseContext(),{documents:ge,isUploading:he,documentError:ve,onFileUpload:be,setDocuments:xe,setDocumentError:ye}=u.useDocument(),{studio:je}=I.useStudio(),{scrollStartSession:we,scrollEndSession:Oe,scrollToBottom:ke}=f.useScroll({auto:!0}),{artifacts:Se,currentPopupType:Ne,setArtifacts:Ce,setCurrentArtifact:Ie}=p.useArtifactContext(),{height:_e}=c.useDimensionContext(),Ee=l.useConversation(),[Te,Ae]=s.useState(""),[Re,qe]=s.useState(!1),[Pe,De]=s.useState(!1),[Le,Ue]=s.useState(null),[Me,$e]=s.useState(null),[Be,Fe]=s.useState(!1),He=s.useRef(null),Xe=s.useRef(""),Ke=s.useRef(null),We=s.useRef(null),Je=s.useRef(null),Ve=s.useRef(null),ze=s.useRef(null),Ge=Math.max(.4*_e,100),{transcript:Qe,listening:Ye,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=n.useSpeechRecognition(),[tt]=g.useMediaQuery("(max-width: 480px)"),st=m.useHover(),{isHover:nt}=st,it=e.__rest(st,["isHover"]),ot=m.useHover(),{isHover:rt}=ot,at=e.__rest(ot,["isHover"]),lt=m.useHover(),{isHover:ct}=lt,dt=e.__rest(lt,["isHover"]),ut=a.useStyleFontSize(),ft=r.useStyleInput(),pt="undefined"!=typeof window?window.location.hostname:"",mt="undefined"!=typeof window?window.location.href:"",gt="undefined"!=typeof window&&window.self!==window.top,ht=pt.includes("pickaxe.co")&&!mt.includes("https://studio.pickaxe.co/_embed")&&!gt,vt=null===(D=null==J?void 0:J.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),bt=et&&(null==J?void 0:J.enablevoicetotext),xt="chat-input"===W&&Y&&!ae,yt="chat-input"===W&&le&&re&&ae,jt=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",wt=Re||Pe,Ot=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==J?void 0:J.studioid},F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ht&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ue(t.studioUser),$e(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,B,H,F,oe,X,K,ht]);s.useEffect((()=>{Ot()}),[Ot]);const kt=(null==te?void 0:te.limit)||0,St=(null==Le?void 0:Le.currentUses)||0,Nt=(null==Le?void 0:Le.extraUses)||0,Ct=!!(null==je?void 0:je.data.usage)&&je.data.usage.isCredits,It=kt>St?kt-St+Nt:Nt,_t=s.useMemo((()=>!!Le&&(!Be&&(!(kt<=0)&&It<=.05*kt))),[Le,Be,It,kt]),Et=s.useMemo((()=>{var e,t,s;return!!Y&&(!!J&&(!Ee.isLoading&&(!((null!==(t=null===(e=Ee.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!xt)))))}),[J,Y,ee,xt,Ee.data,Ee.isLoading]),Tt=s.useMemo((()=>{if(de||he)return!1;const e=ge.length>0&&ge.every((e=>"finished"===e.status));return!(!Te.trim()&&!e)&&ge.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[de,he,Te,ge]);s.useImperativeHandle(P,(()=>({onSubmit:At}))),s.useEffect((()=>{ne(Et)}),[Et]),s.useEffect((()=>{var e;if(_){const t=Array.from(ce),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;At(s,!0)}}),[_]),s.useEffect((()=>{if(!Ve.current||!R)return;const e=new ResizeObserver((e=>{for(const t of e)R(t.contentRect.height)}));return e.observe(Ve.current),()=>{e.disconnect()}}),[R]),s.useEffect((()=>{if(!Ye)return;const e=Xe.current?`${Xe.current} `:"";Ae(`${e}${Qe}`)}),[Qe,Ye]),s.useEffect((()=>{if(!We.current)return;(()=>{if(!We.current)return;let e=We.current.scrollHeight>52;Te.includes("\n")||ge.length?e=!0:Te.trim()||(e=!1),qe(e)})()}),[Te,ge]),s.useEffect((()=>{const e=We.current,t=Je.current;if(!e||!t||Re||Te.includes("\n"))return void De(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Te||jt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;De(o>l)}),[Te,Re,jt]);const At=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(de||he)return;const o=ge.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:Te;if(!c&&!l)return;me(""),ye(""),pe(null),Ae(""),se(!1),fe("fetching"),we(),ke();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ce.slice(0,ce.length-1)):Array.from(ce),...s?[]:[{id:ce.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ce.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ue(u),ke(),d&&xe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:B,senderType:H,value:c},d&&{documentIds:r}),F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},ht&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;fe("streaming"),ze.current=new AbortController;const g=u.length-1,h=[];let b=[...null!=Se?Se:[]],x=0,y=!1,j="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${x}`,{signal:null===(i=ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return me(t),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ue([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:ce.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce([...b]),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ce(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ce(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);me(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ie||ie(B)}catch(e){if(e.limitData)pe(e.limitData),me("");else{let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),me(t)}}finally{ke(),fe("idle"),Oe(),Ke.current=null,yield Ot()}}));return yt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!xt&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ve,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===V.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ft),{maxHeight:`${Ge}px`,overflowY:"auto"})},{children:[_t&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:ft.backgroundColor?`${ft.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:V.cornerRadius+"px",borderTopLeftRadius:V.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[It," ",Ct?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Me}${null==te?void 0:te.accessGroupId}`;C.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Fe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!de&&ge.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:de}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ye&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(U=z.accent)&&void 0!==U?U:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:We,className:N.default(ut.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Te.trim()&&!Te.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",wt&&"mb-12",Ye&&"text-transparent"),value:Te,placeholder:jt,onChange:e=>{if(Ae(e),R){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void R(0);if(t>=11)return;let s=0;t>1&&(s=50),R(24*(t-1)+s)}},onKeyDown:e=>{Q||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),he||de||At()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield be(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Je,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",wt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!wt&&ft.backgroundColor&&{backgroundColor:ft.backgroundColor}),{borderTopRightRadius:V.cornerRadius+"px",borderBottomRightRadius:V.cornerRadius+"px"})},{children:de?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ze.current&&(ze.current.abort(),ze.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),fe("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Ye?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:E.default.stopListening,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[vt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?z.accent+"10":void 0,color:rt?z.accent:z.accent+"80"},disabled:he||de,onClick:()=>{var e;return null===(e=He.current)||void 0===e?void 0:e.click()}},at,{children:[t.jsx("input",{id:"file-upload",ref:He,type:"file",accept:[...h.allowedFileMimeTypes,...h.allowedImageMimeTypes,...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield be(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),bt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ye?z.accent:ct?z.accent+"10":void 0,color:Ye?z.accentText:ct?z.accent:z.accent+"80"},disabled:he||de,onClick:()=>{Ye?E.default.stopListening():(Xe.current=Te,Ze(),E.default.startListening({continuous:!0,interimResults:!0,language:G||"en-US"}))}},dt,{children:t.jsx(y.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||Tt?z.accent:z.accent+"10",color:nt||Tt?z.accentText:z.accent+"80"},disabled:!Tt,onClick:()=>At()},it,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),ve&&t.jsx(k.default,{error:ve,className:"mt-3"})]}))}))}));T.displayName="Input",exports.default=T;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),j=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),C=require("../../../common/validation.js"),N=require("../../../common/cn.js"),I=require("../../../common/utils.js"),_=require("../../../hooks/studio/useStudio.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var T=E(n);const A=s.forwardRef((({resubmitPrompt:E,onFocus:A,onBlur:R,onInputHeightChange:q,initSmitheryAuthData:P},D)=>{var U,L,M;const{origin:$,pickaxeId:F,sessionId:B,sender:H,senderType:V,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:z,colors:G,locale:Q,forceMobile:Y,isNewChat:Z,isRtl:ee,isShowFeedbackMessage:te,accessGroup:se,setIsNewChat:ne,setIsShowIceBreaker:ie,setValidationStatus:re,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:ae,onGenerateComplete:le}=i.usePickaxeContext(),{token:ce,isLoggedOut:de,isSent:ue,isPricingAuth:fe}=d.useAuthContext(),{messages:pe,isGenerating:me,setMessages:ge,setStatus:he,setLimitData:ve,setError:be}=r.useResponseContext(),{documents:xe,isUploading:je,documentError:ye,onFileUpload:we,setDocuments:Oe,setDocumentError:ke}=u.useDocument(),{studio:Se}=_.useStudio(),{scrollStartSession:Ce,scrollEndSession:Ne,scrollToBottom:Ie}=f.useScroll({auto:!0}),{artifacts:_e,currentPopupType:Ee,setArtifacts:Te,setCurrentArtifact:Ae}=p.useArtifactContext(),{height:Re}=c.useDimensionContext(),qe=l.useConversation(),[Pe,De]=s.useState(""),[Ue,Le]=s.useState(!1),[Me,$e]=s.useState(!1),[Fe,Be]=s.useState(null),[He,Ve]=s.useState(null),[Xe,Ke]=s.useState(!1),We=s.useRef(null),Je=s.useRef(""),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=s.useRef(null),et=Math.max(.4*Re,100),{transcript:tt,listening:st,resetTranscript:nt,browserSupportsSpeechRecognition:it}=n.useSpeechRecognition(),[rt]=g.useMediaQuery("(max-width: 480px)"),ot=m.useHover(),{isHover:at}=ot,lt=e.__rest(ot,["isHover"]),ct=m.useHover(),{isHover:dt}=ct,ut=e.__rest(ct,["isHover"]),ft=m.useHover(),{isHover:pt}=ft,mt=e.__rest(ft,["isHover"]),gt=a.useStyleFontSize(),ht=o.useStyleInput(),vt="undefined"!=typeof window?window.location.hostname:"",bt="undefined"!=typeof window?window.location.href:"",xt="undefined"!=typeof window&&window.self!==window.top,jt=vt.includes("pickaxe.co")&&!bt.includes("https://studio.pickaxe.co/_embed")&&!xt,yt=null===(U=null==J?void 0:J.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),wt=it&&(null==J?void 0:J.enablevoicetotext),Ot="chat-input"===W&&Z&&!ue,kt="chat-input"===W&&fe&&de&&ue,St=s.useCallback((e=>{const t=C.getValidationFailure(e);return!!t&&(be(""),ve(null),re(t.status),oe(t.upgradeGroups),ae(t.upgradeUrl),!0)}),[be,ve,re,oe,ae]),Ct=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:ee?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Nt=Ue||Me,It=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==J?void 0:J.studioid},H&&{sender:H}),ce&&{studioSessionToken:ce}),!ce&&!H&&{sender:I.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),jt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Be(t.studioUser),Ve(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[$,F,B,V,H,ce,X,K,jt]);s.useEffect((()=>{It()}),[It]);const _t=(null==se?void 0:se.limit)||0,Et=(null==Fe?void 0:Fe.currentUses)||0,Tt=(null==Fe?void 0:Fe.extraUses)||0,At=!!(null==Se?void 0:Se.data.usage)&&Se.data.usage.isCredits,Rt=_t>Et?_t-Et+Tt:Tt,qt=s.useMemo((()=>!!Fe&&(!Xe&&(!(_t<=0)&&Rt<=.05*_t))),[Fe,Xe,Rt,_t]),Pt=s.useMemo((()=>{var e,t,s;return!!Z&&(!!J&&(!qe.isLoading&&(!((null!==(t=null===(e=qe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!te&&!Ot)))))}),[J,Z,te,Ot,qe.data,qe.isLoading]),Dt=s.useMemo((()=>{if(me||je)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Pe.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[me,je,Pe,xe]);s.useImperativeHandle(D,(()=>({onSubmit:Ut}))),s.useEffect((()=>{ie(Pt)}),[Pt]),s.useEffect((()=>{var e;if(E){const t=Array.from(pe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ut(s,!0)}}),[E]),s.useEffect((()=>{if(!Ye.current||!q)return;const e=new ResizeObserver((e=>{for(const t of e)q(t.contentRect.height)}));return e.observe(Ye.current),()=>{e.disconnect()}}),[q]),s.useEffect((()=>{if(!st)return;const e=Je.current?`${Je.current} `:"";De(`${e}${tt}`)}),[tt,st]),s.useEffect((()=>{if(!Ge.current)return;(()=>{if(!Ge.current)return;let e=Ge.current.scrollHeight>52;Pe.includes("\n")||xe.length?e=!0:Pe.trim()||(e=!1),Le(e)})()}),[Pe,xe]),s.useEffect((()=>{const e=Ge.current,t=Qe.current;if(!e||!t||Ue||Pe.includes("\n"))return void $e(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Pe||Ct,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;$e(r>l)}),[Pe,Ue,Ct]);const Ut=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(me||je)return;const r=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Pe;if(!c&&!l)return;be(""),ke(""),ve(null),De(""),ne(!1),he("fetching"),Ce(),Ie();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,u=[...s?Array.from(pe.slice(0,pe.length-1)):Array.from(pe),...s?[]:[{id:pe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?o:[]}],{id:pe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ge(u),Ie(),d&&Oe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:$,pickaxeId:F,sessionId:B,senderType:V,value:c},d&&{documentIds:o}),H&&{sender:H}),ce&&{studioSessionToken:ce}),!ce&&!H&&{sender:I.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},jt&&{credentials:"include"})),p=yield f.json();if(!p.success){if(St(p))return;const e=new Error(p.error||p.message||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;he("streaming"),Ze.current=new AbortController;const g=u.length-1,h=[];let b=[...null!=_e?_e:[]],x=0,j=!1,y="";for(;!j;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${x}`,{signal:null===(i=Ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ze.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return St(t)||be(s),void(j=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&P){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw j=!0,P({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw j=!0,P({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,h[h.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,h[h.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ge([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:pe.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te([...b]),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Te(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong, please try again.";if(St(t))return void(j=!0);be(s)}else"stop"===e.event&&(j=!0)}else j=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}j||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(j=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==le||le(B)}catch(e){if(e.limitData)ve(e.limitData),be("");else{let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),St(t)||be(t)}}finally{Ie(),he("idle"),Ne(),ze.current=null,yield It()}}));return kt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!Ot&&"px-4 pb-8"),dir:ee?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ye,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===z.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ht),{maxHeight:`${et}px`,overflowY:"auto"})},{children:[qt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:ht.backgroundColor?`${ht.backgroundColor}E6`:void 0,borderColor:G.text+"20",color:G.text,borderTopRightRadius:z.cornerRadius+"px",borderTopLeftRadius:z.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Rt," ",At?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:G.accent,color:G.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${He}${null==se?void 0:se.accessGroupId}`;I.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Ke(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!me&&xe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:me}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[st&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(M=G.accent)&&void 0!==M?M:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:G.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Ge,className:N.default(gt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Pe.trim()&&!Pe.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ee?"text-right":"text-left",Nt&&"mb-12",st&&"text-transparent"),value:Pe,placeholder:Ct,onChange:e=>{if(De(e),q){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void q(0);if(t>=11)return;let s=0;t>1&&(s=50),q(24*(t-1)+s)}},onKeyDown:e=>{Y||rt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),je||me||Ut()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ne(!1),yield we(e))}))},A&&{onFocus:A},R&&{onBlur:R},{dir:ee?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Qe,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Nt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Nt&&ht.backgroundColor&&{backgroundColor:ht.backgroundColor}),{borderTopRightRadius:z.cornerRadius+"px",borderBottomRightRadius:z.cornerRadius+"px"})},{children:me?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ze.current&&(Ze.current.abort(),Ze.current=null),ze.current&&(ze.current.cancel(),ze.current=null),he("idle")},style:{backgroundColor:G.accent,color:G.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):st?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:T.default.stopListening,style:{backgroundColor:G.accent,color:G.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[yt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:dt?G.accent+"10":void 0,color:dt?G.accent:G.accent+"80"},disabled:je||me,onClick:()=>{var e;return null===(e=We.current)||void 0===e?void 0:e.click()}},ut,{children:[t.jsx("input",{id:"file-upload",ref:We,type:"file",accept:[...h.allowedFileMimeTypes,...h.allowedImageMimeTypes,...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ne(!1),yield we(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),wt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:st?G.accent:pt?G.accent+"10":void 0,color:st?G.accentText:pt?G.accent:G.accent+"80"},disabled:je||me,onClick:()=>{st?T.default.stopListening():(Je.current=Pe,nt(),T.default.startListening({continuous:!0,interimResults:!0,language:Q||"en-US"}))}},mt,{children:t.jsx(j.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:at||Dt?G.accent:G.accent+"10",color:at||Dt?G.accentText:G.accent+"80"},disabled:!Dt,onClick:()=>Ut()},lt,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",ee&&"scale-x-[-1] transform")})}))]})}))]}))]})),ye&&t.jsx(k.default,{error:ye,className:"mt-3"})]}))}))}));A.displayName="Input",exports.default=A;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),u=require("./Input.js"),c=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),f=require("../../../common/api/pickaxe.js"),m=require("uuid"),h=require("../../../hooks/pickaxe/useResponseContext.js"),p=require("../Addons/Navbar/NavPill.js"),x=require("../../Icons/history.svg.js");exports.default=()=>{const{deploymentType:v,isNewChat:j,setIsNewChat:g,sessionId:b,setSessionId:k,setLastSessionId:y,pickaxeId:w,sender:D,pickaxe:I,styles:_,isEmbed:S}=i.usePickaxeContext(),{isSent:q}=o.useAuthContext(),{width:C,height:N,setDimension:P}=r.useDimensionContext(),{setDocuments:F,onFileUpload:A}=n.useDocument(),{isGenerating:E,messages:O}=h.useResponseContext(),T=a.useStyleFontSize(),[R,z]=s.useState(0),[H,G]=s.useState(!1),[L,B]=s.useState(!1),M=s.useRef(null),U=s.useRef(null),J=s.useRef(0),[K,Q]=s.useState(null),[V,W]=s.useState(!1),X="chat-input"===v&&j&&!q;s.useEffect((()=>()=>{F([])}),[]);const Y=s.useCallback((()=>{if(!w||!D)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield f.default.post("/get_pickaxe_conversation",{sessionId:b,userId:D});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void $(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[w,D,b]);s.useEffect((()=>{E||j||!b||Y()}),[E,j,b,Y]),s.useEffect((()=>{if(!M.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;P(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(M.current),()=>{e.disconnect()}}),[M.current]);const[Z,$]=s.useState("New Chat"),ee=(null==I?void 0:I.formtitle)||"Pickaxe",te=(null==I?void 0:I.coverphoto)||void 0,[se,ie]=s.useState(!1);s.useEffect((()=>{const e=!X&&!S&&_.portalTheme&&(O.filter((e=>"user"===e.role)).length>0||H||!j);ie(null!=e&&e)}),[O,H,j]);return t.jsxs("div",Object.assign({ref:M,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),J.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&B(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),J.current-=1,0===J.current&&B(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),B(!1),J.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(g(!1),yield A(e))}))},{children:[L&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(c.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(T.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(T.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),X?t.jsx(u.default,{}):t.jsxs(t.Fragment,{children:[se&&t.jsxs("div",Object.assign({className:d.default("direct-link"===v?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[t.jsx(p.NavPill,{text:ee,icon:te}),j||"New Chat"===Z?t.jsx(p.NavPill,{text:Z}):t.jsx(p.EditableNavPill,{text:Z,sessionId:b,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b)try{yield f.default.post("/edit_conversation_name",{sessionId:b,name:t,userId:D}),$(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b&&window.confirm("Are you sure you want to delete this conversation?"))try{yield f.default.post("/delete_pickaxe_conversation",{sessionId:b,userId:D}),g(!0),k(m.v4()),$("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(p.HistoryPill,{icon:t.jsx(x.default,{}),onClick:()=>{k(""),y(b)}})]})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:N<=545||C<=350||H,isInputFocused:H,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){U.current&&U.current.onSubmit(t)})),smitheryAuthData:K,resubmitPrompt:()=>{Q(null),W(!0)}}),t.jsx(u.default,{ref:U,onFocus:()=>G(!0),onBlur:()=>G(!1),onInputHeightChange:z,initSmitheryAuthData:e=>Q(e),resubmitPrompt:V})]})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),g=require("../../common/PickaxeButton.js"),m=require("../../../../common/error.js"),f=require("../../../../common/validation.js");exports.default=({questions:h,resetQuestions:v})=>{var b;const{origin:x,pickaxeId:j,sender:y,senderType:O,portalId:w,deploymentId:S,pickaxe:C,misc:I,translations:k,isRtl:_,setSessionId:P,setIsNewChat:q,setValidationStatus:A,setValidationUpgradeGroups:E,setValidationUpgradeUrl:N,onGenerateComplete:T}=n.usePickaxeContext(),{token:U}=i.useAuthContext(),{isGenerating:D,setResponse:L,setMessages:R,setStatus:J,setLimitData:V,setError:B,setIsSwitchedToChat:K}=o.useResponseContext(),{documents:W,websiteLink:X,isUploading:F,onWebsiteUpload:G,setDocuments:M,setDocumentError:$}=r.useDocument(),{scrollStartSession:z,scrollEndSession:Q,scrollToTarget:Y}=a.useScroll({auto:!(null==C?void 0:C.enablechatresponses)}),{artifacts:H,currentPopupType:Z,setArtifacts:ee,setCurrentArtifact:te}=l.useArtifactContext(),[se,ne]=s.useState(!1),ie=s.useRef(null),oe=e=>{const t=f.getValidationFailure(e);return!!t&&(B(""),V(null),A(t.status),E(t.upgradeGroups),N(t.upgradeUrl),!0)},re=s.useMemo((()=>h.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[h]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:_?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(g.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:F||D||se,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(D||F||se)return;B(""),$(""),V(null),L(null);const n=["Multiple Choice","Checkbox"];for(const e of h){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=W.filter((e=>"finished"===e.status)),o=W.map((e=>e.name)),r=null!==(t=null===(e=null==C?void 0:C.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=h.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(X).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];ne(!0);const t=yield G(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),ne(!1)}else if(a&&r&&!i.length)return void $("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),g=r&&p.length>0,m={};h.forEach((e=>{m[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),J("fetching"),z(),Y();const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:x,pickaxeId:j,senderType:O,valueObj:m},g&&{documentIds:p}),y&&{sender:y}),U&&{studioSessionToken:U}),!U&&!y&&{sender:d.initializeEmbedUserId()}),w&&{portalId:w}),S&&{deploymentId:S}))}),v=yield f.json();if(!v.success){if(oe(v))return;const e=new Error(v.error||v.message||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}if(!v.submissionId||!v.sessionId)throw new Error("Failed to start generation");const b=v.submissionId,I=v.sessionId,k={sessionId:I,documentIds:g?p:[],question:{inputs:h.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};L(k),(null==C?void 0:C.enablechatresponses)&&(P(I),q(!1),K(!0),R([{id:0,role:"assistant",parts:[],documentIds:[]}])),g&&M([]),J("streaming"),ie.current=new AbortController;const _=[];let A=[...null!=H?H:[]],E=0,N=!1,Q="";for(;!N;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${b}?index=${E}`,{signal:null===(s=ie.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&E++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return oe(t)||B(s),void(N=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)Q="",_.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)Q+=n.delta,_[_.length-1].content=Q;else if("text-end"===n.type)Q="";else if("reasoning-start"===n.type)Q="",_.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)Q+=n.delta,_[_.length-1].content=Q;else if("reasoning-end"===n.type)Q="";else if(n.type.startsWith("data-")){const e=n;_.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[..._]})});L(i),(null==C?void 0:C.enablechatresponses)&&R([{id:0,role:"assistant",parts:[..._],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ee([...A]),Z.startsWith("inline")||te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ee([...A]),Z.startsWith("inline")||te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ee([...A]),Z.startsWith("inline")||te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");A=A.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ee([...A])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ee(A.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else N=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}N||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(N=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==T||T(I)}catch(e){let t=m.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),oe(t)||B(t),Y()}finally{J("idle"),ne(!1),Q()}}))},{children:se?(null==k?void 0:k.processing)||"Processing...":F?(null==k?void 0:k.uploading)||"Uploading...":D?(null==k?void 0:k.loading)||"Loading...":null!==(b=null==C?void 0:C.submittext)&&void 0!==b?b:"Submit"})),re&&t.jsx(g.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:F||D||se,onClick:v},{children:(null==k?void 0:k["clear-form"])||"Clear form"}))]})),!I.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),n=require("./ResponseProvider.js"),r=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:y,portalId:h,deploymentType:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),n=require("./ResponseProvider.js"),r=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:y,portalId:h,deploymentType:S,deploymentDimensions:m,deploymentMisc:b,styles:g,colors:v,limits:x={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:j,artifact:P={popupType:"auto"},responsiveBy:w="viewport",locale:F="en",opacity:k=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:A=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:E=!1,isDropShadow:U=!1,allowGuestUsage:G=!0,preventInitialSessionId:H=!1,onGenerateComplete:M,onSessionIdChange:R})=>{const[_,L]=s.useState(""),[B,N]=s.useState(""),[V,W]=s.useState(""),[z,J]=s.useState(""),[Y,K]=s.useState(p),[Q,X]=s.useState(null),[Z,$]=s.useState(f),[ee,te]=s.useState("loading"),[se,ie]=s.useState([]),[oe,ne]=s.useState(null),[re,ae]=s.useState(null),[le,de]=s.useState(null),[ce,ue]=s.useState(null),[pe,fe]=s.useState(!1),[ye,he]=s.useState(!0),[Se,me]=s.useState(!0),[be,ge]=s.useState(!1);return s.useEffect((()=>{fe(!1)}),[null==g?void 0:g.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!pe&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[g.font]},active:()=>{fe(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),fe(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),fe(!0)}}))}),[T,pe,null==g?void 0:g.font]),s.useEffect((()=>{K(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:_,pickaxeId:B,sessionId:V,lastSessionId:z,sender:Y,senderType:Z,portalId:h,deploymentId:y,deploymentType:S,validationStatus:ee,validationUpgradeGroups:se,validationUpgradeUrl:oe,deploymentDimensions:m,deploymentMisc:b,accessGroup:Q,pickaxe:ce,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},j),artifact:P,responsiveBy:w,locale:F,opacity:k,forceMobile:C,loadFont:T,disableHtml:O,disableJs:A,disableCss:D,isFontLoaded:pe,isNewChat:ye,isShowIceBreaker:Se,isShowFeedbackMessage:be,isRtl:q,isEmbed:E,isDropShadow:U,allowGuestUsage:G,clientSecret:le,stripeAccountId:re,preventInitialSessionId:H,setClientSecret:de,setStripeAccountId:ae,setContextId:L,setValidationStatus:te,setValidationUpgradeGroups:ie,setValidationUpgradeUrl:ne,setPickaxeId:N,setSessionId:e=>{W((t=>{const s="function"==typeof e?e(t):e;return null==R||R(s),s}))},setLastSessionId:J,setSender:K,setSenderType:$,setAccessGroup:X,setPickaxe:ue,setIsFontLoaded:fe,setIsNewChat:he,setIsShowIceBreaker:me,setIsShowFeedbackMessage:ge},M&&{onGenerateComplete:M})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(n.default,Object.assign({limits:x},{children:t.jsx(r.default,{children:t.jsx(i.ArtifactProvider,Object.assign({},P,{children:c}))})}))})})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),o=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),o=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("../../common/validation.js"),v=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),b=require("../Icons/lock.svg.js"),k=require("../../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"),y=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const w=({className:e})=>s.jsx("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.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:N,className:O})=>{const{sessionId:q,styles:_,colors:C,responsiveBy:A,deploymentType:I,isNewChat:S,isEmbed:P,opacity:E,deploymentId:U,sender:R,portalId:T,validationStatus:G,validationUpgradeGroups:L,validationUpgradeUrl:D,stripeAccountId:F,clientSecret:M,preventInitialSessionId:B,setClientSecret:V,setStripeAccountId:$,setValidationStatus:W,setValidationUpgradeGroups:z,setValidationUpgradeUrl:H,setContextId:J,setPickaxeId:K,setSessionId:X,setPickaxe:Y,setAccessGroup:Q}=i.usePickaxeContext(),{isSent:Z,token:ee}=r.useAuthContext(),{setMessages:se,setResponse:te,setError:ae,setLimitData:ie,setIsSwitchedToChat:re}=l.useResponseContext(),{setDocumentError:le}=o.useDocumentContext(),{setCurrentArtifact:oe}=c.useArtifactContext(),[ce,ne]=a.useState(!1),de=t.usePickaxe(),ue="chat-input"===I&&S&&!Z,xe=a.useMemo((()=>F?y.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:F}):null),[F]);a.useEffect((()=>{K(N)}),[N]);a.useEffect((()=>{if(!U&&!T||!de.data)return;if("stripe_checkout"===G)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;W("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:U,sender:R||void 0,studioSessionToken:ee,portalId:T,studioId:null===(e=de.data)||void 0===e?void 0:e.studioid}});if(s.data.success)W("success"),z([]),H(null),Q(s.data.accessGroup);else{const e=h.getValidationFailure(s.data);if(!e)return W("login_required"),z([]),void H(null);W(e.status),z(e.upgradeGroups),H(e.upgradeUrl),ne(!0)}}catch(e){console.error("Failed to validate deployment:",e),W("success")}}))}),[U,R,ee,T,de.data]),a.useEffect((()=>{if(!de.data)return;const e=de.data.chatflag;B||X(e?n.v4():""),J(n.v4()),e?se([]):te(null),ae(""),le(""),ie(null),oe(null),re(!1),Y(de.data),ne(!0)}),[de.data]),a.useEffect((()=>{ae(""),le(""),ie(null),se([]),te(null),oe(null)}),[q]);const me=a.useMemo((()=>{const e=null!=E?E:1;if(!C.primary||!C.primary.startsWith("#")||e<0||e>1)return C.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${C.primary}${s}`}),[C.primary,E]);if(!de.data)return null;return s.jsx("div",Object.assign({className:f.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===_.theme&&"dark",O),style:Object.assign({backgroundColor:ue?"transparent":me,color:C.text},_.font&&"Real Head Pro"!==_.font&&{fontFamily:_.font})},{children:"stripe_checkout"===G&&M&&xe?s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:C.secondary||"#ffffff",color:C.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{V&&V(null),$&&$(null),W("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:C.text}},{children:[s.jsx(w,{className:"w-5 h-5"}),s.jsx("span",{children:"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(k.EmbeddedCheckoutProvider,Object.assign({stripe:xe,options:{clientSecret:M}},{children:s.jsx(k.EmbeddedCheckout,{})}))}))]})):de.isLoading||!ce||"loading"===G?s.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===A?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:f.default("w-full min-h-[48px]","viewport"===A?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===G?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:L&&L.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:L.map(((e,t)=>s.jsx(v.default,{data:e,upgradeUrl:D},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===G&&P?s.jsx(p.default,{}):"login_required"!==G||P?"access_denied"===G?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(g.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(g.AvatarImage,{src:null===(pe=de.data)||void 0===pe?void 0:pe.coverphoto,alt:`${null===(fe=de.data)||void 0===fe?void 0:fe.formtitle} Logo`}),s.jsx(g.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(b.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:C.accent,color:C.accentText,borderRadius:_.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=L.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:R||void 0,studioSessionToken:ee,studioId:null===(e=de.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=de.data)||void 0===s?void 0:s.formid,deploymentId:U,accessGroupIds:t})}});a.data.success?alert("Successfully requested access!"):alert(a.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):q?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var pe,fe};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type PickaxeValidationFailureStatus = "login_required" | "upgrade_required" | "access_denied";
|
|
2
|
+
export type PickaxeValidationFailure = {
|
|
3
|
+
status: PickaxeValidationFailureStatus;
|
|
4
|
+
upgradeGroups: any[];
|
|
5
|
+
upgradeUrl: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare const getValidationFailure: (payload: unknown) => PickaxeValidationFailure | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
interface NavPillProps {
|
|
2
3
|
text: string;
|
|
3
4
|
icon?: string;
|
|
@@ -12,4 +13,10 @@ interface EditableNavPillProps extends NavPillProps {
|
|
|
12
13
|
isDarkGlass?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export declare const EditableNavPill: ({ text, className, onRename, onDelete, isDarkGlass, }: EditableNavPillProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
interface HistoryPillProps {
|
|
17
|
+
icon: React.ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
onClick?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const HistoryPill: ({ icon, className, onClick }: HistoryPillProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
22
|
export {};
|
|
@@ -70,6 +70,8 @@ type PickaxeContextType = {
|
|
|
70
70
|
deploymentId?: string;
|
|
71
71
|
deploymentType?: PickaxeDeploymentEmbedType;
|
|
72
72
|
validationStatus: ValidationStatus;
|
|
73
|
+
validationUpgradeGroups: any[];
|
|
74
|
+
validationUpgradeUrl: string | null;
|
|
73
75
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
74
76
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
75
77
|
portalId?: string;
|
|
@@ -105,6 +107,8 @@ type PickaxeContextType = {
|
|
|
105
107
|
setAccessGroup: SetState<AccessGroup | null>;
|
|
106
108
|
setLastSessionId: SetState<string>;
|
|
107
109
|
setValidationStatus: SetState<ValidationStatus>;
|
|
110
|
+
setValidationUpgradeGroups: SetState<any[]>;
|
|
111
|
+
setValidationUpgradeUrl: SetState<string | null>;
|
|
108
112
|
setSender: SetState<string | undefined>;
|
|
109
113
|
setSenderType: SetState<PickaxeHistorySenderType>;
|
|
110
114
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
@@ -9,6 +9,8 @@ export declare const usePickaxeContext: () => {
|
|
|
9
9
|
deploymentId?: string | undefined;
|
|
10
10
|
deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
|
|
11
11
|
validationStatus: "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
12
|
+
validationUpgradeGroups: any[];
|
|
13
|
+
validationUpgradeUrl: string | null;
|
|
12
14
|
deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
|
|
13
15
|
deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
|
|
14
16
|
portalId?: string | undefined;
|
|
@@ -44,6 +46,8 @@ export declare const usePickaxeContext: () => {
|
|
|
44
46
|
setAccessGroup: import("../../types/common").SetState<import("../../components/Pickaxe/Provider").AccessGroup | null>;
|
|
45
47
|
setLastSessionId: import("../../types/common").SetState<string>;
|
|
46
48
|
setValidationStatus: import("../../types/common").SetState<"loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout">;
|
|
49
|
+
setValidationUpgradeGroups: import("../../types/common").SetState<any[]>;
|
|
50
|
+
setValidationUpgradeUrl: import("../../types/common").SetState<string | null>;
|
|
47
51
|
setSender: import("../../types/common").SetState<string | undefined>;
|
|
48
52
|
setSenderType: import("../../types/common").SetState<import("../../types/history").PickaxeHistorySenderType>;
|
|
49
53
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r={"login required":"login_required","upgrade required":"upgrade_required","access denied":"access_denied"},e=e=>{var u;if("string"!=typeof e)return null;const l=e.trim().toLowerCase().replace(/[.!]+$/g,"");return null!==(u=r[l])&&void 0!==u?u:null},u=r=>{var u;if("string"==typeof r){const u=e(r);return u?{status:u,upgradeGroups:[],upgradeUrl:null}:null}if(!r||"object"!=typeof r)return null;const l=r,n=null!==(u=e(l.message))&&void 0!==u?u:e(l.error);return n?{status:n,upgradeGroups:Array.isArray(l.upgradeGroups)?l.upgradeGroups:[],upgradeUrl:"string"==typeof l.upgradeUrl?l.upgradeUrl:null}:null};export{u as getValidationFailure};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";var e,t;function n(){return n=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},n.apply(null,arguments)}var o=o=>r.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},o),e||(e=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 17a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6"})),t||(t=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 13h-4V9M11 13l5-5"})));export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";var e,t;function n(){return n=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},n.apply(null,arguments)}var o=o=>r.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},o),e||(e=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2"})),t||(t=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})));export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";var e;function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},t.apply(null,arguments)}var n=n=>r.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},n),e||(e=r.createElement("path",{fill:"currentColor",d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5z"})));export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as a from"react";var t;function r(){return r=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var e in r)({}).hasOwnProperty.call(r,e)&&(a[e]=r[e])}return a},r.apply(null,arguments)}var e=e=>a.createElement("svg",r({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),t||(t=a.createElement("path",{fill:"#000",d:"M20 10c0-5.523-4.477-10-10-10a9.97 9.97 0 0 0-7 2.859V1.75a.75.75 0 0 0-1.5 0v3.5c0 .414.336.75.75.75h3.5a.75.75 0 0 0 0-1.5H3.519a8.5 8.5 0 1 1 2.348 12.93l-.27-.15-3.986 1.111 1.113-3.984-.151-.27A8.46 8.46 0 0 1 1.5 10c0-.675.079-1.332.227-1.962.08-.301.065-.888-.536-1.02-.613-.134-.87.355-.935.719h.001A10 10 0 0 0 0 10a9.96 9.96 0 0 0 1.115 4.592L.047 18.415a1.25 1.25 0 0 0 1.54 1.54l3.826-1.067A9.96 9.96 0 0 0 10 20c5.523 0 10-4.477 10-10M10 6.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H10z"})));export{e as default};
|