1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[16848,85311],{24400(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.QueryCatalogTemplate=h;const a=r(82329),i=r(29093),l=r(15381),o=r(58215),s=r(78025),u=r(80099),n=r(89108),p=r(97240),c=r(93671),d=r(94155),y=r(22296),f=r(61445),m=r(39871);function h(e){const{semanticContext:t}=i.useContext(s.SemanticContext),r=i.useContext(m.QueryEditorContext);return i.createElement(v,{...e,queryContext:t,queryEditorContext:r})}class v extends i.Component{cancellation=new o.Cancellation;applyingTemplate=this.cancellation.derive();queryTemplateService;queryService;constructor(e){super(e),this.state={};const{queryContext:t}=this.props;this.queryTemplateService=(0,c.QueryTemplateService)(t),this.queryService=(0,p.QueryService)(t)}render(){return i.createElement("div",{onClick:this.fetchAndSetQuery},this.props.children,this.state.fetchingQuery?i.createElement(f.Spinner,{spinnerDelay:0}):null)}componentWillUnmount(){this.cancellation.cancelAll()}fetchAndSetQuery=()=>{if(this.state.fetchingQuery)return;const{queryEditorContext:e}=this.props;e&&(this.applyingTemplate.cancelAll(),this.applyingTemplate=this.cancellation.derive(),this.applyingTemplate.map(this.fetchTemplateWithQuery()).observe({value:([e,t])=>{Boolean(e.args.find(e=>void 0!==e.defaultValue))?this.showParametrizationDialog(r=>{this.setQuery({query:t,template:e,parametrize:r})}):this.setQuery({query:t,template:e,parametrize:!1}),this.setState({fetchingQuery:!1})},error:e=>{(0,d.addNotification)({level:"error",message:"Failed to fetch query template"},e),this.setState({fetchingQuery:!1})}}),this.setState({fetchingQuery:!0}))};showParametrizationDialog(e){const t="query-parametrization-dialog",r=()=>(0,y.getOverlaySystem)().hide(t);(0,y.getOverlaySystem)().show(t,i.createElement(l.Modal,{onHide:r,show:!0,style:{textAlign:"center"}},i.createElement(l.Modal.Header,null,i.createElement(l.Modal.Title,null,"Do you want to apply the default arguments?")),i.createElement(l.Modal.Body,null,i.createElement(l.Button,{variant:"primary",onClick:()=>{r(),e(!0)}},"Apply"),i.createElement(l.Button,{variant:"secondary",style:{marginLeft:5},onClick:()=>{r(),e(!1)}},"Don't Apply"))))}setQuery(e){const{query:t,template:r,parametrize:i}=e;let l=t.value;if(i)try{l=n.SparqlUtil.serializeQuery(function(e,t){const r=n.SparqlUtil.parseQuery(e.value),i=t.args.filter(e=>Boolean(e.defaultValue));if(0===i.length)return r;const l=(0,a.mapValues)((0,a.keyBy)(i,e=>e.variable),e=>e.defaultValue);return n.SparqlClient.setBindings(r,l)}(t,r))}catch(e){(0,d.addNotification)({level:"warning",message:"Failed to substitute default values for query template arguments"},e)}this.props.queryEditorContext.setQuery(l)}fetchTemplateWithQuery(){return this.queryTemplateService.getQueryTemplate(u.Rdf.iri(this.props.iri)).flatMap(({template:e,queryIri:t})=>this.queryService.getQuery(u.Rdf.iri(t)).map(t=>[e,t])).toProperty()}}t.default=h},39871(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.QueryEditorContextProvider=t.QueryEditorContext=void 0;const a=r(70140),i=r(38774),l=r(29093);t.QueryEditorContext=l.createContext(null);class o extends l.Component{query=(0,a.Nothing)();queryPool=i.pool();queryEditorContext;constructor(e){super(e),this.queryEditorContext={getQuery:()=>this.query,setQuery:(e,t={})=>{this.query=(0,a.Just)(e),t.silent||this.queryPool.plug(i.constant({query:this.query,repository:(0,a.fromNullable)(t.repository)}))},queryChanges:this.queryPool.flatMapLatest(e=>i.constant(e)).toProperty().changes()},this.queryPool.plug(i.constant({query:(0,a.Nothing)(),repository:(0,a.Nothing)()}))}render(){return l.createElement(t.QueryEditorContext.Provider,{value:this.queryEditorContext},this.props.children)}}t.QueryEditorContextProvider=o,t.default=o},62541(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LdpService=void 0,t.ldpc=function(e){return new p(e)},t.slugFromName=function(e){return e.toLowerCase().trim().replace(/[^a-zA-Z0-9~_-]+/g,"-")};const a=r(70140),i=r(38774),l=r(82329),o=r(31401),s=r(76573),u=r(80099),{VocabPlatform:n}=u.vocabularies;class p{BASE_CONTAINER;context;constructor(e,t){if(!t||t.isDefault?this.context={repository:"assets"}:this.context=t,"string"!=typeof e)throw new Error("Container IRI cannot be null or undefined");this.BASE_CONTAINER=e}getServiceUrl(e="",t={}){const r=`/container${e}`,a=o.buildQuery(l.assign({repository:this.context.repository},t));return a?`${r}?${a}`:r}static setVisibility(e,t,r){const i=u.Rdf.graph([u.Rdf.triple(u.Rdf.iri(""),n.visibilityItem,e),u.Rdf.triple(e,n.visibility,t),...l.map(r,t=>u.Rdf.triple(e,n.visibleToGroups,t))]);return new p(n.VisibilityContainer.value).addResource(i,a.Nothing())}getContainerIRI=()=>u.Rdf.iri(this.BASE_CONTAINER);getContainer(){return this.fetchResource(u.Rdf.iri(this.BASE_CONTAINER))}get(e){return this.fetchResource(e)}update(e,t){return u.turtle.serialize.serializeGraph(t).flatMap(t=>
1this.sendUpdateResourceRequest(e,{data:t,format:"text/turtle"})).toProperty()}options(e){const t=s.options(this.getServiceUrl()).query({uri:e.value});return i.fromNodeCallback(e=>t.end((t,r)=>e(null!=t?t.status:null,r.ok?r.text:null))).toProperty()}deleteResources(e){const t=this.getServiceUrl("",{iris:e}),r=s.del(t);return i.fromNodeCallback(e=>r.end((t,r)=>e(t,r?r.text:null))).toProperty()}addResource=(e,t=a.Nothing())=>u.turtle.serialize.serializeGraph(e).flatMap(e=>this.createResourceRequest(this.getContainerIRI(),{data:e,format:"text/turtle"},t)).map(e=>u.Rdf.iri(e)).toProperty();renameResource(e,t){const r=s.put(this.getServiceUrl("/rename")).query({uri:e.value,newName:t});return i.stream(e=>(r.end((t,r)=>{t?e.error(t):e.emit(void 0),e.end()}),()=>r.abort())).toProperty()}createResourceRequest=(e,t,r=a.Nothing())=>{let l=s.post(this.getServiceUrl()).query({uri:e.value}).send(t.data).type(t.format);return l=r.map(e=>l.set("Slug",e)).getOrElse(l),i.fromNodeCallback(e=>l.end((t,r)=>e(t,r?r.header.location:null))).toProperty()};copyResource(e,t,r=a.Nothing()){let l=s.get(this.getServiceUrl("/copyResource"));return l=t.map(t=>l.query({source:e.value,target:t.value})).getOrElse(l.query({source:e.value})),l=r.map(e=>l.set("Slug",e)).getOrElse(l),i.fromNodeCallback(e=>l.end((t,r)=>e(t,r?r.header.location:null))).toProperty()}sendUpdateResourceRequest(e,t){const r=s.put(this.getServiceUrl()).query({uri:e.value}).send(t.data).type(t.format);return i.fromNodeCallback(e=>r.end((t,r)=>{e(t,r?u.Rdf.iri(r.header.location):null)})).toProperty()}fetchResource(e){return this.getResourceTriples(e.value,"text/turtle")}getResourceTriples(e,t){return this.getResourceRequest(e,t).flatMap(e=>u.turtle.deserialize.turtleToGraph(e)).toProperty()}getResourceRequest(e,t){const r=s.get(this.getServiceUrl()).query({uri:e}).accept(t);return i.fromNodeCallback(r.end.bind(r)).toProperty().map(e=>e.text)}getExportURL(e){return this.getServiceUrl("/exportResource",{iris:e})}getImportURL(){return this.getServiceUrl("/importResource")}importGetTextFromURL(e){const t=s.get(e);return i.fromNodeCallback(e=>t.end((t,r)=>{e(t,r&&r.ok?r.text:null)})).toProperty()}importFromText(e,t,r){let a=s.post(this.getImportURL()).send(new File([e],"import.ttl"));return r&&(a=a.query({force:r})),t&&(a=a.query({containerIRI:t})),i.fromNodeCallback(e=>a.end((t,r)=>{e(t,r)})).toProperty()}importFromDelayedId(e,t){const r=s.post(this.getImportURL()).query({force:!0,delayedId:e,containerIRI:t});return i.fromNodeCallback(e=>r.end((t,r)=>{e(t,r)})).toProperty()}}t.LdpService=p},93671(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.QueryTemplateService=t.QueryTemplateServiceClass=void 0;const a=r(70140),i=r(82329),l=r(80099),o=r(62541),{VocabPlatform:s,xsd:u,rdf:n,rdfs:p,spl:c,spin:d,dct:y}=l.vocabularies,f=y.subject;class m extends o.LdpService{addItem(e,t,r){const i=this.createGraph(e,t,r);return this.addResource(i,a.Just(e.identifier))}updateItem(e,t,r,a){const i=this.createGraph(t,r,a);return this.update(e,i)}createGraph(e,t,r="http://metaphacts.com/query/"){const{identifier:a,label:i,description:o,args:s}=e,y=l.Rdf.iri(""),m=s.map((e,t)=>{const i=l.Rdf.iri(r+a+"/arg/"+t),o=[l.Rdf.triple(y,d.constraintProp,i),l.Rdf.triple(i,n.type,c.Argument),l.Rdf.triple(i,p.label,l.Rdf.literal(e.label)),l.Rdf.triple(i,c.predicateProp,l.Rdf.iri(r+a+"/predicate/"+e.variable)),l.Rdf.triple(i,c.valueTypeProp,l.Rdf.iri(e.valueType))];e.defaultValue&&o.push(l.Rdf.triple(i,c.defaultValue,e.defaultValue));const s=void 0!==e.optional&&e.optional;return o.push(l.Rdf.triple(i,c.optionalProp,l.Rdf.literal(s,u.boolean))),void 0!==e.comment&&o.push(l.Rdf.triple(i,p.comment,l.Rdf.literal(e.comment))),o}),h=[].concat.apply([],m),v=e.categories.map(e=>l.Rdf.triple(y,f,e));return l.Rdf.graph([l.Rdf.triple(y,n.type,d.Template),l.Rdf.triple(y,n.type,e.templateType),l.Rdf.triple(y,p.label,l.Rdf.literal(i)),l.Rdf.triple(y,p.comment,l.Rdf.literal(o)),l.Rdf.triple(y,d.bodyProp,l.Rdf.iri(t)),...h,...v])}getQueryTemplate(e){return this.get(e).map(t=>this.parseGraphToQueryTemplate(e,t))}parseGraphToQueryTemplate(e,t){const r=[d.AskTemplate,d.SelectTemplate,d.ConstructTemplate,d.UpdateTemplate].map(e=>e.value),a=t.triples.find(e=>
1e.p.equals(n.type)&&(0,i.includes)(r,e.o.value)).o,o=t.triples.filter(t=>t.s.equals(e)&&t.p.equals(d.constraintProp)).toArray().map(e=>e.o).map(e=>{const r=t.triples.find(t=>t.s.equals(e)&&t.p.equals(p.label)).o.value,a=t.triples.find(t=>t.s.equals(e)&&t.p.equals(c.predicateProp)).o.value,i=t.triples.find(t=>t.s.equals(e)&&t.p.equals(p.comment)).o.value,o=t.triples.find(t=>t.s.equals(e)&&t.p.equals(c.optionalProp)),s=t.triples.find(t=>t.s.equals(e)&&t.p.equals(c.valueTypeProp)).o.value,u=t.triples.find(t=>t.s.equals(e)&&t.p.equals(c.defaultValue)&&l.Rdf.isNode(t.o));return{label:r,variable:this.extractValueFromIri(a),comment:i,valueType:s,defaultValue:u?u.o:void 0,optional:!!o&&"true"===o.o.value}});return{template:{templateType:a,identifier:this.extractValueFromIri(e.value),label:t.triples.find(t=>t.s.equals(e)&&t.p.equals(p.label)).o.value,description:t.triples.find(t=>t.s.equals(e)&&t.p.equals(p.comment)).o.value,categories:t.triples.filter(t=>t.s.equals(e)&&t.p.equals(f)&&l.Rdf.isIri(t.o)).map(e=>e.o).toArray(),args:o},queryIri:t.triples.find(t=>t.s.equals(e)&&t.p.equals(d.bodyProp)).o.value}}extractValueFromIri(e){return/[^/]*$/.exec(e)[0]}}t.QueryTemplateServiceClass=m;t.QueryTemplateService=function(e){return new m(s.QueryTemplateContainer.value,e)}},94155(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.clearNotifications=t.removeNotification=t.addNotification=void 0;const a=r(27527);var i=r(80477);Object.defineProperty(t,"addNotification",{enumerable:!0,get:function(){return i.addNotification}}),Object.defineProperty(t,"removeNotification",{enumerable:!0,get:function(){return i.removeNotification}}),Object.defineProperty(t,"clearNotifications",{enumerable:!0,get:function(){return i.clearNotifications}}),a.__exportStar(r(18642),t),a.__exportStar(r(38091),t)},97240(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.QueryService=t.QueryServiceClass=void 0;const a=r(70140),i=r(82329),l=r(80099),o=r(62541),{VocabPlatform:s,rdf:u,rdfs:n,sp:p}=l.vocabularies;class c extends o.LdpService{addItem(e){const t=this.createGraph(e),r=e.label;return this.addResource(t,a.Just(r))}updateItem(e,t){const r=this.createGraph(t);return this.update(e,r)}createGraph(e){const{label:t,value:r,type:a,queryType:i}=e,o="update"===a?p.Update:p.Query,s=[l.Rdf.triple(l.Rdf.iri(""),u.type,o),l.Rdf.triple(l.Rdf.iri(""),u.type,this.getType(a,i)),l.Rdf.triple(l.Rdf.iri(""),n.label,l.Rdf.literal(t)),l.Rdf.triple(l.Rdf.iri(""),p.text,void 0!==r?l.Rdf.literal(r):l.Rdf.literal(""))];return e.structure&&s.push(l.Rdf.triple(l.Rdf.iri(""),l.vocabularies.VocabPlatform.searchState,l.Rdf.literal(e.structure))),l.Rdf.graph(s)}getType(e,t){if("update"===e)return p.Update;switch(t){case"ASK":return p.Ask;case"SELECT":default:return p.Select;case"DESCRIBE":return p.Describe;case"CONSTRUCT":return p.Construct}}getQuery(e){return this.get(e).map(t=>this.parseGraphToQuery(e,t))}parseGraphToQuery(e,t){const r=[p.Ask,p.Select,p.Describe,p.Construct,p.Update].map(e=>e.value),a=t.triples.find(t=>t.s.equals(e)&&t.p.equals(n.label)).o.value,o=t.triples.find(t=>t.s.equals(e)&&t.p.equals(p.text)).o.value,s=t.triples.find(t=>t.s.equals(e)&&t.p.equals(l.vocabularies.VocabPlatform.searchState)),c=t.triples.find(t=>t.s.equals(e)&&t.p.equals(u.type)&&(0,i.includes)(r,t.o.value)).o.value,d=this.extractTypeFromIri(c).toUpperCase();return{label:a,value:o,type:"UPDATE"===d?"update":"query",queryType:d,structure:s?s.o.value:void 0}}extractTypeFromIri(e){return/[^#]*$/.exec(e)[0]}}t.QueryServiceClass=c;t.QueryService=function(e){return new c(s.QueryContainer.value,e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.