"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/toConsumableArray"),r=require("lodash/sumBy"),n=require("lodash/chunk");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=o(e),a=o(t),i=o(r),s=o(n);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){p.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var l="SMALL",f="MEDIUM",h="LARGE",d="XLARGE",m={type:"QUATER",columns:{min:1,max:2},rows:{min:1,max:10},slots:1,height:8.4,width:10.3},y={NORMAL:{type:"NORMAL",columns:{min:1,max:7},rows:{min:1,max:1e3},slots:1,height:17.5,width:20.8},WIDE:{type:"WIDE",columns:{min:8,max:12},rows:{min:1,max:25},slots:2,height:17.5,width:41.8},HALFSCREEN:{type:"HALFSCREEN",columns:{min:8,max:12},rows:{min:26,max:40},slots:4,height:26.5,width:41.8},FULLSCREEN:{type:"FULLSCREEN",columns:{min:8,max:12},rows:{min:41,max:1e3},slots:6,height:53.3,width:41.8}},v=function(e){var t=a.default(e);return t.sort((function(e,t){var r=e.coordinates.y,n=t.coordinates.y;if(r<n)return-1;if(r>n)return 1;if(r===n){var o=e.coordinates.x,p=t.coordinates.x;if(o<p)return-1;if(o>p)return 1}return 0})),t},A=Object.values(y);function E(e,t){var r=e.coordinates,n=e.isFullScreenReport,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A;if("singleApp"===t||n)return y.FULLSCREEN;var p=r.w,a=r.h;return o.find((function(e){return p>=e.columns.min&&p<=e.columns.max&&a>=e.rows.min&&a<=e.rows.max}))}var g=function(e,t,r){if(!("compact"===r))return{quaterApps:[],otherApps:e.map((function(e){return c(c({},e),{},{appType:E(e,t,A)})}))};var n={quaterApps:[],otherApps:[]},o=[m].concat(A);return e.forEach((function(e){var r=E(e,t,o),p=c(c({},e),{},{appType:r});r.type===m.type?n.quaterApps.push(p):n.otherApps.push(p)})),n};exports.PDF_REPORT_PIXEL_RATIO=18.8976377953,exports.PIXELS_IN_CM=37.7952755906,exports.REPORT_APP_GRID_TYPES=y,exports.getAppType=E,exports.getPDFAppPixelSize=function(e){var t=e.width,r=e.height;return{pixelWidth:Math.round(18.8976377953*t),pixelHeight:Math.round(18.8976377953*r),realWidth:Math.round(2*t*18.8976377953),realHeight:Math.round(2*r*18.8976377953)}},exports.getPDFAppSize=function(e){var t=e.w,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?d:t>=5?h:t>=3?f:l},exports.getPages=function(e,t,r){var n=g(e,t,r),o=n.otherApps,p=n.quaterApps,u=v(o),c=v(p),l=0,f=u.reduce((function(e,t,r,n){var o=t.appType,p=o.slots,s=o.type;if(s!==y.FULLSCREEN.type){var u=n[r+1];if(u){var c=u.appType;if(l%2==0&&1===p&&c.slots%2==0){var f=y.WIDE;p=f.slots,s=f.type}}else if(r%2==0){var h=y.WIDE;p=h.slots,s=h.type}}l+=p;var d={app:t,slots:p,reportAppSize:t.appType},m=!1,v=e.map((function(e){if(m)return e;var t=6-i.default(e,"slots");return t>=p&&(m=!0),t>=p?[].concat(a.default(e),[d]):e}));return m?v:[].concat(a.default(v),[[d]])}),[[]]);if(!c.length)return f;var h=f[f.length-1],d=4*(6-i.default(h,"slots")),A=c.map((function(e){return{app:e,reportAppSize:m}})),E=[].concat(a.default(h),a.default(A.slice(0,d))),x=s.default(A.slice(d),24);return[].concat(a.default(f.slice(0,f.length-1)),[E],a.default(x))},exports.sortPDFDashboardApps=function(e){var t=g(e),r=t.otherApps,n=t.quaterApps;return[].concat(a.default(v(r)),a.default(v(n)))};
//# sourceMappingURL=dashboardReports.js.map
