PageSourceSearch

https://openfarmcarbontracker.onrender.com/_build/assets/pigs-BVtsbg9-.js

js openfarmcarbontracker.onrender.com collected 2026-10-03 11:42:17 UTC 7,952 bytes, 1 lines download raw bytes

1import{e as Y,t as F,i as a,c as e,j as P,q as E,w as T,F as N,b as O}from"./web-DjkTK3V5.js";import{s as m,f as k,a as w,g as j}from"./store-Z2Ut5upF.js";import{a as S}from"./icons-BW5iufR6.js";import{T as p,a as f,b}from"./text-field-DlpJyzI0.js";import{c as A}from"./utils-BEHD0UYf.js";import{E as _}from"./emission-factor-textfield-BMIk0aYC.js";import"./index-BR3tKi3v.js";import"./JNCCF6MP-DxcPACs_.js";import"./index-DtvE5Fyt.js";import"./index-BfVHMWJj.js";var K=F('<div class=feed-section><h3 class="text-lg font-semibold mb-4">Feed</h3><button type=button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md mt-2">Add Feed Record'),L=F('<div class="flex gap-2 items-center"><button type=button class="bg-gray-700 hover:bg-red-500 hover:text-white text-white p-1 rounded-md flex mt-5 items-center justify-center w-8 h-8">'),R=F('<div class=pig-production-section><div class=mb-6><div class="flex justify-between items-center mb-4"><h3 class="text-lg font-semibold">Amount of Pigs</h3></div><div class=overflow-x-auto><div class="flex gap-4 min-w-min pb-4"><button type=button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">Adjust amounts at a certain year'),V=F("<div><button type=button>"),D=F('<div class=emission-summary><h3 class="text-lg font-semibold mb-4">Emission Factors (kg CO2e per pig)</h3><a target=_blank class="text-blue-500 block mb-2"href=https://github.com/euraf/OpenFarmCarbonTracker/blob/78d17ca0991d09de98cde370b96272c52f0b1cd5/carbon-tracker/src/data/livestock/emission-factors.ts#L1-L7>Update sources</a><div class="grid gap-4 mb-6">'),U=F('<div class="grid grid-cols-2 gap-4"><div class="flex flex-col gap-4"><div class="border rounded-lg p-6 bg-white shadow-md"></div><div class="border rounded-lg p-6 bg-white shadow-md"></div></div><div class="border rounded-lg p-6 bg-white shadow-md">');function G(){function h(i,r,t){w("livestock","pigs","feed",i,r,t)}function u(){const i=new Date().getFullYear();w("livestock","pigs","feed",(r=[])=>[...r,{label:"",kgsFeed:0,year:i,emissionPerKg:0}])}function d(i){w("livestock","pigs","feed",(r=[])=>r.filter((t,s)=>s!==i))}return(()=>{var i=K(),r=i.firstChild,t=r.nextSibling;return a(i,e(N,{get each(){return m.livestock.pigs.feed},children:(s,n)=>(()=>{var l=L(),y=l.firstChild;return y.$$click=()=>d(n()),a(y,e(S,{})),a(l,e(p,{class:"flex-1",get children(){return[e(f,{children:"Label"}),e(b,{type:"text",get value(){return s.label},onInput:c=>h(n(),"label",c.currentTarget.value)})]}}),null),a(l,e(p,{class:"w-24",get children(){return[e(f,{children:"Kg. feed"}),e(b,{type:"number",min:0,get value(){return s.kgsFeed},onInput:c=>h(n(),"kgsFeed",Number.parseFloat(c.currentTarget.value))})]}}),null),a(l,e(p,{class:"w-24",get children(){return[e(f,{children:"Year"}),e(b,{type:"number",min:"1900",get value(){return s.year},onInput:c=>h(n(),"year",Number.parseInt(c.currentTarget.value))})]}}),null),a(l,e(p,{class:"w-50",get children(){return[e(f,{children:"Kg. CO2e per Kg. feed"}),e(b,{type:"number",min:0,get value(){return s.emissionPerKg},onInput:c=>h(n(),"emissionPerKg",Number.parseFloat(c.currentTarget.value))})]}}),null),l})()}),t),t.$$click=u,i})()}function M(h){function u(r,t,s,n){if(t==="year"){const l=m.livestock.pigs.production.configurations,y=r>0?l[r-1].year:-1/0,c=r<l.length-1?l[r+1].year:1/0;if(n<=y||n>=c)return;w("livestock","pigs","production","configurations",r,"year",n)}else w("livestock","pigs","production","configurations",r,"config",t,s,n)}function d(){w("livestock","pigs","production","configurations",r=>{const t=r.length>0?Math.max(...r.map(s=>s.year)):m.startYear;return[...r,{year:t+1,config:j}]})}function i(r){w("livestock","pigs","production","configurations",t=>t.filter((s,n)=>n!==r))}return(()=>{var r=R(),t=r.firstChild,s=t.firstChild,n=s.nextSibling,l=n.firstChild,y=l.firstChild;return a(l,e(N,{get each(){return m.livestock.pigs.production.configurations},children:(c,g)=>(()=>{var v=V(),$=v.firstChild;return $.$$click=()=>i(g()),a($,e(S,{})),a(v,e(p,{class:"w-full max-w-sm mb-4",get children(){return[e(f,{children:"From Year"}),e(b,{type:"number",get min(){return(g()>0?m.livestock.pigs.production.configurations[g()-1].year:-1/0)+1},get max(){return(g()<m.livestock.pigs.production.configurations.length-1?m.livestock.pigs.production.configurations[g()+1].year:1/0)-1},get value(){return c.year},get disabled(){return g()===0},onInput:o=>u(g(),"year","value",Number.parseInt(o.currentTarget.value))})]}}),null),a(v,e(p,{class:"w-full max-w-sm",get children(){return[e(f,{children:"Farrowing stages completed (0-3 weeks age)"}),e(b,{type:"number",min:0,get value(){return c.config.farrowing.completed},onInput:o=>u(g(),"farrowing","completed",Number.parseInt(o.currentTarget.value))})]}}),null),a(v,e(p,{class:"w-full max-w-sm",get children(){return[e(f,{children:"Nursery stage completed (3-9 weeks)"}),e(b,{type:"number",min:0,get value(){return c.config.nursery.completed},onInput:o=>u(g(),"nursery","completed",Number.parseInt(o.currentTarget.value))})]}}),null),a(v,e(p,{class:"w-full max-w-sm",get children(){return[e(f,{children:"Finishers stage completed (9-28 weeks)"}),e(b,{type:"number",min:0,get value(){return c.config.finishers.completed},onInput:o=>u(g(),"finishers","completed",Number.parseInt(o.currentTarget.value))})]}}),null),a(v,e(p,{class:"w-full max-w-sm",get children(){return[e(f,{children:"Number of Sows at the farm"}),e(b,{type:"number",min:0,get value(){return c.config.sows.count},onInput:o=>u(g(),"sows","count",Number.parseInt(o.currentTarget.value))})]}}),null),a(v,e(p,{class:"w-full max-w-sm",get children(){return[e(f,{children:"Number of Boars at the farm"}),e(b,{type:"number",min:0,get value(){return c.config.boars.count},onInput:o=>u(g(),"boars","count",Number.parseInt(o.currentTarget.value))})]}}),null),E(o=>{var C=A("border-2 rounded-lg p-4 bg-white min-w-[320px] relative"),I=g()==0,x=`absolute top-2 right-2  ${g()!==0?"hover:bg-red-500 bg-gray-700":"bg-gray-400"} hover:text-white text-white p-1 rounded-md flex items-center justify-center w-8 h-8`;return C!==o.e&&T(v,o.e=C),I!==o.t&&($.disabled=o.t=I),x!==o.a&&T($,o.a=x),o},{e:void 0,t:void 0,a:void 0}),v})()}),y),y.$$click=d,r})()}function B(h){O(()=>
1{const i=h.year(),r=m.livestock.pigs.production.configurations,t=()=>[...r].sort((n,l)=>l.year-n.year).find(n=>n.year<=i)?.config||r[0].config,s={farrowing:t().farrowing.completed*t().farrowing.emissionFactor,nursery:t().nursery.completed*t().nursery.emissionFactor,finishers:t().finishers.completed*t().finishers.emissionFactor,sows:t().sows.count*t().sows.emissionFactor,boars:t().boars.count*t().boars.emissionFactor};return{...s,total:Object.values(s).reduce((n,l)=>n+l,0)}});function u(i,r){console.log(r,i),w("livestock","pigs","production","configurations",t=>t.map(s=>({...s,config:{...s.config,[i]:{...s.config[i],emissionFactor:r}}})))}const d=()=>m.livestock.pigs.production.configurations[0].config;return(()=>{var i=D(),r=i.firstChild,t=r.nextSibling,s=t.nextSibling;return a(s,e(_,{label:"Farrowing (0-3 weeks)",value:()=>d().farrowing.emissionFactor,get defaultValue(){return k.farrowing},onChange:n=>u("farrowing",n)}),null),a(s,e(_,{label:"Nursery (3-9 weeks)",value:()=>d().nursery.emissionFactor,get defaultValue(){return k.nursery},onChange:n=>u("nursery",n)}),null),a(s,e(_,{label:"Finishers (9-28 weeks)",value:()=>d().finishers.emissionFactor,get defaultValue(){return k.finishers},onChange:n=>u("finishers",n)}),null),a(s,e(_,{label:"Sows",value:()=>d().sows.emissionFactor,get defaultValue(){return k.sows},onChange:n=>u("sows",n)}),null),a(s,e(_,{label:"Boars",value:()=>d().boars.emissionFactor,get defaultValue(){return k.boars},onChange:n=>u("boars",n)}),null),i})()}function te(){const[h,u]=Y(m.startYear);return(()=>{var d=U(),i=d.firstChild,r=i.firstChild,t=r.nextSibling,s=i.nextSibling;return a(r,e(M,{setInspectYear:u})),a(t,e(G,{})),a(s,e(B,{year:h})),d})()}P(["click"]);export{te as default};

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.