import{aK as O,s as _,bx as l,cj as E,aE as d,I as i,bc as o,t as h,ci as b,u as C,ce as w}from"./index-pVvkWKzi.js";import{O as $}from"./ObjectBar-Cg_Khdxy.js";import{T as N}from"./ThreeColumnLayout-QD46NqkJ.js";import{L as T}from"./LoadingSpinner-BjU99GiU.js";import{_ as j,P as R}from"./PlaceHolderImage-CBAhttrD.js";import{e as k,u as L,a as S,c as x,d as F,S as D}from"./useTriplestore-DEK9P7ID.js";import{M as A}from"./MapViewer-CYBvra4q.js";import{a as P,c as B,p as V}from"./triplestore-DD4Ytlqh.js";import"./ChildTreeSearchButton-DaF4HIkT.js";import"./VDataTable-CcxiU4H1.js";import"./VInput-C6ablejM.js";import"./VChip-CuvHYCvE.js";import"./VSlideGroup-CBZvK47O.js";import"./transform-CA9Jdjju.js";import"./VSliderTrack-CNgqQsjp.js";import"./ObjectCard-KETd_wO-.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 n of t){let[c,u]=n.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(n=>p[n](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)
        }
      }
    `,s=await P(a,{signal:r}),n=[];for(const[c,u]of Object.entries(s.results.bindings[0]))+u.value>0&&n.push({label:q[c],count:+u.value,iri:c});return n},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}),s=B(a,{institution:{name:"name",gnd:"actor_gnd",coordinates:["coordinates"]}});return s.institution.coordinates&&(s.institution.coordinates=s.institution.coordinates.map(n=>V(n))),s.institution}},X={key:0},rt={__name:"Institution",setup(e){const{data:t,dataLoading:r}=k(g.get_institution_data),{objectsCount:a,iris:s,searchLoading:n}=L({conditionFunction:g.build_institution_condition,defaultResultsPerPage:20}),{objectCardsData:c,objectCardsDataLoading:u}=S(s),{objectCardsDataWithRelations:m}=x(c);let f=O({no_grouping:{context:{type:"term_aggregation",loading:!0,values:[],fetch_function:g.get_institution_aggregation}}});return F(f,u),(y,H)=>(d(),_(E,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(),C("div",X,[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(n)||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};