Files
intotheeast-com-content/plugins/admin2/app/_app/immutable/chunks/DI46g3k0.js
T

3 lines
7.2 KiB
JavaScript

import"./DsnmJJEf.js";import{p as _e,f as pe,t as P,a as f,b as ye,o as we,j as D,g as r,c as k,d as i,i as ae,s as m,r as s,h as Me,l as K}from"./krC2xWPP.js";import{d as Ee,e as ke,a as q,s as O}from"./CddAxf8c.js";import{p as E,i as x}from"./DjsWWzyL.js";import{r as Se,s as _,c as Re,b as Pe,e as De}from"./Lvd_r9sp.js";import{s as B,c as Ae}from"./j_DJpx8B.js";import{i as J,b as Ie}from"./Cu5ilWky.js";import{E as Ne,a as Te}from"./DKn7_j4m.js";import{X as ie}from"./CiIMiELt.js";import{C as ze}from"./DEuEFefA.js";import{I as We}from"./dWUbZIEy.js";const V=new Map;function je(a){if(V.has(a))return V.get(a);try{const e=new RegExp(a);return V.set(a,e),e}catch{return V.set(a,null),null}}function Oe(a,e){return e.map(u=>{const l=je(u.pattern);return{rule:u,met:l?l.test(a):!1}})}function Ce(a,e){const u=a.length;if(u===0)return 0;let l=0;/[a-z]/.test(a)&&(l+=26),/[A-Z]/.test(a)&&(l+=26),/\d/.test(a)&&(l+=10),/[^a-zA-Z0-9]/.test(a)&&(l+=32),l=Math.max(l,10);const p=Math.log2(l)*u,F=/(.)\1{2,}/.test(a)?8:0,A=/(?:abcd|bcde|cdef|1234|2345|qwer|asdf)/i.test(a)?6:0,z=Math.max(0,u-Math.max(e,8))*1.5;return Math.max(0,p+z-F-A)}function Fe(a,e){const u=e?.rules??[],l=Oe(a,u),p=u.length>0&&l.every(L=>L.met);if(a.length===0)return{rules:l,allRulesMet:!1,score:0,tier:"weak"};const F=e?.min_length??8,A=Ce(a,F);if(!p){const L=u.length===0?0:l.filter(b=>b.met).length/u.length,y=Math.min(55,Math.round(L*40+Math.min(A,25)*.6)),I=y<25?"weak":"fair";return{rules:l,allRulesMet:p,score:y,tier:I}}const z=Math.min(35,(A-30)*.9),G=Math.max(65,Math.min(100,Math.round(65+z))),Q=G>=85?"strong":"good";return{rules:l,allRulesMet:p,score:G,tier:Q}}var Le=k('<label class="text-[0.8125rem] font-medium text-foreground"> </label>'),Xe=k('<button type="button" class="ms-auto inline-flex items-center gap-1 text-[0.6875rem] font-medium text-muted-foreground transition-colors hover:text-foreground" tabindex="-1"><!> </button>'),He=k('<div class="flex items-center justify-between"><!> <!></div>'),qe=k('<div class="flex items-center justify-between text-[0.6875rem] text-muted-foreground"><span><!></span> <span> </span></div>'),Be=k('<div class="space-y-1 pt-0.5"><div class="h-1 w-full overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuemin="0" aria-valuemax="100"><div></div></div> <!></div>'),Ge=k('<p class="text-xs text-red-500"> </p>'),Qe=k('<li class="flex items-start gap-2 text-[0.8125rem]"><span><!></span> <span> </span></li>'),Ue=k('<div class="fixed inset-0 z-50 flex items-center justify-center bg-neutral-900/75 p-4 backdrop-blur-sm"><div class="flex w-full max-w-sm flex-col rounded-xl border border-border bg-card shadow-2xl"><div class="flex shrink-0 items-center justify-between border-b border-border px-5 py-3"><h2 class="text-sm font-semibold text-foreground"> </h2> <button type="button" class="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground" aria-label="Close"><!></button></div> <ul class="space-y-2 px-5 py-4"></ul></div></div>'),Ze=k('<div class="space-y-1.5"><!> <div><input/> <button type="button" class="absolute inset-y-0 right-0 flex w-9 items-center justify-center text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50" tabindex="-1"><!></button></div> <!> <!></div> <!>',1);function lt(a,e){_e(e,!0);let u=E(e,"value",15),l=E(e,"id",3,"password"),p=E(e,"label",3,"Password"),F=E(e,"autocomplete",3,"new-password"),A=E(e,"disabled",3,!1),z=E(e,"invalid",3,!1),G=E(e,"showMeter",3,!0),Q=E(e,"showHint",3,!0),L=E(e,"inputClass",3,""),y=ae(!1),I=ae(!1);const b=Me(()=>Fe(u()??"",e.policy));function le(t){t.target===t.currentTarget&&D(y,!1)}function oe(t){t.key==="Escape"&&D(y,!1)}const de={weak:"bg-red-500",fair:"bg-amber-500",good:"bg-green-500",strong:"bg-emerald-500"};var re=Ze();ke("keydown",we,function(...t){(r(y)?oe:void 0)?.apply(this,t)});var $=pe(re),se=i($);{var ue=t=>{var o=He(),v=i(o);{var S=d=>{var c=Le(),h=i(c,!0);s(c),P(()=>{_(c,"for",l()),O(h,p())}),f(d,c)};x(v,d=>{p()&&d(S)})}var N=m(v,2);{var H=d=>{var c=Xe(),h=i(c);We(h,{size:12});var w=m(h);s(c),P((R,T)=>{_(c,"aria-label",R),O(w,` ${T??""}`)},[()=>J.t("ADMIN_NEXT.PASSWORD_FIELD.PASSWORD_REQUIREMENTS"),()=>J.t("ADMIN_NEXT.PASSWORD_FIELD.REQUIREMENTS")]),q("click",c,()=>D(y,!0)),f(d,c)};x(N,d=>{Q()&&e.policy&&e.policy.rules.length>0&&d(H)})}s(o),f(t,o)};x(se,t=>{(p()||Q()&&e.policy&&e.policy.rules.length>0)&&t(ue)})}var U=m(se,2),g=i(U);Se(g);var X=m(g,2),ce=i(X);{var ve=t=>{Ne(t,{size:14})},fe=t=>{Te(t,{size:14})};x(ce,t=>{r(I)?t(ve):t(fe,-1)})}s(X),s(U);var ne=m(U,2);{var me=t=>{var o=Be(),v=i(o),S=i(v);s(v);var N=m(v,2);{var H=d=>{var c=qe(),h=i(c),w=i(h);{var R=n=>{var M=K("Too weak");f(n,M)},T=n=>{var M=K("Getting there");f(n,M)},W=n=>{var M=K("Good");f(n,M)},ee=n=>{var M=K("Strong");f(n,M)};x(w,n=>{r(b).tier==="weak"?n(R):r(b).tier==="fair"?n(T,1):r(b).tier==="good"?n(W,2):n(ee,-1)})}s(h);var Z=m(h,2),te=i(Z);s(Z),s(c),P(n=>O(te,`${n??""} / ${r(b).rules.length??""} requirements`),[()=>r(b).rules.filter(n=>n.met).length]),f(d,c)};x(N,d=>{e.policy&&e.policy.rules.length>0&&d(H)})}s(o),P(d=>{_(v,"aria-valuenow",r(b).score),_(v,"aria-label",d),B(S,1,`h-full rounded-full transition-all duration-200 ${de[r(b).tier]??""}`),Pe(S,`width: ${r(b).score??""}%`)},[()=>J.t("ADMIN_NEXT.PASSWORD_FIELD.PASSWORD_STRENGTH")]),f(t,o)};x(ne,t=>{G()&&(u()?.length??0)>0&&t(me)})}var be=m(ne,2);{var ge=t=>{var o=Ge(),v=i(o,!0);s(o),P(()=>O(v,e.invalidMessage)),f(t,o)};x(be,t=>{z()&&e.invalidMessage&&t(ge)})}s($);var he=m($,2);{var xe=t=>{var o=Ue(),v=i(o),S=i(v),N=i(S),H=i(N,!0);s(N);var d=m(N,2),c=i(d);ie(c,{size:14}),s(d),s(S);var h=m(S,2);De(h,21,()=>r(b).rules,w=>w.rule.id,(w,R)=>{var T=Qe(),W=i(T),ee=i(W);{var Z=j=>{ze(j,{size:10,strokeWidth:3})},te=j=>{ie(j,{size:10,strokeWidth:3})};x(ee,j=>{r(R).met?j(Z):j(te,-1)})}s(W);var n=m(W,2),M=i(n,!0);s(n),s(T),P(()=>{B(W,1,`mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${r(R).met?"bg-green-500/15 text-green-600 dark:text-green-400":"bg-muted text-muted-foreground"}`),B(n,1,Ae(r(R).met?"text-foreground":"text-muted-foreground")),O(M,r(R).rule.label)}),f(w,T)}),s(h),s(v),s(o),P(w=>O(H,w),[()=>J.t("ADMIN_NEXT.PASSWORD_FIELD.PASSWORD_REQUIREMENTS")]),q("click",o,le),q("click",d,()=>D(y,!1)),f(t,o)};x(he,t=>{r(y)&&t(xe)})}P(()=>{B(U,1,`relative ${L()??""}`),_(g,"id",l()),_(g,"name",e.name),_(g,"type",r(I)?"text":"password"),_(g,"placeholder",e.placeholder),_(g,"autocomplete",F()),g.disabled=A(),Re(g,u()),B(g,1,`flex h-9 w-full rounded-md border bg-transparent px-3 py-1 pe-9 text-sm shadow-sm transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50
${z()?"border-red-500 ring-1 ring-red-500/30":"border-input"}`),X.disabled=A(),_(X,"aria-label",r(I)?"Hide password":"Show password")}),q("input",g,t=>{const o=t.currentTarget.value;e.onchange?e.onchange(o):u(o)}),q("click",X,()=>D(I,!r(I))),f(a,re),ye()}Ee(["click","input"]);let C=ae(null),Y=null;async function Ke(){const a=await Ie.get("/auth/password-policy");return D(C,a,!0),a}const ot={get current(){return r(C)},seed(a){a&&D(C,a,!0)},async load(){return r(C)?r(C):(Y||(Y=Ke().finally(()=>{Y=null})),Y)},clear(){D(C,null)}};export{lt as P,Fe as e,ot as p};