<!DOCTYPE html>
<html lang="%lang;">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="%images_prefix;favicon_gwd.png">
<link rel="apple-touch-icon" href="%images_prefix;favicon_gwd.png">
<title>Arbre en éventail %self; (g%e.v;)</title>
<style title="fc-auto"></style>
<style>
  body { margin: 0; padding: 0; }
  svg { position: absolute; left: 0; top: 0; }
  .hidden { display: none; }
</style>
%if;(b.use_cdn="yes")
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
%else;
  <link rel="preload" href="%etc_prefix;css/all.min.css?version=6.7.2" as="style" onload="this.onload=null;this.rel='stylesheet'">
%end;
<link rel="preload" href="%etc_prefix;css/fanchart.css?hash=%apply;hash%with;%etc_prefix;css/fanchart.css%end;" as="style" onload="this.onload=null;this.rel='stylesheet'">
</head>
%define;get_random(xxx)
  %random.init;
  %random.xxx;
%end;
%define;dice()
  %random.init;
  %apply;nth%with;one/two/three/four/five/six%and;%random.6;%end;
%end;
%let;random_index;%if;(nb_persons.v!=0)%apply;get_random(nb_persons.v)%end;%in;
%define;event(xx,yy)
  %if;(xx.yy_place!=""),"yy_place":"%xx.yy_place;"%end;
  %if;(xx.yy_place.sub!=""),"yy_sub":"%xx.yy_place.sub;"%nn;
    %if;(xx.yy_place.main!=""),"yy_main":"%xx.yy_place.main;"%end;
  %end;
  %if;(xx.yy_date!=""),"yy_date":"%xx.yy_date;"%end;
%end;
%define;somebody_fanchart_info(xx,iii,ccc)
  "%if;("xx"="ancestor")S%xx.anc_sosa.v;%elseif;("xx"="spouse")SPccc%elseif;("xx"="child")CHccc%end;":%nn;
  {"fn":"%if(xx.public_name!="")%xx.public_name;%else;%xx.first_name;%end;","fnk":"%xx.first_name_key"%nn;
  ,"sn":"%xx.surname","snk":"%xx.surname_key;"%if;(xx.occ!=0),"oc":"%xx.occ"%end;,"dates":"%xx.dates;"%nn;
  %if;(xx.computable_death_age or xx.computable_age)
    ,"age_text":"%if;xx.is_dead;%if;xx.computable_death_age;%xx.death_age;%end;%else;%if;xx.computable_age;%xx.age;%end;%end;"%nn;
    ,"age":"%if;xx.is_dead;%if;xx.computable_death_age;%xx.death_age_years;%end;%else;%if;xx.computable_age;%xx.age_years;%end;%end;"%end;
  %apply;event("xx","birth")
  %apply;event("xx","baptism")
  %apply;event("xx","death")
  %apply;event("xx","burial")
  %apply;event("xx","cremated")
  %if;("xx"!="child"),"has_parents":%if(xx.has_parents)true%else;false%end;%end;
  %if;("xx"="ancestor"),"sosa":"%xx.anc_sosa.v;"%end;
  %if;(xx.index!=iii and xx.is_male and "xx"!="spouse")
    %foreach;xx.family;
      %if;(family.index = xx.family.index)
        %if;(marriage_date!=""),"marriage_date":"%family.date_s;","marriage_date_":"%marriage_date;"%end;
        %if;(marriage_place!=""),"marriage_place":"%marriage_place;"%end;
        %if;(marriage_place.sub!=""),"marriage_sub":"%marriage_place.sub;"%nn;
          %if;(marriage_place.main!=""),"marriage_main":"%marriage_place.main;"%end;
        %end;
        %if;xx.computable_marriage_age;,"marriage_age":"%marriage_age_years;"%end;
        ,"marriage_length":"%nn;
        %if;(family.marriage_date.year!="")
          %if;(not (are_separated or are_divorced))
            %if;(xx.is_dead and xx.death_date.year!="")
              %if;(xx.spouse.is_dead and xx.spouse.death_date.year!="")
                %if;(xx.death_date.year<xx.spouse.death_date.year)
                  %expr(xx.death_date.year-family.marriage_date.year)
                %else;
                  %expr(xx.spouse.death_date.year-family.marriage_date.year)
                %end;
              %else;
                %expr(xx.death_date.year-family.marriage_date.year)
              %end;
            %elseif;(xx.spouse.is_dead and xx.spouse.death_date.year!="")
              %expr(xx.spouse.death_date.year-family.marriage_date.year)
            %elseif;(not xx.is_dead or not xx.spouse.is_dead)
              %expr(today.year-family.marriage_date.year)
            %end;
          %else;
            %if;(family.divorce_date.year!="" and family.divorce_date.year>family.marriage_date.year)
              %expr(family.divorce_date.year-family.marriage_date.year)
            %end;
          %end;
        %end;"%nn;
      %end;
    %end;
  %end;},
%end;
%define;somebody_fanchart_same(xx)
"S%xx.anc_sosa.v;":{"fn":"","sn":"%xx.anc_sosa.v › %xx.same","sosasame":"%xx.same;","fnk":"%xx.first_name_key","snk":"%xx.surname_key;","oc":"","dates":"","has_parents":%if;(xx.has_parents)true%else;false%end;},
%end;
%define;age_li_item(xx,yy,zz)
      <li id="DA%if;("xx"="marr")M%end;yy" class="legend-item xx-item" role="listitem">
        <span class="legend-swatch xx-yy" aria-hidden="true"></span>
        <span class="legend-text">zz [years old]</span>
      </li>
%end;
<body id="body" class="bg-light p-4"%if;wizard; data-wizard="1"%end;>
<canvas id="pixel" width="1" height="1" style="display: none;"></canvas>
<div id="age-legend" class="age-legend-container">
  <div class="legend-header">
    <h3 class="legend-title">[*age]</h3>
    <button class="legend-close" title="Masquer">×</button>
  </div>
  <div class="legend-section ages-section">
    <h4 class="section-label"><i class="fas fa-user" aria-hidden="true"></i>[*person/persons]1</h4>
    <ul class="legend-list" role="list">
      %apply;age_li_item("age",0,"0-39")
      %apply;age_li_item("age",1,"40-54")
      %apply;age_li_item("age",2,"55-69")
      %apply;age_li_item("age",3,"70-84")
      %apply;age_li_item("age",4,"85+")
      </li>
    </ul>
  </div>
  <div class="legend-section marriages-section">
    <h4 class="section-label"><i class="fas fa-heart" aria-hidden="true"></i>[*marriage/marriages]1</h4>
    <ul class="legend-list" role="list">
      %apply;age_li_item("marr",0,"0-9")
      %apply;age_li_item("marr",1,"10-24")
      %apply;age_li_item("marr",2,"25-39")
      %apply;age_li_item("marr",3,"40-54")
      %apply;age_li_item("marr",4,"55+")
    </ul>
  </div>
</div>
%if;(e.pdf!="on")
<div class="fanchart-controls" id="fanchart-controls">
  <div class="control-section">
    <div class="btn-group-fanchart">
      <button id="b-home" class="btn-fanchart" title="[*home]">
        <i class="fa fa-house fa-fw"></i>
      </button>
      <button id="b-help" class="btn-fanchart" title="Aide et raccourcis">
        <i class="fa fa-info fa-fw"></i>
      </button>
      <button id="b-rng" class="btn-fanchart" title="[*random individual]" data-url="%apply;url_set%with;i/p/n/oc/file/v%and;%random_index;%end;&v=5">
        <i class="fa fa-dice-%apply;dice() fa-fw"></i>
      </button>
    </div>
    <button class="btn-close" id="b-no-buttons" title="[*visualize/show/hide/summary]2">×</button>
  </div>

  <div class="control-section">
    <div class="section-title">[*display]%(TODO: translation%)</div>
    <div class="btn-group-fanchart">
      <button id="b-zoom-out" class="btn-fanchart" title="[*zoom/unzoom]1">
        <i class="fa fa-magnifying-glass-minus fa-fw"></i>
      </button>
      <button id="b-zoom-in" class="btn-fanchart" title="[*zoom/unzoom]0">
        <i class="fa fa-magnifying-glass-plus fa-fw"></i>
      </button>
      <button id="b-refresh" class="btn-fanchart" title="[*resize fanchart]">
        <i class="fa fa-arrow-rotate-right fa-fw"></i>
      </button>
    </div>
  </div>

  <div class="control-section">
    <div class="section-title" id="generation-section-title">[generation/generations]1</div>
    <div class="btn-group-fanchart">
      <button id="b-gen-del" class="btn-fanchart %if;(e.v <= 1)disabled%end;" title="Supprimer une génération">
        <i class="fa fa-minus fa-fw"></i>
      </button>
      <button id="b-gen-add" class="btn-fanchart %if;(e.v >= 10)disabled%end;" title="Ajouter une génération">
        <i class="fa fa-plus fa-fw"></i>
      </button>
      <button id="b-implex" class="btn-fanchart" title="%if;(e.implex="")Développer%else;Réduire%end; les implexes">
        <i class="fa fa-comment-%if;(e.implex="")dots%else;slash%end; fa-fw"></i>
      </button>
    </div>
  </div>

  <div class="control-section">
    <div class="section-title">Ouverture</div>
    <div class="btn-group-fanchart">
      <button id="b-angle-180" class="btn-fanchart" title="Vue en demi-disque (180°)">180̣</button>
      <button id="b-angle-220" class="btn-fanchart active" title="Vue standard (220°)">220</button>
      <button id="b-angle-359" class="btn-fanchart" title="Vue complète (359°)">359</button>
    </div>
  </div>

  <div class="control-section">
    <div class="section-title">Mode</div>
    <div class="btn-group-fanchart">
      <button id="b-angle-360" class="btn-fanchart" title="Mode circulaire : deux demi-disques">360</button>
    </div>
  </div>

  <div class="control-section">
    <div class="btn-group-fanchart">
     <select id="font-selector" class="custom-select custom-select-sm mx-0">
       <option value="">[*font]</option>
       <option value="mono">Mono</option>
       <option value="serif">Serif</option>
       <option value="large">Grande</option>
       <option value="readable">Lisible</option>
    </select>
    </div>
  </div>
  <div class="control-section">
    <div class="section-title">[*tools]</div>
    <div class="btn-group-fanchart">
      <button id="b-age" class="btn-fanchart"
              title="Âges décès et durées mariage">
        <i class="fa fa-cake-candles fa-fw"></i>
      </button>
       <button id="b-places-colorise" class="btn-fanchart"
        title="Colorisation des lieux (cycle entre les événements)">
        <i class="fa fa-map-location-dot fa-fw"></i>
      </button>
     %(
      <button id="b-sort-places" class="btn-fanchart"
        title="Trier par ordre alphabétique">
        <i class="fa fa-arrow-down-a-z fa-fw"></i>
      </button>
     %)
    </div>


  </div>
</div>
<div id="container" style="position: relative;">
  <svg id="fanchart" class="bi ba ma de bu" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
  <div id="person-panel" class="identity-panel"></div>
</div>

<!-- Panneau des lieux modernisé -->
<div class="places-panel" id="places-panel">
  <!-- Bouton pour restaurer le panneau quand il est masqué -->
  <button class="panel-toggle" title="Afficher le panneau">‹</button>

  <!-- Header avec bouton pour masquer -->
  <div class="places-header">
    <div class="header-left">
      <div class="places-title">Lieux &amp; Événements</div>
      <div class="generation-count"></div>
    </div>
    <button class="panel-close" title="Masquer">›</button>
  </div>

  <!-- Contrôles de recherche, tri et mode complet -->
  <div class="controls-search-section">
    <div class="search-input-wrapper">
      <input type="text" class="search-input" placeholder="Rechercher…">
      <button class="search-clear" title="Effacer" style="display: none;">×</button>
    </div>
    <div class="controls-buttons">
      <button class="sort-toggle" title="Tri">
        <i class="fas fa-arrow-down-wide-short"></i>
      </button>
      <button class="events-toggle" title="Événements">
        <i class="far fa-lightbulb"></i>
      </button>
    </div>
  </div>

  <!-- Section de résumé avec compteurs -->
  <div class="summary-section">
    <i class="fas fa-lightbulb summary-helper-icon" title="Totaux"></i>
    <div class="summary-places-info">0 lieux</div>
    <div class="summary-events-table">
      <div class="summary-event-column">
        <span class="summary-event-label birth-label" title="Naissances">N</span>
        <span class="summary-event-count">0</span>
      </div>
      <div class="summary-event-column">
        <span class="summary-event-label baptism-label" title="Baptêmes">B</span>
        <span class="summary-event-count">0</span>
      </div>
      <div class="summary-event-column">
        <span class="summary-event-label marriage-label" title="Mariages">M</span>
        <span class="summary-event-count">0</span>
      </div>
      <div class="summary-event-column">
        <span class="summary-event-label death-label" title="Décès">D</span>
        <span class="summary-event-count">0</span>
      </div>
      <div class="summary-event-column">
        <span class="summary-event-label burial-label" title="Sépultures">S</span>
        <span class="summary-event-count">0</span>
      </div>
    </div>
    <div class="summary-persons">
      <i class="fas fa-user summary-persons-icon" title="[*person/persons]1"></i>
      <span class="summary-persons-count">0</span>
    </div>
    <div class="summary-total-events" title="Total des événements">0</div>
  </div>

  <!-- Container de la liste des lieux -->
  <div class="places-container">
    <div class="places-list"></div>
  </div>
</div>

<script>
var link_to_person = "%prefix;";
var max_gen = %e.v;;
var tool = "%e.tool;";
var implexMode = "%e.implex;" === "num" ? "numbered" :
                 "%e.implex;" === "full" ? "full" : "reduced";
var initial_angle = %if;(e.angle != "")%e.angle;%else;220%end;;
var ancestor = {
%foreach;ancestor_level(e.v)
  %foreach;ancestor;
    %if;(ancestor.same = "")
      %apply;somebody_fanchart_info("ancestor", index, "")
    %else;
      %apply;somebody_fanchart_same("ancestor")
    %end;
  %end;
%end;
};

%reset_count;
var spouses = {
%if;has_families;
  %foreach;family;
    %apply;somebody_fanchart_info("spouse", index, count)
    %incr_count;
  %end;
%end;
};

%reset_count;
var children = {
%if;has_families;
  %foreach;family;
    %if;has_children;
      %foreach;child;
      %apply;somebody_fanchart_info("child", index, count)
      %incr_count;
      %end;
    %end;
  %end;
%end;
};

// Dictionnaire de traductions pour fanchart.js
window.FC_TRANSLATIONS = {
  // Messages généraux
  'no_info_available': "[*no information available]",
  'generation': "[generation/generations]0",
  'generations': "[generation/generations]1",
  'person': "[person/persons]0",
  'persons': "[person/persons]1",
  'occurrence': "[occurence]0",
  'occurrences': "[occurence]1",
  'place': "[place/places]0",
  'places': "[place/places]1",
  'event': "[event/events]0",
  'events': "[event/events]1",
  'birth': "[birth]0",
  'births': "[birth]1",
  'baptism': "[baptism]0",
  'baptisms': "[baptism]1",
  'marriage': "[marriage/marriages]0",
  'marriages': "[marriage/marriages]1",
  'death': "[death]0",
  'deaths': "[death]1",
  'burial': "[burial]0",
  'burials': "[burial]1",
  'implex': "[implex/implexes]0",

  // À vérifier…
  'marriage_years': "[*marriage years]",
  'marriage_year': "[*marriage year]",
  'years_old': "[*years old]",

  // Navigation
  'recenter_tree_on': "[*recenter tree on]",
  'no_known_parents': "[*no known parents]",
  'individual_sheet': "[*individual sheet]",
  'navigation_help': "[*navigation help]",
  'ctrl_click_sheet': "[*ctrl click for individual sheet]",

  // Erreurs
  'error_access_sheet': "[*error accessing individual sheet]",

  // Interface
   'sort_by_frequency': '[*sort by frequency]',
  'sort_alphabetically': '[*sort alphabetically]',
};

// Fonction helper pour récupérer une traduction
window.t = function(key, defaultValue = key) {
  const keys = key.split('.');
  let value = window.FC_TRANSLATIONS;

  for (const k of keys) {
    if (value && typeof value === 'object' && k in value) {
      value = value[k];
    } else {
      return defaultValue;
    }
  }

  return typeof value === 'string' ? value : defaultValue;
};
</script>
<script src="%etc_prefix;js/fanchart.min.js?hash=%apply;hash%with;%etc_prefix;js/fanchart.min.js%end;"></script>
</body>
</html>
