/* ============================================================
   PLANT MODEL — Bierkowo dry anaerobic digestion biogas plant
   Device catalog + simulation configuration.
   kinds: 'valve' (EV / motorised), 'motor', 'instrument'
   ============================================================ */

const AREAS = [
  { id: "rec",  page: "reception",  prefix: "10" },
  { id: "tun",  page: "tunnels",    prefix: "20" },
  { id: "per",  page: "percolate",  prefix: "30" },
  { id: "gas",  page: "biogas",     prefix: "40" },
  { id: "chp",  page: "chp",        prefix: "50" },
  { id: "heat", page: "heat",       prefix: "60" },
  { id: "air",  page: "air",        prefix: "70" },
  { id: "bio",  page: "biofilter",  prefix: "80" },
];

// helper builders -------------------------------------------------
function ml(it, en, pl) { return { it, en, pl }; }

function inst(id, area, tag, desc, unit, base, range, lim, vol, fmt) {
  return { id, kind: "instrument", area, tag, desc, unit, base, range, lim: lim || {}, vol: vol == null ? 0.6 : vol, fmt: fmt || 1, v: base };
}
function motor(id, area, tag, desc, sub, kW, rpm, opts) {
  return Object.assign({ id, kind: "motor", area, tag, desc, sub: sub || "pump", kW, rpm: rpm || 1450,
    running: true, mode: "auto", fault: false, hasVfd: false, A: kW * 1.9, hz: 50, runH: 0, starts: 0 }, opts || {});
}
function valve(id, area, tag, desc, sub, opts) {
  return Object.assign({ id, kind: "valve", area, tag, desc, sub: sub || "ev",
    open: false, mode: "auto", fault: false, travelling: false, pos: 0, travel: 4 }, opts || {});
}

const DEVICES = [];

/* ---- 10 RECEPTION & PRETREATMENT -------------------------------- */
DEVICES.push(
  inst("10LT01", "rec", "10-LT-001", ml("Livello tramoggia di carico","Feed hopper level","Poziom zasobnika zasypowego"), "%", 62, [0,100], {L:10,H:90,HH:96}, 0.5),
  inst("10WT01", "rec", "10-WT-001", ml("Peso bilancia di ricezione","Reception weighbridge","Waga przyjęciowa"), "t", 18.4, [0,40], {H:35}, 0.4, 1),
  inst("10QT01", "rec", "10-QT-001", ml("Concentrazione H₂S aria ambiente","Ambient H₂S in hall","Stężenie H₂S w hali"), "ppm", 2.1, [0,25], {H:10,HH:20}, 0.8, 1),
  motor("10MP01", "rec", "10-PP-001", ml("Pompa di carico substrato 1","Substrate feed pump 1","Pompa podająca substrat 1"), "pump", 22, 1460, { hasVfd:true, A:41, runH:14820, starts:6 }),
  motor("10MP02", "rec", "10-PP-002", ml("Pompa di carico substrato 2","Substrate feed pump 2","Pompa podająca substrat 2"), "pump", 22, 1460, { hasVfd:true, running:false, A:0, runH:14110, starts:4 }),
  motor("10MX01", "rec", "10-MX-001", ml("Coclea miscelazione ricezione","Reception mixing auger","Przenośnik mieszający"), "agitator", 15, 980, { A:29, runH:9220, starts:11 }),
  motor("10MC01", "rec", "10-CV-001", ml("Nastro trasportatore carico","Loading conveyor","Przenośnik załadowczy"), "conveyor", 7.5, 1440, { running:false, A:0, runH:5410, starts:22 }),
  valve("10EV01", "rec", "10-EV-001", ml("Valvola sezionamento mandata substrato","Substrate delivery isolation valve","Zawór odcinający tłoczenia substratu"), "ev", { open:true, pos:100 }),
  valve("10EV02", "rec", "10-EV-002", ml("Valvola deviazione tramoggia","Hopper diverter valve","Zawór kierujący zasobnika"), "ev"),
);

/* ---- 20 ANAEROBIC TUNNELS (6, per P&ID) -------------------------
   Real per-tunnel tags from drawing 101-GEN-S-001U:
   T20iA (temperature), PG20i (pressure), EV20iA (biogas extraction),
   EV20iB (aeration), EV10iB (percolate spray).                       */
const N_TUN = 6;
const TUN_PROFILE = [
  { phase:"run",  fill:88, t:41.2, ch4:58.4, day:14 },
  { phase:"run",  fill:91, t:40.6, ch4:59.1, day:21 },
  { phase:"run",  fill:85, t:39.8, ch4:57.2, day:9  },
  { phase:"start",fill:78, t:36.1, ch4:42.0, day:3  },
  { phase:"run",  fill:90, t:41.7, ch4:60.3, day:27 },
  { phase:"empty",fill:24, t:33.4, ch4:30.5, day:34 },
];
for (let i = 1; i <= N_TUN; i++) {
  const n = String(i).padStart(2, "0");
  const p = TUN_PROFILE[i - 1];
  DEVICES.push(
    inst(`20TT${n}`, "tun", `T20${i}A`, ml(`Tunnel ${i} — temperatura digestione`,`Tunnel ${i} — digestion temperature`,`Tunel ${i} — temperatura fermentacji`), "°C", p.t, [20,55], {L:34,H:44,HH:48}, 0.25, 1),
    inst(`20AT${n}`, "tun", `AT20${i}`, ml(`Tunnel ${i} — concentrazione CH₄`,`Tunnel ${i} — CH₄ concentration`,`Tunel ${i} — stężenie CH₄`), "%", p.ch4, [0,75], {LL:35,L:45}, 0.35, 1),
    inst(`20PT${n}`, "tun", `PG20${i}`, ml(`Tunnel ${i} — pressione interna`,`Tunnel ${i} — internal pressure`,`Tunel ${i} — ciśnienie wewnętrzne`), "mbar", 3.4, [-2,12], {H:9,HH:11,L:0.5}, 0.5, 1),
    valve(`20GV${n}`, "tun", `EV20${i}A`, ml(`Tunnel ${i} — valvola estrazione biogas`,`Tunnel ${i} — biogas extraction valve`,`Tunel ${i} — zawór odbioru biogazu`), "ev", { open: p.phase==="run", pos: p.phase==="run"?100:0 }),
    valve(`20AV${n}`, "tun", `EV20${i}B`, ml(`Tunnel ${i} — valvola aerazione avvio`,`Tunnel ${i} — start-up aeration valve`,`Tunel ${i} — zawór napowietrzania rozruchu`), "ev", { open: p.phase==="start", pos: p.phase==="start"?100:0 }),
    valve(`20SV${n}`, "tun", `EV10${i}B`, ml(`Tunnel ${i} — valvola spruzzatura percolato`,`Tunnel ${i} — percolate spray valve`,`Tunel ${i} — zawór zraszania perkolatem`), "ev", { open: p.phase==="run", pos: p.phase==="run"?100:0 }),
  );
  // tunnel meta for the page
  DEVICES.push({ id:`20TUN${n}`, kind:"tunnel", area:"tun", tag:`TF0${i}`, idx:i,
    desc: ml(`Tunnel di fermentazione ${i}`,`Fermentation tunnel ${i}`,`Tunel fermentacyjny ${i}`),
    phase: p.phase, fill: p.fill, day: p.day });
}

/* ---- 30 PERCOLATE MANAGEMENT ------------------------------------ */
DEVICES.push(
  inst("30LT01", "per", "30-LT-001", ml("Vasca percolato PR1 — livello","Percolate reservoir PR1 level","Zbiornik perkolatu PR1 — poziom"), "%", 71, [0,100], {L:15,LL:8,H:92}, 0.4),
  inst("30LT02", "per", "30-LT-002", ml("Vasca percolato PR2 — livello","Percolate reservoir PR2 level","Zbiornik perkolatu PR2 — poziom"), "%", 54, [0,100], {L:15,LL:8,H:92}, 0.4),
  inst("30TT01", "per", "30-TT-001", ml("Percolato — temperatura","Percolate temperature","Perkolat — temperatura"), "°C", 38.6, [10,50], {L:32,H:45}, 0.3, 1),
  inst("30QT01", "per", "30-QT-001", ml("Percolato — pH","Percolate pH","Perkolat — pH"), "pH", 7.62, [4,10], {L:6.8,LL:6.4,H:8.2}, 0.15, 2),
  inst("30FT01", "per", "30-FT-001", ml("Portata ricircolo percolato","Percolate recirculation flow","Przepływ recyrkulacji perkolatu"), "m³/h", 46.2, [0,90], {L:10}, 0.6, 1),
  motor("30MP01", "per", "30-PP-001", ml("Pompa ricircolo percolato 1","Percolate recirculation pump 1","Pompa recyrkulacji perkolatu 1"), "pump", 30, 1465, { hasVfd:true, A:55, runH:21340, starts:18 }),
  motor("30MP02", "per", "30-PP-002", ml("Pompa ricircolo percolato 2","Percolate recirculation pump 2","Pompa recyrkulacji perkolatu 2"), "pump", 30, 1465, { hasVfd:true, A:54, runH:20880, starts:16 }),
  motor("30MP03", "per", "30-PP-003", ml("Pompa percolato di riserva","Percolate standby pump","Pompa rezerwowa perkolatu"), "pump", 30, 1465, { running:false, A:0, runH:6650, starts:9 }),
  motor("30MX01", "per", "30-MX-001", ml("Agitatore vasca PR1","Reservoir PR1 agitator","Mieszadło zbiornika PR1"), "agitator", 11, 980, { A:21, runH:31200, starts:3 }),
  valve("30EV01", "per", "30-EV-001", ml("Valvola distribuzione percolato tunnel","Tunnel percolate distribution valve","Zawór dystrybucji perkolatu"), "ev", { open:true, pos:100 }),
  valve("30EV02", "per", "30-EV-002", ml("Valvola travaso PR1→PR2","Transfer valve PR1→PR2","Zawór przelewu PR1→PR2"), "ev"),
  valve("30EV03", "per", "30-EV-003", ml("Valvola scarico dissabbiatore","Sand trap drain valve","Zawór spustu piaskownika"), "ev"),
);

/* ---- 40 BIOGAS STORAGE & TREATMENT ------------------------------ */
DEVICES.push(
  inst("40LT01", "gas", "40-LT-001", ml("Gasometro — riempimento","Gas holder fill level","Zbiornik gazu — napełnienie"), "%", 68, [0,100], {L:18,LL:8,H:90,HH:96}, 0.5),
  inst("40PT01", "gas", "40-PT-001", ml("Pressione biogas gasometro","Gas holder pressure","Ciśnienie biogazu w zbiorniku"), "mbar", 21.5, [0,40], {L:6,H:32,HH:36}, 0.7, 1),
  inst("40AT01", "gas", "40-AT-001", ml("Analizzatore biogas — CH₄","Biogas analyser — CH₄","Analizator biogazu — CH₄"), "%", 58.7, [0,75], {LL:45,L:50}, 0.4, 1),
  inst("40AT02", "gas", "40-AT-002", ml("Analizzatore biogas — CO₂","Biogas analyser — CO₂","Analizator biogazu — CO₂"), "%", 38.4, [0,60], {H:46}, 0.4, 1),
  inst("40AT03", "gas", "40-AT-003", ml("Analizzatore biogas — H₂S","Biogas analyser — H₂S","Analizator biogazu — H₂S"), "ppm", 184, [0,800], {H:400,HH:600}, 1.2, 0),
  inst("40AT04", "gas", "40-AT-004", ml("Analizzatore biogas — O₂","Biogas analyser — O₂","Analizator biogazu — O₂"), "%", 0.4, [0,5], {H:1.5,HH:2.5}, 0.6, 2),
  inst("40FT01", "gas", "40-FT-001", ml("Portata biogas a cogenerazione","Biogas flow to CHP","Przepływ biogazu do CHP"), "Nm³/h", 412, [0,700], {L:120}, 0.8, 0),
  motor("40MB01", "gas", "40-BL-001", ml("Soffiante booster biogas","Biogas booster blower","Dmuchawa wspomagająca biogazu"), "blower", 18.5, 2900, { hasVfd:true, A:34, hz:46, runH:18250, starts:31 }),
  motor("40MP01", "gas", "40-PP-001", ml("Pompa scarico condensa","Condensate drain pump","Pompa odwadniacza"), "pump", 4, 2870, { running:false, A:0, runH:1980, starts:142 }),
  valve("40EV01", "gas", "40-EV-001", ml("Valvola ingresso gasometro","Gas holder inlet valve","Zawór wlotowy zbiornika gazu"), "ev", { open:true, pos:100 }),
  valve("40EV02", "gas", "40-EV-002", ml("Valvola uscita gasometro a CHP","Gas holder outlet to CHP","Zawór wylotowy do CHP"), "ev", { open:true, pos:100 }),
  valve("40EV03", "gas", "40-EV-003", ml("Valvola alla torcia di sicurezza","Safety flare valve","Zawór do pochodni awaryjnej"), "ev"),
  valve("40EV04", "gas", "40-EV-004", ml("Valvola dosaggio aria desolforazione","Desulph. air dosing valve","Zawór dozowania powietrza odsiarczania"), "ev", { open:true, pos:35 }),
  valve("40EV05", "gas", "40-EV-005", ml("Valvola scarico trappola condensa","Condensate trap drain valve","Zawór spustu odwadniacza"), "ev"),
);

/* ---- 50 COGENERATION (CHP) -------------------------------------- */
DEVICES.push(
  inst("50JT01", "chp", "50-JT-001", ml("Potenza elettrica attiva","Active electrical power","Czynna moc elektryczna"), "kW", 526, [0,650], {L:80}, 0.6, 0),
  inst("50JT02", "chp", "50-JT-002", ml("Potenza termica recuperata","Recovered thermal power","Odzyskana moc cieplna"), "kW", 612, [0,750], {}, 0.6, 0),
  inst("50TT01", "chp", "50-TT-001", ml("Temperatura gas di scarico","Exhaust gas temperature","Temperatura spalin"), "°C", 472, [0,650], {H:560,HH:600}, 0.5, 0),
  inst("50TT02", "chp", "50-TT-002", ml("Temperatura acqua motore","Engine coolant temperature","Temperatura cieczy chłodzącej"), "°C", 86.4, [0,120], {H:95,HH:102}, 0.3, 1),
  inst("50TT03", "chp", "50-TT-003", ml("Temperatura olio motore","Engine oil temperature","Temperatura oleju"), "°C", 78.1, [0,120], {H:98,HH:105}, 0.3, 1),
  inst("50ST01", "chp", "50-ST-001", ml("Velocità motore","Engine speed","Prędkość silnika"), "rpm", 1500, [0,1700], {L:1400,H:1560}, 0.2, 0),
  inst("50ET01", "chp", "50-ET-001", ml("Energia attiva esportata","Active energy exported","Energia czynna oddana"), "MWh", 9842, [0,99999], {}, 0.05, 0),
  motor("50GG01", "chp", "50-GG-001", ml("Gruppo motore-generatore biogas 1","Biogas genset unit 1","Agregat kogeneracyjny 1"), "genset", 600, 1500, { A:0, runH:38420, starts:212, isGenset:true }),
  motor("50GG02", "chp", "50-GG-002", ml("Gruppo motore-generatore biogas 2","Biogas genset unit 2","Agregat kogeneracyjny 2"), "genset", 200, 1500, { A:0, runH:31280, starts:188, isGenset:true, powerKw:178 }),
  motor("50GG03", "chp", "50-GG-003", ml("Gruppo motore-generatore biogas 3","Biogas genset unit 3","Agregat kogeneracyjny 3"), "genset", 180, 1500, { A:0, running:false, runH:24180, starts:142, isGenset:true, powerKw:0 }),
  valve("50EV01", "chp", "50-EV-001", ml("Valvola gas treno principale CHP","CHP main gas train valve","Zawór główny toru gazowego CHP"), "ev", { open:true, pos:100 }),
  valve("50EV02", "chp", "50-EV-002", ml("Valvola blocco di sicurezza gas","Gas safety shut-off valve","Zawór bezpieczeństwa gazu"), "ev", { open:true, pos:100 }),
  valve("50EV03", "chp", "50-EV-003", ml("Valvola dump termico (dry cooler)","Thermal dump valve (dry cooler)","Zawór zrzutu ciepła"), "ev", { open:true, pos:60 }),
);

/* ---- 60 HEAT RECOVERY ------------------------------------------- */
DEVICES.push(
  inst("60TT01", "heat", "60-TT-001", ml("Mandata circuito caldo","Hot circuit supply","Zasilanie obiegu grzewczego"), "°C", 82.3, [0,110], {L:68,H:95}, 0.3, 1),
  inst("60TT02", "heat", "60-TT-002", ml("Ritorno circuito caldo","Hot circuit return","Powrót obiegu grzewczego"), "°C", 64.7, [0,110], {}, 0.3, 1),
  inst("60FT01", "heat", "60-FT-001", ml("Portata circuito riscaldamento tunnel","Tunnel heating loop flow","Przepływ ogrzewania tuneli"), "m³/h", 58.0, [0,100], {L:15}, 0.5, 1),
  inst("60PT01", "heat", "60-PT-001", ml("Pressione circuito termico","Heating circuit pressure","Ciśnienie obiegu cieplnego"), "bar", 2.4, [0,6], {L:1.2,H:4}, 0.3, 2),
  motor("60MP01", "heat", "60-PP-001", ml("Pompa circuito riscaldamento 1","Heating loop pump 1","Pompa obiegu grzewczego 1"), "pump", 7.5, 2880, { hasVfd:true, A:14, runH:42100, starts:7 }),
  motor("60MP02", "heat", "60-PP-002", ml("Pompa circuito riscaldamento 2","Heating loop pump 2","Pompa obiegu grzewczego 2"), "pump", 7.5, 2880, { running:false, A:0, runH:40330, starts:9 }),
  valve("60EV01", "heat", "60-EV-001", ml("Valvola miscelatrice 3 vie","3-way mixing valve","Zawór mieszający 3-drogowy"), "ev", { open:true, pos:72 }),
  valve("60EV02", "heat", "60-EV-002", ml("Valvola sezionamento scambiatore","Heat exchanger isolation valve","Zawór odcinający wymiennika"), "ev", { open:true, pos:100 }),
);

/* ---- 70 COMPRESSED AIR ------------------------------------------ */
DEVICES.push(
  inst("70PT01", "air", "70-PT-001", ml("Pressione rete aria compressa","Compressed air header pressure","Ciśnienie sieci sprężonego powietrza"), "bar", 7.2, [0,12], {L:5.5,LL:4.5,H:9}, 0.3, 2),
  inst("70TT01", "air", "70-TT-001", ml("Punto di rugiada essiccatore","Dryer dew point","Punkt rosy osuszacza"), "°C", 3.1, [-20,20], {H:10}, 0.4, 1),
  inst("70FT01", "air", "70-FT-001", ml("Consumo aria strumenti","Instrument air consumption","Zużycie powietrza"), "Nm³/h", 38.5, [0,120], {H:100}, 0.7, 1),
  motor("70MC01", "air", "70-CP-001", ml("Compressore aria 1","Air compressor 1","Sprężarka powietrza 1"), "compressor", 30, 2950, { A:55, runH:27600, starts:480 }),
  motor("70MC02", "air", "70-CP-002", ml("Compressore aria 2 (riserva)","Air compressor 2 (standby)","Sprężarka powietrza 2 (rezerwa)"), "compressor", 30, 2950, { running:false, A:0, runH:19200, starts:360 }),
  valve("70EV01", "air", "70-EV-001", ml("Valvola distribuzione aria strumenti","Instrument air distribution valve","Zawór dystrybucji powietrza"), "ev", { open:true, pos:100 }),
  valve("70EV02", "air", "70-EV-002", ml("Valvola spurgo condensa serbatoio","Receiver condensate purge valve","Zawór spustu kondensatu zbiornika"), "ev"),
);

/* ---- 80 BIOFILTER & ODOUR CONTROL ------------------------------- */
DEVICES.push(
  inst("80PT01", "bio", "80-PT-001", ml("Perdita di carico biofiltro","Biofilter pressure drop","Spadek ciśnienia biofiltra"), "Pa", 312, [0,800], {H:550,HH:700}, 0.6, 0),
  inst("80MT01", "bio", "80-MT-001", ml("Umidità letto biofiltro","Biofilter bed humidity","Wilgotność złoża biofiltra"), "%", 58.4, [0,100], {L:40,LL:30}, 0.4, 1),
  inst("80TT01", "bio", "80-TT-001", ml("Temperatura letto biofiltro","Biofilter bed temperature","Temperatura złoża biofiltra"), "°C", 28.7, [0,50], {H:40}, 0.3, 1),
  inst("80QT01", "bio", "80-QT-001", ml("H₂S all'uscita camino","Stack outlet H₂S","H₂S na wylocie komina"), "ppm", 1.4, [0,20], {H:5,HH:10}, 0.7, 1),
  motor("80MF01", "bio", "80-FN-001", ml("Ventilatore aspirazione 1","Extraction fan 1","Wentylator wyciągowy 1"), "fan", 22, 1460, { hasVfd:true, A:40, hz:48, runH:33400, starts:24 }),
  motor("80MF02", "bio", "80-FN-002", ml("Ventilatore aspirazione 2","Extraction fan 2","Wentylator wyciągowy 2"), "fan", 22, 1460, { hasVfd:true, A:39, hz:47, runH:32900, starts:21 }),
  valve("80EV01", "bio", "80-EV-001", ml("Valvola irrigazione letto biofiltro","Biofilter bed irrigation valve","Zawór nawadniania złoża"), "ev", { open:false, pos:0 }),
  valve("80EV02", "bio", "80-EV-002", ml("Serranda by-pass camino","Stack bypass damper","Przepustnica obejścia komina"), "ev"),
);

window.MODEL = { AREAS, DEVICES };
window.devById = id => DEVICES.find(d => d.id === id);
window.devByArea = a => DEVICES.filter(d => d.area === a);
window.N_TUN = N_TUN;

/* ============================================================
   AUTHENTIC P&ID TAGS — drawing 101-GEN-S-001U Rev.0N
   (DE.CO. Engineering S.r.l. / CASTORES — MTM Ekotechnika,
   Bierkowo-Słupsk). Internal ids stay stable; only the DISPLAYED
   tag is overridden to the real drawing nomenclature.
   Where the demo aggregates a function the sheet splits across
   many items, the closest representative real tag is used.
   ============================================================ */
const TAG_MAP = {
  // 10/14x — feeding & maneuvering hall
  "10LT01":"LP240", "10WT01":"WB01", "10QT01":"QC142",
  "10MP01":"P141A", "10MP02":"P141B", "10MX01":"MX141A", "10MC01":"GR131",
  "10EV01":"EV141A", "10EV02":"EV142A",
  // 5xx — pumps room & percolate reservoirs (RE2)
  "30LT01":"LP221", "30LT02":"LP222", "30TT01":"T511A", "30QT01":"QC511", "30FT01":"FT510",
  "30MP01":"PP520", "30MP02":"PP524", "30MP03":"PP530", "30MX01":"MX142A",
  "30EV01":"EV501A", "30EV02":"EV502A", "30EV03":"EV503A",
  // 26x + TB tanks — biogas storage & treatment
  "40LT01":"LG650", "40PT01":"PC651A",
  "40AT01":"AN710", "40AT02":"AN720", "40AT03":"AN750", "40AT04":"QC267",
  "40FT01":"FT260", "40MB01":"B261", "40MP01":"P560A",
  "40EV01":"EV260A", "40EV02":"EV261A", "40EV03":"EV265A", "40EV04":"EV266A", "40EV05":"EV267A",
  // 6xx — cogeneration (GG265/266/267)
  "50JT01":"J210A", "50JT02":"J210B", "50TT01":"T657A", "50TT02":"T651", "50TT03":"T653",
  "50ST01":"SE265", "50ET01":"J131A", "50GG01":"GG265", "50GG02":"GG266", "50GG03":"GG267",
  "50EV01":"EV601A", "50EV02":"EV602A", "50EV03":"VC341",
  // 65x — boiler room & heating network
  "60TT01":"T654", "60TT02":"T656", "60FT01":"FT655", "60PT01":"PC652",
  "60MP01":"P650A", "60MP02":"P650B", "60EV01":"VC342", "60EV02":"EV604A",
  // 7xx — compressed air
  "70PT01":"PC720", "70TT01":"TT720", "70FT01":"FT720",
  "70MC01":"CU720", "70MC02":"CU721", "70EV01":"V720", "70EV02":"V740",
  // 32x/75x — biofilter & deodorisation
  "80PT01":"PD1201", "80MT01":"MT750", "80TT01":"TT750", "80QT01":"QC721",
  "80MF01":"EF260", "80MF02":"EF261", "80EV01":"EV320A", "80EV02":"VC320",
};
DEVICES.forEach(d => { if (TAG_MAP[d.id]) d.tag = TAG_MAP[d.id]; });
window.TAG_MAP = TAG_MAP;
