1import{ac as Q,ag as U,t as W,u as X,bG as H,r as o,d7 as Y,d as _,j as t,cd as K,L as Z,cn as ee,z as f,dv as te}from"./index-BH8Hq4fF.js";import{S as se}from"./SitePageShell-BgpTtAUN.js";import{j as ne}from"./usePaymentPlacements-TNXseU1e.js";import"./chevron-left-DaNP-hnR.js";import"./siren-DUj7NgPZ.js";import"./clipboard-check-BKoevPr7.js";import"./personalHeading-DPM7lbxX.js";import"./ContentPageHero-CiDpAGe7.js";import"./siteLogoPanel-FM6PxkL_.js";import"./user-cog-BikfPThJ.js";import"./bell-ring-Db0rTCDW.js";import"./life-buoy-7W458jwF.js";import"./log-in-Ci9k4xKf.js";import"./kibbutzSiteUtils-BetuJpui.js";import"./info-CMJoL0mv.js";import"./folder-open-CWzvkunn.js";import"./graduation-cap-DnGVwVvF.js";import"./file-check-BSDzA9vo.js";import"./instagram-BHE3hi9u.js";import"./sliders-horizontal-D7cGhbbA.js";import"./youtube-CpfQxPon.js";import"./leaf-DJuap4o0.js";import"./paymentCatalogs-CvImawYM.js";const d=6,O={sms:{resend:"ש××× ×× SMS",sent:"×§×× ××××ת × ×©×× ××××× ×Ö¾SMS"},whatsapp:{resend:"ש××× ×× ×××××ס×פ",sent:"×§×× ××××ת × ×©×× ××××× ×××××ס×פ"},voice:{resend:"××ª×§×©×¨× ×××× ×¢× ××§××",sent:"×תקשר×× ××××× ×¢×ש×× ×¢× ×§×× ××××ת"}};function M(l){const p=(l||[]).map(b=>{var y;return(y=O[b])==null?void 0:y.sent}).filter(Boolean);return p.length?p.join(" ×Ö¾"):"×§×× ××××ת × ×©×× ×××××"}function Ee(){const{kibbutzId:l}=Q(),{t:p}=U(),b=W(),[y]=X(),C=ne(y.get("redirect"),H(`/kibbutz-site/${l}/personal`));o.useEffect(()=>{Y(l)&&b(C,{replace:!0})},[l,b,C]);const[j,B]=o.useState("phone"),[x,V]=o.useState(""),[N,P]=o.useState(!1),[D,R]=o.useState(!1),[E,g]=o.useState(Array(d).fill("")),[S,T]=o.useState(0),[q,A]=o.useState(!1),[h,I]=o.useState([]),[z,$]=o.useState([]),u=o.useRef([]);o.useEffect(()=>{if(!l)return;let e=!0;return A(!1),_.functions.invoke("residentOtpOptions",{community_id:l}).then(s=>{var n;e&&A(((n=s.data)==null?void 0:n.voice)===!0)}).catch(()=>{e&&A(!1)}),()=>{e=!1}},[l]),o.useEffect(()=>{if(S<=0)return;const e=setTimeout(()=>T(s=>s-1),1e3);return()=>clearTimeout(e)},[S]);const w=async(e="auto")=>{var s,n,a,i,c,m;if(!ee(x)||!x.trim()){f.error("× × ××××× ×ספר × ××× ×ª×§××");return}P(!0);try{const r=await _.functions.invoke("residentOtpRequest",{community_id:l,phone:x,channel:e});if(((s=r.data)==null?void 0:s.found)===!1){f.error("×ספר ×× ××× ××× × ×§××× ×רש×××ת ×ת×ש×××");return}g(Array(d).fill(""));const v=Array.isArray((n=r.data)==null?void 0:n.channels)&&r.data.channels.length?r.data.channels:[(a=r.data)==null?void 0:a.channel].filter(
1Boolean);I(v),$(((i=r.data)==null?void 0:i.allow_channel_choice)===!1?[]:((c=r.data)==null?void 0:c.available_channels)||[]),T(((m=r.data)==null?void 0:m.resend_in)||60),B("code"),f.success(M(v)),setTimeout(()=>{var k;return(k=u.current[0])==null?void 0:k.focus()},50)}catch(r){f.error((r==null?void 0:r.message)||"ש×××ת ××§×× × ×ש××. × ×¡× ×©××")}finally{P(!1)}},G=(e,s)=>{var i,c;const n=s.replace(/\D/g,"");if(n.length>1){const m=n.slice(0,d-e).split("");g(r=>{const v=[...r];return m.forEach((k,J)=>{v[e+J]=k}),v}),(i=u.current[Math.min(e+m.length,d-1)])==null||i.focus();return}const a=n.slice(-1);g(m=>{const r=[...m];return r[e]=a,r}),a&&e<d-1&&((c=u.current[e+1])==null||c.focus())};o.useEffect(()=>{var n;if(j!=="code"||!h.includes("sms")||!("OTPCredential"in window)||!((n=navigator.credentials)!=null&&n.get))return;const e=new AbortController,s={otp:{transport:["sms"]},signal:e.signal};return navigator.credentials.get(s).then(a=>{var c;const i=String(a&&"code"in a?a.code:"").replace(/\D/g,"").slice(0,d);i.length===d&&(g(i.split("")),(c=u.current[d-1])==null||c.focus())}).catch(()=>{}),()=>e.abort()},[j,h]);const F=(e,s)=>{var n;s.key==="Backspace"&&!E[e]&&e>0&&((n=u.current[e-1])==null||n.focus())},L=async()=>{var s;const e=E.join("");if(e.length<d){f.error("× × ××××× ×ת ××§×× ××××");return}R(!0);try{const n=await _.functions.invoke("residentOtpVerify",{community_id:l,phone:x,code:e}),{token:a,expires_in:i,resident:c}=n.data||{};if(!a)throw new Error("×§×× ×©××× ×× ×©×¤× ×ª×קפ×");te(l,{token:a,expires_in:i,resident:c,phone:x}),f.success("×ת××רת ××צ×××"),b(C)}catch(n){f.error((n==null?void 0:n.message)||"×§×× ×©×××"),g(Array(d).fill("")),(s=u.current[0])==null||s.focus()}finally{R(!1)}};return t.jsx(se,{kibbutzId:l,moduleKey:"resident_registration",showHero:!1,hidePageTitleHeader:!0,children:({primaryColor:e})=>t.jsx("div",{className:"flex items-center justify-center px-4 py-12",children:t.jsxs("div",{className:"w-full max-w-4xl",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-extrabold text-slate-800",children:"××××ר×× ××§××××"}),t.jsx("p",{className:"text-sm sm:text-base text-slate-500 mt-3",children:j==="phone"?K("×צ××¨×¤× ××ער×ת ××§××××¥ ××××××××ת ×××× ×××§ ×××§××××",p):"×××× × ×ת ×§×× ×××××ת ×©× ×©×× ×××××"})]}),j==="phone"?t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6",children:[t.jsxs("div",{className:"card-float p-8 sm:p-10 flex flex-col text-center",children:[t.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:"ת×ש××× ×¨×©××××"}),t.jsx("p",{className:"text-sm text-slate-500 mb-6",children:"×ת××ר×ת ××××¨× ×¢× ×ספר ×× ×××"}),t.jsx("input",{type:"tel",dir:"ltr",value:x,onChange:s=>V(s.target.value),onKeyDown:s=>{s.key==="Enter"&&w("auto")},placeholder:"×××× × ×ספר × ×××",className:"h-12 rounded-xl border border-slate-200 px-4 text-right outline-none focus:border-blue-400 mb-3 placeholder:text-slate-400"}),t.jsx("button",{onClick:()=>w("auto"),disabled:N,className:"h-12 rounded-xl font-semibold text-white transition-opacity hover:opacity-95 disabled:opacity-60",style:{backgroundColor:e},children:N?"ש×××...":"ש×× ×× ×§××"}),q&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>w("voice"),disabled:N,className:"mt-3 text-sm font-semibold disabled:opacity-50",style:{color:e},children:"×§××× ×§×× ×ש××× ×§×××ת"}),t.jsx("p",{className:"text-xs text-slate-400 mt-2 leading-relaxed",children:"×ת××× ×××פ×× ×שר, ×§× × ××× ×× ×ספר ש×× ××§×× ××××¢×ת."})]})]}),t.jsxs("div",{className:"card-float p-8 sm:p-10 flex flex-col text-center",children:[t.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:"ת×ש××× ××ש××"}),t.jsx("p",{className:"text-sm text-slate-500 mb-8",children:K("×רש×× ××××¨× ××§×××ת ××§××××¥",p)}),t.jsx(Z,{to:H(`/kibbutz-site/${l}/register`),className:"mt-auto inline-flex items-center justify-center h-12 rounded-xl border-2 font-semibold transition-colors hover:bg-slate-50",style:{borderColor:e,color:e},children:"×××¥ ××רש×× ×××ר×"})]})]}):t.jsxs("div",{className:"max-w-lg mx-auto card-float p-8 sm:p-10 text-center",children:[t.jsx("h2",{className:"text-xl font-bold text-slate-800 mb-2",children:"×§×× ××××ת"}),t.jsx("p",{className:"text-sm text-slate-500 mb-8",children:h.includes("voice")&&h.length===1?"×תקשר×× ××××× ×¢×ש×× ×¢× ×§×× ××××ת. × × ××¢× ×ת ×ש××× ××××§××× ××× ×ת ×ספר×ת.":`${M(h)}. ×××× × ×ת ××§×× ××× ×××ש×× ××ת××ר×ת.`}),t.jsx("div",{className:"flex justify-center gap-3 mb-8",dir:"ltr",children:E.map((s,n)=>t.jsx("input",{ref:a=>{u.current[n]=a},value:s,onChange:a=>G(n,a.target.value),inputMode:"numeric",autoComplete:n===0?"one-time-code":"off",onKeyDown:a=>{a.key==="Enter"?L():F(n,a)}
1,className:"w-12 h-16 sm:w-14 rounded-xl border-2 border-slate-200 text-center text-2xl font-bold text-slate-800 outline-none focus:border-blue-400"},n))}),t.jsx("button",{onClick:L,disabled:D,className:"w-full h-12 rounded-xl font-semibold text-white transition-opacity hover:opacity-95 disabled:opacity-60 mb-4",style:{backgroundColor:e},children:D?"×××ת...":"×ת××ר ××§××××"}),S>0?t.jsxs("p",{className:"text-sm text-slate-500",children:["× ××ª× ××קש ×§×× ××ש ××¢×× ",S," ×©× ××ת"]}):t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("p",{className:"text-xs text-slate-400",children:"×× ×§××××ª× ×ת ××§××?"}),t.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:(z.length?z:h).filter(s=>O[s]).map(s=>t.jsx("button",{type:"button",onClick:()=>w(s),disabled:N,className:"h-10 px-4 rounded-xl border-2 text-sm font-semibold transition-colors hover:bg-slate-50 disabled:opacity-50",style:{borderColor:e,color:e},children:O[s].resend},s))})]})]})]})})})}export{Ee as default};
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.