import { g as getContext, h as ensure_array_like, f as store_get, e as escape_html, u as unsubscribe_stores, p as pop, a as push } from "../../../../../../chunks/index.js";
import { Q as Question } from "../../../../../../chunks/Question.js";
function _page($$payload, $$props) {
  push();
  var $$store_subs;
  const d = getContext("simulation");
  const fmt2 = Intl.NumberFormat("fr-FR", { maximumFractionDigits: 2 });
  function sum(x, n) {
    let sum2 = 0;
    for (let i = 0; i < n; i++) {
      sum2 += x[i];
    }
    return sum2;
  }
  function format(x) {
    let f = 0;
    let s = "";
    if (Math.abs(x) <= 1e3) {
      s = " €";
      f = x;
    } else if (Math.abs(x) < 1e6) {
      s = " k€";
      f = x / 1e3;
    } else if (Math.abs(x) < 1e9) {
      s = " M€";
      f = x / 1e6;
    } else {
      s = " mds€";
      f = x / 1e9;
    }
    return fmt2.format(f) + s;
  }
  const N = d.N;
  const resultatNet = d.resultatNet;
  const chiffreAffaires = d.chiffreAffaires;
  const arr = 0;
  const autoprod = d.p.autoprod;
  const autoconso = d.p.autoconso;
  const productionAnnuelle = d.productionAnnuelle;
  const tarifAllo = d.tarifAllo;
  const tarifLocal = d.tarifLocal;
  const tarifSurplus = d.tarifSurplus;
  const primeInvestissement = d.primeInvestissement;
  const charges = d.charges;
  const ebe = d.ebe;
  const valeurAjoutee = d.valeurAjoutee;
  const accise = d.accise;
  const taxeFonciere = d.taxeFonciere;
  const ifer = d.ifer;
  const cfe = d.cfe;
  const provisionOnduleurs = d.provisionOnduleurs;
  const interetsDetteSenior = d.interetsDetteSenior;
  const interetsDSRA = d.interetsDSRA;
  const resultatFiscal = d.resultatFiscal;
  const is = d.is;
  const investissement = d.investissement;
  const amortissement = d.amortissement;
  const apport = d.p.apport;
  const dscr = d.dscr;
  const exploitation = d.exploitation;
  const turpe = d.turpe;
  const assurance = d.assurance;
  const divers = d.divers;
  let an = /* @__PURE__ */ (/* @__PURE__ */ new Date()).getFullYear();
  const each_array = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
  const each_array_1 = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
  const each_array_2 = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
  const each_array_3 = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
  const each_array_4 = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
  $$payload.out.push(`<div class="p-10 svelte-1rjhh63"><h1 class="my-8 text-4xl font-bold svelte-1rjhh63"><span class="text-primary svelte-1rjhh63">Projetez-vous</span> dans votre projet.</h1> <div class="text-2xl mt-10 svelte-1rjhh63">Durée d'analyse : ${escape_html(store_get($$store_subs ??= {}, "$N", N))} ans</div> <h2 class="text-2xl my-3 mt-5 svelte-1rjhh63">Résultat</h2> <div class="ms-3 flex flex-col gap-5 svelte-1rjhh63"><h3 class="text-xl mt-5 svelte-1rjhh63">Résultat net</h3> <div class="font-bold text-lg svelte-1rjhh63">Cumulé : <span class="text-primary svelte-1rjhh63">${escape_html(format(sum(store_get($$store_subs ??= {}, "$resultatNet", resultatNet), store_get($$store_subs ??= {}, "$N", N))))}</span></div> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-3 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">Résultat net</div></div> <!--[-->`);
  for (let i = 0, $$length = each_array.length; i < $$length; i++) {
    $$payload.out.push(`<div class="flex flex-col my-3 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$resultatNet", resultatNet)[i].toFixed(arr))}</div></div>`);
  }
  $$payload.out.push(`<!--]--></div></div> <h2 class="text-2xl my-3 svelte-1rjhh63">Détail</h2> <div class="ms-3 flex flex-col gap-5 svelte-1rjhh63"><h3 class="text-xl mt-5 svelte-1rjhh63">Chiffre d'affaires</h3> <div class="font-bold text-lg svelte-1rjhh63">Cumulé : <span class="text-primary svelte-1rjhh63">${escape_html(format(sum(store_get($$store_subs ??= {}, "$chiffreAffaires", chiffreAffaires), store_get($$store_subs ??= {}, "$N", N))))}</span></div> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-4 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">Autoproduction (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Vente locale (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Vente de surplus (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Prime</div> <div class="titreligne tcellt svelte-1rjhh63">Chiffre d'affaires</div></div> <!--[-->`);
  for (let i = 0, $$length = each_array_1.length; i < $$length; i++) {
    $$payload.out.push(`<div class="d-flex flex-column my-4 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html((store_get($$store_subs ??= {}, "$productionAnnuelle", productionAnnuelle)[i] * (store_get($$store_subs ??= {}, "$autoprod", autoprod) * store_get($$store_subs ??= {}, "$tarifAllo", tarifAllo)[i] / 100)).toFixed(0))}</div> <div class="tcellt svelte-1rjhh63">${escape_html((store_get($$store_subs ??= {}, "$productionAnnuelle", productionAnnuelle)[i] * (store_get($$store_subs ??= {}, "$autoconso", autoconso) * store_get($$store_subs ??= {}, "$tarifLocal", tarifLocal)[i] / 100)).toFixed(0))}</div> <div class="tcellt svelte-1rjhh63">${escape_html((store_get($$store_subs ??= {}, "$productionAnnuelle", productionAnnuelle)[i] * ((1 - store_get($$store_subs ??= {}, "$autoconso", autoconso) / 100) * store_get($$store_subs ??= {}, "$tarifSurplus", tarifSurplus)[i])).toFixed(0))}</div> <div class="tcellt svelte-1rjhh63">`);
    if (i == 0) {
      $$payload.out.push("<!--[-->");
      $$payload.out.push(`${escape_html(store_get($$store_subs ??= {}, "$primeInvestissement", primeInvestissement))}`);
    } else {
      $$payload.out.push("<!--[!-->");
      $$payload.out.push(` `);
    }
    $$payload.out.push(`<!--]--></div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$chiffreAffaires", chiffreAffaires)[i].toFixed(arr))}</div></div>`);
  }
  $$payload.out.push(`<!--]--></div> <h3 class="text-xl mt-10 svelte-1rjhh63">Charges d'exploitation</h3> <div class="font-bold text-lg svelte-1rjhh63">Cumulé : <span class="text-primary svelte-1rjhh63">${escape_html(format(sum(store_get($$store_subs ??= {}, "$charges", charges), store_get($$store_subs ??= {}, "$N", N))))}</span></div> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-4 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">Maintenance (€)</div> <div class="titreligne tcellt svelte-1rjhh63">TURPE (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Assurance (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Divers</div> <div class="titreligne tcellt svelte-1rjhh63">Total charges</div></div> <!--[-->`);
  for (let i = 0, $$length = each_array_2.length; i < $$length; i++) {
    $$payload.out.push(`<div class="flex flex-col my-4 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$exploitation", exploitation)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$turpe", turpe)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$assurance", assurance)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$divers", divers)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$charges", charges)[i].toFixed(arr))}</div></div>`);
  }
  $$payload.out.push(`<!--]--></div> <h3 class="text-xl mt-10 svelte-1rjhh63">Excédent brut d'exploitation</h3> <div class="font-bold text-lg svelte-1rjhh63">Cumulé : <span class="text-primary svelte-1rjhh63">${escape_html(format(sum(store_get($$store_subs ??= {}, "$ebe", ebe), store_get($$store_subs ??= {}, "$N", N))))}</span></div> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-4 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">Valeur ajoutée (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Accise (€)</div> <div class="titreligne tcellt svelte-1rjhh63">IFER (€)</div> <div class="titreligne tcellt svelte-1rjhh63">Taxe foncière</div> <div class="titreligne tcellt svelte-1rjhh63">Cotisation foncière des entreprises</div> <div class="titreligne tcellt svelte-1rjhh63">Excédent brut d'exploitation</div></div> <!--[-->`);
  for (let i = 0, $$length = each_array_3.length; i < $$length; i++) {
    $$payload.out.push(`<div class="flex flex-col my-4 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$valeurAjoutee", valeurAjoutee)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$accise", accise)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$ifer", ifer)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$taxeFonciere", taxeFonciere).toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$cfe", cfe).toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$ebe", ebe)[i].toFixed(arr))}</div></div>`);
  }
  $$payload.out.push(`<!--]--></div> <h3 class="text-xl mt-10 svelte-1rjhh63">Résultat net</h3> <div class="text-bold text-lg svelte-1rjhh63">Cumulé : <span class="text-primary svelte-1rjhh63">${escape_html(format(sum(store_get($$store_subs ??= {}, "$resultatNet", resultatNet), store_get($$store_subs ??= {}, "$N", N))))}</span></div> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-4 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">Onduleurs `);
  Question($$payload, { datatip: "Provision pour le remplacement des onduleurs" });
  $$payload.out.push(`<!----></div> <div class="titreligne tcellt svelte-1rjhh63">Amortissement</div> <div class="titreligne tcellt svelte-1rjhh63">Intérêts dette senior</div> <div class="titreligne tcellt svelte-1rjhh63">Intérêts DSRA `);
  Question($$payload, {
    datatip: "Dans un emprunt, compte bancaire qui permettra de payer le service de la dette si jamais l'entité emprunteuse n'est plus en mesure de le faire."
  });
  $$payload.out.push(`<!----></div> <div class="titreligne tcellt svelte-1rjhh63">Résultat fiscal</div> <div class="titreligne tcellt svelte-1rjhh63">Impôt sur les sociétés</div> <div class="titreligne tcellt svelte-1rjhh63">Résultat net</div></div> <!--[-->`);
  for (let i = 0, $$length = each_array_4.length; i < $$length; i++) {
    $$payload.out.push(`<div class="flex flex-col my-4 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$provisionOnduleurs", provisionOnduleurs)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$amortissement", amortissement)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$interetsDetteSenior", interetsDetteSenior)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$interetsDSRA", interetsDSRA)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$resultatFiscal", resultatFiscal)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$is", is)[i].toFixed(arr))}</div> <div class="tcellt svelte-1rjhh63">${escape_html(store_get($$store_subs ??= {}, "$resultatNet", resultatNet)[i].toFixed(arr))}</div></div>`);
  }
  $$payload.out.push(`<!--]--></div> `);
  if (store_get($$store_subs ??= {}, "$investissement", investissement) > store_get($$store_subs ??= {}, "$apport", apport)) {
    $$payload.out.push("<!--[-->");
    const each_array_5 = ensure_array_like(Array(Math.ceil(store_get($$store_subs ??= {}, "$N", N))));
    $$payload.out.push(`<h3 class="text-xl my-3 svelte-1rjhh63">Couverture de la dette</h3> <div class="flex flex-wrap svelte-1rjhh63"><div class="flex flex-col my-3 svelte-1rjhh63"><div class="titreligne tcellt svelte-1rjhh63">Année</div> <div class="titreligne tcellt svelte-1rjhh63">DSCR</div></div> <!--[-->`);
    for (let i = 0, $$length = each_array_5.length; i < $$length; i++) {
      $$payload.out.push(`<div class="flex flex-col my-3 svelte-1rjhh63"><div class="tcellt svelte-1rjhh63">${escape_html(an + i)}</div> <div class="tcellt svelte-1rjhh63">${escape_html(fmt2.format(store_get($$store_subs ??= {}, "$dscr", dscr)[i]))}</div></div>`);
    }
    $$payload.out.push(`<!--]--></div>`);
  } else {
    $$payload.out.push("<!--[!-->");
  }
  $$payload.out.push(`<!--]--></div></div>`);
  if ($$store_subs) unsubscribe_stores($$store_subs);
  pop();
}
export {
  _page as default
};
