PageSourceSearch

https://precoro.com/build/js/sections.procurement-savings-calculator.CjM92B-s.js

js precoro.com collected 2026-09-24 08:54:47 UTC 6,527 bytes, 2 lines download raw bytes

1const T={"50-100":.9,"101-200":1,"201-500":1.1,"501-1000":1.2,"1001-2500":1.3,"2501-5000":1.4,"5000+":1.5},I={"1-5":.9,"6-20":1,"21-50":1.1,"51-100":1.2,"100+":1.3},N={manual:1.25,erp:1.1,disconnected:1.15,basic:.95,automated:.75},P={manual:{min:7,max:10},erp:{min:6,max:8.5},disconnected:{min:6,max:9},basic:{min:5,max:7.5},automated:{min:3,max:5}},_={manual:.22,erp:.18,disconnected:.2,basic:.15,automated:.1},y={costAvoidance:{min:.004,max:.012},consolidation:{min:.0025,max:.008},policy:{min:.0035,max:.01}},k=34,q=50,M={min:.2,max:.4},F={min:.25,max:.4},S={cycles:{min:.03,max:.05},invoices:{min:.02,max:.04},total:{min:.08,max:.1}},h=["costAvoidance","consolidation","policy","cycles","invoices","fraud"],A=["total",...h],b=["min","max"],$=15,g=(t,s,n)=>Math.max(Math.min(t,n),s),L=(t,s)=>typeof s=="string"&&Object.prototype.hasOwnProperty.call(t,s)?t[s]:void 0,x=t=>Number.isFinite(t)&&t>0?t:0,D=t=>Math.round(t*100),w=()=>b.reduce((t,s)=>{const n=A.reduce((u,i)=>({...u,[i]:0}),{});return{...t,[s]:n,raw:{...t.raw,[s]:n},scale:{...t.scale,[s]:1}}},{raw:{},scale:{}}),V=(t,s)=>{const n=t.map(e=>Math.floor(e*100)),u=t.map((e,a)=>({index:a,fraction:e*100-n[a]})).sort((e,a)=>a.fraction-e.fraction||e.index-a.index),i=[...n];let o=s-n.reduce((e,a)=>e+a,0);for(const{index:e}of u){if(o<=0)break;i[e]+=1,o-=1}for(const{index:e}of[...u].reverse()){if(o>=0)break;i[e]!==0&&(i[e]-=1,o+=1)}return i.map(e=>e/100)},G=(t,s)=>{const n=h.reduce((d,r)=>d+t[r],0),u=Math.min(n,s),i=n>u&&n>0?u/n:1,o=D(u),e=V(h.map(d=>t[d]*i),o),a={total:o/100};return h.forEach((d,r)=>{a[d]=e[r]}),{displayed:a,scale:i}},B=t=>{const s=t||{},n=L(T,s.employees),u=L(I,s.locations),i=L(N,s.process),o=x(s.spend);if(!n||!u||!i||o<=0)return w();const e=x(s.orders),a=x(s.invoices),d=g(n*u*i,1,1.6),r=g(n*i,.7,1.5),E=g(u*i,.7,1.4),p=P[s.process],m=_[s.process];return b.reduce((c,l)=>{const f={costAvoidance:o*y.costAvoidance[l]*d,consolidation:o*y.consolidation[l]*d,policy:o*y.policy[l]*d,cycles:Math.min(e*k*M[l]*r,o*S.cycles[l]),invoices:Math.min(a*p[l]*u,o*S.invoices[l]),fraud:a*m*F[l]*q*E},{displayed:O,scale:R}=G(f,o*S.total[l]);return{...c,[l]:O,raw:{...c.raw,[l]:f},scale:{...c.scale,[l]:R}}},{raw:{},scale:{}})},X=t=>`$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,j=t=>{const s=t.dataset.calcPrefix||"",n=t.value,u=t.selectionEnd===null?n.length:t.selectionEnd,i=n.slice(0,u).replace(/[^\d.]/g,"").length,[o,...e]=n.replace(/[^\d.]/g,"").split("."),a=e.length>0,d=e.join("").slice(0,2),r=o.replace(/^0+(?=\d)/,"").slice(0,$),E=r||d?+`${r||"0"}.${d||"0"}`:0;t.value=r||a?`${s}${Number(r||"0").toLocaleString("en-US")}${a?`.${d}`:""}`:"";let p=0,m=i===0?s.length:t.value.length;if(i>0){for(let c=0;c<t.value.length;c+=1)if(/[\d.]/.test(t.value[c])&&(p+=1,p===i)){m=c+1;break}}return t.setSelectionRange(m,m),E},C=8,v=16,U=t=>{const s=[...t.querySelectorAll("[data-tooltip]")].map(o=>({trigger:o.querySelector("[data-tooltip-trigger]"),body:o.querySelector("[data-tooltip-body]")})).filter(({trigger:o,body:e})=>o&&e);s.forEach(({body:o})=>document.body.appendChild(o));const n=o=>{s.forEach(({body:e})=>{e!==o&&e.classList.remove("active")})},u=({trigger:o,body:e})=>{const a=o.getBoundingClientRect(),{width:d,height:r}=e.getBoundingClientRect(),E=Math.max(window.innerWidth-d-v,v),p=g(a.left+a.width/2-d/2,v,E),c=a.bottom+C+r<window.innerHeight-v?a.bottom+C:Math.max(a.top-r-C,v);e.style.left=`${p}px`,e.style.top=`${c}px`},i=o=>{n(o.body),u(o),o.body.classList.add("active")};s.forEach(o=>{const{trigger:e,body:a}=o;e.addEventListener("mouseenter",()=>i(o)),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&i(o)}),e.addEventListener("mouseleave",()=>a.classList.remove("active")),e.addEventListener("blur",()=>a.classList.remove("active")),e.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),a.classList.contains("active")?a.classList.remove("active"):i(o)})}),document.addEventListener("click",()=>n()),document.addEventListener("keydown",o=>{o.key==="Escape"&&n()}),window.addEventListener("scroll",()=>n(),{passive:!0}),window.addEventListener("resize",()=>n())},W=(t,s)=>{const n=t.querySelector("[data-select-trigger]"),u=t.querySelector("[data-select-list]"),i=[...t.querySelectorAll("[data-select-option]")],o=t.querySelector("[data-select-value]"),{calcSelect:e}=t.dataset,a=r=>{n.dataset.state=r?"open":"closed",n.setAttribute("aria-expanded",String(r)),u.classList.toggle("open",r)},d=(r,E)=>{const p=i.find(m=>m.dataset.value===r);p&&(i.forEach(m=>{m.classList.toggle("selected",m===p),m.setAttribute("aria-selected",String(m===p))}),o.textContent=p.textContent.trim(),n.classList.add("has-value"),a(!1),E||s(e,r))};return n.addEventListener("click",r=>{r.stopPropagation(),a(n.dataset.state!=="open")}
1),i.forEach(r=>{r.addEventListener("click",()=>d(r.dataset.value))}),document.addEventListener("click",r=>{t.contains(r.target)||a(!1)}),document.addEventListener("keydown",r=>{r.key==="Escape"&&a(!1)}),{field:e,element:t,setValue:d}},Y=t=>{if(t.dataset.calcReady)return;t.dataset.calcReady="true";const s={spend:0,orders:0,invoices:0,employees:"",locations:"",process:""};let n="min",u=w();const i=A.reduce((c,l)=>{const f=t.querySelector(`[data-calc-result="${l}"]`);return f?{...c,[l]:f}:c},{}),o=()=>{Object.entries(i).forEach(([c,l])=>{l.textContent=X(u[n][c])})},e=()=>{u=B(s),o()};t.querySelectorAll("[data-calc-number]").forEach(c=>{c.addEventListener("input",()=>{s[c.dataset.calcNumber]=j(c),c.classList.toggle("filled",c.value.length>0),e()})});const a=[...t.querySelectorAll('[data-calc-radio="locations"]')],d=t.querySelector("[data-slider-value]");let r=[];const E=c=>{const l=a.find(f=>f.value===c);if(l&&(l.checked=!0,d)){const f=l.parentElement.querySelector("span:last-child");d.textContent=f?f.textContent.trim():c}},p=(c,l)=>{E(c),r.filter(f=>f.field==="locations"&&f.element!==l).forEach(f=>f.setValue(c,!0))};r=[...t.querySelectorAll("[data-calc-select]")].map(c=>W(c,(l,f)=>{s[l]=f,l==="locations"&&p(f,c),e()})),a.forEach(c=>{c.addEventListener("change",()=>{c.checked&&(s.locations=c.value,p(c.value,c),e())})}),t.querySelectorAll('[data-calc-radio="process"]').forEach(c=>{c.addEventListener("change",()=>{c.checked&&(s.process=c.value,e())})});const m=[...t.querySelectorAll("[data-calc-tab]")];m.forEach(c=>{c.addEventListener("click",()=>{n=c.dataset.calcTab,m.forEach(l=>l.classList.toggle("active",l===c)),o()})}),U(t),e()};export{B as calculate,Y as init};
2//# sourceMappingURL=sections.procurement-savings-calculator.CjM92B-s.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.