1import{r as x,j as t}from"./index-B0OyW6Z1.js";import{aq as R}from"./adminAuthStore-BHmzF4RP.js";import{f as V}from"./tenantInvite-DDDpIxsi.js";const f="NONE",U=[{value:"FULL_NAME",label:"Full name"},{value:"EMIRATES_ID",label:"Emirates ID"}],M=[{value:"FULL_NAME",label:"Company name"}],D=[{value:"PERSONAL",label:"Individual"},{value:"BUSINESS",label:"Business"}];function A(e){return e==="BUSINESS"?M:U}function S(e,s){return e===f?f:A(s).some(n=>n.value===e)?e:"FULL_NAME"}const O=()=>({customerType:"PERSONAL",iban:"",identifier1Type:"FULL_NAME",identifier1Value:"",identifier2Type:f,identifier2Value:""});function P(e){return!!e.iban.trim()&&!!e.identifier1Value.trim()}function $(e){const s=[{type:e.identifier1Type,value:e.identifier1Value.trim()}];return e.identifier2Type!==f&&e.identifier2Value.trim()&&s.push({type:e.identifier2Type,value:e.identifier2Value.trim()}),{customer_type:e.customerType,iban:e.iban.replace(/\s+/g,"").toUpperCase(),identifications:s}}function q(e){return e?e.kind==="answered"?e.ownership_verified?{tone:"success",title:"Account verified"}:{tone:"danger",title:"Account not verified"}:e.kind==="invalid_input"?{tone:"danger",title:"Details rejected"}:{tone:"warning",title:"Could not verify"}:null}function H(e){return e?[e.message,e.detail].filter((s,n,i)=>s&&i.indexOf(s)===n):[]}const Y={PARTIAL:"Partial match",NO_MATCH:"No match",MATCH:"Match"};function W(e){return e?Y[e]??e:null}function z(e){return e==="PARTIAL"?"warning":"neutral"}function G(e){return typeof e!="number"?null:`${Math.round(e*100)}%`}function J(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():null}function K(e){var i,r,o,u,h,d;if(!e)return[];const s=[],n=(g,m,b)=>{m!=null&&m!==""&&s.push({label:g,value:m,...b})};return n("Match type",W((i=e.matching)==null?void 0:i.type),{chip:z((r=e.matching)==null?void 0:r.type)}),n("Match score",G((o=e.matching)==null?void 0:o.score)),n("Verification ID",e.results_id,{mono:!0}),n("Country","United Arab Emirates"),n("Bank name",(u=e.bank)==null?void 0:u.bank_name),n("BIC",(h=e.bank)==null?void 0:h.bic,{mono:!0}),n("Bank code",(d=e.bank)==null?void 0:d.bank_code,{mono:!0}),n("Account holder",e.account_holder_masked?"Not disclosed by the bank":e.account_holder_name),n("Account status",J(e.account_status),{chip:e.account_status&&e.account_status.toUpperCase()!=="ACTIVE"?"warning":void 0}),n("Verification method",e.verification_method),n("Provider code",e.code,{mono:!0}),s}function Q(e){if(!e)return[];const s=Object.fromEntries(A(e.customer_type).map(i=>[i.value,i.label])),n=(e.identifications??[]).map((i,r)=>({label:r===0?"First identifier":"Second identifier",value:i.value,hint:s[i.type]??i.type}));return n.push({label:"Account IBAN",value:e.iban,iban:!0}),n.push({label:"Customer type",value:e.customer_type==="BUSINESS"?"Business":"Individual"}),n}const j=({label:e,hint:s,error:n,errorId:i,children:r})=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"mb-1 block text-sm font-semibold text-slate-700",children:e}),r,s&&!n&&t.jsx("span",{className:"mt-1 block text-xs text-slate-500",children:s}),n&&t.jsx("span",{id:i,className:"mt-1 block text-xs text-red-600",children:n})]}),p="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-[#1F5BFF] focus:outline-none focus:ring-1 focus:ring-[#1F5BFF]",k={success:{heading:"text-emerald-800",panel:"border-emerald-300 bg-emerald-50/60",glyph:"â"},danger:{heading:"text-red-800",panel:"border-red-300 bg-red-50/60",glyph:"â"},warning:{heading:"text-amber-900",panel:"border-amber-300 bg-amber-50/60",glyph:"â "}},X={warning:"bg-amber-100 text-amber-900 ring-1 ring-amber-300",neutral:"bg-slate-100 text-slate-700 ring-1 ring-slate-300"},Z=e=>String(e).replace(/(.{4})/g,"$1 ").trim(),ee=({label:e,value:s,hint:n,mono:i,iban:r,chip:o})=>t.jsxs("div",{className:"flex items-start justify-between gap-6 border-b border-slate-100 py-3 last:border-b-0",children:[t.jsxs("dt",{className:"shrink-0 max-w-[45%] text-sm font-semibold text-[#0f2461]",children:[e,n&&t.jsxs("span",{className:"ml-1.5 text-xs font-medium text-slate-500",children:["(",n,")"]})]}),t.jsx("dd",{className:`min-w-0 text-right text-slate-600 ${r?"font-mono text-sm tabular-nums break-words":i?"break-all font-mono text-xs":"text-sm break-words"}`,children:o?t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-bold ${X[o]}`,children:[o==="warning"&&t.jsx("span",{"aria-hidden":"true",children:"â "}),s]}):r?Z(s):s})]}),I=({title:e,rows:s})=>s.length===0?null:t.jsxs("div",{children:[t.jsx("h3",{className:"mb-1 text-base font-bold text-[#0f2461]",children:e}),t.jsx("dl",{children:s.map(n=>t.jsx(ee,{...n},n.label+n.value))})]}),se=()=>{var T;const[e,s]=x.useState(O),[n,i]=x.useState({}
1),[r,o]=x.useState(null),[u,h]=x.useState(!1),[d,g]=x.useState(null),m=x.useRef(null),b=a=>c=>s(l=>({...l,[a]:c.target.value})),C=a=>s(c=>({...c,customerType:a,identifier1Type:S(c.identifier1Type,a),identifier2Type:S(c.identifier2Type,a)})),N=A(e.customerType),w=P(e)&&!u,_=async a=>{var c;if(a.preventDefault(),!!w){h(!0),o(null),i({}),g(null);try{const l=$(e),B=await R(l);g({outcome:B,payload:l})}catch(l){i(V((c=l==null?void 0:l.data)==null?void 0:c.errors)),o((l==null?void 0:l.message)||"Could not run the verification")}finally{h(!1)}}},v=d==null?void 0:d.outcome,y=q(v),E=H(v),F=K(v),L=Q(d==null?void 0:d.payload);return t.jsxs("div",{className:"mx-auto max-w-6xl space-y-6",children:[t.jsxs("header",{children:[t.jsx("h1",{className:"text-2xl font-black text-[#0f2461]",children:"Landlord Bank Verification"}),t.jsx("p",{className:"mt-0.5 text-sm font-medium text-gray-400",children:"Check that a landlord's bank account belongs to the landlord before paying them."})]}),r&&t.jsx("div",{role:"status",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:r}),t.jsxs("div",{className:"grid grid-cols-1 items-start gap-6 lg:grid-cols-2",children:[t.jsxs("form",{onSubmit:_,className:"space-y-5 rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-bold text-[#0f2461]",children:"Verify a single customer"}),t.jsx("p",{className:"mt-0.5 text-sm text-slate-500",children:"Enter the landlord's IBAN and the name the tenant gave for it. The bank confirms whether the account really belongs to that landlord."})]}),t.jsxs("div",{children:[t.jsx("span",{className:"mb-1 block text-sm font-semibold text-slate-700",children:"Select customer type"}),t.jsx("div",{className:"flex gap-6 border-b border-slate-200",role:"group","aria-label":"Select customer type",children:D.map(a=>t.jsx("button",{type:"button",role:"tab","aria-selected":e.customerType===a.value,onClick:()=>C(a.value),className:`-mb-px border-b-2 px-1 pb-2 text-sm font-semibold transition-colors ${e.customerType===a.value?"border-[#0f2461] text-[#0f2461]":"border-transparent text-slate-500 hover:text-slate-700"}`,children:a.label},a.value))})]}),t.jsx(j,{label:"Account location",hint:"United Arab Emirates only. Accounts held outside the UAE cannot be checked here.",children:t.jsx("select",{className:p,value:"AE",disabled:!0,"aria-label":"Account location",children:t.jsx("option",{value:"AE",children:"ð¦ðª United Arab Emirates"})})}),t.jsx(j,{label:"Account IBAN",error:n.iban,errorId:"iban-error",children:t.jsx("input",{className:p,value:e.iban,onChange:b("iban"),"aria-label":"Account IBAN","aria-describedby":n.iban?"iban-error":void 0,"aria-invalid":n.iban?!0:void 0,autoComplete:"off",spellCheck:!1})}),t.jsx(j,{label:"First identifier",children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)]",children:[t.jsx("select",{className:p,value:e.identifier1Type,onChange:b("identifier1Type"),"aria-label":"First identifier type",children:N.map(a=>t.jsx("option",{value:a.value,children:a.label},a.value))}),t.jsx("input",{className:p,value:e.identifier1Value,onChange:b("identifier1Value"),placeholder:(T=N.find(a=>a.value===e.identifier1Type))==null?void 0:T.label,"aria-label":"First identifier value",autoComplete:"off"})]})}),n.identifications&&t.jsx("p",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:n.identifications}),t.jsx(j,{label:"Second identifier (optional)",hint:e.customerType==="PERSONAL"?"An Emirates ID alongside the name is the stronger check: a name can be typed to match, an ID cannot.":void 0,children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)]",children:[t.jsxs("select",{className:p,value:e.identifier2Type,onChange:b("identifier2Type"),"aria-label":"Second identifier type",children:[t.jsx("option",{value:f,children:"None"}),N.map(a=>t.jsx("option",{value:a.value,children:a.label},a.value))]}),t.jsx("input",{className:p,value:e.identifier2Value,onChange:b("identifier2Value"),disabled:e.identifier2Type===f,"aria-label":"Second identifier value",autoComplete:"off"})]})}),t.jsx("div",{className:"flex justify-end border-t border-slate-100 pt-4",children:t.jsxs("button",{ref:m,type:"submit",disabled:!w,className:"inline-flex items-center gap-2 rounded-lg bg-[#1F5BFF] px-4 py-2 text-sm font-bold text-white hover:bg-[#1a4de0] disabled:cursor-not-allowed disabled:opacity-60",children:[u&&t.jsx("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}),u?"Verifying":"Verify details"]}
1)}),u&&t.jsx("p",{className:"text-right text-xs text-slate-500",children:"UAE checks take a few seconds while the bank answers."})]}),y&&t.jsxs("section",{"data-testid":"verification-result",role:"status","aria-live":"polite","aria-atomic":"true",className:`space-y-6 rounded-2xl border-2 p-6 shadow-sm lg:sticky lg:top-6 ${k[y.tone].panel}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("h2",{className:`flex items-center gap-2 text-2xl font-black ${k[y.tone].heading}`,children:[t.jsx("span",{"aria-hidden":"true",children:k[y.tone].glyph}),t.jsx("span",{children:y.title})]}),t.jsx("button",{type:"button",onClick:()=>{var a;g(null),(a=m.current)==null||a.focus()},"aria-label":"Dismiss result",className:"-mr-1 -mt-1 rounded p-1 text-slate-500 hover:bg-slate-100 hover:text-slate-700",children:t.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:"1.5",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),E.length>0?E.map(a=>t.jsx("p",{className:"text-sm text-slate-700",children:a},a)):v.kind!=="answered"&&t.jsx("p",{className:"text-sm italic text-slate-500",children:"The provider returned no message."}),t.jsx(I,{title:"Response",rows:F}),t.jsx(I,{title:"Request",rows:L}),t.jsx("p",{className:"border-t border-slate-100 pt-3 text-xs text-slate-500",children:"This check is not recorded. Note the outcome yourself if you need it later."})]})]})]})};export{se 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.