n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 2.84 kB
JavaScript
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`n8n@2.13.4`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`846a9db0-b95e-43be-92e5-b1b364abf181`,e._sentryDebugIdIdentifier=`sentry-dbid-846a9db0-b95e-43be-92e5-b1b364abf181`)})()}catch{}import{o as e}from"./chunk-DxpFCn6T.js";import{bt as t}from"./_MapCache-CUJwh2qp.js";import{h as n,i as r,l as i,m as a,s as o}from"./CalendarDate-CgcSr8SP.js";import{t as s}from"./dateformat-CYfyw486.js";import{a as c,n as l,r as u}from"./insights.constants-BWd0PYhd.js";var d=e(s(),1),f=`d mmm, yyyy`,p=`d mmm`;const m=e=>Math.round(e/(Math.abs(e)<60?1:60)),h=e=>e/1e3,g=e=>e*100,_={total:e=>e,failed:e=>e,timeSaved:m,averageRunTime:h,failureRate:g};var v=(e,t)=>e-t,y=(e,t)=>{if(e===0&&t===0)return 0;let n=v(e,t);return n===0?null:t/n*100};const b={total:y,failed:y,timeSaved:(e,t)=>m(t),averageRunTime:(e,t)=>h(t),failureRate:(e,t)=>g(t)},x=e=>e?u.map(t=>({id:t,value:_[t](e[t].value),deviation:e[t].deviation===null?null:b[t](e[t].value,e[t].deviation),deviationUnit:e[t].deviation===null?``:l[t](e[t].deviation),unit:c[t](e[t].value)})):[],S={day:1,week:7,"2weeks":14,month:30,quarter:90,"6months":180,year:365},C=()=>{let e=t();return{day:e.baseText(`insights.lastNHours`,{interpolate:{count:24}}),week:e.baseText(`insights.lastNDays`,{interpolate:{count:7}}),"2weeks":e.baseText(`insights.lastNDays`,{interpolate:{count:14}}),month:e.baseText(`insights.lastNDays`,{interpolate:{count:30}}),quarter:e.baseText(`insights.lastNDays`,{interpolate:{count:90}}),"6months":e.baseText(`insights.months`,{interpolate:{count:6}}),year:e.baseText(`insights.oneYear`)}},w=e=>{let{start:t,end:n}=e;if(!t)return``;let r=t.toDate(a()),i=n?.toDate(a());return!n||t.compare(n)===0?(0,d.default)(r,f):t.year===n.year?`${(0,d.default)(r,p)} - ${(0,d.default)(i,f)}`:`${(0,d.default)(r,f)} - ${(0,d.default)(i,f)}`},T=e=>{let{start:t,end:n}=e;if(!t||!n||!i(n,a()))return null;let r=n.compare(t);for(let[e,t]of Object.entries(S))if(r===t)return e;return null},E=e=>{if(!e.start||!e.end)return{startDate:new Date,endDate:new Date};let t=a(),i=n(t),s=e.end&&e.end.compare(i)===0,c=e.end&&e.start?e.end.compare(e.start):0;if(s){let n=o(t);return c===1?{startDate:r(e.start,n).toDate(t),endDate:r(e.end,n).toDate(t)}:{startDate:e.start?.toDate(t)??new Date,endDate:r(e.end,n).toDate(t)}}else{let n=e.start?.toDate(t)??new Date,r=e.end?.toDate(t)??new Date;return r.setHours(23,59,59,999),{startDate:n,endDate:r}}};export{S as a,x as c,C as i,m as l,E as n,h as o,T as r,g as s,w as t};
//# sourceMappingURL=insights.utils-BGXnT8rV.js.map