Team Ai
Apppublic

gbehem/Data_Visualization_Project_RQ2

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
markdown-renderer-MR9df58W.js11 linesDownload Raw Back to assets
1import{s as A}from"./chunk-LvLJmgfZ.js";import{u as oe}from"./useEvent-O0nX5vok.js";import{t as ie}from"./react-Bj1aDYRI.js";import{Dt as le,E as se,Ft as ue}from"./cells-fq1RMGX_.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{o as ce}from"./utils-tNbLd14P.js";import{t as he}from"./jsx-runtime-icT_Ltz2.js";import{t as P}from"./button-Ej3vmCIF.js";import{at as fe}from"./dist-B_cxg-E4.js";import{t as q}from"./createLucideIcon-Cm-Z7dYr.js";import{n as me,t as pe}from"./LazyAnyLanguageCodeMirror-m8w66E4s.js";import{r as de}from"./useTheme-BYXBU1of.js";import{n as ge}from"./copy-YwM0Pd7v.js";import{c as k,d as xe,f as ye,g as we,h as ve,l as ke,m as C,o as be,p as Fe,s as N}from"./chunk-5FQGJX7Z-CM1a_K7I.js";import{c as I}from"./katex-rvFxOCU-.js";import{r as Ne}from"./html-to-image-BnSc-Wa0.js";import{o as Te}from"./focus-DYwTiH9-.js";var Ce=q("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),Ee=q("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]),_=D(),w=A(ie(),1),B={},z={};function Se(e){let t=(0,_.c)(6),[r,n]=(0,w.useState)(B[e]??!1),a,o;t[0]!==e||t[1]!==r?(a=()=>{B[e]=r},o=[e,r],t[0]=e,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,w.useEffect)(a,o);let i;return t[4]===r?i=t[5]:(i=[r,n],t[4]=r,t[5]=i),i}function Me(e){let t=(0,_.c)(6),[r,n]=(0,w.useState)(z[e]??!1),a,o;t[0]!==e||t[1]!==r?(a=()=>{z[e]=r},o=[e,r],t[0]=e,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,w.useEffect)(a,o);let i;return t[4]===r?i=t[5]:(i=[r,n],t[4]=r,t[5]=i),i}function $e(e){return e==null||e.data==null||e.data===""}function je(e,t){return`data:${t};base64,${e}`}function Ae(e){return e.startsWith("data:")&&e.includes(";base64,")}function De(e){return e.split(",")[1]}function Pe(e){let t=globalThis.atob(e),r=t.length,n=new Uint8Array(r);for(let a=0;a<r;a++)n[a]=t.charCodeAt(a);return n}const O=Uint8Array.fromBase64??Pe;function U(e){let t=O(e);return new DataView(t.buffer)}function qe(e){let t="",r=e.length;for(let n=0;n<r;n++)t+=String.fromCharCode(e[n]);return globalThis.btoa(t)}const Ie=Uint8Array.prototype.toBase64?e=>e.toBase64():qe;function _e(e){return Ie(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Be(e){return(e.buffers??[]).map(U)}function ze(e,t){return V(e,t||{})||{type:"root",children:[]}}function V(e,t){let r=Oe(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function Oe(e,t){switch(e.nodeType){case 1:return Re(e,t);case 3:return Ve(e);case 8:return Le(e);case 9:return L(e,t);case 10:return Ue();case 11:return L(e,t);default:return}}function L(e,t){return{type:"root",children:R(e,t)}}function Ue(){return{type:"doctype"}}function Ve(e){return{type:"text",value:e.nodeValue||""}}function Le(e){return{type:"comment",value:e.nodeValue||""}}function Re(e,t){let r=e.namespaceURI,n=r===C.svg?we:ve,a=r===C.html?e.tagName.toLowerCase():e.tagName,o=r===C.html&&a==="template"?e.content:e,i=e.getAttributeNames(),s={},l=-1;for(;++l<i.length;)s[i[l]]=e.getAttribute(i[l])||"";return n(a,s,R(o,t))}function R(e,t){let r=e.childNodes,n=[],a=-1;for(;++a<r.length;){let o=V(r[a],t);o!==void 0&&n.push(o)}return n}var We=new DOMParser;function He(e,t){return ze(t!=null&&t.fragment?Ke(e):We.parseFromString(e,"text/html"))}function Ke(e){let t=document.createElement("template");return t.innerHTML=e,t.content}const W=(function(e,t,r){let n=Fe(r);if(!e||!e.type||!e.children)throw Error("Expected parent node");if(typeof t=="number"){if(t<0||t===1/0)throw Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]}),b=(function(e){if(e==null)return Ge;if(typeof e=="string")return Xe(e);if(typeof e=="object")return Qe(e);if(typeof e=="function")return E(e);throw Error("Expected function, string, or array as `test`")});function Qe(e){let t=[],r=-1;for(;++r<e.length;)t[r]=b(e[r]);return E(n);function n(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function Xe(e){return E(t);function t(r){return r.tagName===e}}function E(e){return t;function t(r,n,a){return!!(Je(r)&&e.call(this,r,typeof n=="number"?n:void 0,a||void 0))}}function Ge(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Je(e){return typeof e=="object"&&!!e&&"type"in e&&"tagName"in e}var H=/\n/g,K=/[\t ]+/g,S=b("br"),Q=b(ot),Ye=b("p"),X=b("tr"),Ze=b(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",at,it]),G=b("address.article.aside.blockquote.body.caption.center.dd.dialog.dir.dl.dt.div.figure.figcaption.footer.form,.h1.h2.h3.h4.h5.h6.header.hgroup.hr.html.legend.li.listing.main.menu.nav.ol.p.plaintext.pre.section.ul.xmp".split("."));function et(e,t){let r=t||{},n="children"in e?e.children:[],a=G(e),o=Z(e,{whitespace:r.whitespace||"normal",breakBefore:!1,breakAfter:!1}),i=[];(e.type==="text"||e.type==="comment")&&i.push(...Y(e,{whitespace:o,breakBefore:!0,breakAfter:!0}));let s=-1;for(;++s<n.length;)i.push(...J(n[s],e,{whitespace:o,breakBefore:s?void 0:a,breakAfter:s<n.length-1?S(n[s+1]):a}));let l=[],h;for(s=-1;++s<i.length;){let f=i[s];typeof f=="number"?h!==void 0&&f>h&&(h=f):f&&(h!==void 0&&h>-1&&l.push(`2`.repeat(h)||" "),h=-1,l.push(f))}return l.join("")}function J(e,t,r){return e.type==="element"?tt(e,t,r):e.type==="text"?r.whitespace==="normal"?Y(e,r):nt(e):[]}function tt(e,t,r){let n=Z(e,r),a=e.children||[],o=-1,i=[];if(Ze(e))return i;let s,l;for(S(e)||X(e)&&W(t,e,X)?l=`3`:Ye(e)?(s=2,l=2):G(e)&&(s=1,l=1);++o<a.length;)i=i.concat(J(a[o],e,{whitespace:n,breakBefore:o?void 0:s,breakAfter:o<a.length-1?S(a[o+1]):l}));return Q(e)&&W(t,e,Q)&&i.push("	"),s&&i.unshift(s),l&&i.push(l),i}function Y(e,t){let r=String(e.value),n=[],a=[],o=0;for(;o<=r.length;){H.lastIndex=o;let l=H.exec(r),h=l&&"index"in l?l.index:r.length;n.push(rt(r.slice(o,h).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?t.breakBefore:!0,h===r.length?t.breakAfter:!0)),o=h+1}let i=-1,s;for(;++i<n.length;)n[i].charCodeAt(n[i].length-1)===8203||i<n.length-1&&n[i+1].charCodeAt(0)===8203?(a.push(n[i]),s=void 0):n[i]?(typeof s=="number"&&a.push(s),a.push(n[i]),s=0):(i===0||i===n.length-1)&&a.push(0);return a}function nt(e){return[String(e.value)]}function rt(e,t,r){let n=[],a=0,o;for(;a<e.length;){K.lastIndex=a;let i=K.exec(e);o=i?i.index:e.length,!a&&!o&&i&&!t&&n.push(""),a!==o&&n.push(e.slice(a,o)),a=i?o+i[0].length:o}return a!==o&&!r&&n.push(""),n.join(" ")}function Z(e,t){if(e.type==="element"){let r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function at(e){return!!(e.properties||{}).hidden}function ot(e){return e.tagName==="td"||e.tagName==="th"}function it(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var lt={},st=[];function ut(e){let t=e||lt;return function(r,n){ye(r,"element",function(a,o){let i=Array.isArray(a.properties.className)?a.properties.className:st,s=i.includes("language-math"),l=i.includes("math-display"),h=i.includes("math-inline"),f=l;if(!s&&!l&&!h)return;let m=o[o.length-1],d=a;if(a.tagName==="code"&&s&&m&&m.type==="element"&&m.tagName==="pre"&&(d=m,m=o[o.length-2],f=!0),!m)return;let p=et(d,{whitespace:"pre"}),u;try{u=I.renderToString(p,{...t,displayMode:f,throwOnError:!0})}catch(v){let F=v,c=F.name.toLowerCase();n.message("Could not render math with KaTeX",{ancestors:[...o,a],cause:F,place:a.position,ruleId:c,source:"rehype-katex"});try{u=I.renderToString(p,{...t,displayMode:f,strict:"ignore",throwOnError:!1})}catch{u=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(v)},children:[{type:"text",value:p}]}]}}typeof u=="string"&&(u=He(u,{fragment:!0}).children);let y=m.children.indexOf(d);return m.children.splice(y,1,...u),xe})}}function ct(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:o},exit:{mathFlow:a,mathFlowFence:n,mathFlowFenceMeta:r,mathFlowValue:s,mathText:i,mathTextData:s}};function e(l){this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[{type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]}]}},l)}function t(){this.buffer()}function r(){let l=this.resume(),h=this.stack[this.stack.length-1];h.type,h.meta=l}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function a(l){let h=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),f=this.stack[this.stack.length-1];f.type,this.exit(l),f.value=h;let m=f.data.hChildren[0];m.type,m.tagName,m.children.push({type:"text",value:h}),this.data.mathFlowInside=void 0}function o(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function i(l){let h=this.resume(),f=this.stack[this.stack.length-1];f.type,this.exit(l),f.value=h,f.data.hChildren.push({type:"text",value:h})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}function ht(e){let t=(e||{}).singleDollarTextMath;return t??(t=!0),n.peek=a,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`4`,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:r,inlineMath:n}};function r(o,i,s,l){let h=o.value||"",f=s.createTracker(l),m="$".repeat(Math.max(ke(h,"$")+1,2)),d=s.enter("mathFlow"),p=f.move(m);if(o.meta){let u=s.enter("mathFlowMeta");p+=f.move(s.safe(o.meta,{after:`5`,before:p,encode:["$"],...f.current()})),u()}return p+=f.move(`6`),h&&(p+=f.move(h+`7`)),p+=f.move(m),d(),p}function n(o,i,s){let l=o.value||"",h=1;for(t||h++;RegExp("(^|[^$])"+"\\$".repeat(h)+"([^$]|$)").test(l);)h++;let f="$".repeat(h);/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^\$|\$$/.test(l))&&(l=" "+l+" ");let m=-1;for(;++m<s.unsafe.length;){let d=s.unsafe[m];if(!d.atBreak)continue;let p=s.compilePattern(d),u;for(;u=p.exec(l);){let y=u.index;l.codePointAt(y)===10&&l.codePointAt(y-1)===13&&y--,l=l.slice(0,y)+" "+l.slice(u.index+1)}}return f+l+f}function a(){return"$"}}const ft={tokenize:mt,concrete:!0,name:"mathFlow"};var ee={tokenize:pt,partial:!0};function mt(e,t,r){let n=this,a=n.events[n.events.length-1],o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,i=0;return s;function s(c){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(c)}function l(c){return c===36?(e.consume(c),i++,l):i<2?r(c):(e.exit("mathFlowFenceSequence"),N(e,h,"whitespace")(c))}function h(c){return c===null||k(c)?m(c):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(c))}function f(c){return c===null||k(c)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),m(c)):c===36?r(c):(e.consume(c),f)}function m(c){return e.exit("mathFlowFence"),n.interrupt?t(c):e.attempt(ee,d,v)(c)}function d(c){return e.attempt({tokenize:F,partial:!0},v,p)(c)}function p(c){return(o?N(e,u,"linePrefix",o+1):u)(c)}function u(c){return c===null?v(c):k(c)?e.attempt(ee,d,v)(c):(e.enter("mathFlowValue"),y(c))}function y(c){return c===null||k(c)?(e.exit("mathFlowValue"),u(c)):(e.consume(c),y)}function v(c){return e.exit("mathFlow"),t(c)}function F(c,ne,M){let $=0;return N(c,re,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function re(x){return c.enter("mathFlowFence"),c.enter("mathFlowFenceSequence"),j(x)}function j(x){return x===36?($++,c.consume(x),j):$<i?M(x):(c.exit("mathFlowFenceSequence"),N(c,ae,"whitespace")(x))}function ae(x){return x===null||k(x)?(c.exit("mathFlowFence"),ne(x)):M(x)}}}function pt(e,t,r){let n=this;return a;function a(i){return i===null?t(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return n.parser.lazy[n.now().line]?r(i):t(i)}}function dt(e){let t=(e||{}).singleDollarTextMath;return t??(t=!0),{tokenize:r,resolve:gt,previous:xt,name:"mathText"};function r(n,a,o){let i=0,s,l;return h;function h(u){return n.enter("mathText"),n.enter("mathTextSequence"),f(u)}function f(u){return u===36?(n.consume(u),i++,f):i<2&&!t?o(u):(n.exit("mathTextSequence"),m(u))}function m(u){return u===null?o(u):u===36?(l=n.enter("mathTextSequence"),s=0,p(u)):u===32?(n.enter("space"),n.consume(u),n.exit("space"),m):k(u)?(n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),m):(n.enter("mathTextData"),d(u))}function d(u){return u===null||u===32||u===36||k(u)?(n.exit("mathTextData"),m(u)):(n.consume(u),d)}function p(u){return u===36?(n.consume(u),s++,p):s===i?(n.exit("mathTextSequence"),n.exit("mathText"),a(u)):(l.type="mathTextData",d(u))}}}function gt(e){let t=e.length-4,r=3,n,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=r;++n<t;)if(e[n][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[r][1].type="mathTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)a===void 0?n!==t&&e[n][1].type!=="lineEnding"&&(a=n):(n===t||e[n][1].type==="lineEnding")&&(e[a][1].type="mathTextData",n!==a+2&&(e[a][1].end=e[n-1][1].end,e.splice(a+2,n-a-2),t-=n-a-2,n=a+2),a=void 0);return e}function xt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function yt(e){return{flow:{36:ft},text:{36:dt(e)}}}var wt={};function vt(e){let t=this,r=e||wt,n=t.data(),a=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),i=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);a.push(yt(r)),o.push(ct()),i.push(ht(r))}function kt(e={}){return{name:"katex",type:"math",remarkPlugin:[vt,{singleDollarTextMath:e.singleDollarTextMath??!1}],rehypePlugin:[ut,{errorColor:e.errorColor??"var(--color-muted-foreground)"}],getStyles(){return"katex/dist/katex.min.css"}}}var bt=kt(),T=D(),g=A(he(),1),Ft=[fe.lineWrapping];function Nt(e,t){return e?e==="python"?{language:e,code:t}:e==="sql"?{language:"python",code:le.fromQuery(t)}:e==="markdown"?{language:"python",code:ue.fromMarkdown(t)}:e==="shell"||e==="bash"?{language:"python",code:`import subprocess8subprocess.run("${t}")`}:{language:"python",code:`_${e} = """9${t}10"""`}:{language:"python",code:t}}var Tt=e=>{let t=(0,T.c)(9),{code:r,language:n}=e,{createNewCell:a}=se(),o=Te(),i=oe(ce),s;t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n||t[4]!==o?(s=()=>{let m=Nt(n,r);n==="sql"&&Ne({autoInstantiate:i,createNewCell:a,fromCellId:o}),a({code:m.code,before:!1,cellId:o??"__end__"})},t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s):s=t[5];let l=s,h;t[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,g.jsx)(me,{className:"ml-2 h-4 w-4"}),t[6]=h):h=t[6];let f;return t[7]===l?f=t[8]:(f=(0,g.jsxs)(P,{size:"xs",variant:"outline",onClick:l,children:["Add to Notebook",h]}),t[7]=l,t[8]=f),f},Ct=e=>{let t=(0,T.c)(17),{code:r,language:n}=e,{theme:a}=de(),[o,i]=(0,w.useState)(r);o!==r&&i(r);let s;t[0]===o?s=t[1]:(s=async()=>{await ge(o)},t[0]=o,t[1]=s);let l=s,h=a==="dark"?"dark":"light",f;t[2]!==n||t[3]!==h||t[4]!==o?(f=(0,g.jsx)(w.Suspense,{children:(0,g.jsx)(pe,{theme:h,language:n,hideUnsupportedLanguageErrors:!0,className:"cm border rounded overflow-hidden",extensions:Ft,value:o,onChange:i})}),t[2]=n,t[3]=h,t[4]=o,t[5]=f):f=t[5];let m;t[6]===l?m=t[7]:(m=(0,g.jsx)(Et,{size:"xs",variant:"outline",onClick:l,children:"Copy"}),t[6]=l,t[7]=m);let d;t[8]!==n||t[9]!==o?(d=(0,g.jsx)(Tt,{code:o,language:n}),t[8]=n,t[9]=o,t[10]=d):d=t[10];let p;t[11]!==m||t[12]!==d?(p=(0,g.jsxs)("div",{className:"flex justify-end mt-2 space-x-2",children:[m,d]}),t[11]=m,t[12]=d,t[13]=p):p=t[13];let u;return t[14]!==f||t[15]!==p?(u=(0,g.jsxs)("div",{className:"relative",children:[f,p]}),t[14]=f,t[15]=p,t[16]=u):u=t[16],u},Et=e=>{let t=(0,T.c)(9),r,n;t[0]===e?(r=t[1],n=t[2]):({onClick:r,...n}=e,t[0]=e,t[1]=r,t[2]=n);let[a,o]=(0,w.useState)(!1),i;t[3]===r?i=t[4]:(i=h=>{r==null||r(h),o(!0),setTimeout(()=>o(!1),1e3)},t[3]=r,t[4]=i);let s=a?"Copied":"Copy",l;return t[5]!==n||t[6]!==i||t[7]!==s?(l=(0,g.jsx)(P,{...n,onClick:i,children:s}),t[5]=n,t[6]=i,t[7]=s,t[8]=l):l=t[8],l},St={code:({children:e,className:t})=>{let r=t==null?void 0:t.replace("language-","");if(r&&typeof e=="string"){let n=e.trim();return(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"text-xs text-muted-foreground pl-1",children:r}),(0,g.jsx)(Ct,{code:n,language:r})]})}return(0,g.jsx)("code",{className:t,children:e})}};const te=(0,w.memo)(e=>{let t=(0,T.c)(3),{content:r}=e,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={math:bt},t[0]=n):n=t[0];let a;return t[1]===r?a=t[2]:(a=(0,g.jsx)(be,{components:St,plugins:n,className:"mo-markdown-renderer",children:r}),t[1]=r,t[2]=a),a});te.displayName="MarkdownRenderer";export{_e as a,Be as c,Se as d,Ee as f,O as i,$e as l,je as n,De as o,Ce as p,U as r,Ae as s,te as t,Me as u};11