@pickaxeproject/react 6.1.1-0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/common/validation.js +1 -0
  2. package/dist/cjs/components/Icons/collapse-new.svg.js +1 -0
  3. package/dist/cjs/components/Icons/copy-new.svg.js +1 -0
  4. package/dist/cjs/components/Icons/download-new.svg.js +1 -0
  5. package/dist/cjs/components/Icons/history.svg.js +1 -0
  6. package/dist/cjs/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  10. package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
  11. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  12. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  13. package/dist/cjs/components/Pickaxe/index.js +1 -1
  14. package/dist/cjs/hooks/pickaxe/useSpeech.js +1 -0
  15. package/dist/cjs/src/common/validation.d.ts +7 -0
  16. package/dist/cjs/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +7 -0
  17. package/dist/cjs/src/components/Pickaxe/Chat/Input.d.ts +0 -1
  18. package/dist/cjs/src/components/Pickaxe/Form/Questions/Input.d.ts +0 -1
  19. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +4 -0
  20. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +4 -0
  21. package/dist/cjs/src/hooks/pickaxe/useSpeech.d.ts +9 -0
  22. package/dist/esm/common/validation.js +1 -0
  23. package/dist/esm/components/Icons/collapse-new.svg.js +1 -0
  24. package/dist/esm/components/Icons/copy-new.svg.js +1 -0
  25. package/dist/esm/components/Icons/download-new.svg.js +1 -0
  26. package/dist/esm/components/Icons/history.svg.js +1 -0
  27. package/dist/esm/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
  28. package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
  29. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  30. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  31. package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
  32. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  33. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  34. package/dist/esm/components/Pickaxe/index.js +1 -1
  35. package/dist/esm/hooks/pickaxe/useSpeech.js +1 -0
  36. package/dist/esm/src/common/validation.d.ts +7 -0
  37. package/dist/esm/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +7 -0
  38. package/dist/esm/src/components/Pickaxe/Chat/Input.d.ts +0 -1
  39. package/dist/esm/src/components/Pickaxe/Form/Questions/Input.d.ts +0 -1
  40. package/dist/esm/src/components/Pickaxe/Provider.d.ts +4 -0
  41. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +4 -0
  42. package/dist/esm/src/hooks/pickaxe/useSpeech.d.ts +9 -0
  43. package/package.json +210 -209
  44. package/dist/cjs/src/hooks/pickaxe/useSpeechRecognition.d.ts +0 -13
  45. package/dist/esm/src/hooks/pickaxe/useSpeechRecognition.d.ts +0 -13
@@ -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"),a=require("react"),n=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]=a.useState(!1),[p,h]=a.useState(!1),[f,j]=a.useState(l),[b,g]=a.useState(!1),v=a.useRef(null),w=a.useRef(null);a.useEffect((()=>{p||j(l)}),[l,p]),a.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*(){f.trim()&&(g(!0),yield c(f),g(!1),h(!1))})),k=()=>{j(l),h(!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:f,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:b,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(n.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:k,disabled:b,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:s.jsx(n.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(n.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),h(!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.NavPill=({text:e,icon:a,className:n,onClick:i})=>s.jsx("div",Object.assign({onClick:e=>{e.stopPropagation(),null==i||i()},className:t.default("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",n),onMouseDown:e=>{e.preventDefault()}},{children:s.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[a&&s.jsx("img",{src:a,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),s.jsx("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))}));
1
+ "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"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),r=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),m=require("../../../common/documents.js"),g=require("eventsource-parser"),v=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),y=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),k=require("../../../common/validation.js"),C=require("../../../common/cn.js"),N=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js"),_=require("../../../hooks/pickaxe/useSpeech.js");const E=s.forwardRef((({resubmitPrompt:E,onFocus:T,onBlur:A,onInputHeightChange:P,initSmitheryAuthData:q},R)=>{var D,U,L;const{origin:M,pickaxeId:$,sessionId:F,sender:B,senderType:H,portalId:V,deploymentId:X,deploymentType:K,pickaxe:W,styles:J,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,setValidationStatus:ie,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:re,onGenerateComplete:ae}=n.usePickaxeContext(),{token:le,isLoggedOut:ce,isSent:de,isPricingAuth:ue}=c.useAuthContext(),{messages:pe,isGenerating:fe,setMessages:he,setStatus:me,setLimitData:ge,setError:ve}=i.useResponseContext(),{documents:be,isUploading:xe,documentError:je,onFileUpload:ye,setDocuments:we,setDocumentError:Oe}=d.useDocument(),{studio:Se}=I.useStudio(),{scrollStartSession:ke,scrollEndSession:Ce,scrollToBottom:Ne}=u.useScroll({auto:!0}),{artifacts:Ie,currentPopupType:_e,setArtifacts:Ee,setCurrentArtifact:Te}=p.useArtifactContext(),{height:Ae}=l.useDimensionContext(),Pe=a.useConversation(),[qe,Re]=s.useState(""),[De,Ue]=s.useState(!1),[Le,Me]=s.useState(!1),[$e,Fe]=s.useState(null),[Be,He]=s.useState(null),[Ve,Xe]=s.useState(!1),Ke=s.useRef(null),We=s.useRef(""),Je=s.useRef(null),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=Math.max(.4*Ae,100),{speechTranscript:et,isSpeechListening:tt,isSpeechProcessing:st,isSpeechSupported:nt,onStartListening:it,onStopListening:ot}=_.useSpeech(),[rt]=h.useMediaQuery("(max-width: 480px)"),at=f.useHover(),{isHover:lt}=at,ct=e.__rest(at,["isHover"]),dt=f.useHover(),{isHover:ut}=dt,pt=e.__rest(dt,["isHover"]),ft=f.useHover(),{isHover:ht}=ft,mt=e.__rest(ft,["isHover"]),gt=r.useStyleFontSize(),vt=o.useStyleInput(),bt="undefined"!=typeof window?window.location.hostname:"",xt="undefined"!=typeof window?window.location.href:"",jt="undefined"!=typeof window&&window.self!==window.top,yt=bt.includes("pickaxe.co")&&!xt.includes("https://studio.pickaxe.co/_embed")&&!jt,wt=null===(D=null==W?void 0:W.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),Ot=nt&&(null==W?void 0:W.enablevoicetotext),St="chat-input"===K&&Y&&!de,kt="chat-input"===K&&ue&&ce&&de,Ct=s.useCallback((e=>{const t=k.getValidationFailure(e);return!!t&&(ve(""),ge(null),ie(t.status),oe(t.upgradeGroups),re(t.upgradeUrl),!0)}),[ve,ge,ie,oe,re]),Nt=null!==(U=null==W?void 0:W.placeholdertext)&&void 0!==U?U:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",It=De||Le,_t=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==W?void 0:W.studioid},B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),yt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Fe(t.studioUser),He(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,F,H,B,le,V,X,yt]);s.useEffect((()=>{_t()}),[_t]);const Et=(null==te?void 0:te.limit)||0,Tt=(null==$e?void 0:$e.currentUses)||0,At=(null==$e?void 0:$e.extraUses)||0,Pt=!!(null==Se?void 0:Se.data.usage)&&Se.data.usage.isCredits,qt=Et>Tt?Et-Tt+At:At,Rt=s.useMemo((()=>!!$e&&(!Ve&&(!(Et<=0)&&qt<=.05*Et))),[$e,Ve,qt,Et]),Dt=s.useMemo((()=>{var e,t,s;return!!Y&&(!!W&&(!Pe.isLoading&&(!((null!==(t=null===(e=Pe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=W.icebreakers)||void 0===s?void 0:s.length)&&(!ee&&!St)))))}),[W,Y,ee,St,Pe.data,Pe.isLoading]),Ut=s.useMemo((()=>{if(fe||xe)return!1;const e=be.length>0&&be.every((e=>"finished"===e.status));return!(!qe.trim()&&!e)&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[fe,xe,qe,be]);s.useImperativeHandle(R,(()=>({onSubmit:Lt}))),s.useEffect((()=>{ne(Dt)}),[Dt]),s.useEffect((()=>{var e;if(E){const t=Array.from(pe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Lt(s,!0)}}),[E]),s.useEffect((()=>{if(!Qe.current||!P)return;const e=new ResizeObserver((e=>{for(const t of e)P(t.contentRect.height)}));return e.observe(Qe.current),()=>{e.disconnect()}}),[P]),s.useEffect((()=>{if(!tt)return;const e=We.current?`${We.current} `:"";Re(`${e}${et}`)}),[et,tt]),s.useEffect((()=>{if(!ze.current)return;(()=>{if(!ze.current)return;let e=ze.current.scrollHeight>52;qe.includes("\n")||be.length?e=!0:qe.trim()||(e=!1),Ue(e)})()}),[qe,be]),s.useEffect((()=>{const e=ze.current,t=Ge.current;if(!e||!t||De||qe.includes("\n"))return void Me(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=qe||Nt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Me(o>l)}),[qe,De,Nt]);const Lt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(fe||xe)return;const o=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:qe;if(!c&&!l)return;ve(""),Oe(""),ge(null),Re(""),se(!1),me("fetching"),ke(),Ne();const d=null!==(n=null===(e=null==W?void 0:W.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(pe.slice(0,pe.length-1)):Array.from(pe),...s?[]:[{id:pe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:pe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];he(u),Ne(),d&&we([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:F,senderType:H,value:c},d&&{documentIds:r}),B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}),V&&{portalId:V}),X&&{deploymentId:X}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},yt&&{credentials:"include"})),f=yield p.json();if(!f.success){if(Ct(f))return;const e=new Error(f.error||f.message||"Failed to start generation");throw f.limitData&&(e.limitData=f.limitData),e}const h=f.submissionId;me("streaming"),Ye.current=new AbortController;const m=u.length-1,v=[];let b=[...null!=Ie?Ie:[]],x=0,j=!1,y="";for(;!j;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${h}?index=${x}`,{signal:null===(i=Ye.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Je.current=t;const s=new TextDecoder,n=g.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ct(t)||ve(s),void(j=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw j=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw j=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",v.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",v.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;v.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}he([...u.slice(0,m),Object.assign(Object.assign({},u[u.length-1]),{id:pe.length+1,role:"assistant",parts:v})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee([...b]),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ee(b),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee(b),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ee(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ee(b.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong, please try again.";if(Ct(t))return void(j=!0);ve(s)}else"stop"===e.event&&(j=!0)}else j=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}j||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(j=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ae||ae(F)}catch(e){if(e.limitData)ge(e.limitData),ve("");else{let t=S.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ct(t)||ve(t)}}finally{Ne(),me("idle"),Ce(),Je.current=null,yield _t()}}));return kt?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!St&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Qe,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===J.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},vt),{maxHeight:`${Ze}px`,overflowY:"auto"})},{children:[Rt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:vt.backgroundColor?`${vt.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:J.cornerRadius+"px",borderTopLeftRadius:J.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[qt," ",Pt?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Be}${null==te?void 0:te.accessGroupId}`;N.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Xe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!fe&&be.length>0&&t.jsx(y.default,{className:"p-4 pb-0",isDisabled:fe}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[tt&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(L=z.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(w.default,Object.assign({ref:ze,className:C.default(gt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!qe.trim()&&!qe.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",It&&"mb-12",tt&&"text-transparent"),value:qe,placeholder:Nt,onChange:e=>{if(Re(e),P){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void P(0);if(t>=11)return;let s=0;t>1&&(s=50),P(24*(t-1)+s)}},onKeyDown:e=>{Q||rt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),xe||fe||Lt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield ye(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Ge,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",It?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!It&&vt.backgroundColor&&{backgroundColor:vt.backgroundColor}),{borderTopRightRadius:J.cornerRadius+"px",borderBottomRightRadius:J.cornerRadius+"px"})},{children:fe?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ye.current&&(Ye.current.abort(),Ye.current=null),Je.current&&(Je.current.cancel(),Je.current=null),me("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):tt?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:ot,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[wt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ut?z.accent+"10":void 0,color:ut?z.accent:z.accent+"80"},disabled:xe||fe,onClick:()=>{var e;return null===(e=Ke.current)||void 0===e?void 0:e.click()}},pt,{children:[t.jsx("input",{id:"file-upload",ref:Ke,type:"file",accept:[...m.allowedFileMimeTypes,...m.allowedImageMimeTypes,...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield ye(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(v.default,{className:"h-6 w-6 shrink-0"})]})),Ot&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:tt?z.accent:ht?z.accent+"10":void 0,color:tt?z.accentText:ht?z.accent:z.accent+"80"},disabled:xe||fe||st,onClick:()=>{tt?ot():(We.current=qe,it(G||"en-US"))}},mt,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:lt||Ut?z.accent:z.accent+"10",color:lt||Ut?z.accentText:z.accent+"80"},disabled:!Ut,onClick:()=>Lt()},ct,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),je&&t.jsx(O.default,{error:je,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=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");exports.default=()=>{const{deploymentType:x,isNewChat:v,setIsNewChat:j,sessionId:g,setSessionId:b,setLastSessionId:k,pickaxeId:w,sender:y,pickaxe:D,styles:_,isEmbed:I}=o.usePickaxeContext(),{isSent:S}=i.useAuthContext(),{width:C,height:N,setDimension:q}=r.useDimensionContext(),{setDocuments:P,onFileUpload:F}=n.useDocument(),{isGenerating:A,messages:E}=h.useResponseContext(),O=a.useStyleFontSize(),[T,R]=s.useState(0),[z,H]=s.useState(!1),[G,L]=s.useState(!1),B=s.useRef(null),M=s.useRef(null),U=s.useRef(0),[J,K]=s.useState(null),[Q,V]=s.useState(!1),W="chat-input"===x&&v&&!S;s.useEffect((()=>()=>{P([])}),[]);const X=s.useCallback((()=>{if(!w||!y)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:g,userId:y});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void Z(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,y,g]);s.useEffect((()=>{A||v||!g||X()}),[A,v,g,X]),s.useEffect((()=>{if(!B.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;q(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(B.current),()=>{e.disconnect()}}),[B.current]);const[Y,Z]=s.useState("New Chat"),$=(null==D?void 0:D.formtitle)||"Pickaxe",ee=(null==D?void 0:D.coverphoto)||void 0,[te,se]=s.useState(!1);s.useEffect((()=>{const e=!W&&!I&&_.portalTheme&&(E.filter((e=>"user"===e.role)).length>0||z||!v);se(null!=e&&e)}),[E,z,v]);return t.jsxs("div",Object.assign({ref:B,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),U.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&L(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),U.current-=1,0===U.current&&L(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),L(!1),U.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(j(!1),yield F(e))}))},{children:[G&&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(O.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(O.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),W?t.jsx(u.default,{}):t.jsxs(t.Fragment,{children:[te&&t.jsxs("div",Object.assign({className:d.default("direct-link"===x?"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:$,icon:ee,onClick:()=>{b(""),k(g)}}),v||"New Chat"===Y?t.jsx(p.NavPill,{text:Y}):t.jsx(p.EditableNavPill,{text:Y,sessionId:g,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(g)try{yield f.default.post("/edit_conversation_name",{sessionId:g,name:t,userId:y}),Z(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(g&&window.confirm("Are you sure you want to delete this conversation?"))try{yield f.default.post("/delete_pickaxe_conversation",{sessionId:g,userId:y}),j(!0),b(m.v4()),Z("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme})]})),t.jsx(l.default,{additionalScrollHeight:T,isForceHideInfo:N<=545||C<=350||z,isInputFocused:z,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){M.current&&M.current.onSubmit(t)})),smitheryAuthData:J,resubmitPrompt:()=>{K(null),V(!0)}}),t.jsx(u.default,{ref:M,onFocus:()=>H(!0),onBlur:()=>H(!1),onInputHeightChange:R,initSmitheryAuthData:e=>K(e),resubmitPrompt:Q})]})]}))};
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");require("../../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleInput.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("../../../../hooks/core/useHover.js"),c=require("../../../Core/Textarea.js"),u=require("../../../Icons/microphone.svg.js"),d=require("../../../Icons/stop.svg.js"),p=require("../../../../common/cn.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=g(n);exports.default=({field:g,update:h,activeVoiceId:m,setActiveVoiceId:j})=>{var f;const{styles:b,colors:v,isRtl:y,pickaxe:O,locale:k}=o.usePickaxeContext(),{setError:N}=r.useResponseContext(),[q,w]=s.useState(!1),S=a.useStyleFontSize(),C=i.useStyleInput(),{transcript:R,listening:_,resetTranscript:I,browserSupportsSpeechRecognition:L}=n.useSpeechRecognition(),T=s.useRef(""),z=l.useHover(),{isHover:F}=z,H=e.__rest(z,["isHover"]),P=L&&(null==O?void 0:O.enablevoicetotext),$=_&&m===g.id,B=e=>{N("");const t=e.length;h(Object.assign(Object.assign({},g),{input:e,length:t}))};s.useEffect((()=>{if(!_||m!==g.id)return;const e=T.current?`${T.current} `:"";B(`${e}${R}`)}),[R,_,m,g.id]);return t.jsxs("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:y?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[t.jsx("p",Object.assign({className:p.default(S.b3,"font-semibold opacity-70")},{children:g.main})),g.isRequired&&t.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:v.accent}},{children:"*"}))]})),t.jsxs("div",Object.assign({className:"relative w-full"},{children:[$&&t.jsxs("div",Object.assign({className:p.default("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",y?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(f=v.accent)&&void 0!==f?f:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm font-semilight",style:{color:v.text+"90"}},{children:"Listening..."}))]})),t.jsx(c.default,{className:p.default(S.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",y?P?"pl-10 pr-4":"px-4":P?"pl-4 pr-10":"px-4",g.maxLength<10&&"max-w-[400px]","block"===b.formFieldStyle&&"shadow hover:shadow-none",$&&"caret-transparent"),style:Object.assign(Object.assign({},C),$&&{color:"transparent"}),placeholder:$?"":g.placeholder,rows:1,value:g.input,tabIndex:g.order,onChange:B,onFocus:()=>w(!0),onBlur:()=>w(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const t=e.target;setTimeout((()=>{const e=t.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),P&&t.jsx("div",Object.assign({className:p.default("absolute top-2 z-20",y?"left-2":"right-2")},{children:t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:$?v.accent:F?v.accent+"10":void 0,color:$?v.accentText:F?v.accent:v.accent+"80"},onClick:()=>{_?(x.default.stopListening(),j(null)):(j(g.id),T.current=g.input||"",I(),x.default.startListening({continuous:!0,interimResults:!0,language:k||"en-US"}),w(!0))}},H,{type:"button"},{children:$?t.jsx(d.default,{className:"h-4 w-4 shrink-0"}):t.jsx(u.default,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),t.jsx("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:t.jsxs("p",Object.assign({className:p.default(S.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",g.length>g.maxLength&&"text-c-red opacity-100",q&&"opacity-100")},{children:[g.length,"/",g.maxLength]}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../../../hooks/core/useHover.js"),l=require("../../../../hooks/pickaxe/useSpeech.js"),c=require("../../../Core/Textarea.js"),u=require("../../../Icons/microphone.svg.js"),d=require("../../../Icons/stop.svg.js"),p=require("../../../../common/cn.js");exports.default=({field:h,update:x,activeVoiceId:g,setActiveVoiceId:j})=>{var m;const{styles:b,colors:f,isRtl:v,pickaxe:y,locale:k}=o.usePickaxeContext(),{setError:O}=n.useResponseContext(),[S,N]=t.useState(!1),w=r.useStyleFontSize(),q=i.useStyleInput(),{speechTranscript:C,isSpeechListening:_,isSpeechProcessing:I,isSpeechSupported:L,onStartListening:R,onStopListening:P}=l.useSpeech(),T=t.useRef(""),z=a.useHover(),{isHover:F}=z,H=e.__rest(z,["isHover"]),$=L&&(null==y?void 0:y.enablevoicetotext),B=_&&g===h.id,D=e=>{O("");const s=e.length;x(Object.assign(Object.assign({},h),{input:e,length:s}))};return t.useEffect((()=>{if(!_||g!==h.id)return;const e=T.current?`${T.current} `:"";D(`${e}${C}`)}),[C,_,g,h.id]),s.jsxs("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:v?"rtl":"ltr"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:p.default(w.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:f.accent}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"relative w-full"},{children:[B&&s.jsxs("div",Object.assign({className:p.default("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",v?"right-4":"left-4")},{children:[s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(m=f.accent)&&void 0!==m?m:"#ff0000"}}),s.jsx("span",Object.assign({className:"text-sm font-semilight",style:{color:f.text+"90"}},{children:"Listening..."}))]})),s.jsx(c.default,{className:p.default(w.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",v?$?"pl-10 pr-4":"px-4":$?"pl-4 pr-10":"px-4",h.maxLength<10&&"max-w-[400px]","block"===b.formFieldStyle&&"shadow hover:shadow-none",B&&"caret-transparent"),style:Object.assign(Object.assign({},q),B&&{color:"transparent"}),placeholder:B?"":h.placeholder,rows:1,value:h.input,tabIndex:h.order,onChange:D,onFocus:()=>N(!0),onBlur:()=>N(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const s=e.target;setTimeout((()=>{const e=s.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),$&&s.jsx("div",Object.assign({className:p.default("absolute top-2 z-20",v?"left-2":"right-2")},{children:s.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:B?f.accent:F?f.accent+"10":void 0,color:B?f.accentText:F?f.accent:f.accent+"80"},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){_?(yield P(),j(h.id)):(j(h.id),T.current=h.input||"",yield R(k||"en-US"),N(!0))}))},H,{type:"button"},{children:B?s.jsx(d.default,{className:"h-4 w-4 shrink-0"}):s.jsx(u.default,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),s.jsx("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:s.jsxs("p",Object.assign({className:p.default(w.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",h.length>h.maxLength&&"text-c-red opacity-100",S&&"opacity-100")},{children:[h.length,"/",h.maxLength]}))}))]}))};
@@ -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"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:j,senderType:y,portalId:O,deploymentId:w,pickaxe:C,misc:S,translations:I,isRtl:k,setSessionId:_,setIsNewChat:P,onGenerateComplete:q}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{isGenerating:N,setResponse:E,setMessages:T,setStatus:D,setLimitData:U,setError:L,setIsSwitchedToChat:R}=o.useResponseContext(),{documents:J,websiteLink:B,isUploading:K,onWebsiteUpload:W,setDocuments:X,setDocumentError:V}=r.useDocument(),{scrollStartSession:M,scrollEndSession:$,scrollToTarget:F}=a.useScroll({auto:!(null==C?void 0:C.enablechatresponses)}),{artifacts:G,currentPopupType:z,setArtifacts:Q,setCurrentArtifact:Y}=l.useArtifactContext(),[H,Z]=s.useState(!1),ee=s.useRef(null),te=s.useMemo((()=>f.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))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||N||H,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(N||K||H)return;L(""),V(""),U(null),E(null);const n=["Multiple Choice","Checkbox"];for(const e of f){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=J.filter((e=>"finished"===e.status)),o=J.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=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(B).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];Z(!0);const t=yield W(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Z(!1)}else if(a&&r&&!i.length)return void V("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),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),D("fetching"),M(),F();const h=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:b,pickaxeId:x,senderType:y,valueObj:g},m&&{documentIds:p}),j&&{sender:j}),A&&{studioSessionToken:A}),!A&&!j&&{sender:d.initializeEmbedUserId()}),O&&{portalId:O}),w&&{deploymentId:w}))}),v=yield h.json();if(!v.success){const e=new Error(v.error||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}const S=v.submissionId,I=v.sessionId,k={sessionId:I,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};E(k),(null==C?void 0:C.enablechatresponses)&&(_(I),P(!1),R(!0),T([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&X([]),D("streaming"),ee.current=new AbortController;const $=[];let te=[...null!=G?G:[]],se=0,ne=!1,ie="";for(;!ne;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${S}?index=${se}`,{signal:null===(s=ee.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&&se++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return L(t),void(ne=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ie="",$.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("text-end"===n.type)ie="";else if("reasoning-start"===n.type)ie="",$.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ie+=n.delta,$[$.length-1].content=ie;else if("reasoning-end"===n.type)ie="";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:[...$]})});E(i),(null==C?void 0:C.enablechatresponses)&&T([{id:0,role:"assistant",parts:[...$],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);te=te.filter((e=>!(e.id===t.id&&e.version===t.version))),te.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...te]),z.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");te=te.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Q([...te])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Q(te.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else ne=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}ne||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(ne=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==q||q(I)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),L(t),F()}finally{D("idle"),Z(!1),$()}}))},{children:H?(null==I?void 0:I.processing)||"Processing...":K?(null==I?void 0:I.uploading)||"Uploading...":N?(null==I?void 0:I.loading)||"Loading...":null!==(v=null==C?void 0:C.submittext)&&void 0!==v?v:"Submit"})),te&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||N||H,onClick:h},{children:(null==I?void 0:I["clear-form"])||"Clear form"}))]})),!S.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
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:m,deploymentDimensions:S,deploymentMisc:b,styles:v,colors:g,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:H=!1,allowGuestUsage:M=!0,preventInitialSessionId:R=!1,onGenerateComplete:_,onSessionIdChange:G})=>{const[L,B]=s.useState(""),[N,U]=s.useState(""),[W,z]=s.useState(""),[J,V]=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(null),[oe,ne]=s.useState(null),[re,ae]=s.useState(null),[le,de]=s.useState(!1),[ce,ue]=s.useState(!0),[pe,fe]=s.useState(!0),[ye,he]=s.useState(!1);return s.useEffect((()=>{de(!1)}),[null==v?void 0:v.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!le&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{de(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),de(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),de(!0)}}))}),[T,le,null==v?void 0:v.font]),s.useEffect((()=>{K(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:L,pickaxeId:N,sessionId:W,lastSessionId:J,sender:Y,senderType:Z,portalId:h,deploymentId:y,deploymentType:m,validationStatus:ee,deploymentDimensions:S,deploymentMisc:b,accessGroup:Q,pickaxe:re,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},g),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:le,isNewChat:ce,isShowIceBreaker:pe,isShowFeedbackMessage:ye,isRtl:q,isEmbed:E,isDropShadow:H,allowGuestUsage:M,clientSecret:oe,stripeAccountId:se,preventInitialSessionId:R,setClientSecret:ne,setStripeAccountId:ie,setContextId:B,setValidationStatus:te,setPickaxeId:U,setSessionId:e=>{z((t=>{const s="function"==typeof e?e(t):e;return null==G||G(s),s}))},setLastSessionId:V,setSender:K,setSenderType:$,setAccessGroup:X,setPickaxe:ae,setIsFontLoaded:de,setIsNewChat:ue,setIsShowIceBreaker:fe,setIsShowFeedbackMessage:he},_&&{onGenerateComplete:_})},{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
+ "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"),v=require("../Icons/lock.svg.js"),b=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"),k=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const y=({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:w,className:N})=>{const{sessionId:q,styles:_,colors:O,responsiveBy:C,deploymentType:A,isNewChat:S,isEmbed:I,opacity:P,deploymentId:E,sender:L,portalId:R,validationStatus:T,stripeAccountId:D,clientSecret:G,preventInitialSessionId:M,setClientSecret:U,setStripeAccountId:B,setValidationStatus:F,setContextId:$,setPickaxeId:W,setSessionId:z,setPickaxe:H,setAccessGroup:J}=i.usePickaxeContext(),{isSent:K,token:V}=r.useAuthContext(),{setMessages:X,setResponse:Y,setError:Q,setLimitData:Z,setIsSwitchedToChat:ee}=l.useResponseContext(),{setDocumentError:se}=o.useDocumentContext(),{setCurrentArtifact:te}=c.useArtifactContext(),[ae,ie]=a.useState(!1),[re,le]=a.useState([]),[oe,ce]=a.useState(null),ne=t.usePickaxe(),de="chat-input"===A&&S&&!K,ue=a.useMemo((()=>D?k.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:D}):null),[D]);a.useEffect((()=>{W(w)}),[w]);a.useEffect((()=>{if(!E&&!R||!ne.data)return;if("stripe_checkout"===T)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;F("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:E,sender:L||void 0,studioSessionToken:V,portalId:R,studioId:null===(e=ne.data)||void 0===e?void 0:e.studioid}});s.data.success?(F("success"),J(s.data.accessGroup)):"Login required."===s.data.message?(F("login_required"),ie(!0)):"Access denied."===s.data.message?(F("access_denied"),le(s.data.upgradeGroups||[]),ie(!0)):"Upgrade required."===s.data.message?(F("upgrade_required"),le(s.data.upgradeGroups||[]),ce(s.data.upgradeUrl),ie(!0)):F("login_required")}catch(e){console.error("Failed to validate deployment:",e),F("success")}}))}),[E,L,V,R,ne.data]),a.useEffect((()=>{if(!ne.data)return;const e=ne.data.chatflag;M||z(e?n.v4():""),$(n.v4()),e?X([]):Y(null),Q(""),se(""),Z(null),te(null),ee(!1),H(ne.data),ie(!0)}),[ne.data]),a.useEffect((()=>{Q(""),se(""),Z(null),X([]),Y(null),te(null)}),[q]);const xe=a.useMemo((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${s}`}),[O.primary,P]);if(!ne.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",N),style:Object.assign({backgroundColor:de?"transparent":xe,color:O.text},_.font&&"Real Head Pro"!==_.font&&{fontFamily:_.font})},{children:"stripe_checkout"===T&&G&&ue?s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:O.secondary||"#ffffff",color:O.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:()=>{U&&U(null),B&&B(null),F("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:O.text}},{children:[s.jsx(y,{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(b.EmbeddedCheckoutProvider,Object.assign({stripe:ue,options:{clientSecret:G}},{children:s.jsx(b.EmbeddedCheckout,{})}))}))]})):ne.isLoading||!ae||"loading"===T?s.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===C?"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"===C?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===T?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:re&&re.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:re.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:oe},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"===T&&I?s.jsx(p.default,{}):"login_required"!==T||I?"access_denied"===T?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===(me=ne.data)||void 0===me?void 0:me.coverphoto,alt:`${null===(pe=ne.data)||void 0===pe?void 0:pe.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(v.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:O.accent,color:O.accentText,borderRadius:_.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=re.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:L||void 0,studioSessionToken:V,studioId:null===(e=ne.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=ne.data)||void 0===s?void 0:s.formid,deploymentId:E,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 me,pe};
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 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js");require("../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var t=require("react-speech-recognition"),i=require("web-speech-cognitive-services"),r=require("react"),n=require("../../common/api/pickaxe.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(t);exports.useSpeech=()=>{const{transcript:o,listening:a,resetTranscript:c}=t.useSpeechRecognition(),[u,l]=r.useState(!1),[p,d]=r.useState(!1);return{speechTranscript:o,isSpeechSupported:!0,isSpeechProcessing:u,isSpeechListening:a,onStartListening:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{l(!0),yield navigator.mediaDevices.getUserMedia({audio:!0});const e=(yield n.default.post("/speech")).data;if(!p){const{SpeechRecognition:t}=i.createSpeechServicesPonyfill({credentials:{region:"eastus",authorizationToken:e.token}});s.default.applyPolyfill(t),d(!0)}c();const r={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",hi:"hi-IN",it:"it-IT",iw:"he-IL",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};yield s.default.startListening({continuous:!0,interimResults:!0,language:r[t]||"en-US"})}catch(e){console.error(e)}finally{l(!1)}})),onStopListening:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{l(!0),yield s.default.abortListening()}catch(e){console.error(e)}finally{l(!1)}}))}};
@@ -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 {};
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import "regenerator-runtime/runtime";
3
2
  export interface InputHandle {
4
3
  onSubmit: (msg?: string) => Promise<void>;
5
4
  }
@@ -1,5 +1,4 @@
1
1
  import type { MemoryStoredQuestionField } from "../../../../types/form";
2
- import "regenerator-runtime/runtime";
3
2
  interface InputProps {
4
3
  field: MemoryStoredQuestionField;
5
4
  update: (questions: MemoryStoredQuestionField) => void;
@@ -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,9 @@
1
+ import "regenerator-runtime/runtime";
2
+ export declare const useSpeech: () => {
3
+ speechTranscript: string;
4
+ isSpeechSupported: boolean;
5
+ isSpeechProcessing: boolean;
6
+ isSpeechListening: boolean;
7
+ onStartListening: (locale: string) => Promise<void>;
8
+ onStopListening: () => Promise<void>;
9
+ };
@@ -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};