1import{r as c,j as e,W as b,X as Q,a4 as W,K as T,B as _,a7 as X,f as v,a6 as Y,s as f,e as Z,h as R,c as L,d as O,a8 as F}from"./index-BNGXKjJb.js";import{O as P,C as z,a as ee,T as M,D as U,R as te,b as ae,P as ne}from"./index-DNCZTDFl.js";import{C as D}from"./circle-help-CW6JZd46.js";import{S as se}from"./shield-alert-B30HuGMg.js";import{F as ie}from"./file-text-PuvwG3rP.js";import{D as re}from"./download-BlJ1qOxA.js";import{H as oe}from"./HelpdeskContact-DIdexiH1.js";import{D as ce,a as le,b as de,c as me,d as ue,e as fe}from"./dialog-MheTz5Oq.js";import{C as pe}from"./checkbox-D89n26-Y.js";import{S as he}from"./shield-check-CJw5ILPg.js";const ge=te,xe=ae,ve=ne,q=c.forwardRef(({className:n,...a},t)=>e.jsx(P,{className:b("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...a,ref:t}));q.displayName=P.displayName;const be=W("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),J=c.forwardRef(({side:n="right",className:a,children:t,...i},o)=>e.jsxs(ve,{children:[e.jsx(q,{}),e.jsxs(z,{ref:o,className:b(be({side:n}),a),...i,children:[t,e.jsxs(ee,{className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));J.displayName=z.displayName;const K=({className:n,...a})=>e.jsx("div",{className:b("flex flex-col space-y-2 text-center sm:text-left",n),...a});K.displayName="SheetHeader";const H=c.forwardRef(({className:n,...a},t)=>e.jsx(M,{ref:t,className:b("text-lg font-semibold text-foreground",n),...a}));H.displayName=M.displayName;const B=c.forwardRef(({className:n,...a},t)=>e.jsx(U,{ref:t,className:b("text-sm text-muted-foreground",n),...a}));B.displayName=U.displayName;const j={national:{key:"usage-national",path:"utilisation/Guide_Admin_National_AR_FR.pdf",filename:"Guide_Admin_National_AR_FR.pdf",titleFr:"Guide d'utilisation â Admin national",titleAr:"دÙÙÙ Ø§ÙØ§Ø³ØªØ¹Ù
Ø§Ù â Ø§ÙÙ
سؤÙ٠اÙÙØ·ÙÙ",descriptionFr:"Référentiel territorial, partis, candidats, comptes admins, audit et règles de répartition des sièges.",sizeLabel:"279 Ko",version:"v1"},provincial:{key:"usage-provincial",path:"utilisation/Guide_Admin_Provincial_AR_FR_v2.pdf",filename:"Guide_Admin_Provincial_AR_FR_v2.pdf",titleFr:"Guide d'utilisation â Admin provincial / régional",titleAr:"دÙÙÙ Ø§ÙØ§Ø³ØªØ¹Ù
Ø§Ù â Ø§ÙÙ
سؤÙÙ Ø§ÙØ¥ÙÙÙÙ
Ù / Ø§ÙØ¬ÙÙÙ",descriptionFr:"Pilotage de la circonscription, PV, assesseurs, admins communaux, répartition des sièges, Jour J.",sizeLabel:"293 Ko",version:"v2"},communal:{key:"usage-communal",path:"utilisation/Guide_Admin_Communal_AR_FR.pdf",filename:"Guide_Admin_Communal_AR_FR.pdf",titleFr:"Guide d'utilisation â Admin communal",titleAr:"دÙÙÙ Ø§ÙØ§Ø³ØªØ¹Ù
Ø§Ù â Ø§ÙÙ
سؤÙÙ Ø§ÙØ¬Ù
اعÙ",descriptionFr:"Bureaux de vote, recrutement et suivi des assesseurs, contrôle qualité des PV, dépannage.",sizeLabel:"251 Ko",version:"v1"}},je=[{key:"command-fr",path:"commandement/Guide_Commandement_FR.pdf",filename:"Guide_Commandement_ISTIQLALI_FR.pdf",titleFr:"Guide de commandement â Français",titleAr:"دÙÙ٠اÙÙÙØ§Ø¯Ø© â Ø§ÙÙØ±ÙØ³ÙØ©",descriptionFr:"Rôles par niveau, monitoring, recrutement, Jour J, incidents, jalons J-39 â J-0.",sizeLabel:"198 Ko",version:"2026"},{key:"command-ar",path:"commandement/Guide_Commandement_AR.pdf",filename:"Guide_Commandement_ISTIQLALI_AR.pdf",titleFr:"Guide de commandement â Arabe",titleAr:"دÙÙ٠اÙÙÙØ§Ø¯Ø© â Ø§ÙØ¹Ø±Ø¨ÙØ©",descriptionFr:"Version arabe intégrale du guide de commandement.",sizeLabel:"530 Ko",version:"2026"}];function _e(n){switch(n){case"national":return j.national;case"regional":case"provincial":return j.provincial;case"communal":case"bureau":return j.communal;default:return j.communal}}const Ne="guides";function I({guide:n}){const{toast:a}=X(),[t,i]=c.useState(null),o=async d=>{const{data:l,error:s}=await f.storage.from(Ne).createSignedUrl(n.path,600,d?{download:n.filename}:void 0);if(s||!(l!=null&&l.signedUrl))throw s??new Error("URL indisponible");return l.signedUrl},g=async d=>{i(d);try{const l=await o(d==="download");if(d==="open")window.open(l,"_blank","noopener,noreferrer");else{const s=document.createElement("a");s.href=l,s.download=n.filename,document.body.appendChild(s),s.click(),s.remove()}}catch{a({title:"Guide indisponible",description:"Impossible d'ouvrir le document. Réessayez dans un instant.",variant:"destructive"})}finally{i(null)}};return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ie,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"font-semibold leading-tight",children:n.titleFr}),e.jsx("p",{className:"font-arabic text-sm text-muted-foreground leading-tight",dir:"rtl",lang:"ar",children:n.titleAr}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.descriptionFr}
1),e.jsxs("p",{className:"text-[11px] text-muted-foreground/80",children:["PDF · ",n.sizeLabel," · ",n.version]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(_,{size:"sm",variant:"secondary",disabled:t!==null,onClick:()=>g("open"),children:[t==="open"?e.jsx(v,{className:"h-4 w-4 animate-spin"}):e.jsx(Y,{className:"h-4 w-4"}),"Ouvrir"]}),e.jsxs(_,{size:"sm",disabled:t!==null,onClick:()=>g("download"),children:[t==="download"?e.jsx(v,{className:"h-4 w-4 animate-spin"}):e.jsx(re,{className:"h-4 w-4"}),"Télécharger"]})]})]})}function ye({variant:n="floating"}){const{scope:a}=T(),t=_e(a==null?void 0:a.niveau);return e.jsxs(ge,{children:[e.jsx(xe,{asChild:!0,children:n==="floating"?e.jsx(_,{size:"icon","aria-label":"Aide et guides PDF",className:"fixed bottom-5 left-5 z-50 h-12 w-12 rounded-full shadow-lg",children:e.jsx(D,{className:"h-6 w-6"})}):e.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-3 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(D,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Guides PDF"})]})}),e.jsxs(J,{side:"right",className:"w-full sm:max-w-md overflow-y-auto",children:[e.jsxs(K,{className:"text-left",children:[e.jsx(H,{children:"Aide et documentation"}),e.jsx(B,{children:e.jsx("span",{className:"font-arabic block",dir:"rtl",lang:"ar",children:"اÙÙ
ساعدة ÙØ§ÙÙØ«Ø§Ø¦Ù"})})]}),e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Guide d'utilisation â votre périmètre"}),e.jsx(I,{guide:t})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Guide de commandement â tous niveaux"}),je.map(i=>e.jsx(I,{guide:i},i.key))]}),e.jsxs("p",{className:"flex items-start gap-2 text-xs text-muted-foreground border-t border-border pt-4",children:[e.jsx(se,{className:"h-4 w-4 shrink-0 mt-0.5"}),"Document interne â ne pas diffuser hors de la chaîne de commandement."]})]})]})]})}const N="2026-08-22",we=()=>{const[n,a]=c.useState(!1),[t,i]=c.useState(null),[o,g]=c.useState(""),[d,l]=c.useState(!1),[s,p]=c.useState(!1);c.useEffect(()=>{let r=!1;return(async()=>{const{data:{session:m}}=await f.auth.getSession();if(!(m!=null&&m.user))return;const{data:h}=await f.from("admin_contacts").select("id, nom, engagement_accepted_at").eq("user_id",m.user.id).eq("actif",!0).limit(1).maybeSingle();r||!h||h.engagement_accepted_at||(i(h.id),g(h.nom??""),a(!0))})(),()=>{r=!0}},[]);const u=async()=>{if(!(!t||!d)){p(!0);try{const r=new Date().toISOString(),{error:m}=await f.from("admin_contacts").update({engagement_accepted_at:r,engagement_version:N}).eq("id",t);if(m)throw m;await f.from("audit_log").insert({action:"CONSENT_ACCEPTED",entity_type:"admin_consent",entity_id:t,entity_label:o,actor:o||"admin",summary:`Engagement de confidentialité accepté (version ${N})`,metadata:{engagement_version:N,accepted_at:r}}),a(!1),R.success("Engagement de confidentialité enregistré. Merci.")}catch(r){R.error((r==null?void 0:r.message)||"Enregistrement impossible")}finally{p(!1)}}};return n?e.jsx(ce,{open:!0,onOpenChange:()=>{},children:e.jsxs(le,{className:"max-w-lg [&>button]:hidden",onInteractOutside:r=>r.preventDefault(),onEscapeKeyDown:r=>r.preventDefault(),children:[e.jsxs(de,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-5 h-5 text-primary"}),"Engagement de confidentialité"]}),e.jsx(ue,{children:"Une seule fois : la CNDP (règle 8, délibération 2015-108) impose que chaque administrateur accédant à des données personnelles soit lié par un engagement écrit."})]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 list-disc pl-5",children:[e.jsx("li",{children:"Utiliser les données uniquement pour la mission électorale."}),e.jsx("li",{children:"Ne rien transmettre hors de la chaîne de commandement du Parti."}),e.jsx("li",{children:"Ne pas partager son compte ni ses codes."}),e.jsx("li",{children:"Signaler immédiatement toute fuite ou accès non autorisé."})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border p-3 cursor-pointer",children:[e.jsx(pe,{checked:d,onCheckedChange:r=>l(r===!0),className:"mt-0.5"}),e.jsxs("span",{className:"text-sm",children:["J'ai lu et j'accepte l'",e.jsx(Z,{to:"/engagement-confidentialite",target:"_blank",className:"underline underline-offset-4",children:"engagement de confidentialité"})," ","des administrateurs de la plateforme ISTIQLALI."]})]}),e.jsx(fe,{children:e.jsxs(_,{onClick:u,disabled:!d||s,className:"w-full",children:[s&&e.jsx(v,{className:"w-4 h-4 mr-2 animate-spin"}),"Je m'engage"]})})]})}):null},Se=30*60*1e3,Ce=({children:n})=>{const a=L(),t=O(),[i,o]=c.useState(!1),[g,d]=c.useState(!0),l=c.useRef(null),s=c.useCallback(async()=>{sessionStorage.removeItem("admin_token"),sessionStorage.removeItem("admin_mode");try{await f.auth.signOut()}catch{}o(!1),a("/admin/login",{replace:!0,state:{from:t.pathname}})},[a,t.pathname]),p=c.useCallback(()=>{l.current&&clearTimeout(l.current),i&&(l.current=setTimeout(s,Se))},[i,s]);return c.useEffect(()=>{let u=!1;(async()=>{const{data:{session:m}}=await f.auth.getSession();if(!(m!=null&&m.user)){u||(d(!1),a("/admin/login",{replace:!0,state:{from:t.pathname}}));return}const{data:h}=await f.from("admin_contacts").select("id, actif").eq("user_id",m.user.id).eq("actif",!0).limit(1);if(!h||h.length===0){await f.auth.signOut(),u||(d(!1),a("/admin/login",{replace:!0}));return}sessionStorage.setItem("admin_token","authenticated"),sessionStorage.setItem("admin_mode","scoped"),u||(o(!0),d(!1))})();const{data:r}=f.auth.onAuthStateChange(m=>{m==="SIGNED_OUT"&&(sessionStorage.removeItem("admin_token"),sessionStorage.removeItem("admin_mode"),o(!1),a("/admin/login",{replace:!0}))});return()=>{u=!0,r.subscription.unsubscribe()}},[a,t.pathname]),c.useEffect(()=>{if(!i)return;const u=["mousedown","keydown","scroll","touchstart","mousemove"];return p(),u.forEach(r=>window.addEventListener(r,p)),()=>{l.current&&clearTimeout(l.current),u.forEach(r=>window.removeEventListener(r,p))}},[i,p]),g?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(v,{className:"w-8 h-8 animate-spin text-primary"})}):i?e.jsx(Ae,{children:n}):null};function Ae({children:n}){const{loading:a,scope:t,defaultLanding:i}=T(),o=L(),g=O(),[d,l]=c.useState(null);return c.useEffect(()=>{if(!t||t.niveau!=="regional"||!t.region_id){l(null);return}let s=!1;return(async()=>{const{data:p}=await f.from("provinces").select("code, nom_fr").eq("region_id",t.region_id).eq("status","active");s||l(new Set((p??[]).map(u=>F(u.code,u.nom_fr))))})(),()=>{s=!0}}
1,[t==null?void 0:t.niveau,t==null?void 0:t.region_id]),c.useEffect(()=>{var y,w,S,C,A;if(a||!t)return;const s=g.pathname;if(["/admin","/admin/national/referentiel","/admin/national/parties","/admin/national/candidats"].includes(s)&&t.niveau!=="national"){const x=i();o(x==="/admin"?"/admin/profile":x,{replace:!0});return}if(s.match(/^\/admin\/province\/[^/]+\/candidats$/)&&t.niveau!=="national"&&t.niveau!=="provincial"){o(i(),{replace:!0});return}const r=s.match(/^\/admin\/region\/([^/]+)/);if(r){if(t.niveau==="national")return;const x=r[1];if(t.niveau==="regional"&&((y=t.region)==null?void 0:y.code)===x)return;o(i(),{replace:!0});return}const m=s.match(/^\/admin\/circonscription\/([^/]+)/);if(m){if(t.niveau==="national"||t.niveau==="regional")return;if(t.niveau==="provincial"&&((w=t.circonscription)!=null&&w.code)){t.circonscription.code!==m[1]&&o(i(),{replace:!0});return}return}const h=s.match(/^\/admin\/province\/([^/]+)/);if(h){const x=h[1];if(t.niveau==="national")return;if(t.niveau==="regional"){if(d===null||d.has(x))return;o(i(),{replace:!0});return}if(t.province){if(F(t.province.code,t.province.nom_fr)!==x){o(i(),{replace:!0});return}if(t.niveau==="provincial"&&((S=t.circonscription)!=null&&S.code)){const G=s.replace(/^\/admin\/province\/[^/]+/,"");if(!/^\/bureau\//.test(G)){o(`/admin/circonscription/${t.circonscription.code}${G}`,{replace:!0});return}}const V=/\/commune\//.test(s),$=/\/bureau\//.test(s);if((t.niveau==="communal"||t.niveau==="bureau")&&!V&&!$){o(i(),{replace:!0});return}const k=s.match(/\/commune\/([^/]+)/);if(k&&(t.niveau==="communal"||t.niveau==="bureau")&&((C=t.commune)==null?void 0:C.id)!==k[1]){o(i(),{replace:!0});return}const E=s.match(/\/bureau\/([^/]+)/);if(E&&t.niveau==="bureau"&&((A=t.bureau)==null?void 0:A.id)!==E[1]){o(i(),{replace:!0});return}}else{o(i(),{replace:!0});return}}},[a,t,g.pathname,o,i,d]),a?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(v,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[n,e.jsx(ye,{}),e.jsx("div",{className:"fixed bottom-5 right-5 z-40 max-w-[240px] print:hidden",children:e.jsx(oe,{compact:!0})}),e.jsx(we,{})]})}const ze=Object.freeze(Object.defineProperty({__proto__:null,default:Ce},Symbol.toStringTag,{value:"Module"}));export{ye as A,ge as S,J as a,Ce as b,ze as c};
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.