"use strict";(self.webpackChunk_esome_dev_ppms=self.webpackChunk_esome_dev_ppms||[]).push([[3838],{23838:(e,t,a)=>{a.r(t),a.d(t,{DataReportSamplesPage:()=>S});var r,n,i,d=a(171),s=(a(68784),a(16682)),o=a(94430),l=a(56765),p=a(28120),y=a(27805),c=a(53421),f=a(77675),m=a(15633),u=a(36179),v=a(51266);function g(e,t,a,r,n,i,d){try{var s=e[i](d),o=s.value}catch(e){return void a(e)}s.done?t(o):Promise.resolve(o).then(r,n)}function h(e){return function(){var t=this,a=arguments;return new Promise((function(r,n){var i=e.apply(t,a);function d(e){g(i,r,n,d,s,"next",e)}function s(e){g(i,r,n,d,s,"throw",e)}d(void 0)}))}}function K(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var S=class extends((0,p.$)(f.h)((0,c.NC)(c.z2)(f.B4))){get context(){var e=(new Date).toISOString().split("T")[0],t=[{name:"workDateRange",type:"date",label:c.z2.t("field.work-date"),operator:"between",value:[e,e]},...this.getDataKeyFilters()];return{title:c.z2.t("title.data-report samples"),help:"dataset/data-report-samples",filters:t}}getDataKeyFilters(){var e;return(null===(e=this.dataKeySet)||void 0===e?void 0:e.dataKeyItems.map(((e,t)=>({type:"string",name:"key_0".concat(t+1),label:c.z2.t(e.tKey),operator:"i_like",width:120}))))||[]}render(){return this.container.src="",(0,o.dy)(r||(r=K(["\n      <ox-filters-form-base\n        .filters=","\n        @filters-change=","\n        ?url-params-sensitive=","\n      ></ox-filters-form-base>\n\n      <iframe></iframe>\n    "])),this.context.filters,(e=>{v.log("filters changed",e.detail),this.renderTemplate(e.detail.filters)}),this.active)}renderTemplate(e){var t,a=e.reduce(((e,t)=>(e[t.name]=t.value,e)),{});Object.assign(a,this.lifecycle.params);var r=this.getDataKeyFilters().map((e=>e.name)),n=e.filter((e=>r.includes(e.name))),{workDateRange:i}=a;if(i[0]&&i[1]&&!(i[0]>i[1])){var d={reportType:a.reportType,reportView:a.reportView,reportTemplate:a.reportTemplate,table:"samples",datasetId:a.datasetId,dataKeySetId:a.dataKeySetId,startDate:i[0],endDate:i[1],dataKeySetItems:JSON.stringify((null===(t=this.dataKeySet)||void 0===t?void 0:t.dataKeyItems)||[]),dataKeyFilters:JSON.stringify(n)},s=(0,u.jy)(d),o="/data-report/".concat(d.reportType,"/");this.container.src="".concat(o,"?").concat(s)}}pageUpdated(e,t){if(this.active){var{dataKeySetId:a}=t.params;this.dataKeySetId=a}}fetchHandler(e){return h((function*(){var{page:t,limit:a,sortings:r=[],filters:n=[]}=e}))()}updated(e){var t=this;return h((function*(){if(e.has("dataKeySetId")){if(!t.dataKeySetId)return void(t.dataKeySet=null);var a=yield y.Lp.query({query:(0,s.ZP)(n||(n=K(["\n          query ($id: String!) {\n            dataKeySet(id: $id) {\n              id\n              name\n              description\n              reportType\n              reportView\n              dataKeyItems {\n                name\n                description\n                dataKey\n                tKey\n              }\n            }\n          }\n        "]))),variables:{id:t.dataKeySetId}});t.dataKeySet=a.data.dataKeySet}}))()}};S.styles=[m.Ix,(0,o.iv)(i||(i=K(["\n      :host {\n        display: flex;\n        flex-direction: column;\n        padding: 0;\n      }\n\n      #container {\n        flex: 1;\n        padding: 0;\n        margin: 0;\n        border: 0;\n      }\n    "])))],(0,d.gn)([(0,l.SB)(),(0,d.w6)("design:type",String)],S.prototype,"dataKeySetId",void 0),(0,d.gn)([(0,l.SB)(),(0,d.w6)("design:type",Object)],S.prototype,"dataKeySet",void 0),(0,d.gn)([(0,l.IO)("iframe"),(0,d.w6)("design:type",HTMLIFrameElement)],S.prototype,"container",void 0),S=(0,d.gn)([(0,l.Mo)("data-report-samples-page")],S)}}]);