@qaecy/cue-ui 0.0.43 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/719.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[719],{5448(D,h,a){a.d(h,{ButtonLabel:()=>C});var s=a(7705),c=a(2245),u=a(5547);const m=["*"];let C=(()=>{class r{fontSize=(0,s.hFB)("m");italic=(0,s.hFB)(!1);noWrap=(0,s.hFB)(!0);static \u0275fac=function(l){return new(l||r)};static \u0275cmp=u.VBU({type:r,selectors:[["cue-button-label"]],inputs:{fontSize:[1,"fontSize"],italic:[1,"italic"],noWrap:[1,"noWrap"]},ngContentSelectors:m,decls:3,vars:3,consts:[[3,"size","italic","noWrap"]],template:function(l,d){1&l&&(u.NAR(),u.j41(0,"div")(1,"cue-typography",0),u.SdG(2),u.k0s()()),2&l&&(u.R7$(),u.Y8G("size",d.fontSize())("italic",d.italic())("noWrap",d.noWrap()))},dependencies:[c.Typography],styles:["div[_ngcontent-%COMP%]{transform:translateY(.05em)}"]})}return r})()},7719(D,h,a){a.d(h,{CueDocumentCharts:()=>W});var s=a(7705),c=a(5802),u=a(2271),m=a(3615),C=a(7993),r=a(1519),f=a(9811),p=a(5381),l=a(2245),d=a(5971),b=a(9352),v=a(3319),y=a(5448),M=a(2014),E=a(7851),B=a(7293),t=a(5547);const x=i=>({suffix:i}),O=i=>({type:i});function w(i,_){if(1&i&&(t.j41(0,"cue-flexcontainer",1)(1,"cue-typography",3),t.EFF(2),t.k0s()()),2&i){const e=t.XpG();t.R7$(2),t.SpI(" ",e.errorMessage()," ")}}function P(i,_){if(1&i){const e=t.RV6();t.j41(0,"div",7)(1,"cue-block-documents-by-suffix",8),t.bIt("navigated",function(o){c.eBV(e);const g=t.XpG(2);return c.Njj(g.handleNavigated(o,"suffix"))}),t.k0s()()}if(2&i){const e=t.XpG(2);t.xc7("height",e.chartHeight(),"px"),t.R7$(),t.Y8G("data",_)("config",e.blockConfig())}}function L(i,_){if(1&i){const e=t.RV6();t.j41(0,"div",7)(1,"cue-block-documents-by-content-category",8),t.bIt("navigated",function(o){c.eBV(e);const g=t.XpG(2);return c.Njj(g.handleNavigated(o,"content-category"))}),t.k0s()()}if(2&i){const e=t.XpG(2);t.xc7("height",e.chartHeight(),"px"),t.R7$(),t.Y8G("data",_)("config",e.blockConfig())}}function S(i,_){if(1&i&&(t.EFF(0),t.nI1(1,"transloco")),2&i){const e=t.XpG(3);t.SpI(" ",t.i5U(1,1,"components.documentCharts.listDocumentsBySuffix",t.eq3(4,x,e._activeSelection().label))," ")}}function I(i,_){if(1&i&&(t.EFF(0),t.nI1(1,"transloco")),2&i){const e=t.XpG(3);t.SpI(" ",t.i5U(1,1,"components.documentCharts.listDocumentsByType",t.eq3(4,O,e._activeSelection().label))," ")}}function R(i,_){if(1&i){const e=t.RV6();t.j41(0,"cue-flexcontainer",6)(1,"cue-button",9),t.bIt("click",function(){c.eBV(e);const o=t.XpG(2);return c.Njj(o.onShowListButtonClick())}),t.nrm(2,"cue-button-padder")(3,"cue-button-icon",10),t.j41(4,"cue-button-label"),t.nVh(5,S,2,6)(6,I,2,6),t.k0s(),t.nrm(7,"cue-button-padder"),t.k0s()()}if(2&i){const e=t.XpG(2);t.R7$(5),t.vxM("suffix"===e._activeSelection().filterBy&&e._activeSelection().label.startsWith(".")?5:6)}}function j(i,_){if(1&i&&(t.j41(0,"cue-flexcontainer",4),t.nVh(1,P,2,4,"div",5),t.nVh(2,L,2,4,"div",5),t.k0s(),t.nVh(3,R,8,1,"cue-flexcontainer",6)),2&i){let e,n;const o=t.XpG();t.Y8G("direction",o.stackCharts()?"column":"row"),t.R7$(),t.vxM((e="content-category"!==o.mode()&&o.bySuffix())?1:-1,e),t.R7$(),t.vxM((n="suffix"!==o.mode()&&o.byContentCategory())?2:-1,n),t.R7$(),t.vxM(o.showDocumentListButton()&&o._activeSelection()?3:-1)}}function T(i,_){if(1&i&&t.nrm(0,"cue-logo-link",2),2&i){const e=t.XpG();t.Y8G("projectId",e.projectId())}}let W=(()=>{class i{_blockCtx=(0,c.WQX)(f.z);projectId=(0,s.hFB)(void 0);sdkState=(0,s.hFB)(void 0);mode=(0,s.hFB)("both");stackCharts=(0,s.hFB)(!1);chartHeight=(0,s.hFB)(400);selected=(0,s.CGW)();selectionCleared=(0,s.CGW)();showDocumentListButton=(0,s.hFB)(!1,{transform:s.L39});showLogo=(0,s.hFB)(!1,{transform:s.L39});showInDocumentList=(0,s.CGW)();state=(0,c.vPA)("idle");errorMessage=(0,c.vPA)(null);_activeSelection=(0,c.vPA)(null);_rawData=(0,c.vPA)(void 0);bySuffix=(0,u.EW)(()=>{const e=this._rawData();if(e?.documentsBySuffix&&0!==Object.keys(e.documentsBySuffix).length)return{documents:e.documentsBySuffix}});byContentCategory=(0,u.EW)(()=>{const e=this._rawData();if(e?.documentsByContentCategory&&0!==Object.keys(e.documentsByContentCategory).length)return{documents:e.documentsByContentCategory}});blockConfig=(0,u.EW)(()=>({projectId:this.projectId()??"",portalBaseURL:"",resourceBaseURL:"",graphIsSaturated:!1,privileges:new r.c,handlers:new r.$}));_ownedView;_unsubscribeCategories;_unsubscribeDocumentsData;_lastSetupSignature;constructor(){(0,c.QZP)(()=>{const e=this.projectId(),n=this.sdkState();if(!n)return this._clearRuntimeState(),void this.state.set("idle");const o={projectId:e,cue:n.cue,view:n.view,documents:n.documents,language:n.language};this._isSameSetupSignature(o)||(this._setupFromSdkState(e,n),this._lastSetupSignature=o)})}ngOnDestroy(){this._cleanupSubscriptions(),this._cleanupOwnedView()}handleNavigated(e,n){if(!e)return this._activeSelection.set(null),void this.selectionCleared.emit({chart:n});const o={filterBy:"suffix"===e.filterBy?"suffix":"content-category",values:e.values.filter(g=>"__grouped_small__"!==g),label:e.label};this._activeSelection.set(o),this.selected.emit(o)}onShowListButtonClick(){const e=this._activeSelection();e&&this.showInDocumentList.emit(e)}_setupFromSdkState(e,n){if(this._cleanupSubscriptions(),this._cleanupOwnedView(),this._rawData.set(void 0),n.availableContentCategories&&this._blockCtx.availableContentCategories.set(n.availableContentCategories),n.documents)return n.documents.setLanguage(n.language??"en"),void this._bindDocumentsData(n.documents);if(n.view)return n.view.setLanguage(n.language??"en"),this._bindDocumentsData(n.view.documents),void(n.availableContentCategories||this._bindCategoriesFromView(n.view));if(n.cue&&e){const o=n.cue.createProjectView(e,{language:n.language??"en"});return this._ownedView=o,this._bindDocumentsData(o.documents),void(n.availableContentCategories||this._bindCategoriesFromView(o))}this.errorMessage.set("sdkState must include cue, view, or documents to load data."),this.state.set("error")}_bindDocumentsData(e){this.state.set("loading");const n=()=>{const o=e.projectDocumentsData.get();o&&Object.keys(o.documentsBySuffix).length>0&&(0,u.O8)(()=>{this._rawData.set(o),this.state.set("ready")})};n(),this._unsubscribeDocumentsData=e.projectDocumentsData.subscribe(()=>n())}_bindCategoriesFromView(e){const n=()=>{this._blockCtx.availableContentCategories.set(e.availableContentCategories.get())};n(),this._unsubscribeCategories=e.availableContentCategories.subscribe(n)}_clearRuntimeState(){this._cleanupSubscriptions(),this._cleanupOwnedView(),this._rawData.set(void 0),this._blockCtx.availableContentCategories.set(void 0),this.errorMessage.set(null),this._lastSetupSignature=void 0}_cleanupSubscriptions(){this._unsubscribeCategories?.(),this._unsubscribeCategories=void 0,this._unsubscribeDocumentsData?.(),this._unsubscribeDocumentsData=void 0}_cleanupOwnedView(){this._ownedView&&(this._ownedView.destroy(),this._ownedView=void 0)}_isSameSetupSignature(e){const n=this._lastSetupSignature;return!!n&&n.projectId===e.projectId&&n.cue===e.cue&&n.view===e.view&&n.documents===e.documents&&n.language===e.language}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=t.VBU({type:i,selectors:[["cue-document-charts"]],inputs:{projectId:[1,"projectId"],sdkState:[1,"sdkState"],mode:[1,"mode"],stackCharts:[1,"stackCharts"],chartHeight:[1,"chartHeight"],showDocumentListButton:[1,"showDocumentListButton"],showLogo:[1,"showLogo"]},outputs:{selected:"selected",selectionCleared:"selectionCleared",showInDocumentList:"showInDocumentList"},features:[t.Jv_([f.z])],decls:4,vars:5,consts:[[3,"cueLogoLoader"],["direction","column","align","center","justify","center",2,"height","100%","width","100%","padding","8px"],[2,"position","absolute","bottom","8px","right","8px","z-index","5",3,"projectId"],[2,"color","#c44","font-size","13px"],["align","stretch",2,"width","100%",3,"direction"],[1,"chart-wrapper",3,"height"],["justify","center"],[1,"chart-wrapper"],[3,"navigated","data","config"],["size","s","variant","secondary",3,"click"],["icon","filter"]],template:function(n,o){1&n&&(t.j41(0,"div",0),t.nVh(1,w,3,1,"cue-flexcontainer",1)(2,j,4,4),t.nVh(3,T,1,1,"cue-logo-link",2),t.k0s()),2&n&&(t.xc7("min-height",o.chartHeight(),"px"),t.Y8G("cueLogoLoader","loading"===o.state()),t.R7$(),t.vxM("error"===o.state()?1:"ready"===o.state()?2:-1),t.R7$(2),t.vxM(o.showLogo()?3:-1))},dependencies:[m.Y,C.o,p.n,l.Typography,d.Button,y.ButtonLabel,M.ButtonPadder,v.ButtonIcon,E.k,B.x,b.Kj],styles:["[_nghost-%COMP%]{display:block;width:100%}.chart-wrapper[_ngcontent-%COMP%]{flex:1;min-width:0;position:relative}cue-block-documents-by-suffix[_ngcontent-%COMP%], cue-block-documents-by-content-category[_ngcontent-%COMP%]{display:block;width:100%;height:100%}"],changeDetection:0})}return i})()}}]);
package/724.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[724],{2724(Zt,ge,h){h.d(ge,{CueSparqlTable:()=>Jt});var m=h(7705),s=h(5802),_=h(2271),Z=h(5281),C=h(467),he=h(7374),q=h.n(he),P=h(7400);function j(l,u,t=""){const a=u.valueKey??"val",n=u.priorityKey,o=u.fallback??t,i=u.preProcess?l.map(p=>{const c=p[a];return null==c?p:{...p,[a]:(0,P.w9)(u.preProcess,c)}}):l,r=(n?[...i].sort((p,c)=>{const f=p[n],g=c[n],y=Number(f),T=Number(g);return isNaN(y)||isNaN(T)?(g??"").localeCompare(f??""):T-y}):i).map(p=>p[a]).filter(p=>null!=p);if(0===r.length)return o;switch(u.type){case"first":default:return r[0];case"last":return r[r.length-1];case"random":return r[Math.floor(Math.random()*r.length)];case"count":return String(r.length);case"join":return r.join(u.separator??", ");case"longest":return r.reduce((p,c)=>c.length>p.length?c:p);case"shortest":return r.reduce((p,c)=>c.length<p.length?c:p);case"sum":{const p=r.map(Number).filter(c=>!isNaN(c));return p.length?String(p.reduce((c,f)=>c+f,0)):t}case"avg":{const p=r.map(Number).filter(c=>!isNaN(c));return p.length?String(p.reduce((c,f)=>c+f,0)/p.length):t}case"min":{const p=r.map(Number).filter(c=>!isNaN(c));return p.length?String(Math.min(...p)):t}case"max":{const p=r.map(Number).filter(c=>!isNaN(c));return p.length?String(Math.max(...p)):t}case"mostRecent":return[...r].sort((c,f)=>q()(f).valueOf()-q()(c).valueOf())[0];case"oldest":return[...r].sort((c,f)=>q()(c).valueOf()-q()(f).valueOf())[0];case"map":{const{map:p}=u;return p[r[0]]??o}}}const ee=Object.keys({first:"First",last:"Last",random:"Random",join:"Concatenate",count:"Count",longest:"Longest text",shortest:"Shortest text",map:"Map lookup",sum:"Sum",avg:"Average",min:"Minimum",max:"Maximum",mostRecent:"Most recent date",oldest:"Oldest date"}),Q=["first","last","random","join","count"],te={text:[...Q,"longest","shortest","map"],number:[...Q,"sum","avg","min","max"],date:[...Q,"mostRecent","oldest"]},ye={first:"components.sparqlTable.strategyFirst",last:"components.sparqlTable.strategyLast",random:"components.sparqlTable.strategyRandom",join:"components.sparqlTable.strategyJoin",count:"components.sparqlTable.strategyCount",longest:"components.sparqlTable.strategyLongest",shortest:"components.sparqlTable.strategyShortest",map:"components.sparqlTable.strategyMap",sum:"components.sparqlTable.strategySum",avg:"components.sparqlTable.strategyAvg",min:"components.sparqlTable.strategyMin",max:"components.sparqlTable.strategyMax",mostRecent:"components.sparqlTable.strategyMostRecent",oldest:"components.sparqlTable.strategyOldest"},be={first:"components.sparqlTable.strategyFirstDesc",last:"components.sparqlTable.strategyLastDesc",random:"components.sparqlTable.strategyRandomDesc",join:"components.sparqlTable.strategyJoinDesc",count:"components.sparqlTable.strategyCountDesc",longest:"components.sparqlTable.strategyLongestDesc",shortest:"components.sparqlTable.strategyShortestDesc",map:"components.sparqlTable.strategyMapDesc",sum:"components.sparqlTable.strategySumDesc",avg:"components.sparqlTable.strategyAvgDesc",min:"components.sparqlTable.strategyMinDesc",max:"components.sparqlTable.strategyMaxDesc",mostRecent:"components.sparqlTable.strategyMostRecentDesc",oldest:"components.sparqlTable.strategyOldestDesc"};var O=h(7573);const $=`PREFIX qcy: <${O.E.qcy}>\nPREFIX qcy-e: <${O.E["qcy-e"]}>\n\nSELECT ?subject\nWHERE {\n ?subject a qcy:CanonicalEntity ;\n qcy:hasEntityCategory qcy-e:Person .\n}`;class ne{field;headerName;sortable;filter;editable;hide;minWidth;cellStyle;headerClass;query="";defType="data";calculatedFrom;evaluation;datatype;postProcess;strategy;valueKey;labelKey;formatter=void 0;constructor(u="",t=""){this.field=u,this.headerName=t}getFormatter=()=>{if(this.formatter)return this.formatter;if(this.strategy){const u=this.strategy;return t=>j(t,u,"")}return u=>Array.isArray(u)?u.map(t=>t?.val??"").filter(Boolean).join(", "):String(u??"")}}var De=h(4284);class Te{menuDisplaySettings=new Ce;columnSelectSettings=new Se}class Ce{hide=!0;buttonVariant="tertiary";buttonSize="s";showColumnSelect=!0;showDownload=!0}class Se{allowEditing=!0;allowToggleEditable=!0;allowToggleHideOnHover=!0;allowSettingTextAlign=!0;allowSettingLabel=!0}var Me=h(222),w=h(6593);function E(l){const u=new w.Parser({sparqlStar:!0});try{return u.parse(l)}catch(t){if(-1!=t.toString().indexOf("SPARQL*"))return{type:"query",queryType:"CONSTRUCT",sparqlStar:!0};throw"Couldn't get query details: "+t.toString()}}class xe{queryHandler=(0,C.A)(function*(){throw new Error("No query handler defined")})}var oe=h(7089),e=h(5547);function Ee(l,u){if(1&l&&(e.j41(0,"span",1),e.EFF(1),e.k0s()),2&l){const t=e.XpG();e.Y8G("cueTooltip",t._tooltip()),e.R7$(),e.SpI("\xd7",t._allValues().length)}}let Fe=(()=>{class l{_displayValue=(0,s.vPA)("");_allValues=(0,s.vPA)([]);_tooltip=(0,s.vPA)("");agInit(t){this._apply(t)}refresh(t){return this._apply(t),!0}_apply(t){const a=t.value,n=Array.isArray(a)?a:null!=a?[a]:[],o=t.colDef?.cellRendererParams?.strategy,i=t.colDef?.cellRendererParams?.valueKey??"val",r=t.colDef?.cellRendererParams?.labelKey??i,p=n.map(f=>f[r]).filter(Boolean);this._allValues.set(p);const c=t.colDef?.cellRendererParams?.postProcess;this._displayValue.set((0,P.g4)(o?j(n,o):p[0]??"",c)),this._tooltip.set(p.map(f=>(0,P.g4)(f,c)).join("\n"))}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-multi-binding-cell-renderer"]],decls:3,vars:2,consts:[[1,"cell-value"],["cueTooltipPosition","bottomleft",1,"badge",3,"cueTooltip"]],template:function(a,n){1&a&&(e.j41(0,"span",0),e.EFF(1),e.k0s(),e.nVh(2,Ee,2,2,"span",1)),2&a&&(e.R7$(),e.JRh(n._displayValue()),e.R7$(),e.vxM(n._allValues().length>1?2:-1))},dependencies:[oe.d],styles:["[_nghost-%COMP%]{display:flex;align-items:center;gap:4px;overflow:hidden;width:100%}.cell-value[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}.badge[_ngcontent-%COMP%]{flex-shrink:0;font-size:10px;font-weight:600;background:var(--cue-color-blue, #2563eb);color:#fff;border-radius:8px;padding:0 5px;line-height:16px;cursor:default}"],changeDetection:0})}return l})();const le=["template","formula","pipeline"],ie=["add","subtract","multiply","divide"],je={template:"components.sparqlTable.evalTypeTemplate",formula:"components.sparqlTable.evalTypeFormula",pipeline:"components.sparqlTable.evalTypePipeline"},Ae={template:"components.sparqlTable.evalTypeTemplateDesc",formula:"components.sparqlTable.evalTypeFormulaDesc",pipeline:"components.sparqlTable.evalTypePipelineDesc"},Ne={add:"components.sparqlTable.formulaOpAdd",subtract:"components.sparqlTable.formulaOpSubtract",multiply:"components.sparqlTable.formulaOpMultiply",divide:"components.sparqlTable.formulaOpDivide"};let I=(()=>{class l{_requestedColumns=[];_columnQueries={};emptyTableText=(0,s.vPA)("Building table");_columns=(0,s.vPA)([]);_columnsGross=(0,s.vPA)(void 0);_dataColumns=(0,s.vPA)(void 0);columnDefsGross=(0,_.EW)(()=>void 0===this._columnsGross()?this._columns():this._columnsGross());keyVals={};_handlers=(0,s.vPA)(new xe);destroy(){this.keyVals={},this._requestedColumns=[],this._columnQueries={},this.fetchedColumns.update(()=>[])}resetData(){this.keyVals={},this._requestedColumns=[],this._columnQueries={},this.fetchedColumns.update(()=>[])}mergeColumnData(t,a,n){Object.entries(a).forEach(([o,i])=>{this.keyVals[o]||(this.keyVals[o]={}),void 0===this.keyVals[o][t]&&(this.keyVals[o][t]=i)}),this._requestedColumns.includes(t)||this._requestedColumns.push(t),this._columnQueries[t]=n,this.fetchedColumns.update(o=>[...o,t])}injectPreloadedData(t,a,n){this.keyVals=t,this._requestedColumns=[...a],this._columnQueries={...n},this.fetchedColumns.update(()=>[...a])}fetchedColumns=(0,s.vPA)([],{equal:(t,a)=>t.length===a.length});isLoading=(0,_.EW)(()=>this._columns().length>0&&this.fetchedColumns().length<this.totalQueryCount());totalQueryCount=(0,_.EW)(()=>{const t=new Set;for(const a of this._columns())"data"===a.defType&&!a.hide&&a.query&&t.add(a.field);return t.size});columnDefsAG=(0,_.EW)(()=>{const t=[];return this._columns().forEach(a=>{const n=a.getFormatter();if("calculated"===a.defType){const o=this._columns().filter(r=>"data"===r.defType).map(r=>r.field);if(Array.from(new Set(o)).every(r=>this.fetchedColumns().includes(r))){const r=a.formatter??n;t.push({colId:a.field,headerName:a.headerName,sortable:!0,filter:!0,...a.minWidth?{minWidth:a.minWidth}:{},valueGetter:p=>r(null,p.data)})}}else if("evaluation"===a.defType){const o=this._columns().filter(r=>"data"===r.defType).map(r=>r.field);if(Array.from(new Set(o)).every(r=>this.fetchedColumns().includes(r))&&a.evaluation){const r=a.evaluation,p=this._columns();t.push({colId:a.field,headerName:a.headerName,hide:a.hide,flex:1,sortable:!0,filter:!0,valueGetter:c=>{const f=c.data??{},g={};for(const y of p)if("data"===y.defType){const T=y.getFormatter();g[y.field]=(0,P.g4)(T(f[y.field]??[]),y.postProcess)}return function we(l,u,t="",a){switch(l.type){case"template":return l.template.replace(/\$\{([\w.-]+)\}/g,(n,o)=>u[o]??"").trim();case"formula":{const n=l.fields.map(o=>parseFloat(u[o])).filter(o=>!isNaN(o));if(0===n.length)return t;switch(l.op){case"add":return String(n.reduce((o,i)=>o+i,0));case"subtract":return String(n.reduce((o,i)=>o-i));case"multiply":return String(n.reduce((o,i)=>o*i,1));case"divide":return n.length<2||0===n[1]?t:String(n[0]/n[1])}return t}case"pipeline":{const{sources:n,transform:o,exclude:i,deduplicate:d,sort:r,limit:p,valueKey:c="val"}=l,f=l.separator??", ",g=l.fallback??t,y=new Set,T=[];for(const M of n){let D=(a?.[M]??[]).map(v=>v[c]??"").filter(v=>""!==v);o&&(D=D.map(v=>(0,P.w9)(o,v))),i?.length&&(D=D.filter(v=>!i.includes(v)));for(const v of D)d&&y.has(v)||(y.add(v),T.push(v))}r&&T.sort();const b=void 0!==p?T.slice(0,p):T;return 0===b.length?g:b.join(f)}}}(r,g,"",f)}})}}else{const o=!!a.strategy;t.push({field:a.field,headerName:a.headerName,hide:a.hide,flex:1,sortable:!0,filter:!0,...a.minWidth?{minWidth:a.minWidth}:{},...a.cellStyle?{cellStyle:a.cellStyle}:{},...a.headerClass?{headerClass:a.headerClass}:{},valueGetter:o?i=>i.data?.[a.field]??[]:i=>(0,P.g4)(n(i.data?.[a.field]??[]),a.postProcess),...o?{comparator:(i,d)=>{const r=Array.isArray(i)?i:[],p=Array.isArray(d)?d:[],c=(0,P.g4)(j(r,a.strategy,""),a.postProcess),f=(0,P.g4)(j(p,a.strategy,""),a.postProcess);return c.localeCompare(f)},cellRenderer:Fe,cellRendererParams:{strategy:a.strategy,valueKey:a.valueKey??"val",labelKey:a.labelKey,postProcess:a.postProcess}}:{}})}}),t});set columns(t){t.forEach(a=>{a.field&&void 0!==this._columnQueries[a.field]&&this._columnQueries[a.field]!==a.query&&(this._requestedColumns=this._requestedColumns.filter(n=>n!==a.field),Object.values(this.keyVals).forEach(n=>delete n[a.field]),this.fetchedColumns.update(n=>n.filter(o=>o!==a.field))),this._columnQueries[a.field]=a.query}),this._columns.set(t),this.buildTable()}set columnsGross(t){this._columnsGross.set(t)}set dataColumns(t){this._dataColumns.set(t)}set handlers(t){this._handlers.set(t)}get visibleColumns(){return this._columns}buildTable(){var t=this;return(0,C.A)(function*(){const a=t._columns(),n=t._dataColumns(),o=a.filter(r=>"data"===r.defType&&!r.hide),i=n?.filter(r=>"data"===r.defType&&!r.hide);if(!o.length&&!i?.length)return void((a.length>0||(n?.length??0)>0)&&t.emptyTableText.set("No data columns defined"));t.emptyTableText.set("Building table...");const d=[];o.forEach(r=>{d.push(t.fetchColumnData(r))}),i?.forEach(r=>{d.push(t.fetchColumnData(r))}),yield Promise.all(d),t.emptyTableText.set("Table data downloaded")})()}fetchColumnData(t){var a=this;return(0,C.A)(function*(){if(a._requestedColumns.includes(t.field))return;a._requestedColumns.push(t.field);const n=E(t.query),o=yield a._handlers().queryHandler(t.query,n),i=new Set;o.results.bindings.forEach(d=>{const r=d.subject?.value,p=Object.keys(d).filter(f=>"subject"!==f),c={};p.forEach(f=>{const g=d[f]?.value;Object.keys(a.keyVals).includes(r)||(a.keyVals[r]={}),void 0===a.keyVals[r][t.field]&&(a.keyVals[r][t.field]=[]),c[f]=g}),a.keyVals[r][t.field].push(c),i.add(r)}),a.fetchedColumns.update(d=>[...d,t.field])})()}static \u0275fac=function(a){return new(a||l)};static \u0275prov=s.jDH({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})(),B=(()=>{class l{_isUpdating=!1;_pendingUpdate=!1;_dataFetchService=(0,s.WQX)(I);tableData=(0,s.vPA)([]);destroy(){this.tableData.update(()=>[])}onProcessedColumn=(0,s.QZP)((()=>{var t=this;return(0,C.A)(function*(){t._dataFetchService.fetchedColumns(),yield t._debouncedUpdateTableData()})})());_debouncedUpdateTableData(){var t=this;return(0,C.A)(function*(){t._isUpdating?t._pendingUpdate=!0:(t._isUpdating=!0,yield t._updateTableData(),t._isUpdating=!1,t._pendingUpdate&&(t._pendingUpdate=!1,yield t._debouncedUpdateTableData()))})()}_updateTableData(){var t=this;return(0,C.A)(function*(){return new Promise(a=>{const n={},o=Object.keys(t._dataFetchService.keyVals),i=[],d=t._dataFetchService.visibleColumns().map(p=>p.field);let r=!1;for(let p=0;p<o.length;p++){const c=o[p],f={};if(f.id=c,Object.keys(t._dataFetchService.keyVals[c]).forEach(g=>{Object.keys(n).includes(g)||(n[g]=0),f[g]=t._dataFetchService.keyVals[c][g]??[],""!==f[g]&&n[g]++}),i.push(f),!r&&9===p){let g=!0;for(const y of d)if(typeof f[y]>"u"){g=!1;break}g&&(t.tableData.update(()=>[...i]),r=!0)}}t.tableData.update(()=>i),a()})})()}static \u0275fac=function(a){return new(a||l)};static \u0275prov=s.jDH({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var A=h(2245),N=h(5381),ke=h(2611);function qe(l,u){if(1&l&&e.nrm(0,"cue-typography",1),2&l){const t=e.XpG();e.Y8G("innerHTML",t.instructions(),e.npT)}}let Ie=(()=>{class l{tableService=(0,s.WQX)(B);dataFetchService=(0,s.WQX)(I);handlers=m.hFB.required();columns=(0,m.geq)([]);columnsGross=(0,m.hFB)();dataColumns=(0,m.hFB)();showInstructions=(0,m.hFB)(!1);showPaginator=(0,m.hFB)(!0);paginationPageSize=(0,m.hFB)(10);settings=(0,m.hFB)(new Te);emptyTableText=(0,m.geq)("Building table");loading=(0,m.hFB)(!1);clickableRows=(0,m.hFB)(!1);useAGGrid=(0,m.hFB)(!1);size=(0,m.hFB)("m");clickedRow=(0,m.CGW)();hoveredRow=(0,m.CGW)();tableDataUpdated=(0,m.CGW)();gridApi=(0,m.CGW)();visibleRows=(0,m.CGW)();columnDefsAG=(0,m.CGW)();onAGColumnDefs=(0,s.QZP)(()=>{const t=this.dataFetchService.columnDefsAG();this.columnDefsAG.emit(t)});onTableDataChange=(0,s.QZP)(()=>{this.tableDataUpdated.emit(this.tableService.tableData())});onHandlersChange=(0,s.QZP)(()=>{this.dataFetchService.handlers=this.handlers()});onColumnsChange=(0,s.QZP)(()=>{this.dataFetchService.columns=this.columns()});onColumnsGrossChange=(0,s.QZP)(()=>{this.dataFetchService.columnsGross=this.columnsGross()});onDataColumnsChange=(0,s.QZP)(()=>{this.dataFetchService.dataColumns=this.dataColumns()});onEmptyTableTextChange=(0,s.QZP)(()=>{this.emptyTableText.set(this.emptyTableText())});_onGridApiReady(t){this.gridApi.emit(t),t.addEventListener("columnVisible",a=>{a.visible&&(a.columns??(a.column?[a.column]:[])).forEach(o=>{const i=o.getColId(),d=this.columns().find(r=>r.field===i);d&&this.dataFetchService.fetchColumnData(d)})})}instructions=(0,s.vPA)("");buildInstructions=(0,s.QZP)((()=>{var t=this;return(0,C.A)(function*(){if(t.showInstructions()){const a=yield(0,Me.xI)('The component takes an array of SPARQL table columns. It is an extension of the regular table that adds a query to the column definition and restricts the formatter to always start with an array of values that should be converted to a string value (per default by comma joining).\n\nThere are some requirements for the SPARQL query:\n\n- Must be a SELECT query \n- Must use variable `?subject` to bind to the row identifier\n- No grouping needed since the component automatically groups by key and returns the remaining bindings as an array\n\nExample query:\n\n```sparql\nSELECT ?subject ?val \nWHERE { \n ?subject qcy:entityCategory qcy-e:Space ;\n qcy:hasProperty [\n qcy:label "LongName" ;\n qcy:value ?val\n ]\n}\n```\n\nThis query will outputs for the formatter in the following form (in this case with two bindings to the key/val):\n\n```json\n[{"val": "Room 101"}, {"val": "Room 01"}]\n```\n\nThese can then be used in a simple formatter that simply returns the first value or a - in case there are no bindings:\n\n```typescript\n(row) => row[0]?.val ?? \'-\'\n```\n\nLet\'s imagine that we instead had a query that would return bindings on the variables *?val* and *?score* and return bindings like this:\n\n```json\n[{"val": "Room 101", "score": "1"}, {"val": "Room 01", "score": "0.9"}]\n```\n\nA formatter could then take the highest score value:\n\n```typescript\n(row) => {\n const maxScore = 0;\n let val = "";\n row.forEach(r => {\n if(parseFloat(r.score) > maxScore) {\n maxScore = parseFloat(r.score);\n val = r.val;\n }\n });\n return val;\n}\n```\n\nThe formatter can also be more advanced and for example first format the values as dates using a library like DayJS before taking the most recent.\n');t.instructions.set(a)}})})());ngOnDestroy(){this.tableService.destroy(),this.dataFetchService.destroy()}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-sparql-table-inner"]],inputs:{handlers:[1,"handlers"],columns:[1,"columns"],columnsGross:[1,"columnsGross"],dataColumns:[1,"dataColumns"],showInstructions:[1,"showInstructions"],showPaginator:[1,"showPaginator"],paginationPageSize:[1,"paginationPageSize"],settings:[1,"settings"],emptyTableText:[1,"emptyTableText"],loading:[1,"loading"],clickableRows:[1,"clickableRows"],useAGGrid:[1,"useAGGrid"],size:[1,"size"]},outputs:{columns:"columnsChange",emptyTableText:"emptyTableTextChange",clickedRow:"clickedRow",hoveredRow:"hoveredRow",tableDataUpdated:"tableDataUpdated",gridApi:"gridApi",visibleRows:"visibleRows",columnDefsAG:"columnDefsAG"},decls:3,vars:8,consts:[["direction","column","gap","xl"],[3,"innerHTML"],[3,"gridApiReady","visibleRows","size","rowData","columnDefs","showPaginator","paginationPageSize","noRowsText","loading"]],template:function(a,n){1&a&&(e.j41(0,"cue-flexcontainer",0),e.nVh(1,qe,1,1,"cue-typography",1),e.j41(2,"cue-ag-grid",2),e.bIt("gridApiReady",function(i){return n._onGridApiReady(i)})("visibleRows",function(i){return n.visibleRows.emit(i)}),e.k0s()()),2&a&&(e.R7$(),e.vxM(n.showInstructions()?1:-1),e.R7$(),e.Y8G("size",n.size())("rowData",n.tableService.tableData())("columnDefs",n.dataFetchService.columnDefsAG())("showPaginator",n.showPaginator())("paginationPageSize",n.paginationPageSize())("noRowsText",n.dataFetchService.emptyTableText())("loading",n.loading()||n.dataFetchService.isLoading()))},dependencies:[A.Typography,N.n,ke.R],encapsulation:2,changeDetection:0})}return l})();var Le=h(9079),L=h(9352),se=h(2444),re=h(8957),X=h(5971),ce=h(3319),ue=h(836),z=h(1096),de=h(5448),Ge=h(2014);const K=(l,u)=>u.field;function Qe(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(2);e.R7$(),e.SpI(" ",t._queryError()," ")}}function Oe(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-button",17),e.bIt("click",function(){s.eBV(t);const n=e.XpG(2);return s.Njj(n.discardQuery())}),e.nrm(1,"cue-button-padder"),e.j41(2,"cue-button-label"),e.EFF(3),e.nI1(4,"transloco"),e.k0s(),e.nrm(5,"cue-button-padder"),e.k0s()}2&l&&(e.R7$(3),e.JRh(e.bMT(4,1,"components.sparqlTable.labelDiscard")))}function $e(l,u){1&l&&(e.j41(0,"cue-typography",11),e.EFF(1),e.nI1(2,"transloco"),e.k0s()),2&l&&(e.R7$(),e.SpI(" ",e.bMT(2,1,"components.sparqlTable.labelQueryPending")," "))}function Be(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(2);e.R7$(),e.SpI(" ",t._testError()," ")}}function Xe(l,u){if(1&l&&(e.j41(0,"cue-typography",19),e.EFF(1),e.k0s()),2&l){const t=u.$implicit;e.R7$(),e.JRh(t)}}function ze(l,u){if(1&l&&(e.j41(0,"cue-typography",18),e.EFF(1),e.nI1(2,"transloco"),e.k0s(),e.Z7z(3,Xe,2,1,"cue-typography",19,e.Vm6)),2&l){const t=e.XpG(2);e.R7$(),e.JRh(e.bMT(2,1,"components.sparqlTable.labelTestResults")),e.R7$(2),e.Dyx(t._testRows())}}function Ke(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-input",20),e.nI1(1,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return s.Njj(o._strategySeparator.set(n))}),e.k0s()}if(2&l){const t=e.XpG(2);e.Y8G("label",e.bMT(1,2,"components.sparqlTable.labelSeparator"))("value",t._strategySeparator())}}function Ye(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-input",20),e.nI1(1,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return s.Njj(o._strategyValueKey.set(n))}),e.k0s()}if(2&l){const t=e.XpG(2);e.Y8G("label",e.bMT(1,2,"components.sparqlTable.labelValueKey"))("value",t._strategyValueKey())}}function We(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-input",16),e.nI1(1,"transloco"),e.nI1(2,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._strategyPriorityKey.set(n),s.Njj(o._applyStrategyChange())}),e.k0s()}if(2&l){const t=e.XpG(2);e.Y8G("label",e.bMT(1,3,"components.sparqlTable.labelPriorityKey"))("info",e.bMT(2,5,"components.sparqlTable.tooltipPriorityKey"))("value",t._strategyPriorityKey())}}function He(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.SpI(" ",t._strategyMapError()," ")}}function Ue(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-typography",3),e.nI1(1,"transloco"),e.EFF(2),e.nI1(3,"transloco"),e.k0s(),e.j41(4,"div",21)(5,"cue-code-editor",22),e.bIt("contentChanged",function(n){s.eBV(t);const o=e.XpG(2);return s.Njj(o._onMapJsonChanged(n))}),e.k0s()(),e.nVh(6,He,2,1,"cue-typography",6)}if(2&l){const t=e.XpG(2);e.Y8G("info",e.bMT(1,4,"components.sparqlTable.tooltipMapJson")),e.R7$(2),e.SpI(" ",e.bMT(3,6,"components.sparqlTable.labelMapJson")," "),e.R7$(3),e.Y8G("content",t._strategyMapJson()),e.R7$(),e.vxM(t._strategyMapError()?6:-1)}}function Je(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(2);e.R7$(),e.SpI(" ",t._strategyPreProcessError()," ")}}function Ze(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-typography",3),e.nI1(1,"transloco"),e.EFF(2),e.nI1(3,"transloco"),e.k0s(),e.j41(4,"div",4)(5,"cue-code-editor",5),e.bIt("contentChanged",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.onQueryChanged(n))}),e.k0s()(),e.nVh(6,Qe,2,1,"cue-typography",6),e.j41(7,"cue-flexcontainer",7),e.nVh(8,Oe,6,3,"cue-button",8),e.j41(9,"cue-button",9),e.bIt("click",function(){s.eBV(t);const n=e.XpG();return s.Njj(n.testQuery())}),e.nrm(10,"cue-button-padder")(11,"cue-button-icon",10),e.j41(12,"cue-button-label"),e.EFF(13),e.nI1(14,"transloco"),e.k0s(),e.nrm(15,"cue-button-padder"),e.k0s()(),e.nVh(16,$e,3,3,"cue-typography",11),e.nVh(17,Be,2,1,"cue-typography",6),e.nVh(18,ze,5,3),e.j41(19,"cue-select",2),e.nI1(20,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.setDatatype(n))}),e.k0s(),e.j41(21,"cue-select",12),e.nI1(22,"transloco"),e.nI1(23,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.setStrategyType(n))}),e.k0s(),e.j41(24,"cue-typography",13),e.EFF(25),e.k0s(),e.nVh(26,Ke,2,4,"cue-input",14),e.nVh(27,Ye,2,4,"cue-input",14),e.nVh(28,We,3,7,"cue-input",15),e.nVh(29,Ue,7,8),e.j41(30,"cue-input",16),e.nI1(31,"transloco"),e.nI1(32,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG();return o._strategyPreProcess.set(n),s.Njj(o._applyStrategyChange())}),e.k0s(),e.nVh(33,Je,2,1,"cue-typography",6),e.j41(34,"cue-input",16),e.nI1(35,"transloco"),e.nI1(36,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG();return o._strategyFallback.set(n),s.Njj(o._applyStrategyChange())}),e.k0s()}if(2&l){const t=e.XpG();e.Y8G("info",e.bMT(1,31,"components.sparqlTable.tooltipQuery")),e.R7$(2),e.JRh(e.bMT(3,33,"components.sparqlTable.labelQuery")),e.R7$(3),e.Y8G("content",t.query()),e.R7$(),e.vxM(t._queryError()?6:-1),e.R7$(2),e.vxM(t._queryDirty()?8:-1),e.R7$(),e.Y8G("disabled",!!t._queryError()),e.R7$(4),e.JRh(e.bMT(14,35,"components.sparqlTable.labelTest")),e.R7$(3),e.vxM(t._queryDirty()&&!t._queryError()?16:-1),e.R7$(),e.vxM(t._testError()?17:-1),e.R7$(),e.vxM(t._testRows().length>0?18:-1),e.R7$(),e.Y8G("label",e.bMT(20,37,"components.sparqlTable.labelDatatype"))("value",t._datatype()??"")("options",t.datatypeOptions)("labelMap",t.datatypeLabelMap()),e.R7$(2),e.Y8G("label",e.bMT(22,39,"components.sparqlTable.labelStrategy"))("info",e.bMT(23,41,"components.sparqlTable.tooltipStrategy"))("value",t._strategyType())("options",t.availableStrategyTypes())("labelMap",t.strategyLabelMap()),e.R7$(4),e.JRh(t._strategyDescription()),e.R7$(),e.vxM(t._strategyNeedsSeparator()?26:-1),e.R7$(),e.vxM(t._strategyNeedsValueKey()?27:-1),e.R7$(),e.vxM(t._strategyNeedsPriorityKey()?28:-1),e.R7$(),e.vxM(t._strategyNeedsMap()?29:-1),e.R7$(),e.Y8G("label",e.bMT(31,43,"components.sparqlTable.labelPreProcess"))("info",e.bMT(32,45,"components.sparqlTable.tooltipPreProcess"))("value",t._strategyPreProcess()),e.R7$(3),e.vxM(t._strategyPreProcessError()?33:-1),e.R7$(),e.Y8G("label",e.bMT(35,47,"components.sparqlTable.labelFallback"))("info",e.bMT(36,49,"components.sparqlTable.tooltipFallback"))("value",t._strategyFallback())}}function et(l,u){if(1&l){const t=e.RV6();e.j41(0,"span",26),e.bIt("click",function(){const n=s.eBV(t).$implicit,o=e.XpG(4);return s.Njj(o._insertFieldIntoTemplate(n.field))}),e.EFF(1),e.k0s()}if(2&l){const t=u.$implicit;e.Y8G("title",t.headerName),e.R7$(),e.JRh(t.token)}}function tt(l,u){if(1&l&&(e.j41(0,"cue-typography",13),e.EFF(1),e.nI1(2,"transloco"),e.k0s(),e.j41(3,"cue-flexcontainer",24),e.Z7z(4,et,2,2,"span",25,K),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.SpI(" ",e.bMT(2,1,"components.sparqlTable.labelAvailableFields")," "),e.R7$(3),e.Dyx(t._dataColumnFields())}}function nt(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-input",16),e.nI1(1,"transloco"),e.nI1(2,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._evalTemplate.set(n),s.Njj(o._applyEvaluation())}),e.k0s(),e.nVh(3,tt,6,3)}if(2&l){const t=e.XpG(2);e.Y8G("label",e.bMT(1,4,"components.sparqlTable.labelEvalTemplate"))("info",e.bMT(2,6,"components.sparqlTable.tooltipEvalTemplate"))("value",t._evalTemplate()),e.R7$(3),e.vxM(t._dataColumnFields().length?3:-1)}}function at(l,u){if(1&l){const t=e.RV6();e.j41(0,"span",26),e.bIt("click",function(){const n=s.eBV(t).$implicit,o=e.XpG(3);return s.Njj(o._toggleFormulaField(n.field))}),e.EFF(1),e.k0s()}if(2&l){const t=u.$implicit,a=e.XpG(3);e.AVh("field-chip--active",a._formulaFields().includes(t.field)),e.Y8G("title",t.field),e.R7$(),e.JRh(t.headerName)}}function ot(l,u){if(1&l&&(e.j41(0,"span",30),e.EFF(1),e.k0s()),2&l){const t=e.XpG(5);e.R7$(),e.JRh(t._formulaOpSymbol())}}function lt(l,u){if(1&l&&(e.j41(0,"span",29),e.EFF(1),e.k0s(),e.nVh(2,ot,2,1,"span",30)),2&l){const t=u.$implicit,a=u.$index,n=u.$count,o=e.XpG(4);e.R7$(),e.JRh(o._fieldLabel(t)),e.R7$(),e.vxM(a!==n-1?2:-1)}}function it(l,u){if(1&l&&(e.j41(0,"cue-flexcontainer",28),e.Z7z(1,lt,3,2,null,null,e.fX1),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.Dyx(t._formulaFields())}}function st(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-select",2),e.nI1(1,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return s.Njj(o.setFormulaOp(n))}),e.k0s(),e.j41(2,"cue-typography",13),e.EFF(3),e.nI1(4,"transloco"),e.k0s(),e.j41(5,"cue-flexcontainer",24),e.Z7z(6,at,2,4,"span",27,K),e.k0s(),e.nVh(8,it,3,0,"cue-flexcontainer",28)}if(2&l){const t=e.XpG(2);e.Y8G("label",e.bMT(1,6,"components.sparqlTable.labelFormulaOp"))("value",t._formulaOp())("options",t.formulaOpOptions)("labelMap",t.formulaOpLabelMap()),e.R7$(3),e.SpI(" ",e.bMT(4,8,"components.sparqlTable.labelFormulaFields")," "),e.R7$(3),e.Dyx(t._dataColumnFields()),e.R7$(2),e.vxM(t._formulaFields().length?8:-1)}}function rt(l,u){if(1&l&&(e.j41(0,"cue-typography",23),e.EFF(1),e.nI1(2,"transloco"),e.k0s()),2&l){const t=e.XpG(2);e.R7$(),e.Lme(" ",e.bMT(2,2,"components.sparqlTable.labelEvalPreview"),": ",t._evalPreview()," ")}}function ct(l,u){if(1&l){const t=e.RV6();e.j41(0,"span",26),e.bIt("click",function(){const n=s.eBV(t).$implicit,o=e.XpG(3);return s.Njj(o._togglePipelineSource(n.field))}),e.EFF(1),e.k0s()}if(2&l){const t=u.$implicit,a=e.XpG(3);e.AVh("field-chip--active",a._pipelineSources().includes(t.field)),e.Y8G("title",t.field),e.R7$(),e.JRh(t.headerName)}}function ut(l,u){if(1&l&&(e.j41(0,"cue-typography",11),e.EFF(1),e.nI1(2,"transloco"),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.Lme(" ",e.bMT(2,2,"components.sparqlTable.labelPipelineSourceOrder"),": ",t._pipelineSources().join(" \u2192 ")," ")}}function dt(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.JRh(t._pipelineTransformError())}}function pt(l,u){if(1&l&&(e.j41(0,"cue-typography",6),e.EFF(1),e.k0s()),2&l){const t=e.XpG(3);e.R7$(),e.JRh(t._pipelineExcludeError())}}function _t(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-typography",3),e.nI1(1,"transloco"),e.EFF(2),e.nI1(3,"transloco"),e.k0s(),e.j41(4,"cue-flexcontainer",24),e.Z7z(5,ct,2,4,"span",27,K),e.k0s(),e.nVh(7,ut,3,4,"cue-typography",11),e.j41(8,"cue-input",16),e.nI1(9,"transloco"),e.nI1(10,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._pipelineTransform.set(n),s.Njj(o._applyEvaluation())}),e.k0s(),e.nVh(11,dt,2,1,"cue-typography",6),e.j41(12,"cue-input",16),e.nI1(13,"transloco"),e.nI1(14,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._pipelineLimit.set(n),s.Njj(o._applyEvaluation())}),e.k0s(),e.j41(15,"cue-input",20),e.nI1(16,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._pipelineSeparator.set(n),s.Njj(o._applyEvaluation())}),e.k0s(),e.j41(17,"cue-input",16),e.nI1(18,"transloco"),e.nI1(19,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG(2);return o._pipelineFallback.set(n),s.Njj(o._applyEvaluation())}),e.k0s(),e.j41(20,"cue-flexcontainer",31)(21,"label",32)(22,"input",33),e.bIt("change",function(){s.eBV(t);const n=e.XpG(2);return n._pipelineDeduplicate.set(!n._pipelineDeduplicate()),s.Njj(n._applyEvaluation())}),e.k0s(),e.EFF(23),e.nI1(24,"transloco"),e.k0s(),e.j41(25,"label",32)(26,"input",33),e.bIt("change",function(){s.eBV(t);const n=e.XpG(2);return n._pipelineSort.set(!n._pipelineSort()),s.Njj(n._applyEvaluation())}),e.k0s(),e.EFF(27),e.nI1(28,"transloco"),e.k0s()(),e.j41(29,"cue-typography",3),e.nI1(30,"transloco"),e.EFF(31),e.nI1(32,"transloco"),e.k0s(),e.j41(33,"div",34)(34,"cue-code-editor",22),e.bIt("contentChanged",function(n){s.eBV(t);const o=e.XpG(2);return s.Njj(o._onPipelineExcludeChanged(n))}),e.k0s()(),e.nVh(35,pt,2,1,"cue-typography",6)}if(2&l){const t=e.XpG(2);e.Y8G("info",e.bMT(1,23,"components.sparqlTable.tooltipPipelineSources")),e.R7$(2),e.SpI(" ",e.bMT(3,25,"components.sparqlTable.labelPipelineSources")," "),e.R7$(3),e.Dyx(t._dataColumnFields()),e.R7$(2),e.vxM(t._pipelineSources().length>1?7:-1),e.R7$(),e.Y8G("label",e.bMT(9,27,"components.sparqlTable.labelPipelineTransform"))("info",e.bMT(10,29,"components.sparqlTable.tooltipPipelineTransform"))("value",t._pipelineTransform()),e.R7$(3),e.vxM(t._pipelineTransformError()?11:-1),e.R7$(),e.Y8G("label",e.bMT(13,31,"components.sparqlTable.labelPipelineLimit"))("info",e.bMT(14,33,"components.sparqlTable.tooltipPipelineLimit"))("value",t._pipelineLimit()),e.R7$(3),e.Y8G("label",e.bMT(16,35,"components.sparqlTable.labelSeparator"))("value",t._pipelineSeparator()),e.R7$(2),e.Y8G("label",e.bMT(18,37,"components.sparqlTable.labelFallback"))("info",e.bMT(19,39,"components.sparqlTable.tooltipFallback"))("value",t._pipelineFallback()),e.R7$(5),e.Y8G("checked",t._pipelineDeduplicate()),e.R7$(),e.SpI(" ",e.bMT(24,41,"components.sparqlTable.labelPipelineDeduplicate")," "),e.R7$(3),e.Y8G("checked",t._pipelineSort()),e.R7$(),e.SpI(" ",e.bMT(28,43,"components.sparqlTable.labelPipelineSort")," "),e.R7$(2),e.Y8G("info",e.bMT(30,45,"components.sparqlTable.tooltipPipelineExclude")),e.R7$(2),e.SpI(" ",e.bMT(32,47,"components.sparqlTable.labelPipelineExclude")," "),e.R7$(3),e.Y8G("content",t._pipelineExcludeJson()),e.R7$(),e.vxM(t._pipelineExcludeError()?35:-1)}}function ft(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-select",2),e.nI1(1,"transloco"),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.setEvalType(n))}),e.k0s(),e.j41(2,"cue-typography",13),e.EFF(3),e.k0s(),e.nVh(4,nt,4,8),e.nVh(5,st,9,10),e.nVh(6,rt,3,4,"cue-typography",23),e.nVh(7,_t,36,49)}if(2&l){const t=e.XpG();e.Y8G("label",e.bMT(1,9,"components.sparqlTable.labelEvalType"))("value",t._evalType())("options",t.evaluationTypeOptions)("labelMap",t.evaluationTypeLabelMap()),e.R7$(3),e.JRh(t._evalTypeDescription()),e.R7$(),e.vxM("template"===t._evalType()?4:-1),e.R7$(),e.vxM("formula"===t._evalType()?5:-1),e.R7$(),e.vxM(t._evalPreview()?6:-1),e.R7$(),e.vxM("pipeline"===t._evalType()?7:-1)}}const mt=["join"],pe=["sum","avg","min","max","mostRecent","oldest","longest","shortest"],_e=["first","last","sum","avg","min","max","mostRecent","oldest","longest","shortest"],gt=["map"],fe=["text","number","date"],ht=Object.assign(new z.e,{});let yt=(()=>{class l{columnDef=m.geq.required();handlers=(0,m.hFB)();columns=(0,m.hFB)([]);close=(0,m.CGW)();updateColumnDef=(0,m.CGW)();agGridSettings=ht;_transloco=(0,s.WQX)(L.JO);_lang=(0,Le.ot)(this._transloco.langChanges$,{initialValue:this._transloco.getActiveLang()});columnTypeOptions=["data","evaluation"];columnTypeLabelMap=(0,_.EW)(()=>(this._lang(),{data:this._transloco.translate("components.sparqlTable.columnTypeData"),evaluation:this._transloco.translate("components.sparqlTable.columnTypeEvaluation")}));_defType=(0,_.uu)(()=>"evaluation"===this.columnDef().defType?"evaluation":"data");setDefType(t){const a=t;if(this._defType.set(a),"evaluation"===a){const o=this.columnDef().evaluation??{type:"template",template:""};this.updateColumnDef.emit({defType:"evaluation",evaluation:o})}else this.updateColumnDef.emit({defType:"data"})}_evalType=(0,_.uu)(()=>this.columnDef().evaluation?.type??"template");_evalTemplate=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"template"===t?.type?t.template:""});_formulaOp=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"formula"===t?.type?t.op:"add"});_formulaFields=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"formula"===t?.type?[...t.fields]:[]});_pipelineSources=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type?[...t.sources]:[]});_pipelineTransform=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type?t.transform??"":""});_pipelineLimit=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type?String(t.limit??""):""});_pipelineSeparator=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type?t.separator??", ":", "});_pipelineFallback=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type?t.fallback??"":""});_pipelineDeduplicate=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type&&(t.deduplicate??!1)});_pipelineSort=(0,_.uu)(()=>{const t=this.columnDef().evaluation;return"pipeline"===t?.type&&(t.sort??!1)});_pipelineExcludeJson=(0,_.uu)(()=>{const t=this.columnDef().evaluation,a="pipeline"===t?.type?t.exclude??[]:[];try{return JSON.stringify(a,null,2)}catch{return"[]"}});_pipelineExcludeError=(0,s.vPA)("");_pipelineExcludeParsed=(0,s.vPA)([]);_pipelineTransformError=(0,_.EW)(()=>{const t=this._pipelineTransform();if(t)return(0,P.NF)(t)??void 0});evaluationTypeOptions=le;evaluationTypeLabelMap=(0,_.EW)(()=>(this._lang(),Object.fromEntries(le.map(t=>[t,this._transloco.translate(je[t])]))));_evalTypeDescription=(0,_.EW)(()=>(this._lang(),this._transloco.translate(Ae[this._evalType()])));formulaOpOptions=ie;formulaOpLabelMap=(0,_.EW)(()=>(this._lang(),Object.fromEntries(ie.map(t=>[t,this._transloco.translate(Ne[t])]))));_dataColumnFields=(0,_.EW)(()=>this.columns().filter(t=>"data"===t.defType&&t.field!==this.columnDef().field).map(t=>({field:t.field,headerName:t.headerName??t.field,token:"${"+t.field+"}"})));_evalPreview=(0,_.EW)(()=>{if("template"===this._evalType()){const t=this._evalTemplate();return t?t.replace(/\$\{([\w.-]+)\}/g,(a,n)=>`[${n}]`):""}if("formula"===this._evalType()){const t=this._formulaFields(),a=this._formulaOp();return 0===t.length?"":t.join(` ${{add:"+",subtract:"\u2212",multiply:"\xd7",divide:"\xf7"}[a]} `)}if("pipeline"===this._evalType()){const t=this._pipelineSources(),a=this._pipelineTransform(),n=this._pipelineLimit();if(0===t.length)return"";const o=[`sources: [${t.join(", ")}]`];return a&&o.push(`transform: ${a}`),this._pipelineDeduplicate()&&o.push("deduplicate"),this._pipelineSort()&&o.push("sort"),n&&o.push(`limit: ${n}`),o.join(" | ")}return""});setEvalType(t){if(t){if(this._evalType.set(t),"pipeline"===t&&0===this._pipelineSources().length){const a=this._dataColumnFields()[0];a&&this._pipelineSources.set([a.field])}this._applyEvaluation()}}setFormulaOp(t){t&&(this._formulaOp.set(t),this._applyEvaluation())}_toggleFormulaField(t){const a=this._formulaFields(),n=a.includes(t)?a.filter(o=>o!==t):[...a,t];this._formulaFields.set(n),this._applyEvaluation()}_fieldLabel(t){return this._dataColumnFields().find(a=>a.field===t)?.headerName??t}_formulaOpSymbol=(0,_.EW)(()=>({add:"+",subtract:"\u2212",multiply:"\xd7",divide:"\xf7"}[this._formulaOp()]));_insertFieldIntoTemplate(t){const a=this._evalTemplate();this._evalTemplate.set(a+`\${${t}}`),this._applyEvaluation()}_togglePipelineSource(t){const a=this._pipelineSources(),n=a.includes(t)?a.filter(o=>o!==t):[...a,t];this._pipelineSources.set(n),this._applyEvaluation()}_applyEvaluation(){let t;if("template"===this._evalType())t={type:"template",template:this._evalTemplate()};else if("pipeline"===this._evalType()){const a={type:"pipeline",sources:this._pipelineSources(),deduplicate:this._pipelineDeduplicate()||void 0,sort:this._pipelineSort()||void 0,separator:this._pipelineSeparator()||void 0,fallback:this._pipelineFallback()||void 0,transform:this._pipelineTransform()||void 0,exclude:this._pipelineExcludeParsed().length?this._pipelineExcludeParsed():void 0},n=parseInt(this._pipelineLimit(),10);!isNaN(n)&&n>0&&(a.limit=n),t=a}else t={type:"formula",fields:this._formulaFields(),op:this._formulaOp()};this.updateColumnDef.emit({evaluation:t})}_onPipelineExcludeChanged(t){this._pipelineExcludeJson.set(t);try{const a=JSON.parse(t);if(!Array.isArray(a))throw new Error("Must be a JSON array of strings");this._pipelineExcludeError.set(""),this._pipelineExcludeParsed.set(a),this._applyEvaluation()}catch(a){this._pipelineExcludeError.set(a?.message??"Invalid JSON")}}datatypeOptions=fe;datatypeLabelMap=(0,_.EW)(()=>(this._lang(),Object.fromEntries(fe.map(t=>[t,this._transloco.translate(`components.sparqlTable.datatype${t.charAt(0).toUpperCase()+t.slice(1)}`)]))));availableStrategyTypes=(0,_.EW)(()=>{const t=this._datatype();return t?te[t]:ee});strategyLabelMap=(0,_.EW)(()=>(this._lang(),Object.fromEntries(ee.map(t=>[t,this._transloco.translate(ye[t])]))));_strategyDescription=(0,_.EW)(()=>(this._lang(),this._transloco.translate(be[this._strategyType()])));query=(0,_.EW)(()=>this.columnDef().query??"");_editedQuery=(0,_.uu)(()=>this.query());_queryError=(0,_.EW)(()=>{this._lang();const t=function Ve(l,u="val"){if(!l?.trim())return null;let t;try{t=new w.Parser({sparqlStar:!0}).parse(l)}catch{return"validationErrorSyntax"}if("query"!==t?.type||"SELECT"!==t?.queryType)return"validationErrorNotSelect";const n=t.variables;if(1===n.length&&"*"===n[0])return null;const o=n.map(i=>i?.value??i?.variable?.value??"");return o.includes("subject")?o.includes(u)?null:"validationErrorMissingVal":"validationErrorMissingKey"}(this._editedQuery(),this._strategyValueKey()||"val");if(!t)return;const a=`components.sparqlTable.${t}`;return"validationErrorMissingVal"===t?this._transloco.translate(a,{var:this._strategyValueKey()||"val"}):this._transloco.translate(a)});_datatype=(0,_.uu)(()=>this.columnDef().datatype);_strategyType=(0,_.uu)(()=>this.columnDef().strategy?.type??"join");_strategySeparator=(0,_.uu)(()=>this.columnDef().strategy?.separator??", ");_strategyValueKey=(0,_.uu)(()=>this.columnDef().strategy?.valueKey??"val");_strategyPriorityKey=(0,_.uu)(()=>this.columnDef().strategy?.priorityKey??"");_strategyPreProcess=(0,_.uu)(()=>this.columnDef().strategy?.preProcess??"");_strategyFallback=(0,_.uu)(()=>this.columnDef().strategy?.fallback??"");_strategyMapJson=(0,_.uu)(()=>{const t=this.columnDef().strategy;if("map"!==t?.type)return"{}";try{return JSON.stringify(t.map,null,2)}catch{return"{}"}});_strategyMapError=(0,s.vPA)("");_strategyNeedsSeparator=(0,_.EW)(()=>mt.includes(this._strategyType()));_strategyNeedsValueKey=(0,_.EW)(()=>pe.includes(this._strategyType()));_strategyNeedsPriorityKey=(0,_.EW)(()=>_e.includes(this._strategyType())&&this._queryExtraBindings().length>0);_strategyNeedsMap=(0,_.EW)(()=>gt.includes(this._strategyType()));_strategyPreProcessError=(0,_.EW)(()=>{const t=this._strategyPreProcess();return t?(0,P.NF)(t)??void 0:void 0});_queryExtraBindings=(0,_.EW)(()=>{const t=this._editedQuery(),a=this._strategyValueKey()||"val";if(!t?.trim())return[];try{const n=new w.Parser({sparqlStar:!0}).parse(t);if("SELECT"!==n?.queryType)return[];const o=n.variables;return 1===o.length&&"*"===o[0]?[]:o.map(d=>d?.value??d?.variable?.value??"").filter(Boolean).filter(d=>"subject"!==d&&d!==a)}catch{return[]}});setDatatype(t){const a=t||void 0;if(this._datatype.set(a),a&&!te[a].includes(this._strategyType()))return this._strategyType.set("first"),void this.updateColumnDef.emit({strategy:{type:"first"},datatype:a});this.updateColumnDef.emit({datatype:a})}setStrategyType(t){if(!t)return;this._strategyType.set(t);const a=this._buildStrategy(t);this.updateColumnDef.emit({strategy:a})}_applyStrategyChange(){const t=this._buildStrategy(this._strategyType());this.updateColumnDef.emit({strategy:t})}_buildStrategy(t){const a=this._strategyValueKey()||"val",n=this._strategyPriorityKey()||void 0,d={preProcess:this._strategyPreProcess()||void 0,fallback:this._strategyFallback()||void 0};if("join"===t)return{type:t,separator:this._strategySeparator(),...d};if("map"===t){let r={};try{r=JSON.parse(this._strategyMapJson())}catch{}return{type:t,map:r,...d}}return pe.includes(t)?{type:t,valueKey:a,priorityKey:n,...d}:_e.includes(t)?{type:t,priorityKey:n,...d}:{type:t,...d}}_onMapJsonChanged(t){this._strategyMapJson.set(t);try{const a=JSON.parse(t);if("object"!=typeof a||Array.isArray(a))throw new Error("Must be a JSON object");this._strategyMapError.set(""),this._applyStrategyChange()}catch(a){this._strategyMapError.set(a?.message??"Invalid JSON")}}_queryDirty=(0,_.EW)(()=>this._editedQuery()!==this.query());onQueryChanged(t){this._editedQuery.set(t)}discardQuery(){this._editedQuery.set(this.query()),this._testRows.set([]),this._testError.set("")}_testRows=(0,s.vPA)([]);_testError=(0,s.vPA)("");_testLoading=(0,s.vPA)(!1);testQuery(){var t=this;return(0,C.A)(function*(){const a=t.handlers()?.queryHandler;if(!a)return void t._testError.set("No query handler available.");t._testRows.set([]),t._testError.set(""),t._testLoading.set(!0);const o=t._editedQuery().trim().replace(/\s*LIMIT\s+\d+\s*$/i,"")+"\nLIMIT 5";try{const d=((yield a(o,{}))?.results?.bindings??[]).map(r=>JSON.stringify(Object.fromEntries(Object.entries(r).map(([p,c])=>[p,c.value])),null,2));t._testRows.set(d),t.updateColumnDef.emit({query:t._editedQuery()})}catch(i){t._testError.set(i?.message??String(i))}finally{t._testLoading.set(!1)}})()}_onColDefUpdate(t){this.updateColumnDef.emit(t)}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-declarative-sparql-column-settings-modal"]],inputs:{columnDef:[1,"columnDef"],handlers:[1,"handlers"],columns:[1,"columns"]},outputs:{columnDef:"columnDefChange",close:"close",updateColumnDef:"updateColumnDef"},decls:7,vars:13,consts:[["minWidth","800px",3,"updateColumn","close","columnDef","settings","extraPanelLabel"],["cueExtraContent","","direction","column"],[3,"valueChange","label","value","options","labelMap"],["size","s",3,"info"],[2,"height","200px","min-height","120px"],["type","sparql",3,"contentChanged","content"],["size","s",2,"color","var(--cue-error)"],["direction","row","justify","end","gap","s"],["variant","ghost","size","s"],["variant","secondary","size","s",3,"click","disabled"],["icon","go"],["size","xs",2,"opacity","0.6","font-style","italic"],[3,"valueChange","label","info","value","options","labelMap"],["size","xs",2,"opacity","0.7"],[3,"label","value"],[3,"label","info","value"],[3,"valueChange","label","info","value"],["variant","ghost","size","s",3,"click"],["size","s"],["size","xs",2,"font-family","monospace","white-space","pre-wrap"],[3,"valueChange","label","value"],[2,"height","200px","min-height","120px","text-align","left"],["type","json",3,"contentChanged","content"],["size","xs",2,"opacity","0.7","font-style","italic"],["direction","row","wrap","wrap","gap","xs"],[1,"field-chip",3,"title"],[1,"field-chip",3,"click","title"],[1,"field-chip",3,"field-chip--active","title"],["direction","row","wrap","wrap","gap","xs",2,"align-items","center"],[1,"formula-token"],[1,"formula-op"],["direction","row","gap","m"],[2,"display","flex","align-items","center","gap","4px","font-size","0.85rem","cursor","pointer"],["type","checkbox",3,"change","checked"],[2,"height","160px","min-height","80px","text-align","left"]],template:function(a,n){1&a&&(e.j41(0,"cue-table-column-settings-modal",0),e.nI1(1,"transloco"),e.bIt("updateColumn",function(i){return n._onColDefUpdate(i)})("close",function(){return n.close.emit()}),e.j41(2,"cue-flexcontainer",1)(3,"cue-select",2),e.nI1(4,"transloco"),e.bIt("valueChange",function(i){return n.setDefType(i)}),e.k0s(),e.nVh(5,Ze,37,51),e.nVh(6,ft,8,11),e.k0s()()),2&a&&(e.Y8G("columnDef",n.columnDef())("settings",n.agGridSettings)("extraPanelLabel",e.bMT(1,9,"components.sparqlTable.panelLabel")),e.R7$(3),e.Y8G("label",e.bMT(4,11,"components.sparqlTable.labelColumnType"))("value",n._defType())("options",n.columnTypeOptions)("labelMap",n.columnTypeLabelMap()),e.R7$(2),e.vxM("data"===n._defType()?5:-1),e.R7$(),e.vxM("evaluation"===n._defType()?6:-1))},dependencies:[z.T,N.n,A.Typography,se.l,re.p,X.Button,ce.ButtonIcon,ue.B,de.ButtonLabel,Ge.ButtonPadder,L.Kj],styles:[".field-chip[_ngcontent-%COMP%]{display:inline-block;padding:2px 8px;border-radius:4px;background:var(--cue-surface-2, #eee);font-family:monospace;font-size:.75rem;cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .12s,outline .12s;outline:2px solid transparent}.field-chip[_ngcontent-%COMP%]:hover{background:var(--cue-primary-light, #c8e6c9)}.field-chip--active[_ngcontent-%COMP%]{background:var(--cue-primary, #4caf50);color:#fff;outline-color:var(--cue-primary, #4caf50)}.formula-token[_ngcontent-%COMP%]{display:inline-block;padding:2px 8px;border-radius:4px;background:var(--cue-primary, #4caf50);color:#fff;font-family:monospace;font-size:.75rem}.formula-op[_ngcontent-%COMP%]{font-size:1rem;font-weight:700;opacity:.6;padding:0 2px}"],changeDetection:0})}return l})();var bt=h(5187),vt=h(7717),Y=h(5661),Dt=h(6117),Tt=h(356),Ct=h(6279),St=h(29),Mt=h(5821),Rt=h(5745);const xt=(l,u)=>u.key;function Pt(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-input",12),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG().$implicit,i=e.XpG(2);return s.Njj(i._setVar(o.key,n))}),e.k0s()}if(2&l){const t=e.XpG().$implicit,a=e.XpG(2);e.Y8G("label",t.label)("value",a._varValues()[t.key]??a._filePathPlaceholder())}}function Et(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-select",13),e.bIt("valueChange",function(n){s.eBV(t);const o=e.XpG().$implicit,i=e.XpG(2);return s.Njj(i._setVar(o.key,n))}),e.k0s()}if(2&l){const t=e.XpG().$implicit,a=e.XpG(2);e.Y8G("label",t.label)("options",a._categoryOptions())("labelMap",a._categoryLabelMap())("value",a._varValues()[t.key]??void 0)("disabled",a._categoriesLoading())("placeholder",a._categoriesLoading()?"Loading\u2026":"Select a category\u2026")}}function Ft(l,u){if(1&l&&e.nVh(0,Pt,1,2,"cue-input",10)(1,Et,1,6,"cue-select",11),2&l){const t=u.$implicit;e.vxM("text"===t.type?0:"select"===t.type?1:-1)}}function wt(l,u){1&l&&e.Z7z(0,Ft,2,1,null,null,xt),2&l&&e.Dyx(u.variables)}function jt(l,u){1&l&&(e.j41(0,"div",6),e.EFF(1),e.nI1(2,"transloco"),e.k0s()),2&l&&(e.R7$(),e.JRh(e.bMT(2,1,u)))}const At=new w.Parser({sparqlStar:!0}),me=`PREFIX qcy: <${O.E.qcy}>`,W=[{id:"files-in-directory",label:"Files in a specific directory",template:`${me}\n\nSELECT DISTINCT ?subject\nWHERE {\n ?subject a qcy:FileContent ;\n qcy:hasFileLocation ?fl .\n ?fl qcy:filePath ?path .\n FILTER(STRSTARTS(STR(?path), "\${THE_FILE_PATH}"))\n\n # EXCLUDE DERIVED FILES\n FILTER NOT EXISTS {?x qcy:alternativeRepresentation ?subject}\n}`,variables:[{key:"THE_FILE_PATH",label:"File path",type:"text"}]},{id:"entities-of-category",label:"Entities of a specific category",template:`${me}\n\nSELECT DISTINCT ?subject\nWHERE {\n ?subject a qcy:CanonicalEntity ;\n qcy:hasEntityCategory <\${CATEGORY_IRI}> .\n}`,variables:[{key:"CATEGORY_IRI",label:"Category",type:"select"}]}];let Nt=(()=>{class l{rowDefinitionQuery=(0,m.geq)(null);handlers=(0,m.hFB)(void 0);close=(0,m.CGW)();saved=(0,m.CGW)();_draft=(0,_.uu)(()=>this.rowDefinitionQuery()||$);_selectedPredefinedId=(0,s.vPA)(null);_varValues=(0,s.vPA)({});_categories=(0,s.vPA)([]);_categoriesLoading=(0,s.vPA)(!1);_filePathPlaceholder=(0,s.vPA)("");_selectedPredefined=(0,_.EW)(()=>{const t=this._selectedPredefinedId();return t?W.find(a=>a.id===t)??null:null});_predefinedOptions=W.map(t=>t.id);_predefinedLabelMap=Object.fromEntries(W.map(t=>[t.id,t.label]));_categoryOptions=(0,_.EW)(()=>this._categories().map(t=>t.iri));_categoryLabelMap=(0,_.EW)(()=>Object.fromEntries(this._categories().map(t=>[t.iri,t.label])));_resolvedTemplate=(0,_.EW)(()=>{const t=this._selectedPredefined();if(!t)return null;const a=this._varValues();let n=t.template;for(const o of t.variables)n=n.replaceAll(`\${${o.key}}`,a[o.key]??"");return n});constructor(){(0,s.QZP)(()=>{const t=this._selectedPredefined(),a=this.handlers();this._varValues.set({}),this._categories.set([]),this._filePathPlaceholder.set(""),t?.variables.some(n=>"select"===n.type)&&this._loadCategories(a),t?.variables.some(n=>"THE_FILE_PATH"===n.key)&&this._loadFilePathPlaceholder(a)}),(0,s.QZP)(()=>{const t=this._resolvedTemplate();null!==t&&this._draft.set(t)})}_loadCategories(t){var a=this;return(0,C.A)(function*(){const n=t?.contentCategoriesInProject;if(n){a._categoriesLoading.set(!0);try{const o=yield n();a._categories.set(o)}catch(o){console.error("[RowDefModal] _loadCategories \u2014 error:",o)}finally{a._categoriesLoading.set(!1)}}})()}_loadFilePathPlaceholder(t){var a=this;return(0,C.A)(function*(){const n=t?.randomFilePath;if(!n)return;const o=yield n();if(o){const i=o.replace(/\/?[^\/]*$/,"/");a._filePathPlaceholder.set(i),a._setVar("THE_FILE_PATH",i)}})()}_onPredefinedChange(t){this._selectedPredefinedId.set(null!=t?String(t):null)}_setVar(t,a){null!=a&&this._varValues.update(n=>({...n,[t]:String(a)}))}_validationError=(0,_.EW)(()=>{const t=this._draft().trim();if(!t)return null;try{const a=At.parse(t);if("SELECT"!==a?.queryType)return"components.sparqlTable.rowDefinitionErrorNotSelect";if(!a.variables.filter(i=>"*"!==i).map(i=>i?.value??i?.variable?.value??"").includes("subject"))return"components.sparqlTable.rowDefinitionErrorMissingSubject"}catch{return"components.sparqlTable.rowDefinitionErrorSyntax"}return null});_isSaveDisabled=(0,_.EW)(()=>!!this._draft().trim()&&!!this._validationError());_save(){this._draft()&&this._validationError()||(this.rowDefinitionQuery.set(this._draft()),this.saved.emit(),this.close.emit())}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-sparql-row-definition-modal"]],inputs:{rowDefinitionQuery:[1,"rowDefinitionQuery"],handlers:[1,"handlers"]},outputs:{rowDefinitionQuery:"rowDefinitionQueryChange",close:"close",saved:"saved"},decls:20,vars:20,consts:[[3,"close","label","minWidth"],["direction","column","gap","m",2,"padding","4px 0"],["size","s","color","secondary"],["label","Predefined query","placeholder","Custom query\u2026",3,"valueChange","options","labelMap","value"],[2,"height","200px","display","flex","flex-direction","column"],["type","sparql",2,"flex","1",3,"contentChange","content"],[1,"row-def-error"],["direction","row","gap","s","justify","end"],["variant","tertiary","size","s",3,"click"],["variant","primary","size","s",3,"click","disabled"],[3,"label","value"],[3,"label","options","labelMap","value","disabled","placeholder"],[3,"valueChange","label","value"],[3,"valueChange","label","options","labelMap","value","disabled","placeholder"]],template:function(a,n){if(1&a&&(e.j41(0,"cue-modal",0),e.nI1(1,"transloco"),e.bIt("close",function(){return n.close.emit()}),e.j41(2,"cue-flexcontainer",1)(3,"cue-typography",2),e.EFF(4),e.nI1(5,"transloco"),e.k0s(),e.j41(6,"cue-select",3),e.bIt("valueChange",function(i){return n._onPredefinedChange(i)}),e.k0s(),e.nVh(7,wt,2,0),e.j41(8,"div",4)(9,"cue-code-editor",5),e.bIt("contentChange",function(i){return n._draft.set(i)}),e.k0s()(),e.nVh(10,jt,3,3,"div",6),e.j41(11,"cue-flexcontainer",7)(12,"cue-button",8),e.bIt("click",function(){return n.close.emit()}),e.j41(13,"cue-button-label"),e.EFF(14),e.nI1(15,"transloco"),e.k0s()(),e.j41(16,"cue-button",9),e.bIt("click",function(){return n._save()}),e.j41(17,"cue-button-label"),e.EFF(18),e.nI1(19,"transloco"),e.k0s()()()()()),2&a){let o,i;e.Y8G("label",e.bMT(1,12,"components.sparqlTable.rowDefinitionModalTitle"))("minWidth","620px"),e.R7$(4),e.SpI(" ",e.bMT(5,14,"components.sparqlTable.rowDefinitionModalDescription")," "),e.R7$(2),e.Y8G("options",n._predefinedOptions)("labelMap",n._predefinedLabelMap)("value",n._selectedPredefinedId()??void 0),e.R7$(),e.vxM((o=n._selectedPredefined())?7:-1,o),e.R7$(2),e.Y8G("content",n._draft()),e.R7$(),e.vxM((i=n._draft()&&n._validationError())?10:-1,i),e.R7$(4),e.SpI(" ",e.bMT(15,16,"components.sparqlTable.rowDefinitionDiscard")," "),e.R7$(2),e.Y8G("disabled",n._isSaveDisabled()),e.R7$(2),e.SpI(" ",e.bMT(19,18,"components.sparqlTable.rowDefinitionSave")," ")}},dependencies:[Rt.a,N.n,A.Typography,X.Button,de.ButtonLabel,ue.B,se.l,re.p,L.Kj],styles:[".row-def-error[_ngcontent-%COMP%]{color:var(--cue-color-error, #ef4444);font-size:12px;padding:2px 0}"],changeDetection:0})}return l})();var kt=h(7284);function qt(l,u){if(1&l&&(e.j41(0,"div",13),e.nrm(1,"span",26),e.EFF(2),e.k0s()),2&l){const t=u;e.R7$(2),e.Lme(" ",t.done," / ",t.total," queries ")}}function It(l,u){1&l&&(e.j41(0,"div",13),e.nrm(1,"span",26),e.EFF(2," Building table for download\u2026 "),e.k0s())}function Lt(l,u){if(1&l){const t=e.RV6();e.j41(0,"div",27),e.bIt("click",function(){s.eBV(t);const n=e.XpG();return s.Njj(n._openRowDefModal())}),e.j41(1,"cue-typography",28),e.EFF(2),e.nI1(3,"transloco"),e.k0s()()}2&l&&(e.R7$(2),e.SpI(" ",e.bMT(3,1,"components.sparqlTable.rowDefinitionEmpty")," "))}function Gt(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-paginator",29),e.bIt("currentPage",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o._onPaginateEvent(n))}),e.k0s()}if(2&l){const t=e.XpG();e.Y8G("size",t._totalKeys())("pageSize",t.pageSize())}}function Vt(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-button",30),e.bIt("click",function(){const n=s.eBV(t),o=n.$implicit,i=n.index,d=e.XpG();return s.Njj(d._openSettings(o,i))}),e.nrm(1,"cue-button-icon",11),e.k0s(),e.j41(2,"cue-button",31),e.bIt("click",function(){const n=s.eBV(t).$implicit,o=e.XpG();return s.Njj(o._deleteColumn(n.field))}),e.nrm(3,"cue-button-icon",32),e.k0s()}}function Qt(l,u){if(1&l){const t=e.RV6();e.j41(0,"div",33),e.bIt("click",function(){s.eBV(t);const n=e.XpG();return s.Njj(n._addColumn())}),e.nrm(1,"cue-button-icon",34),e.k0s()}}function Ot(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-declarative-sparql-column-settings-modal",35),e.mxI("columnDefChange",function(n){const o=s.eBV(t);return e.DH7(o.col,n)||(o.col=n),s.Njj(n)}),e.bIt("close",function(){s.eBV(t);const n=e.XpG();return s.Njj(n._activeColumn.set(void 0))})("updateColumnDef",function(n){const o=s.eBV(t),i=e.XpG();return s.Njj(i._applyColumnUpdate(o.index,n))}),e.k0s()}if(2&l){const t=e.XpG();e.R50("columnDef",u.col),e.Y8G("handlers",t.handlers())("columns",t.columns())}}function $t(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-sparql-row-definition-modal",36),e.mxI("rowDefinitionQueryChange",function(n){s.eBV(t);const o=e.XpG();return e.DH7(o.rowDefinition,n)||(o.rowDefinition=n),s.Njj(n)}),e.bIt("saved",function(){s.eBV(t);const n=e.XpG();return s.Njj(n._onRowDefSaved())})("close",function(){s.eBV(t);const n=e.XpG();return s.Njj(n._showRowDefModal.set(!1))}),e.k0s()}if(2&l){const t=e.XpG();e.R50("rowDefinitionQuery",t.rowDefinition),e.Y8G("handlers",t.rowDefinitionHandlers())}}const Bt=new w.Parser({sparqlStar:!0}),Xt=new w.Generator;function V(l,u){return H.apply(this,arguments)}function H(){return H=(0,C.A)(function*(l,u){const t=new Array(l.length);let a=0;function o(){return(o=(0,C.A)(function*(){for(;a<l.length;){const d=a++;t[d]=yield l[d]()}})).apply(this,arguments)}const i=Array.from({length:Math.min(u,l.length)},()=>function n(){return o.apply(this,arguments)}());return yield Promise.all(i),t}),H.apply(this,arguments)}function U(l,u){if(u.length>200)return l;try{const t=Bt.parse(l),a={type:"values",values:u.map(n=>({"?subject":{termType:"NamedNode",value:n}}))};return Array.isArray(t.where)&&(t.where=[a,...t.where]),Xt.stringify(t)}catch{const t=`VALUES ?subject { ${u.map(a=>`<${a}>`).join(" ")} }`;return l.replace(/WHERE\s*\{/i,`WHERE {\n ${t}`)}}let Kt=(()=>{class l{visibleRows=(0,m.CGW)();columnDefsAG=(0,m.CGW)();columns=m.geq.required();handlers=m.hFB.required();rowDefinitionHandlers=(0,m.hFB)(void 0);rowDefinition=(0,m.geq)($);pageSize=(0,m.hFB)(10);bufferFactor=(0,m.hFB)(5);_bufferSize=(0,_.EW)(()=>this.pageSize()*this.bufferFactor());_noRowDef=(0,_.EW)(()=>null!==this.rowDefinition()&&!this.rowDefinition()&&!this._showSettings());_showSettings=(0,s.vPA)(!1);_activeColumn=(0,s.vPA)(void 0);_showRowDefModal=(0,s.vPA)(!1);_dataFetchService=(0,s.WQX)(I);_tableService=(0,s.WQX)(B);_allKeys=(0,s.vPA)([]);_totalKeys=(0,_.EW)(()=>this._allKeys().length);_bufferKeys=(0,s.vPA)([]);_bufferOffset=(0,s.vPA)(0);_rowDefLoading=(0,s.vPA)(!1);_rowDefError=(0,s.vPA)("");_gridApi=null;_fullDataMode=(0,s.vPA)(!1);_fetchingFullData=(0,s.vPA)(!1);_fullDataFetchVersion=0;_exporting=(0,s.vPA)(!1);_prefetchCache=new Map;_currentlyPrefetching=new Set;_displayColumns=(0,_.EW)(()=>{const t=this._bufferKeys();return null===this.rowDefinition()||t.length?this._patchColumns(this.columns(),t):[]});_queryProgress=(0,_.EW)(()=>{const t=!!this.rowDefinition(),a=t?1:0;if(this._fetchingFullData()){const p=this._dataFetchService.totalQueryCount(),c=a+Math.max(p,1);return 0===c?null:{done:0,total:c}}const n=t&&!this._rowDefLoading()&&this._allKeys().length>0?1:0,o=this._dataFetchService.totalQueryCount(),d=n+this._dataFetchService.fetchedColumns().length,r=a+o;return 0===r||d>=r?null:{done:d,total:r}});_handlers=(0,_.EW)(()=>({queryHandler:this.handlers().queryHandler}));constructor(){(0,s.QZP)(()=>{const t=this.rowDefinition(),a=this.handlers();t&&a&&this._fetchRowDef(t,a)})}_openRowDefModal(){this._showRowDefModal.set(!0)}_onGridApi(t){this._gridApi=t,null!==this.rowDefinition()&&(t.addEventListener("sortChanged",()=>this._checkSortFilterState(t)),t.addEventListener("filterChanged",()=>this._checkSortFilterState(t)))}_checkSortFilterState(t){if(!this.rowDefinition())return;const a=t.getColumnState().some(i=>null!=i.sort),n=Object.keys(t.getFilterModel()??{}).length>0,o=a||n;!o||this._fullDataMode()||this._fetchingFullData()?o&&this._fullDataMode()?this._fillVisibleRows():!o&&(this._fullDataMode()||this._fetchingFullData())&&this._exitFullDataMode():this._enterFullDataMode()}_fillingVisibleRows=!1;_fillVisibleRows(){var t=this;return(0,C.A)(function*(){if(!t._fillingVisibleRows&&t._gridApi){t._fillingVisibleRows=!0;try{const a=t._gridApi.paginationGetPageSize?.()??t.pageSize(),o=(t._gridApi.paginationGetCurrentPage?.()??0)*a,i=[];for(let p=o;p<o+a;p++){const c=t._gridApi.getDisplayedRowAtIndex(p);if(!c?.data?.id)break;i.push(c.data.id)}if(!i.length)return;const d=t.columns().filter(p=>"data"===p.defType&&p.query&&!p.hide),r=t._dataFetchService.keyVals;yield V(d.map(p=>(0,C.A)(function*(){const c=i.filter(g=>void 0===r[g]?.[p.field]);if(!c.length)return;const f=U(p.query,c);try{const g=yield t.handlers().queryHandler(f,E(f)),y={};g.results.bindings.forEach(T=>{const b=T.subject?.value;if(!b)return;y[b]||(y[b]=[]);const M={};Object.keys(T).filter(S=>"subject"!==S).forEach(S=>{M[S]=T[S]?.value}),y[b].push(M)}),t._dataFetchService.mergeColumnData(p.field,y,p.query)}catch{}})),3)}finally{t._fillingVisibleRows=!1}}})()}_onPaginateEvent(t){const a=t.startIndex,n=this._bufferSize(),o=Math.floor(a/n)*n;this._loadBuffer(o);const i=Math.floor((a-o)/this.pageSize());if(this._gridApi)try{this._gridApi.paginationGoToPage(i)}catch{}if(i>=Math.ceil(n/this.pageSize())-1){const r=o+n;r<this._allKeys().length&&this._prefetchBuffer(r)}}_fetchRowDef(t,a){var n=this;return(0,C.A)(function*(){n._rowDefLoading.set(!0),n._rowDefError.set(""),n._dataFetchService.emptyTableText.set("Loading\u2026"),n._allKeys.set([]),n._bufferKeys.set([]),n._bufferOffset.set(0),n._prefetchCache.clear(),n._currentlyPrefetching.clear();try{const o=E(t),i=yield a.queryHandler(t,o),d=i.results.bindings.map(r=>r.subject?.value).filter(Boolean);console.log("[ROWDEF] _fetchRowDef received",i.results.bindings.length,"bindings,",d.length,"valid keys. meta=",i.meta),n._allKeys.set(d),n._loadBuffer(0)}catch(o){n._rowDefError.set(String(o?.message??o))}finally{n._rowDefLoading.set(!1)}})()}_loadBuffer(t,a=!1){const n=this._allKeys().slice(t,t+this._bufferSize()),o=this._bufferKeys();if(!a&&n.length===o.length&&n.every((d,r)=>d===o[r]))return;const i=this._prefetchCache.get(t);if(this._prefetchCache.delete(t),this._dataFetchService.resetData(),i?this._dataFetchService.injectPreloadedData(i.keyVals,i.fetchedColumnFields,i.columnQueries):this._tableService.destroy(),this._bufferOffset.set(t),this._bufferKeys.set(n),this._gridApi)try{this._gridApi.paginationGoToPage(0)}catch{}}_enterFullDataMode(){var t=this;return(0,C.A)(function*(){if(console.log("[FDM] _enterFullDataMode called. _fetchingFullData=",t._fetchingFullData(),"_fullDataMode=",t._fullDataMode(),"_allKeys=",t._allKeys().length),t._fetchingFullData())return;t._fetchingFullData.set(!0);const a=++t._fullDataFetchVersion;let n;t._gridApi&&(n=t._gridApi.getColumnState().find(r=>null!=r.sort)?.colId,n||(n=Object.keys(t._gridApi.getFilterModel()??{})[0]));const o=n?.replace(/_\d+$/,""),i=o?t.columns().find(d=>d.field===o&&"data"===d.defType&&d.query):void 0;if(!i)return t._fullDataMode.set(!0),void t._fetchingFullData.set(!1);try{if(a!==t._fullDataFetchVersion)return;const d=yield t.handlers().queryHandler(i.query,E(i.query));if(a!==t._fullDataFetchVersion)return;const r={};Object.entries(t._dataFetchService.keyVals).forEach(([b,M])=>{r[b]={...M}});const p=t._allKeys();p.forEach(b=>{r[b]||(r[b]={})}),console.log("[DeclarativeSPARQLTable] keyVals pre-seed: allKeys=",p.length,"keyVals size=",Object.keys(r).length);const c=[...t._dataFetchService.fetchedColumns()],f={...t._dataFetchService._columnQueries},g=[];if(d.results.bindings.forEach(b=>{const M=b.subject?.value;if(!M)return;r[M]||(r[M]={}),r[M][i.field]=[];const S={};Object.keys(b).filter(D=>"subject"!==D).forEach(D=>{S[D]=b[D]?.value}),r[M][i.field].push(S),g.push(M)}),c.includes(i.field)||c.push(i.field),f[i.field]=i.query,console.log("[FDM] after sort-col fetch: keyVals size=",Object.keys(r).length,"allKeys from sort col=",g.length),console.log("[FDM] calling resetData()"),t._dataFetchService.resetData(),t._tableService.destroy(),console.log("[FDM] calling injectPreloadedData with",Object.keys(r).length,"rows"),t._dataFetchService.injectPreloadedData(r,c,f),console.log("[FDM] injectPreloadedData done. Service keyVals size=",Object.keys(t._dataFetchService.keyVals).length),t._fullDataMode.set(!0),a!==t._fullDataFetchVersion)return;const y=t.columns().filter(b=>"data"===b.defType&&b.query&&b.field!==i.field&&!b.hide),T=new Set(t._bufferKeys());yield V(y.map(b=>(0,C.A)(function*(){const M=g.filter(D=>T.has(D)&&void 0===r[D]?.[b.field]);if(!M.length||a!==t._fullDataFetchVersion)return;const S=U(b.query,M);try{const D=yield t.handlers().queryHandler(S,E(S));if(a!==t._fullDataFetchVersion)return;const v={};D.results.bindings.forEach(R=>{const x=R.subject?.value;if(!x)return;v[x]||(v[x]=[]);const k={};Object.keys(R).filter(F=>"subject"!==F).forEach(F=>{k[F]=R[F]?.value}),v[x].push(k)}),Object.entries(v).forEach(([R,x])=>{r[R]&&(r[R][b.field]=x)}),t._dataFetchService.mergeColumnData(b.field,v,b.query)}catch{}})),3)}catch(d){console.error("[DeclarativeSPARQLTable] Error in _enterFullDataMode:",d)}finally{a===t._fullDataFetchVersion&&t._fetchingFullData.set(!1)}})()}_exitFullDataMode(){if(console.log("[FDM] _exitFullDataMode called"),this._fullDataFetchVersion++,this._fetchingFullData.set(!1),this._fullDataMode.set(!1),this._dataFetchService.resetData(),this._tableService.destroy(),this._loadBuffer(this._bufferOffset(),!0),this._gridApi)try{this._gridApi.paginationGoToPage(0)}catch{}}_prefetchBuffer(t){var a=this;return(0,C.A)(function*(){if(a._prefetchCache.has(t)||a._currentlyPrefetching.has(t))return;const n=a._allKeys().slice(t,t+a._bufferSize());if(!n.length)return;a._currentlyPrefetching.add(t);const i=a._patchColumns(a.columns(),n).filter(c=>"data"===c.defType&&!c.hide&&c.query),d={},r=[],p={};try{yield V(i.map(c=>(0,C.A)(function*(){try{(yield a.handlers().queryHandler(c.query,E(c.query))).results.bindings.forEach(g=>{const y=g.subject?.value;if(!y)return;d[y]||(d[y]={}),d[y][c.field]||(d[y][c.field]=[]);const T={};Object.keys(g).filter(b=>"subject"!==b).forEach(b=>{T[b]=g[b]?.value}),d[y][c.field].push(T)}),r.push(c.field),p[c.field]=c.query}catch{}})),3),a._prefetchCache.set(t,{keyVals:d,fetchedColumnFields:r,columnQueries:p})}finally{a._currentlyPrefetching.delete(t)}})()}_patchColumns(t,a){return a.length?t.map(n=>n.query&&"data"===n.defType?{...n,query:U(n.query,a)}:n):t}_columnSelectSettings=Object.assign(new z.e,{allowEditing:!1});_shownColumns=(0,_.EW)(()=>this.columns().filter(t=>!t.hide));_openSettings(t,a){const n=this.columns().findIndex(o=>o.field===t.field);this._activeColumn.set({col:{...t},index:n})}_onShownChanged(t){const a=new Set(t.map(d=>d.field)),n=this.columns(),o=t.map(d=>({...n.find(p=>p.field===d.field)??d,hide:!1})),i=n.filter(d=>!a.has(d.field)).map(d=>({...d,hide:!0}));this.columns.set([...o,...i])}_applyColumnUpdate(t,a){const n=this.columns().map((o,i)=>i===t?Object.assign(Object.create(Object.getPrototypeOf(o)),o,a):o);this.columns.set(n)}_addColumn(){const t=this.columns();let a;if(t.length>0)a=t[t.length-1];else{const i=this.rowDefinition();a=Object.assign(new ne,{query:i?this._seedQueryFromRowDef(i):"",strategy:{type:"first"}})}const n=Object.assign(Object.create(Object.getPrototypeOf(a)),a,{field:`column_${Date.now()}`,headerName:`${a.headerName??a.field??"Column"} Copy`,hide:!1}),o=t.length;this.columns.update(i=>[...i,n]),this._activeColumn.set({col:{...n},index:o})}_deleteColumn(t){this.columns.update(a=>a.filter(n=>n.field!==t))}_onRowDefSaved(){if(this.columns().length>0)return;this._showSettings.set(!0);const t=this.rowDefinition(),a=t?this._seedQueryFromRowDef(t):"",n=Object.assign(new ne,{field:`column_${Date.now()}`,headerName:"Column 1",query:a,strategy:{type:"first"}});this.columns.set([n]),this._activeColumn.set({col:{...n},index:0})}_seedQueryFromRowDef(t){try{if(/qcy:FileContent\b/.test(t)){let n=t.replace(/SELECT\s+(?:DISTINCT\s+)?\?subject\b/i,"SELECT ?subject ?value");n=n.replace(/\s*ORDER\s+BY\s+[^\n{}]*/gi,""),/PREFIX\s+skos:/i.test(n)||(n=`PREFIX skos: <${De.B.skos}>\n`+n);const o=n.lastIndexOf("}");return-1!==o&&(n=n.slice(0,o)+" ?subject qcy:hasContentCategory ?cat .\n ?cat skos:prefLabel ?value .\n}"),n.trim()}{let n=t.replace(/SELECT\s+(?:DISTINCT\s+)?\?subject\b/i,"SELECT ?subject ?val");n=n.replace(/\s*ORDER\s+BY\s+[^\n{}]*/gi,"");const o=n.lastIndexOf("}");return-1!==o&&(n=n.slice(0,o)+" ?subject qcy:value ?val .\n}"),n.trim()}}catch{return t}}_getFormattedData(t=!1,a){const n=t?this.columns().filter(c=>"data"===c.defType&&c.query).map(c=>this._dataFetchService.columnDefsAG().find(g=>g.colId===c.field||g.field===c.field)??{colId:c.field,headerName:c.headerName??c.field,cellRendererParams:{strategy:c.strategy,postProcess:c.postProcess}}):this._dataFetchService.columnDefsAG().filter(c=>!c.hide),o=this._allKeys(),i=a?(o.length>0?o:Object.keys(a)).map(c=>({id:c,...a[c]??{}})):this._tableService.tableData(),d=["Key",...n.map(c=>c.headerName??c.field??"")],r=["",...n.map(c=>{const f=c.cellStyle;return f&&"object"==typeof f?String(f.textAlign??f["text-align"]??"").toLowerCase():""})];return{headers:d,rows:i.map(c=>[String(c.id??""),...n.map(f=>{const g=f.colId??f.field??"",y=f.valueGetter;let T="function"==typeof y?y({data:c,colDef:f}):c[g];if(void 0===T&&a&&(T=(a[c.id]??{})[g]??[]),Array.isArray(T)){const b=f.cellRendererParams?.strategy,M=f.cellRendererParams?.postProcess,S=b?j(T,b,""):T.map(D=>D?.val??"").filter(Boolean).join(", ");return(0,P.g4)(S,M)}return String(T??"")})]),alignments:r}}_fetchAllColumnsForExport(t){var a=this;return(0,C.A)(function*(){const n=a._allKeys();console.log("[EXPORT] _fetchAllColumnsForExport called for",t.length,"columns. allKeys=",n.length);const o=t.filter(r=>"data"===r.defType&&r.query);if(!o.length)return{};const i=n.length?a._patchColumns(o,n):o,d={};return yield V(i.map(r=>(0,C.A)(function*(){try{(yield a.handlers().queryHandler(r.query,E(r.query))).results.bindings.forEach(c=>{const f=c.subject?.value;if(!f)return;d[f]||(d[f]={}),d[f][r.field]||(d[f][r.field]=[]);const g={};Object.keys(c).filter(y=>"subject"!==y).forEach(y=>{g[y]=c[y]?.value}),d[f][r.field].push(g)})}catch{}})),3),d})()}_downloadCsv(){var t=this;return(0,C.A)(function*(a=!1){if(!t._exporting()){t._exporting.set(!0);try{const n=a?t.columns():t.columns().filter(c=>!c.hide),o=yield t._fetchAllColumnsForExport(n),{headers:i,rows:d}=t._getFormattedData(a,o),r=kt.unparse([i,...d]),p=new Blob([r],{type:"text/csv;charset=utf-8;"});t._triggerDownload(p,"export.csv")}finally{t._exporting.set(!1)}}}).apply(this,arguments)}_downloadXlsx(){var t=this;return(0,C.A)(function*(a=!1){if(!t._exporting()){t._exporting.set(!0);try{const n=a?t.columns():t.columns().filter(c=>!c.hide),o=yield t._fetchAllColumnsForExport(n),{headers:i,rows:d,alignments:r}=t._getFormattedData(a,o),p=yield t._buildStyledXlsxBlob(i,d,r);t._triggerDownload(p,"export.xlsx")}finally{t._exporting.set(!1)}}}).apply(this,arguments)}_buildStyledXlsxBlob(t,a,n){return(0,C.A)(function*(){const d=(D,v)=>D?"center"===v?2:"right"===v?3:1:"center"===v?4:"right"===v?5:0,r=(D,v,R,x)=>{const k=`${(D=>{let v="",R=D+1;for(;R>0;)v=String.fromCharCode(65+(R-1)%26)+v,R=Math.floor((R-1)/26);return v})(D)}${v}`,F=x>0?` s="${x}"`:"",J=Number(R);return 0===x&&""!==R&&!isNaN(J)&&isFinite(J)?`<c r="${k}"${F}><v>${J}</v></c>`:`<c r="${k}"${F} t="inlineStr"><is><t>${(D=>D.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))(R)}</t></is></c>`},p=[];p.push(`<row r="1">${t.map((D,v)=>r(v,1,D,d(!0,n[v]??""))).join("")}</row>`),a.forEach((D,v)=>{p.push(`<row r="${v+2}">${D.map((R,x)=>r(x,v+2,R,d(!1,n[x]??""))).join("")}</row>`)});const c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">\n <cols><col min="1" max="1" hidden="1"/></cols>\n <sheetData>${p.join("")}</sheetData>\n</worksheet>`,S=new(0,(yield h.e(628).then(h.t.bind(h,7247,23))).default);return S.file("[Content_Types].xml",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\n <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>\n <Default Extension="xml" ContentType="application/xml"/>\n <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>\n <Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>\n <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>\n</Types>'),S.file("_rels/.rels",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>\n</Relationships>'),S.file("xl/workbook.xml",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">\n <sheets><sheet name="Data" sheetId="1" r:id="rId1"/></sheets>\n</workbook>'),S.file("xl/_rels/workbook.xml.rels",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>\n <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>\n</Relationships>'),S.file("xl/worksheets/sheet1.xml",c),S.file("xl/styles.xml",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">\n <fonts count="2">\n <font><sz val="11"/><name val="Calibri"/></font>\n <font><b/><color rgb="FFFFFFFF"/><sz val="11"/><name val="Poppins"/></font>\n </fonts>\n <fills count="3">\n <fill><patternFill patternType="none"/></fill>\n <fill><patternFill patternType="gray125"/></fill>\n <fill><patternFill patternType="solid"><fgColor rgb="FF2859E1"/><bgColor indexed="64"/></patternFill></fill>\n </fills>\n <borders count="1">\n <border><left/><right/><top/><bottom/><diagonal/></border>\n </borders>\n <cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>\n <cellXfs count="6">\n <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>\n <xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1"/>\n <xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment horizontal="center"/></xf>\n <xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment horizontal="right"/></xf>\n <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="center"/></xf>\n <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="right"/></xf>\n </cellXfs>\n</styleSheet>'),S.generateAsync({type:"blob",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})})()}_triggerDownload(t,a){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=a,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-declarative-sparql-table"]],inputs:{columns:[1,"columns"],handlers:[1,"handlers"],rowDefinitionHandlers:[1,"rowDefinitionHandlers"],rowDefinition:[1,"rowDefinition"],pageSize:[1,"pageSize"],bufferFactor:[1,"bufferFactor"]},outputs:{visibleRows:"visibleRows",columnDefsAG:"columnDefsAG",columns:"columnsChange",rowDefinition:"rowDefinitionChange"},features:[e.Jv_([I,B])],decls:39,vars:26,consts:[[1,"flip-card",3,"cueFlipChange","cueFlip"],[1,"flip-content"],[1,"card-face","front"],["direction","row","justify","end",2,"padding","2px"],["positioning","bottomleft"],["trigger","","variant","tertiary","size","s","cueTooltip","Export",3,"disabled"],["icon","more-vert"],["menu",""],[3,"click","disabled"],["before","","name","download"],["variant","accent","size","s","cueTooltip","Column settings",3,"click"],["icon","settings"],[3,"gridApi","visibleRows","columnDefsAG","handlers","columns","showPaginator","paginationPageSize","loading"],[1,"query-status"],[1,"row-def-empty"],[3,"size","pageSize"],[1,"card-face","back",2,"min-height","var(--cue-table-m-height)",3,"maxHeight"],["variant","tertiary","size","s",3,"click","cueTooltip"],["icon","filter"],["variant","accent","size","s","cueTooltip","Back to table",3,"click"],["icon","arrow-back"],[3,"shown","columnDefs","columnDefsGross","settings"],["cueColumnItem",""],["cueColumnListFooter",""],[3,"columnDef","handlers","columns"],[3,"rowDefinitionQuery","handlers"],[1,"query-status-spinner"],[1,"row-def-empty",3,"click"],["size","s","color","muted"],[3,"currentPage","size","pageSize"],["variant","tertiary","size","s","cueTooltip","Edit column",3,"click"],["variant","tertiary","size","s","cueTooltip","Delete column",3,"click"],["icon","delete"],["cueTooltip","Add column definition",1,"add-column-row",3,"click"],["icon","add"],[3,"columnDefChange","close","updateColumnDef","columnDef","handlers","columns"],[3,"rowDefinitionQueryChange","saved","close","rowDefinitionQuery","handlers"]],template:function(a,n){if(1&a&&(e.j41(0,"div",0),e.mxI("cueFlipChange",function(i){return e.DH7(n._showSettings,i)||(n._showSettings=i),i}),e.j41(1,"div",1)(2,"cue-card",2)(3,"cue-flexcontainer",3)(4,"cue-menu",4)(5,"cue-button",5),e.nrm(6,"cue-button-icon",6),e.k0s(),e.j41(7,"cue-menu-wrap",7)(8,"cue-menu-item",8),e.bIt("click",function(){return n._downloadCsv()}),e.nrm(9,"cue-svg-icon",9),e.EFF(10," Download CSV "),e.k0s(),e.j41(11,"cue-menu-item",8),e.bIt("click",function(){return n._downloadCsv(!0)}),e.nrm(12,"cue-svg-icon",9),e.EFF(13," Download CSV (incl. hidden columns) "),e.k0s(),e.j41(14,"cue-menu-item",8),e.bIt("click",function(){return n._downloadXlsx()}),e.nrm(15,"cue-svg-icon",9),e.EFF(16," Download XLSX "),e.k0s(),e.j41(17,"cue-menu-item",8),e.bIt("click",function(){return n._downloadXlsx(!0)}),e.nrm(18,"cue-svg-icon",9),e.EFF(19," Download XLSX (incl. hidden columns) "),e.k0s()()(),e.j41(20,"cue-button",10),e.bIt("click",function(){return n._showSettings.set(!0)}),e.nrm(21,"cue-button-icon",11),e.k0s()(),e.j41(22,"cue-sparql-table-inner",12),e.bIt("gridApi",function(i){return n._onGridApi(i)})("visibleRows",function(i){return n.visibleRows.emit(i)})("columnDefsAG",function(i){return n.columnDefsAG.emit(i)}),e.k0s(),e.nVh(23,qt,3,2,"div",13),e.nVh(24,It,3,0,"div",13),e.nVh(25,Lt,4,3,"div",14),e.nVh(26,Gt,1,2,"cue-paginator",15),e.k0s(),e.j41(27,"cue-card",16)(28,"cue-flexcontainer",3)(29,"cue-button",17),e.nI1(30,"transloco"),e.bIt("click",function(){return n._openRowDefModal()}),e.nrm(31,"cue-button-icon",18),e.k0s(),e.j41(32,"cue-button",19),e.bIt("click",function(){return n._showSettings.set(!1)}),e.nrm(33,"cue-button-icon",20),e.k0s()(),e.j41(34,"cue-ag-grid-column-select",21),e.bIt("shown",function(i){return n._onShownChanged(i)}),e.DNE(35,Vt,4,0,"ng-template",22)(36,Qt,2,0,"ng-template",23),e.k0s()()()(),e.nVh(37,Ot,1,3,"cue-declarative-sparql-column-settings-modal",24),e.nVh(38,$t,1,2,"cue-sparql-row-definition-modal",25)),2&a){let o,i;e.R50("cueFlip",n._showSettings),e.R7$(5),e.Y8G("disabled",n._exporting()),e.R7$(3),e.Y8G("disabled",n._exporting()),e.R7$(3),e.Y8G("disabled",n._exporting()),e.R7$(3),e.Y8G("disabled",n._exporting()),e.R7$(3),e.Y8G("disabled",n._exporting()),e.R7$(5),e.AVh("hidden",n._showSettings()||n._noRowDef()),e.Y8G("handlers",n._handlers())("columns",n._displayColumns())("showPaginator",n._fullDataMode())("paginationPageSize",n.pageSize())("loading",n._rowDefLoading()),e.R7$(),e.vxM((o=n._queryProgress())?23:-1,o),e.R7$(),e.vxM(n._exporting()?24:-1),e.R7$(),e.vxM(n._noRowDef()?25:-1),e.R7$(),e.vxM(n.rowDefinition()&&!n._fullDataMode()?26:-1),e.R7$(),e.Y8G("maxHeight","var(--cue-table-m-height)"),e.R7$(2),e.Y8G("cueTooltip",e.bMT(30,24,"components.sparqlTable.rowDefinitionTooltip")),e.R7$(5),e.Y8G("columnDefs",n._shownColumns())("columnDefsGross",n.columns())("settings",n._columnSelectSettings),e.R7$(3),e.vxM((i=n._activeColumn())?37:-1,i),e.R7$(),e.vxM(n._showRowDefModal()?38:-1)}},dependencies:[Ie,yt,Nt,Y.pL,Y.pC,Y.rx,bt.Card,N.n,A.Typography,X.Button,ce.ButtonIcon,vt.R,oe.d,Dt.W,Tt.M,Ct.D,St.A,Mt.m,L.Kj],styles:[".flip-card[_ngcontent-%COMP%]{width:100%}.flip-content[_ngcontent-%COMP%]{position:relative;width:100%}.card-face[_ngcontent-%COMP%]{width:100%}.hidden[_ngcontent-%COMP%]{display:none}.row-def-empty[_ngcontent-%COMP%]{flex:1;min-height:160px;display:flex;align-items:center;justify-content:center;padding:32px 16px;border:2px dashed var(--cue-color-border, #d1d5db);border-radius:8px;cursor:pointer;margin-top:8px;transition:border-color .15s}.row-def-empty[_ngcontent-%COMP%]:hover{border-color:var(--cue-color-accent, #4f46e5)}.query-status[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:12px;color:var(--cue-color-text-muted, #6b7280);background:var(--cue-color-surface-subtle, #f9fafb);border:1px solid var(--cue-color-border, #e5e7eb);border-radius:6px;margin-top:6px}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.query-status-spinner[_ngcontent-%COMP%]{display:inline-block;width:11px;height:11px;border:2px solid currentColor;border-top-color:transparent;border-radius:50%;animation:_ngcontent-%COMP%_spin .7s linear infinite;flex-shrink:0}.add-column-row[_ngcontent-%COMP%]{padding:20px 10px;border-top:solid 1px #ccc;display:flex;align-items:center;justify-content:center;opacity:.4;cursor:pointer;transition:opacity .15s ease}.add-column-row[_ngcontent-%COMP%]:hover{opacity:.75}"],changeDetection:0})}return l})();var Yt=h(7293);function Wt(l,u){if(1&l){const t=e.RV6();e.j41(0,"cue-declarative-sparql-table",3),e.mxI("columnsChange",function(n){s.eBV(t);const o=e.XpG();return e.DH7(o.columns,n)||(o.columns=n),s.Njj(n)})("rowDefinitionChange",function(n){s.eBV(t);const o=e.XpG();return e.DH7(o.rowDefinition,n)||(o.rowDefinition=n),s.Njj(n)}),e.bIt("visibleRows",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.visibleRows.emit(n))})("columnDefsAG",function(n){s.eBV(t);const o=e.XpG();return s.Njj(o.columnDefsAG.emit(n))}),e.k0s()}if(2&l){const t=e.XpG();e.Y8G("handlers",u)("rowDefinitionHandlers",t._rowDefinitionHandlers()),e.R50("columns",t.columns)("rowDefinition",t.rowDefinition),e.Y8G("pageSize",t.pageSize())("bufferFactor",t.bufferFactor())}}function Ht(l,u){1&l&&(e.j41(0,"cue-flexcontainer",1)(1,"cue-typography",4),e.EFF(2," No project connected. Pass a sdkState with cue and projectId. "),e.k0s()())}function Ut(l,u){if(1&l&&e.nrm(0,"cue-logo-link",2),2&l){let t;const a=e.XpG();e.Y8G("projectId",null==(t=a.sdkState())?null:t.projectId)}}let Jt=(()=>{class l{sdkState=(0,m.hFB)(void 0);columns=m.geq.required();rowDefinition=(0,m.geq)($);pageSize=(0,m.hFB)(10,{transform:m.Udg});showLogo=(0,m.hFB)(!1,{transform:m.L39});bufferFactor=(0,m.hFB)(5,{transform:m.Udg});visibleRows=(0,m.CGW)();columnDefsAG=(0,m.CGW)();_entities=(0,s.vPA)(void 0);_documents=(0,s.vPA)(void 0);_handlers=(0,_.EW)(()=>{const t=this.sdkState();if(!t)return;const{cue:a,projectId:n,graphType:o="fuseki"}=t;return{queryHandler:i=>a.api.sparql(i,n,o)}});_rowDefinitionHandlers=(0,_.EW)(()=>{const t=this._entities(),a=this._documents();if(t&&a)return{contentCategoriesInProject:()=>t.contentCategoriesInProject(),randomFilePath:()=>a.randomFilePath()}});constructor(){(0,s.QZP)(()=>{const t=this.sdkState();t?.cue&&t?.projectId?(this._entities.set(new Z.g8(t.cue.api,t.projectId)),this._documents.set(new Z.f$(t.cue.api,t.projectId))):(this._entities.set(void 0),this._documents.set(void 0))})}static \u0275fac=function(a){return new(a||l)};static \u0275cmp=e.VBU({type:l,selectors:[["cue-sparql-table"]],inputs:{sdkState:[1,"sdkState"],columns:[1,"columns"],rowDefinition:[1,"rowDefinition"],pageSize:[1,"pageSize"],showLogo:[1,"showLogo"],bufferFactor:[1,"bufferFactor"]},outputs:{columns:"columnsChange",rowDefinition:"rowDefinitionChange",visibleRows:"visibleRows",columnDefsAG:"columnDefsAG"},decls:3,vars:2,consts:[[3,"handlers","rowDefinitionHandlers","columns","rowDefinition","pageSize","bufferFactor"],["direction","column","align","center","justify","center",2,"height","100%","width","100%","padding","8px"],[2,"position","absolute","top","26px","left","26px","z-index","5",3,"projectId"],[3,"columnsChange","rowDefinitionChange","visibleRows","columnDefsAG","handlers","rowDefinitionHandlers","columns","rowDefinition","pageSize","bufferFactor"],[2,"color","#9ca3af","font-size","13px"]],template:function(a,n){if(1&a&&(e.nVh(0,Wt,1,6,"cue-declarative-sparql-table",0)(1,Ht,3,0,"cue-flexcontainer",1),e.nVh(2,Ut,1,1,"cue-logo-link",2)),2&a){let o;e.vxM((o=n._handlers())?0:1,o),e.R7$(2),e.vxM(n.showLogo()?2:-1)}},dependencies:[Kt,N.n,A.Typography,Yt.x],styles:["[_nghost-%COMP%]{display:block;width:100%;position:relative}"],changeDetection:0})}return l})()}}]);
package/791.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[791],{8791(I,w,m){m.d(w,{CueDocumentList:()=>R});var D=m(467),i=m(7705),u=m(5802),v=m(2271),O=m(4879),g=m(2065),_=m(4372),a=m(5381),p=m(2245),b=m(7851),L=m(7293),s=m(5547);function E(c,y){if(1&c&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-typography",2),s.EFF(2),s.k0s()()),2&c){const t=s.XpG();s.R7$(2),s.SpI(" ",t.errorMessage()," ")}}function A(c,y){if(1&c&&s.nrm(0,"cue-logo-link",4),2&c){const t=s.XpG(2);s.Y8G("projectId",t.projectId())}}function j(c,y){if(1&c){const t=s.RV6();s.j41(0,"div",1)(1,"cue-doc-list",3),s.bIt("clickedDocument",function(o){u.eBV(t);const n=s.XpG();return u.Njj(n.clickedDocument.emit(o))})("clickedDownloadDocument",function(o){u.eBV(t);const n=s.XpG();return u.Njj(n.clickedDownloadDocument.emit(o))})("clickedOpenInDir",function(o){u.eBV(t);const n=s.XpG();return u.Njj(n.clickedOpenInDir.emit(o))})("clickedOpen",function(o){u.eBV(t);const n=s.XpG();return u.Njj(n.clickedOpen.emit(o))}),s.k0s(),s.nVh(2,A,1,1,"cue-logo-link",4),s.k0s()}if(2&c){const t=s.XpG();s.Y8G("cueLogoLoader","loading"===t.state()),s.R7$(),s.Y8G("documentRefs",t.documentRefs())("documentData",t.documentData())("handlers",t.handlers())("availableContentCategories",t.availableContentCategories())("detailedView",t.detailedView())("simple",t.simple())("pageSize",t.pageSize())("prefetchPages",t.prefetchPages())("showOpenInDocumentViewerAction",t.showOpenInDocumentViewerAction())("showOpenInFileManagerAction",t.showOpenInFileManagerAction())("customOverlayActions",t.customOverlayActions())("variant",t.variant()),s.R7$(),s.vxM(t.showLogo()?2:-1)}}function M(c){return c.split("?")[0].trim()}let R=(()=>{class c{projectId=(0,i.hFB)(void 0);uuids=(0,i.hFB)([]);suffixes=(0,i.hFB)(void 0);mimeTypes=(0,i.hFB)(void 0);contentCategories=(0,i.hFB)(void 0);sdkState=(0,i.hFB)(void 0);detailedView=(0,i.hFB)(!1,{transform:i.L39});simple=(0,i.hFB)(!1,{transform:i.L39});pageSize=(0,i.hFB)(10,{transform:i.Udg});prefetchPages=(0,i.hFB)(3,{transform:i.Udg});showOpenInDocumentViewerAction=(0,i.hFB)(!1,{transform:i.L39});showOpenInFileManagerAction=(0,i.hFB)(!1,{transform:i.L39});customMenuItems=(0,i.hFB)([]);showLogo=(0,i.hFB)(!1,{transform:i.L39});variant=(0,i.hFB)("none");clickedDocument=(0,i.CGW)();clickedDownloadDocument=(0,i.CGW)();clickedOpenInDir=(0,i.CGW)();clickedOpen=(0,i.CGW)();state=(0,u.vPA)("idle");errorMessage=(0,u.vPA)(null);documentData=(0,u.vPA)({});availableContentCategories=(0,u.vPA)(void 0);_filterResolvedUuids=(0,u.vPA)(void 0);documentRefs=(0,v.EW)(()=>{const t=new Set;return(void 0!==this._filterResolvedUuids()?this._filterResolvedUuids()??[]:this.uuids()??[]).map(M).filter(o=>!!o).filter(o=>!t.has(o)&&(t.add(o),!0)).map(o=>({id:o}))});customOverlayActions=(0,v.EW)(()=>{const t=this.projectId();return[...t?[{label:"Open in Cue",icon:"external-link",action:n=>{const d=n.rowData;window.open(`https://cue.qaecy.com/r/${encodeURIComponent(t)}/${encodeURIComponent(d.id)}`,"_blank","noopener,noreferrer")}}]:[],...(this.customMenuItems()||[]).map(n=>({label:n.label,icon:n.icon,action:d=>{n.action(d.rowData,d)}}))]});handlers=(0,v.EW)(()=>{var t=this;const e=this._docs();if(e)return{requestData:(o=(0,D.A)(function*(n){const d=n.map(M).filter(l=>!!l),r=d.filter(l=>!t.documentData()[l]);if(console.debug("[CueDocumentListWC] requestData",{requestedCount:d.length,missingCount:r.length,missing:r}),r.length)try{const l=e,h=t.simple()&&l.fetchDocumentDataSimple?yield l.fetchDocumentDataSimple(r):yield e.fetchDocumentData(r);console.debug("[CueDocumentListWC] fetchDocumentData resolved",{fetchedCount:Object.keys(h).length,ids:Object.keys(h)});const C={};Object.values(h).forEach(f=>{C[f.id]=function P(c){return{id:c.id,path:c.path,suffix:c.suffix,size:c.size,contentIRI:c.contentIRI,providerId:c.providerId,tags:c.tags??[],summary:c.summary??"",categories:c.categories??[],subject:c.subject,relevance:0}}(f)}),Object.keys(C).length>0&&t.documentData.update(f=>({...f,...C}))}catch(l){console.error("[CueDocumentListWC] Failed to fetch document data:",l),t.errorMessage.set(l instanceof Error?l.message:String(l)),t.state.set("error")}}),function(d){return o.apply(this,arguments)}),requestDownload:function(){var o=(0,D.A)(function*(n){const d=t._cue(),r=t.projectId();if(d&&r)try{const l=yield d.storage.getDownloadUrl(r,n.id,n.suffix,"raw"),h=yield fetch(l);if(!h.ok)throw new Error(`Download failed: ${h.status} ${h.statusText}`);const C=yield h.blob(),f=(0,_.M)(n.path)||`${n.id}${n.suffix||""}`;(0,g.KE)(C,f)}catch(l){console.error("[CueDocumentListWC] Failed to download document:",l)}});return function(d){return o.apply(this,arguments)}}(),requestOpen:(o,n)=>{console.log("[CueDocumentListWC] requestOpen",{documentUUID:o,document:n})},requestOpenInDir:(o,n)=>{console.log("[CueDocumentListWC] requestOpenInDir",{documentUUID:o,document:n})}};var o});_cue=(0,u.vPA)(void 0);_docs=(0,u.vPA)(void 0);_ownedView;_inputWarningTimer;_unsubscribeCategories;_lastSetupSignature;constructor(){this._inputWarningTimer=setTimeout(()=>{this.projectId()||console.warn('[cue-document-list] Required input "projectId" is not set. Pass the Cue project ID to load documents.'),this.sdkState()||console.warn('[cue-document-list] Required input "sdkState" is not set. Pass a { cue, view, or documents } object to enable document loading.')},3e3),(0,u.QZP)(()=>{const t=this.projectId(),e=this.sdkState(),o=e?.language??"en";if(console.debug("[CueDocumentListWC] input state changed",{projectId:t,uuids:this.uuids().length,hasSdkState:!!e,hasCue:!!e?.cue,hasView:!!e?.view,hasDocuments:!!e?.documents}),!t||!e)return this._clearRuntimeState(),void this.state.set("idle");const n={projectId:t,cue:e.cue,view:e.view,documents:e.documents,language:o,simple:this.simple()};if(this._isSameSetupSignature(n))return this.state.set("ready"),void this.errorMessage.set(null);this._setupFromSdkState(t,e),this._lastSetupSignature=n,this.state.set("ready"),this.errorMessage.set(null)}),(0,u.QZP)(()=>{const t=this.suffixes(),e=this.mimeTypes(),o=this.contentCategories(),n=this._docs();void 0!==t||void 0!==e||void 0!==o?this._fetchByFilter(t,e,o,n):this._filterResolvedUuids.set(void 0)}),(0,u.QZP)(()=>{const t=new Set(this.documentRefs().map(e=>e.id));this.documentData.update(e=>Object.fromEntries(Object.entries(e).filter(([n])=>t.has(n))))})}ngOnDestroy(){clearTimeout(this._inputWarningTimer),this._cleanupOwnedView(),this._unsubscribeCategories?.(),this._unsubscribeCategories=void 0}_setupFromSdkState(t,e){const o=e.language??"en";if(this.documentData.set({}),this._cleanupOwnedView(),this._unsubscribeCategories?.(),this._unsubscribeCategories=void 0,this.availableContentCategories.set(e.availableContentCategories?e.availableContentCategories:void 0),e.documents)return e.documents.setLanguage(o),this._docs.set(e.documents),void this._cue.set(e.cue);if(e.view)return e.view.setLanguage(o),this._docs.set(e.view.documents),this._cue.set(e.cue),void(this.simple()||this._bindCategoriesFromView(e.view));if(e.cue){if(this.simple())return this._docs.set(e.cue.createProjectDocuments(t)),this._cue.set(e.cue),void this.availableContentCategories.set(void 0);const n=e.cue.createProjectView(t,{language:o});return this._ownedView=n,this._docs.set(n.documents),this._cue.set(e.cue),void this._bindCategoriesFromView(n)}this._docs.set(void 0),this._cue.set(void 0),this.errorMessage.set("sdkState must include cue, view, or documents to load data."),this.state.set("error")}_bindCategoriesFromView(t){const e=()=>{this.availableContentCategories.set(t.availableContentCategories.get())};e(),this._unsubscribeCategories=t.availableContentCategories.subscribe(e)}_clearRuntimeState(){this._cleanupOwnedView(),this._unsubscribeCategories?.(),this._unsubscribeCategories=void 0,this._docs.set(void 0),this._cue.set(void 0),this.documentData.set({}),this.availableContentCategories.set(void 0),this.errorMessage.set(null),this._lastSetupSignature=void 0}_cleanupOwnedView(){this._ownedView&&(this._ownedView.destroy(),this._ownedView=void 0)}_fetchByFilter(t,e,o,n){var d=this;return(0,D.A)(function*(){if(n){d.state.set("loading");try{let r;if(void 0!==t&&t.length>0)r=yield n.documentsBySuffix(t);else if(void 0!==e&&e.length>0)r=yield n.documentsByMime(e);else{if(!(void 0!==o&&o.length>0))return d._filterResolvedUuids.set([]),void d.state.set("ready");r=yield n.documentsByContentCategory(o)}d._filterResolvedUuids.set(r.map(l=>l.uuid)),d.state.set("ready")}catch(r){console.error("[CueDocumentListWC] Failed to fetch documents by filter",r),d.errorMessage.set(r instanceof Error?r.message:"Failed to load documents."),d.state.set("error")}}else d._filterResolvedUuids.set([])})()}_isSameSetupSignature(t){const e=this._lastSetupSignature;return!!e&&e.projectId===t.projectId&&e.cue===t.cue&&e.view===t.view&&e.documents===t.documents&&e.language===t.language&&e.simple===t.simple}static \u0275fac=function(e){return new(e||c)};static \u0275cmp=s.VBU({type:c,selectors:[["cue-document-list"]],inputs:{projectId:[1,"projectId"],uuids:[1,"uuids"],suffixes:[1,"suffixes"],mimeTypes:[1,"mimeTypes"],contentCategories:[1,"contentCategories"],sdkState:[1,"sdkState"],detailedView:[1,"detailedView"],simple:[1,"simple"],pageSize:[1,"pageSize"],prefetchPages:[1,"prefetchPages"],showOpenInDocumentViewerAction:[1,"showOpenInDocumentViewerAction"],showOpenInFileManagerAction:[1,"showOpenInFileManagerAction"],customMenuItems:[1,"customMenuItems"],showLogo:[1,"showLogo"],variant:[1,"variant"]},outputs:{clickedDocument:"clickedDocument",clickedDownloadDocument:"clickedDownloadDocument",clickedOpenInDir:"clickedOpenInDir",clickedOpen:"clickedOpen"},decls:2,vars:1,consts:[["direction","column","align","center","justify","center",2,"height","100%","width","100%","padding","8px"],[2,"position","relative","width","100%",3,"cueLogoLoader"],[2,"color","#c44","font-size","13px"],[3,"clickedDocument","clickedDownloadDocument","clickedOpenInDir","clickedOpen","documentRefs","documentData","handlers","availableContentCategories","detailedView","simple","pageSize","prefetchPages","showOpenInDocumentViewerAction","showOpenInFileManagerAction","customOverlayActions","variant"],[2,"position","absolute","top","8px","left","8px","z-index","5",3,"projectId"]],template:function(e,o){1&e&&s.nVh(0,E,3,1,"cue-flexcontainer",0)(1,j,3,14,"div",1),2&e&&s.vxM("error"===o.state()?0:1)},dependencies:[O.g,a.n,p.Typography,b.k,L.x],styles:["[_nghost-%COMP%]{display:block;width:100%}"],changeDetection:0})}return c})()},2065(I,w,m){function u(g,_,a="text/plain"){return function D(g,_="data.zip"){const a=document.createElement("a"),p=URL.createObjectURL(g);a.href=p,a.download=_,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(p)}(new Blob([g],{type:a}),_)}function v(g,_){const a=document.createElement("a");a.style.display="hidden",a.setAttribute("href",window.URL.createObjectURL(g)),a.setAttribute("download",_),document.body.appendChild(a),a.click(),a.remove()}m.d(w,{KE:()=>v,YN:()=>u})}}]);
package/802.js CHANGED
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[802],{5137(R,v,a){a.d(v,{BlockProjectDocuments:()=>G});var _=a(467),d=a(7705),u=a(5802),r=a(2271),D=a(6114),g=a(7993),M=a(3615),h=a(1493),k=a(9352),B=a(2245),S=a(5381),t=a(5547);const E=i=>({percent:i}),z=i=>({count:i});function O(i,m){if(1&i){const e=t.RV6();t.j41(0,"cue-block-documents-by-suffix",11),t.bIt("navigated",function(c){u.eBV(e);const s=t.XpG();return u.Njj(s.handleNavigated(c))}),t.k0s()}if(2&i){t.XpG();const e=t.r8f(2),n=t.r8f(4);t.Y8G("data",e)("config",n)}}function T(i,m){if(1&i){const e=t.RV6();t.j41(0,"cue-block-documents-by-content-category",11),t.bIt("navigated",function(c){u.eBV(e);const s=t.XpG();return u.Njj(s.handleNavigated(c))}),t.k0s()}if(2&i){t.XpG();const e=t.r8f(3),n=t.r8f(4);t.Y8G("data",e)("config",n)}}function N(i,m){if(1&i&&(t.nrm(0,"cue-typography",7),t.nI1(1,"transloco")),2&i){const e=t.XpG();t.Y8G("innerHTML",t.i5U(1,1,"components.contentBlocks.projectDocuments.pctOpenFormats",t.eq3(4,E,e.openFormatPct())),t.npT)}}function A(i,m){if(1&i){const e=t.RV6();t.j41(0,"cue-typography",12),t.nI1(1,"transloco"),t.bIt("click",function(){u.eBV(e);const c=t.XpG();return u.Njj(c.getDuplicates())}),t.k0s()}2&i&&t.Y8G("innerHTML",t.i5U(1,1,1===m?"components.contentBlocks.projectDocuments.duplicateFilesSingular":"components.contentBlocks.projectDocuments.duplicateFilesPlural",t.eq3(4,z,m)),t.npT)}function W(i,m){if(1&i&&(t.j41(0,"cue-typography",10),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.SpI("\u2696\ufe0f ",e.humanSize()," ")}}function L(i,m){if(1&i&&(t.j41(0,"cue-typography",10),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.E5c("",e.filterKey(),": ",e.humanSizeFiltered()," (",e.countFiltered(),")")}}let G=(()=>{class i{data=(0,d.hFB)(void 0);_data=(0,u.vPA)(void 0);constructor(){let e=null;(0,u.QZP)(()=>{const n=this.data();null!==e&&clearTimeout(e),(0,r.O8)(()=>this._data.set(n)),e=setTimeout(()=>{e=null,(0,r.O8)(()=>this._data.set(this.data()))},100)})}config=d.hFB.required();handlers=(0,r.EW)(()=>this.config().handlers);filterKey=(0,u.vPA)("");bySuffix=(0,r.EW)(()=>{const e=this._data();if(e?.documentsBySuffix&&0!==Object.keys(e.documentsBySuffix).length)return{documents:e.documentsBySuffix}});byContentCategory=(0,r.EW)(()=>{const e=this._data();if(e?.documentsByContentCategory&&0!==Object.keys(e.documentsByContentCategory).length)return{documents:e.documentsByContentCategory}});duplicateCount=(0,r.EW)(()=>this._data()?.duplicateCount??0);size=(0,r.EW)(()=>{const e=this._data();if(!e)return 0;const n=Object.values(e.documentsBySuffix||{}).reduce((s,o)=>s+(o?.size||0),0),c=Object.values(e.documentsByContentCategory||{}).reduce((s,o)=>s+(o?.size||0),0);return Math.max(n,c)});documentCount=(0,r.EW)(()=>{const e=this._data();if(!e)return 0;const n=Object.values(e.documentsBySuffix||{}).reduce((s,o)=>s+(o?.count||0),0),c=Object.values(e.documentsByContentCategory||{}).reduce((s,o)=>s+(o?.count||0),0);return Math.max(n,c)});sizeFiltered=(0,u.vPA)(0);countFiltered=(0,u.vPA)(0);humanSize=(0,r.EW)(()=>(0,h.b)(this.size()));humanSizeFiltered=(0,r.EW)(()=>(0,h.b)(this.sizeFiltered()));openFormatPct=(0,r.EW)(()=>{const e=this._data();if(!e?.documentsBySuffix)return 0;let n=0,c=0;for(const[o,l]of Object.entries(e.documentsBySuffix)){if(!l)continue;const p=Number(l.count||0);n+=p;const x=o.toLowerCase().trim(),F=x.startsWith(".")?x:`.${x}`;D.V[F]?.open&&(c+=p)}return n>0?Math.round(c/n*100):null});configWithFilterResolver=(0,r.EW)(()=>{var e=this;const n=this.config();return{...n,handlers:{...n.handlers,docListFilterRequest:(c=(0,_.A)(function*(s,o){if(console.log("[ProjectDocuments] docListFilterRequest",s,o),!o||0===o.length)return;const l="contentCat"===s?(i=>{const m=i.split("#").pop()??i,e={AgreementDocument:"Agreement",ArchitecturalDesignDocument:"Architectural Design",AsBuiltDocument:"As-Built",BudgetEstimateDocument:"Budget Estimate",CertificationDocument:"Certification",ComplianceDocument:"Compliance",CorrespondenceDocument:"Correspondence",ConstructionContract:"Construction Contract",ConstructionProcessDocument:"Construction Process",ContractCondition:"Contract Condition",ContractRole:"Contract Role",ContractualDocument:"Contract",CostControlDocument:"Cost Control",DesignDocument:"Design Document",EmailAddress:"Email Address",EngineeringDesignDocument:"Engineering Design",FinancialAdministrativeDocument:"Financial/Administrative",FunctionalRequirementsDocument:"Functional Requirements",InspectionDocument:"Inspection",InsuranceBondDocument:"Insurance/Bond",InteriorDesignDocument:"Interior Design",MarketingCloseoutDocument:"Marketing Closeout",MiscDocument:"Miscellaneous",OperationManual:"Operation Manual",OperationsMaintenanceDocument:"Operations & Maintenance",OperationsManualDocument:"Operations Manual",OtherDocument:"Other",OtherContent:"Other Content",ProgressStatusReport:"Progress Status Report",QualityAssuranceDocument:"Quality Assurance",QualityControlDocument:"Quality Control",RegulatoryComplianceDocument:"Regulatory Compliance",SafetyDocument:"Safety",ScheduleDocument:"Schedule",SiteAssessmentDocument:"Site Assessment",TechnicalRequirementsDocument:"Technical Requirements",TechnicalSpecificationDocument:"Technical Specification",TenderingDocument:"Tendering Document",TermsAndConditionsDocument:"Terms & Conditions"};return void 0===e[m]&&console.log(`No pretty label for category: ${m}`),e[m]??m})(o[0]):o[0];if(e.filterKey.set(l),"suffix"===s){const f=e._data()?.documentsBySuffix;if(f){const j=o.reduce((C,y)=>C+(f[y.toLowerCase()]?.size||0),0),P=o.reduce((C,y)=>C+(f[y.toLowerCase()]?.count||0),0);e.sizeFiltered.set(j),e.countFiltered.set(P)}}else if("contentCat"===s){const f=e._data()?.documentsByContentCategory;if(f){const j=o.reduce((C,y)=>C+(f[y]?.size||0),0),P=o.reduce((C,y)=>C+(f[y]?.count||0),0);e.sizeFiltered.set(j),e.countFiltered.set(P)}}const p=n.handlers?.requestDocumentsByFilter;if(!p)return void console.warn("No requestDocumentsByFilter handler defined");const F=yield p([{type:"suffix"===s?"suffix":"content",included:o,excluded:[]}]);return{ids:F.map(f=>({id:f})),totalCount:F.length}}),function(o,l){return c.apply(this,arguments)})}};var c});handleNavigated(e){if(!e)return this.sizeFiltered.set(0),this.countFiltered.set(0),void this.filterKey.set("");this.filterKey.set(e.label);const n=this._data();if(!n)return;let c=0,s=0;if("suffix"===e.filterBy){const o=n.documentsBySuffix;e.values.forEach(l=>{const p=l.toLowerCase();c+=o[p]?.size||0,s+=o[p]?.count||0})}else if("contentCat"===e.filterBy){const o=n.documentsByContentCategory;e.values.forEach(l=>{c+=o[l]?.size||0,s+=o[l]?.count||0})}this.sizeFiltered.set(c),this.countFiltered.set(s)}handleCanvasClick(){this.sizeFiltered.set(0),this.countFiltered.set(0)}getDuplicates(){var e=this;return(0,_.A)(function*(){const n=e.handlers()?.subsequentBlockRequest;if(void 0===n)return void console.warn("No handler for subsequent block request");const c=e.handlers()?.documentDuplicatesRequest;if(!c)return void console.warn("No documentDuplicatesRequest handler defined");const s=yield c();n({id:"document-duplicates",config:e.config(),data:s,focusOnAdd:!0},"Duplicates",!0)})()}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=t.VBU({type:i,selectors:[["cue-block-project-documents"]],inputs:{data:[1,"data"],config:[1,"config"]},decls:19,vars:13,consts:[["direction","column"],[1,"container",3,"click"],["id","chart-1",1,"chart"],[3,"data","config"],["id","chart-2",1,"chart"],["direction","column","align","center",1,"stats"],[1,"stat-line"],["size","l",3,"innerHTML"],["size","l",1,"clickable",3,"innerHTML"],["direction","column","align","center",1,"sizes"],["size","l"],[3,"navigated","data","config"],["size","l",1,"clickable",3,"click","innerHTML"]],template:function(n,c){if(1&n&&(t.j41(0,"cue-flexcontainer",0)(1,"div",1),t.bIt("click",function(){return c.handleCanvasClick()}),t.SS7(2)(3)(4),t.j41(5,"div",2),t.nVh(6,O,1,2,"cue-block-documents-by-suffix",3),t.k0s(),t.j41(7,"div",4),t.nVh(8,T,1,2,"cue-block-documents-by-content-category",3),t.k0s(),t.j41(9,"cue-flexcontainer",5)(10,"div",6),t.nVh(11,N,2,6,"cue-typography",7),t.k0s(),t.j41(12,"div",6),t.nVh(13,A,2,6,"cue-typography",8),t.k0s()(),t.j41(14,"cue-flexcontainer",9)(15,"div",6),t.nVh(16,W,2,1,"cue-typography",10),t.k0s(),t.j41(17,"div",6),t.nVh(18,L,2,3,"cue-typography",10),t.k0s()()()()),2&n){let s;t.R7$(2);const o=t.bH3(c.bySuffix());t.R7$();const l=t.bH3(c.byContentCategory());t.R7$(),t.bH3(c.configWithFilterResolver()),t.R7$(),t.xc7("opacity",o?1:0),t.R7$(),t.vxM(o?6:-1),t.R7$(),t.xc7("opacity",l?1:0),t.R7$(),t.vxM(l?8:-1),t.R7$(3),t.vxM(null!==c.openFormatPct()?11:-1),t.R7$(2),t.vxM((s=c.duplicateCount())?13:-1,s),t.R7$(3),t.vxM(c.size()>0?16:-1),t.R7$(2),t.vxM(c.sizeFiltered()>0?18:-1)}},dependencies:[B.Typography,S.n,g.o,M.Y,k.Kj],styles:[".container[_ngcontent-%COMP%]{height:700px;width:100%;position:relative;overflow:hidden}.chart[_ngcontent-%COMP%]{position:absolute;width:470px;height:350px;transition:opacity .5s ease-in-out}#chart-1[_ngcontent-%COMP%]{top:20px;left:0}#chart-2[_ngcontent-%COMP%]{bottom:50px;right:0}.stats[_ngcontent-%COMP%]{position:absolute;right:230px;top:180px;transform:translate(50%);min-height:80px;justify-content:center}.sizes[_ngcontent-%COMP%]{position:absolute;left:230px;bottom:180px;transform:translate(-50%);min-height:80px;justify-content:center}.stat-line[_ngcontent-%COMP%]{height:32px;display:flex;align-items:center;justify-content:center}.clickable[_ngcontent-%COMP%]:hover{cursor:pointer;transform:scale(1.05)}"],changeDetection:0})}return i})()},6170(R,v,a){a.d(v,{R:()=>D});var _=a(7705),d=a(5802),u=a(2271),r=a(5547);let D=(()=>{class g{destroyRef=(0,d.WQX)(d.abz);_isDarkMode=(0,d.vPA)(this.hasDarkClass());isDarkMode=(0,u.EW)(()=>this._isDarkMode());darkModeChange=(0,_.CGW)();constructor(){const h=new MutationObserver(b=>{b.forEach(k=>{if("attributes"===k.type&&"class"===k.attributeName){const B=this.hasDarkClass();B!==this._isDarkMode()&&this._isDarkMode.set(B)}})});h.observe(document.body,{attributes:!0,attributeFilter:["class"]}),this.destroyRef.onDestroy(()=>h.disconnect()),(0,d.QZP)(()=>{this.darkModeChange.emit(this._isDarkMode()),document.documentElement.style.colorScheme=this._isDarkMode()?"dark":"light"})}hasDarkClass(){return document.body.classList.contains("dark")}toggleDarkMode(){document.body.classList.toggle("dark")}static \u0275fac=function(b){return new(b||g)};static \u0275dir=r.FsC({type:g,selectors:[["","cueDarkMode",""]],outputs:{darkModeChange:"darkModeChange"},exportAs:["darkModeDetector"]})}return g})()},1493(R,v,a){function _(d,u=!1,r=1){const D=u?1e3:1024;if(Math.abs(d)<D)return d+" B";const g=u?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let M=-1;const h=10**r;do{d/=D,++M}while(Math.round(Math.abs(d)*h)/h>=D&&M<g.length-1);return d.toFixed(r)+" "+g[M]}a.d(v,{b:()=>_})}}]);
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[802],{5137(j,E,o){o.d(E,{BlockProjectDocuments:()=>L});var l=o(467),m=o(7705),u=o(5802),p=o(2271),b=o(6114),g=o(7993),y=o(3615),n=o(1493),h=o(9352),v=o(2245),P=o(5381),e=o(5547);const _=s=>({percent:s}),I=s=>({count:s});function d(s,x){if(1&s){const t=e.RV6();e.j41(0,"cue-block-documents-by-suffix",11),e.bIt("navigated",function(c){u.eBV(t);const r=e.XpG();return u.Njj(r.handleNavigated(c))}),e.k0s()}if(2&s){e.XpG();const t=e.r8f(2),i=e.r8f(4);e.Y8G("data",t)("config",i)}}function D(s,x){if(1&s){const t=e.RV6();e.j41(0,"cue-block-documents-by-content-category",11),e.bIt("navigated",function(c){u.eBV(t);const r=e.XpG();return u.Njj(r.handleNavigated(c))}),e.k0s()}if(2&s){e.XpG();const t=e.r8f(3),i=e.r8f(4);e.Y8G("data",t)("config",i)}}function C(s,x){if(1&s&&(e.nrm(0,"cue-typography",7),e.nI1(1,"transloco")),2&s){const t=e.XpG();e.Y8G("innerHTML",e.i5U(1,1,"components.contentBlocks.projectDocuments.pctOpenFormats",e.eq3(4,_,t.openFormatPct())),e.npT)}}function B(s,x){if(1&s){const t=e.RV6();e.j41(0,"cue-typography",12),e.nI1(1,"transloco"),e.bIt("click",function(){u.eBV(t);const c=e.XpG();return u.Njj(c.getDuplicates())}),e.k0s()}2&s&&e.Y8G("innerHTML",e.i5U(1,1,1===x?"components.contentBlocks.projectDocuments.duplicateFilesSingular":"components.contentBlocks.projectDocuments.duplicateFilesPlural",e.eq3(4,I,x)),e.npT)}function A(s,x){if(1&s&&(e.j41(0,"cue-typography",10),e.EFF(1),e.k0s()),2&s){const t=e.XpG();e.R7$(),e.SpI("\u2696\ufe0f ",t.humanSize()," ")}}function W(s,x){if(1&s&&(e.j41(0,"cue-typography",10),e.EFF(1),e.k0s()),2&s){const t=e.XpG();e.R7$(),e.E5c("",t.filterKey(),": ",t.humanSizeFiltered()," (",t.countFiltered(),")")}}let L=(()=>{class s{data=(0,m.hFB)(void 0);_data=(0,u.vPA)(void 0);constructor(){let t=null;(0,u.QZP)(()=>{const i=this.data();null!==t&&clearTimeout(t),(0,p.O8)(()=>this._data.set(i)),t=setTimeout(()=>{t=null,(0,p.O8)(()=>this._data.set(this.data()))},100)})}config=m.hFB.required();handlers=(0,p.EW)(()=>this.config().handlers);filterKey=(0,u.vPA)("");bySuffix=(0,p.EW)(()=>{const t=this._data();if(t?.documentsBySuffix&&0!==Object.keys(t.documentsBySuffix).length)return{documents:t.documentsBySuffix}});byContentCategory=(0,p.EW)(()=>{const t=this._data();if(t?.documentsByContentCategory&&0!==Object.keys(t.documentsByContentCategory).length)return{documents:t.documentsByContentCategory}});duplicateCount=(0,p.EW)(()=>this._data()?.duplicateCount??0);size=(0,p.EW)(()=>{const t=this._data();if(!t)return 0;const i=Object.values(t.documentsBySuffix||{}).reduce((r,a)=>r+(a?.size||0),0),c=Object.values(t.documentsByContentCategory||{}).reduce((r,a)=>r+(a?.size||0),0);return Math.max(i,c)});documentCount=(0,p.EW)(()=>{const t=this._data();if(!t)return 0;const i=Object.values(t.documentsBySuffix||{}).reduce((r,a)=>r+(a?.count||0),0),c=Object.values(t.documentsByContentCategory||{}).reduce((r,a)=>r+(a?.count||0),0);return Math.max(i,c)});sizeFiltered=(0,u.vPA)(0);countFiltered=(0,u.vPA)(0);humanSize=(0,p.EW)(()=>(0,n.b)(this.size()));humanSizeFiltered=(0,p.EW)(()=>(0,n.b)(this.sizeFiltered()));openFormatPct=(0,p.EW)(()=>{const t=this._data();if(!t?.documentsBySuffix)return 0;let i=0,c=0;for(const[a,M]of Object.entries(t.documentsBySuffix)){if(!M)continue;const k=Number(M.count||0);i+=k;const R=a.toLowerCase().trim(),N=R.startsWith(".")?R:`.${R}`;b.V[N]?.open&&(c+=k)}return i>0?Math.round(c/i*100):null});configWithFilterResolver=(0,p.EW)(()=>{var t=this;const i=this.config();return{...i,handlers:{...i.handlers,docListFilterRequest:(c=(0,l.A)(function*(r,a){if(console.log("[ProjectDocuments] docListFilterRequest",r,a),!a||0===a.length)return;const M="contentCat"===r?(s=>{const x=s.split("#").pop()??s,t={AgreementDocument:"Agreement",ArchitecturalDesignDocument:"Architectural Design",AsBuiltDocument:"As-Built",BudgetEstimateDocument:"Budget Estimate",CertificationDocument:"Certification",ComplianceDocument:"Compliance",CorrespondenceDocument:"Correspondence",ConstructionContract:"Construction Contract",ConstructionProcessDocument:"Construction Process",ContractCondition:"Contract Condition",ContractRole:"Contract Role",ContractualDocument:"Contract",CostControlDocument:"Cost Control",DesignDocument:"Design Document",EmailAddress:"Email Address",EngineeringDesignDocument:"Engineering Design",FinancialAdministrativeDocument:"Financial/Administrative",FunctionalRequirementsDocument:"Functional Requirements",InspectionDocument:"Inspection",InsuranceBondDocument:"Insurance/Bond",InteriorDesignDocument:"Interior Design",MarketingCloseoutDocument:"Marketing Closeout",MiscDocument:"Miscellaneous",OperationManual:"Operation Manual",OperationsMaintenanceDocument:"Operations & Maintenance",OperationsManualDocument:"Operations Manual",OtherDocument:"Other",OtherContent:"Other Content",ProgressStatusReport:"Progress Status Report",QualityAssuranceDocument:"Quality Assurance",QualityControlDocument:"Quality Control",RegulatoryComplianceDocument:"Regulatory Compliance",SafetyDocument:"Safety",ScheduleDocument:"Schedule",SiteAssessmentDocument:"Site Assessment",TechnicalRequirementsDocument:"Technical Requirements",TechnicalSpecificationDocument:"Technical Specification",TenderingDocument:"Tendering Document",TermsAndConditionsDocument:"Terms & Conditions"};return void 0===t[x]&&console.log(`No pretty label for category: ${x}`),t[x]??x})(a[0]):a[0];if(t.filterKey.set(M),"suffix"===r){const T=t._data()?.documentsBySuffix;if(T){const z=a.reduce((F,O)=>F+(T[O.toLowerCase()]?.size||0),0),S=a.reduce((F,O)=>F+(T[O.toLowerCase()]?.count||0),0);t.sizeFiltered.set(z),t.countFiltered.set(S)}}else if("contentCat"===r){const T=t._data()?.documentsByContentCategory;if(T){const z=a.reduce((F,O)=>F+(T[O]?.size||0),0),S=a.reduce((F,O)=>F+(T[O]?.count||0),0);t.sizeFiltered.set(z),t.countFiltered.set(S)}}const k=i.handlers?.requestDocumentsByFilter;if(!k)return void console.warn("No requestDocumentsByFilter handler defined");const N=yield k([{type:"suffix"===r?"suffix":"content",included:a,excluded:[]}]);return{ids:N.map(T=>({id:T})),totalCount:N.length}}),function(a,M){return c.apply(this,arguments)})}};var c});handleNavigated(t){if(!t)return this.sizeFiltered.set(0),this.countFiltered.set(0),void this.filterKey.set("");this.filterKey.set(t.label);const i=this._data();if(!i)return;let c=0,r=0;if("suffix"===t.filterBy){const a=i.documentsBySuffix;t.values.forEach(M=>{const k=M.toLowerCase();c+=a[k]?.size||0,r+=a[k]?.count||0})}else if("contentCat"===t.filterBy){const a=i.documentsByContentCategory;t.values.forEach(M=>{c+=a[M]?.size||0,r+=a[M]?.count||0})}this.sizeFiltered.set(c),this.countFiltered.set(r)}handleCanvasClick(){this.sizeFiltered.set(0),this.countFiltered.set(0)}getDuplicates(){var t=this;return(0,l.A)(function*(){const i=t.handlers()?.subsequentBlockRequest;if(void 0===i)return void console.warn("No handler for subsequent block request");const c=t.handlers()?.documentDuplicatesRequest;if(!c)return void console.warn("No documentDuplicatesRequest handler defined");const r=yield c();i({id:"document-duplicates",config:t.config(),data:r,focusOnAdd:!0},"Duplicates",!0)})()}static \u0275fac=function(i){return new(i||s)};static \u0275cmp=e.VBU({type:s,selectors:[["cue-block-project-documents"]],inputs:{data:[1,"data"],config:[1,"config"]},decls:19,vars:13,consts:[["direction","column"],[1,"container",3,"click"],["id","chart-1",1,"chart"],[3,"data","config"],["id","chart-2",1,"chart"],["direction","column","align","center",1,"stats"],[1,"stat-line"],["size","l",3,"innerHTML"],["size","l",1,"clickable",3,"innerHTML"],["direction","column","align","center",1,"sizes"],["size","l"],[3,"navigated","data","config"],["size","l",1,"clickable",3,"click","innerHTML"]],template:function(i,c){if(1&i&&(e.j41(0,"cue-flexcontainer",0)(1,"div",1),e.bIt("click",function(){return c.handleCanvasClick()}),e.SS7(2)(3)(4),e.j41(5,"div",2),e.nVh(6,d,1,2,"cue-block-documents-by-suffix",3),e.k0s(),e.j41(7,"div",4),e.nVh(8,D,1,2,"cue-block-documents-by-content-category",3),e.k0s(),e.j41(9,"cue-flexcontainer",5)(10,"div",6),e.nVh(11,C,2,6,"cue-typography",7),e.k0s(),e.j41(12,"div",6),e.nVh(13,B,2,6,"cue-typography",8),e.k0s()(),e.j41(14,"cue-flexcontainer",9)(15,"div",6),e.nVh(16,A,2,1,"cue-typography",10),e.k0s(),e.j41(17,"div",6),e.nVh(18,W,2,3,"cue-typography",10),e.k0s()()()()),2&i){let r;e.R7$(2);const a=e.bH3(c.bySuffix());e.R7$();const M=e.bH3(c.byContentCategory());e.R7$(),e.bH3(c.configWithFilterResolver()),e.R7$(),e.xc7("opacity",a?1:0),e.R7$(),e.vxM(a?6:-1),e.R7$(),e.xc7("opacity",M?1:0),e.R7$(),e.vxM(M?8:-1),e.R7$(3),e.vxM(null!==c.openFormatPct()?11:-1),e.R7$(2),e.vxM((r=c.duplicateCount())?13:-1,r),e.R7$(3),e.vxM(c.size()>0?16:-1),e.R7$(2),e.vxM(c.sizeFiltered()>0?18:-1)}},dependencies:[v.Typography,P.n,g.o,y.Y,h.Kj],styles:[".container[_ngcontent-%COMP%]{height:700px;width:100%;position:relative;overflow:hidden}.chart[_ngcontent-%COMP%]{position:absolute;width:470px;height:350px;transition:opacity .5s ease-in-out}#chart-1[_ngcontent-%COMP%]{top:20px;left:0}#chart-2[_ngcontent-%COMP%]{bottom:50px;right:0}.stats[_ngcontent-%COMP%]{position:absolute;right:230px;top:180px;transform:translate(50%);min-height:80px;justify-content:center}.sizes[_ngcontent-%COMP%]{position:absolute;left:230px;bottom:180px;transform:translate(-50%);min-height:80px;justify-content:center}.stat-line[_ngcontent-%COMP%]{height:32px;display:flex;align-items:center;justify-content:center}.clickable[_ngcontent-%COMP%]:hover{cursor:pointer;transform:scale(1.05)}"],changeDetection:0})}return s})()},9495(j,E,o){o.d(E,{I:()=>b});var l=o(7705),m=o(5802),u=o(5547);const p=["inputEl"];let b=(()=>{class g{value=(0,l.geq)("");placeholder=(0,l.hFB)("");autofocus=(0,l.hFB)(!1);valueChange=(0,l.CGW)();save=(0,l.CGW)();cancel=(0,l.CGW)();inputEl;constructor(){(0,m.QZP)(()=>{const n=this.value(),f=this.inputEl?.nativeElement;f&&f.innerText.replace(/\n$/,"")!==n&&(f.innerText=n)})}ngAfterViewInit(){const n=this.inputEl?.nativeElement;n&&(n.innerText=this.value()),this.autofocus()&&n&&n.focus()}onInput(n){const h=n.target.innerText.replace(/\n$/,"");this.value.set(h),this.valueChange.emit(h)}onEnter(n){n.preventDefault(),this.save.emit()}onEscape(n){n.preventDefault(),this.cancel.emit()}onBlur(){this.save.emit()}static \u0275fac=function(f){return new(f||g)};static \u0275cmp=u.VBU({type:g,selectors:[["cue-inline-input"]],viewQuery:function(f,h){if(1&f&&u.GBs(p,5),2&f){let v;u.mGM(v=u.lsd())&&(h.inputEl=v.first)}},inputs:{value:[1,"value"],placeholder:[1,"placeholder"],autofocus:[1,"autofocus"]},outputs:{value:"valueChange",valueChange:"valueChange",save:"save",cancel:"cancel"},decls:2,vars:1,consts:[["inputEl",""],["contenteditable","true","role","textbox","aria-multiline","true",3,"input","keydown.enter","keydown.escape","blur"]],template:function(f,h){1&f&&(u.rj2(0,"span",1,0),u.VwU("input",function(P){return h.onInput(P)})("keydown.enter",function(P){return h.onEnter(P)})("keydown.escape",function(P){return h.onEscape(P)})("blur",function(){return h.onBlur()}),u.eux()),2&f&&u.BMQ("data-placeholder",h.placeholder())},styles:["[_nghost-%COMP%]{display:inline}span[contenteditable][_ngcontent-%COMP%]{outline:none;-webkit-text-decoration:underline dashed;text-decoration:underline dashed;text-underline-offset:3px;white-space:pre-wrap;word-break:break-word;cursor:text}span[contenteditable][_ngcontent-%COMP%]:empty:before{content:attr(data-placeholder);color:var(--cue-input-placeholder-color, currentColor);opacity:.5;pointer-events:none}"],changeDetection:0})}return g})()},2245(j,E,o){o.r(E),o.d(E,{Typography:()=>e});var l=o(7705),m=o(2271),u=o(7089),p=o(5381),b=o(29),g=o(9495),y=o(5802),n=o(5547);const f=["*"];function h(_,I){if(1&_){const d=n.RV6();n.j41(0,"div",2),n.bIt("input",function(C){y.eBV(d);const B=n.XpG();return y.Njj(B.onInput(C))})("blur",function(C){y.eBV(d);const B=n.XpG();return y.Njj(B.onInput(C))}),n.k0s()}if(2&_){const d=n.XpG();n.Aen(d.getStyles()),n.xc7("font-style",d.italic()?"italic":"normal"),n.Y8G("innerHTML",d.innerHTML(),n.npT)("contentEditable",d.editable())}}function v(_,I){if(1&_&&n.nrm(0,"cue-svg-icon",5),2&_){const d=n.XpG(2);n.xc7("--cue-icon-width",d.infoSize()+"px"),n.Y8G("cueTooltip",d.info())}}function P(_,I){if(1&_){const d=n.RV6();n.j41(0,"div",3),n.bIt("input",function(C){y.eBV(d);const B=n.XpG();return y.Njj(B.onInput(C))})("blur",function(C){y.eBV(d);const B=n.XpG();return y.Njj(B.onInput(C))}),n.SdG(1),n.k0s(),n.nVh(2,v,1,3,"cue-svg-icon",4)}if(2&_){const d=n.XpG();n.Aen(d.getStyles()),n.xc7("font-style",d.italic()?"italic":"normal"),n.Y8G("contentEditable",d.editable()),n.R7$(2),n.vxM(d.info()?2:-1)}}let e=(()=>{class _{_inlineInput=(0,l.sbv)(g.I);hasInlineInput=(0,m.EW)(()=>!!this._inlineInput());as=(0,l.hFB)("div");size=(0,l.hFB)("m");weight=(0,l.hFB)("regular");align=(0,l.hFB)("start");noWrap=(0,l.hFB)(!1);italic=(0,l.hFB)(!1);innerHTML=(0,l.hFB)(null);info=(0,l.hFB)("");editable=(0,l.hFB)(!1);change=(0,l.CGW)();onInput(d){this.editable()&&this.change.emit(d.target.innerText)}getStyles=(0,m.EW)(()=>`\n font-family: var(--cue-font-family);\n font-size: var(--cue-font-${this.size()}-size);\n line-height: var(--cue-font-${this.size()}-line-height);\n letter-spacing: var(--cue-font-${this.size()}-letter-spacing);\n font-weight: var(--cue-font-weight-${this.weight()});\n text-align: ${this.align()};\n ${this.noWrap()?"white-space: nowrap; overflow: hidden; text-overflow: ellipsis;":""}\n `);infoSize=(0,m.EW)(()=>{switch(this.size()){case"xs":return 10;case"s":return 12;case"m":default:return 14;case"l":return 16;case"xl":return 18}});static \u0275fac=function(D){return new(D||_)};static \u0275cmp=n.VBU({type:_,selectors:[["cue-typography"]],contentQueries:function(D,C,B){1&D&&n.C6U(B,C._inlineInput,g.I,5),2&D&&n.NyB()},inputs:{as:[1,"as"],size:[1,"size"],weight:[1,"weight"],align:[1,"align"],noWrap:[1,"noWrap"],italic:[1,"italic"],innerHTML:[1,"innerHTML"],info:[1,"info"],editable:[1,"editable"]},outputs:{change:"change"},ngContentSelectors:f,decls:3,vars:2,consts:[["justify","start","align","center",3,"noGap"],[3,"style","font-style","innerHTML","contentEditable"],[3,"input","blur","innerHTML","contentEditable"],[3,"input","blur","contentEditable"],["name","info",2,"margin-left","4px","vertical-align","super","cursor","pointer",3,"cueTooltip","--cue-icon-width"],["name","info",2,"margin-left","4px","vertical-align","super","cursor","pointer",3,"cueTooltip"]],template:function(D,C){1&D&&(n.NAR(),n.j41(0,"cue-flexcontainer",0),n.nVh(1,h,1,6,"div",1)(2,P,3,6),n.k0s()),2&D&&(n.Y8G("noGap",!0),n.R7$(),n.vxM(C.innerHTML()?1:2))},dependencies:[b.A,u.d,p.n],encapsulation:2})}return _})()},6170(j,E,o){o.d(E,{R:()=>b});var l=o(7705),m=o(5802),u=o(2271),p=o(5547);let b=(()=>{class g{destroyRef=(0,m.WQX)(m.abz);_isDarkMode=(0,m.vPA)(this.hasDarkClass());isDarkMode=(0,u.EW)(()=>this._isDarkMode());darkModeChange=(0,l.CGW)();constructor(){const n=new MutationObserver(f=>{f.forEach(h=>{if("attributes"===h.type&&"class"===h.attributeName){const v=this.hasDarkClass();v!==this._isDarkMode()&&this._isDarkMode.set(v)}})});n.observe(document.body,{attributes:!0,attributeFilter:["class"]}),this.destroyRef.onDestroy(()=>n.disconnect()),(0,m.QZP)(()=>{this.darkModeChange.emit(this._isDarkMode()),document.documentElement.style.colorScheme=this._isDarkMode()?"dark":"light"})}hasDarkClass(){return document.body.classList.contains("dark")}toggleDarkMode(){document.body.classList.toggle("dark")}static \u0275fac=function(f){return new(f||g)};static \u0275dir=p.FsC({type:g,selectors:[["","cueDarkMode",""]],outputs:{darkModeChange:"darkModeChange"},exportAs:["darkModeDetector"]})}return g})()},1493(j,E,o){function l(m,u=!1,p=1){const b=u?1e3:1024;if(Math.abs(m)<b)return m+" B";const g=u?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let y=-1;const n=10**p;do{m/=b,++y}while(Math.round(Math.abs(m)*n)/n>=b&&y<g.length-1);return m.toFixed(p)+" "+g[y]}o.d(E,{b:()=>l})}}]);