@neuctra/authix 1.1.19 → 1.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(Q,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],w):(Q=typeof globalThis<"u"?globalThis:Q||self,w(Q.NeuctraAuthix={},Q.React))})(this,(function(Q,w){"use strict";function ut(e,t){return function(){return e.apply(t,arguments)}}const{toString:lr}=Object.prototype,{getPrototypeOf:qe}=Object,{iterator:Re,toStringTag:pt}=Symbol,ze=(e=>t=>{const n=lr.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),se=e=>(e=e.toLowerCase(),t=>ze(t)===e),_e=e=>t=>typeof t===e,{isArray:me}=Array,ye=_e("undefined");function je(e){return e!==null&&!ye(e)&&e.constructor!==null&&!ye(e.constructor)&&te(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ft=se("ArrayBuffer");function dr(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ft(e.buffer),t}const cr=_e("string"),te=_e("function"),xt=_e("number"),ve=e=>e!==null&&typeof e=="object",ur=e=>e===!0||e===!1,Ae=e=>{if(ze(e)!=="object")return!1;const t=qe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(pt in e)&&!(Re in e)},pr=e=>{if(!ve(e)||je(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fr=se("Date"),xr=se("File"),hr=se("Blob"),gr=se("FileList"),mr=e=>ve(e)&&te(e.pipe),yr=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||te(e.append)&&((t=ze(e))==="formdata"||t==="object"&&te(e.toString)&&e.toString()==="[object FormData]"))},br=se("URLSearchParams"),[wr,Sr,jr,vr]=["ReadableStream","Request","Response","Headers"].map(se),kr=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ke(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,o;if(typeof e!="object"&&(e=[e]),me(e))for(s=0,o=e.length;s<o;s++)t.call(null,e[s],s,e);else{if(je(e))return;const a=n?Object.getOwnPropertyNames(e):Object.keys(e),i=a.length;let l;for(s=0;s<i;s++)l=a[s],t.call(null,e[l],l,e)}}function ht(e,t){if(je(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,o;for(;s-- >0;)if(o=n[s],t===o.toLowerCase())return o;return null}const fe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gt=e=>!ye(e)&&e!==fe;function He(){const{caseless:e,skipUndefined:t}=gt(this)&&this||{},n={},s=(o,a)=>{const i=e&&ht(n,a)||a;Ae(n[i])&&Ae(o)?n[i]=He(n[i],o):Ae(o)?n[i]=He({},o):me(o)?n[i]=o.slice():(!t||!ye(o))&&(n[i]=o)};for(let o=0,a=arguments.length;o<a;o++)arguments[o]&&ke(arguments[o],s);return n}const Er=(e,t,n,{allOwnKeys:s}={})=>(ke(t,(o,a)=>{n&&te(o)?e[a]=ut(o,n):e[a]=o},{allOwnKeys:s}),e),Cr=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tr=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Ir=(e,t,n,s)=>{let o,a,i;const l={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),a=o.length;a-- >0;)i=o[a],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&qe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Pr=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Or=e=>{if(!e)return null;if(me(e))return e;let t=e.length;if(!xt(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Rr=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&qe(Uint8Array)),zr=(e,t)=>{const s=(e&&e[Re]).call(e);let o;for(;(o=s.next())&&!o.done;){const a=o.value;t.call(e,a[0],a[1])}},_r=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Ar=se("HTMLFormElement"),$r=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,o){return s.toUpperCase()+o}),mt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Nr=se("RegExp"),yt=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};ke(n,(o,a)=>{let i;(i=t(o,a,e))!==!1&&(s[a]=i||o)}),Object.defineProperties(e,s)},Ur=e=>{yt(e,(t,n)=>{if(te(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(te(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Dr=(e,t)=>{const n={},s=o=>{o.forEach(a=>{n[a]=!0})};return me(e)?s(e):s(String(e).split(t)),n},Lr=()=>{},Fr=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Mr(e){return!!(e&&te(e.append)&&e[pt]==="FormData"&&e[Re])}const Wr=e=>{const t=new Array(10),n=(s,o)=>{if(ve(s)){if(t.indexOf(s)>=0)return;if(je(s))return s;if(!("toJSON"in s)){t[o]=s;const a=me(s)?[]:{};return ke(s,(i,l)=>{const x=n(i,o+1);!ye(x)&&(a[l]=x)}),t[o]=void 0,a}}return s};return n(e,0)},Br=se("AsyncFunction"),qr=e=>e&&(ve(e)||te(e))&&te(e.then)&&te(e.catch),bt=((e,t)=>e?setImmediate:t?((n,s)=>(fe.addEventListener("message",({source:o,data:a})=>{o===fe&&a===n&&s.length&&s.shift()()},!1),o=>{s.push(o),fe.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",te(fe.postMessage)),Hr=typeof queueMicrotask<"u"?queueMicrotask.bind(fe):typeof process<"u"&&process.nextTick||bt,p={isArray:me,isArrayBuffer:ft,isBuffer:je,isFormData:yr,isArrayBufferView:dr,isString:cr,isNumber:xt,isBoolean:ur,isObject:ve,isPlainObject:Ae,isEmptyObject:pr,isReadableStream:wr,isRequest:Sr,isResponse:jr,isHeaders:vr,isUndefined:ye,isDate:fr,isFile:xr,isBlob:hr,isRegExp:Nr,isFunction:te,isStream:mr,isURLSearchParams:br,isTypedArray:Rr,isFileList:gr,forEach:ke,merge:He,extend:Er,trim:kr,stripBOM:Cr,inherits:Tr,toFlatObject:Ir,kindOf:ze,kindOfTest:se,endsWith:Pr,toArray:Or,forEachEntry:zr,matchAll:_r,isHTMLForm:Ar,hasOwnProperty:mt,hasOwnProp:mt,reduceDescriptors:yt,freezeMethods:Ur,toObjectSet:Dr,toCamelCase:$r,noop:Lr,toFiniteNumber:Fr,findKey:ht,global:fe,isContextDefined:gt,isSpecCompliantForm:Mr,toJSONObject:Wr,isAsyncFn:Br,isThenable:qr,setImmediate:bt,asap:Hr,isIterable:e=>e!=null&&te(e[Re])};function D(e,t,n,s,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),s&&(this.request=s),o&&(this.response=o,this.status=o.status?o.status:null)}p.inherits(D,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:p.toJSONObject(this.config),code:this.code,status:this.status}}});const wt=D.prototype,St={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{St[e]={value:e}}),Object.defineProperties(D,St),Object.defineProperty(wt,"isAxiosError",{value:!0}),D.from=(e,t,n,s,o,a)=>{const i=Object.create(wt);p.toFlatObject(e,i,function(u){return u!==Error.prototype},d=>d!=="isAxiosError");const l=e&&e.message?e.message:"Error",x=t==null&&e?e.code:t;return D.call(i,l,x,n,s,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};const Vr=null;function Ve(e){return p.isPlainObject(e)||p.isArray(e)}function jt(e){return p.endsWith(e,"[]")?e.slice(0,-2):e}function vt(e,t,n){return e?e.concat(t).map(function(o,a){return o=jt(o),!n&&a?"["+o+"]":o}).join(n?".":""):t}function Yr(e){return p.isArray(e)&&!e.some(Ve)}const Kr=p.toFlatObject(p,{},null,function(t){return/^is[A-Z]/.test(t)});function $e(e,t,n){if(!p.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=p.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,m){return!p.isUndefined(m[j])});const s=n.metaTokens,o=n.visitor||u,a=n.dots,i=n.indexes,x=(n.Blob||typeof Blob<"u"&&Blob)&&p.isSpecCompliantForm(t);if(!p.isFunction(o))throw new TypeError("visitor must be a function");function d(c){if(c===null)return"";if(p.isDate(c))return c.toISOString();if(p.isBoolean(c))return c.toString();if(!x&&p.isBlob(c))throw new D("Blob is not supported. Use a Buffer instead.");return p.isArrayBuffer(c)||p.isTypedArray(c)?x&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function u(c,j,m){let A=c;if(c&&!m&&typeof c=="object"){if(p.endsWith(j,"{}"))j=s?j:j.slice(0,-2),c=JSON.stringify(c);else if(p.isArray(c)&&Yr(c)||(p.isFileList(c)||p.endsWith(j,"[]"))&&(A=p.toArray(c)))return j=jt(j),A.forEach(function($,T){!(p.isUndefined($)||$===null)&&t.append(i===!0?vt([j],T,a):i===null?j:j+"[]",d($))}),!1}return Ve(c)?!0:(t.append(vt(m,j,a),d(c)),!1)}const b=[],y=Object.assign(Kr,{defaultVisitor:u,convertValue:d,isVisitable:Ve});function S(c,j){if(!p.isUndefined(c)){if(b.indexOf(c)!==-1)throw Error("Circular reference detected in "+j.join("."));b.push(c),p.forEach(c,function(A,P){(!(p.isUndefined(A)||A===null)&&o.call(t,A,p.isString(P)?P.trim():P,j,y))===!0&&S(A,j?j.concat(P):[P])}),b.pop()}}if(!p.isObject(e))throw new TypeError("data must be an object");return S(e),t}function kt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function Ye(e,t){this._pairs=[],e&&$e(e,this,t)}const Et=Ye.prototype;Et.append=function(t,n){this._pairs.push([t,n])},Et.toString=function(t){const n=t?function(s){return t.call(this,s,kt)}:kt;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Jr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ct(e,t,n){if(!t)return e;const s=n&&n.encode||Jr;p.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let a;if(o?a=o(t,n):a=p.isURLSearchParams(t)?t.toString():new Ye(t,n).toString(s),a){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class Tt{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){p.forEach(this.handlers,function(s){s!==null&&t(s)})}}const It={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Xr={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ye,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ke=typeof window<"u"&&typeof document<"u",Je=typeof navigator=="object"&&navigator||void 0,Gr=Ke&&(!Je||["ReactNative","NativeScript","NS"].indexOf(Je.product)<0),Zr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Qr=Ke&&window.location.href||"http://localhost",ee={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ke,hasStandardBrowserEnv:Gr,hasStandardBrowserWebWorkerEnv:Zr,navigator:Je,origin:Qr},Symbol.toStringTag,{value:"Module"})),...Xr};function en(e,t){return $e(e,new ee.classes.URLSearchParams,{visitor:function(n,s,o,a){return ee.isNode&&p.isBuffer(n)?(this.append(s,n.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function tn(e){return p.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function rn(e){const t={},n=Object.keys(e);let s;const o=n.length;let a;for(s=0;s<o;s++)a=n[s],t[a]=e[a];return t}function Pt(e){function t(n,s,o,a){let i=n[a++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),x=a>=n.length;return i=!i&&p.isArray(o)?o.length:i,x?(p.hasOwnProp(o,i)?o[i]=[o[i],s]:o[i]=s,!l):((!o[i]||!p.isObject(o[i]))&&(o[i]=[]),t(n,s,o[i],a)&&p.isArray(o[i])&&(o[i]=rn(o[i])),!l)}if(p.isFormData(e)&&p.isFunction(e.entries)){const n={};return p.forEachEntry(e,(s,o)=>{t(tn(s),o,n,0)}),n}return null}function nn(e,t,n){if(p.isString(e))try{return(t||JSON.parse)(e),p.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Ee={transitional:It,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",o=s.indexOf("application/json")>-1,a=p.isObject(t);if(a&&p.isHTMLForm(t)&&(t=new FormData(t)),p.isFormData(t))return o?JSON.stringify(Pt(t)):t;if(p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)||p.isReadableStream(t))return t;if(p.isArrayBufferView(t))return t.buffer;if(p.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(s.indexOf("application/x-www-form-urlencoded")>-1)return en(t,this.formSerializer).toString();if((l=p.isFileList(t))||s.indexOf("multipart/form-data")>-1){const x=this.env&&this.env.FormData;return $e(l?{"files[]":t}:t,x&&new x,this.formSerializer)}}return a||o?(n.setContentType("application/json",!1),nn(t)):t}],transformResponse:[function(t){const n=this.transitional||Ee.transitional,s=n&&n.forcedJSONParsing,o=this.responseType==="json";if(p.isResponse(t)||p.isReadableStream(t))return t;if(t&&p.isString(t)&&(s&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?D.from(l,D.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ee.classes.FormData,Blob:ee.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};p.forEach(["delete","get","head","post","put","patch"],e=>{Ee.headers[e]={}});const sn=p.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),on=e=>{const t={};let n,s,o;return e&&e.split(`
|
|
2
2
|
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),s=i.substring(o+1).trim(),!(!n||t[n]&&sn[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t},Ot=Symbol("internals");function Ce(e){return e&&String(e).trim().toLowerCase()}function Ne(e){return e===!1||e==null?e:p.isArray(e)?e.map(Ne):String(e)}function an(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const ln=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Xe(e,t,n,s,o){if(p.isFunction(s))return s.call(this,t,n);if(o&&(t=n),!!p.isString(t)){if(p.isString(s))return t.indexOf(s)!==-1;if(p.isRegExp(s))return s.test(t)}}function dn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function cn(e,t){const n=p.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{value:function(o,a,i){return this[s].call(this,t,o,a,i)},configurable:!0})})}let re=class{constructor(t){t&&this.set(t)}set(t,n,s){const o=this;function a(l,x,d){const u=Ce(x);if(!u)throw new Error("header name must be a non-empty string");const b=p.findKey(o,u);(!b||o[b]===void 0||d===!0||d===void 0&&o[b]!==!1)&&(o[b||x]=Ne(l))}const i=(l,x)=>p.forEach(l,(d,u)=>a(d,u,x));if(p.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(p.isString(t)&&(t=t.trim())&&!ln(t))i(on(t),n);else if(p.isObject(t)&&p.isIterable(t)){let l={},x,d;for(const u of t){if(!p.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(x=l[d])?p.isArray(x)?[...x,u[1]]:[x,u[1]]:u[1]}i(l,n)}else t!=null&&a(n,t,s);return this}get(t,n){if(t=Ce(t),t){const s=p.findKey(this,t);if(s){const o=this[s];if(!n)return o;if(n===!0)return an(o);if(p.isFunction(n))return n.call(this,o,s);if(p.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ce(t),t){const s=p.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Xe(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let o=!1;function a(i){if(i=Ce(i),i){const l=p.findKey(s,i);l&&(!n||Xe(s,s[l],l,n))&&(delete s[l],o=!0)}}return p.isArray(t)?t.forEach(a):a(t),o}clear(t){const n=Object.keys(this);let s=n.length,o=!1;for(;s--;){const a=n[s];(!t||Xe(this,this[a],a,t,!0))&&(delete this[a],o=!0)}return o}normalize(t){const n=this,s={};return p.forEach(this,(o,a)=>{const i=p.findKey(s,a);if(i){n[i]=Ne(o),delete n[a];return}const l=t?dn(a):String(a).trim();l!==a&&delete n[a],n[l]=Ne(o),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return p.forEach(this,(s,o)=>{s!=null&&s!==!1&&(n[o]=t&&p.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(o=>s.set(o)),s}static accessor(t){const s=(this[Ot]=this[Ot]={accessors:{}}).accessors,o=this.prototype;function a(i){const l=Ce(i);s[l]||(cn(o,i),s[l]=!0)}return p.isArray(t)?t.forEach(a):a(t),this}};re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),p.reduceDescriptors(re.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}}),p.freezeMethods(re);function Ge(e,t){const n=this||Ee,s=t||n,o=re.from(s.headers);let a=s.data;return p.forEach(e,function(l){a=l.call(n,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function Rt(e){return!!(e&&e.__CANCEL__)}function be(e,t,n){D.call(this,e??"canceled",D.ERR_CANCELED,t,n),this.name="CanceledError"}p.inherits(be,D,{__CANCEL__:!0});function zt(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new D("Request failed with status code "+n.status,[D.ERR_BAD_REQUEST,D.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function un(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pn(e,t){e=e||10;const n=new Array(e),s=new Array(e);let o=0,a=0,i;return t=t!==void 0?t:1e3,function(x){const d=Date.now(),u=s[a];i||(i=d),n[o]=x,s[o]=d;let b=a,y=0;for(;b!==o;)y+=n[b++],b=b%e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),d-i<t)return;const S=u&&d-u;return S?Math.round(y*1e3/S):void 0}}function fn(e,t){let n=0,s=1e3/t,o,a;const i=(d,u=Date.now())=>{n=u,o=null,a&&(clearTimeout(a),a=null),e(...d)};return[(...d)=>{const u=Date.now(),b=u-n;b>=s?i(d,u):(o=d,a||(a=setTimeout(()=>{a=null,i(o)},s-b)))},()=>o&&i(o)]}const Ue=(e,t,n=3)=>{let s=0;const o=pn(50,250);return fn(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,x=i-s,d=o(x),u=i<=l;s=i;const b={loaded:i,total:l,progress:l?i/l:void 0,bytes:x,rate:d||void 0,estimated:d&&l&&u?(l-i)/d:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(b)},n)},_t=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},At=e=>(...t)=>p.asap(()=>e(...t)),xn=ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,hn=ee.hasStandardBrowserEnv?{write(e,t,n,s,o,a){const i=[e+"="+encodeURIComponent(t)];p.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),p.isString(s)&&i.push("path="+s),p.isString(o)&&i.push("domain="+o),a===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function gn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function mn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $t(e,t,n){let s=!gn(t);return e&&(s||n==!1)?mn(e,t):t}const Nt=e=>e instanceof re?{...e}:e;function xe(e,t){t=t||{};const n={};function s(d,u,b,y){return p.isPlainObject(d)&&p.isPlainObject(u)?p.merge.call({caseless:y},d,u):p.isPlainObject(u)?p.merge({},u):p.isArray(u)?u.slice():u}function o(d,u,b,y){if(p.isUndefined(u)){if(!p.isUndefined(d))return s(void 0,d,b,y)}else return s(d,u,b,y)}function a(d,u){if(!p.isUndefined(u))return s(void 0,u)}function i(d,u){if(p.isUndefined(u)){if(!p.isUndefined(d))return s(void 0,d)}else return s(void 0,u)}function l(d,u,b){if(b in t)return s(d,u);if(b in e)return s(void 0,d)}const x={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(d,u,b)=>o(Nt(d),Nt(u),b,!0)};return p.forEach(Object.keys({...e,...t}),function(u){const b=x[u]||o,y=b(e[u],t[u],u);p.isUndefined(y)&&b!==l||(n[u]=y)}),n}const Ut=e=>{const t=xe({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:l}=t;if(t.headers=i=re.from(i),t.url=Ct($t(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),p.isFormData(n)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(p.isFunction(n.getHeaders)){const x=n.getHeaders(),d=["content-type","content-length"];Object.entries(x).forEach(([u,b])=>{d.includes(u.toLowerCase())&&i.set(u,b)})}}if(ee.hasStandardBrowserEnv&&(s&&p.isFunction(s)&&(s=s(t)),s||s!==!1&&xn(t.url))){const x=o&&a&&hn.read(a);x&&i.set(o,x)}return t},yn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,s){const o=Ut(e);let a=o.data;const i=re.from(o.headers).normalize();let{responseType:l,onUploadProgress:x,onDownloadProgress:d}=o,u,b,y,S,c;function j(){S&&S(),c&&c(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function A(){if(!m)return;const $=re.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),M={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:$,config:e,request:m};zt(function(O){n(O),j()},function(O){s(O),j()},M),m=null}"onloadend"in m?m.onloadend=A:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(A)},m.onabort=function(){m&&(s(new D("Request aborted",D.ECONNABORTED,e,m)),m=null)},m.onerror=function(T){const M=T&&T.message?T.message:"Network Error",g=new D(M,D.ERR_NETWORK,e,m);g.event=T||null,s(g),m=null},m.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const M=o.transitional||It;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),s(new D(T,M.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,m)),m=null},a===void 0&&i.setContentType(null),"setRequestHeader"in m&&p.forEach(i.toJSON(),function(T,M){m.setRequestHeader(M,T)}),p.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),l&&l!=="json"&&(m.responseType=o.responseType),d&&([y,c]=Ue(d,!0),m.addEventListener("progress",y)),x&&m.upload&&([b,S]=Ue(x),m.upload.addEventListener("progress",b),m.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(u=$=>{m&&(s(!$||$.type?new be(null,e,m):$),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const P=un(o.url);if(P&&ee.protocols.indexOf(P)===-1){s(new D("Unsupported protocol "+P+":",D.ERR_BAD_REQUEST,e));return}m.send(a||null)})},bn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let s=new AbortController,o;const a=function(d){if(!o){o=!0,l();const u=d instanceof Error?d:this.reason;s.abort(u instanceof D?u:new be(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,a(new D(`timeout ${t} of ms exceeded`,D.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),e=null)};e.forEach(d=>d.addEventListener("abort",a));const{signal:x}=s;return x.unsubscribe=()=>p.asap(l),x}},wn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,o;for(;s<n;)o=s+t,yield e.slice(s,o),s=o},Sn=async function*(e,t){for await(const n of jn(e))yield*wn(n,t)},jn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},Dt=(e,t,n,s)=>{const o=Sn(e,t);let a=0,i,l=x=>{i||(i=!0,s&&s(x))};return new ReadableStream({async pull(x){try{const{done:d,value:u}=await o.next();if(d){l(),x.close();return}let b=u.byteLength;if(n){let y=a+=b;n(y)}x.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(x){return l(x),o.return()}},{highWaterMark:2})},Lt=64*1024,{isFunction:De}=p,vn=(({Request:e,Response:t})=>({Request:e,Response:t}))(p.global),{ReadableStream:Ft,TextEncoder:Mt}=p.global,Wt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kn=e=>{e=p.merge.call({skipUndefined:!0},vn,e);const{fetch:t,Request:n,Response:s}=e,o=t?De(t):typeof fetch=="function",a=De(n),i=De(s);if(!o)return!1;const l=o&&De(Ft),x=o&&(typeof Mt=="function"?(c=>j=>c.encode(j))(new Mt):async c=>new Uint8Array(await new n(c).arrayBuffer())),d=a&&l&&Wt(()=>{let c=!1;const j=new n(ee.origin,{body:new Ft,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return c&&!j}),u=i&&l&&Wt(()=>p.isReadableStream(new s("").body)),b={stream:u&&(c=>c.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!b[c]&&(b[c]=(j,m)=>{let A=j&&j[c];if(A)return A.call(j);throw new D(`Response type '${c}' is not supported`,D.ERR_NOT_SUPPORT,m)})});const y=async c=>{if(c==null)return 0;if(p.isBlob(c))return c.size;if(p.isSpecCompliantForm(c))return(await new n(ee.origin,{method:"POST",body:c}).arrayBuffer()).byteLength;if(p.isArrayBufferView(c)||p.isArrayBuffer(c))return c.byteLength;if(p.isURLSearchParams(c)&&(c=c+""),p.isString(c))return(await x(c)).byteLength},S=async(c,j)=>{const m=p.toFiniteNumber(c.getContentLength());return m??y(j)};return async c=>{let{url:j,method:m,data:A,signal:P,cancelToken:$,timeout:T,onDownloadProgress:M,onUploadProgress:g,responseType:O,headers:v,withCredentials:U="same-origin",fetchOptions:q}=Ut(c),F=t||fetch;O=O?(O+"").toLowerCase():"text";let Y=bn([P,$&&$.toAbortSignal()],T),Z=null;const I=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let X;try{if(g&&d&&m!=="get"&&m!=="head"&&(X=await S(v,A))!==0){let f=new n(j,{method:"POST",body:A,duplex:"half"}),k;if(p.isFormData(A)&&(k=f.headers.get("content-type"))&&v.setContentType(k),f.body){const[N,h]=_t(X,Ue(At(g)));A=Dt(f.body,Lt,N,h)}}p.isString(U)||(U=U?"include":"omit");const K=a&&"credentials"in n.prototype,_={...q,signal:Y,method:m.toUpperCase(),headers:v.normalize().toJSON(),body:A,duplex:"half",credentials:K?U:void 0};Z=a&&new n(j,_);let R=await(a?F(Z,q):F(j,_));const ne=u&&(O==="stream"||O==="response");if(u&&(M||ne&&I)){const f={};["status","statusText","headers"].forEach(E=>{f[E]=R[E]});const k=p.toFiniteNumber(R.headers.get("content-length")),[N,h]=M&&_t(k,Ue(At(M),!0))||[];R=new s(Dt(R.body,Lt,N,()=>{h&&h(),I&&I()}),f)}O=O||"text";let J=await b[p.findKey(b,O)||"text"](R,c);return!ne&&I&&I(),await new Promise((f,k)=>{zt(f,k,{data:J,headers:re.from(R.headers),status:R.status,statusText:R.statusText,config:c,request:Z})})}catch(K){throw I&&I(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,c,Z),{cause:K.cause||K}):D.from(K,K&&K.code,c,Z)}}},En=new Map,Bt=e=>{let t=e?e.env:{};const{fetch:n,Request:s,Response:o}=t,a=[s,o,n];let i=a.length,l=i,x,d,u=En;for(;l--;)x=a[l],d=u.get(x),d===void 0&&u.set(x,d=l?new Map:kn(t)),u=d;return d};Bt();const Ze={http:Vr,xhr:yn,fetch:{get:Bt}};p.forEach(Ze,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qt=e=>`- ${e}`,Cn=e=>p.isFunction(e)||e===null||e===!1,Ht={getAdapter:(e,t)=>{e=p.isArray(e)?e:[e];const{length:n}=e;let s,o;const a={};for(let i=0;i<n;i++){s=e[i];let l;if(o=s,!Cn(s)&&(o=Ze[(l=String(s)).toLowerCase()],o===void 0))throw new D(`Unknown adapter '${l}'`);if(o&&(p.isFunction(o)||(o=o.get(t))))break;a[l||"#"+i]=o}if(!o){const i=Object.entries(a).map(([x,d])=>`adapter ${x} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(o=>s.set(o)),s}static accessor(t){const s=(this[Ot]=this[Ot]={accessors:{}}).accessors,o=this.prototype;function a(i){const l=Ce(i);s[l]||(cn(o,i),s[l]=!0)}return p.isArray(t)?t.forEach(a):a(t),this}};re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),p.reduceDescriptors(re.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}}),p.freezeMethods(re);function Ge(e,t){const n=this||Ee,s=t||n,o=re.from(s.headers);let a=s.data;return p.forEach(e,function(l){a=l.call(n,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function Rt(e){return!!(e&&e.__CANCEL__)}function be(e,t,n){D.call(this,e??"canceled",D.ERR_CANCELED,t,n),this.name="CanceledError"}p.inherits(be,D,{__CANCEL__:!0});function zt(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new D("Request failed with status code "+n.status,[D.ERR_BAD_REQUEST,D.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function un(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pn(e,t){e=e||10;const n=new Array(e),s=new Array(e);let o=0,a=0,i;return t=t!==void 0?t:1e3,function(x){const d=Date.now(),u=s[a];i||(i=d),n[o]=x,s[o]=d;let b=a,y=0;for(;b!==o;)y+=n[b++],b=b%e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),d-i<t)return;const S=u&&d-u;return S?Math.round(y*1e3/S):void 0}}function fn(e,t){let n=0,s=1e3/t,o,a;const i=(d,u=Date.now())=>{n=u,o=null,a&&(clearTimeout(a),a=null),e(...d)};return[(...d)=>{const u=Date.now(),b=u-n;b>=s?i(d,u):(o=d,a||(a=setTimeout(()=>{a=null,i(o)},s-b)))},()=>o&&i(o)]}const Ue=(e,t,n=3)=>{let s=0;const o=pn(50,250);return fn(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,x=i-s,d=o(x),u=i<=l;s=i;const b={loaded:i,total:l,progress:l?i/l:void 0,bytes:x,rate:d||void 0,estimated:d&&l&&u?(l-i)/d:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(b)},n)},_t=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},At=e=>(...t)=>p.asap(()=>e(...t)),xn=ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,hn=ee.hasStandardBrowserEnv?{write(e,t,n,s,o,a){const i=[e+"="+encodeURIComponent(t)];p.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),p.isString(s)&&i.push("path="+s),p.isString(o)&&i.push("domain="+o),a===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function gn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function mn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $t(e,t,n){let s=!gn(t);return e&&(s||n==!1)?mn(e,t):t}const Nt=e=>e instanceof re?{...e}:e;function xe(e,t){t=t||{};const n={};function s(d,u,b,y){return p.isPlainObject(d)&&p.isPlainObject(u)?p.merge.call({caseless:y},d,u):p.isPlainObject(u)?p.merge({},u):p.isArray(u)?u.slice():u}function o(d,u,b,y){if(p.isUndefined(u)){if(!p.isUndefined(d))return s(void 0,d,b,y)}else return s(d,u,b,y)}function a(d,u){if(!p.isUndefined(u))return s(void 0,u)}function i(d,u){if(p.isUndefined(u)){if(!p.isUndefined(d))return s(void 0,d)}else return s(void 0,u)}function l(d,u,b){if(b in t)return s(d,u);if(b in e)return s(void 0,d)}const x={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(d,u,b)=>o(Nt(d),Nt(u),b,!0)};return p.forEach(Object.keys({...e,...t}),function(u){const b=x[u]||o,y=b(e[u],t[u],u);p.isUndefined(y)&&b!==l||(n[u]=y)}),n}const Ut=e=>{const t=xe({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:l}=t;if(t.headers=i=re.from(i),t.url=Ct($t(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),p.isFormData(n)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(p.isFunction(n.getHeaders)){const x=n.getHeaders(),d=["content-type","content-length"];Object.entries(x).forEach(([u,b])=>{d.includes(u.toLowerCase())&&i.set(u,b)})}}if(ee.hasStandardBrowserEnv&&(s&&p.isFunction(s)&&(s=s(t)),s||s!==!1&&xn(t.url))){const x=o&&a&&hn.read(a);x&&i.set(o,x)}return t},yn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,s){const o=Ut(e);let a=o.data;const i=re.from(o.headers).normalize();let{responseType:l,onUploadProgress:x,onDownloadProgress:d}=o,u,b,y,S,c;function j(){S&&S(),c&&c(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function A(){if(!m)return;const $=re.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),F={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:$,config:e,request:m};zt(function(O){n(O),j()},function(O){s(O),j()},F),m=null}"onloadend"in m?m.onloadend=A:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(A)},m.onabort=function(){m&&(s(new D("Request aborted",D.ECONNABORTED,e,m)),m=null)},m.onerror=function(T){const F=T&&T.message?T.message:"Network Error",g=new D(F,D.ERR_NETWORK,e,m);g.event=T||null,s(g),m=null},m.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||It;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),s(new D(T,F.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,m)),m=null},a===void 0&&i.setContentType(null),"setRequestHeader"in m&&p.forEach(i.toJSON(),function(T,F){m.setRequestHeader(F,T)}),p.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),l&&l!=="json"&&(m.responseType=o.responseType),d&&([y,c]=Ue(d,!0),m.addEventListener("progress",y)),x&&m.upload&&([b,S]=Ue(x),m.upload.addEventListener("progress",b),m.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(u=$=>{m&&(s(!$||$.type?new be(null,e,m):$),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const P=un(o.url);if(P&&ee.protocols.indexOf(P)===-1){s(new D("Unsupported protocol "+P+":",D.ERR_BAD_REQUEST,e));return}m.send(a||null)})},bn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let s=new AbortController,o;const a=function(d){if(!o){o=!0,l();const u=d instanceof Error?d:this.reason;s.abort(u instanceof D?u:new be(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,a(new D(`timeout ${t} of ms exceeded`,D.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),e=null)};e.forEach(d=>d.addEventListener("abort",a));const{signal:x}=s;return x.unsubscribe=()=>p.asap(l),x}},wn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,o;for(;s<n;)o=s+t,yield e.slice(s,o),s=o},Sn=async function*(e,t){for await(const n of jn(e))yield*wn(n,t)},jn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},Dt=(e,t,n,s)=>{const o=Sn(e,t);let a=0,i,l=x=>{i||(i=!0,s&&s(x))};return new ReadableStream({async pull(x){try{const{done:d,value:u}=await o.next();if(d){l(),x.close();return}let b=u.byteLength;if(n){let y=a+=b;n(y)}x.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(x){return l(x),o.return()}},{highWaterMark:2})},Lt=64*1024,{isFunction:De}=p,vn=(({Request:e,Response:t})=>({Request:e,Response:t}))(p.global),{ReadableStream:Ft,TextEncoder:Mt}=p.global,Wt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kn=e=>{e=p.merge.call({skipUndefined:!0},vn,e);const{fetch:t,Request:n,Response:s}=e,o=t?De(t):typeof fetch=="function",a=De(n),i=De(s);if(!o)return!1;const l=o&&De(Ft),x=o&&(typeof Mt=="function"?(c=>j=>c.encode(j))(new Mt):async c=>new Uint8Array(await new n(c).arrayBuffer())),d=a&&l&&Wt(()=>{let c=!1;const j=new n(ee.origin,{body:new Ft,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return c&&!j}),u=i&&l&&Wt(()=>p.isReadableStream(new s("").body)),b={stream:u&&(c=>c.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!b[c]&&(b[c]=(j,m)=>{let A=j&&j[c];if(A)return A.call(j);throw new D(`Response type '${c}' is not supported`,D.ERR_NOT_SUPPORT,m)})});const y=async c=>{if(c==null)return 0;if(p.isBlob(c))return c.size;if(p.isSpecCompliantForm(c))return(await new n(ee.origin,{method:"POST",body:c}).arrayBuffer()).byteLength;if(p.isArrayBufferView(c)||p.isArrayBuffer(c))return c.byteLength;if(p.isURLSearchParams(c)&&(c=c+""),p.isString(c))return(await x(c)).byteLength},S=async(c,j)=>{const m=p.toFiniteNumber(c.getContentLength());return m??y(j)};return async c=>{let{url:j,method:m,data:A,signal:P,cancelToken:$,timeout:T,onDownloadProgress:F,onUploadProgress:g,responseType:O,headers:v,withCredentials:U="same-origin",fetchOptions:q}=Ut(c),M=t||fetch;O=O?(O+"").toLowerCase():"text";let K=bn([P,$&&$.toAbortSignal()],T),Z=null;const I=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let X;try{if(g&&d&&m!=="get"&&m!=="head"&&(X=await S(v,A))!==0){let f=new n(j,{method:"POST",body:A,duplex:"half"}),k;if(p.isFormData(A)&&(k=f.headers.get("content-type"))&&v.setContentType(k),f.body){const[N,h]=_t(X,Ue(At(g)));A=Dt(f.body,Lt,N,h)}}p.isString(U)||(U=U?"include":"omit");const V=a&&"credentials"in n.prototype,z={...q,signal:K,method:m.toUpperCase(),headers:v.normalize().toJSON(),body:A,duplex:"half",credentials:V?U:void 0};Z=a&&new n(j,z);let R=await(a?M(Z,q):M(j,z));const ne=u&&(O==="stream"||O==="response");if(u&&(F||ne&&I)){const f={};["status","statusText","headers"].forEach(E=>{f[E]=R[E]});const k=p.toFiniteNumber(R.headers.get("content-length")),[N,h]=F&&_t(k,Ue(At(F),!0))||[];R=new s(Dt(R.body,Lt,N,()=>{h&&h(),I&&I()}),f)}O=O||"text";let J=await b[p.findKey(b,O)||"text"](R,c);return!ne&&I&&I(),await new Promise((f,k)=>{zt(f,k,{data:J,headers:re.from(R.headers),status:R.status,statusText:R.statusText,config:c,request:Z})})}catch(V){throw I&&I(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,c,Z),{cause:V.cause||V}):D.from(V,V&&V.code,c,Z)}}},En=new Map,Bt=e=>{let t=e?e.env:{};const{fetch:n,Request:s,Response:o}=t,a=[s,o,n];let i=a.length,l=i,x,d,u=En;for(;l--;)x=a[l],d=u.get(x),d===void 0&&u.set(x,d=l?new Map:kn(t)),u=d;return d};Bt();const Ze={http:Vr,xhr:yn,fetch:{get:Bt}};p.forEach(Ze,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qt=e=>`- ${e}`,Cn=e=>p.isFunction(e)||e===null||e===!1,Ht={getAdapter:(e,t)=>{e=p.isArray(e)?e:[e];const{length:n}=e;let s,o;const a={};for(let i=0;i<n;i++){s=e[i];let l;if(o=s,!Cn(s)&&(o=Ze[(l=String(s)).toLowerCase()],o===void 0))throw new D(`Unknown adapter '${l}'`);if(o&&(p.isFunction(o)||(o=o.get(t))))break;a[l||"#"+i]=o}if(!o){const i=Object.entries(a).map(([x,d])=>`adapter ${x} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
4
|
`+i.map(qt).join(`
|
|
5
5
|
`):" "+qt(i[0]):"as no adapter specified";throw new D("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return o},adapters:Ze};function Qe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new be(null,e)}function Vt(e){return Qe(e),e.headers=re.from(e.headers),e.data=Ge.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ht.getAdapter(e.adapter||Ee.adapter,e)(e).then(function(s){return Qe(e),s.data=Ge.call(e,e.transformResponse,s),s.headers=re.from(s.headers),s},function(s){return Rt(s)||(Qe(e),s&&s.response&&(s.response.data=Ge.call(e,e.transformResponse,s.response),s.response.headers=re.from(s.response.headers))),Promise.reject(s)})}const Yt="1.12.2",Le={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Le[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Kt={};Le.transitional=function(t,n,s){function o(a,i){return"[Axios v"+Yt+"] Transitional option '"+a+"'"+i+(s?". "+s:"")}return(a,i,l)=>{if(t===!1)throw new D(o(i," has been removed"+(n?" in "+n:"")),D.ERR_DEPRECATED);return n&&!Kt[i]&&(Kt[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(a,i,l):!0}},Le.spelling=function(t){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function Tn(e,t,n){if(typeof e!="object")throw new D("options must be an object",D.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let o=s.length;for(;o-- >0;){const a=s[o],i=t[a];if(i){const l=e[a],x=l===void 0||i(l,a,e);if(x!==!0)throw new D("option "+a+" must be "+x,D.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new D("Unknown option "+a,D.ERR_BAD_OPTION)}}const Fe={assertOptions:Tn,validators:Le},ie=Fe.validators;let he=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Tt,response:new Tt}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const a=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?a&&!String(s.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
6
6
|
`+a):s.stack=a}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=xe(this.defaults,n);const{transitional:s,paramsSerializer:o,headers:a}=n;s!==void 0&&Fe.assertOptions(s,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),o!=null&&(p.isFunction(o)?n.paramsSerializer={serialize:o}:Fe.assertOptions(o,{encode:ie.function,serialize:ie.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fe.assertOptions(n,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=a&&p.merge(a.common,a[n.method]);a&&p.forEach(["delete","get","head","post","put","patch","common"],c=>{delete a[c]}),n.headers=re.concat(i,a);const l=[];let x=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(n)===!1||(x=x&&j.synchronous,l.unshift(j.fulfilled,j.rejected))});const d=[];this.interceptors.response.forEach(function(j){d.push(j.fulfilled,j.rejected)});let u,b=0,y;if(!x){const c=[Vt.bind(this),void 0];for(c.unshift(...l),c.push(...d),y=c.length,u=Promise.resolve(n);b<y;)u=u.then(c[b++],c[b++]);return u}y=l.length;let S=n;for(;b<y;){const c=l[b++],j=l[b++];try{S=c(S)}catch(m){j.call(this,m);break}}try{u=Vt.call(this,S)}catch(c){return Promise.reject(c)}for(b=0,y=d.length;b<y;)u=u.then(d[b++],d[b++]);return u}getUri(t){t=xe(this.defaults,t);const n=$t(t.baseURL,t.url,t.allowAbsoluteUrls);return Ct(n,t.params,t.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(t){he.prototype[t]=function(n,s){return this.request(xe(s||{},{method:t,url:n,data:(s||{}).data}))}}),p.forEach(["post","put","patch"],function(t){function n(s){return function(a,i,l){return this.request(xe(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}he.prototype[t]=n(),he.prototype[t+"Form"]=n(!0)});let In=class ar{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const s=this;this.promise.then(o=>{if(!s._listeners)return;let a=s._listeners.length;for(;a-- >0;)s._listeners[a](o);s._listeners=null}),this.promise.then=o=>{let a;const i=new Promise(l=>{s.subscribe(l),a=l}).then(o);return i.cancel=function(){s.unsubscribe(a)},i},t(function(a,i,l){s.reason||(s.reason=new be(a,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ar(function(o){t=o}),cancel:t}}};function Pn(e){return function(n){return e.apply(null,n)}}function On(e){return p.isObject(e)&&e.isAxiosError===!0}const et={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(et).forEach(([e,t])=>{et[t]=e});function Jt(e){const t=new he(e),n=ut(he.prototype.request,t);return p.extend(n,he.prototype,t,{allOwnKeys:!0}),p.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Jt(xe(e,o))},n}const W=Jt(Ee);W.Axios=he,W.CanceledError=be,W.CancelToken=In,W.isCancel=Rt,W.VERSION=Yt,W.toFormData=$e,W.AxiosError=D,W.Cancel=W.CanceledError,W.all=function(t){return Promise.all(t)},W.spread=Pn,W.isAxiosError=On,W.mergeConfig=xe,W.AxiosHeaders=re,W.formToJSON=e=>Pt(p.isHTMLForm(e)?new FormData(e):e),W.getAdapter=Ht.getAdapter,W.HttpStatusCode=et,W.default=W;const{Axios:bs,AxiosError:ws,CanceledError:Ss,isCancel:js,CancelToken:vs,VERSION:ks,all:Es,Cancel:Cs,isAxiosError:Ts,spread:Is,toFormData:Ps,AxiosHeaders:Os,HttpStatusCode:Rs,formToJSON:zs,getAdapter:_s,mergeConfig:As}=W;class Rn{baseUrl;apiKey;appId;client;constructor(t){if(!t||!t.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=t.baseUrl.replace(/\/$/,""),this.apiKey=t.apiKey||null,this.appId=t.appId||null,this.client=W.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:1e4})}async request(t,n,s,o={}){if(!t)throw new Error("HTTP method is required");if(!n)throw new Error("Request path is required");try{const a={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:n,method:t,data:a,headers:o})).data}catch(a){if(console.error("❌ [Request Error]:",a),a.isAxiosError){const i=a.response?.status||0,l=a.response?.data?.message||a.message||"Unknown Axios error occurred";throw new Error(`Request failed (${i}): ${l}`)}throw new Error(`Unexpected error: ${a.message||"Unknown failure"}`)}}async signup(t){const{name:n,email:s,password:o}=t;if(!n||!s||!o)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",t)}async login(t){const{email:n,password:s,appId:o}=t;if(!n||!s)throw new Error("login: 'email' and 'password' are required");return this.request("POST","/users/login",{email:n,password:s,appId:o||this.appId})}async updateUser(t){const{userId:n,appId:s}=t;if(!n)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${n}`,{...t,appId:s||this.appId})}async changePassword(t){const{userId:n,currentPassword:s,newPassword:o,appId:a}=t;if(!n)throw new Error("changePassword: 'userId' is required");if(!s||!o)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return this.request("PUT",`/users/change-password/${n}`,{currentPassword:s,newPassword:o,appId:a||this.appId})}async deleteUser(t){const{userId:n,appId:s}=t;if(!n)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${n}`,{appId:s||this.appId})}async getProfile(t){const{token:n}=t;if(!n)throw new Error("getProfile: 'token' is required");return this.request("GET","/users/profile",{},{Authorization:`Bearer ${n}`})}async sendVerifyOTP(t){const{token:n,appId:s}=t;if(!n)throw new Error("sendVerifyOTP: 'token' is required");return this.request("POST","/users/send-verify-otp",{appId:s||this.appId},{Authorization:`Bearer ${n}`})}async verifyEmail(t){const{token:n,otp:s,appId:o}=t;if(!n)throw new Error("verifyEmail: 'token' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");return this.request("POST","/users/verify-email",{otp:s,appId:o||this.appId},{Authorization:`Bearer ${n}`})}async forgotPassword(t){const{email:n,appId:s}=t;if(!n)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:n,appId:s||this.appId})}async resetPassword(t){const{email:n,otp:s,newPassword:o,appId:a}=t;if(!n||!s||!o)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:n,otp:s,newPassword:o,appId:a||this.appId})}async getUserData(t){const{userId:n}=t;if(!n)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${n}/data`)}async getSingleUserData(t){const{userId:n,dataId:s}=t;if(!n||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${n}/data/${s}`)}async addUserData(t){const{userId:n,data:s}=t;if(!n)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'data' is required");return this.request("POST",`/users/${n}/data`,s)}async updateUserData(t){const{userId:n,dataId:s,data:o}=t;if(!n||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!o)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${n}/data/${s}`,o)}async deleteUserData(t){const{userId:n,dataId:s}=t;if(!n||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${n}/data/${s}`)}}var Me={exports:{}},Te={};/**
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the MIT license found in the
|
|
21
21
|
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/var Gt;function _n(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&(function(){function e(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===
|
|
22
|
+
*/var Gt;function _n(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&(function(){function e(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===M?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case m:return"Fragment";case P:return"Profiler";case A:return"StrictMode";case g:return"Suspense";case O:return"SuspenseList";case q:return"Activity"}if(typeof f=="object")switch(typeof f.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),f.$$typeof){case j:return"Portal";case T:return f.displayName||"Context";case $:return(f._context.displayName||"Context")+".Consumer";case F:var k=f.render;return f=f.displayName,f||(f=k.displayName||k.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case v:return k=f.displayName||null,k!==null?k:e(f.type)||"Memo";case U:k=f._payload,f=f._init;try{return e(f(k))}catch{}}return null}function t(f){return""+f}function n(f){try{t(f);var k=!1}catch{k=!0}if(k){k=console;var N=k.error,h=typeof Symbol=="function"&&Symbol.toStringTag&&f[Symbol.toStringTag]||f.constructor.name||"Object";return N.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",h),t(f)}}function s(f){if(f===m)return"<>";if(typeof f=="object"&&f!==null&&f.$$typeof===U)return"<...>";try{var k=e(f);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function o(){var f=K.A;return f===null?null:f.getOwner()}function a(){return Error("react-stack-top-frame")}function i(f){if(Z.call(f,"key")){var k=Object.getOwnPropertyDescriptor(f,"key").get;if(k&&k.isReactWarning)return!1}return f.key!==void 0}function l(f,k){function N(){V||(V=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",k))}N.isReactWarning=!0,Object.defineProperty(f,"key",{get:N,configurable:!0})}function x(){var f=e(this.type);return z[f]||(z[f]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),f=this.props.ref,f!==void 0?f:null}function d(f,k,N,h,E,_){var B=N.ref;return f={$$typeof:c,type:f,key:k,props:N,_owner:h},(B!==void 0?B:null)!==null?Object.defineProperty(f,"ref",{enumerable:!1,get:x}):Object.defineProperty(f,"ref",{enumerable:!1,value:null}),f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(f,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(f,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:E}),Object.defineProperty(f,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f}function u(f,k,N,h,E,_){var B=k.children;if(B!==void 0)if(h)if(I(B)){for(h=0;h<B.length;h++)b(B[h]);Object.freeze&&Object.freeze(B)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(B);if(Z.call(k,"key")){B=e(f);var le=Object.keys(k).filter(function(Oe){return Oe!=="key"});h=0<le.length?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}",J[B+h]||(le=0<le.length?"{"+le.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
23
23
|
let props = %s;
|
|
24
24
|
<%s {...props} />
|
|
25
25
|
React keys must be passed directly to JSX without using spread:
|
|
26
26
|
let props = %s;
|
|
27
|
-
<%s key={someKey} {...props} />`,h,B,le,B),J[B+h]=!0)}if(B=null,N!==void 0&&(n(N),B=""+N),i(k)&&(n(k.key),B=""+k.key),"key"in k){N={};for(var pe in k)pe!=="key"&&(N[pe]=k[pe])}else N=k;return B&&l(N,typeof f=="function"?f.displayName||f.name||"Unknown":f),d(f,B,N,o(),E,
|
|
27
|
+
<%s key={someKey} {...props} />`,h,B,le,B),J[B+h]=!0)}if(B=null,N!==void 0&&(n(N),B=""+N),i(k)&&(n(k.key),B=""+k.key),"key"in k){N={};for(var pe in k)pe!=="key"&&(N[pe]=k[pe])}else N=k;return B&&l(N,typeof f=="function"?f.displayName||f.name||"Unknown":f),d(f,B,N,o(),E,_)}function b(f){y(f)?f._store&&(f._store.validated=1):typeof f=="object"&&f!==null&&f.$$typeof===U&&(f._payload.status==="fulfilled"?y(f._payload.value)&&f._payload.value._store&&(f._payload.value._store.validated=1):f._store&&(f._store.validated=1))}function y(f){return typeof f=="object"&&f!==null&&f.$$typeof===c}var S=w,c=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),T=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),K=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,I=Array.isArray,X=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(f){return f()}};var V,z={},R=S.react_stack_bottom_frame.bind(S,a)(),ne=X(s(a)),J={};Ie.Fragment=m,Ie.jsx=function(f,k,N){var h=1e4>K.recentlyCreatedOwnerStacks++;return u(f,k,N,!1,h?Error("react-stack-top-frame"):R,h?X(s(f)):ne)},Ie.jsxs=function(f,k,N){var h=1e4>K.recentlyCreatedOwnerStacks++;return u(f,k,N,!0,h?Error("react-stack-top-frame"):R,h?X(s(f)):ne)}})()),Ie}var Zt;function An(){return Zt||(Zt=1,process.env.NODE_ENV==="production"?Me.exports=zn():Me.exports=_n()),Me.exports}var r=An();const $n=async(e,t)=>{const{name:n,email:s,password:o,appId:a,phone:i,address:l,avatarUrl:x,isActive:d=!0,role:u="user"}=e,{baseUrl:b,apiKey:y}=t;if(!y)throw new Error("API key is required for signup");if(!n||!s||!o||!a)throw new Error("Name, email, password, and appId are required");try{const S=await W.post(`${b}/users/signup`,{name:n,email:s,password:o,appId:a,phone:i,address:l,avatarUrl:x,isActive:d,role:u},{headers:{"Content-Type":"application/json","x-api-key":y}});return S.data?.user&&localStorage.setItem("userInfo",JSON.stringify(S.data.user)),S.data.user}catch(S){const c=S.response?.data?.message||S.message||"Signup failed";if(console.error("Signup API Error:",c),S.response?.status===400){if(c.includes("already exists"))throw{success:!1,message:"User with this email already exists for this app",status:400};if(c.includes("inactive"))throw{success:!1,message:"Cannot signup under an inactive app",status:400}}throw S.response?.status===404?{success:!1,message:"Invalid or inactive app",status:404}:{success:!1,message:c,status:S.response?.status||500}}};/**
|
|
28
28
|
* @license lucide-react v0.544.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
@@ -199,12 +199,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
199
199
|
*
|
|
200
200
|
* This source code is licensed under the ISC license.
|
|
201
201
|
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
-
*/const Pe=H("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={baseUrl:"",apiKey:"",appId:""},Qn=e=>{if(!e.baseUrl||!e.apiKey||!e.appId)throw new Error("baseUrl, apiKey, and appId are required");Be.baseUrl=e.baseUrl,Be.apiKey=e.apiKey,Be.appId=e.appId},ue=()=>Be,es=({logoUrl:e,logoLinkUrl:t,title:n="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:x=!1,roles:d=[],showRoleSelector:u=!1,loginUrl:b,onSuccess:y,onError:S})=>{const{baseUrl:c,apiKey:j,appId:m}=ue(),A={name:"",email:"",password:"",role:d.length?d[0]:"user",...x&&{avatarUrl:""}},[P,$]=w.useState(A),[T,
|
|
202
|
+
*/const Pe=H("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={baseUrl:"",apiKey:"",appId:""},Qn=e=>{if(!e.baseUrl||!e.apiKey||!e.appId)throw new Error("baseUrl, apiKey, and appId are required");Be.baseUrl=e.baseUrl,Be.apiKey=e.apiKey,Be.appId=e.appId},ue=()=>Be,es=({logoUrl:e,logoLinkUrl:t,title:n="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:x=!1,roles:d=[],showRoleSelector:u=!1,loginUrl:b,onSuccess:y,onError:S})=>{const{baseUrl:c,apiKey:j,appId:m}=ue(),A={name:"",email:"",password:"",role:d.length?d[0]:"user",...x&&{avatarUrl:""}},[P,$]=w.useState(A),[T,F]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(null),[q,M]=w.useState({}),[K,Z]=w.useState(!1),I=l?"#ffffff":"#111827",X=l?"#a1a1aa":"#6b7280",V=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",z=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const k=()=>Z(window.innerWidth<768);return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)}},[]);const R=k=>{const{name:N,value:h}=k.target;$(E=>({...E,[N]:h})),q[N]&&M(E=>({...E,[N]:void 0}))},ne=()=>{const k={};return P.name.trim()||(k.name="Name is required"),P.email.trim()?/\S+@\S+\.\S+/.test(P.email)||(k.email="Invalid email address"):k.email="Email is required",P.password?P.password.length<6&&(k.password="Password must be at least 6 characters"):k.password="Password is required",M(k),Object.keys(k).length===0},J=async k=>{if(k.preventDefault(),!!ne()){O(!0),U(null);try{const N={...P,appId:m},h=await $n(N,{baseUrl:c,apiKey:j});U({type:"success",text:"Account created successfully!"}),y&&y(h)}catch(N){const h=N.message||"Signup failed. Please try again.";U({type:"error",text:h}),S&&S(N)}finally{O(!1)}}},f={width:"100%",padding:K?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:V,border:`1px solid ${z}`,borderRadius:"10px",color:I,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"};return r.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[r.jsxs("div",{style:{minWidth:K?"320px":"380px",width:"100%",maxWidth:K?"340px":"390px",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:K?"30px 24px":"20px 28px"},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?r.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:r.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):r.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),r.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:I,margin:0},children:n}),r.jsx("p",{style:{fontSize:"14px",color:X},children:s})]}),x&&P.avatarUrl&&r.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:r.jsx("img",{src:P.avatarUrl,alt:"Avatar Preview",style:{width:"60px",height:"60px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${a}30`},onError:k=>{const N=k.target;N.style.display="none"}})}),r.jsxs("form",{onSubmit:J,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[u&&d&&d.length===2&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{style:{fontSize:"14px",fontWeight:500,color:I},children:"Select Role"}),r.jsxs("div",{style:{position:"relative",display:"flex",borderRadius:"10px",border:`1px solid ${z}`,backgroundColor:V,overflow:"hidden",cursor:"pointer",height:"42px"},children:[r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"50%",height:"100%",backgroundColor:l?"#000000":"#ffffff",boxShadow:l?"0 1px 3px rgba(255,255,255,0.05)":"0 1px 3px rgba(0,0,0,0.1)",borderRadius:"10px",transition:"transform 0.3s ease, background-color 0.3s ease",transform:P.role===d[1]?"translateX(100%)":"translateX(0)",zIndex:0}}),r.jsx("button",{type:"button",onClick:()=>$(k=>({...k,role:d[0]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[0]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[0]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[0].charAt(0).toUpperCase()+d[0].slice(1)}),r.jsx("button",{type:"button",onClick:()=>$(k=>({...k,role:d[1]})),style:{flex:1,zIndex:10,border:"none",background:"transparent",color:P.role===d[1]?a:l?"#9ca3af":"#6b7280",fontWeight:P.role===d[1]?600:500,fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s ease"},children:d[1].charAt(0).toUpperCase()+d[1].slice(1)})]})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"signup-name",style:{fontSize:"14px",fontWeight:500,color:I},children:"Full Name"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:X}}),r.jsx("input",{id:"signup-name",type:"text",name:"name",placeholder:"Enter your full name",value:P.name,onChange:R,style:{...f,borderColor:q.name?"#ef4444":z}})]}),q.name&&r.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.name})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"signup-email",style:{fontSize:"14px",fontWeight:500,color:I},children:"Email Address"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:X}}),r.jsx("input",{id:"signup-email",type:"email",name:"email",placeholder:"Enter your email address",value:P.email,onChange:R,style:{...f,borderColor:q.email?"#ef4444":z}})]}),q.email&&r.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.email})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"signup-password",style:{fontSize:"14px",fontWeight:500,color:I},children:"Password"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:X}}),r.jsx("input",{id:"signup-password",type:T?"text":"password",name:"password",placeholder:"Create a secure password",value:P.password,onChange:R,style:{...f,borderColor:q.password?"#ef4444":z}}),r.jsx("button",{type:"button",onClick:()=>F(!T),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:X,cursor:"pointer",padding:"4px"},children:T?r.jsx(nt,{size:20}):r.jsx(st,{size:20})})]}),q.password&&r.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.password})]}),x&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"signup-avatar",style:{fontSize:"14px",fontWeight:500,color:I},children:"Avatar URL (Optional)"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(tr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:X}}),r.jsx("input",{id:"signup-avatar",type:"url",name:"avatarUrl",placeholder:"Paste your avatar image URL",value:P.avatarUrl||"",onChange:R,style:f})]})]}),b&&r.jsx("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:r.jsx("a",{href:b,style:{color:a,textDecoration:"none",fontWeight:500},children:"Already have an account?"})}),v&&r.jsxs("div",{style:{padding:"12px",borderRadius:"12px",fontSize:"12px",display:"flex",alignItems:"start",gap:"10px",backgroundColor:v.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:v.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:v.type==="success"?a:"#ef4444"},children:[v.type==="success"?r.jsx(de,{size:20}):r.jsx(ae,{size:20}),r.jsx("span",{children:v.text})]}),r.jsx("button",{type:"submit",disabled:g,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600,cursor:g?"not-allowed":"pointer",opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:g?r.jsxs(r.Fragment,{children:[r.jsx(Vn,{size:18,style:{animation:"spin 1s linear infinite"}}),"Creating Account..."]}):"Create Account"})]}),r.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:X,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",r.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]}),r.jsx("style",{children:`
|
|
203
203
|
@keyframes spin {
|
|
204
204
|
from { transform: rotate(0deg); }
|
|
205
205
|
to { transform: rotate(360deg); }
|
|
206
206
|
}
|
|
207
|
-
`})]})},ts=async(e,t)=>{const{email:n,password:s,appId:o}=e,{baseUrl:a,apiKey:i}=t;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:n,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":i}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const x=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",x),{success:!1,message:x,status:l.response?.status||500}}},rs=({logoUrl:e,logoLinkUrl:t,title:n="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:x,onSuccess:d,onError:u})=>{const{baseUrl:b,apiKey:y,appId:S}=ue(),[c,j]=w.useState("login"),[m,A]=w.useState(1),[P,$]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(null),[v,U]=w.useState(""),[q,F]=w.useState(""),[Y,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,X]=w.useState(!1),K=l?"#ffffff":"#111827",_=l?"#a1a1aa":"#6b7280",R=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",ne=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const E=()=>X(window.innerWidth<768);return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)}},[]);const J=async E=>{E.preventDefault(),M(!0),O(null);try{const z=await ts({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${z.name}`}),d?.(z)}catch(z){const B=z.message||"Login failed";O({type:"error",text:B}),u?.(z)}finally{M(!1)}},f=E=>{Z({...Y,[E.target.name]:E.target.value})},k=async E=>{E.preventDefault(),M(!0),O(null);try{const z=await W.post(`${b}/users/forgot-password`,{email:Y.email,appId:S},{headers:{"x-api-key":y}});z.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:z.data.message||"Failed to send OTP"})}catch(z){O({type:"error",text:z.response?.data?.message||"Something went wrong"})}finally{M(!1)}},N=async E=>{E.preventDefault(),M(!0),O(null);try{const z=await W.post(`${b}/users/reset-password`,Y,{headers:{"x-api-key":y}});z.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:z.data.message||"Reset failed"})}catch(z){O({type:"error",text:z.response?.data?.message||"Something went wrong"})}finally{M(!1)}},h={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:R,border:`1px solid ${ne}`,borderRadius:"10px",color:K,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return r.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:r.jsxs("div",{style:{minWidth:I?"320px":"380px",maxWidth:I?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:I?"30px 24px":"18px 28px"},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?r.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:r.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):r.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),r.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:K,margin:0},children:c==="login"?n:m===1?"Forgot Password":"Reset Password"}),r.jsx("p",{style:{fontSize:"14px",color:_},children:c==="login"?s:"Follow the steps to reset your password"})]}),c==="login"&&r.jsxs("form",{onSubmit:J,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:_}}),r.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:E=>U(E.target.value),style:h})]})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:_}}),r.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:E=>F(E.target.value),style:h}),r.jsx("button",{type:"button",onClick:()=>$(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:_,cursor:"pointer"},children:P?r.jsx(nt,{size:20}):r.jsx(st,{size:20})})]})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[x&&r.jsx("a",{href:x,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),r.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),r.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),c==="forgot"&&r.jsxs("form",{onSubmit:m===1?k:N,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:_}}),r.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:Y.email,onChange:f,style:h})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[r.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(rr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:_}}),r.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:Y.otp,onChange:f,style:h})]})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[r.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:_}}),r.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:Y.newPassword,onChange:f,style:h})]})]})]}),r.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":m===1?"Send Reset OTP":"Reset Password"}),r.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:_,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&r.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:g.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:g.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:g.type==="success"?a:"#ef4444"},children:[g.type==="success"?r.jsx(de,{size:20}):r.jsx(ae,{size:20}),r.jsx("span",{children:g.text})]}),r.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:_,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",r.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},ns=({children:e,fallback:t=null,width:n,height:s})=>{const[o,a]=w.useState(!1);return w.useEffect(()=>{const i=()=>{if(typeof window>"u")return!1;try{const x=localStorage.getItem("userInfo");return!!(x&&x!=="undefined"&&x!=="null")}catch{return!1}},l=()=>a(i());return l(),typeof window<"u"&&window.addEventListener("storage",l),()=>{typeof window<"u"&&window.removeEventListener("storage",l)}},[]),o?r.jsx("span",{style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:n,height:s},children:e}):r.jsx(r.Fragment,{children:t})},ss=({children:e,fallback:t=null,width:n,height:s})=>{const[o,a]=w.useState(!0);return w.useEffect(()=>{const i=()=>{try{const x=localStorage.getItem("userInfo");return!!(x&&x!=="undefined"&&x!=="null")}catch{return!1}},l=()=>a(!i());return l(),window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]),o?r.jsx("span",{style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:n,height:s},children:e}):r.jsx(r.Fragment,{children:t})},os=({isOpen:e,onClose:t,onSuccess:n,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:x,appId:d}=ue(),[u,b]=w.useState(!1),[y,S]=w.useState(""),[c,j]=w.useState("warning"),[m,A]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const g=()=>{A(window.innerWidth<640)};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),!e)return null;const P=async()=>{b(!0),j("processing");try{const{data:g}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:d},headers:{"x-api-key":x}});g.success?(n(g.message||"Account deleted successfully"),j("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(g.message||"Failed to delete account"),j("warning"))}catch(g){s(g.response?.data?.message||"Something went wrong"),j("warning")}finally{b(!1)}},$=y.toLowerCase()==="delete my account",T=g=>{g.target===g.currentTarget&&c!=="processing"&&c!=="success"&&t()},M=()=>{switch(c){case"warning":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(We,{size:20})}),r.jsx("div",{children:r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),r.jsx("button",{onClick:t,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:i.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.color=i.textPrimary},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.color=i.textTertiary},children:r.jsx(Pe,{size:20})})]}),r.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[r.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:r.jsx(sr,{size:24})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:r.jsx(Wn,{size:16}),text:"All your data will be permanently deleted"},{icon:r.jsx(Zn,{size:16}),text:"This action cannot be reversed"},{icon:r.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[r.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),r.jsx("span",{children:g.text})]},O))})]})]}),r.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[r.jsx("button",{onClick:t,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),r.jsxs("button",{onClick:()=>j("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:g=>{g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[r.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(sr,{size:24})}),r.jsx("div",{style:{flex:1},children:r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),r.jsxs("div",{style:{marginBottom:"24px"},children:[r.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",r.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),r.jsx("input",{type:"text",value:y,onChange:g=>S(g.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${$?i.success:i.error}`,backgroundColor:"transparent",color:i.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:g=>{g.target.style.boxShadow=`0 0 0 3px ${i.accent}20`},onBlur:g=>{g.target.style.boxShadow="none"},autoFocus:!0}),$&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[r.jsx(rt,{size:16}),r.jsx("span",{children:"Confirmation accepted"})]})]}),r.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[r.jsx("button",{onClick:()=>{j("warning"),S("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),r.jsxs("button",{onClick:P,disabled:!$||u,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!$||u?"not-allowed":"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",opacity:!$||u?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!$||u?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{$&&!u&&(g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:g=>{$&&!u&&(g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[r.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),r.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),r.jsx("div",{style:{marginBottom:"20px"},children:r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((g,O)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.active?`${i.accent}10`:"transparent"},children:[r.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:g.active?i.accent:i.textTertiary,transition:"all 0.3s ease",boxShadow:g.active?`0 0 0 4px ${i.accent}20`:"none"}}),r.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[r.jsx(nr,{size:18,style:{color:i.accent,flexShrink:0}}),r.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(rt,{size:20})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),r.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),r.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[r.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),r.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),r.jsx("p",{style:{color:i.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary,justifyContent:"center"},children:[r.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),r.jsx("span",{children:"Redirecting to login page..."})]})]})}};return r.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[r.jsx("div",{style:{backgroundColor:i.surface,border:`1px solid ${i.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:M()}),r.jsx("style",{children:`
|
|
207
|
+
`})]})},ts=async(e,t)=>{const{email:n,password:s,appId:o}=e,{baseUrl:a,apiKey:i}=t;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:n,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":i}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const x=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",x),{success:!1,message:x,status:l.response?.status||500}}},rs=({logoUrl:e,logoLinkUrl:t,title:n="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:a="#00C214",gradient:i="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:x,onSuccess:d,onError:u})=>{const{baseUrl:b,apiKey:y,appId:S}=ue(),[c,j]=w.useState("login"),[m,A]=w.useState(1),[P,$]=w.useState(!1),[T,F]=w.useState(!1),[g,O]=w.useState(null),[v,U]=w.useState(""),[q,M]=w.useState(""),[K,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,X]=w.useState(!1),V=l?"#ffffff":"#111827",z=l?"#a1a1aa":"#6b7280",R=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",ne=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const E=()=>X(window.innerWidth<768);return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)}},[]);const J=async E=>{E.preventDefault(),F(!0),O(null);try{const _=await ts({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${_.name}`}),d?.(_)}catch(_){const B=_.message||"Login failed";O({type:"error",text:B}),u?.(_)}finally{F(!1)}},f=E=>{Z({...K,[E.target.name]:E.target.value})},k=async E=>{E.preventDefault(),F(!0),O(null);try{const _=await W.post(`${b}/users/forgot-password`,{email:K.email,appId:S},{headers:{"x-api-key":y}});_.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:_.data.message||"Failed to send OTP"})}catch(_){O({type:"error",text:_.response?.data?.message||"Something went wrong"})}finally{F(!1)}},N=async E=>{E.preventDefault(),F(!0),O(null);try{const _=await W.post(`${b}/users/reset-password`,K,{headers:{"x-api-key":y}});_.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:_.data.message||"Reset failed"})}catch(_){O({type:"error",text:_.response?.data?.message||"Something went wrong"})}finally{F(!1)}},h={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:R,border:`1px solid ${ne}`,borderRadius:"10px",color:V,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return r.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:r.jsxs("div",{style:{minWidth:I?"320px":"380px",maxWidth:I?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:I?"30px 24px":"18px 28px"},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?r.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:r.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):r.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),r.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:V,margin:0},children:c==="login"?n:m===1?"Forgot Password":"Reset Password"}),r.jsx("p",{style:{fontSize:"14px",color:z},children:c==="login"?s:"Follow the steps to reset your password"})]}),c==="login"&&r.jsxs("form",{onSubmit:J,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:z}}),r.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:E=>U(E.target.value),style:h})]})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:z}}),r.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:E=>M(E.target.value),style:h}),r.jsx("button",{type:"button",onClick:()=>$(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:z,cursor:"pointer"},children:P?r.jsx(nt,{size:20}):r.jsx(st,{size:20})})]})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[x&&r.jsx("a",{href:x,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),r.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),r.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),c==="forgot"&&r.jsxs("form",{onSubmit:m===1?k:N,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:z}}),r.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:K.email,onChange:f,style:h})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[r.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(rr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:z}}),r.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:K.otp,onChange:f,style:h})]})]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[r.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:z}}),r.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:K.newPassword,onChange:f,style:h})]})]})]}),r.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:i,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":m===1?"Send Reset OTP":"Reset Password"}),r.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:z,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&r.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:g.type==="success"?`${a}15`:"rgba(239,68,68,0.1)",border:g.type==="success"?`1px solid ${a}30`:"1px solid rgba(239,68,68,0.3)",color:g.type==="success"?a:"#ef4444"},children:[g.type==="success"?r.jsx(de,{size:20}):r.jsx(ae,{size:20}),r.jsx("span",{children:g.text})]}),r.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:z,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",r.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},ns=({children:e,fallback:t=null,width:n,height:s})=>{const[o,a]=w.useState(!1);return w.useEffect(()=>{const i=()=>{if(typeof window>"u")return!1;try{const x=localStorage.getItem("userInfo");return!!(x&&x!=="undefined"&&x!=="null")}catch{return!1}},l=()=>a(i());return l(),typeof window<"u"&&window.addEventListener("storage",l),()=>{typeof window<"u"&&window.removeEventListener("storage",l)}},[]),o?r.jsx("span",{style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:n,height:s},children:e}):r.jsx(r.Fragment,{children:t})},ss=({children:e,fallback:t=null,width:n,height:s})=>{const[o,a]=w.useState(!0);return w.useEffect(()=>{const i=()=>{try{const x=localStorage.getItem("userInfo");return!!(x&&x!=="undefined"&&x!=="null")}catch{return!1}},l=()=>a(!i());return l(),window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]),o?r.jsx("span",{style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:n,height:s},children:e}):r.jsx(r.Fragment,{children:t})},os=({isOpen:e,onClose:t,onSuccess:n,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:x,appId:d}=ue(),[u,b]=w.useState(!1),[y,S]=w.useState(""),[c,j]=w.useState("warning"),[m,A]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const g=()=>{A(window.innerWidth<640)};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),!e)return null;const P=async()=>{b(!0),j("processing");try{const{data:g}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:d},headers:{"x-api-key":x}});g.success?(n(g.message||"Account deleted successfully"),j("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(g.message||"Failed to delete account"),j("warning"))}catch(g){s(g.response?.data?.message||"Something went wrong"),j("warning")}finally{b(!1)}},$=y.toLowerCase()==="delete my account",T=g=>{g.target===g.currentTarget&&c!=="processing"&&c!=="success"&&t()},F=()=>{switch(c){case"warning":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(We,{size:20})}),r.jsx("div",{children:r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),r.jsx("button",{onClick:t,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:i.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.color=i.textPrimary},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.color=i.textTertiary},children:r.jsx(Pe,{size:20})})]}),r.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[r.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:r.jsx(sr,{size:24})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:r.jsx(Wn,{size:16}),text:"All your data will be permanently deleted"},{icon:r.jsx(Zn,{size:16}),text:"This action cannot be reversed"},{icon:r.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[r.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),r.jsx("span",{children:g.text})]},O))})]})]}),r.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[r.jsx("button",{onClick:t,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),r.jsxs("button",{onClick:()=>j("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:g=>{g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[r.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(sr,{size:24})}),r.jsx("div",{style:{flex:1},children:r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),r.jsxs("div",{style:{marginBottom:"24px"},children:[r.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",r.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),r.jsx("input",{type:"text",value:y,onChange:g=>S(g.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${$?i.success:i.error}`,backgroundColor:"transparent",color:i.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:g=>{g.target.style.boxShadow=`0 0 0 3px ${i.accent}20`},onBlur:g=>{g.target.style.boxShadow="none"},autoFocus:!0}),$&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[r.jsx(rt,{size:16}),r.jsx("span",{children:"Confirmation accepted"})]})]}),r.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[r.jsx("button",{onClick:()=>{j("warning"),S("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${i.border}`,background:"transparent",color:i.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:m?"none":1,minWidth:m?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:g=>{g.currentTarget.style.backgroundColor=i.border,g.currentTarget.style.transform="translateY(-1px)"},onMouseOut:g=>{g.currentTarget.style.backgroundColor="transparent",g.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),r.jsxs("button",{onClick:P,disabled:!$||u,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!$||u?"not-allowed":"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",opacity:!$||u?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!$||u?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{$&&!u&&(g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:g=>{$&&!u&&(g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[r.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),r.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),r.jsx("div",{style:{marginBottom:"20px"},children:r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((g,O)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.active?`${i.accent}10`:"transparent"},children:[r.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:g.active?i.accent:i.textTertiary,transition:"all 0.3s ease",boxShadow:g.active?`0 0 0 4px ${i.accent}20`:"none"}}),r.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[r.jsx(nr,{size:18,style:{color:i.accent,flexShrink:0}}),r.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:r.jsx(rt,{size:20})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),r.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),r.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[r.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),r.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),r.jsx("p",{style:{color:i.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary,justifyContent:"center"},children:[r.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),r.jsx("span",{children:"Redirecting to login page..."})]})]})}};return r.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[r.jsx("div",{style:{backgroundColor:i.surface,border:`1px solid ${i.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:F()}),r.jsx("style",{children:`
|
|
208
208
|
@keyframes fadeIn {
|
|
209
209
|
from { opacity: 0; }
|
|
210
210
|
to { opacity: 1; }
|
|
@@ -306,7 +306,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
306
306
|
transition: none !important;
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
`})]})},as=({isOpen:e,onClose:t,onSuccess:n,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:x}=ue(),[d,u]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState({}),[S,c]=w.useState(!1),[j,m]=w.useState({currentPassword:!1,newPassword:!1,confirmPassword:!1}),[A,P]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const v=()=>{P(window.innerWidth<640)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]),!e)return null;const $=v=>{const{name:U,value:q}=v.target;u(
|
|
309
|
+
`})]})},as=({isOpen:e,onClose:t,onSuccess:n,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:x}=ue(),[d,u]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState({}),[S,c]=w.useState(!1),[j,m]=w.useState({currentPassword:!1,newPassword:!1,confirmPassword:!1}),[A,P]=w.useState(!1);if(w.useEffect(()=>{if(typeof window>"u")return;const v=()=>{P(window.innerWidth<640)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]),!e)return null;const $=v=>{const{name:U,value:q}=v.target;u(M=>({...M,[U]:q})),b[U]&&y(M=>({...M,[U]:""}))},T=v=>{m(U=>({...U,[v]:!U[v]}))},F=()=>{const v={};return d.currentPassword||(v.currentPassword="Current password is required"),d.newPassword?d.newPassword.length<6&&(v.newPassword="Password must be at least 6 characters"):v.newPassword="New password is required",d.newPassword!==d.confirmPassword&&(v.confirmPassword="Passwords do not match"),y(v),Object.keys(v).length===0},g=async v=>{if(v.preventDefault(),!!F()){c(!0);try{const{data:U}=await W.put(`${i}/users/change-password/${o}`,{appId:x,currentPassword:d.currentPassword,newPassword:d.newPassword},{headers:{"x-api-key":l}});U.success?(n(U.message||"Password updated successfully"),u({currentPassword:"",newPassword:"",confirmPassword:""}),t()):s(U.message||"Failed to update password")}catch(U){s(U.response?.data?.message||"Something went wrong")}finally{c(!1)}}},O=[{field:"currentPassword",label:"Current Password",icon:r.jsx(ot,{size:18})},{field:"newPassword",label:"New Password",icon:r.jsx(we,{size:18})},{field:"confirmPassword",label:"Confirm Password",icon:r.jsx(we,{size:18})}];return r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e3},children:r.jsxs("div",{style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,borderRadius:"16px",maxWidth:"440px",width:"100%",padding:"24px",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",maxHeight:"90vh",overflowY:"auto"},className:"change-password-modal",children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px",gap:"12px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[r.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"10px",background:`linear-gradient(135deg, ${a.accent}20, ${a.accent}40)`,display:"flex",alignItems:"center",justifyContent:"center",color:a.accent,flexShrink:0},children:r.jsx(we,{size:20})}),r.jsx("div",{children:r.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"18px",fontWeight:600,lineHeight:"1.4"},children:"Change Password"})})]}),r.jsx("button",{onClick:t,"aria-label":"Close password change modal",style:{background:"transparent",border:"none",color:a.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:v=>{v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.color=a.textPrimary},onMouseOut:v=>{v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.color=a.textTertiary},children:r.jsx(Pe,{size:20})})]}),r.jsxs("form",{onSubmit:g,children:[O.map(({field:v,label:U,icon:q})=>r.jsxs("div",{style:{marginBottom:"20px",position:"relative"},children:[r.jsx("label",{htmlFor:v,style:{display:"block",marginBottom:"8px",color:a.textPrimary,fontSize:"14px",fontWeight:500,lineHeight:"1.4"},children:U}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx("div",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:a.textTertiary,zIndex:2},children:q}),r.jsx("input",{type:j[v]?"text":"password",id:v,name:v,placeholder:`Enter ${U.toLowerCase()}`,value:d[v],onChange:$,style:{width:"100%",padding:"14px 48px 14px 44px",borderRadius:"10px",border:`1.5px solid ${b[v]?a.error:a.border}`,backgroundColor:"transparent",color:a.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:M=>{M.target.style.borderColor=a.accent,M.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:M=>{M.target.style.borderColor=b[v]?a.error:a.border,M.target.style.boxShadow="none"}}),r.jsx("button",{type:"button",onClick:()=>T(v),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",cursor:"pointer",color:a.textTertiary,padding:"4px",borderRadius:"4px",width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center"},onMouseOver:M=>{M.currentTarget.style.backgroundColor=a.border,M.currentTarget.style.color=a.textPrimary},onMouseOut:M=>{M.currentTarget.style.backgroundColor="transparent",M.currentTarget.style.color=a.textTertiary},children:j[v]?r.jsx(nt,{size:18}):r.jsx(st,{size:18})})]}),b[v]&&r.jsxs("div",{style:{fontSize:"13px",color:a.error,marginTop:"6px",display:"flex",alignItems:"center",gap:"6px"},children:[r.jsx("span",{style:{fontSize:"16px"},children:"⚠"}),b[v]]})]},v)),r.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:A?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[r.jsx("button",{type:"button",onClick:t,disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"120px",opacity:S?.6:1,transition:"all 0.2s ease"},onMouseOver:v=>{S||(v.currentTarget.style.backgroundColor=a.border,v.currentTarget.style.transform="translateY(-1px)")},onMouseOut:v=>{S||(v.currentTarget.style.backgroundColor="transparent",v.currentTarget.style.transform="translateY(0)")},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:S,style:{padding:"14px 24px",borderRadius:"10px",border:"none",background:`linear-gradient(135deg, ${a.accent}, ${a.accent}E6)`,color:"#fff",fontSize:"14px",fontWeight:600,cursor:S?"not-allowed":"pointer",flex:A?"none":1,minWidth:A?"100%":"140px",opacity:S?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:S?"none":`0 4px 12px ${a.accent}40`},onMouseOver:v=>{S||(v.currentTarget.style.transform="translateY(-1px)",v.currentTarget.style.boxShadow=`0 6px 20px ${a.accent}60`)},onMouseOut:v=>{S||(v.currentTarget.style.transform="translateY(0)",v.currentTarget.style.boxShadow=`0 4px 12px ${a.accent}40`)},children:S?r.jsxs(r.Fragment,{children:[r.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Updating..."]}):"Update Password"})]})]}),r.jsx("style",{children:`
|
|
310
310
|
@keyframes spin {
|
|
311
311
|
from { transform: rotate(0deg); }
|
|
312
312
|
to { transform: rotate(360deg); }
|
|
@@ -491,7 +491,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
491
491
|
animation: none;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
`})]})},ds=({token:e,user:t=null,darkMode:n=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:x,appId:d}=ue(),[u,b]=w.useState(null),[y,S]=w.useState(t),[c,j]=w.useState(!0),[m,A]=w.useState(!1),[P,$]=w.useState(!1),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(!1),[q,F]=w.useState(!1),[Y,Z]=w.useState(!1),[I,X]=w.useState(!1),[K,_]=w.useState(null),[R,ne]=w.useState(!1),[J,f]=w.useState({email:"",otp:"",appId:d}),[k,N]=w.useState(!1),[h,E]=w.useState(!1);w.useEffect(()=>{if(typeof window<"u"){const C=()=>b(window.innerWidth);return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)}},[]);const z=(C,V)=>{_({type:C,message:V}),setTimeout(()=>_(null),3e3)},B=()=>{X(!0);const C=setTimeout(()=>{Z(!1),X(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=V=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(V.target)&&B()};return Y&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[Y]);const le=async()=>{if(!J.email||!/\S+@\S+\.\S+/.test(J.email)){z("error","Please enter a valid email");return}try{E(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:J.email},{headers:{"x-api-key":x,"x-app-id":d}});C.data.success?(z("success",C.data.message||"OTP sent to email!"),N(!0)):z("error",C.data.message||"Failed to send OTP")}catch(C){z("error",C.response?.data?.message||"Server error")}finally{E(!1)}},pe=async C=>{if(C.preventDefault(),!J.email||!J.otp){z("error","Please fill in all fields");return}try{E(!0);const V=await W.post(`${l}/users/verify-email`,J);if(V.data.success){if(z("success",V.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:e})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),N(!1),F(!1)}else z("error",V.data.message||"Verification failed")}catch(V){z("error",V.response?.data?.message||"Something went wrong")}finally{E(!1)}},Oe=async C=>{if(!y)return!1;try{const V={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,V,{headers:{"x-api-key":x}});return G.success?(S(V),localStorage.setItem("userInfo",JSON.stringify({...V,token:e})),z("success","Avatar updated successfully!"),!0):(z("error",G.message||"Failed to update avatar"),!1)}catch(V){return console.error("Avatar update error:",V),z("error","Failed to update avatar"),!1}},lt=async()=>{if(y){$(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":x}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:e})),z("success","Profile updated successfully")):z("error",C.message)}catch(C){console.error(C),z("error","Update failed")}finally{$(!1)}}},or=async C=>{try{const{data:V}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":x}});V?.success===!0&&V?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(V){console.error("⚠️ User validation request failed:",V)}};w.useEffect(()=>{(()=>{if(t)S(t),j(!1),or(t.id);else{const V=localStorage.getItem("userInfo");if(V){const G=JSON.parse(V);S(G),j(!1),or(G.id)}else j(!1)}})()},[t]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const ir=(C,V)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+V,dt=(G>>8&255)+V,ct=(G&255)+V;return ge=Math.min(255,Math.max(0,ge)),dt=Math.min(255,Math.max(0,dt)),ct=Math.min(255,Math.max(0,ct)),`#${(ct|dt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=n?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:ir(i,-15),success:"#10b981",error:"#ef4444",border:"#27272a",warning:"#f59e0b"}:{background:"#ffffff",surface:"#fafafa",surfaceLight:"#f4f4f5",surfaceLighter:"#e4e4e7",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",accent:i,accentHover:ir(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(c)return r.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[r.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),r.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return r.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[r.jsx(ae,{size:40,color:L.error,"aria-hidden":"true"}),r.jsx("p",{style:{color:L.textTertiary,margin:0},children:"No profile found. Please log in again."})]})});const ps=[{label:"Full Name",value:y.name,name:"name",type:"text",icon:Se},{label:"Email Address",value:y.email,name:"email",type:"email",icon:ce},{label:"Phone Number",value:y.phone||"Not set",name:"phone",type:"tel",icon:Jn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Yn}];return r.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",lineHeight:1.5,minHeight:"80vh"},children:[K&&r.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",padding:"12px 24px",borderRadius:"12px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"blur(8px)",border:"1px solid",zIndex:1e3,display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontWeight:500,maxWidth:"400px",animation:"slideIn 0.3s ease-out",...K.type==="success"?{backgroundColor:n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:n?"#34d399":"#059669"}:{backgroundColor:n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:n?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:n?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[K.type==="success"?r.jsx(de,{size:20,"aria-hidden":"true"}):r.jsx(ae,{size:20,"aria-hidden":"true"}),K.message]}),r.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:r.jsxs("div",{style:{display:"grid",gap:"24px",gridTemplateColumns:"1fr",...u&&window.innerWidth>=1024&&{gridTemplateColumns:"1fr 2fr",gap:"10px"},...u&&window.innerWidth>=768&&u&&window.innerWidth<1024&&{gap:"10px"},...u&&window.innerWidth>=600&&u&&window.innerWidth<768&&{gap:"28px"}},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",position:"relative",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",textAlign:"center",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",flex:1,minHeight:"300px"},children:[s&&r.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:r.jsx(qn,{size:20,style:{color:n?"#ffffff":"#000000"}})}),r.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[r.jsx("img",{src:y.avatarUrl||`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(y.name)}`,alt:`Profile avatar of ${y.name}`,style:{width:"128px",height:"128px",borderRadius:"50%",objectFit:"cover",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.3)",border:`3px solid ${L.border}`},width:128,height:128,loading:"eager"}),r.jsx("button",{onClick:()=>M(!0),style:{position:"absolute",bottom:"8px",right:"8px",backgroundColor:L.accent,color:"white",padding:"8px",borderRadius:"50%",border:"none",cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px"},"aria-label":"Change profile picture",children:r.jsx(tt,{size:16,"aria-hidden":"true"})})]}),r.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),r.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),r.jsxs("div",{style:{backgroundColor:y.isVerified?n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":n?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":n?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`,padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"6px",marginTop:"8px"},children:[y.isVerified?r.jsx(de,{size:16,"aria-hidden":"true"}):r.jsx(ae,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),r.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>A(!1),style:{backgroundColor:L.surfaceLight,border:`1px solid ${L.border}`,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",borderStyle:"solid",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[r.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),r.jsxs("button",{onClick:lt,disabled:P,style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,opacity:P?.7:1,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:P?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[P?r.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):r.jsx(Xn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>A(!0),style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[r.jsx(Kn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&r.jsxs("button",{onClick:()=>F(!0),disabled:R,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:R?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:R?.7:1,flex:u&&window.innerWidth<1024?"1":"auto"},children:[R?r.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):r.jsx(at,{size:14,"aria-hidden":"true"}),R?"Sending...":"Verify Email"]}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("button",{style:{backgroundColor:L.surfaceLight,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",width:"100%",boxSizing:"border-box"},onClick:()=>Z(!Y),children:[r.jsx(Bn,{size:16,"aria-hidden":"true"}),"More Actions"]}),Y&&r.jsxs("div",{className:`dropdown-container ${I?"closing":""}`,style:{position:"absolute",bottom:"100%",left:0,right:0,backgroundColor:L.surface,border:`1px solid ${L.border}`,borderRadius:"12px 12px 0 0",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.25)",zIndex:200,marginBottom:"6px",overflow:"hidden",animation:`${I?"drawerSlideDown":"drawerSlideUp"} 0.25s ease-out forwards`},children:[r.jsxs("button",{onClick:()=>{O(!0),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:L.textPrimary,cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>C.currentTarget.style.backgroundColor=L.surfaceLight,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&r.jsxs("button",{onClick:()=>{o(),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:n?"#fca5a5":"#dc2626",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),r.jsxs("button",{onClick:()=>{U(!0),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:"#ef4444",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:600,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),r.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[r.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),r.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...u&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const V=C.icon;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[r.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(V,{size:16,"aria-hidden":"true"}),C.label]}),m?r.jsx("input",{type:C.type,name:C.name,value:y[C.name],onChange:G=>S(ge=>ge&&{...ge,[G.target.name]:G.target.value}),style:{padding:"12px",borderRadius:"8px",border:`1px solid ${i}`,backgroundColor:"transparent",color:L.textPrimary,fontSize:"12px",outline:"none",transition:"border-color 0.2s ease",minHeight:"44px",width:"100%",boxSizing:"border-box"},placeholder:`Enter ${C.label.toLowerCase()}`,"aria-label":C.label}):r.jsx("div",{style:{padding:"12px",borderRadius:"8px",border:"1px solid transparent",fontSize:"12px",minHeight:"44px",display:"flex",alignItems:"center",boxSizing:"border-box",color:L.textPrimary,backgroundColor:n?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[r.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(nr,{size:20,"aria-hidden":"true"}),"Security Status"]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[r.jsx(ce,{size:16,"aria-hidden":"true"}),r.jsx("span",{children:"Email Verification"})]}),r.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:n?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${n?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?r.jsxs(r.Fragment,{children:[r.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):r.jsxs(r.Fragment,{children:[r.jsx(ae,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&r.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:n?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:r.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),r.jsx(is,{isOpen:T,onClose:()=>{M(!1)},onUpdate:Oe,colors:L}),r.jsx(as,{baseUrl:l,apiKey:x,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>z("success",C),onError:C=>z("error",C),colors:L}),r.jsx(os,{baseUrl:l,apiKey:x,appId:d,userId:y.id,token:e,isOpen:v,onClose:()=>U(!1),onSuccess:C=>z("success",C),onError:C=>z("error",C),colors:L}),r.jsx(ls,{isOpen:q,onClose:()=>{F(!1),N(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:pe,onSendOTP:le,verifyFormData:J,setVerifyFormData:f,otpSent:k,verifying:h,user:y,colors:L,darkMode:n}),r.jsx("style",{children:`
|
|
494
|
+
`})]})},ds=({token:e,user:t=null,darkMode:n=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:x,appId:d}=ue(),[u,b]=w.useState(null),[y,S]=w.useState(t),[c,j]=w.useState(!0),[m,A]=w.useState(!1),[P,$]=w.useState(!1),[T,F]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(!1),[q,M]=w.useState(!1),[K,Z]=w.useState(!1),[I,X]=w.useState(!1),[V,z]=w.useState(null),[R,ne]=w.useState(!1),[J,f]=w.useState({email:"",otp:"",appId:d}),[k,N]=w.useState(!1),[h,E]=w.useState(!1);w.useEffect(()=>{if(typeof window<"u"){const C=()=>b(window.innerWidth);return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)}},[]);const _=(C,Y)=>{z({type:C,message:Y}),setTimeout(()=>z(null),3e3)},B=()=>{X(!0);const C=setTimeout(()=>{Z(!1),X(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=Y=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(Y.target)&&B()};return K&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[K]);const le=async()=>{if(!J.email||!/\S+@\S+\.\S+/.test(J.email)){_("error","Please enter a valid email");return}try{E(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:J.email},{headers:{"x-api-key":x,"x-app-id":d}});C.data.success?(_("success",C.data.message||"OTP sent to email!"),N(!0)):_("error",C.data.message||"Failed to send OTP")}catch(C){_("error",C.response?.data?.message||"Server error")}finally{E(!1)}},pe=async C=>{if(C.preventDefault(),!J.email||!J.otp){_("error","Please fill in all fields");return}try{E(!0);const Y=await W.post(`${l}/users/verify-email`,J);if(Y.data.success){if(_("success",Y.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:e})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),N(!1),M(!1)}else _("error",Y.data.message||"Verification failed")}catch(Y){_("error",Y.response?.data?.message||"Something went wrong")}finally{E(!1)}},Oe=async C=>{if(!y)return!1;try{const Y={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,Y,{headers:{"x-api-key":x}});return G.success?(S(Y),localStorage.setItem("userInfo",JSON.stringify({...Y,token:e})),_("success","Avatar updated successfully!"),!0):(_("error",G.message||"Failed to update avatar"),!1)}catch(Y){return console.error("Avatar update error:",Y),_("error","Failed to update avatar"),!1}},lt=async()=>{if(y){$(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":x}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:e})),_("success","Profile updated successfully")):_("error",C.message)}catch(C){console.error(C),_("error","Update failed")}finally{$(!1)}}},or=async C=>{try{const{data:Y}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":x}});Y?.success===!0&&Y?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(Y){console.error("⚠️ User validation request failed:",Y)}};w.useEffect(()=>{(()=>{if(t)S(t),j(!1),or(t.id);else{const Y=localStorage.getItem("userInfo");if(Y){const G=JSON.parse(Y);S(G),j(!1),or(G.id)}else j(!1)}})()},[t]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const ir=(C,Y)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+Y,dt=(G>>8&255)+Y,ct=(G&255)+Y;return ge=Math.min(255,Math.max(0,ge)),dt=Math.min(255,Math.max(0,dt)),ct=Math.min(255,Math.max(0,ct)),`#${(ct|dt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=n?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:ir(i,-15),success:"#10b981",error:"#ef4444",border:"#27272a",warning:"#f59e0b"}:{background:"#ffffff",surface:"#fafafa",surfaceLight:"#f4f4f5",surfaceLighter:"#e4e4e7",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",accent:i,accentHover:ir(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(c)return r.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[r.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),r.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return r.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[r.jsx(ae,{size:40,color:L.error,"aria-hidden":"true"}),r.jsx("p",{style:{color:L.textTertiary,margin:0},children:"No profile found. Please log in again."})]})});const ps=[{label:"Full Name",value:y.name,name:"name",type:"text",icon:Se},{label:"Email Address",value:y.email,name:"email",type:"email",icon:ce},{label:"Phone Number",value:y.phone||"Not set",name:"phone",type:"tel",icon:Jn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Yn}];return r.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",lineHeight:1.5,minHeight:"80vh"},children:[V&&r.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",padding:"12px 24px",borderRadius:"12px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"blur(8px)",border:"1px solid",zIndex:1e3,display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontWeight:500,maxWidth:"400px",animation:"slideIn 0.3s ease-out",...V.type==="success"?{backgroundColor:n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:n?"#34d399":"#059669"}:{backgroundColor:n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:n?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:n?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[V.type==="success"?r.jsx(de,{size:20,"aria-hidden":"true"}):r.jsx(ae,{size:20,"aria-hidden":"true"}),V.message]}),r.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:r.jsxs("div",{style:{display:"grid",gap:"24px",gridTemplateColumns:"1fr",...u&&window.innerWidth>=1024&&{gridTemplateColumns:"1fr 2fr",gap:"10px"},...u&&window.innerWidth>=768&&u&&window.innerWidth<1024&&{gap:"10px"},...u&&window.innerWidth>=600&&u&&window.innerWidth<768&&{gap:"28px"}},children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",position:"relative",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",textAlign:"center",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",flex:1,minHeight:"300px"},children:[s&&r.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:r.jsx(qn,{size:20,style:{color:n?"#ffffff":"#000000"}})}),r.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[r.jsx("img",{src:y.avatarUrl||`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(y.name)}`,alt:`Profile avatar of ${y.name}`,style:{width:"128px",height:"128px",borderRadius:"50%",objectFit:"cover",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.3)",border:`3px solid ${L.border}`},width:128,height:128,loading:"eager"}),r.jsx("button",{onClick:()=>F(!0),style:{position:"absolute",bottom:"8px",right:"8px",backgroundColor:L.accent,color:"white",padding:"8px",borderRadius:"50%",border:"none",cursor:"pointer",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px"},"aria-label":"Change profile picture",children:r.jsx(tt,{size:16,"aria-hidden":"true"})})]}),r.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),r.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),r.jsxs("div",{style:{backgroundColor:y.isVerified?n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":n?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":n?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`,padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"6px",marginTop:"8px"},children:[y.isVerified?r.jsx(de,{size:16,"aria-hidden":"true"}):r.jsx(ae,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),r.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>A(!1),style:{backgroundColor:L.surfaceLight,border:`1px solid ${L.border}`,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",borderStyle:"solid",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[r.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),r.jsxs("button",{onClick:lt,disabled:P,style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,opacity:P?.7:1,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:P?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[P?r.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):r.jsx(Xn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>A(!0),style:{background:`linear-gradient(to right, ${L.accent}, ${L.accentHover})`,color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",flex:u&&window.innerWidth<1024?"1":"auto"},children:[r.jsx(Kn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&r.jsxs("button",{onClick:()=>M(!0),disabled:R,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:R?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:R?.7:1,flex:u&&window.innerWidth<1024?"1":"auto"},children:[R?r.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):r.jsx(at,{size:14,"aria-hidden":"true"}),R?"Sending...":"Verify Email"]}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("button",{style:{backgroundColor:L.surfaceLight,color:L.textPrimary,padding:"10px 20px",borderRadius:"6px",border:"none",cursor:"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",textDecoration:"none",minHeight:"36px",width:"100%",boxSizing:"border-box"},onClick:()=>Z(!K),children:[r.jsx(Bn,{size:16,"aria-hidden":"true"}),"More Actions"]}),K&&r.jsxs("div",{className:`dropdown-container ${I?"closing":""}`,style:{position:"absolute",bottom:"100%",left:0,right:0,backgroundColor:L.surface,border:`1px solid ${L.border}`,borderRadius:"12px 12px 0 0",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.25)",zIndex:200,marginBottom:"6px",overflow:"hidden",animation:`${I?"drawerSlideDown":"drawerSlideUp"} 0.25s ease-out forwards`},children:[r.jsxs("button",{onClick:()=>{O(!0),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:L.textPrimary,cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>C.currentTarget.style.backgroundColor=L.surfaceLight,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&r.jsxs("button",{onClick:()=>{o(),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:n?"#fca5a5":"#dc2626",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),r.jsxs("button",{onClick:()=>{U(!0),B()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:"#ef4444",cursor:"pointer",transition:"all 0.2s ease",fontSize:"13px",fontWeight:600,display:"flex",alignItems:"center",gap:"8px",textAlign:"left"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=n?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[r.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),r.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[r.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),r.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...u&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const Y=C.icon;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[r.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(Y,{size:16,"aria-hidden":"true"}),C.label]}),m?r.jsx("input",{type:C.type,name:C.name,value:y[C.name],onChange:G=>S(ge=>ge&&{...ge,[G.target.name]:G.target.value}),style:{padding:"12px",borderRadius:"8px",border:`1px solid ${i}`,backgroundColor:"transparent",color:L.textPrimary,fontSize:"12px",outline:"none",transition:"border-color 0.2s ease",minHeight:"44px",width:"100%",boxSizing:"border-box"},placeholder:`Enter ${C.label.toLowerCase()}`,"aria-label":C.label}):r.jsx("div",{style:{padding:"12px",borderRadius:"8px",border:"1px solid transparent",fontSize:"12px",minHeight:"44px",display:"flex",alignItems:"center",boxSizing:"border-box",color:L.textPrimary,backgroundColor:n?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),r.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[r.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(nr,{size:20,"aria-hidden":"true"}),"Security Status"]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[r.jsx(ce,{size:16,"aria-hidden":"true"}),r.jsx("span",{children:"Email Verification"})]}),r.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:n?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${n?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:n?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${n?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?r.jsxs(r.Fragment,{children:[r.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):r.jsxs(r.Fragment,{children:[r.jsx(ae,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&r.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:n?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:r.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),r.jsx(is,{isOpen:T,onClose:()=>{F(!1)},onUpdate:Oe,colors:L}),r.jsx(as,{baseUrl:l,apiKey:x,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>_("success",C),onError:C=>_("error",C),colors:L}),r.jsx(os,{baseUrl:l,apiKey:x,appId:d,userId:y.id,token:e,isOpen:v,onClose:()=>U(!1),onSuccess:C=>_("success",C),onError:C=>_("error",C),colors:L}),r.jsx(ls,{isOpen:q,onClose:()=>{M(!1),N(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:pe,onSendOTP:le,verifyFormData:J,setVerifyFormData:f,otpSent:k,verifying:h,user:y,colors:L,darkMode:n}),r.jsx("style",{children:`
|
|
495
495
|
@keyframes slideIn {
|
|
496
496
|
from {
|
|
497
497
|
transform: translateX(100%);
|
|
@@ -579,4 +579,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
579
579
|
transition-duration: 0.01ms !important;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
`})]})},cs=({darkMode:e=!0,primaryColor:t="#3b82f6",onLogout:n,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:x=!0,showSettingsMenuItem:d=!0,showViewProfileMenuItem:u=!0,profileLabel:b="My Profile",settingsLabel:y="Settings",viewProfileLabel:S="View Profile",logoutLabel:c="Sign Out"})=>{const{baseUrl:j,apiKey:m,appId:A}=ue(),[P,$]=w.useState(!1),[T,M]=w.useState(null),[g,O]=w.useState(!0),[v,U]=w.useState(null),q=w.useRef(null),F=w.useRef(null),[Y,Z]=w.useState(!1),[I,X]=w.useState(!1),K=async h=>{try{if(!h)throw new Error("Invalid user ID");const{data:E}=await W.get(`${j}/users/check-user/${h}?appId=${A}`,{headers:{"x-api-key":m},timeout:1e4});(!E.success||!E.exists)&&(console.warn("User not found, clearing session..."),localStorage.removeItem("userInfo"),M(null),U("Session expired"))}catch(E){console.error("User validation failed:",E);const z=E.response?.status===404?"User not found":E.code==="NETWORK_ERROR"?"Network error":"Validation failed";U(z),E.response?.status===404&&(localStorage.removeItem("userInfo"),M(null))}};w.useEffect(()=>{if(typeof window>"u")return;const h=()=>{X(window.innerWidth<768)};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),w.useEffect(()=>{(async()=>{try{if(O(!0),U(null),o){if(!o.id||!o.name||!o.email)throw new Error("Invalid user data provided");M(o),await K(o.id)}else if(typeof window<"u"){const E=localStorage.getItem("userInfo");if(E)try{const z=JSON.parse(E);if(!z.id||!z.name||!z.email)throw new Error("Invalid stored user data");M(z),await K(z.id)}catch(z){console.error("Failed to parse stored user data:",z),localStorage.removeItem("userInfo"),U("Invalid user data")}}}catch(E){console.error("User initialization failed:",E),U(E.message||"Failed to load user")}finally{O(!1)}})()},[o]),w.useEffect(()=>{if(typeof window>"u")return;const h=()=>{if(!P||!F.current)return;const E=F.current.getBoundingClientRect(),z=window.innerWidth,B=window.innerHeight,le=280,pe=z-E.right,Oe=E.left;B-E.bottom;const lt=pe>=le||pe>Oe;Z(lt)};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const h=B=>{q.current&&!q.current.contains(B.target)&&!F.current?.contains(B.target)&&$(!1)},E=B=>{B.key==="Escape"&&$(!1)},z=()=>{P&&$(!1)};return P&&(document.addEventListener("mousedown",h),document.addEventListener("keydown",E),window.addEventListener("scroll",z)),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",E),window.removeEventListener("scroll",z)}},[P]);const _=e?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:t,accentHover:`${t}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:t,accentHover:`${t}e6`,error:"#ef4444"},R={wrapper:{position:"relative",display:"inline-block"},avatarButton:{display:"flex",alignItems:"center",gap:I?"6px":"8px",padding:I?"6px 10px 6px 6px":"8px 12px 8px 8px",borderRadius:"24px",backgroundColor:_.surface,cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",minWidth:I?"auto":"140px",maxWidth:I?"200px":"none",outline:"none"},avatarImage:{width:I?"28px":"32px",height:I?"28px":"32px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${_.borderLight}`,flexShrink:0},userInfo:{display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1,minWidth:0,overflow:"hidden"},userName:{fontSize:I?"13px":"14px",fontWeight:600,color:_.textPrimary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},userEmail:{fontSize:I?"11px":"12px",color:_.textTertiary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},chevron:{transition:"transform 0.2s ease",transform:P?"rotate(180deg)":"rotate(0deg)",color:_.textTertiary,flexShrink:0},dropdown:{position:"absolute",top:"100%",marginTop:"8px",[Y?"left":"right"]:"0",backgroundColor:_.surfaceElevated,border:`1px solid ${_.border}`,borderRadius:"12px",boxShadow:"0 20px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1)",width:"min(280px, 90vw)",maxWidth:"calc(100vw - 20px)",padding:"6px 6px 16px 6px",zIndex:1e3,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",opacity:P?1:0,pointerEvents:P?"auto":"none",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",transform:P?"translateY(0) scale(1)":"translateY(-8px) scale(0.95)",overflow:"hidden"},dropdownSection:{padding:I?"10px 12px":"0px 16px","&:last-child":{borderBottom:"none"}},userSection:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"14px":"16px"},dropdownAvatar:{width:I?"40px":"48px",height:I?"40px":"48px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${_.borderLight}`,flexShrink:0},dropdownUserInfo:{display:"flex",flexDirection:"column",flex:1,minWidth:0},dropdownUserName:{fontSize:I?"15px":"16px",fontWeight:600,color:_.textPrimary,lineHeight:"1.2",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis"},dropdownUserEmail:{fontSize:I?"13px":"14px",color:_.textSecondary,lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis"},menuItem:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",color:_.textPrimary,textDecoration:"none",border:"none",background:"none",width:"100%",fontSize:I?"13px":"14px",textAlign:"left",outline:"none"},menuItemText:{flex:1},icon:{width:I?"16px":"18px",height:I?"16px":"18px",color:_.textSecondary,flexShrink:0},logoutButton:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",background:"none",border:"none",width:"100%",fontSize:I?"13px":"14px",color:_.error,textAlign:"left",outline:"none"},loadingText:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:_.textSecondary,fontSize:I?"13px":"14px"},errorState:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:_.textSecondary,fontSize:I?"13px":"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",flexDirection:"column"},retryButton:{marginTop:"8px",padding:"8px 16px",backgroundColor:_.accent,color:"#ffffff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:500,transition:"background-color 0.2s ease"}},ne=()=>{U(null),O(!0);const h=localStorage.getItem("userInfo");if(h)try{const E=JSON.parse(h);M(E),K(E.id)}catch{U("Invalid user data")}O(!1)},J=(h,E)=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),E())},f=()=>i||T?.profileUrl,k=()=>{const h=f();h&&window.open(h,"_self","noopener,noreferrer")},N=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return r.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?r.jsx("div",{ref:F,onClick:()=>$(h=>!h),onKeyDown:h=>J(h,()=>$(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T?.name||"User"}'s avatar`,style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${_.borderLight}`,flexShrink:0},loading:"lazy",onError:h=>{const E=h.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):r.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`,alt:"Default user avatar",style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${_.borderLight}`,flexShrink:0},loading:"lazy"})}):r.jsxs("div",{ref:F,style:R.avatarButton,onClick:()=>$(h=>!h),onKeyDown:h=>J(h,()=>$(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.surfaceHover,h.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:h=>{h.currentTarget.style.backgroundColor=_.surface,h.currentTarget.style.boxShadow="none"},onBlur:h=>{h.currentTarget.style.outline="none"},children:[T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:h=>{const E=h.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):r.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&r.jsxs("div",{style:R.userInfo,children:[r.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&r.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),r.jsx(Mn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&r.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?r.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:h=>{const E=h.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):r.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`,alt:`${T.name}'s default avatar`,style:R.dropdownAvatar,loading:"lazy"}),r.jsxs("div",{style:R.dropdownUserInfo,children:[r.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),r.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),r.jsxs("div",{style:R.dropdownSection,children:[x&&f()&&r.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,k),role:"menuitem",tabIndex:0,children:[r.jsx(Se,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&r.jsxs("button",{style:R.menuItem,onClick:N,onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,N),role:"menuitem",tabIndex:0,children:[r.jsx(Gn,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:y})]}),u&&T.profileUrl&&r.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[r.jsx(ce,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:S})]})]}),r.jsx("div",{style:R.dropdownSection,children:r.jsxs("button",{style:R.logoutButton,onClick:n,onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,n),role:"menuitem",tabIndex:0,children:[r.jsx(it,{style:{...R.icon,color:_.error},"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:c})]})})]}):r.jsxs("div",{style:R.errorState,role:"alert",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(ae,{size:16,"aria-hidden":"true"}),r.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&r.jsx("button",{style:R.retryButton,onClick:ne,onMouseOver:h=>{h.currentTarget.style.backgroundColor=_.accentHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor=_.accent},children:"Try Again"})]})})]})},us=({user:e,darkMode:t=!0,primaryColor:n="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ue(),[l,x]=w.useState({email:e?.email||"",otp:"",appId:o}),[d,u]=w.useState(!1),[b,y]=w.useState(!1),[S,c]=w.useState(null),j=(g,O)=>{let v=parseInt(g.replace("#",""),16),U=(v>>16)+O,q=(v>>8&255)+O,F=(v&255)+O;return U=Math.min(255,Math.max(0,U)),q=Math.min(255,Math.max(0,q)),F=Math.min(255,Math.max(0,F)),`#${(F|q<<8|U<<16).toString(16).padStart(6,"0")}`},m=t?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:n,accentHover:j(n,-15),success:j(n,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:n,accentHover:j(n,-15),success:j(n,0),warning:"#d97706"};w.useEffect(()=>{e?.email&&x(g=>({...g,email:e.email}))},[e?.email]);const A=(g,O)=>{c({type:g,message:O}),setTimeout(()=>c(null),3e3)},P=async()=>{if(!l.email||!/\S+@\S+\.\S+/.test(l.email)){A("error","Please enter a valid email");return}try{y(!0);const g=await W.post(`${a}/users/send-verify-otp/${e?.id}`,{email:l.email},{headers:{"x-api-key":i,"x-app-id":o}});g.data.success?(A("success",g.data.message||"OTP sent!"),u(!0)):A("error",g.data.message||"Failed to send OTP")}catch(g){A("error",g.response?.data?.message||"Server error")}finally{y(!1)}},$=async g=>{if(g.preventDefault(),!l.email||!l.otp){A("error","Please fill in all fields");return}try{y(!0);const O=await W.post(`${a}/users/verify-email`,l);if(O.data.success&&e){const v={...e,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),u(!1),x({email:e.email,otp:"",appId:o})}else A("error",O.data.message||"Verification failed")}catch(O){A("error",O.response?.data?.message||"Server error")}finally{y(!1)}},T={width:"100%",padding:"12px 12px 12px 40px",borderRadius:8,border:`1px solid ${m.border}`,backgroundColor:m.surfaceLight,color:m.textPrimary,fontSize:14,outline:"none"},M=(g=!1)=>({flex:1,padding:12,borderRadius:8,color:"#fff",fontWeight:500,cursor:g?"not-allowed":"pointer",background:`linear-gradient(to right, ${m.accent}, ${m.accentHover})`,opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,fontSize:14,border:"none"});return r.jsxs("form",{onSubmit:$,style:{display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&r.jsxs("div",{style:{padding:"12px 20px",borderRadius:12,fontSize:13,fontWeight:500,color:S.type==="success"?m.success:m.warning,border:`1px solid ${S.type==="success"?m.success:m.warning}`,backgroundColor:S.type==="success"?`${m.success}20`:`${m.warning}20`,display:"flex",alignItems:"center",gap:8},children:[S.type==="success"?r.jsx(de,{size:16}):r.jsx(ae,{size:16}),S.message]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("label",{style:{color:m.textSecondary},children:"Email"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),r.jsx("input",{type:"email",value:l.email,onChange:g=>x(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),r.jsx("input",{type:"text",value:l.otp,onChange:g=>x(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),r.jsx("div",{style:{display:"flex",gap:12},children:d?r.jsxs("button",{type:"submit",disabled:b,style:M(b),children:[b?r.jsx(oe,{size:16,className:"spinner"}):r.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):r.jsxs("button",{type:"button",onClick:P,disabled:b,style:M(b),children:[b?r.jsx(oe,{size:16,className:"spinner"}):r.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=Rn,Q.ReactEmailVerification=us,Q.ReactSignedIn=ns,Q.ReactSignedOut=ss,Q.ReactUserButton=cs,Q.ReactUserLogin=rs,Q.ReactUserProfile=ds,Q.ReactUserSignUp=es,Q.getSdkConfig=ue,Q.setSdkConfig=Qn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
|
582
|
+
`})]})},cs=({darkMode:e=!0,primaryColor:t="#3b82f6",onLogout:n,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:x=!0,showSettingsMenuItem:d=!0,showViewProfileMenuItem:u=!0,profileLabel:b="My Profile",settingsLabel:y="Settings",viewProfileLabel:S="View Profile",logoutLabel:c="Sign Out"})=>{const{baseUrl:j,apiKey:m,appId:A}=ue(),[P,$]=w.useState(!1),[T,F]=w.useState(null),[g,O]=w.useState(!0),[v,U]=w.useState(null),q=w.useRef(null),M=w.useRef(null),[K,Z]=w.useState(!1),[I,X]=w.useState(!1),V=async h=>{try{const{data:E}=await W.get(`${j}/users/check-user/${h}?appId=${A}`,{headers:{"x-api-key":m}});E?.success===!0&&E?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),F(null))}catch(E){console.error("⚠️ User validation request failed:",E)}};w.useEffect(()=>{if(typeof window>"u")return;const h=()=>{X(window.innerWidth<768)};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),w.useEffect(()=>{(async()=>{try{if(O(!0),U(null),o){if(!o.id||!o.name||!o.email)throw new Error("Invalid user data provided");F(o),await V(o.id)}else if(typeof window<"u"){const E=localStorage.getItem("userInfo");if(E)try{const _=JSON.parse(E);if(!_.id||!_.name||!_.email)throw new Error("Invalid stored user data");F(_),await V(_.id)}catch(_){console.error("Failed to parse stored user data:",_),localStorage.removeItem("userInfo"),U("Invalid user data")}}}catch(E){console.error("User initialization failed:",E),U(E.message||"Failed to load user")}finally{O(!1)}})()},[o]),w.useEffect(()=>{if(typeof window>"u")return;const h=()=>{if(!P||!M.current)return;const E=M.current.getBoundingClientRect(),_=window.innerWidth,B=window.innerHeight,le=280,pe=_-E.right,Oe=E.left;B-E.bottom;const lt=pe>=le||pe>Oe;Z(lt)};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const h=B=>{q.current&&!q.current.contains(B.target)&&!M.current?.contains(B.target)&&$(!1)},E=B=>{B.key==="Escape"&&$(!1)},_=()=>{P&&$(!1)};return P&&(document.addEventListener("mousedown",h),document.addEventListener("keydown",E),window.addEventListener("scroll",_)),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",E),window.removeEventListener("scroll",_)}},[P]);const z=e?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:t,accentHover:`${t}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:t,accentHover:`${t}e6`,error:"#ef4444"},R={wrapper:{position:"relative",display:"inline-block"},avatarButton:{display:"flex",alignItems:"center",gap:I?"6px":"8px",padding:I?"6px 10px 6px 6px":"8px 12px 8px 8px",borderRadius:"24px",backgroundColor:z.surface,cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",minWidth:I?"auto":"140px",maxWidth:I?"200px":"none",outline:"none"},avatarImage:{width:I?"28px":"32px",height:I?"28px":"32px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},userInfo:{display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1,minWidth:0,overflow:"hidden"},userName:{fontSize:I?"13px":"14px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},userEmail:{fontSize:I?"11px":"12px",color:z.textTertiary,lineHeight:"1.2",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:I?"80px":"120px"},chevron:{transition:"transform 0.2s ease",transform:P?"rotate(180deg)":"rotate(0deg)",color:z.textTertiary,flexShrink:0},dropdown:{position:"absolute",top:"100%",marginTop:"8px",[K?"left":"right"]:"0",backgroundColor:z.surfaceElevated,border:`1px solid ${z.border}`,borderRadius:"12px",boxShadow:"0 20px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1)",width:"min(280px, 90vw)",maxWidth:"calc(100vw - 20px)",padding:"6px 6px 16px 6px",zIndex:1e3,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",opacity:P?1:0,pointerEvents:P?"auto":"none",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",transform:P?"translateY(0) scale(1)":"translateY(-8px) scale(0.95)",overflow:"hidden"},dropdownSection:{padding:I?"10px 12px":"0px 16px","&:last-child":{borderBottom:"none"}},userSection:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"14px":"16px"},dropdownAvatar:{width:I?"40px":"48px",height:I?"40px":"48px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},dropdownUserInfo:{display:"flex",flexDirection:"column",flex:1,minWidth:0},dropdownUserName:{fontSize:I?"15px":"16px",fontWeight:600,color:z.textPrimary,lineHeight:"1.2",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis"},dropdownUserEmail:{fontSize:I?"13px":"14px",color:z.textSecondary,lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis"},menuItem:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",color:z.textPrimary,textDecoration:"none",border:"none",background:"none",width:"100%",fontSize:I?"13px":"14px",textAlign:"left",outline:"none"},menuItemText:{flex:1},icon:{width:I?"16px":"18px",height:I?"16px":"18px",color:z.textSecondary,flexShrink:0},logoutButton:{display:"flex",alignItems:"center",gap:I?"10px":"12px",padding:I?"10px 12px":"12px 16px",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease",background:"none",border:"none",width:"100%",fontSize:I?"13px":"14px",color:z.error,textAlign:"left",outline:"none"},loadingText:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px"},errorState:{padding:I?"16px 12px":"20px 16px",textAlign:"center",color:z.textSecondary,fontSize:I?"13px":"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",flexDirection:"column"},retryButton:{marginTop:"8px",padding:"8px 16px",backgroundColor:z.accent,color:"#ffffff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:500,transition:"background-color 0.2s ease"}},ne=async()=>{U(null),O(!0);try{const h=localStorage.getItem("userInfo");if(h){const E=JSON.parse(h);F(E),await V(E.id)}else o&&(F(o),await V(o.id))}catch(h){console.error("Retry failed:",h),U("Invalid user data"),localStorage.removeItem("userInfo"),F(null)}finally{O(!1)}},J=(h,E)=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),E())},f=()=>i||T?.profileUrl,k=()=>{const h=f();h&&window.open(h,"_self","noopener,noreferrer")},N=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return r.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?r.jsx("div",{ref:M,onClick:()=>$(h=>!h),onKeyDown:h=>J(h,()=>$(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T?.name||"User"}'s avatar`,style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy",onError:h=>{const E=h.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):r.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`,alt:"Default user avatar",style:{width:I?"34px":"40px",height:I?"34px":"40px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy"})}):r.jsxs("div",{ref:M,style:R.avatarButton,onClick:()=>$(h=>!h),onKeyDown:h=>J(h,()=>$(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.surfaceHover,h.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:h=>{h.currentTarget.style.backgroundColor=z.surface,h.currentTarget.style.boxShadow="none"},onBlur:h=>{h.currentTarget.style.outline="none"},children:[T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:h=>{const E=h.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):r.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&r.jsxs("div",{style:R.userInfo,children:[r.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&r.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),r.jsx(Mn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&r.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?r.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?r.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:h=>{const E=h.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):r.jsx("img",{src:`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`,alt:`${T.name}'s default avatar`,style:R.dropdownAvatar,loading:"lazy"}),r.jsxs("div",{style:R.dropdownUserInfo,children:[r.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),r.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),r.jsxs("div",{style:R.dropdownSection,children:[x&&f()&&r.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,k),role:"menuitem",tabIndex:0,children:[r.jsx(Se,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&r.jsxs("button",{style:R.menuItem,onClick:N,onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,N),role:"menuitem",tabIndex:0,children:[r.jsx(Gn,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:y})]}),u&&T.profileUrl&&r.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[r.jsx(ce,{style:R.icon,"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:S})]})]}),r.jsx("div",{style:R.dropdownSection,children:r.jsxs("button",{style:R.logoutButton,onClick:n,onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent"},onKeyDown:h=>J(h,n),role:"menuitem",tabIndex:0,children:[r.jsx(it,{style:{...R.icon,color:z.error},"aria-hidden":"true"}),r.jsx("span",{style:R.menuItemText,children:c})]})})]}):r.jsxs("div",{style:R.errorState,role:"alert",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r.jsx(ae,{size:16,"aria-hidden":"true"}),r.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&r.jsx("button",{style:R.retryButton,onClick:ne,onMouseOver:h=>{h.currentTarget.style.backgroundColor=z.accentHover},onMouseOut:h=>{h.currentTarget.style.backgroundColor=z.accent},children:"Try Again"})]})})]})},us=({user:e,darkMode:t=!0,primaryColor:n="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ue(),[l,x]=w.useState({email:e?.email||"",otp:"",appId:o}),[d,u]=w.useState(!1),[b,y]=w.useState(!1),[S,c]=w.useState(null),j=(g,O)=>{let v=parseInt(g.replace("#",""),16),U=(v>>16)+O,q=(v>>8&255)+O,M=(v&255)+O;return U=Math.min(255,Math.max(0,U)),q=Math.min(255,Math.max(0,q)),M=Math.min(255,Math.max(0,M)),`#${(M|q<<8|U<<16).toString(16).padStart(6,"0")}`},m=t?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:n,accentHover:j(n,-15),success:j(n,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:n,accentHover:j(n,-15),success:j(n,0),warning:"#d97706"};w.useEffect(()=>{e?.email&&x(g=>({...g,email:e.email}))},[e?.email]);const A=(g,O)=>{c({type:g,message:O}),setTimeout(()=>c(null),3e3)},P=async()=>{if(!l.email||!/\S+@\S+\.\S+/.test(l.email)){A("error","Please enter a valid email");return}try{y(!0);const g=await W.post(`${a}/users/send-verify-otp/${e?.id}`,{email:l.email},{headers:{"x-api-key":i,"x-app-id":o}});g.data.success?(A("success",g.data.message||"OTP sent!"),u(!0)):A("error",g.data.message||"Failed to send OTP")}catch(g){A("error",g.response?.data?.message||"Server error")}finally{y(!1)}},$=async g=>{if(g.preventDefault(),!l.email||!l.otp){A("error","Please fill in all fields");return}try{y(!0);const O=await W.post(`${a}/users/verify-email`,l);if(O.data.success&&e){const v={...e,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),u(!1),x({email:e.email,otp:"",appId:o})}else A("error",O.data.message||"Verification failed")}catch(O){A("error",O.response?.data?.message||"Server error")}finally{y(!1)}},T={width:"100%",padding:"12px 12px 12px 40px",borderRadius:8,border:`1px solid ${m.border}`,backgroundColor:m.surfaceLight,color:m.textPrimary,fontSize:14,outline:"none"},F=(g=!1)=>({flex:1,padding:12,borderRadius:8,color:"#fff",fontWeight:500,cursor:g?"not-allowed":"pointer",background:`linear-gradient(to right, ${m.accent}, ${m.accentHover})`,opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,fontSize:14,border:"none"});return r.jsxs("form",{onSubmit:$,style:{display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&r.jsxs("div",{style:{padding:"12px 20px",borderRadius:12,fontSize:13,fontWeight:500,color:S.type==="success"?m.success:m.warning,border:`1px solid ${S.type==="success"?m.success:m.warning}`,backgroundColor:S.type==="success"?`${m.success}20`:`${m.warning}20`,display:"flex",alignItems:"center",gap:8},children:[S.type==="success"?r.jsx(de,{size:16}):r.jsx(ae,{size:16}),S.message]}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("label",{style:{color:m.textSecondary},children:"Email"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ce,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),r.jsx("input",{type:"email",value:l.email,onChange:g=>x(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),r.jsx("input",{type:"text",value:l.otp,onChange:g=>x(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),r.jsx("div",{style:{display:"flex",gap:12},children:d?r.jsxs("button",{type:"submit",disabled:b,style:F(b),children:[b?r.jsx(oe,{size:16,className:"spinner"}):r.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):r.jsxs("button",{type:"button",onClick:P,disabled:b,style:F(b),children:[b?r.jsx(oe,{size:16,className:"spinner"}):r.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=Rn,Q.ReactEmailVerification=us,Q.ReactSignedIn=ns,Q.ReactSignedOut=ss,Q.ReactUserButton=cs,Q.ReactUserLogin=rs,Q.ReactUserProfile=ds,Q.ReactUserSignUp=es,Q.getSdkConfig=ue,Q.setSdkConfig=Qn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|