@pickaxeproject/react 5.5.0 → 5.5.2

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../Icons/save.svg.js"),t=require("../../../../Core/Menu/index.js"),a=require("../../../../Core/Menu/Button.js"),l=require("../../../../Core/Menu/List.js");exports.default=({variant:n="default",className:i,children:c,data:r,colors:o,onDownload:x,onSaveAsPDF:d,onSaveAsDOCX:p})=>e.jsxs(t.default,Object.assign({id:`save-artifact-${r.id}-${r.version}`},{children:[e.jsx(a.default,Object.assign({variant:n,className:i,style:{color:o.text}},{children:c})),e.jsx(l.default,Object.assign({width:"auto",className:"font-semibold p-1 text-sm",style:{backgroundColor:o.primary,color:o.text},border:`1px solid ${o.primary}`},{children:"text/markdown"===r.type?e.jsxs(e.Fragment,{children:[e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/markdown")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"Markdown"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:p},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"DOCX"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/plain")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TXT"]}))]}):"text/html"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/html")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"HTML"]})):"text/csv"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/csv")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"CSV"]})):"text/tab-separated-values"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/tab-separated-values")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSV"]})):"image/svg+xml"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("image/svg+xml")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.code"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.code")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),`${r.programmingLanguage||"Plain Text"}`]})):"application/vnd.pxe.mermaid"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.mermaid")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.react"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.react")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSX"]})):null}))]}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../Icons/save.svg.js"),t=require("../../../../Core/Menu/index.js"),a=require("../../../../Core/Menu/Button.js"),l=require("../../../../Core/Menu/List.js");exports.default=({variant:n="default",className:i,children:c,data:r,colors:x,onDownload:o,onSaveAsPDF:d,onSaveAsDOCX:p})=>e.jsxs(t.default,Object.assign({id:`save-artifact-${r.id}-${r.version}`},{children:[e.jsx(a.default,Object.assign({variant:n,className:i,style:{color:x.text}},{children:c})),e.jsx(l.default,Object.assign({width:"auto",className:"font-semibold p-1 text-sm",style:{backgroundColor:x.primary,color:x.text},border:`1px solid ${x.primary}`},{children:"text/markdown"===r.type?e.jsxs(e.Fragment,{children:[e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("text/markdown")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"Markdown"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:p},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"DOCX"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("text/plain")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TXT"]}))]}):"text/html"===r.type?e.jsxs(e.Fragment,{children:[e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("text/html")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"HTML"]})),e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]}))]}):"text/csv"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("text/csv")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"CSV"]})):"text/tab-separated-values"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("text/tab-separated-values")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSV"]})):"image/svg+xml"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("image/svg+xml")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.code"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("application/vnd.pxe.code")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),`${r.programmingLanguage||"Plain Text"}`]})):"application/vnd.pxe.mermaid"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("application/vnd.pxe.mermaid")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.react"===r.type?e.jsxs("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>o("application/vnd.pxe.react")},{children:[e.jsx(s.default,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSX"]})):null}))]}));
@@ -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;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"),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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("./hooks/useDocument.js"),l=require("../../../../common/utils.js"),i=require("../../../Icons/spinner-lines.svg.js"),c=require("../../../Icons/file.svg.js"),n=require("../../../Icons/x.svg.js"),o=require("../../../Icons/circle-info.svg.js"),u=require("../../../../common/cn.js");exports.default=({className:d,isDisabled:f})=>{const{styles:h,colors:m,translations:x,isRtl:j}=t.usePickaxeContext(),{documents:b,isUploading:g,removeDocument:p}=r.useDocument(),v=a.useStyleFontSize();return e.jsx("div",Object.assign({className:u.default("flex flex-row gap-3 flex-wrap",d)},{children:b.map(((t,a)=>{var r,d,b,y,k,N;return e.jsx(s.Fragment,{children:"document"===t.type?e.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:m.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(o.default,{className:"w-5 h-5 shrink-0"}):e.jsx(c.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:u.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:u.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(r=t.error)||void 0===r?void 0:r.includes("You have reached the file limit"))?null!==(d=null==x?void 0:x["file-limit-reached"])&&void 0!==d?d:"You have reached the file limit.":t.error:l.formatBytes(t.size)}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(n.default,{className:"w-4 h-4 shrink-0"})}))]})):"image"===t.type?e.jsxs("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:["finished"===t.status?e.jsx("img",{className:"object-cover w-full h-full",style:{borderRadius:h.cornerRadius},src:`https://cdn.mail.studio/documentinterrogation/${null!==(b=t.folder)&&void 0!==b?b:"jpg"}/${t.documentId}.${null!==(y=t.folder)&&void 0!==y?y:"jpg"}`,alt:""}):"failed"===t.status?e.jsx(o.default,{className:"w-5 h-5 shrink-0"}):e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(n.default,{className:"w-4 h-4 shrink-0"})}))]})):"website"===t.type?e.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:m.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:m.accent,color:m.accentText},"failed"===t.status&&{backgroundColor:m.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(o.default,{className:"w-5 h-5 shrink-0"}):e.jsx(c.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:u.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:u.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(k=t.error)||void 0===k?void 0:k.includes("You have reached the file limit"))?null!==(N=null==x?void 0:x["file-limit-reached"])&&void 0!==N?N:"You have reached the file limit.":t.error:"Website "}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:m.accent,color:m.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(n.default,{className:"w-4 h-4 shrink-0"})}))]})):null},a)}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("./hooks/useDocument.js"),l=require("../../../../common/utils.js"),o=require("../../../Icons/spinner-lines.svg.js"),n=require("../../../Icons/file.svg.js"),c=require("../../../Icons/x.svg.js"),d=require("../../../Icons/circle-info.svg.js"),u=require("../../../../common/cn.js");exports.default=({className:f,isDisabled:m})=>{const{styles:h,colors:x,translations:j,isRtl:b}=i.usePickaxeContext(),{documents:g,isUploading:p,removeDocument:v}=r.useDocument(),{sessionId:y,contextId:k}=i.usePickaxeContext(),N=a.useStyleFontSize();return s.jsx("div",Object.assign({className:u.default("flex flex-row gap-3 flex-wrap",f)},{children:g.map(((i,a)=>{var r,f,g,w,O,_;return s.jsx(t.Fragment,{children:"document"===i.type?s.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",b&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:x.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===i.status&&{backgroundColor:x.error,color:"white"})},{children:"uploading"===i.status?s.jsx(o.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===i.status?s.jsx(d.default,{className:"w-5 h-5 shrink-0"}):s.jsx(n.default,{className:"w-5 h-5 shrink-0"})})),s.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",b?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:u.default(N.b3,"font-medium truncate")},{children:i.name})),s.jsx("p",Object.assign({className:u.default(N.b4,"opacity-80 truncate")},{children:"failed"===i.status?(null===(r=i.error)||void 0===r?void 0:r.includes("You have reached the file limit"))?null!==(f=null==j?void 0:j["file-limit-reached"])&&void 0!==f?f:"You have reached the file limit.":i.error:l.formatBytes(i.size)}))]})),!p&&s.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",b?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:p||m,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(v(i.id),"failed"!==i.status){const e=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/decrement_document_count?sessionid=${k}&responseid=${y}&documentid=${i.documentId}`;yield fetch(e)}}))},{children:s.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):"image"===i.type?s.jsxs("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===i.status&&{backgroundColor:x.error,color:"white"})},{children:["finished"===i.status?s.jsx("img",{className:"object-cover w-full h-full",style:{borderRadius:h.cornerRadius},src:`https://cdn.mail.studio/documentinterrogation/${null!==(g=i.folder)&&void 0!==g?g:"jpg"}/${i.documentId}.${null!==(w=i.folder)&&void 0!==w?w:"jpg"}`,alt:""}):"failed"===i.status?s.jsx(d.default,{className:"w-5 h-5 shrink-0"}):s.jsx(o.default,{className:"w-5 h-5 animate-spin shrink-0"}),!p&&s.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",b?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:p||m,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(v(i.id),"failed"!==i.status){const e=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/decrement_document_count?sessionid=${k}&responseid=${y}&documentid=${i.documentId}`;yield fetch(e)}}))},{children:s.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):"website"===i.type?s.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",b&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:x.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===i.status&&{backgroundColor:x.error,color:"white"})},{children:"uploading"===i.status?s.jsx(o.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===i.status?s.jsx(d.default,{className:"w-5 h-5 shrink-0"}):s.jsx(n.default,{className:"w-5 h-5 shrink-0"})})),s.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",b?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:u.default(N.b3,"font-medium truncate")},{children:i.name})),s.jsx("p",Object.assign({className:u.default(N.b4,"opacity-80 truncate")},{children:"failed"===i.status?(null===(O=i.error)||void 0===O?void 0:O.includes("You have reached the file limit"))?null!==(_=null==j?void 0:j["file-limit-reached"])&&void 0!==_?_:"You have reached the file limit.":i.error:"Website "}))]})),!p&&s.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",b?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:p||m,onClick:()=>v(i.id)},{children:s.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):null},a)}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");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"),a=require("../../../../hooks/studio/useStyleInput.js"),i=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})=>{var m;const{styles:j,colors:f,isRtl:b,pickaxe:v,locale:y}=o.usePickaxeContext(),{setError:O}=r.useResponseContext(),[k,N]=s.useState(!1),q=i.useStyleFontSize(),w=a.useStyleInput(),{transcript:S,listening:C,resetTranscript:R,browserSupportsSpeechRecognition:_}=n.useSpeechRecognition(),L=s.useRef(""),I=l.useHover(),{isHover:T}=I,z=e.__rest(I,["isHover"]),F=_&&(null==v?void 0:v.enablevoicetotext),H=e=>{O("");const t=e.length;h(Object.assign(Object.assign({},g),{input:e,length:t}))};s.useEffect((()=>{if(!C)return;const e=L.current?`${L.current} `:"";H(`${e}${S}`)}),[S,C]);return t.jsxs("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:b?"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(q.b3,"font-semibold opacity-70")},{children:g.main})),g.isRequired&&t.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:f.accent}},{children:"*"}))]})),t.jsxs("div",Object.assign({className:"relative w-full"},{children:[C&&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",b?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(m=f.accent)&&void 0!==m?m:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm font-semilight",style:{color:f.text+"90"}},{children:"Listening..."}))]})),t.jsx(c.default,{className:p.default(q.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",b?F?"pl-10 pr-4":"px-4":F?"pl-4 pr-10":"px-4",g.maxLength<10&&"max-w-[400px]","block"===j.formFieldStyle&&"shadow hover:shadow-none",C&&"caret-transparent"),style:Object.assign(Object.assign({},w),C&&{color:"transparent"}),placeholder:C?"":g.placeholder,rows:1,value:g.input,tabIndex:g.order,onChange:H,onFocus:()=>N(!0),onBlur:()=>N(!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)}}),F&&t.jsx("div",Object.assign({className:p.default("absolute top-2 z-20",b?"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:C?f.accent:T?f.accent+"10":void 0,color:C?f.accentText:T?f.accent:f.accent+"80"},onClick:()=>{C?x.default.stopListening():(L.current=g.input||"",R(),x.default.startListening({continuous:!0,interimResults:!0,language:y||"en-US"}),N(!0))}},z,{type:"button"},{children:C?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(q.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",g.length>g.maxLength&&"text-c-red opacity-100",k&&"opacity-100")},{children:[g.length,"/",g.maxLength]}))}))]}))};
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../Core/ErrorAlert.js"),a=require("../../common/PickaxeUpgradeCard.js"),o=require("./Input.js"),u=require("./Option.js"),n=require("./Document.js"),l=require("./Checkbox.js"),d=require("./Submit.js");exports.default=()=>{const{pickaxe:p,translations:c}=r.usePickaxeContext(),{error:x}=s.useResponseContext(),[m,f]=t.useState([]),[j,h]=t.useState([]),g=e=>{f((t=>t.map((t=>t.id===e.id?e:t))))},q=t.useMemo((()=>j),[j]);return t.useEffect((()=>{if(!p)return;if(!p._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!p.updatedAt||new Date(p.updatedAt)<e,r=p._questions.map(((e,r)=>{var s;let i="";const a="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||a||(i=t[0])}let o=e.secondary||"";return t&&(o=e.secondary||("Knowledge Upload"===e.type?null!==(s=null==c?void 0:c["form-doc-placeholder"])&&void 0!==s?s:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:r+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:o,allowOther:a},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));f(r),h(r)}),[p]),e.jsxs("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[m.map(((r,s)=>"Multiple Choice"===r.type?e.jsx(t.Fragment,{children:e.jsx(u.default,{field:r,update:g})},s):"Checkbox"===r.type?e.jsx(t.Fragment,{children:e.jsx(l.default,{field:r,update:g})},s):"userinput:documentupload"===r.id?e.jsx(t.Fragment,{children:e.jsx(n.default,{field:r,update:g})},s):e.jsx(t.Fragment,{children:e.jsx(o.default,{field:r,update:g})},s))),e.jsx(i.default,{error:x}),e.jsx(a.default,{}),e.jsx(d.default,{questions:m,update:g,resetQuestions:()=>f(q)})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../Core/ErrorAlert.js"),a=require("../../common/PickaxeUpgradeCard.js"),o=require("./Input.js"),u=require("./Option.js"),l=require("./Document.js"),n=require("./Checkbox.js"),d=require("./Submit.js");exports.default=()=>{const{pickaxe:p,translations:c}=r.usePickaxeContext(),{error:x}=s.useResponseContext(),[m,f]=t.useState([]),[j,h]=t.useState([]),[g,q]=t.useState(null),w=e=>{f((t=>t.map((t=>t.id===e.id?e:t))))},y=t.useMemo((()=>j),[j]);return t.useEffect((()=>{if(!p)return;if(!p._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!p.updatedAt||new Date(p.updatedAt)<e,r=p._questions.map(((e,r)=>{var s;let i="";const a="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||a||(i=t[0])}let o=e.secondary||"";return t&&(o=e.secondary||("Knowledge Upload"===e.type?null!==(s=null==c?void 0:c["form-doc-placeholder"])&&void 0!==s?s:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:r+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:o,allowOther:a},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));f(r),h(r)}),[p]),e.jsxs("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[m.map(((r,s)=>"Multiple Choice"===r.type?e.jsx(t.Fragment,{children:e.jsx(u.default,{field:r,update:w})},s):"Checkbox"===r.type?e.jsx(t.Fragment,{children:e.jsx(n.default,{field:r,update:w})},s):"userinput:documentupload"===r.id?e.jsx(t.Fragment,{children:e.jsx(l.default,{field:r,update:w})},s):e.jsx(t.Fragment,{children:e.jsx(o.default,{field:r,update:w,activeVoiceId:g,setActiveVoiceId:q})},s))),e.jsx(i.default,{error:x}),e.jsx(a.default,{}),e.jsx(d.default,{questions:m,update:w,resetQuestions:()=>f(y)})]}))};
@@ -3,6 +3,8 @@ import "regenerator-runtime/runtime";
3
3
  interface InputProps {
4
4
  field: MemoryStoredQuestionField;
5
5
  update: (questions: MemoryStoredQuestionField) => void;
6
+ activeVoiceId: string | null;
7
+ setActiveVoiceId: (id: string | null) => void;
6
8
  }
7
- declare const Input: ({ field, update }: InputProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const Input: ({ field, update, activeVoiceId, setActiveVoiceId, }: InputProps) => import("react/jsx-runtime").JSX.Element;
8
10
  export default Input;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import a from"../../../../Icons/save.svg.js";import s from"../../../../Core/Menu/index.js";import i from"../../../../Core/Menu/Button.js";import l from"../../../../Core/Menu/List.js";const c=({variant:c="default",className:o,children:r,data:m,colors:p,onDownload:x,onSaveAsPDF:d,onSaveAsDOCX:b})=>e(s,Object.assign({id:`save-artifact-${m.id}-${m.version}`},{children:[t(i,Object.assign({variant:c,className:o,style:{color:p.text}},{children:r})),t(l,Object.assign({width:"auto",className:"font-semibold p-1 text-sm",style:{backgroundColor:p.primary,color:p.text},border:`1px solid ${p.primary}`},{children:"text/markdown"===m.type?e(n,{children:[e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/markdown")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"Markdown"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:b},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"DOCX"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/plain")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TXT"]}))]}):"text/html"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/html")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"HTML"]})):"text/csv"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/csv")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"CSV"]})):"text/tab-separated-values"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/tab-separated-values")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSV"]})):"image/svg+xml"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("image/svg+xml")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.code"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.code")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),`${m.programmingLanguage||"Plain Text"}`]})):"application/vnd.pxe.mermaid"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.mermaid")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.react"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.react")},{children:[t(a,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSX"]})):null}))]}));export{c as default};
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import s from"../../../../Icons/save.svg.js";import a from"../../../../Core/Menu/index.js";import l from"../../../../Core/Menu/Button.js";import i from"../../../../Core/Menu/List.js";const c=({variant:c="default",className:o,children:r,data:m,colors:p,onDownload:x,onSaveAsPDF:d,onSaveAsDOCX:h})=>e(a,Object.assign({id:`save-artifact-${m.id}-${m.version}`},{children:[t(l,Object.assign({variant:c,className:o,style:{color:p.text}},{children:r})),t(i,Object.assign({width:"auto",className:"font-semibold p-1 text-sm",style:{backgroundColor:p.primary,color:p.text},border:`1px solid ${p.primary}`},{children:"text/markdown"===m.type?e(n,{children:[e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/markdown")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"Markdown"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:h},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"DOCX"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/plain")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TXT"]}))]}):"text/html"===m.type?e(n,{children:[e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/html")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"HTML"]})),e("button",Object.assign({className:"px-2 py-1 text-left",onClick:d},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"PDF"]}))]}):"text/csv"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/csv")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"CSV"]})):"text/tab-separated-values"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("text/tab-separated-values")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSV"]})):"image/svg+xml"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("image/svg+xml")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.code"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.code")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),`${m.programmingLanguage||"Plain Text"}`]})):"application/vnd.pxe.mermaid"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.mermaid")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"SVG"]})):"application/vnd.pxe.react"===m.type?e("button",Object.assign({className:"px-2 py-1 text-left",onClick:()=>x("application/vnd.pxe.react")},{children:[t(s,{className:"w-5 h-5 shrink-0 inline-block mr-2"}),"TSX"]})):null}))]}));export{c as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useMemo as i,useEffect as a}from"react";import{useArtifactContext as l}from"../hooks/useArtifactContext.js";import{usePickaxeContext as c}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useScroll as s}from"../../Scroll/hooks/useScroll.js";import{useArtifact as d}from"../hooks/useArtifact.js";import{useReactToPrint as p}from"react-to-print";import{PickaxeMarkdown as m}from"../../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as u}from"../../../common/PickaxeMarkdown/Renderer.js";import{Prism as v}from"react-syntax-highlighter";import{convertMarkdownToDocx as y,downloadDocx as x}from"../../../../../common/docx/index.js";import f from"file-saver";import g from"../../Scroll/ScrollLockView.js";import h from"../../../../Icons/x.svg.js";import b from"../../../../Icons/save.svg.js";import C from"../../../../Icons/expand.svg.js";import w from"../../../../Icons/shrink.svg.js";import k from"../../../../Icons/copy.svg.js";import j from"../../../common/PickaxeCopyButton.js";import F from"../../../../Core/ScrollArea.js";import T from"../../../../Core/TipContainer.js";import O from"../MermaidRenderer.js";import A from"./SaveMenu.js";import S from"./ViewOptions.js";import D from"csv-to-markdown-table";import N from"copy-to-clipboard";import E from"../../../../../common/cn.js";const B="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",$=$=>{var z,M,W,L;const{artifacts:P,currentPopupType:R,currentArtifact:H,setCurrentArtifact:I}=l(),{onLoadArtifact:_}=d(),{styles:V,colors:X,translations:q}=c(),[G,J]=n("code"),[K,Q]=n(!1),U=r(),Y=r(null),Z=r(null),ee=p({contentRef:U}),{scrollContainerRef:oe,scrollStartSession:te,scrollToBottom:ne,scrollEndSession:re}=s({auto:"code"===G}),ie=null!==(M=null===(z=$.styling)||void 0===z?void 0:z.styles)&&void 0!==M?M:V,ae=null!==(L=null===(W=$.styling)||void 0===W?void 0:W.colors)&&void 0!==L?L:X,le=i((()=>{var e,o,t,n,r;if(!$.artifact&&!H)return null;const i=null!==(o=null===(e=$.artifact)||void 0===e?void 0:e.id)&&void 0!==o?o:null==H?void 0:H.id,a=null!==(n=null===(t=$.artifact)||void 0===t?void 0:t.version)&&void 0!==n?n:null==H?void 0:H.version;return null!==(r=P.find((e=>e.id===i&&e.version===a)))&&void 0!==r?r:null}),[H,P,$.artifact]),ce=i((()=>le?"text/csv"===le.type?D(le.content,",",!0):"text/tab-separated-values"===le.type?D(le.content,"\t",!0):null:null),[le]),se=i((()=>(ae.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==ae?void 0:ae.secondaryText]),de=i((()=>{const e=$.artifact&&(null==H?void 0:H.id)===$.artifact.id&&(null==H?void 0:H.version)===$.artifact.version;return"inline"===$.type&&("inline-form"===R?!!H:e)}),[H,R,$.type,$.artifact]);a((()=>{e(void 0,void 0,void 0,(function*(){"inline"===$.type&&$.artifact&&(P.some((e=>$.artifact&&e.id===$.artifact.id&&e.version===$.artifact.version))||_({id:$.artifact.id,version:$.artifact.version}))}))}),[P,$.type,$.artifact]),a((()=>{if("application/vnd.pxe.code"===(null==le?void 0:le.type)&&J("code"),"finished"!==(null==le?void 0:le.status))return J("code"),te(),void ne();re(),"application/vnd.pxe.code"!==le.type&&J("render")}),[null==le?void 0:le.status,null==le?void 0:le.type]),a((()=>{var e;!Z.current||"text/html"!==(null==le?void 0:le.type)&&"application/vnd.pxe.react"!==(null==le?void 0:le.type)||null===(e=Z.current.contentWindow)||void 0===e||e.postMessage({type:"text/html"===le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}),[null==le?void 0:le.content,null==le?void 0:le.type]);const pe=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;const e=G;"code"===e&&(J("render"),yield new Promise((e=>setTimeout(e,50)))),ee(),"code"===e&&J(e)})),me=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;const e=yield y(le.content);x(e,`${le.title}.docx`)})),ue=o=>e(void 0,void 0,void 0,(function*(){var e;if(!le)return;let t={mimeType:"text/plain",extension:".txt"};switch(o){case"text/markdown":t={mimeType:"text/markdown",extension:".md"};break;case"text/html":t={mimeType:"text/html",extension:".html"};break;case"text/csv":t={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":t={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":t={mimeType:"image/svg+xml",extension:".svg"};break;case"application/vnd.pxe.code":t={mimeType:`application/${le.programmingLanguage||"text"};charset=utf-8`,extension:`.${le.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":t={mimeType:"text/typescript",extension:".tsx"};break;default:t={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===le.type){const o=G;"code"===o&&(J("render"),yield new Promise((e=>setTimeout(e,50))));const t=null===(e=Y.current)||void 0===e?void 0:e.querySelector("svg");t&&(n=(new XMLSerializer).serializeToString(t)),"code"===o&&J(o)}const r=new Blob([null!=n?n:le.content],{type:t.mimeType});f(r,`${le.title}${t.extension}`)}));return le?o("div",Object.assign({className:E("pxe-artifact-renderer flex flex-col","inline"===$.type&&!de&&"min-h-[320px] mb-6",$.className),style:Object.assign(Object.assign({backgroundColor:ae.secondary,color:ae.secondaryText},"auto"!==R&&{borderRadius:ie.cornerRadius}),$.style)},{children:[o("div",Object.assign({className:"flex items-center gap-6 justify-between p-4 shadow-sm"},{children:[o("div",Object.assign({className:"pxe-artifact-create-header flex items-center gap-4 truncate"},{children:[(de||!R.startsWith("inline"))&&t(S,{type:le.type,view:G,colors:ae,onChange:J}),t("p",Object.assign({className:"font-semilight truncate text-xl"},{children:le.title}))]})),o("div",Object.assign({className:"flex items-center gap-4"},{children:["code"===G&&(de||!R.startsWith("inline"))&&o("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:ae.secondaryText},disabled:K,onClick:()=>e(void 0,void 0,void 0,(function*(){try{N(le.content),Q(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{Q(!1)}}))},{children:[t(k,{className:"w-5 h-5 shrink-0"}),(null==q?void 0:q.copy)||"Copy"]})),(de||!R.startsWith("inline"))&&t(A,Object.assign({variant:"anchor",className:"px-3 py-1.5 shrink-0",data:le,colors:ae,onDownload:ue,onSaveAsPDF:pe,onSaveAsDOCX:me},{children:t("span",Object.assign({className:"shrink-0 font-semibold text-sm select-none"},{children:(null==q?void 0:q["save-as"])||"Save as"}))})),t("button",Object.assign({style:{color:ae.secondaryText},onClick:()=>{"inline"!==$.type||!$.artifact||de?I(null):I({id:$.artifact.id,version:$.artifact.version})}},{children:"inline"===$.type?t(de?w:C,{className:"w-6 h-6 shrink-0"}):t(h,{className:"w-6 h-6 shrink-0"})}))]}))]})),t("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:o(F,Object.assign({ref:oe,innerClassName:"flex-grow w-full"},{children:["render"===G&&"application/vnd.pxe.code"!==le.type?t("div",Object.assign({ref:U,className:E("p-4 pb-6 flex-grow flex flex-col","application/vnd.pxe.react"===le.type&&"p-0","text/html"===le.type&&"p-0","text/csv"===le.type&&"p-0")},{children:"text/markdown"===le.type||"text/csv"===le.type||"text/tab-separated-values"===le.type||"image/svg+xml"===le.type?t(m,Object.assign({theme:ie.theme,colors:ae},{children:t(u,{value:null!=ce?ce:le.content,className:E("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===le.type||"text/tab-separated-values"===le.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===le.type?t(O,{ref:Y,id:`mermaid-${le.id}-${le.version}`,data:le.content}):"text/html"===le.type||"application/vnd.pxe.react"===le.type?t("iframe",Object.assign({ref:Z,title:le.title,src:`${B}/${"text/html"===le.type?"html":"react"}?theme=${se?"dark":"light"}&bg=${ae.secondary}&accent=${ae.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==ae?void 0:ae.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 o=e.target;setTimeout((()=>{var e;try{null===(e=o.contentWindow)||void 0===e||e.postMessage({type:"text/html"===le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}catch(e){console.error("Error sending message to iframe:",e)}}),100),ne()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t(v,Object.assign({PreTag:"div",language:"text/markdown"===le.type?"markdown":"text/html"===le.type||"image/svg+xml"===le.type?"xml":"application/vnd.pxe.react"===le.type?"typescript":le.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==ae?void 0:ae.secondaryText},se&&{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==ae?void 0:ae.secondaryText},se&&{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==ae?void 0:ae.secondary}),':not(pre) > code[class*="language-"]':{background:null==ae?void 0:ae.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==ae?void 0:ae.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!se&&{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==ae?void 0:ae.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:le.content})),t(g,{})]}))})),"inline"===$.type&&!de&&o("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t(T,Object.assign({id:`artifact-copy-${le.id}-${le.version}`,tip:(null==q?void 0:q.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:ae.secondary,color:ae.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(j,{color:ae.secondaryText,text:le.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t(T,Object.assign({id:`artifact-save-${le.id}-${le.version}`,tip:(null==q?void 0:q.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:ae.secondary,color:ae.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(A,Object.assign({data:le,colors:ae,onDownload:ue,onSaveAsPDF:pe,onSaveAsDOCX:me},{children:t("button",Object.assign({style:{color:ae.secondaryText}},{children:t(b,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};export{$ as default};
1
+ import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useMemo as i,useEffect as a}from"react";import{useArtifactContext as l}from"../hooks/useArtifactContext.js";import{usePickaxeContext as c}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useScroll as s}from"../../Scroll/hooks/useScroll.js";import{useArtifact as d}from"../hooks/useArtifact.js";import{useReactToPrint as p}from"react-to-print";import{PickaxeMarkdown as m}from"../../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as u}from"../../../common/PickaxeMarkdown/Renderer.js";import{Prism as v}from"react-syntax-highlighter";import{convertMarkdownToDocx as y,downloadDocx as x}from"../../../../../common/docx/index.js";import f from"file-saver";import g from"../../Scroll/ScrollLockView.js";import h from"../../../../Icons/x.svg.js";import b from"../../../../Icons/save.svg.js";import C from"../../../../Icons/expand.svg.js";import w from"../../../../Icons/shrink.svg.js";import k from"../../../../Icons/copy.svg.js";import j from"../../../common/PickaxeCopyButton.js";import F from"../../../../Core/ScrollArea.js";import T from"../../../../Core/TipContainer.js";import O from"../MermaidRenderer.js";import A from"./SaveMenu.js";import S from"./ViewOptions.js";import D from"csv-to-markdown-table";import N from"copy-to-clipboard";import E from"../../../../../common/cn.js";const B="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",$=$=>{var z,M,W,L;const{artifacts:P,currentPopupType:R,currentArtifact:H,setCurrentArtifact:I}=l(),{onLoadArtifact:_}=d(),{styles:V,colors:X,translations:q}=c(),[G,J]=n("code"),[K,Q]=n(!1),U=r(),Y=r(null),Z=r(null),ee=p({contentRef:U}),{scrollContainerRef:oe,scrollStartSession:te,scrollToBottom:ne,scrollEndSession:re}=s({auto:"code"===G}),ie=null!==(M=null===(z=$.styling)||void 0===z?void 0:z.styles)&&void 0!==M?M:V,ae=null!==(L=null===(W=$.styling)||void 0===W?void 0:W.colors)&&void 0!==L?L:X,le=i((()=>{var e,o,t,n,r;if(!$.artifact&&!H)return null;const i=null!==(o=null===(e=$.artifact)||void 0===e?void 0:e.id)&&void 0!==o?o:null==H?void 0:H.id,a=null!==(n=null===(t=$.artifact)||void 0===t?void 0:t.version)&&void 0!==n?n:null==H?void 0:H.version;return null!==(r=P.find((e=>e.id===i&&e.version===a)))&&void 0!==r?r:null}),[H,P,$.artifact]),ce=i((()=>le?"text/csv"===le.type?D(le.content,",",!0):"text/tab-separated-values"===le.type?D(le.content,"\t",!0):null:null),[le]),se=i((()=>(ae.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==ae?void 0:ae.secondaryText]),de=i((()=>{const e=$.artifact&&(null==H?void 0:H.id)===$.artifact.id&&(null==H?void 0:H.version)===$.artifact.version;return"inline"===$.type&&("inline-form"===R?!!H:e)}),[H,R,$.type,$.artifact]);a((()=>{e(void 0,void 0,void 0,(function*(){"inline"===$.type&&$.artifact&&(P.some((e=>$.artifact&&e.id===$.artifact.id&&e.version===$.artifact.version))||_({id:$.artifact.id,version:$.artifact.version}))}))}),[P,$.type,$.artifact]),a((()=>{if("application/vnd.pxe.code"===(null==le?void 0:le.type)&&J("code"),"finished"!==(null==le?void 0:le.status))return J("code"),te(),void ne();re(),"application/vnd.pxe.code"!==le.type&&J("render")}),[null==le?void 0:le.status,null==le?void 0:le.type]),a((()=>{var e;!Z.current||"text/html"!==(null==le?void 0:le.type)&&"application/vnd.pxe.react"!==(null==le?void 0:le.type)||null===(e=Z.current.contentWindow)||void 0===e||e.postMessage({type:"text/html"===le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}),[null==le?void 0:le.content,null==le?void 0:le.type]);const pe=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;if("text/html"===le.type){const e=le.content,o=window.open("","_blank");return void(o&&(o.document.open(),o.document.write(e),o.document.close(),o.focus(),o.print()))}const e=G;"code"===e&&(J("render"),yield new Promise((e=>setTimeout(e,50)))),ee(),"code"===e&&J(e)})),me=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;const e=yield y(le.content);x(e,`${le.title}.docx`)})),ue=o=>e(void 0,void 0,void 0,(function*(){var e;if(!le)return;let t={mimeType:"text/plain",extension:".txt"};switch(o){case"text/markdown":t={mimeType:"text/markdown",extension:".md"};break;case"text/html":t={mimeType:"text/html",extension:".html"};break;case"text/csv":t={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":t={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":t={mimeType:"image/svg+xml",extension:".svg"};break;case"application/vnd.pxe.code":t={mimeType:`application/${le.programmingLanguage||"text"};charset=utf-8`,extension:`.${le.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":t={mimeType:"text/typescript",extension:".tsx"};break;default:t={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===le.type){const o=G;"code"===o&&(J("render"),yield new Promise((e=>setTimeout(e,50))));const t=null===(e=Y.current)||void 0===e?void 0:e.querySelector("svg");t&&(n=(new XMLSerializer).serializeToString(t)),"code"===o&&J(o)}const r=new Blob([null!=n?n:le.content],{type:t.mimeType});f(r,`${le.title}${t.extension}`)}));return le?o("div",Object.assign({className:E("pxe-artifact-renderer flex flex-col","inline"===$.type&&!de&&"min-h-[320px] mb-6",$.className),style:Object.assign(Object.assign({backgroundColor:ae.secondary,color:ae.secondaryText},"auto"!==R&&{borderRadius:ie.cornerRadius}),$.style)},{children:[o("div",Object.assign({className:"flex items-center gap-6 justify-between p-4 shadow-sm"},{children:[o("div",Object.assign({className:"pxe-artifact-create-header flex items-center gap-4 truncate"},{children:[(de||!R.startsWith("inline"))&&t(S,{type:le.type,view:G,colors:ae,onChange:J}),t("p",Object.assign({className:"font-semilight truncate text-xl"},{children:le.title}))]})),o("div",Object.assign({className:"flex items-center gap-4"},{children:["code"===G&&(de||!R.startsWith("inline"))&&o("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:ae.secondaryText},disabled:K,onClick:()=>e(void 0,void 0,void 0,(function*(){try{N(le.content),Q(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{Q(!1)}}))},{children:[t(k,{className:"w-5 h-5 shrink-0"}),(null==q?void 0:q.copy)||"Copy"]})),(de||!R.startsWith("inline"))&&t(A,Object.assign({variant:"anchor",className:"px-3 py-1.5 shrink-0",data:le,colors:ae,onDownload:ue,onSaveAsPDF:pe,onSaveAsDOCX:me},{children:t("span",Object.assign({className:"shrink-0 font-semibold text-sm select-none"},{children:(null==q?void 0:q["save-as"])||"Save as"}))})),t("button",Object.assign({style:{color:ae.secondaryText},onClick:()=>{"inline"!==$.type||!$.artifact||de?I(null):I({id:$.artifact.id,version:$.artifact.version})}},{children:"inline"===$.type?t(de?w:C,{className:"w-6 h-6 shrink-0"}):t(h,{className:"w-6 h-6 shrink-0"})}))]}))]})),t("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:o(F,Object.assign({ref:oe,innerClassName:"flex-grow w-full"},{children:["render"===G&&"application/vnd.pxe.code"!==le.type?t("div",Object.assign({ref:U,className:E("p-4 pb-6 flex-grow flex flex-col","application/vnd.pxe.react"===le.type&&"p-0","text/html"===le.type&&"p-0","text/csv"===le.type&&"p-0")},{children:"text/markdown"===le.type||"text/csv"===le.type||"text/tab-separated-values"===le.type||"image/svg+xml"===le.type?t(m,Object.assign({theme:ie.theme,colors:ae},{children:t(u,{value:null!=ce?ce:le.content,className:E("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===le.type||"text/tab-separated-values"===le.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===le.type?t(O,{ref:Y,id:`mermaid-${le.id}-${le.version}`,data:le.content}):"text/html"===le.type||"application/vnd.pxe.react"===le.type?t("iframe",Object.assign({ref:Z,title:le.title,src:`${B}/${"text/html"===le.type?"html":"react"}?theme=${se?"dark":"light"}&bg=${ae.secondary}&accent=${ae.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==ae?void 0:ae.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 o=e.target;setTimeout((()=>{var e;try{null===(e=o.contentWindow)||void 0===e||e.postMessage({type:"text/html"===le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}catch(e){console.error("Error sending message to iframe:",e)}}),100),ne()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t(v,Object.assign({PreTag:"div",language:"text/markdown"===le.type?"markdown":"text/html"===le.type||"image/svg+xml"===le.type?"xml":"application/vnd.pxe.react"===le.type?"typescript":le.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==ae?void 0:ae.secondaryText},se&&{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==ae?void 0:ae.secondaryText},se&&{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==ae?void 0:ae.secondary}),':not(pre) > code[class*="language-"]':{background:null==ae?void 0:ae.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==ae?void 0:ae.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!se&&{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==ae?void 0:ae.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:le.content})),t(g,{})]}))})),"inline"===$.type&&!de&&o("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t(T,Object.assign({id:`artifact-copy-${le.id}-${le.version}`,tip:(null==q?void 0:q.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:ae.secondary,color:ae.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(j,{color:ae.secondaryText,text:le.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t(T,Object.assign({id:`artifact-save-${le.id}-${le.version}`,tip:(null==q?void 0:q.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:ae.secondary,color:ae.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(A,Object.assign({data:le,colors:ae,onDownload:ue,onSaveAsPDF:pe,onSaveAsDOCX:me},{children:t("button",Object.assign({style:{color:ae.secondaryText}},{children:t(b,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};export{$ as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Fragment as s}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as a}from"./hooks/useDocument.js";import{formatBytes as o}from"../../../../common/utils.js";import l from"../../../Icons/spinner-lines.svg.js";import c from"../../../Icons/file.svg.js";import n from"../../../Icons/x.svg.js";import d from"../../../Icons/circle-info.svg.js";import u from"../../../../common/cn.js";const m=({className:m,isDisabled:h})=>{const{styles:f,colors:b,translations:p,isRtl:g}=r(),{documents:x,isUploading:j,removeDocument:v}=a(),k=i();return e("div",Object.assign({className:u("flex flex-row gap-3 flex-wrap",m)},{children:x.map(((r,i)=>{var a,m,x,y,N,w;return e(s,{children:"document"===r.type?t("div",Object.assign({className:u("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",g&&"flex-row-reverse"),style:{borderRadius:f.cornerRadius,borderColor:b.secondaryText+"50"}},{children:[e("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:f.cornerRadius,backgroundColor:b.accent,color:b.accentText},"failed"===r.status&&{backgroundColor:b.error,color:"white"})},{children:"uploading"===r.status?e(l,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===r.status?e(d,{className:"w-5 h-5 shrink-0"}):e(c,{className:"w-5 h-5 shrink-0"})})),t("div",Object.assign({className:u("flex flex-col justify-center truncate",g?"text-right items-end":"text-left items-start")},{children:[e("p",Object.assign({className:u(k.b3,"font-medium truncate")},{children:r.name})),e("p",Object.assign({className:u(k.b4,"opacity-80 truncate")},{children:"failed"===r.status?(null===(a=r.error)||void 0===a?void 0:a.includes("You have reached the file limit"))?null!==(m=null==p?void 0:p["file-limit-reached"])&&void 0!==m?m:"You have reached the file limit.":r.error:o(r.size)}))]})),!j&&e("button",Object.assign({type:"button",className:u("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",g?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:b.accent,color:b.accentText},disabled:j||h,onClick:()=>v(r.id)},{children:e(n,{className:"w-4 h-4 shrink-0"})}))]})):"image"===r.type?t("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:f.cornerRadius,backgroundColor:b.accent,color:b.accentText},"failed"===r.status&&{backgroundColor:b.error,color:"white"})},{children:["finished"===r.status?e("img",{className:"object-cover w-full h-full",style:{borderRadius:f.cornerRadius},src:`https://cdn.mail.studio/documentinterrogation/${null!==(x=r.folder)&&void 0!==x?x:"jpg"}/${r.documentId}.${null!==(y=r.folder)&&void 0!==y?y:"jpg"}`,alt:""}):"failed"===r.status?e(d,{className:"w-5 h-5 shrink-0"}):e(l,{className:"w-5 h-5 animate-spin shrink-0"}),!j&&e("button",Object.assign({type:"button",className:u("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",g?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:b.accent,color:b.accentText},disabled:j||h,onClick:()=>v(r.id)},{children:e(n,{className:"w-4 h-4 shrink-0"})}))]})):"website"===r.type?t("div",Object.assign({className:u("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",g&&"flex-row-reverse"),style:{borderRadius:f.cornerRadius,borderColor:b.secondaryText+"50"}},{children:[e("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:f.cornerRadius,backgroundColor:b.accent,color:b.accentText},"failed"===r.status&&{backgroundColor:b.error,color:"white"})},{children:"uploading"===r.status?e(l,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===r.status?e(d,{className:"w-5 h-5 shrink-0"}):e(c,{className:"w-5 h-5 shrink-0"})})),t("div",Object.assign({className:u("flex flex-col justify-center truncate",g?"text-right items-end":"text-left items-start")},{children:[e("p",Object.assign({className:u(k.b3,"font-medium truncate")},{children:r.name})),e("p",Object.assign({className:u(k.b4,"opacity-80 truncate")},{children:"failed"===r.status?(null===(N=r.error)||void 0===N?void 0:N.includes("You have reached the file limit"))?null!==(w=null==p?void 0:p["file-limit-reached"])&&void 0!==w?w:"You have reached the file limit.":r.error:"Website "}))]})),!j&&e("button",Object.assign({type:"button",className:u("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",g?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:b.accent,color:b.accentText},disabled:j||h,onClick:()=>v(r.id)},{children:e(n,{className:"w-4 h-4 shrink-0"})}))]})):null},i)}))}))};export{m as default};
1
+ import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{Fragment as i}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as o}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as a}from"./hooks/useDocument.js";import{formatBytes as l}from"../../../../common/utils.js";import n from"../../../Icons/spinner-lines.svg.js";import c from"../../../Icons/file.svg.js";import d from"../../../Icons/x.svg.js";import u from"../../../Icons/circle-info.svg.js";import m from"../../../../common/cn.js";const f=({className:f,isDisabled:h})=>{const{styles:b,colors:p,translations:g,isRtl:v}=r(),{documents:x,isUploading:j,removeDocument:y}=a(),{sessionId:k,contextId:N}=r(),w=o();return t("div",Object.assign({className:m("flex flex-row gap-3 flex-wrap",f)},{children:x.map(((r,o)=>{var a,f,x,O,C,_;return t(i,{children:"document"===r.type?s("div",Object.assign({className:m("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",v&&"flex-row-reverse"),style:{borderRadius:b.cornerRadius,borderColor:p.secondaryText+"50"}},{children:[t("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:b.cornerRadius,backgroundColor:p.accent,color:p.accentText},"failed"===r.status&&{backgroundColor:p.error,color:"white"})},{children:"uploading"===r.status?t(n,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===r.status?t(u,{className:"w-5 h-5 shrink-0"}):t(c,{className:"w-5 h-5 shrink-0"})})),s("div",Object.assign({className:m("flex flex-col justify-center truncate",v?"text-right items-end":"text-left items-start")},{children:[t("p",Object.assign({className:m(w.b3,"font-medium truncate")},{children:r.name})),t("p",Object.assign({className:m(w.b4,"opacity-80 truncate")},{children:"failed"===r.status?(null===(a=r.error)||void 0===a?void 0:a.includes("You have reached the file limit"))?null!==(f=null==g?void 0:g["file-limit-reached"])&&void 0!==f?f:"You have reached the file limit.":r.error:l(r.size)}))]})),!j&&t("button",Object.assign({type:"button",className:m("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",v?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:p.accent,color:p.accentText},disabled:j||h,onClick:()=>e(void 0,void 0,void 0,(function*(){if(y(r.id),"failed"!==r.status){const e=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/decrement_document_count?sessionid=${N}&responseid=${k}&documentid=${r.documentId}`;yield fetch(e)}}))},{children:t(d,{className:"w-4 h-4 shrink-0"})}))]})):"image"===r.type?s("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:b.cornerRadius,backgroundColor:p.accent,color:p.accentText},"failed"===r.status&&{backgroundColor:p.error,color:"white"})},{children:["finished"===r.status?t("img",{className:"object-cover w-full h-full",style:{borderRadius:b.cornerRadius},src:`https://cdn.mail.studio/documentinterrogation/${null!==(x=r.folder)&&void 0!==x?x:"jpg"}/${r.documentId}.${null!==(O=r.folder)&&void 0!==O?O:"jpg"}`,alt:""}):"failed"===r.status?t(u,{className:"w-5 h-5 shrink-0"}):t(n,{className:"w-5 h-5 animate-spin shrink-0"}),!j&&t("button",Object.assign({type:"button",className:m("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",v?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:p.accent,color:p.accentText},disabled:j||h,onClick:()=>e(void 0,void 0,void 0,(function*(){if(y(r.id),"failed"!==r.status){const e=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/decrement_document_count?sessionid=${N}&responseid=${k}&documentid=${r.documentId}`;yield fetch(e)}}))},{children:t(d,{className:"w-4 h-4 shrink-0"})}))]})):"website"===r.type?s("div",Object.assign({className:m("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",v&&"flex-row-reverse"),style:{borderRadius:b.cornerRadius,borderColor:p.secondaryText+"50"}},{children:[t("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:b.cornerRadius,backgroundColor:p.accent,color:p.accentText},"failed"===r.status&&{backgroundColor:p.error,color:"white"})},{children:"uploading"===r.status?t(n,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===r.status?t(u,{className:"w-5 h-5 shrink-0"}):t(c,{className:"w-5 h-5 shrink-0"})})),s("div",Object.assign({className:m("flex flex-col justify-center truncate",v?"text-right items-end":"text-left items-start")},{children:[t("p",Object.assign({className:m(w.b3,"font-medium truncate")},{children:r.name})),t("p",Object.assign({className:m(w.b4,"opacity-80 truncate")},{children:"failed"===r.status?(null===(C=r.error)||void 0===C?void 0:C.includes("You have reached the file limit"))?null!==(_=null==g?void 0:g["file-limit-reached"])&&void 0!==_?_:"You have reached the file limit.":r.error:"Website "}))]})),!j&&t("button",Object.assign({type:"button",className:m("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",v?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:p.accent,color:p.accentText},disabled:j||h,onClick:()=>y(r.id)},{children:t(d,{className:"w-4 h-4 shrink-0"})}))]})):null},o)}))}))};export{f as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as s,useRef as n,useEffect as r}from"react";import"../../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import i,{useSpeechRecognition as a}from"react-speech-recognition";import{usePickaxeContext as c}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as p}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as u}from"../../../../hooks/core/useHover.js";import d from"../../../Core/Textarea.js";import g from"../../../Icons/microphone.svg.js";import h from"../../../Icons/stop.svg.js";import b from"../../../../common/cn.js";const f=({field:f,update:x})=>{var j;const{styles:v,colors:y,isRtl:N,pickaxe:O,locale:k}=c(),{setError:w}=l(),[C,S]=s(!1),L=m(),R=p(),{transcript:T,listening:I,resetTranscript:_,browserSupportsSpeechRecognition:z}=a(),F=n(""),H=u(),{isHover:$}=H,B=e(H,["isHover"]),D=z&&(null==O?void 0:O.enablevoicetotext),P=e=>{w("");const t=e.length;x(Object.assign(Object.assign({},f),{input:e,length:t}))};r((()=>{if(!I)return;const e=F.current?`${F.current} `:"";P(`${e}${T}`)}),[T,I]);return t("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:N?"rtl":"ltr"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:b(L.b3,"font-semibold opacity-70")},{children:f.main})),f.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:y.accent}},{children:"*"}))]})),t("div",Object.assign({className:"relative w-full"},{children:[I&&t("div",Object.assign({className:b("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",N?"right-4":"left-4")},{children:[o("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(j=y.accent)&&void 0!==j?j:"#ff0000"}}),o("span",Object.assign({className:"text-sm font-semilight",style:{color:y.text+"90"}},{children:"Listening..."}))]})),o(d,{className:b(L.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",N?D?"pl-10 pr-4":"px-4":D?"pl-4 pr-10":"px-4",f.maxLength<10&&"max-w-[400px]","block"===v.formFieldStyle&&"shadow hover:shadow-none",I&&"caret-transparent"),style:Object.assign(Object.assign({},R),I&&{color:"transparent"}),placeholder:I?"":f.placeholder,rows:1,value:f.input,tabIndex:f.order,onChange:P,onFocus:()=>S(!0),onBlur:()=>S(!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)}}),D&&o("div",Object.assign({className:b("absolute top-2 z-20",N?"left-2":"right-2")},{children:o("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:I?y.accent:$?y.accent+"10":void 0,color:I?y.accentText:$?y.accent:y.accent+"80"},onClick:()=>{I?i.stopListening():(F.current=f.input||"",_(),i.startListening({continuous:!0,interimResults:!0,language:k||"en-US"}),S(!0))}},B,{type:"button"},{children:I?o(h,{className:"h-4 w-4 shrink-0"}):o(g,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),o("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:t("p",Object.assign({className:b(L.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",f.length>f.maxLength&&"text-c-red opacity-100",C&&"opacity-100")},{children:[f.length,"/",f.maxLength]}))}))]}))};export{f as default};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as s,useRef as n,useEffect as r}from"react";import"../../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import i,{useSpeechRecognition as a}from"react-speech-recognition";import{usePickaxeContext as c}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as p}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import u from"../../../Core/Textarea.js";import g from"../../../Icons/microphone.svg.js";import h from"../../../Icons/stop.svg.js";import b from"../../../../common/cn.js";const f=({field:f,update:x,activeVoiceId:j,setActiveVoiceId:v})=>{var y;const{styles:N,colors:O,isRtl:k,pickaxe:w,locale:C}=c(),{setError:S}=l(),[I,L]=s(!1),R=m(),T=p(),{transcript:_,listening:z,resetTranscript:F,browserSupportsSpeechRecognition:H}=a(),$=n(""),B=d(),{isHover:D}=B,P=e(B,["isHover"]),V=H&&(null==w?void 0:w.enablevoicetotext),q=z&&j===f.id,A=e=>{S("");const t=e.length;x(Object.assign(Object.assign({},f),{input:e,length:t}))};r((()=>{if(!z||j!==f.id)return;const e=$.current?`${$.current} `:"";A(`${e}${_}`)}),[_,z,j,f.id]);return t("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:k?"rtl":"ltr"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:b(R.b3,"font-semibold opacity-70")},{children:f.main})),f.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:O.accent}},{children:"*"}))]})),t("div",Object.assign({className:"relative w-full"},{children:[q&&t("div",Object.assign({className:b("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",k?"right-4":"left-4")},{children:[o("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(y=O.accent)&&void 0!==y?y:"#ff0000"}}),o("span",Object.assign({className:"text-sm font-semilight",style:{color:O.text+"90"}},{children:"Listening..."}))]})),o(u,{className:b(R.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",k?V?"pl-10 pr-4":"px-4":V?"pl-4 pr-10":"px-4",f.maxLength<10&&"max-w-[400px]","block"===N.formFieldStyle&&"shadow hover:shadow-none",q&&"caret-transparent"),style:Object.assign(Object.assign({},T),q&&{color:"transparent"}),placeholder:q?"":f.placeholder,rows:1,value:f.input,tabIndex:f.order,onChange:A,onFocus:()=>L(!0),onBlur:()=>L(!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)}}),V&&o("div",Object.assign({className:b("absolute top-2 z-20",k?"left-2":"right-2")},{children:o("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:q?O.accent:D?O.accent+"10":void 0,color:q?O.accentText:D?O.accent:O.accent+"80"},onClick:()=>{z?(i.stopListening(),v(null)):(v(f.id),$.current=f.input||"",F(),i.startListening({continuous:!0,interimResults:!0,language:C||"en-US"}),L(!0))}},P,{type:"button"},{children:q?o(h,{className:"h-4 w-4 shrink-0"}):o(g,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),o("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:t("p",Object.assign({className:b(R.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",f.length>f.maxLength&&"text-c-red opacity-100",I&&"opacity-100")},{children:[f.length,"/",f.maxLength]}))}))]}))};export{f as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as r,useEffect as i,Fragment as p}from"react";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import a from"../../../Core/ErrorAlert.js";import l from"../../common/PickaxeUpgradeCard.js";import d from"./Input.js";import u from"./Option.js";import m from"./Document.js";import c from"./Checkbox.js";import f from"./Submit.js";const h=()=>{const{pickaxe:h,translations:x}=s(),{error:g}=n(),[w,y]=o([]),[j,k]=o([]),q=e=>{y((t=>t.map((t=>t.id===e.id?e:t))))},C=r((()=>j),[j]);return i((()=>{if(!h)return;if(!h._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!h.updatedAt||new Date(h.updatedAt)<e,o=h._questions.map(((e,o)=>{var r;let i="";const p="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||p||(i=t[0])}let s=e.secondary||"";return t&&(s=e.secondary||("Knowledge Upload"===e.type?null!==(r=null==x?void 0:x["form-doc-placeholder"])&&void 0!==r?r:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:o+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:s,allowOther:p},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));y(o),k(o)}),[h]),e("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[w.map(((e,o)=>"Multiple Choice"===e.type?t(p,{children:t(u,{field:e,update:q})},o):"Checkbox"===e.type?t(p,{children:t(c,{field:e,update:q})},o):"userinput:documentupload"===e.id?t(p,{children:t(m,{field:e,update:q})},o):t(p,{children:t(d,{field:e,update:q})},o))),t(a,{error:g}),t(l,{}),t(f,{questions:w,update:q,resetQuestions:()=>y(C)})]}))};export{h as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as r,useEffect as i,Fragment as s}from"react";import{usePickaxeContext as p}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import l from"../../../Core/ErrorAlert.js";import a from"../../common/PickaxeUpgradeCard.js";import d from"./Input.js";import u from"./Option.js";import m from"./Document.js";import c from"./Checkbox.js";import f from"./Submit.js";const h=()=>{const{pickaxe:h,translations:x}=p(),{error:g}=n(),[w,y]=o([]),[j,k]=o([]),[q,C]=o(null),D=e=>{y((t=>t.map((t=>t.id===e.id?e:t))))},O=r((()=>j),[j]);return i((()=>{if(!h)return;if(!h._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!h.updatedAt||new Date(h.updatedAt)<e,o=h._questions.map(((e,o)=>{var r;let i="";const s="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||s||(i=t[0])}let p=e.secondary||"";return t&&(p=e.secondary||("Knowledge Upload"===e.type?null!==(r=null==x?void 0:x["form-doc-placeholder"])&&void 0!==r?r:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:o+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:p,allowOther:s},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));y(o),k(o)}),[h]),e("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[w.map(((e,o)=>"Multiple Choice"===e.type?t(s,{children:t(u,{field:e,update:D})},o):"Checkbox"===e.type?t(s,{children:t(c,{field:e,update:D})},o):"userinput:documentupload"===e.id?t(s,{children:t(m,{field:e,update:D})},o):t(s,{children:t(d,{field:e,update:D,activeVoiceId:q,setActiveVoiceId:C})},o))),t(l,{error:g}),t(a,{}),t(f,{questions:w,update:D,resetQuestions:()=>y(O)})]}))};export{h as default};
@@ -3,6 +3,8 @@ import "regenerator-runtime/runtime";
3
3
  interface InputProps {
4
4
  field: MemoryStoredQuestionField;
5
5
  update: (questions: MemoryStoredQuestionField) => void;
6
+ activeVoiceId: string | null;
7
+ setActiveVoiceId: (id: string | null) => void;
6
8
  }
7
- declare const Input: ({ field, update }: InputProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const Input: ({ field, update, activeVoiceId, setActiveVoiceId, }: InputProps) => import("react/jsx-runtime").JSX.Element;
8
10
  export default Input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "5.5.0",
3
+ "version": "5.5.2",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",