import{b1 as v,R as c,j as a,h as p,S as x,H as f}from"./vendor-ClLR6ncd.js";import{L as h,b,a2 as g,g as y}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{a as w}from"./model-Ci5wTidX.js";import{u as S}from"./model-CfTXIMmE.js";import{S as q}from"./SmallStandardSelect-7k6-Wr8Q.js";import{E as L}from"./Messages-BRmQDxrZ.js";import"./MenuItem-CCerWMyq.js";import"./dividerClasses-DvO85-mA.js";const m=[{extension:".json",label:"SPARQL JSON ",value:"application/sparql-results+json"},{extension:".xml",label:"SPARQL XML",value:"application/sparql-results+xml"},{extension:".ttl",label:"SPARQL TTL ",value:"application/sparql-results+ttl"},{extension:".csv",label:"SPARQL Comma-Separated Values",value:"text/csv"},{extension:".csv",label:"Comma-Separated Values",value:"application/processed-csv"},{extension:".csv",label:"Comma-Separated Values (with fields in N-Triples syntax)",value:"text/simple-csv"}],j=[{extension:".nt",label:"N-Triples",value:"text/plain"},{extension:".nq",label:"N-Quads",value:"text/x-nquads"},{extension:".xml",label:"RDF/XML",value:"application/rdf+xml"},{extension:".trig",label:"TriG",value:"application/trig"},{extension:".ttl",label:"Turtle",value:"text/turtle"}],T="query";function P(e,u){var l;const o=w(),r=b(),{queryOptions:t}=g(),n=new URL(y(r),window.location.origin);n.searchParams.append("query",o),n.searchParams.append("infer",t.infer),n.searchParams.append("queryLn",t.queryLn);const s=n.toString();return S({accept:e,file:`${T}${(l=u.find(i=>i.value===e))==null?void 0:l.extension}`,path:s})}const d=[];function k(){const{queryResult:e,isTableFetching:u}=v(),[o,r]=c.useState(m[0].value),t=(e==null?void 0:e._queryType)==="sparql"?m:(e==null?void 0:e._queryType)==="triples"?j:d,n=t.find(i=>i.value===o)===void 0;c.useEffect(()=>{t!==d&&n&&r(t[0].value)},[t,o,n]);const s=P(o,t);if(u||n)return a.jsx(h,{});if(!e)return a.jsx(p,{sx:{color:"text.disabled",p:2,textAlign:"center"},children:"Click on the execute button to get query response"});const l=t===d;return a.jsxs(x,{p:2,children:[a.jsx(L,{error:s.error,resetError:s.reset}),a.jsxs(x,{direction:"row",spacing:1,alignItems:"flex-end",children:[a.jsx(f,{sx:{width:"220px"},variant:"contained",disabled:l||s.isLoading,onClick:s.mutate,children:s.isLoading?"downloading...":"download results"}),a.jsx(p,{pb:"4px",children:"using format"}),a.jsx(q,{sx:{width:"fit-content"},disabled:l,items:t,value:o,onChange:i=>r(i.target.value)})]}),s.isLoading?a.jsx(p,{pt:1,variant:"subtitle2",children:"The file is downloading, check your browser."}):null]})}export{k as default};
