  <!-- $Id: modules/arbre_hi.txt v7.1 04/03/2023 09:51:04 $-->
%let;evarv;%if;(e.v!="")%e.v;%else;5%end;%in;
%let;evart;%if;(e.t!="")%e.t;%else;T%end;%in;
%let;evart1;%if;(e.t1!="")%e.t1;%else;CT%end;%in;
%let;evarhi;%if;(e.hi!="")%e.hi;%else;H%end;%in;
%let;evarim;%if;(e.image!="" and e.image!="off")on%end;%in;
%let;evarix;%if;(e.implx!="" and e.implx="on")on%end;%in;
%let;evarso;%if;(e.sosa!="" and e.sosa="on")on%end;%in;
%let;evarcpl;%if;(e.cpl!="" and e.cpl="on")on%end;%in;
%let;evarsms;%if;(e.sms!="" and e.sms="on")on%end;%in;
%let;evarscl;%if;(e.scale!="")%e.scale;%else;100%end;%in;
%let;evarfs;%if;(e.fs!="")%e.fs;%else;17%end;%in;
%let;fs;%evarfs;%in;
%( dimensions des boites %)
%let;hbc;13%in; %( mode caractère %)
%let;wbc;8%in;
%let;hbs;%if;cgi;24%else;%expr(24*evarscl/100)%end;%in; %( espacement des boites en mode sosa  dimension + marge %)
%let;wbs;%if;cgi;40%else;%expr(40*evarscl/100)%end;%in;
%let;hb1;%if;cgi;22%else;%expr(22*evarscl/100)%end;%in; %( dimensions de la boite sosa %)
%let;wb1;%if;cgi;38%else;%expr(38*evarscl/100)%end;%in;
<style type="text/css">
#hi-tree1 {position:relative;left:10px;}
#hi-tree1 tt{position:absolute;line-height:10pt;font-family:monospace;}
#hi-tree1 span{position:absolute;line-height:10pt;margin:%if;((evarv<9 and evarcpl!="on") or (evarv<10 and evarcpl="on"))8px 12px%else;0px 4px%end;}
#hi-tree1 a{position:absolute;line-height:10pt;}
</style>
<script>
  <!--
  function over1(xx)
  {
   document.getElementById(xx).style.%if;(evarso="on")outline="#C0FEFF solid 6px"%else;backgroundColor="#CBFECE"%end;;
   return false;
  }
  function out1(xx)
  {
   document.getElementById(xx).style.%if;(evarso="on")outline="none"%else;backgroundColor=""%end;;
   return false;
  }
  -->
</script>
%define;implexc(x0,y0,x1,y1)
  %( TODO : fix ugly hack, originaly it was %top/%left without substractions needed %)
  %let;ttt;%if;((evarv<9 and evarcpl!="on") or (evarv<10 and evarcpl="on"))%expr(top-wbc)%else;%expr(top-2)%end;%in;
  %let;lll;%if;((evarv<9 and evarcpl!="on") or (evarv<10 and evarcpl="on"))%expr(left-hbc)%else;%expr(left-4)%end;%in;
  <span style="top:%ttt;px;left:%lll;px;font-family:monospace;">x</span>
  <script>
    $(window).on("load", function() {
      $('#hi-tree1').line(x0, y0, x1, y1, {color:"red", stroke:1, opacity:0.5, zindex:1});
    });
  </script>
%end;
%define;implexs(x0,y0,x1,y1)
  <script>
    $(window).on("load", function() {
      $('#hi-tree1').line(x0, y0, x1, y1, {color:"red", stroke:1, opacity:0.5, zindex:1});
    });
  </script>
%end;
%define;line(x0,y0,x1,y1)
  <script>
    $(window).on("load", function() {
      $('#hi-tree1').line(x0, y0, x1, y1, {stroke:2, opacity:0.3, zindex:-1});
    });
  </script>
%end;
%define;implex1(xx)
  onmouseover="over1('sxx')" onmouseout="out1('sxx')" %nn;
%end;
%define;bg(xx)
  %apply;nth%with;
    /FFFFFF/FFC8E3/F0CBFE/DDCEFF/FFA8D3/E7A9FE/FF86C2/DD88FD/FF62B0/C4ABFE/C433FE/FFFFFF/
  %and;xx%end;
%end;
%define;size(xx)
  %apply;nth%with;
    %if;(evarso="on")
      //70/70/70/190/190/430/430/600/600/950/950/
    %else;
      //50/50/105/105/215/215/410/410/840/840/1650/1650/
    %end;
  %and;xx%end;
%end;
%define;wid(xx) %(nb of cells in the width of the total graph %)
  %apply;nth%with;/////7/7/15/15/31/31/63/63/127%and;xx%end;
%end;
%define;hig(xx) %(nb of cells in the height of the total graph %)
  %apply;nth%with;/////3/7/7/15/15/31/31/63/63/127%and;ll%end;
%end;
%define;divsr(xx)
  %apply;nth%with;/1/2/4/8/16/32/64/128/256/512%and;xx%end;
%end;
%include;modules/arbre_hi_indexes
%define;prefix_all()
  %if;(e.templ!="")templ=%e.templ;p%end;%nn;
  %if;(e.wide!="")wide=%e.wide;&%end;%nn;
  %if;(e.p_mod!="")p_mod=%e.p_mod;&%end;%nn;
%end;

%(a=ancestor, s=sosa, p=has_parents, bg=background, t=top, l=left  %)
%define;boxsosa(aaa, sss, ppp, bgg, lll, ttt)
  %let;bg_col;bgg%in;
  <div id="s%aaaanc_sosa.v;"%nn;
    style="position:absolute;border:solid 1px;top:tttpx;left:lllpx;%nn;
    %if;(aaasame="")
      %if;(evarcpl="on")
        %if;(not aaahas_parents)border-left: 3px solid;%end;%nn;
        %if;(not aaaspouse.has_parents)border-right: 3px solid;%end;%nn;
      %elseif;(not aaahas_parents )
         border-top:3px solid;%nn;
      %end;
    %end;
    width:%if;(boxsize=2)%expr(wb1*2)%else;%wb1;%end;px;%nn;
    height:%if;(boxsize=2)%expr(hb1*2)%else;%hb1;%end;px;%nn;
    background-color:%if;(bg_col="")#FFFFFF%else;#bgg;%end;;zindex:2">
    %let;imsz;%if;(boxsize=2)15%else;8%end;%in;
    %if;(e.cgl!="on")
      %if;(evarcpl!="on")
        <a class="big_anchor_1 list-group-item-action"
          href='%prefix;%aaaaccess;'
          title="%aaafirst_name; %aaasurname; (%aaaocc;)">
          %if;(aaahas_image)
            <img style="width:%imsz;px" src="%aaaimage_url;" alt="[image/images]0">
          %end;
        </a>
        <a class="big_anchor_1m list-group-item-action"
          href="%prefix_set.all;%apply;prefix_all();m=MOD_IND&i=%aaaindex;"
          title="Modifier %aaafirst_name; %aaasurname; (%aaaocc;)">
        </a>
      %else;
        <a class="big_anchor_him list-group-item-action"
          href='%prefix;%aaaaccess;'
          title="%aaafirst_name; %aaasurname; (%aaaocc;)">
          %if;(aaahas_image)
            <img style="width:%imsz;px" src="%aaaimage_url;" alt="[image/images]0">
          %end;
        </a>
        %if;(aaasame="")
        <a class="big_anchor_her list-group-item-action"
          href='%prefix;%aaaspouse.access;'
          title="%aaaspouse;">
          %if;(aaaspouse.has_image)
            <img style="width:%imsz;px" src="%aaaspouse.image_url;" alt="[image/images]0">
          %end;
        </a>
        %end;
        <a class="big_anchor_him_m list-group-item-action"
          href="%prefix_set.all;%apply;prefix_all();m=MOD_IND&i=%aaaindex;"
          title="Modifier %aaafirst_name; %aaasurname; (%aaaocc;)">
        </a>
        %if;(aaasame="")
        <a class="big_anchor_her_m list-group-item-action"
          href="%prefix_set.all;%apply;prefix_all();m=MOD_IND&i=%aaaspouse.index;"
          title="Modifier %aaaspouse;">
        </a>
        %end;
      %end;
    %else;
      %let;width;%if;(boxsize=2)%expr(wb1*2)%else;%wb1;%end;%in;
      %let;imsz;%if;(boxsize=2)15%else;8%end;%in;
      %let;fs1;%if;(sss>999)%expr(fs-10)%elseif;(boxsize=2)%fs;%else;%expr(fs-5)%end;%in;
      %let;tm;%if;(boxsize=2)8%else;2%end;%in;
      %let;dw1;%expr(width-imsz)%in;
      %let;dw2;%expr(width-2*imsz)%in;
      %let;dm;%if;(aaahas_image)%imsz;%end;%in;
      %if;(evarcpl!="on")
        <div class="d-flex">
        %if;(aaahas_image)
          <img style="width:%imsz;px" src="%aaaimage_url;" alt="[image/images]0">
        %end;
        <span style="margin:0 0 2px 0;text-align:center;width:%dw1;px;font-size:%fs1;px;">
          %if;(aaaanc_sosa!="")%aaaanc_sosa;%else;1%end;
        </span>
        </div>
      %else;
        <div class="d-flex justify-content-between">
        %if;(aaahas_image)%nn;
          <div style="margin:0 0 2px 0"><img style="width:%imsz;px" src="%aaaimage_url;" alt="[image/images]0"></div>%nn;
        %else;
          <div style="margin:0 0 2px 0;width:%imsz;px"></div>
        %end;%nn;
        <div style="margin:0 0 2px 0;text-align:center;width:%dw2;px;font-size:%fs1;px;">%nn;
          %if;(aaaanc_sosa!="")%aaaanc_sosa;%else;1%end;%nn;
        </div>%nn;
        %if;(aaaspouse.has_image)%nn;
          <div style="margin:0 0 2px 0"><img style="width:%imsz;px" src="%aaaspouse.image_url;" alt="[image/images]0"></div>%nn;
        %end;%nn;
        </div>
      %end;
    %end;
    %if;(e.cgl!="on")
    <div>
      <a style="width:100%%;zindex:2;"
        href="%prefix_base_password;%aaaaccess;&t=T&t1=CT&
          %foreach;env_binding;%if;(not (env.key="t" or env.key="t1" or env.key="p"
            or env.key="n" or env.key="oc"))%env.key=%env.val;&%end;%end;"
        %if;(aaasame!="")%apply;implex1(aaasame.v)%end;%nn;
        title='[*generation/generations]0 %level; – Sosa %nn;
          %if;(evarcpl="")%aaaanc_sosa; %if;(aaasame!="")=Sosa %aaasame;%end;
          %else;%aaaanc_sosa; & %expr(aaaanc_sosa.v+1)%nn;
          %end;&#010;%nn;
          %if;(aaais_male) ♂%else; ♀%end; %aaafirst_name; %aaasurname; %if;(aaaocc!="" or aaaocc!=0)(%aaaocc;)%end;&#010;%nn;
          %if;(aaabirth_date.year!="")° %aaabirth_date.year;%end;%nn;
          %if;(aaabirth_date.year!="" and aaais_dead) – %end;%nn;
          %if;(aaabirth_date.year="" and aaadeath_date.year!="")†%else;%aaadeath_date.year;%end;&#010;%nn;
          %if;(not aaahas_parents) [*missing parents].&#010;%end;%nn;
          %if;(aaasame=""  and aaahas_families and evarcpl="on")%nn;
            %if;(aaaspouse.is_male) ♂%else; ♀%end; %aaaspouse; (%aaaspouse.occ;)&#010;%nn;
            %if;(aaaspouse.birth_date.year!="")° %aaaspouse.birth_date.year;%end;%nn;
            %if;(aaaspouse.birth_date.year!="" and aaaspouse.is_dead) – %end;%nn;
            %if;(aaaspouse.birth_date.year="" and aaaspouse.death_date.year!="")†%else;%aaaspouse.death_date.year;%end;&#010;%nn;
            %if;(not aaaspouse.has_parents) [*missing parents].%end;%nn;
          %end;'>
        %let;fs1;%if;(sss>999)%expr(fs-10)%elseif;(boxsize=2)%fs;%else;%expr(fs-5)%end;%in;
        %let;tm;%if;(boxsize=2)8%else;2%end;%in;
        <span style="margin:%tm;px 0 2px 0;text-align:center;width:100%%;font-size:%fs1;px;">
          %if;(aaaanc_sosa!="")%aaaanc_sosa;%else;1%end;
        </span>
      </a>
    </div>
    %end;
  </div>
%end;

%define;linesosa(ss0, ll, yy, x0, y0)
  %( ss=sosa, ll=level, yy=orientation I or H, x0, y0=coordinates of top left corner of box %)
  %( x axis to the right, y axis to bottom %)
  %let;ss;%if;(evarcpl="on")%expr(ss0/2)%else;ss0%end;%in;
  %if;(ss!=1)
    %let;lev;
      %if;(ss>=1 and ss<2)1%nn;
      %elseif;(ss>=2 and ss<4)2%nn;
      %elseif;(ss>=4 and ss<8)3%nn;
      %elseif;(ss>=8 and ss<16)4%nn;
      %elseif;(ss>=16 and ss<32)5%nn;
      %elseif;(ss>=32 and ss<64)6%nn;
      %elseif;(ss>=64 and ss<128)7%nn;
      %elseif;(ss>=128 and ss<256)8%nn;
      %elseif;(ss>=256 and ss<512)9%nn;
      %elseif;(ss>=512 and ss<1024)10%nn;
      %elseif;(ss>=1024 and ss<2048)11%nn;
      %elseif;(ss>=2048 and ss<4096)12%nn;
      %elseif;(ss>=4096 and ss<8192)13%nn;
      %else;14%end;
    %in;
    %let;www;%apply;nth%with;///4/4/8/8/16/16/32/32/64/64/128/128/%and;ll%end;%in;
    %let;hhh;%apply;nth%with;///4/8/8/16/16/32/32/64/64/128/128/%and;ll%end;%in;
    %let;ddd;%apply;nth%with;/1/2/4/4/8/8/16/16/32/32/64/64/128/128/256/256/512/512/%and;%nn;
        %if;("yy"="H")%lev;%else;%expr(lev-1)%end;%end;%nn;
    %in;
    %let;or;%nn;
      %if;("yy"="H")%apply;nth%with;/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/%and;%lev;%end;%nn;
      %else;%apply;nth%with;/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/v/h/%and;%lev;%end;%nn;
      %end;%nn;
    %in;
    %let;twid0;%expr(www*wbs)%in;
    %let;twid;%if;("yy"="H")%expr(twid0*2)%else;%expr(twid0)%end;%in;
    %let;thig;%expr(hhh*hbs)%in;
    %let;len;%if;(or="h")%expr(twid/ddd)%else;%expr(thig/ddd)%end;%in;
    %let;len2;%if;(boxsize=2)%len;%else;%expr(len/2)%end;%in;
    %let;wb2;%if;(boxsize=2)%wb1;%else;%expr(wb1/2)%end;%in;
    %let;hb2;%if;(boxsize=2)%hb1;%else;%expr(hb1/2)%end;%in;
    %let;x1;%expr(x0+wb2)%in;
    %let;y1;%expr(y0+hb2)%in;
    %let;x2;%if;(or="h")%if;(ss%2=0)%expr(x1+len2)%else;%expr(x1-len2)%end;%else;%x1;%end;%in;
    %let;y2;%if;(or="v")%if;(ss%2=0)%expr(y1+len2)%else;%expr(y1-len2)%end;%else;%y1;%end;%in;
    %apply;line(x1, y1, x2, y2)
  %end;
%end;

%define;boxchar(aaa,yyy,lll,ttt) %( ttt and lll seem to be inversed in boxsosa%)
  %let;xxx;%if;(evarcpl="on")%expr(aaaanc_sosa.v/2)%else;%aaaanc_sosa.v;%end;%in;
  <div id="s%aaaanc_sosa.v;" style="font-family:monospace;margin:0">
    <a style="top:tttpx;left:lllpx;"
      href='%prefix_set.all;%apply;prefix_all();%aaaaccess;&'
      %if;(aaasame!="")%apply;implex1(aaasame.v)%end;
      title='[*generation/generations]0 %level; – Sosa %nn;
        %if;(evarcpl="")%aaaanc_sosa; %if;(aaasame!="")=Sosa %aaasame;%end;
        %else;%aaaanc_sosa; & %expr(aaaanc_sosa.v+1)%nn;
        %end;&#010;%nn;
        %(%if;("aaainterval"!="")=Sosa %aaainterval;;%else;%aaaanc_sosa; & %expr(aaaanc_sosa.v+1)%end;&#010;%)%nn;
        %if;(aaais_male) ♂%else; ♀%end; %aaafirst_name; %aaasurname; %if;(aaaocc!="" or aaaocc!=0)(%aaaocc;)%end;&#010;%nn;
        %if;(aaabirth_date.year!="")° %aaabirth_date.year;%end;%nn;
        %if;(aaabirth_date.year!="" and aaais_dead) – %end;%nn;
        %if;(aaabirth_date.year="" and aaadeath_date.year!="")†%else;%aaadeath_date.year;%end;&#010;%nn;
        %if;(not aaahas_parents) [*missing parents].&#010;%end;%nn;
        %if;(aaasame="" and aaahas_families and evarcpl="on")%nn;
          %if;(aaaspouse.is_male) ♂%else; ♀%end; %aaaspouse; (%aaaspouse.occ;)&#010;%nn;
          %if;(aaaspouse.birth_date.year!="")° %aaaspouse.birth_date.year;%end;%nn;
          %if;(aaaspouse.birth_date.year!="" and aaaspouse.is_dead) – %end;%nn;
          %if;(aaaspouse.birth_date.year="" and aaaspouse.death_date.year!="")†%else;%aaaspouse.death_date.year;%end;&#010;%nn;
          %if;(not aaaspouse.has_parents) [*missing parents].%end;%nn;
        %end;'
    >
    %if;(xxx=1)┼
    %elseif;((xxx>1 and xxx<4) or (xxx>7 and xxx<16) or (xxx>31 and xxx<64) or
             (xxx>127 and xxx<256) or (xxx>511 and xxx<1024) or (xxx>2047 and xxx<4096))
      %if;("yyy"="H")
        %if;(xxx%2=0)
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┐
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┌
          %elseif;(not ancestor.has_parents)╷
          %else;┬%end;
        %else;
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┘
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)└
          %elseif;(not ancestor.has_parents)╵
          %else;┴%end;
        %end;
      %else;
         %if;(xxx%2=0)
           %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)└
           %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┌
           %elseif;(not ancestor.has_parents)╶
           %else;├%end;
         %else;
           %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┘
           %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┐
           %elseif;(not ancestor.has_parents)╴
           %else;┤%end;
         %end;
      %end;
    %elseif;((xxx>3 and xxx<8) or (xxx>15 and xxx<32) or (xxx>63 and xxx<128) or
             (xxx>255 and xxx<512) or (xxx>1023 and xxx<2048) or (xxx>4095 and xxx<8192))
      %if;("yyy"="H")
        %if;(xxx%2=0)
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)└
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┌
          %elseif;(not ancestor.has_parents)╶
          %else;├%end;
        %else;
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┘
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┐
          %elseif;(not ancestor.has_parents)╴
          %else;┤%end;
        %end;
      %else;
        %if;(xxx%2=0)
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┐
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)┌
          %elseif;(not ancestor.has_parents)╷
          %else;┬%end;
        %else;
          %if;(evarcpl="on" and not ancestor.spouse.has_parents and ancestor.has_parents)┘
          %elseif;(evarcpl="on" and not ancestor.has_parents and ancestor.spouse.has_parents)└
          %elseif;(not ancestor.has_parents)╵
          %else;┴%end;
        %end;
      %end;
    %end;
    </a>
  </div>
%end;

%define;linechar(nn,yy,oo) %( nn #linechar, yy I ou H, oo orientation %)
  <span style="top:%top_;px;left:%left_;px;font-family:monospace;margin:0">
  %for;i;0;nn;
    %if;(oo=0)
      %if;("yy"="H")│<br>%else;─%if;(evarso="on" and (evarv<9 and evarcpl!="on") or (evarv<8 and evarcpl="on") and nn!=1)───%elseif;(evarso="on" and nn!=1)─%end;%end;
    %elseif;(oo=1)
      %if;("yy"="H")─%if;(evarso="on" and (evarv<9 and evarcpl!="on") or (evarv<8 and evarcpl="on") and nn!=1)───%elseif;(evarso="on" and nn!=1)─%end;%else;│<br>%end;
    %end;
  %end;
  </span>
%end;

%define;graph(xx,yy,zz) %( xx gen ; yy mode I ou H; zz 1=single 2=couple %)
  %let;x_1;%expr(xx-1)%in;
  %let;hb;%if;(evarso="on" and boxsize=2)%expr(hbs*2)%elseif;(evarso="on")%hbs;%else;%hbc;%end;%in;
  %let;wb;%if;(evarso="on" and boxsize=2)%expr(wbs*2)%elseif;(evarso="on")%wbs;%else;%wbc;%end;%in;
  %let;wb2;%if;(evarso="on" and boxsize=2)%expr(wb1*2)%elseif;(evarso="on")%wb1;%else;%wbc;%end;%in;
  %if;(zz=2)  %( par couple %)
    %foreach;ancestor_level(xx)
      %foreach;ancestor;
        %if;(ancestor.anc_sosa.v %2=0)
          %let;anc_sosahalf;%expr(ancestor.anc_sosa.v/2)%in;
          %let;anc_sosasamehalf;%if;(ancestor.same.v!="")%expr(ancestor.same.v/2)%else;0%end;%in;
          %let;top;%expr(topxx_yy(anc_sosahalf)*hb)%in; %( top left corner %)
          %let;left;%expr(leftxx_yy(anc_sosahalf)*wb)%in;
          %let;top1;%expr(topxx_yy(anc_sosahalf)*hb+6)%in; %( offset for implex liens %)
          %let;left1;%expr(leftxx_yy(anc_sosahalf)*wb+4)%in;
          %let;top2;%expr(topxx_yy(anc_sosasamehalf)*hb+6)%in;
          %let;left2;%expr(leftxx_yy(anc_sosasamehalf)*wb+4)%in;
          %let;bg;%if;(ancestor.same!="")CBFECE;%elseif;(evarcpl="on")%apply;bg(level-1)%else;%apply;bg(level)%end;%in;
          %if;(evarso!="on")
            %if;(ancestor.same!="" and evarix="on")%apply;implexc(left1, top1, left2, top2)%end;
            %if;(ancestor.anc_sosa.v!="" or ancestor.anc_sosa.v=1)
              %apply;boxchar("ancestor.", "yy", left, top)
            %else;
              %apply;boxchar("", "yy", left, top)
            %end;
          %else;
            %if;(ancestor.same!="" and evarix="on")%apply;implexs(left1, top1, left2, top2)%end;
            %if;(ancestor.anc_sosa.v!="" or ancestor.anc_sosa.v=1)
              %apply;boxsosa("ancestor.", ancestor.anc_sosa.v, ancestor.has_parents, bg, left, top)
            %else;
              %apply;boxsosa("", ancestor.anc_sosa.v, ancestor.has_parents, bg, left, top)
            %end;
            %apply;linesosa(ancestor.anc_sosa.v, xx+1, "yy", left, top)
          %end;
        %end;
      %end;
    %end;
    %foreach;ancestor_level(xx)
      %foreach;ancestor;
        %let;top4;%expr(topxx_yy(ancestor.anc_sosa.v)*hb)%in;
        %let;left4;%expr(leftxx_yy(ancestor.anc_sosa.v)*wb)%in;
        %let;hb4;%expr(hb-4)%in;
        %let;bb;%if;(evarso="on")1%else;0%end;%in;
        %if;(not ancestor.has_parents and evarsms="on" and level<e.v)
          <div id="s%ancestor.anc_sosa.v;"
            style="position:absolute;text-align:center;border:solid %bb;px;top:%top4;px;left:%left4;px;
              width:%wb2;px;height:%hb4;px;background-color:#FFFFFF">
            <a href="%prefix_set.all;%apply;prefix_all();m=ADD_PAR;ip=%ancestor.index;"
              target="_blank"
              title="[missing sosa] %expr(ancestor.anc_sosa.v*2) & %expr(ancestor.anc_sosa.v*2+1) – [*generation/generations]0 %expr(level+1)&#010; %nn;
              [*add] %apply;a_of_b%with;[the parents]%and;Sosa %ancestor.anc_sosa.v;%end; %ancestor;"
            >%if;(evarso="on")•%else;·%end;</a>
          </div>
        %(%apply;linesosa(ancestor.anc_sosa.v*2, xx+1, "yy", left4, top4%)
        %end;
      %end;
    %end;
  %else; %( single %)
    %foreach;ancestor_level(x_1)
      %foreach;ancestor;
        %let;top;%expr(topxx_yy(ancestor.anc_sosa.v)*hb)%in; %( top left corner %)
        %let;left;%expr(leftxx_yy(ancestor.anc_sosa.v)*wb)%in;
        %let;top1;%expr(topxx_yy(ancestor.anc_sosa.v)*hb+6)%in; %( offset for implex liens %)
        %let;left1;%expr(leftxx_yy(ancestor.anc_sosa.v)*wb+4)%in;
        %let;top2;%if;(ancestor.same!="")%expr(topxx_yy(ancestor.same.v)*hb+6)%end;%in;
        %let;left2;%if;(ancestor.same!="")%expr(leftxx_yy(ancestor.same.v)*wb+4)%end;%in;
        %let;bb;%if;(evarso="on")1%else;0%end;%in;
        %let;bg;%if;(ancestor.same!="")CBFECE;%elseif;(evarcpl="on")%apply;bg(level-1)%else;%apply;bg(level)%end;%in;
        %if;(evarso!="on")
          %if;(ancestor.same!="" and evarix="on")
            %apply;implexc(left1, top1, left2, top2)
          %else;
            %if;(ancestor.anc_sosa.v!="" or ancestor.anc_sosa.v=1)
              %apply;boxchar("ancestor.", "yy", left, top)
            %else;
              %apply;boxchar("", "yy", left, top)
            %end;
          %end;
        %else;
          %if;(ancestor.same!="" and evarix="on")
            %apply;implexc(left1, top1, left2, top2)%end;
            %if;(ancestor.anc_sosa.v!="" or ancestor.anc_sosa.v=1)
              %apply;boxsosa("ancestor.", ancestor.anc_sosa.v, ancestor.has_parents, bg, left, top)
            %else;
              %apply;boxsosa("", ancestor.anc_sosa.v, ancestor.has_parents, bg, left, top)
            %end;
          %apply;linesosa(ancestor.anc_sosa.v, xx+1, "yy", left, top)
        %end;
      %end;
    %end;
    %foreach;ancestor_level(x_1)
      %foreach;ancestor;
        %if;(not ancestor.has_parents and evarsms="on" and level<e.v)
          %let;top2;%expr(topxx_yy(ancestor.anc_sosa.v*2)*hb)%in;
          %let;left2;%expr(leftxx_yy(ancestor.anc_sosa.v*2)*wb)%in;
          %let;hb4;%expr(hb-4)%in;
          %let;bb;%if;(evarso="on")1%else;0%end;%in;
          <div id="s%ancestor.anc_sosa.v;"
            style="position:absolute;text-align:center;border:solid %bb;px;top:%top2;px;left:%left2;px;
              width:%wb2;px;height:%hb4;px;background-color:#FFFFFF">
            <a href="%prefix_set.all;%apply;prefix_all();m=ADD_PAR;ip=%ancestor.index;"
              title="[missing sosa] %expr(ancestor.anc_sosa.v*2) & %expr(ancestor.anc_sosa.v*2+1) – [*generation/generations]0 %expr(level+1)&#010;%nn;
              [*add] %apply;a_of_b%with;[the parents]%and;Sosa %ancestor.anc_sosa.v; %ancestor;%end;"
            >%if;(evarso="on")•%else;·%end;</a>
          </div>
          %let;top3;%expr(topxx_yy(ancestor.anc_sosa.v*2+1)*hb)%in;
          %let;left3;%expr(leftxx_yy(ancestor.anc_sosa.v*2+1)*wb)%in;
          <div id="s%ancestor.anc_sosa.v;"
            style="position:absolute;text-align:center;border:solid %bb;px;top:%top3;px;left:%left3;px;
              width:%wb2;px;height:%hb4;px;background-color:#FFFFFF">
            <a href="%prefix_set.all;%apply;prefix_all();m=ADD_PAR;ip=%ancestor.index;"
              target="_blank"
              title="[missing sosa] %expr(ancestor.anc_sosa.v*2) & %expr(ancestor.anc_sosa.v*2+1) – [*generation/generations]0 %expr(level+1)&#010;%nn;
              [*add] %apply;a_of_b%with;[the parents]%and;%ancestor; Sosa %ancestor.anc_sosa.v;%end;"
            >%if;(evarso="on")•%else;·%end;</a>
          </div>
        %end;
      %end;
    %end;
  %end;
%end;

%define;graphlinks(xx,yy) %( xx level -1, yy mode : I ou H %)
  %let;hb;%if;(evarso="on" and boxsize=2)%expr(hbs*2)%elseif;(evarso="on")%hbs;%else;%hbc;%end;%in;
  %let;wb;%if;(evarso="on" and boxsize=2)%expr(wbs*2)%elseif;(evarso="on")%wbs;%else;%wbc;%end;%in;
  %if;(evarso!="on")
  %foreach;ancestor_level(xx-2)
    %foreach;ancestor;
      %let;top_;%expr(topxx_yy_(ancestor.anc_sosa.v)*hb)%in;
      %let;left_;%expr(leftxx_yy_(ancestor.anc_sosa.v)*wb)%in;
      %let;aaa;%if;("yy"="H")1%else;0%end;%in;
      %let;bbb;%if;("yy"="H")0%else;1%end;%in;
      %if;((evarcpl="on" and ancestor.has_parents) or (evarcpl!="on" and ancestor!=""))
        %if;(ancestor.anc_sosa.v=2 or ancestor.anc_sosa.v=3)
          %if;(xx=4 or xx=5)       %apply;linechar(1,yy,aaa)
          %elseif;(xx=6 or xx=7)   %apply;linechar(3,yy,aaa)
          %elseif;(xx=8 or xx=9)   %apply;linechar(7,yy,aaa)
          %elseif;(xx=10 or xx=11) %apply;linechar(15,yy,aaa)
          %elseif;(xx=12)          %apply;linechar(31,yy,aaa)
          %end;
        %elseif;(ancestor.anc_sosa.v>3 and ancestor.anc_sosa.v<8)
          %if;(xx=5 or xx=6)       %apply;linechar(1,yy,bbb)
          %elseif;(xx=7 or xx=8)   %apply;linechar(3,yy,bbb)
          %elseif;(xx=9 or xx=10)  %apply;linechar(7,yy,bbb)
          %elseif;(xx=11 or xx=12) %apply;linechar(15,yy,bbb)
          %end;
        %elseif;(ancestor.anc_sosa.v>7 and ancestor.anc_sosa.v<16)
          %if;(xx=6 or xx=7)       %apply;linechar(1,yy,aaa)
          %elseif;(xx=8 or xx=9)   %apply;linechar(3,yy,aaa)
          %elseif;(xx=10 or xx=11) %apply;linechar(7,yy,aaa)
          %elseif;(xx=12)          %apply;linechar(15,yy,aaa)
          %end;
        %elseif;(ancestor.anc_sosa.v>15 and ancestor.anc_sosa.v<32)
          %if;(xx=7 or xx=8)       %apply;linechar(1,yy,bbb)
          %elseif;(xx=9 or xx=10)  %apply;linechar(3,yy,bbb)
          %elseif;(xx=11 or xx=12) %apply;linechar(7,yy,bbb)
          %end;
        %elseif;(ancestor.anc_sosa.v>31 and ancestor.anc_sosa.v<64)
          %if;(xx=8 or xx=9)       %apply;linechar(1,yy,aaa)
          %elseif;(xx=10 or xx=11) %apply;linechar(3,yy,aaa)
          %elseif;(xx=12)          %apply;linechar(7,yy,aaa)
          %end;
        %elseif;(ancestor.anc_sosa.v>63 and ancestor.anc_sosa.v<128)
          %if;(xx=9 or xx=10)      %apply;linechar(1,yy,bbb)
          %elseif;(xx=11 or xx=12)  %apply;linechar(3,yy,bbb)
          %end;
        %elseif;(ancestor.anc_sosa.v>127 and ancestor.anc_sosa.v<256)
          %if;(xx=10 or xx=11)     %apply;linechar(1,yy,aaa)
          %elseif;(xx=12)          %apply;linechar(3,yy,aaa)
          %end;
        %elseif;(ancestor.anc_sosa.v>255 and ancestor.anc_sosa.v<512)
          %if;(xx=11 or xx=12)     %apply;linechar(1,yy,bbb)
          %end;
        %elseif;(ancestor.anc_sosa.v>511 and ancestor.anc_sosa.v<1024)
          %if;(xx=12)              %apply;linechar(1,yy,aaa)
          %end;
        %end;
      %end;
    %end;
  %end;
  %end;
%end;

%define;my_title(aa, bb, tt)
 [*aa:::bb:tt]
%end;
<h2 class="display-5 ml-3">%apply;my_title("ancestors tree of", e.hi, first_name) %surname; %dates (%e.v; [generation/generations]1)</h3>
%let;boxsize;%if;((evarv<9 and evarcpl!="on") or (evarv<10 and evarcpl="on"))2%else;1%end;%in;
%if;((evarcpl="on" and evarv < 4) or (evarcpl!="on" and evarv < 3))
  [*compact tree][:] [specify::generation/generations]0 > 3.
%else;
  %let;vvv;%if;(evarcpl="on")%evarv;%else;%expr(evarv+1)%end;%in;
  %let;mmm;%if;(evarso="on" and boxsize=2)2%else;1%end;%in;
  %let;nbc;%apply;nth%with;/0/1/1/3/3/7/7/15/15/31/31/63/63/127/127/255/255/%and;%nn;
    %if;(evarhi="H")%expr(vvv+1)%else;%expr(vvv)%end;%end;%in;
  %let;nbl;%apply;nth%with;/0/1/1/3/3/7/7/15/15/31/31/63/63/127/127/255/255/%and;%nn;
    %if;(evarhi="H")%expr(vvv)%else;%expr(vvv+1)%end;%end;%in;
  %let;widc;%expr(mmm*nbc*wbc)%in;
  %let;wids;%expr(mmm*nbc*wbs)%in;
  %let;higc;%expr(mmm*nbl*hbc)%in;
  %let;higs;%expr(mmm*nbl*hbs)%in;
  %if;(evarv >= 3)
    %if;(evarhi="H" or evarhi="")
      %if;(evarso="on")
        %if;(evarv < 13 and evarcpl="on")
          <div id="hi-tree1" style="width:%wids;px;height:%higs;px">
          %apply;graphlinks(evarv,"I")
          %apply;graph(evarv,"I",2)
          </div>
        %elseif;(evarv < 12 and evarcpl!="on")
          <div id="hi-tree1" style="width:%wids;px;height:%higs;px">
          %apply;graphlinks(evarv+1,"I")
          %apply;graph(evarv+1,"I",1)
          </div>
        %else;
          [*compact tree][:] [specify::generation/generations]0 %if;(evarcpl="on")< 13.%else;< 12.%end;
        %end;
      %elseif;(evarso!="on")
        %if;(evarv < 14 and evarcpl="on")
          <div id="hi-tree1" style="width:%widc;px;height:%higc;px">
          %apply;graphlinks(evarv,"I")
          %apply;graph(evarv,"I",2)
          </div>
        %elseif;(evarv < 13 and evarcpl!="on")
          <div id="hi-tree1" style="width:%widc;px;height:%higc;px">
          %apply;graphlinks(evarv+1,"I")
          %apply;graph(evarv+1,"I",1)
          </div>
        %else;
          [*compact tree][couples][:] [specify::generation/generations]0%if;(evarcpl="on")< 14.%else;< 13.%end;
        %end;
      %end;
    %elseif;(evarhi="I")
      %if;(evarso="on")
        %if;(evarv < 13 and evarcpl="on")
          <div id="hi-tree1" style="width:%wids;px;height:%higs;px">
          %apply;graphlinks(evarv,"H")
          %apply;graph(evarv,"H",2)
          </div>
        %elseif;(evarv < 12 and evarcpl!="on")
          <div id="hi-tree1" style="width:%wids;px;height:%higs;px">
          %apply;graphlinks(evarv+1,"H")
          %apply;graph(evarv+1,"H",1)
          </div>
        %else;
          [*compact tree][:] [specify::generation/generations]0%if;(evarcpl="on")< 13.%else;< 12.%end;
        %end;
      %elseif;(evarso!="on")
        %if;(evarv < 14 and evarcpl="on")
          <div id="hi-tree1" style="width:%widc;px;height:%higc;px">
          %apply;graphlinks(evarv,"H")
          %apply;graph(evarv,"H",2)
          </div>
        %elseif;(evarv < 13 and evarcpl!="on")
          <div id="hi-tree1" style="width:%widc;px;height:%higc;px">
          %apply;graphlinks(evarv+1,"H")
          %apply;graph(evarv+1,"H",1)
          </div>
        %else;
          [*compact tree][:] [specify::generation/generations]0%if;(evarcpl="on")< 14.%else;< 13.%end;
        %end;
      %end;
    %else;no hi
    %end;
  %end;
%end;
