@pickaxeproject/react 6.12.0 → 6.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../Addons/Auth/hooks/useAuthContext.js"),i=require("../../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("../../hooks/usePickaxeMarkdownContext.js"),l=require("../../../../../Icons/download.svg.js"),a=require("../../../../../Icons/copy.svg.js"),c=require("../../../../../Icons/copied.svg.js"),d=require("../../../../../Icons/file.svg.js"),u=require("../../../../../Icons/upload-cloud.svg.js"),p=require("copy-to-clipboard"),m=require("../../../../../../common/error.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=f(p);const h=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,v=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),w=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),b=new Set(["mp4","webm","mov","avi","mkv","m4v"]),g=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),j=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),k=new Set(["pdf","html","htm",...g,...j]),y=new Set([...v,...w,...b,...k]),N=e=>v.has(e)?"image":w.has(e)?"audio":b.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":g.has(e)?"text":j.has(e)?"office":"file",S=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},C=e=>{try{return new URL(S(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},O=e=>{try{return new URL(S(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},I=e=>{const t=S(e);return/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i.test(t)},F=e=>{const t=S(e);if(C(t))return!1;if(O(t))return!0;if(I(t))return!1;if((e=>{const t=S(e);return/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,s,r;try{const i=new URL(S(e));return"https:"!==i.protocol&&"http:"!==i.protocol?null:null!==(r=null===(s=null===(o=null===(t=i.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===s?void 0:s.toLowerCase())&&void 0!==r?r:null}catch(e){return null}})(t);return!!o&&k.has(o)},q=(e,t)=>{const o=S(e);return!I(o)&&(F(o)||(null==t?void 0:t.has(o)))};exports.default=({fileInfo:p,displayName:f})=>{const{theme:h,colors:v,disableHtml:w,disableJs:b}=n.usePickaxeMarkdownContext(),{contextId:g,pickaxeId:j,pickaxe:k,translations:y}=s.usePickaxeContext(),{isLoggedIn:N,token:S}=r.useAuthContext(),C=i.useSubmitDocument(),[O,I]=o.useState(!1),[F,q]=o.useState(!1),[U,P]=o.useState(!1),R=(e,t)=>{var o;return null!==(o=null==y?void 0:y[e])&&void 0!==o?o:t},_="dark"===h?"#30363D":"#D0D7DE",D="dark"===h?"#0D1117":"#F6F8FA",$="dark"===h?"#161B22":"#FFFFFF",L=(null==f?void 0:f.trim())||p.fileName,T=L!==p.fileName,A={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:v.accentText,backgroundColor:v.accent,opacity:.88,flexShrink:0},B=(e,o,s)=>t.jsx("div",Object.assign({className:"flex w-full p-4"},{children:t.jsxs("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:$,border:`1px solid ${_}`}},{children:[t.jsx("iframe",Object.assign({src:e,title:o},s,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===h?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t.jsxs("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${_}`,backgroundColor:D,color:v.secondaryText}},{children:[t.jsxs("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:_}},{children:[t.jsx("a",Object.assign({href:p.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:v.secondaryText},title:T?`${L} (${p.fileName})`:L},{children:L})),t.jsxs("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[t.jsx("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=p.url,e.download=p.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:R("download","Download"),"aria-label":R("download","Download"),style:A},{children:t.jsx(l.default,{className:"h-[18px] w-[18px]"})})),t.jsx("button",Object.assign({type:"button",onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{I(!0),x.default(p.url),yield new Promise((e=>setTimeout(e,1500)))}finally{I(!1)}}))},title:O?R("copied","Copied"):R("copy-link","Copy link"),"aria-label":O?R("copied","Copied"):R("copy-link","Copy link"),style:Object.assign(Object.assign({},A),{opacity:O?1:A.opacity})},{children:O?t.jsx(c.default,{className:"h-[18px] w-[18px]"}):t.jsx(a.default,{className:"h-[18px] w-[18px]"})})),N&&S&&t.jsx("button",Object.assign({type:"button",disabled:F||U,onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(S&&!F){q(!0),P(!1);try{const e=yield fetch(p.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],p.fileName,{type:t.type||"application/octet-stream"});yield C.document(Object.assign(Object.assign({contextId:g,pickaxeId:j,file:o},(null==k?void 0:k.workspaceid)&&{workspaceId:k.workspaceid}),{studioSessionToken:S,isUserDocument:!0})),P(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(m.default(e))}finally{q(!1),P(!1)}}}))},title:F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},A),{opacity:F||U?.55:A.opacity,cursor:F||U?"not-allowed":"pointer"})},{children:t.jsx(u.default,{className:"h-[18px] w-[18px]"})}))]}))]})),t.jsx("div",{children:(()=>{if("image"===p.kind)return t.jsx("img",{src:p.url,alt:p.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===p.kind)return t.jsx("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:t.jsx("audio",{className:"w-full",controls:!0,src:p.url})}));if("video"===p.kind)return t.jsx("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:p.url});if("pdf"===p.kind||"text"===p.kind){const e="pdf"===p.kind?`${p.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:p.url;return B(e,p.fileName)}if("html"===p.kind&&!w){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",b?"":"allow-scripts"].filter(Boolean).join(" ");return B(p.url,p.fileName,{sandbox:e})}return"office"===p.kind?B(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(p.url)}`,p.fileName):t.jsxs("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[t.jsx(d.default,{className:"h-8 w-8 shrink-0"}),t.jsx("span",Object.assign({className:"break-all"},{children:p.extension.toUpperCase()}))]}))})()})]}))},exports.getFilePreviewInfo=e=>{var t,o;try{const s=S(e),r=new URL(s);if("https:"!==r.protocol&&"http:"!==r.protocol)return null;const i=r.pathname.split("/").filter(Boolean).pop();if(!i)return null;const n=decodeURIComponent(i),l=null===(o=null===(t=n.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return l&&(C(s)||y.has(l))?{url:s,fileName:n,extension:l,kind:N(l)}:null}catch(e){return null}},exports.isDocumentSourceUrl=O,exports.isGeneratedFileUrl=C,exports.isSourceLikeRichPreviewUrl=F,exports.normalizeMarkdownUrl=S,exports.shouldRenderFilePreview=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),exports.shouldSuppressRichPreviewForUrl=q,exports.shouldSuppressRichPreviewInText=(e,t)=>{for(const o of e.matchAll(h))if(q(o[0],t))return!0;return!1};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../Addons/Auth/hooks/useAuthContext.js"),i=require("../../../../../../hooks/pickaxe/useSubmitDocument.js"),l=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../../../Icons/download.svg.js"),a=require("../../../../../Icons/copy.svg.js"),c=require("../../../../../Icons/copied.svg.js"),d=require("../../../../../Icons/file.svg.js"),u=require("../../../../../Icons/upload-cloud.svg.js"),p=require("copy-to-clipboard"),m=require("../../../../../../common/error.js"),f=require("../common/youtube.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=x(p);const v=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,w=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),b=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),g=new Set(["mp4","webm","mov","avi","mkv","m4v"]),j=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),k=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),y=new Set(["pdf","html","htm",...j,...k]),N=new Set([...w,...b,...g,...y]),S=e=>w.has(e)?"image":b.has(e)?"audio":g.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":j.has(e)?"text":k.has(e)?"office":"file",C=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},O=e=>{try{return new URL(C(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},I=e=>{try{return new URL(C(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},F=e=>{const t=C(e);return null!==f.getYouTubeEmbedUrl(t)},q=e=>{const t=C(e);if(O(t))return!1;if(I(t))return!0;if(F(t))return!1;if((e=>{const t=C(e);return/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,s,r;try{const i=new URL(C(e));return"https:"!==i.protocol&&"http:"!==i.protocol?null:null!==(r=null===(s=null===(o=null===(t=i.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===s?void 0:s.toLowerCase())&&void 0!==r?r:null}catch(e){return null}})(t);return!!o&&y.has(o)},U=(e,t)=>{const o=C(e);return!F(o)&&(q(o)||(null==t?void 0:t.has(o)))};exports.default=({fileInfo:p,displayName:f})=>{const{theme:x,colors:v,disableHtml:w,disableJs:b}=l.usePickaxeMarkdownContext(),{contextId:g,pickaxeId:j,pickaxe:k,translations:y}=s.usePickaxeContext(),{isLoggedIn:N,token:S}=r.useAuthContext(),C=i.useSubmitDocument(),[O,I]=o.useState(!1),[F,q]=o.useState(!1),[U,P]=o.useState(!1),R=(e,t)=>{var o;return null!==(o=null==y?void 0:y[e])&&void 0!==o?o:t},_="dark"===x?"#30363D":"#D0D7DE",D="dark"===x?"#0D1117":"#F6F8FA",$="dark"===x?"#161B22":"#FFFFFF",L=(null==f?void 0:f.trim())||p.fileName,T=L!==p.fileName,A={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:v.accentText,backgroundColor:v.accent,opacity:.88,flexShrink:0},B=(e,o,s)=>t.jsx("div",Object.assign({className:"flex w-full p-4"},{children:t.jsxs("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:$,border:`1px solid ${_}`}},{children:[t.jsx("iframe",Object.assign({src:e,title:o},s,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===x?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t.jsxs("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${_}`,backgroundColor:D,color:v.secondaryText}},{children:[t.jsxs("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:_}},{children:[t.jsx("a",Object.assign({href:p.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:v.secondaryText},title:T?`${L} (${p.fileName})`:L},{children:L})),t.jsxs("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[t.jsx("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=p.url,e.download=p.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:R("download","Download"),"aria-label":R("download","Download"),style:A},{children:t.jsx(n.default,{className:"h-[18px] w-[18px]"})})),t.jsx("button",Object.assign({type:"button",onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{I(!0),h.default(p.url),yield new Promise((e=>setTimeout(e,1500)))}finally{I(!1)}}))},title:O?R("copied","Copied"):R("copy-link","Copy link"),"aria-label":O?R("copied","Copied"):R("copy-link","Copy link"),style:Object.assign(Object.assign({},A),{opacity:O?1:A.opacity})},{children:O?t.jsx(c.default,{className:"h-[18px] w-[18px]"}):t.jsx(a.default,{className:"h-[18px] w-[18px]"})})),N&&S&&t.jsx("button",Object.assign({type:"button",disabled:F||U,onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(S&&!F){q(!0),P(!1);try{const e=yield fetch(p.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],p.fileName,{type:t.type||"application/octet-stream"});yield C.document(Object.assign(Object.assign({contextId:g,pickaxeId:j,file:o},(null==k?void 0:k.workspaceid)&&{workspaceId:k.workspaceid}),{studioSessionToken:S,isUserDocument:!0})),P(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(m.default(e))}finally{q(!1),P(!1)}}}))},title:F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},A),{opacity:F||U?.55:A.opacity,cursor:F||U?"not-allowed":"pointer"})},{children:t.jsx(u.default,{className:"h-[18px] w-[18px]"})}))]}))]})),t.jsx("div",{children:(()=>{if("image"===p.kind)return t.jsx("img",{src:p.url,alt:p.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===p.kind)return t.jsx("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:t.jsx("audio",{className:"w-full",controls:!0,src:p.url})}));if("video"===p.kind)return t.jsx("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:p.url});if("pdf"===p.kind||"text"===p.kind){const e="pdf"===p.kind?`${p.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:p.url;return B(e,p.fileName)}if("html"===p.kind&&!w){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",b?"":"allow-scripts"].filter(Boolean).join(" ");return B(p.url,p.fileName,{sandbox:e})}return"office"===p.kind?B(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(p.url)}`,p.fileName):t.jsxs("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[t.jsx(d.default,{className:"h-8 w-8 shrink-0"}),t.jsx("span",Object.assign({className:"break-all"},{children:p.extension.toUpperCase()}))]}))})()})]}))},exports.getFilePreviewInfo=e=>{var t,o;try{const s=C(e),r=new URL(s);if("https:"!==r.protocol&&"http:"!==r.protocol)return null;const i=r.pathname.split("/").filter(Boolean).pop();if(!i)return null;const l=decodeURIComponent(i),n=null===(o=null===(t=l.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return n&&(O(s)||N.has(n))?{url:s,fileName:l,extension:n,kind:S(n)}:null}catch(e){return null}},exports.isDocumentSourceUrl=I,exports.isGeneratedFileUrl=O,exports.isSourceLikeRichPreviewUrl=q,exports.normalizeMarkdownUrl=C,exports.shouldRenderFilePreview=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),exports.shouldSuppressRichPreviewForUrl=U,exports.shouldSuppressRichPreviewInText=(e,t)=>{for(const o of e.matchAll(v))if(U(o[0],t))return!0;return!1};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../hooks/usePickaxeMarkdownContext.js"),o=require("../common/IframeVideo.js"),s=require("./FilePreview.js");const i=e=>{let t="";return r.Children.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?r.isValidElement(e)&&(t+=i(e.props.children)):t+=e})),t.trim().replace(/\s+/g," ")};exports.A=({href:l="",children:n,filePreviewSeenRef:c,suppressedRichPreviewUrls:m})=>{const{colors:u}=t.usePickaxeMarkdownContext(),a=r.useMemo((()=>l?s.normalizeMarkdownUrl(l):""),[l]),d=r.useMemo((()=>s.shouldSuppressRichPreviewForUrl(a,m)),[a,m]),h=r.useMemo((()=>s.getFilePreviewInfo(a)),[a]),f=r.useMemo((()=>((e,r)=>{const t=i(e);if(t&&t!==r&&s.normalizeMarkdownUrl(t)!==r)return t})(n,a)),[n,a]),w=r.useMemo((()=>{if(d)return null;if(h)return null;const e=a.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const r=a.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=a.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=a.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[h,a,d]);return w?e.jsx(o.default,{title:w.title,src:w.src}):h&&!d&&s.shouldRenderFilePreview(h,c)?e.jsx(s.default,{fileInfo:h,displayName:f}):e.jsx("a",Object.assign({href:a,target:"_blank",rel:"noopener noreferrer",style:{color:u.accent}},{children:n}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../hooks/usePickaxeMarkdownContext.js"),o=require("../common/IframeVideo.js"),s=require("../common/youtube.js"),i=require("./FilePreview.js");const l=e=>{let t="";return r.Children.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?r.isValidElement(e)&&(t+=l(e.props.children)):t+=e})),t.trim().replace(/\s+/g," ")};exports.A=({href:n="",children:c,filePreviewSeenRef:m,suppressedRichPreviewUrls:u})=>{const{colors:a}=t.usePickaxeMarkdownContext(),d=r.useMemo((()=>n?i.normalizeMarkdownUrl(n):""),[n]),f=r.useMemo((()=>i.shouldSuppressRichPreviewForUrl(d,u)),[d,u]),h=r.useMemo((()=>i.getFilePreviewInfo(d)),[d]),p=r.useMemo((()=>((e,r)=>{const t=l(e);if(t&&t!==r&&i.normalizeMarkdownUrl(t)!==r)return t})(c,d)),[c,d]),b=r.useMemo((()=>{if(f)return null;if(h)return null;const e=s.getYouTubeEmbedUrl(d);if(e)return{title:"youtube-embed",src:e};const r=d.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=d.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=d.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[h,d,f]);return b?e.jsx(o.default,{title:b.title,src:b.src}):h&&!f&&i.shouldRenderFilePreview(h,m)?e.jsx(i.default,{fileInfo:h,displayName:p}):e.jsx("a",Object.assign({href:d,target:"_blank",rel:"noopener noreferrer",style:{color:a.accent}},{children:c}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../common/IframeVideo.js"),o=require("../A/FilePreview.js");exports.P=({children:s,suppressedRichPreviewUrls:i})=>{const c=t.useMemo((()=>{if("string"!=typeof s)return null;if(o.shouldSuppressRichPreviewInText(s,i))return null;const e=s.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=s.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=s.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const c=s.match(/streamable\.com\/([\w-]+)/i);return c?{title:"streamable-embed",src:`https://streamable.com/e/${c[1]}`}:null}),[s,i]);return c?e.jsx(r.default,{title:c.title,src:c.src}):e.jsx("p",{children:s})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../common/IframeVideo.js"),s=require("../common/youtube.js"),i=require("../A/FilePreview.js");exports.P=({children:o,suppressedRichPreviewUrls:m})=>{const c=r.useMemo((()=>{if("string"!=typeof o)return null;if(i.shouldSuppressRichPreviewInText(o,m))return null;const e=s.getYouTubeEmbedUrl(o);if(e)return{title:"youtube-embed",src:e};const r=o.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=o.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const c=o.match(/streamable\.com\/([\w-]+)/i);return c?{title:"streamable-embed",src:`https://streamable.com/e/${c[1]}`}:null}),[o,m]);return c?e.jsx(t.default,{title:c.title,src:c.src}):e.jsx("p",{children:o})};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=/(?:https?:\/\/)?(?:(?:www|m)\.)?(?:youtube\.com\/watch\?[^\s<>"']+|youtu\.be\/[\w-]+(?:[?#][^\s<>"']*)?)/i;exports.getYouTubeEmbedUrl=e=>{var r,s;const n=e.match(t);if(!n)return null;const u=n[0].replace(/[),.!;:]+$/,"");try{const t=new URL(/^https?:\/\//i.test(u)?u:`https://${u}`),e=t.hostname.toLowerCase(),n="youtu.be"===e,a=("youtube.com"===e||e.endsWith(".youtube.com"))&&"/watch"===t.pathname;if(!n&&!a)return null;const o=n?t.pathname.split("/").filter(Boolean)[0]:t.searchParams.get("v");if(!o||!/^[\w-]+$/.test(o))return null;const c=(t=>{if(!t)return null;const e=t.trim().toLowerCase();if(/^\d+$/.test(e))return Number.parseInt(e,10);const r=e.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);if(!r||!r.slice(1).some(Boolean))return null;const[,s="0",n="0",u="0"]=r;return 3600*Number.parseInt(s,10)+60*Number.parseInt(n,10)+Number.parseInt(u,10)})(null!==(s=null!==(r=t.searchParams.get("start"))&&void 0!==r?r:t.searchParams.get("t"))&&void 0!==s?s:(t=>{const e=t.hash.replace(/^#/,"");return e?new URLSearchParams(e).get("t"):null})(t)),l=new URL(`https://www.youtube.com/embed/${o}`);return null!==c&&c>0&&l.searchParams.set("start",String(c)),l.toString()}catch(t){return null}};
@@ -0,0 +1 @@
1
+ export declare const getYouTubeEmbedUrl: (value: string) => string | null;
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as n}from"react";import{usePickaxeContext as i}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../../../../Addons/Auth/hooks/useAuthContext.js";import{useSubmitDocument as a}from"../../../../../../hooks/pickaxe/useSubmitDocument.js";import{usePickaxeMarkdownContext as r}from"../../hooks/usePickaxeMarkdownContext.js";import s from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copy.svg.js";import d from"../../../../../Icons/copied.svg.js";import m from"../../../../../Icons/file.svg.js";import p from"../../../../../Icons/upload-cloud.svg.js";import u from"copy-to-clipboard";import f from"../../../../../../common/error.js";const h=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,b=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),v=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),w=new Set(["mp4","webm","mov","avi","mkv","m4v"]),g=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),x=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),k=new Set(["pdf","html","htm",...g,...x]),y=new Set([...b,...v,...w,...k]),j=e=>b.has(e)?"image":v.has(e)?"audio":w.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":g.has(e)?"text":x.has(e)?"office":"file",N=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},C=e=>{try{return new URL(N(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},O=e=>{try{return new URL(N(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},I=e=>{const t=N(e);return/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i.test(t)},S=e=>{const t=N(e);if(C(t))return!1;if(O(t))return!0;if(I(t))return!1;if((e=>{const t=N(e);return/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,n,i;try{const l=new URL(N(e));return"https:"!==l.protocol&&"http:"!==l.protocol?null:null!==(i=null===(n=null===(o=null===(t=l.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===n?void 0:n.toLowerCase())&&void 0!==i?i:null}catch(e){return null}})(t);return!!o&&k.has(o)},F=(e,t)=>{const o=N(e);return!I(o)&&(S(o)||(null==t?void 0:t.has(o)))},$=(e,t)=>{for(const o of e.matchAll(h))if(F(o[0],t))return!0;return!1},D=e=>{var t,o;try{const n=N(e),i=new URL(n);if("https:"!==i.protocol&&"http:"!==i.protocol)return null;const l=i.pathname.split("/").filter(Boolean).pop();if(!l)return null;const a=decodeURIComponent(l),r=null===(o=null===(t=a.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return r&&(C(n)||y.has(r))?{url:n,fileName:a,extension:r,kind:j(r)}:null}catch(e){return null}},R=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),U=({fileInfo:h,displayName:b})=>{const{theme:v,colors:w,disableHtml:g,disableJs:x}=r(),{contextId:k,pickaxeId:y,pickaxe:j,translations:N}=i(),{isLoggedIn:C,token:O}=l(),I=a(),[S,F]=n(!1),[$,D]=n(!1),[R,U]=n(!1),L=(e,t)=>{var o;return null!==(o=null==N?void 0:N[e])&&void 0!==o?o:t},B="dark"===v?"#30363D":"#D0D7DE",T="dark"===v?"#0D1117":"#F6F8FA",_="dark"===v?"#161B22":"#FFFFFF",A=(null==b?void 0:b.trim())||h.fileName,E=A!==h.fileName,P={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:w.accentText,backgroundColor:w.accent,opacity:.88,flexShrink:0},z=(e,n,i)=>o("div",Object.assign({className:"flex w-full p-4"},{children:t("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:_,border:`1px solid ${B}`}},{children:[o("iframe",Object.assign({src:e,title:n},i,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),o("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===v?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${B}`,backgroundColor:T,color:w.secondaryText}},{children:[t("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:B}},{children:[o("a",Object.assign({href:h.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:w.secondaryText},title:E?`${A} (${h.fileName})`:A},{children:A})),t("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[o("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=h.url,e.download=h.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:L("download","Download"),"aria-label":L("download","Download"),style:P},{children:o(s,{className:"h-[18px] w-[18px]"})})),o("button",Object.assign({type:"button",onClick:()=>{e(void 0,void 0,void 0,(function*(){try{F(!0),u(h.url),yield new Promise((e=>setTimeout(e,1500)))}finally{F(!1)}}))},title:S?L("copied","Copied"):L("copy-link","Copy link"),"aria-label":S?L("copied","Copied"):L("copy-link","Copy link"),style:Object.assign(Object.assign({},P),{opacity:S?1:P.opacity})},{children:o(S?d:c,{className:"h-[18px] w-[18px]"})})),C&&O&&o("button",Object.assign({type:"button",disabled:$||R,onClick:()=>{e(void 0,void 0,void 0,(function*(){if(O&&!$){D(!0),U(!1);try{const e=yield fetch(h.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],h.fileName,{type:t.type||"application/octet-stream"});yield I.document(Object.assign(Object.assign({contextId:k,pickaxeId:y,file:o},(null==j?void 0:j.workspaceid)&&{workspaceId:j.workspaceid}),{studioSessionToken:O,isUserDocument:!0})),U(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(f(e))}finally{D(!1),U(!1)}}}))},title:$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},P),{opacity:$||R?.55:P.opacity,cursor:$||R?"not-allowed":"pointer"})},{children:o(p,{className:"h-[18px] w-[18px]"})}))]}))]})),o("div",{children:(()=>{if("image"===h.kind)return o("img",{src:h.url,alt:h.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===h.kind)return o("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:o("audio",{className:"w-full",controls:!0,src:h.url})}));if("video"===h.kind)return o("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:h.url});if("pdf"===h.kind||"text"===h.kind){const e="pdf"===h.kind?`${h.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:h.url;return z(e,h.fileName)}if("html"===h.kind&&!g){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",x?"":"allow-scripts"].filter(Boolean).join(" ");return z(h.url,h.fileName,{sandbox:e})}return"office"===h.kind?z(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(h.url)}`,h.fileName):t("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[o(m,{className:"h-8 w-8 shrink-0"}),o("span",Object.assign({className:"break-all"},{children:h.extension.toUpperCase()}))]}))})()})]}))};export{U as default,D as getFilePreviewInfo,O as isDocumentSourceUrl,C as isGeneratedFileUrl,S as isSourceLikeRichPreviewUrl,N as normalizeMarkdownUrl,R as shouldRenderFilePreview,F as shouldSuppressRichPreviewForUrl,$ as shouldSuppressRichPreviewInText};
1
+ import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as n}from"react";import{usePickaxeContext as i}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../../../../Addons/Auth/hooks/useAuthContext.js";import{useSubmitDocument as r}from"../../../../../../hooks/pickaxe/useSubmitDocument.js";import{usePickaxeMarkdownContext as a}from"../../hooks/usePickaxeMarkdownContext.js";import s from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copy.svg.js";import d from"../../../../../Icons/copied.svg.js";import m from"../../../../../Icons/file.svg.js";import p from"../../../../../Icons/upload-cloud.svg.js";import u from"copy-to-clipboard";import f from"../../../../../../common/error.js";import{getYouTubeEmbedUrl as h}from"../common/youtube.js";const b=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,v=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),g=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),w=new Set(["mp4","webm","mov","avi","mkv","m4v"]),x=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),k=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),y=new Set(["pdf","html","htm",...x,...k]),j=new Set([...v,...g,...w,...y]),N=e=>v.has(e)?"image":g.has(e)?"audio":w.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":x.has(e)?"text":k.has(e)?"office":"file",C=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},O=e=>{try{return new URL(C(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},I=e=>{try{return new URL(C(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},S=e=>{const t=C(e);return null!==h(t)},F=e=>{const t=C(e);if(O(t))return!1;if(I(t))return!0;if(S(t))return!1;if((e=>{const t=C(e);return/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,n,i;try{const l=new URL(C(e));return"https:"!==l.protocol&&"http:"!==l.protocol?null:null!==(i=null===(n=null===(o=null===(t=l.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===n?void 0:n.toLowerCase())&&void 0!==i?i:null}catch(e){return null}})(t);return!!o&&y.has(o)},$=(e,t)=>{const o=C(e);return!S(o)&&(F(o)||(null==t?void 0:t.has(o)))},D=(e,t)=>{for(const o of e.matchAll(b))if($(o[0],t))return!0;return!1},R=e=>{var t,o;try{const n=C(e),i=new URL(n);if("https:"!==i.protocol&&"http:"!==i.protocol)return null;const l=i.pathname.split("/").filter(Boolean).pop();if(!l)return null;const r=decodeURIComponent(l),a=null===(o=null===(t=r.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return a&&(O(n)||j.has(a))?{url:n,fileName:r,extension:a,kind:N(a)}:null}catch(e){return null}},U=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),L=({fileInfo:h,displayName:b})=>{const{theme:v,colors:g,disableHtml:w,disableJs:x}=a(),{contextId:k,pickaxeId:y,pickaxe:j,translations:N}=i(),{isLoggedIn:C,token:O}=l(),I=r(),[S,F]=n(!1),[$,D]=n(!1),[R,U]=n(!1),L=(e,t)=>{var o;return null!==(o=null==N?void 0:N[e])&&void 0!==o?o:t},B="dark"===v?"#30363D":"#D0D7DE",T="dark"===v?"#0D1117":"#F6F8FA",_="dark"===v?"#161B22":"#FFFFFF",A=(null==b?void 0:b.trim())||h.fileName,E=A!==h.fileName,P={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:g.accentText,backgroundColor:g.accent,opacity:.88,flexShrink:0},z=(e,n,i)=>o("div",Object.assign({className:"flex w-full p-4"},{children:t("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:_,border:`1px solid ${B}`}},{children:[o("iframe",Object.assign({src:e,title:n},i,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),o("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===v?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${B}`,backgroundColor:T,color:g.secondaryText}},{children:[t("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:B}},{children:[o("a",Object.assign({href:h.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:g.secondaryText},title:E?`${A} (${h.fileName})`:A},{children:A})),t("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[o("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=h.url,e.download=h.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:L("download","Download"),"aria-label":L("download","Download"),style:P},{children:o(s,{className:"h-[18px] w-[18px]"})})),o("button",Object.assign({type:"button",onClick:()=>{e(void 0,void 0,void 0,(function*(){try{F(!0),u(h.url),yield new Promise((e=>setTimeout(e,1500)))}finally{F(!1)}}))},title:S?L("copied","Copied"):L("copy-link","Copy link"),"aria-label":S?L("copied","Copied"):L("copy-link","Copy link"),style:Object.assign(Object.assign({},P),{opacity:S?1:P.opacity})},{children:o(S?d:c,{className:"h-[18px] w-[18px]"})})),C&&O&&o("button",Object.assign({type:"button",disabled:$||R,onClick:()=>{e(void 0,void 0,void 0,(function*(){if(O&&!$){D(!0),U(!1);try{const e=yield fetch(h.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],h.fileName,{type:t.type||"application/octet-stream"});yield I.document(Object.assign(Object.assign({contextId:k,pickaxeId:y,file:o},(null==j?void 0:j.workspaceid)&&{workspaceId:j.workspaceid}),{studioSessionToken:O,isUserDocument:!0})),U(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(f(e))}finally{D(!1),U(!1)}}}))},title:$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},P),{opacity:$||R?.55:P.opacity,cursor:$||R?"not-allowed":"pointer"})},{children:o(p,{className:"h-[18px] w-[18px]"})}))]}))]})),o("div",{children:(()=>{if("image"===h.kind)return o("img",{src:h.url,alt:h.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===h.kind)return o("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:o("audio",{className:"w-full",controls:!0,src:h.url})}));if("video"===h.kind)return o("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:h.url});if("pdf"===h.kind||"text"===h.kind){const e="pdf"===h.kind?`${h.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:h.url;return z(e,h.fileName)}if("html"===h.kind&&!w){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",x?"":"allow-scripts"].filter(Boolean).join(" ");return z(h.url,h.fileName,{sandbox:e})}return"office"===h.kind?z(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(h.url)}`,h.fileName):t("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[o(m,{className:"h-8 w-8 shrink-0"}),o("span",Object.assign({className:"break-all"},{children:h.extension.toUpperCase()}))]}))})()})]}))};export{L as default,R as getFilePreviewInfo,I as isDocumentSourceUrl,O as isGeneratedFileUrl,F as isSourceLikeRichPreviewUrl,C as normalizeMarkdownUrl,U as shouldRenderFilePreview,$ as shouldSuppressRichPreviewForUrl,D as shouldSuppressRichPreviewInText};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useMemo as r,Children as t,isValidElement as o}from"react";import{usePickaxeMarkdownContext as m}from"../../hooks/usePickaxeMarkdownContext.js";import i from"../common/IframeVideo.js";import c,{normalizeMarkdownUrl as s,shouldSuppressRichPreviewForUrl as n,getFilePreviewInfo as l,shouldRenderFilePreview as a}from"./FilePreview.js";const u=e=>{let r="";return t.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?o(e)&&(r+=u(e.props.children)):r+=e})),r.trim().replace(/\s+/g," ")},f=({href:t="",children:o,filePreviewSeenRef:f,suppressedRichPreviewUrls:p})=>{const{colors:h}=m(),b=r((()=>t?s(t):""),[t]),d=r((()=>n(b,p)),[b,p]),w=r((()=>l(b)),[b]),v=r((()=>((e,r)=>{const t=u(e);if(t&&t!==r&&s(t)!==r)return t})(o,b)),[o,b]),y=r((()=>{if(d)return null;if(w)return null;const e=b.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const r=b.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=b.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=b.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[w,b,d]);return y?e(i,{title:y.title,src:y.src}):w&&!d&&a(w,f)?e(c,{fileInfo:w,displayName:v}):e("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:h.accent}},{children:o}))};export{f as A};
1
+ import{jsx as e}from"react/jsx-runtime";import{useMemo as r,Children as t,isValidElement as o}from"react";import{usePickaxeMarkdownContext as m}from"../../hooks/usePickaxeMarkdownContext.js";import i from"../common/IframeVideo.js";import{getYouTubeEmbedUrl as s}from"../common/youtube.js";import c,{normalizeMarkdownUrl as n,shouldSuppressRichPreviewForUrl as l,getFilePreviewInfo as a,shouldRenderFilePreview as f}from"./FilePreview.js";const p=e=>{let r="";return t.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?o(e)&&(r+=p(e.props.children)):r+=e})),r.trim().replace(/\s+/g," ")},u=({href:t="",children:o,filePreviewSeenRef:u,suppressedRichPreviewUrls:d})=>{const{colors:h}=m(),b=r((()=>t?n(t):""),[t]),w=r((()=>l(b,d)),[b,d]),v=r((()=>a(b)),[b]),y=r((()=>((e,r)=>{const t=p(e);if(t&&t!==r&&n(t)!==r)return t})(o,b)),[o,b]),j=r((()=>{if(w)return null;if(v)return null;const e=s(b);if(e)return{title:"youtube-embed",src:e};const r=b.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=b.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=b.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[v,b,w]);return j?e(i,{title:j.title,src:j.src}):v&&!w&&f(v,u)?e(c,{fileInfo:v,displayName:y}):e("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:h.accent}},{children:o}))};export{u as A};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useMemo as t}from"react";import r from"../common/IframeVideo.js";import{shouldSuppressRichPreviewInText as o}from"../A/FilePreview.js";const m=({children:m,suppressedRichPreviewUrls:i})=>{const c=t((()=>{if("string"!=typeof m)return null;if(o(m,i))return null;const e=m.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=m.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=m.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const c=m.match(/streamable\.com\/([\w-]+)/i);return c?{title:"streamable-embed",src:`https://streamable.com/e/${c[1]}`}:null}),[m,i]);return c?e(r,{title:c.title,src:c.src}):e("p",{children:m})};export{m as P};
1
+ import{jsx as e}from"react/jsx-runtime";import{useMemo as t}from"react";import r from"../common/IframeVideo.js";import{getYouTubeEmbedUrl as o}from"../common/youtube.js";import{shouldSuppressRichPreviewInText as m}from"../A/FilePreview.js";const i=({children:i,suppressedRichPreviewUrls:c})=>{const s=t((()=>{if("string"!=typeof i)return null;if(m(i,c))return null;const e=o(i);if(e)return{title:"youtube-embed",src:e};const t=i.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=i.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const s=i.match(/streamable\.com\/([\w-]+)/i);return s?{title:"streamable-embed",src:`https://streamable.com/e/${s[1]}`}:null}),[i,c]);return s?e(r,{title:s.title,src:s.src}):e("p",{children:i})};export{i as P};
@@ -0,0 +1 @@
1
+ const t=/(?:https?:\/\/)?(?:(?:www|m)\.)?(?:youtube\.com\/watch\?[^\s<>"']+|youtu\.be\/[\w-]+(?:[?#][^\s<>"']*)?)/i,e=e=>{var r,n;const s=e.match(t);if(!s)return null;const a=s[0].replace(/[),.!;:]+$/,"");try{const t=new URL(/^https?:\/\//i.test(a)?a:`https://${a}`),e=t.hostname.toLowerCase(),s="youtu.be"===e,u=("youtube.com"===e||e.endsWith(".youtube.com"))&&"/watch"===t.pathname;if(!s&&!u)return null;const o=s?t.pathname.split("/").filter(Boolean)[0]:t.searchParams.get("v");if(!o||!/^[\w-]+$/.test(o))return null;const c=(t=>{if(!t)return null;const e=t.trim().toLowerCase();if(/^\d+$/.test(e))return Number.parseInt(e,10);const r=e.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);if(!r||!r.slice(1).some(Boolean))return null;const[,n="0",s="0",a="0"]=r;return 3600*Number.parseInt(n,10)+60*Number.parseInt(s,10)+Number.parseInt(a,10)})(null!==(n=null!==(r=t.searchParams.get("start"))&&void 0!==r?r:t.searchParams.get("t"))&&void 0!==n?n:(t=>{const e=t.hash.replace(/^#/,"");return e?new URLSearchParams(e).get("t"):null})(t)),l=new URL(`https://www.youtube.com/embed/${o}`);return null!==c&&c>0&&l.searchParams.set("start",String(c)),l.toString()}catch(t){return null}};export{e as getYouTubeEmbedUrl};
@@ -0,0 +1 @@
1
+ export declare const getYouTubeEmbedUrl: (value: string) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.12.0",
3
+ "version": "6.12.1",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",