import{aQ as O,s as _,bH as l,ct as C,aK as d,I as i,bi as o,t as h,cs as b,u as E,co as w}from"./index-UvaAT40e.js";import{O as $}from"./ObjectBar-BQn-rAYH.js";import{T as N}from"./ThreeColumnLayout-BRd-Jgmr.js";import{L as T}from"./LoadingSpinner-CRcacgcO.js";import{_ as j,P as R}from"./PlaceHolderImage-OI0HV4no.js";import{e as k,u as L,a as S,c as F,d as x,S as D}from"./useTriplestore-BZngkwQJ.js";import{M as A}from"./MapViewer-CqxinSFL.js";import{a as P,c as B,p as V}from"./triplestore-YmGWX4yk.js";import"./ChildTreeSearchButton-C65ZPLlZ.js";import"./VDataTable-BagkVmHP.js";import"./VInput-tBjZAjEz.js";import"./VChip-DWC_1h7b.js";import"./VSlideGroup-BkB-Mi6K.js";import"./transform-CA9Jdjju.js";import"./VSliderTrack-BSvqM6gM.js";import"./ObjectCard-Ck5X7LdM.js";import"./_commonjsHelpers-C4iS2aBk.js";const v=` BASE <https://db.antiquitatum-thesaurus.eu> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> PREFIX owl: <http://www.w3.org/2002/07/owl#> `,q={custody:"Aufbewahrung",provenance_institution:"Provenienz"},p={custody:e=>`?object crm:P30i_custody_transferred_through ?transfer_of_custody . ?transfer_of_custody crm:P2_has_type <type/acquisition> . ?transfer_of_custody crm:P29_custody_received_by <actor/${e}> . `,provenance_institution:e=>`?object crm:P30i_custody_transferred_through ?transfer_of_custody . ?transfer_of_custody crm:P2_has_type <type/provenance> . ?transfer_of_custody crm:P29_custody_received_by <actor/${e}> . `};function I(e,t,r){let a=[];if(typeof t=="string"&&(t=[t]),t&&t.length)for(const s of t){let[c,u]=s.split("-IS_OR-");if(c=="context"&&r!="context")for(const m of u.split("-OR-"))a.push(m)}return a.length==0&&(a=Object.keys(p)),`{ ${a.map(s=>p[s](e)).join("} UNION {")} }`}const g={build_institution_condition:I,async get_institution_aggregation({id:e,qfilter:t,signal:r}){let a=` ${v} SELECT (COUNT(DISTINCT ?custody_object) as ?custody) (COUNT(DISTINCT ?prov_object) as ?provenance_institution) WHERE { ${I(e,t,"context")} OPTIONAL { ${p.custody(e)} BIND(?object as ?custody_object) } OPTIONAL { ${p.provenance_institution(e)} BIND(?object as ?prov_object) } } `,n=await P(a,{signal:r}),s=[];for(const[c,u]of Object.entries(n.results.bindings[0]))+u.value>0&&s.push({label:q[c],count:+u.value,iri:c});return s},async get_institution_data({id:e,signal:t}){let r=` ${v} PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT * WHERE { <actor/${e}> crm:P1_is_identified_by / crm:P190_has_symbolic_content ?name . OPTIONAL { <actor/${e}> owl:sameAs ?actor_gnd } SERVICE <https://query.wikidata.org/sparql> { OPTIONAL { ?wd wdt:P227 "${e.replace("gnd_","")}" . ?wd wdt:P625 ?coordinates . } } } `,a=await P(r,{signal:t}),n=B(a,{institution:{name:"name",gnd:"actor_gnd",coordinates:["coordinates"]}});return n.institution.coordinates&&(n.institution.coordinates=n.institution.coordinates.map(s=>V(s))),n.institution}},H={key:0},rt={__name:"Institution",setup(e){const{data:t,dataLoading:r}=k(g.get_institution_data),{objectsCount:a,iris:n,searchLoading:s}=L({conditionFunction:g.build_institution_condition,defaultResultsPerPage:20}),{objectCardsData:c,objectCardsDataLoading:u}=S(n),{objectCardsDataWithRelations:m}=F(c);let f=O({no_grouping:{context:{type:"term_aggregation",loading:!0,values:[],fetch_function:g.get_institution_aggregation}}});return x(f,u),(y,X)=>(d(),_(C,null,{default:l(()=>[i($),i(N,null,{"col-1":l(()=>[y.$vuetify.display.xs?(d(),_(j,{key:0,class:"px-2 mb-3",title:o(t).name},null,8,["title"])):h("",!0),i(b,{border:"",rounded:"",height:430},{default:l(()=>[o(r)?(d(),_(T,{key:0})):o(t).coordinates.length?(d(),_(A,{key:1,coordinates:o(t).coordinates},null,8,["coordinates"])):(d(),_(R,{key:2}))]),_:1})]),"col-2":l(()=>[i(b,{class:"px-2"},{default:l(()=>[y.$vuetify.display.xs?h("",!0):(d(),E("div",H,[i(j,{title:o(t).name},null,8,["title"]),i(w,{class:"my-4"})]))]),_:1})]),_:1}),i(w),i(D,{"object-cards-data":o(c),"object-cards-data-with-relations":o(m),"search-loading":o(s)||o(u),"total-count":o(a),aggregation:o(f),"default-results-per-page":20,"default-sorting":"production_date_asc",mode:"objects_institution"},null,8,["object-cards-data","object-cards-data-with-relations","search-loading","total-count","aggregation"])]),_:1}))}};export{rt as default};