@neuctra/authix 1.1.25 → 1.1.27
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,9 +1,9 @@
|
|
|
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 ct(t,e){return function(){return t.apply(e,arguments)}}const{toString:ar}=Object.prototype,{getPrototypeOf:Be}=Object,{iterator:Re,toStringTag:ut}=Symbol,ze=(t=>e=>{const r=ar.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),se=t=>(t=t.toLowerCase(),e=>ze(e)===t),_e=t=>e=>typeof e===t,{isArray:me}=Array,ye=_e("undefined");function je(t){return t!==null&&!ye(t)&&t.constructor!==null&&!ye(t.constructor)&&re(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const pt=se("ArrayBuffer");function lr(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&pt(t.buffer),e}const dr=_e("string"),re=_e("function"),ft=_e("number"),ve=t=>t!==null&&typeof t=="object",cr=t=>t===!0||t===!1,Ae=t=>{if(ze(t)!=="object")return!1;const e=Be(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ut in t)&&!(Re in t)},ur=t=>{if(!ve(t)||je(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},pr=se("Date"),fr=se("File"),xr=se("Blob"),hr=se("FileList"),gr=t=>ve(t)&&re(t.pipe),mr=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||re(t.append)&&((e=ze(t))==="formdata"||e==="object"&&re(t.toString)&&t.toString()==="[object FormData]"))},yr=se("URLSearchParams"),[br,wr,Sr,jr]=["ReadableStream","Request","Response","Headers"].map(se),vr=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ke(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let s,o;if(typeof t!="object"&&(t=[t]),me(t))for(s=0,o=t.length;s<o;s++)e.call(null,t[s],s,t);else{if(je(t))return;const a=r?Object.getOwnPropertyNames(t):Object.keys(t),i=a.length;let l;for(s=0;s<i;s++)l=a[s],e.call(null,t[l],l,t)}}function xt(t,e){if(je(t))return null;e=e.toLowerCase();const r=Object.keys(t);let s=r.length,o;for(;s-- >0;)if(o=r[s],e===o.toLowerCase())return o;return null}const pe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ht=t=>!ye(t)&&t!==pe;function He(){const{caseless:t,skipUndefined:e}=ht(this)&&this||{},r={},s=(o,a)=>{const i=t&&xt(r,a)||a;Ae(r[i])&&Ae(o)?r[i]=He(r[i],o):Ae(o)?r[i]=He({},o):me(o)?r[i]=o.slice():(!e||!ye(o))&&(r[i]=o)};for(let o=0,a=arguments.length;o<a;o++)arguments[o]&&ke(arguments[o],s);return r}const kr=(t,e,r,{allOwnKeys:s}={})=>(ke(e,(o,a)=>{r&&re(o)?t[a]=ct(o,r):t[a]=o},{allOwnKeys:s}),t),Er=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Cr=(t,e,r,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},Tr=(t,e,r,s)=>{let o,a,i;const l={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),a=o.length;a-- >0;)i=o[a],(!s||s(i,t,e))&&!l[i]&&(e[i]=t[i],l[i]=!0);t=r!==!1&&Be(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},Ir=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const s=t.indexOf(e,r);return s!==-1&&s===r},Pr=t=>{if(!t)return null;if(me(t))return t;let e=t.length;if(!ft(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},Or=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Be(Uint8Array)),Rr=(t,e)=>{const s=(t&&t[Re]).call(t);let o;for(;(o=s.next())&&!o.done;){const a=o.value;e.call(t,a[0],a[1])}},zr=(t,e)=>{let r;const s=[];for(;(r=t.exec(e))!==null;)s.push(r);return s},_r=se("HTMLFormElement"),Ar=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,o){return s.toUpperCase()+o}),gt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),$r=se("RegExp"),mt=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),s={};ke(r,(o,a)=>{let i;(i=e(o,a,t))!==!1&&(s[a]=i||o)}),Object.defineProperties(t,s)},Nr=t=>{mt(t,(e,r)=>{if(re(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=t[r];if(re(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Ur=(t,e)=>{const r={},s=o=>{o.forEach(a=>{r[a]=!0})};return me(t)?s(t):s(String(t).split(e)),r},Dr=()=>{},Lr=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Fr(t){return!!(t&&re(t.append)&&t[ut]==="FormData"&&t[Re])}const Mr=t=>{const e=new Array(10),r=(s,o)=>{if(ve(s)){if(e.indexOf(s)>=0)return;if(je(s))return s;if(!("toJSON"in s)){e[o]=s;const a=me(s)?[]:{};return ke(s,(i,l)=>{const h=r(i,o+1);!ye(h)&&(a[l]=h)}),e[o]=void 0,a}}return s};return r(t,0)},Wr=se("AsyncFunction"),qr=t=>t&&(ve(t)||re(t))&&re(t.then)&&re(t.catch),yt=((t,e)=>t?setImmediate:e?((r,s)=>(pe.addEventListener("message",({source:o,data:a})=>{o===pe&&a===r&&s.length&&s.shift()()},!1),o=>{s.push(o),pe.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",re(pe.postMessage)),Br=typeof queueMicrotask<"u"?queueMicrotask.bind(pe):typeof process<"u"&&process.nextTick||yt,p={isArray:me,isArrayBuffer:pt,isBuffer:je,isFormData:mr,isArrayBufferView:lr,isString:dr,isNumber:ft,isBoolean:cr,isObject:ve,isPlainObject:Ae,isEmptyObject:ur,isReadableStream:br,isRequest:wr,isResponse:Sr,isHeaders:jr,isUndefined:ye,isDate:pr,isFile:fr,isBlob:xr,isRegExp:$r,isFunction:re,isStream:gr,isURLSearchParams:yr,isTypedArray:Or,isFileList:hr,forEach:ke,merge:He,extend:kr,trim:vr,stripBOM:Er,inherits:Cr,toFlatObject:Tr,kindOf:ze,kindOfTest:se,endsWith:Ir,toArray:Pr,forEachEntry:Rr,matchAll:zr,isHTMLForm:_r,hasOwnProperty:gt,hasOwnProp:gt,reduceDescriptors:mt,freezeMethods:Nr,toObjectSet:Ur,toCamelCase:Ar,noop:Dr,toFiniteNumber:Lr,findKey:xt,global:pe,isContextDefined:ht,isSpecCompliantForm:Fr,toJSONObject:Mr,isAsyncFn:Wr,isThenable:qr,setImmediate:yt,asap:Br,isIterable:t=>t!=null&&re(t[Re])};function D(t,e,r,s,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),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 bt=D.prototype,wt={};["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(t=>{wt[t]={value:t}}),Object.defineProperties(D,wt),Object.defineProperty(bt,"isAxiosError",{value:!0}),D.from=(t,e,r,s,o,a)=>{const i=Object.create(bt);p.toFlatObject(t,i,function(u){return u!==Error.prototype},d=>d!=="isAxiosError");const l=t&&t.message?t.message:"Error",h=e==null&&t?t.code:e;return D.call(i,l,h,r,s,o),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",a&&Object.assign(i,a),i};const Hr=null;function Ve(t){return p.isPlainObject(t)||p.isArray(t)}function St(t){return p.endsWith(t,"[]")?t.slice(0,-2):t}function jt(t,e,r){return t?t.concat(e).map(function(o,a){return o=St(o),!r&&a?"["+o+"]":o}).join(r?".":""):e}function Vr(t){return p.isArray(t)&&!t.some(Ve)}const Yr=p.toFlatObject(p,{},null,function(e){return/^is[A-Z]/.test(e)});function $e(t,e,r){if(!p.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=p.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,m){return!p.isUndefined(m[j])});const s=r.metaTokens,o=r.visitor||u,a=r.dots,i=r.indexes,h=(r.Blob||typeof Blob<"u"&&Blob)&&p.isSpecCompliantForm(e);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(!h&&p.isBlob(c))throw new D("Blob is not supported. Use a Buffer instead.");return p.isArrayBuffer(c)||p.isTypedArray(c)?h&&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)&&Vr(c)||(p.isFileList(c)||p.endsWith(j,"[]"))&&(A=p.toArray(c)))return j=St(j),A.forEach(function(_,T){!(p.isUndefined(_)||_===null)&&e.append(i===!0?jt([j],T,a):i===null?j:j+"[]",d(_))}),!1}return Ve(c)?!0:(e.append(jt(m,j,a),d(c)),!1)}const b=[],y=Object.assign(Yr,{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(e,A,p.isString(P)?P.trim():P,j,y))===!0&&S(A,j?j.concat(P):[P])}),b.pop()}}if(!p.isObject(t))throw new TypeError("data must be an object");return S(t),e}function vt(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Ye(t,e){this._pairs=[],t&&$e(t,this,e)}const kt=Ye.prototype;kt.append=function(e,r){this._pairs.push([e,r])},kt.toString=function(e){const r=e?function(s){return e.call(this,s,vt)}:vt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function Kr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Et(t,e,r){if(!e)return t;const s=r&&r.encode||Kr;p.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let a;if(o?a=o(e,r):a=p.isURLSearchParams(e)?e.toString():new Ye(e,r).toString(s),a){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class Ct{constructor(){this.handlers=[]}use(e,r,s){return this.handlers.push({fulfilled:e,rejected:r,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){p.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jr={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,Xr=Ke&&(!Je||["ReactNative","NativeScript","NS"].indexOf(Je.product)<0),Gr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zr=Ke&&window.location.href||"http://localhost",ee={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ke,hasStandardBrowserEnv:Xr,hasStandardBrowserWebWorkerEnv:Gr,navigator:Je,origin:Zr},Symbol.toStringTag,{value:"Module"})),...Jr};function Qr(t,e){return $e(t,new ee.classes.URLSearchParams,{visitor:function(r,s,o,a){return ee.isNode&&p.isBuffer(r)?(this.append(s,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function en(t){return p.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function tn(t){const e={},r=Object.keys(t);let s;const o=r.length;let a;for(s=0;s<o;s++)a=r[s],e[a]=t[a];return e}function It(t){function e(r,s,o,a){let i=r[a++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),h=a>=r.length;return i=!i&&p.isArray(o)?o.length:i,h?(p.hasOwnProp(o,i)?o[i]=[o[i],s]:o[i]=s,!l):((!o[i]||!p.isObject(o[i]))&&(o[i]=[]),e(r,s,o[i],a)&&p.isArray(o[i])&&(o[i]=tn(o[i])),!l)}if(p.isFormData(t)&&p.isFunction(t.entries)){const r={};return p.forEachEntry(t,(s,o)=>{e(en(s),o,r,0)}),r}return null}function rn(t,e,r){if(p.isString(t))try{return(e||JSON.parse)(t),p.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(t)}const Ee={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const s=r.getContentType()||"",o=s.indexOf("application/json")>-1,a=p.isObject(e);if(a&&p.isHTMLForm(e)&&(e=new FormData(e)),p.isFormData(e))return o?JSON.stringify(It(e)):e;if(p.isArrayBuffer(e)||p.isBuffer(e)||p.isStream(e)||p.isFile(e)||p.isBlob(e)||p.isReadableStream(e))return e;if(p.isArrayBufferView(e))return e.buffer;if(p.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(a){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Qr(e,this.formSerializer).toString();if((l=p.isFileList(e))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return $e(l?{"files[]":e}:e,h&&new h,this.formSerializer)}}return a||o?(r.setContentType("application/json",!1),rn(e)):e}],transformResponse:[function(e){const r=this.transitional||Ee.transitional,s=r&&r.forcedJSONParsing,o=this.responseType==="json";if(p.isResponse(e)||p.isReadableStream(e))return e;if(e&&p.isString(e)&&(s&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?D.from(l,D.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ee.classes.FormData,Blob:ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};p.forEach(["delete","get","head","post","put","patch"],t=>{Ee.headers[t]={}});const nn=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"]),sn=t=>{const e={};let r,s,o;return t&&t.split(`
|
|
2
|
-
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),s=i.substring(o+1).trim(),!(!r||e[r]&&nn[r])&&(r==="set-cookie"?e[r]?e[r].push(s):e[r]=[s]:e[r]=e[r]?e[r]+", "+s:s)}),e},Pt=Symbol("internals");function Ce(t){return t&&String(t).trim().toLowerCase()}function Ne(t){return t===!1||t==null?t:p.isArray(t)?t.map(Ne):String(t)}function on(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=r.exec(t);)e[s[1]]=s[2];return e}const an=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Xe(t,e,r,s,o){if(p.isFunction(s))return s.call(this,e,r);if(o&&(e=r),!!p.isString(e)){if(p.isString(s))return e.indexOf(s)!==-1;if(p.isRegExp(s))return s.test(e)}}function ln(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,s)=>r.toUpperCase()+s)}function dn(t,e){const r=p.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+r,{value:function(o,a,i){return this[s].call(this,e,o,a,i)},configurable:!0})})}let ne=class{constructor(e){e&&this.set(e)}set(e,r,s){const o=this;function a(l,h,d){const
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const s=new this(e);return r.forEach(o=>s.set(o)),s}static accessor(e){const s=(this[Pt]=this[Pt]={accessors:{}}).accessors,o=this.prototype;function a(i){const l=Ce(i);s[l]||(dn(o,i),s[l]=!0)}return p.isArray(e)?e.forEach(a):a(e),this}};ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),p.reduceDescriptors(ne.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[r]=s}}}),p.freezeMethods(ne);function Ge(t,e){const r=this||Ee,s=e||r,o=ne.from(s.headers);let a=s.data;return p.forEach(t,function(l){a=l.call(r,a,o.normalize(),e?e.status:void 0)}),o.normalize(),a}function Ot(t){return!!(t&&t.__CANCEL__)}function be(t,e,r){D.call(this,t??"canceled",D.ERR_CANCELED,e,r),this.name="CanceledError"}p.inherits(be,D,{__CANCEL__:!0});function Rt(t,e,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?t(r):e(new D("Request failed with status code "+r.status,[D.ERR_BAD_REQUEST,D.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function cn(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function un(t,e){t=t||10;const r=new Array(t),s=new Array(t);let o=0,a=0,i;return e=e!==void 0?e:1e3,function(h){const d=Date.now(),u=s[a];i||(i=d),r[o]=h,s[o]=d;let b=a,y=0;for(;b!==o;)y+=r[b++],b=b%t;if(o=(o+1)%t,o===a&&(a=(a+1)%t),d-i<e)return;const S=u&&d-u;return S?Math.round(y*1e3/S):void 0}}function pn(t,e){let r=0,s=1e3/e,o,a;const i=(d,u=Date.now())=>{r=u,o=null,a&&(clearTimeout(a),a=null),t(...d)};return[(...d)=>{const u=Date.now(),b=u-r;b>=s?i(d,u):(o=d,a||(a=setTimeout(()=>{a=null,i(o)},s-b)))},()=>o&&i(o)]}const Ue=(t,e,r=3)=>{let s=0;const o=un(50,250);return pn(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,h=i-s,d=o(h),u=i<=l;s=i;const b={loaded:i,total:l,progress:l?i/l:void 0,bytes:h,rate:d||void 0,estimated:d&&l&&u?(l-i)/d:void 0,event:a,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(b)},r)},zt=(t,e)=>{const r=t!=null;return[s=>e[0]({lengthComputable:r,total:t,loaded:s}),e[1]]},_t=t=>(...e)=>p.asap(()=>t(...e)),fn=ee.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,ee.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,xn=ee.hasStandardBrowserEnv?{write(t,e,r,s,o,a){const i=[t+"="+encodeURIComponent(e)];p.isNumber(r)&&i.push("expires="+new Date(r).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(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function gn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function At(t,e,r){let s=!hn(e);return t&&(s||r==!1)?gn(t,e):e}const $t=t=>t instanceof ne?{...t}:t;function fe(t,e){e=e||{};const r={};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 e)return s(d,u);if(b in t)return s(void 0,d)}const h={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($t(d),$t(u),b,!0)};return p.forEach(Object.keys({...t,...e}),function(u){const b=h[u]||o,y=b(t[u],e[u],u);p.isUndefined(y)&&b!==l||(r[u]=y)}),r}const Nt=t=>{const e=fe({},t);let{data:r,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:l}=e;if(e.headers=i=ne.from(i),e.url=Et(At(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),p.isFormData(r)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(p.isFunction(r.getHeaders)){const h=r.getHeaders(),d=["content-type","content-length"];Object.entries(h).forEach(([u,b])=>{d.includes(u.toLowerCase())&&i.set(u,b)})}}if(ee.hasStandardBrowserEnv&&(s&&p.isFunction(s)&&(s=s(e)),s||s!==!1&&fn(e.url))){const h=o&&a&&xn.read(a);h&&i.set(o,h)}return e},mn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,s){const o=Nt(t);let a=o.data;const i=ne.from(o.headers).normalize();let{responseType:l,onUploadProgress:h,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 _=ne.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:t,request:m};Rt(function(O){r(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,t,m)),m=null)},m.onerror=function(T){const M=T&&T.message?T.message:"Network Error",g=new D(M,D.ERR_NETWORK,t,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||Tt;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),s(new D(T,M.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,t,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)),h&&m.upload&&([b,S]=Ue(h),m.upload.addEventListener("progress",b),m.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(u=_=>{m&&(s(!_||_.type?new be(null,t,m):_),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const P=cn(o.url);if(P&&ee.protocols.indexOf(P)===-1){s(new D("Unsupported protocol "+P+":",D.ERR_BAD_REQUEST,t));return}m.send(a||null)})},yn=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){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=e&&setTimeout(()=>{i=null,a(new D(`timeout ${e} of ms exceeded`,D.ETIMEDOUT))},e);const l=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),t=null)};t.forEach(d=>d.addEventListener("abort",a));const{signal:h}=s;return h.unsubscribe=()=>p.asap(l),h}},bn=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let s=0,o;for(;s<r;)o=s+e,yield t.slice(s,o),s=o},wn=async function*(t,e){for await(const r of Sn(t))yield*bn(r,e)},Sn=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:s}=await e.read();if(r)break;yield s}}finally{await e.cancel()}},Ut=(t,e,r,s)=>{const o=wn(t,e);let a=0,i,l=h=>{i||(i=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:d,value:u}=await o.next();if(d){l(),h.close();return}let b=u.byteLength;if(r){let y=a+=b;r(y)}h.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(h){return l(h),o.return()}},{highWaterMark:2})},Dt=64*1024,{isFunction:De}=p,jn=(({Request:t,Response:e})=>({Request:t,Response:e}))(p.global),{ReadableStream:Lt,TextEncoder:Ft}=p.global,Mt=(t,...e)=>{try{return!!t(...e)}catch{return!1}},vn=t=>{t=p.merge.call({skipUndefined:!0},jn,t);const{fetch:e,Request:r,Response:s}=t,o=e?De(e):typeof fetch=="function",a=De(r),i=De(s);if(!o)return!1;const l=o&&De(Lt),h=o&&(typeof Ft=="function"?(c=>j=>c.encode(j))(new Ft):async c=>new Uint8Array(await new r(c).arrayBuffer())),d=a&&l&&Mt(()=>{let c=!1;const j=new r(ee.origin,{body:new Lt,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return c&&!j}),u=i&&l&&Mt(()=>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 r(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 h(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}=Nt(c),F=e||fetch;O=O?(O+"").toLowerCase():"text";let V=yn([P,_&&_.toAbortSignal()],T),Z=null;const I=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let J;try{if(g&&d&&m!=="get"&&m!=="head"&&(J=await S(v,A))!==0){let f=new r(j,{method:"POST",body:A,duplex:"half"}),k;if(p.isFormData(A)&&(k=f.headers.get("content-type"))&&v.setContentType(k),f.body){const[x,E]=zt(J,Ue(_t(g)));A=Ut(f.body,Dt,x,E)}}p.isString(U)||(U=U?"include":"omit");const z=a&&"credentials"in r.prototype,R={...q,signal:V,method:m.toUpperCase(),headers:v.normalize().toJSON(),body:A,duplex:"half",credentials:z?U:void 0};Z=a&&new r(j,R);let K=await(a?F(Z,q):F(j,R));const te=u&&(O==="stream"||O==="response");if(u&&(M||te&&I)){const f={};["status","statusText","headers"].forEach($=>{f[$]=K[$]});const k=p.toFiniteNumber(K.headers.get("content-length")),[x,E]=M&&zt(k,Ue(_t(M),!0))||[];K=new s(Ut(K.body,Dt,x,()=>{E&&E(),I&&I()}),f)}O=O||"text";let X=await b[p.findKey(b,O)||"text"](K,c);return!te&&I&&I(),await new Promise((f,k)=>{Rt(f,k,{data:X,headers:ne.from(K.headers),status:K.status,statusText:K.statusText,config:c,request:Z})})}catch(z){throw I&&I(),z&&z.name==="TypeError"&&/Load failed|fetch/i.test(z.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,c,Z),{cause:z.cause||z}):D.from(z,z&&z.code,c,Z)}}},kn=new Map,Wt=t=>{let e=t?t.env:{};const{fetch:r,Request:s,Response:o}=e,a=[s,o,r];let i=a.length,l=i,h,d,u=kn;for(;l--;)h=a[l],d=u.get(h),d===void 0&&u.set(h,d=l?new Map:vn(e)),u=d;return d};Wt();const Ze={http:Hr,xhr:mn,fetch:{get:Wt}};p.forEach(Ze,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const qt=t=>`- ${t}`,En=t=>p.isFunction(t)||t===null||t===!1,Bt={getAdapter:(t,e)=>{t=p.isArray(t)?t:[t];const{length:r}=t;let s,o;const a={};for(let i=0;i<r;i++){s=t[i];let l;if(o=s,!En(s)&&(o=Ze[(l=String(s)).toLowerCase()],o===void 0))throw new D(`Unknown adapter '${l}'`);if(o&&(p.isFunction(o)||(o=o.get(e))))break;a[l||"#"+i]=o}if(!o){const i=Object.entries(a).map(([h,d])=>`adapter ${h} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=r?i.length>1?`since :
|
|
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 ct(t,e){return function(){return t.apply(e,arguments)}}const{toString:ar}=Object.prototype,{getPrototypeOf:Be}=Object,{iterator:Re,toStringTag:ut}=Symbol,ze=(t=>e=>{const r=ar.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),se=t=>(t=t.toLowerCase(),e=>ze(e)===t),_e=t=>e=>typeof e===t,{isArray:me}=Array,ye=_e("undefined");function je(t){return t!==null&&!ye(t)&&t.constructor!==null&&!ye(t.constructor)&&re(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const pt=se("ArrayBuffer");function lr(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&pt(t.buffer),e}const dr=_e("string"),re=_e("function"),ft=_e("number"),ve=t=>t!==null&&typeof t=="object",cr=t=>t===!0||t===!1,Ae=t=>{if(ze(t)!=="object")return!1;const e=Be(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ut in t)&&!(Re in t)},ur=t=>{if(!ve(t)||je(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},pr=se("Date"),fr=se("File"),xr=se("Blob"),hr=se("FileList"),gr=t=>ve(t)&&re(t.pipe),mr=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||re(t.append)&&((e=ze(t))==="formdata"||e==="object"&&re(t.toString)&&t.toString()==="[object FormData]"))},yr=se("URLSearchParams"),[br,wr,Sr,jr]=["ReadableStream","Request","Response","Headers"].map(se),vr=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ke(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let s,o;if(typeof t!="object"&&(t=[t]),me(t))for(s=0,o=t.length;s<o;s++)e.call(null,t[s],s,t);else{if(je(t))return;const a=r?Object.getOwnPropertyNames(t):Object.keys(t),i=a.length;let l;for(s=0;s<i;s++)l=a[s],e.call(null,t[l],l,t)}}function xt(t,e){if(je(t))return null;e=e.toLowerCase();const r=Object.keys(t);let s=r.length,o;for(;s-- >0;)if(o=r[s],e===o.toLowerCase())return o;return null}const pe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ht=t=>!ye(t)&&t!==pe;function He(){const{caseless:t,skipUndefined:e}=ht(this)&&this||{},r={},s=(o,a)=>{const i=t&&xt(r,a)||a;Ae(r[i])&&Ae(o)?r[i]=He(r[i],o):Ae(o)?r[i]=He({},o):me(o)?r[i]=o.slice():(!e||!ye(o))&&(r[i]=o)};for(let o=0,a=arguments.length;o<a;o++)arguments[o]&&ke(arguments[o],s);return r}const kr=(t,e,r,{allOwnKeys:s}={})=>(ke(e,(o,a)=>{r&&re(o)?t[a]=ct(o,r):t[a]=o},{allOwnKeys:s}),t),Er=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Cr=(t,e,r,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},Tr=(t,e,r,s)=>{let o,a,i;const l={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),a=o.length;a-- >0;)i=o[a],(!s||s(i,t,e))&&!l[i]&&(e[i]=t[i],l[i]=!0);t=r!==!1&&Be(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},Ir=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const s=t.indexOf(e,r);return s!==-1&&s===r},Pr=t=>{if(!t)return null;if(me(t))return t;let e=t.length;if(!ft(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},Or=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Be(Uint8Array)),Rr=(t,e)=>{const s=(t&&t[Re]).call(t);let o;for(;(o=s.next())&&!o.done;){const a=o.value;e.call(t,a[0],a[1])}},zr=(t,e)=>{let r;const s=[];for(;(r=t.exec(e))!==null;)s.push(r);return s},_r=se("HTMLFormElement"),Ar=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,o){return s.toUpperCase()+o}),gt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),$r=se("RegExp"),mt=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),s={};ke(r,(o,a)=>{let i;(i=e(o,a,t))!==!1&&(s[a]=i||o)}),Object.defineProperties(t,s)},Nr=t=>{mt(t,(e,r)=>{if(re(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=t[r];if(re(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Ur=(t,e)=>{const r={},s=o=>{o.forEach(a=>{r[a]=!0})};return me(t)?s(t):s(String(t).split(e)),r},Dr=()=>{},Lr=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Fr(t){return!!(t&&re(t.append)&&t[ut]==="FormData"&&t[Re])}const Mr=t=>{const e=new Array(10),r=(s,o)=>{if(ve(s)){if(e.indexOf(s)>=0)return;if(je(s))return s;if(!("toJSON"in s)){e[o]=s;const a=me(s)?[]:{};return ke(s,(i,l)=>{const h=r(i,o+1);!ye(h)&&(a[l]=h)}),e[o]=void 0,a}}return s};return r(t,0)},Wr=se("AsyncFunction"),qr=t=>t&&(ve(t)||re(t))&&re(t.then)&&re(t.catch),yt=((t,e)=>t?setImmediate:e?((r,s)=>(pe.addEventListener("message",({source:o,data:a})=>{o===pe&&a===r&&s.length&&s.shift()()},!1),o=>{s.push(o),pe.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",re(pe.postMessage)),Br=typeof queueMicrotask<"u"?queueMicrotask.bind(pe):typeof process<"u"&&process.nextTick||yt,p={isArray:me,isArrayBuffer:pt,isBuffer:je,isFormData:mr,isArrayBufferView:lr,isString:dr,isNumber:ft,isBoolean:cr,isObject:ve,isPlainObject:Ae,isEmptyObject:ur,isReadableStream:br,isRequest:wr,isResponse:Sr,isHeaders:jr,isUndefined:ye,isDate:pr,isFile:fr,isBlob:xr,isRegExp:$r,isFunction:re,isStream:gr,isURLSearchParams:yr,isTypedArray:Or,isFileList:hr,forEach:ke,merge:He,extend:kr,trim:vr,stripBOM:Er,inherits:Cr,toFlatObject:Tr,kindOf:ze,kindOfTest:se,endsWith:Ir,toArray:Pr,forEachEntry:Rr,matchAll:zr,isHTMLForm:_r,hasOwnProperty:gt,hasOwnProp:gt,reduceDescriptors:mt,freezeMethods:Nr,toObjectSet:Ur,toCamelCase:Ar,noop:Dr,toFiniteNumber:Lr,findKey:xt,global:pe,isContextDefined:ht,isSpecCompliantForm:Fr,toJSONObject:Mr,isAsyncFn:Wr,isThenable:qr,setImmediate:yt,asap:Br,isIterable:t=>t!=null&&re(t[Re])};function D(t,e,r,s,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),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 bt=D.prototype,wt={};["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(t=>{wt[t]={value:t}}),Object.defineProperties(D,wt),Object.defineProperty(bt,"isAxiosError",{value:!0}),D.from=(t,e,r,s,o,a)=>{const i=Object.create(bt);p.toFlatObject(t,i,function(c){return c!==Error.prototype},d=>d!=="isAxiosError");const l=t&&t.message?t.message:"Error",h=e==null&&t?t.code:e;return D.call(i,l,h,r,s,o),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",a&&Object.assign(i,a),i};const Hr=null;function Ve(t){return p.isPlainObject(t)||p.isArray(t)}function St(t){return p.endsWith(t,"[]")?t.slice(0,-2):t}function jt(t,e,r){return t?t.concat(e).map(function(o,a){return o=St(o),!r&&a?"["+o+"]":o}).join(r?".":""):e}function Vr(t){return p.isArray(t)&&!t.some(Ve)}const Yr=p.toFlatObject(p,{},null,function(e){return/^is[A-Z]/.test(e)});function $e(t,e,r){if(!p.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=p.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,m){return!p.isUndefined(m[j])});const s=r.metaTokens,o=r.visitor||c,a=r.dots,i=r.indexes,h=(r.Blob||typeof Blob<"u"&&Blob)&&p.isSpecCompliantForm(e);if(!p.isFunction(o))throw new TypeError("visitor must be a function");function d(u){if(u===null)return"";if(p.isDate(u))return u.toISOString();if(p.isBoolean(u))return u.toString();if(!h&&p.isBlob(u))throw new D("Blob is not supported. Use a Buffer instead.");return p.isArrayBuffer(u)||p.isTypedArray(u)?h&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function c(u,j,m){let A=u;if(u&&!m&&typeof u=="object"){if(p.endsWith(j,"{}"))j=s?j:j.slice(0,-2),u=JSON.stringify(u);else if(p.isArray(u)&&Vr(u)||(p.isFileList(u)||p.endsWith(j,"[]"))&&(A=p.toArray(u)))return j=St(j),A.forEach(function(_,T){!(p.isUndefined(_)||_===null)&&e.append(i===!0?jt([j],T,a):i===null?j:j+"[]",d(_))}),!1}return Ve(u)?!0:(e.append(jt(m,j,a),d(u)),!1)}const b=[],y=Object.assign(Yr,{defaultVisitor:c,convertValue:d,isVisitable:Ve});function S(u,j){if(!p.isUndefined(u)){if(b.indexOf(u)!==-1)throw Error("Circular reference detected in "+j.join("."));b.push(u),p.forEach(u,function(A,P){(!(p.isUndefined(A)||A===null)&&o.call(e,A,p.isString(P)?P.trim():P,j,y))===!0&&S(A,j?j.concat(P):[P])}),b.pop()}}if(!p.isObject(t))throw new TypeError("data must be an object");return S(t),e}function vt(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Ye(t,e){this._pairs=[],t&&$e(t,this,e)}const kt=Ye.prototype;kt.append=function(e,r){this._pairs.push([e,r])},kt.toString=function(e){const r=e?function(s){return e.call(this,s,vt)}:vt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function Kr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Et(t,e,r){if(!e)return t;const s=r&&r.encode||Kr;p.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let a;if(o?a=o(e,r):a=p.isURLSearchParams(e)?e.toString():new Ye(e,r).toString(s),a){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class Ct{constructor(){this.handlers=[]}use(e,r,s){return this.handlers.push({fulfilled:e,rejected:r,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){p.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jr={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,Xr=Ke&&(!Je||["ReactNative","NativeScript","NS"].indexOf(Je.product)<0),Gr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zr=Ke&&window.location.href||"http://localhost",ee={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ke,hasStandardBrowserEnv:Xr,hasStandardBrowserWebWorkerEnv:Gr,navigator:Je,origin:Zr},Symbol.toStringTag,{value:"Module"})),...Jr};function Qr(t,e){return $e(t,new ee.classes.URLSearchParams,{visitor:function(r,s,o,a){return ee.isNode&&p.isBuffer(r)?(this.append(s,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function en(t){return p.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function tn(t){const e={},r=Object.keys(t);let s;const o=r.length;let a;for(s=0;s<o;s++)a=r[s],e[a]=t[a];return e}function It(t){function e(r,s,o,a){let i=r[a++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),h=a>=r.length;return i=!i&&p.isArray(o)?o.length:i,h?(p.hasOwnProp(o,i)?o[i]=[o[i],s]:o[i]=s,!l):((!o[i]||!p.isObject(o[i]))&&(o[i]=[]),e(r,s,o[i],a)&&p.isArray(o[i])&&(o[i]=tn(o[i])),!l)}if(p.isFormData(t)&&p.isFunction(t.entries)){const r={};return p.forEachEntry(t,(s,o)=>{e(en(s),o,r,0)}),r}return null}function rn(t,e,r){if(p.isString(t))try{return(e||JSON.parse)(t),p.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(t)}const Ee={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const s=r.getContentType()||"",o=s.indexOf("application/json")>-1,a=p.isObject(e);if(a&&p.isHTMLForm(e)&&(e=new FormData(e)),p.isFormData(e))return o?JSON.stringify(It(e)):e;if(p.isArrayBuffer(e)||p.isBuffer(e)||p.isStream(e)||p.isFile(e)||p.isBlob(e)||p.isReadableStream(e))return e;if(p.isArrayBufferView(e))return e.buffer;if(p.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(a){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Qr(e,this.formSerializer).toString();if((l=p.isFileList(e))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return $e(l?{"files[]":e}:e,h&&new h,this.formSerializer)}}return a||o?(r.setContentType("application/json",!1),rn(e)):e}],transformResponse:[function(e){const r=this.transitional||Ee.transitional,s=r&&r.forcedJSONParsing,o=this.responseType==="json";if(p.isResponse(e)||p.isReadableStream(e))return e;if(e&&p.isString(e)&&(s&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?D.from(l,D.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ee.classes.FormData,Blob:ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};p.forEach(["delete","get","head","post","put","patch"],t=>{Ee.headers[t]={}});const nn=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"]),sn=t=>{const e={};let r,s,o;return t&&t.split(`
|
|
2
|
+
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),s=i.substring(o+1).trim(),!(!r||e[r]&&nn[r])&&(r==="set-cookie"?e[r]?e[r].push(s):e[r]=[s]:e[r]=e[r]?e[r]+", "+s:s)}),e},Pt=Symbol("internals");function Ce(t){return t&&String(t).trim().toLowerCase()}function Ne(t){return t===!1||t==null?t:p.isArray(t)?t.map(Ne):String(t)}function on(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=r.exec(t);)e[s[1]]=s[2];return e}const an=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Xe(t,e,r,s,o){if(p.isFunction(s))return s.call(this,e,r);if(o&&(e=r),!!p.isString(e)){if(p.isString(s))return e.indexOf(s)!==-1;if(p.isRegExp(s))return s.test(e)}}function ln(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,s)=>r.toUpperCase()+s)}function dn(t,e){const r=p.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+r,{value:function(o,a,i){return this[s].call(this,e,o,a,i)},configurable:!0})})}let ne=class{constructor(e){e&&this.set(e)}set(e,r,s){const o=this;function a(l,h,d){const c=Ce(h);if(!c)throw new Error("header name must be a non-empty string");const b=p.findKey(o,c);(!b||o[b]===void 0||d===!0||d===void 0&&o[b]!==!1)&&(o[b||h]=Ne(l))}const i=(l,h)=>p.forEach(l,(d,c)=>a(d,c,h));if(p.isPlainObject(e)||e instanceof this.constructor)i(e,r);else if(p.isString(e)&&(e=e.trim())&&!an(e))i(sn(e),r);else if(p.isObject(e)&&p.isIterable(e)){let l={},h,d;for(const c of e){if(!p.isArray(c))throw TypeError("Object iterator must return a key-value pair");l[d=c[0]]=(h=l[d])?p.isArray(h)?[...h,c[1]]:[h,c[1]]:c[1]}i(l,r)}else e!=null&&a(r,e,s);return this}get(e,r){if(e=Ce(e),e){const s=p.findKey(this,e);if(s){const o=this[s];if(!r)return o;if(r===!0)return on(o);if(p.isFunction(r))return r.call(this,o,s);if(p.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=Ce(e),e){const s=p.findKey(this,e);return!!(s&&this[s]!==void 0&&(!r||Xe(this,this[s],s,r)))}return!1}delete(e,r){const s=this;let o=!1;function a(i){if(i=Ce(i),i){const l=p.findKey(s,i);l&&(!r||Xe(s,s[l],l,r))&&(delete s[l],o=!0)}}return p.isArray(e)?e.forEach(a):a(e),o}clear(e){const r=Object.keys(this);let s=r.length,o=!1;for(;s--;){const a=r[s];(!e||Xe(this,this[a],a,e,!0))&&(delete this[a],o=!0)}return o}normalize(e){const r=this,s={};return p.forEach(this,(o,a)=>{const i=p.findKey(s,a);if(i){r[i]=Ne(o),delete r[a];return}const l=e?ln(a):String(a).trim();l!==a&&delete r[a],r[l]=Ne(o),s[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return p.forEach(this,(s,o)=>{s!=null&&s!==!1&&(r[o]=e&&p.isArray(s)?s.join(", "):s)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const s=new this(e);return r.forEach(o=>s.set(o)),s}static accessor(e){const s=(this[Pt]=this[Pt]={accessors:{}}).accessors,o=this.prototype;function a(i){const l=Ce(i);s[l]||(dn(o,i),s[l]=!0)}return p.isArray(e)?e.forEach(a):a(e),this}};ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),p.reduceDescriptors(ne.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[r]=s}}}),p.freezeMethods(ne);function Ge(t,e){const r=this||Ee,s=e||r,o=ne.from(s.headers);let a=s.data;return p.forEach(t,function(l){a=l.call(r,a,o.normalize(),e?e.status:void 0)}),o.normalize(),a}function Ot(t){return!!(t&&t.__CANCEL__)}function be(t,e,r){D.call(this,t??"canceled",D.ERR_CANCELED,e,r),this.name="CanceledError"}p.inherits(be,D,{__CANCEL__:!0});function Rt(t,e,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?t(r):e(new D("Request failed with status code "+r.status,[D.ERR_BAD_REQUEST,D.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function cn(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function un(t,e){t=t||10;const r=new Array(t),s=new Array(t);let o=0,a=0,i;return e=e!==void 0?e:1e3,function(h){const d=Date.now(),c=s[a];i||(i=d),r[o]=h,s[o]=d;let b=a,y=0;for(;b!==o;)y+=r[b++],b=b%t;if(o=(o+1)%t,o===a&&(a=(a+1)%t),d-i<e)return;const S=c&&d-c;return S?Math.round(y*1e3/S):void 0}}function pn(t,e){let r=0,s=1e3/e,o,a;const i=(d,c=Date.now())=>{r=c,o=null,a&&(clearTimeout(a),a=null),t(...d)};return[(...d)=>{const c=Date.now(),b=c-r;b>=s?i(d,c):(o=d,a||(a=setTimeout(()=>{a=null,i(o)},s-b)))},()=>o&&i(o)]}const Ue=(t,e,r=3)=>{let s=0;const o=un(50,250);return pn(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,h=i-s,d=o(h),c=i<=l;s=i;const b={loaded:i,total:l,progress:l?i/l:void 0,bytes:h,rate:d||void 0,estimated:d&&l&&c?(l-i)/d:void 0,event:a,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(b)},r)},zt=(t,e)=>{const r=t!=null;return[s=>e[0]({lengthComputable:r,total:t,loaded:s}),e[1]]},_t=t=>(...e)=>p.asap(()=>t(...e)),fn=ee.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,ee.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,xn=ee.hasStandardBrowserEnv?{write(t,e,r,s,o,a){const i=[t+"="+encodeURIComponent(e)];p.isNumber(r)&&i.push("expires="+new Date(r).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(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function gn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function At(t,e,r){let s=!hn(e);return t&&(s||r==!1)?gn(t,e):e}const $t=t=>t instanceof ne?{...t}:t;function fe(t,e){e=e||{};const r={};function s(d,c,b,y){return p.isPlainObject(d)&&p.isPlainObject(c)?p.merge.call({caseless:y},d,c):p.isPlainObject(c)?p.merge({},c):p.isArray(c)?c.slice():c}function o(d,c,b,y){if(p.isUndefined(c)){if(!p.isUndefined(d))return s(void 0,d,b,y)}else return s(d,c,b,y)}function a(d,c){if(!p.isUndefined(c))return s(void 0,c)}function i(d,c){if(p.isUndefined(c)){if(!p.isUndefined(d))return s(void 0,d)}else return s(void 0,c)}function l(d,c,b){if(b in e)return s(d,c);if(b in t)return s(void 0,d)}const h={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,c,b)=>o($t(d),$t(c),b,!0)};return p.forEach(Object.keys({...t,...e}),function(c){const b=h[c]||o,y=b(t[c],e[c],c);p.isUndefined(y)&&b!==l||(r[c]=y)}),r}const Nt=t=>{const e=fe({},t);let{data:r,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:l}=e;if(e.headers=i=ne.from(i),e.url=Et(At(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),p.isFormData(r)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(p.isFunction(r.getHeaders)){const h=r.getHeaders(),d=["content-type","content-length"];Object.entries(h).forEach(([c,b])=>{d.includes(c.toLowerCase())&&i.set(c,b)})}}if(ee.hasStandardBrowserEnv&&(s&&p.isFunction(s)&&(s=s(e)),s||s!==!1&&fn(e.url))){const h=o&&a&&xn.read(a);h&&i.set(o,h)}return e},mn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,s){const o=Nt(t);let a=o.data;const i=ne.from(o.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:d}=o,c,b,y,S,u;function j(){S&&S(),u&&u(),o.cancelToken&&o.cancelToken.unsubscribe(c),o.signal&&o.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function A(){if(!m)return;const _=ne.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:t,request:m};Rt(function(O){r(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,t,m)),m=null)},m.onerror=function(T){const M=T&&T.message?T.message:"Network Error",g=new D(M,D.ERR_NETWORK,t,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||Tt;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),s(new D(T,M.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,t,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,u]=Ue(d,!0),m.addEventListener("progress",y)),h&&m.upload&&([b,S]=Ue(h),m.upload.addEventListener("progress",b),m.upload.addEventListener("loadend",S)),(o.cancelToken||o.signal)&&(c=_=>{m&&(s(!_||_.type?new be(null,t,m):_),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(c),o.signal&&(o.signal.aborted?c():o.signal.addEventListener("abort",c)));const P=cn(o.url);if(P&&ee.protocols.indexOf(P)===-1){s(new D("Unsupported protocol "+P+":",D.ERR_BAD_REQUEST,t));return}m.send(a||null)})},yn=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let s=new AbortController,o;const a=function(d){if(!o){o=!0,l();const c=d instanceof Error?d:this.reason;s.abort(c instanceof D?c:new be(c instanceof Error?c.message:c))}};let i=e&&setTimeout(()=>{i=null,a(new D(`timeout ${e} of ms exceeded`,D.ETIMEDOUT))},e);const l=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),t=null)};t.forEach(d=>d.addEventListener("abort",a));const{signal:h}=s;return h.unsubscribe=()=>p.asap(l),h}},bn=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let s=0,o;for(;s<r;)o=s+e,yield t.slice(s,o),s=o},wn=async function*(t,e){for await(const r of Sn(t))yield*bn(r,e)},Sn=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:s}=await e.read();if(r)break;yield s}}finally{await e.cancel()}},Ut=(t,e,r,s)=>{const o=wn(t,e);let a=0,i,l=h=>{i||(i=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:d,value:c}=await o.next();if(d){l(),h.close();return}let b=c.byteLength;if(r){let y=a+=b;r(y)}h.enqueue(new Uint8Array(c))}catch(d){throw l(d),d}},cancel(h){return l(h),o.return()}},{highWaterMark:2})},Dt=64*1024,{isFunction:De}=p,jn=(({Request:t,Response:e})=>({Request:t,Response:e}))(p.global),{ReadableStream:Lt,TextEncoder:Ft}=p.global,Mt=(t,...e)=>{try{return!!t(...e)}catch{return!1}},vn=t=>{t=p.merge.call({skipUndefined:!0},jn,t);const{fetch:e,Request:r,Response:s}=t,o=e?De(e):typeof fetch=="function",a=De(r),i=De(s);if(!o)return!1;const l=o&&De(Lt),h=o&&(typeof Ft=="function"?(u=>j=>u.encode(j))(new Ft):async u=>new Uint8Array(await new r(u).arrayBuffer())),d=a&&l&&Mt(()=>{let u=!1;const j=new r(ee.origin,{body:new Lt,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!j}),c=i&&l&&Mt(()=>p.isReadableStream(new s("").body)),b={stream:c&&(u=>u.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!b[u]&&(b[u]=(j,m)=>{let A=j&&j[u];if(A)return A.call(j);throw new D(`Response type '${u}' is not supported`,D.ERR_NOT_SUPPORT,m)})});const y=async u=>{if(u==null)return 0;if(p.isBlob(u))return u.size;if(p.isSpecCompliantForm(u))return(await new r(ee.origin,{method:"POST",body:u}).arrayBuffer()).byteLength;if(p.isArrayBufferView(u)||p.isArrayBuffer(u))return u.byteLength;if(p.isURLSearchParams(u)&&(u=u+""),p.isString(u))return(await h(u)).byteLength},S=async(u,j)=>{const m=p.toFiniteNumber(u.getContentLength());return m??y(j)};return async u=>{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}=Nt(u),F=e||fetch;O=O?(O+"").toLowerCase():"text";let V=yn([P,_&&_.toAbortSignal()],T),Z=null;const I=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let J;try{if(g&&d&&m!=="get"&&m!=="head"&&(J=await S(v,A))!==0){let f=new r(j,{method:"POST",body:A,duplex:"half"}),k;if(p.isFormData(A)&&(k=f.headers.get("content-type"))&&v.setContentType(k),f.body){const[x,E]=zt(J,Ue(_t(g)));A=Ut(f.body,Dt,x,E)}}p.isString(U)||(U=U?"include":"omit");const z=a&&"credentials"in r.prototype,R={...q,signal:V,method:m.toUpperCase(),headers:v.normalize().toJSON(),body:A,duplex:"half",credentials:z?U:void 0};Z=a&&new r(j,R);let K=await(a?F(Z,q):F(j,R));const te=c&&(O==="stream"||O==="response");if(c&&(M||te&&I)){const f={};["status","statusText","headers"].forEach($=>{f[$]=K[$]});const k=p.toFiniteNumber(K.headers.get("content-length")),[x,E]=M&&zt(k,Ue(_t(M),!0))||[];K=new s(Ut(K.body,Dt,x,()=>{E&&E(),I&&I()}),f)}O=O||"text";let X=await b[p.findKey(b,O)||"text"](K,u);return!te&&I&&I(),await new Promise((f,k)=>{Rt(f,k,{data:X,headers:ne.from(K.headers),status:K.status,statusText:K.statusText,config:u,request:Z})})}catch(z){throw I&&I(),z&&z.name==="TypeError"&&/Load failed|fetch/i.test(z.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,u,Z),{cause:z.cause||z}):D.from(z,z&&z.code,u,Z)}}},kn=new Map,Wt=t=>{let e=t?t.env:{};const{fetch:r,Request:s,Response:o}=e,a=[s,o,r];let i=a.length,l=i,h,d,c=kn;for(;l--;)h=a[l],d=c.get(h),d===void 0&&c.set(h,d=l?new Map:vn(e)),c=d;return d};Wt();const Ze={http:Hr,xhr:mn,fetch:{get:Wt}};p.forEach(Ze,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const qt=t=>`- ${t}`,En=t=>p.isFunction(t)||t===null||t===!1,Bt={getAdapter:(t,e)=>{t=p.isArray(t)?t:[t];const{length:r}=t;let s,o;const a={};for(let i=0;i<r;i++){s=t[i];let l;if(o=s,!En(s)&&(o=Ze[(l=String(s)).toLowerCase()],o===void 0))throw new D(`Unknown adapter '${l}'`);if(o&&(p.isFunction(o)||(o=o.get(e))))break;a[l||"#"+i]=o}if(!o){const i=Object.entries(a).map(([h,d])=>`adapter ${h} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=r?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(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new be(null,t)}function Ht(t){return Qe(t),t.headers=ne.from(t.headers),t.data=Ge.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Bt.getAdapter(t.adapter||Ee.adapter,t)(t).then(function(s){return Qe(t),s.data=Ge.call(t,t.transformResponse,s),s.headers=ne.from(s.headers),s},function(s){return Ot(s)||(Qe(t),s&&s.response&&(s.response.data=Ge.call(t,t.transformResponse,s.response),s.response.headers=ne.from(s.response.headers))),Promise.reject(s)})}const Vt="1.12.2",Le={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Le[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const Yt={};Le.transitional=function(e,r,s){function o(a,i){return"[Axios v"+Vt+"] Transitional option '"+a+"'"+i+(s?". "+s:"")}return(a,i,l)=>{if(e===!1)throw new D(o(i," has been removed"+(r?" in "+r:"")),D.ERR_DEPRECATED);return r&&!Yt[i]&&(Yt[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,i,l):!0}},Le.spelling=function(e){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function Cn(t,e,r){if(typeof t!="object")throw new D("options must be an object",D.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let o=s.length;for(;o-- >0;){const a=s[o],i=e[a];if(i){const l=t[a],h=l===void 0||i(l,a,t);if(h!==!0)throw new D("option "+a+" must be "+h,D.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new D("Unknown option "+a,D.ERR_BAD_OPTION)}}const Fe={assertOptions:Cn,validators:Le},ae=Fe.validators;let xe=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ct,response:new Ct}}async request(e,r){try{return await this._request(e,r)}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
|
-
`+a):s.stack=a}catch{}}throw s}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=fe(this.defaults,r);const{transitional:s,paramsSerializer:o,headers:a}=r;s!==void 0&&Fe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Fe.assertOptions(o,{encode:ae.function,serialize:ae.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Fe.assertOptions(r,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=a&&p.merge(a.common,a[r.method]);a&&p.forEach(["delete","get","head","post","put","patch","common"],c=>{delete a[c]}),r.headers=ne.concat(i,a);const l=[];let h=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(r)===!1||(h=h&&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(!h){const c=[Ht.bind(this),void 0];for(c.unshift(...l),c.push(...d),y=c.length,u=Promise.resolve(r);b<y;)u=u.then(c[b++],c[b++]);return u}y=l.length;let S=r;for(;b<y;){const c=l[b++],j=l[b++];try{S=c(S)}catch(m){j.call(this,m);break}}try{u=Ht.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(e){e=fe(this.defaults,e);const r=At(e.baseURL,e.url,e.allowAbsoluteUrls);return Et(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){xe.prototype[e]=function(r,s){return this.request(fe(s||{},{method:e,url:r,data:(s||{}).data}))}}),p.forEach(["post","put","patch"],function(e){function r(s){return function(a,i,l){return this.request(fe(l||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}xe.prototype[e]=r(),xe.prototype[e+"Form"]=r(!0)});let Tn=class ir{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=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},e(function(a,i,l){s.reason||(s.reason=new be(a,i,l),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=s=>{e.abort(s)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new ir(function(o){e=o}),cancel:e}}};function In(t){return function(r){return t.apply(null,r)}}function Pn(t){return p.isObject(t)&&t.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(([t,e])=>{et[e]=t});function Kt(t){const e=new xe(t),r=ct(xe.prototype.request,e);return p.extend(r,xe.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Kt(fe(t,o))},r}const W=Kt(Ee);W.Axios=xe,W.CanceledError=be,W.CancelToken=Tn,W.isCancel=Ot,W.VERSION=Vt,W.toFormData=$e,W.AxiosError=D,W.Cancel=W.CanceledError,W.all=function(e){return Promise.all(e)},W.spread=In,W.isAxiosError=Pn,W.mergeConfig=fe,W.AxiosHeaders=ne,W.formToJSON=t=>It(p.isHTMLForm(t)?new FormData(t):t),W.getAdapter=Bt.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 On{baseUrl;apiKey;appId;client;constructor(e){if(!e||!e.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey||null,this.appId=e.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(e,r,s,o={}){if(!e)throw new Error("HTTP method is required");if(!r)throw new Error("Request path is required");try{const a={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:e,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(e){const{name:r,email:s,password:o}=e;if(!r||!s||!o)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",e)}async login(e){const{email:r,password:s,appId:o}=e;if(!r||!s)throw new Error("login: 'email' and 'password' are required");return this.request("POST","/users/login",{email:r,password:s,appId:o||this.appId})}async updateUser(e){const{userId:r,appId:s}=e;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...e,appId:s||this.appId})}async changePassword(e){const{userId:r,currentPassword:s,newPassword:o,appId:a}=e;if(!r)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/${r}`,{currentPassword:s,newPassword:o,appId:a||this.appId})}async deleteUser(e){const{userId:r,appId:s}=e;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{appId:s||this.appId})}async getProfile(e){const{token:r}=e;if(!r)throw new Error("getProfile: 'token' is required");return this.request("GET","/users/profile",{},{Authorization:`Bearer ${r}`})}async sendVerifyOTP(e){const{token:r,appId:s}=e;if(!r)throw new Error("sendVerifyOTP: 'token' is required");return this.request("POST","/users/send-verify-otp",{appId:s||this.appId},{Authorization:`Bearer ${r}`})}async verifyEmail(e){const{token:r,otp:s,appId:o}=e;if(!r)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 ${r}`})}async forgotPassword(e){const{email:r,appId:s}=e;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r,appId:s||this.appId})}async resetPassword(e){const{email:r,otp:s,newPassword:o,appId:a}=e;if(!r||!s||!o)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:o,appId:a||this.appId})}async searchAllUsersData(e){if(!this.appId)throw new Error("searchAllUsersData: appId missing");const r=new URLSearchParams(e).toString();return this.request("GET",`/users/${this.appId}/data/search?${r}`)}async searchUserData(e){const{userId:r,...s}=e;if(!r)throw new Error("userId required");const o=new URLSearchParams(s).toString();return this.request("GET",`/users/${r}/data/search?${o}`)}async getAllUsersData(){if(!this.appId)throw new Error("getAllUsersData: SDK 'appId' is missing in config");return this.request("GET",`/users/all-data/${this.appId}/data`)}async getUserData(e){const{userId:r}=e;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`)}async getSingleUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`)}async addUserData(e){const{userId:r,dataCategory:s,data:o}=e;if(!r)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'dataCategory' is required");if(!o)throw new Error("addUserData: 'data' is required");return this.request("POST",`/users/${r}/data`,{dataCategory:s,...o})}async updateUserData(e){const{userId:r,dataId:s,data:o}=e;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!o)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,o)}async deleteUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`)}}var Me={exports:{}},Te={};/**
|
|
6
|
+
`+a):s.stack=a}catch{}}throw s}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=fe(this.defaults,r);const{transitional:s,paramsSerializer:o,headers:a}=r;s!==void 0&&Fe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Fe.assertOptions(o,{encode:ae.function,serialize:ae.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Fe.assertOptions(r,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=a&&p.merge(a.common,a[r.method]);a&&p.forEach(["delete","get","head","post","put","patch","common"],u=>{delete a[u]}),r.headers=ne.concat(i,a);const l=[];let h=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(r)===!1||(h=h&&j.synchronous,l.unshift(j.fulfilled,j.rejected))});const d=[];this.interceptors.response.forEach(function(j){d.push(j.fulfilled,j.rejected)});let c,b=0,y;if(!h){const u=[Ht.bind(this),void 0];for(u.unshift(...l),u.push(...d),y=u.length,c=Promise.resolve(r);b<y;)c=c.then(u[b++],u[b++]);return c}y=l.length;let S=r;for(;b<y;){const u=l[b++],j=l[b++];try{S=u(S)}catch(m){j.call(this,m);break}}try{c=Ht.call(this,S)}catch(u){return Promise.reject(u)}for(b=0,y=d.length;b<y;)c=c.then(d[b++],d[b++]);return c}getUri(e){e=fe(this.defaults,e);const r=At(e.baseURL,e.url,e.allowAbsoluteUrls);return Et(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){xe.prototype[e]=function(r,s){return this.request(fe(s||{},{method:e,url:r,data:(s||{}).data}))}}),p.forEach(["post","put","patch"],function(e){function r(s){return function(a,i,l){return this.request(fe(l||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}xe.prototype[e]=r(),xe.prototype[e+"Form"]=r(!0)});let Tn=class ir{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=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},e(function(a,i,l){s.reason||(s.reason=new be(a,i,l),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=s=>{e.abort(s)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new ir(function(o){e=o}),cancel:e}}};function In(t){return function(r){return t.apply(null,r)}}function Pn(t){return p.isObject(t)&&t.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(([t,e])=>{et[e]=t});function Kt(t){const e=new xe(t),r=ct(xe.prototype.request,e);return p.extend(r,xe.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Kt(fe(t,o))},r}const W=Kt(Ee);W.Axios=xe,W.CanceledError=be,W.CancelToken=Tn,W.isCancel=Ot,W.VERSION=Vt,W.toFormData=$e,W.AxiosError=D,W.Cancel=W.CanceledError,W.all=function(e){return Promise.all(e)},W.spread=In,W.isAxiosError=Pn,W.mergeConfig=fe,W.AxiosHeaders=ne,W.formToJSON=t=>It(p.isHTMLForm(t)?new FormData(t):t),W.getAdapter=Bt.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 On{baseUrl;apiKey;appId;client;constructor(e){if(!e||!e.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey||null,this.appId=e.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(e,r,s,o={}){if(!e)throw new Error("HTTP method is required");if(!r)throw new Error("Request path is required");try{const a={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:e,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(e){const{name:r,email:s,password:o}=e;if(!r||!s||!o)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",e)}async login(e){const{email:r,password:s,appId:o}=e;if(!r||!s)throw new Error("login: 'email' and 'password' are required");return this.request("POST","/users/login",{email:r,password:s,appId:o||this.appId})}async updateUser(e){const{userId:r,appId:s}=e;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...e,appId:s||this.appId})}async changePassword(e){const{userId:r,currentPassword:s,newPassword:o,appId:a}=e;if(!r)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/${r}`,{currentPassword:s,newPassword:o,appId:a||this.appId})}async deleteUser(e){const{userId:r,appId:s}=e;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{appId:s||this.appId})}async getProfile(e){const{token:r}=e;if(!r)throw new Error("getProfile: 'token' is required");return this.request("GET","/users/profile",{},{Authorization:`Bearer ${r}`})}async sendVerifyOTP(e){const{token:r,appId:s}=e;if(!r)throw new Error("sendVerifyOTP: 'token' is required");return this.request("POST","/users/send-verify-otp",{appId:s||this.appId},{Authorization:`Bearer ${r}`})}async verifyEmail(e){const{token:r,otp:s,appId:o}=e;if(!r)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 ${r}`})}async forgotPassword(e){const{email:r,appId:s}=e;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r,appId:s||this.appId})}async resetPassword(e){const{email:r,otp:s,newPassword:o,appId:a}=e;if(!r||!s||!o)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:o,appId:a||this.appId})}async searchAllUsersData(e){if(!this.appId)throw new Error("searchAllUsersData: appId missing");const r=new URLSearchParams(e).toString();return this.request("GET",`/users/${this.appId}/data/search?${r}`)}async searchUserData(e){const{userId:r,...s}=e;if(!r)throw new Error("userId required");const o=new URLSearchParams(s).toString();return this.request("GET",`/users/${r}/data/search?${o}`)}async getAllUsersData(){if(!this.appId)throw new Error("getAllUsersData: SDK 'appId' is missing in config");return this.request("GET",`/users/all-data/${this.appId}/data`)}async getUserData(e){const{userId:r}=e;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`)}async getSingleUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`)}async addUserData(e){const{userId:r,dataCategory:s,data:o}=e;if(!r)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'dataCategory' is required");if(!o)throw new Error("addUserData: 'data' is required");return this.request("POST",`/users/${r}/data`,{dataCategory:s,...o})}async updateUserData(e){const{userId:r,dataId:s,data:o}=e;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!o)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,o)}async deleteUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`)}}var Me={exports:{}},Te={};/**
|
|
7
7
|
* @license React
|
|
8
8
|
* react-jsx-runtime.production.js
|
|
9
9
|
*
|
|
@@ -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 Xt;function zn(){return Xt||(Xt=1,process.env.NODE_ENV!=="production"&&(function(){function t(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===F?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 M: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:t(f.type)||"Memo";case U:k=f._payload,f=f._init;try{return t(f(k))}catch{}}return null}function e(f){return""+f}function r(f){try{e(f);var k=!1}catch{k=!0}if(k){k=console;var x=k.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&f[Symbol.toStringTag]||f.constructor.name||"Object";return x.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),e(f)}}function s(f){if(f===m)return"<>";if(typeof f=="object"&&f!==null&&f.$$typeof===U)return"<...>";try{var k=t(f);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function o(){var f=V.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 x(){z||(z=!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))}x.isReactWarning=!0,Object.defineProperty(f,"key",{get:x,configurable:!0})}function h(){var f=t(this.type);return R[f]||(R[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,x,E,$,N){var Y=x.ref;return f={$$typeof:
|
|
22
|
+
*/var Xt;function zn(){return Xt||(Xt=1,process.env.NODE_ENV!=="production"&&(function(){function t(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===F?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 M: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:t(f.type)||"Memo";case U:k=f._payload,f=f._init;try{return t(f(k))}catch{}}return null}function e(f){return""+f}function r(f){try{e(f);var k=!1}catch{k=!0}if(k){k=console;var x=k.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&f[Symbol.toStringTag]||f.constructor.name||"Object";return x.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),e(f)}}function s(f){if(f===m)return"<>";if(typeof f=="object"&&f!==null&&f.$$typeof===U)return"<...>";try{var k=t(f);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function o(){var f=V.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 x(){z||(z=!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))}x.isReactWarning=!0,Object.defineProperty(f,"key",{get:x,configurable:!0})}function h(){var f=t(this.type);return R[f]||(R[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,x,E,$,N){var Y=x.ref;return f={$$typeof:u,type:f,key:k,props:x,_owner:E},(Y!==void 0?Y:null)!==null?Object.defineProperty(f,"ref",{enumerable:!1,get:h}):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:$}),Object.defineProperty(f,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f}function c(f,k,x,E,$,N){var Y=k.children;if(Y!==void 0)if(E)if(I(Y)){for(E=0;E<Y.length;E++)b(Y[E]);Object.freeze&&Object.freeze(Y)}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(Y);if(Z.call(k,"key")){Y=t(f);var ie=Object.keys(k).filter(function(Oe){return Oe!=="key"});E=0<ie.length?"{key: someKey, "+ie.join(": ..., ")+": ...}":"{key: someKey}",X[Y+E]||(ie=0<ie.length?"{"+ie.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} />`,E,Y,ie,Y),X[Y+E]=!0)}if(Y=null,x!==void 0&&(r(x),Y=""+x),i(k)&&(r(k.key),Y=""+k.key),"key"in k){x={};for(var he in k)he!=="key"&&(x[he]=k[he])}else x=k;return Y&&l(x,typeof f=="function"?f.displayName||f.name||"Unknown":f),d(f,Y,x,o(),$,N)}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===
|
|
27
|
+
<%s key={someKey} {...props} />`,E,Y,ie,Y),X[Y+E]=!0)}if(Y=null,x!==void 0&&(r(x),Y=""+x),i(k)&&(r(k.key),Y=""+k.key),"key"in k){x={};for(var he in k)he!=="key"&&(x[he]=k[he])}else x=k;return Y&&l(x,typeof f=="function"?f.displayName||f.name||"Unknown":f),d(f,Y,x,o(),$,N)}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===u}var S=w,u=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"),M=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"),F=Symbol.for("react.client.reference"),V=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,I=Array.isArray,J=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(f){return f()}};var z,R={},K=S.react_stack_bottom_frame.bind(S,a)(),te=J(s(a)),X={};Ie.Fragment=m,Ie.jsx=function(f,k,x){var E=1e4>V.recentlyCreatedOwnerStacks++;return c(f,k,x,!1,E?Error("react-stack-top-frame"):K,E?J(s(f)):te)},Ie.jsxs=function(f,k,x){var E=1e4>V.recentlyCreatedOwnerStacks++;return c(f,k,x,!0,E?Error("react-stack-top-frame"):K,E?J(s(f)):te)}})()),Ie}var Gt;function _n(){return Gt||(Gt=1,process.env.NODE_ENV==="production"?Me.exports=Rn():Me.exports=zn()),Me.exports}var n=_n();const An=async(t,e)=>{const{name:r,email:s,password:o,appId:a,phone:i,address:l,avatarUrl:h,isActive:d=!0,role:c="user"}=t,{baseUrl:b,apiKey:y}=e;if(!y)throw new Error("API key is required for signup");if(!r||!s||!o||!a)throw new Error("Name, email, password, and appId are required");try{const S=await W.post(`${b}/users/signup`,{name:r,email:s,password:o,appId:a,phone:i,address:l,avatarUrl:h,isActive:d,role:c},{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 u=S.response?.data?.message||S.message||"Signup failed";if(console.error("Signup API Error:",u),S.response?.status===400){if(u.includes("already exists"))throw{success:!1,message:"User with this email already exists for this app",status:400};if(u.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:u,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.
|
|
@@ -39,7 +39,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const Ln=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:o="",children:a,iconNode:i,...l},h)=>w.createElement("svg",{ref:h,...Dn,width:e,height:e,stroke:t,strokeWidth:s?Number(r)*24/Number(e):r,className:Qt("lucide",o),...!a&&!Un(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,
|
|
42
|
+
*/const Ln=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:o="",children:a,iconNode:i,...l},h)=>w.createElement("svg",{ref:h,...Dn,width:e,height:e,stroke:t,strokeWidth:s?Number(r)*24/Number(e):r,className:Qt("lucide",o),...!a&&!Un(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,c])=>w.createElement(d,c)),...Array.isArray(a)?a:[a]]));/**
|
|
43
43
|
* @license lucide-react v0.544.0 - ISC
|
|
44
44
|
*
|
|
45
45
|
* 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=B("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),qe={baseUrl:"",apiKey:"",appId:""},Zn=t=>{if(!t.baseUrl||!t.apiKey||!t.appId)throw new Error("baseUrl, apiKey, and appId are required");qe.baseUrl=t.baseUrl,qe.apiKey=t.apiKey,qe.appId=t.appId},ue=()=>qe,Qn=({logoUrl:t,logoLinkUrl:e,title:r="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:h=!1,roles:d=[],showRoleSelector:
|
|
202
|
+
*/const Pe=B("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),qe={baseUrl:"",apiKey:"",appId:""},Zn=t=>{if(!t.baseUrl||!t.apiKey||!t.appId)throw new Error("baseUrl, apiKey, and appId are required");qe.baseUrl=t.baseUrl,qe.apiKey=t.apiKey,qe.appId=t.appId},ue=()=>qe,Qn=({logoUrl:t,logoLinkUrl:e,title:r="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:h=!1,roles:d=[],showRoleSelector:c=!1,loginUrl:b,onSuccess:y,onError:S})=>{const{baseUrl:u,apiKey:j,appId:m}=ue(),A={name:"",email:"",password:"",role:d.length?d[0]:"user",...h&&{avatarUrl:""}},[P,_]=w.useState(A),[T,M]=w.useState(!1),[g,O]=w.useState(!1),[v,U]=w.useState(null),[q,F]=w.useState({}),[V,Z]=w.useState(!1),I=l?"#ffffff":"#111827",J=l?"#a1a1aa":"#6b7280",z=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",R=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 K=k=>{const{name:x,value:E}=k.target;_($=>({...$,[x]:E})),q[x]&&F($=>({...$,[x]:void 0}))},te=()=>{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",F(k),Object.keys(k).length===0},X=async k=>{if(k.preventDefault(),!!te()){O(!0),U(null);try{const x={...P,appId:m},E=await An(x,{baseUrl:u,apiKey:j});U({type:"success",text:"Account created successfully!"}),y&&y(E)}catch(x){const E=x.message||"Signup failed. Please try again.";U({type:"error",text:E}),S&&S(x)}finally{O(!1)}}},f={width:"100%",padding:V?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:z,border:`1px solid ${R}`,borderRadius:"10px",color:I,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"};return n.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[n.jsxs("div",{style:{minWidth:V?"320px":"380px",width:"100%",maxWidth:V?"340px":"390px",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:V?"30px 24px":"20px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:I,margin:0},children:r}),n.jsx("p",{style:{fontSize:"14px",color:J},children:s})]}),h&&P.avatarUrl&&n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:n.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 x=k.target;x.style.display="none"}})}),n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[c&&d&&d.length===2&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{style:{fontSize:"14px",fontWeight:500,color:I},children:"Select Role"}),n.jsxs("div",{style:{position:"relative",display:"flex",borderRadius:"10px",border:`1px solid ${R}`,backgroundColor:z,overflow:"hidden",cursor:"pointer",height:"42px"},children:[n.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}}),n.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)}),n.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)})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-name",style:{fontSize:"14px",fontWeight:500,color:I},children:"Full Name"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-name",type:"text",name:"name",placeholder:"Enter your full name",value:P.name,onChange:K,style:{...f,borderColor:q.name?"#ef4444":R}})]}),q.name&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.name})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-email",style:{fontSize:"14px",fontWeight:500,color:I},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-email",type:"email",name:"email",placeholder:"Enter your email address",value:P.email,onChange:K,style:{...f,borderColor:q.email?"#ef4444":R}})]}),q.email&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.email})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-password",style:{fontSize:"14px",fontWeight:500,color:I},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-password",type:T?"text":"password",name:"password",placeholder:"Create a secure password",value:P.password,onChange:K,style:{...f,borderColor:q.password?"#ef4444":R}}),n.jsx("button",{type:"button",onClick:()=>M(!T),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:J,cursor:"pointer",padding:"4px"},children:T?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]}),q.password&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:q.password})]}),h&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-avatar",style:{fontSize:"14px",fontWeight:500,color:I},children:"Avatar URL (Optional)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(er,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:J}}),n.jsx("input",{id:"signup-avatar",type:"url",name:"avatarUrl",placeholder:"Paste your avatar image URL",value:P.avatarUrl||"",onChange:K,style:f})]})]}),b&&n.jsx("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:n.jsx("a",{href:b,style:{color:a,textDecoration:"none",fontWeight:500},children:"Already have an account?"})}),v&&n.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"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:v.text})]}),n.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?n.jsxs(n.Fragment,{children:[n.jsx(Hn,{size:18,style:{animation:"spin 1s linear infinite"}}),"Creating Account..."]}):"Create Account"})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:J,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]}),n.jsx("style",{children:`
|
|
203
203
|
@keyframes spin {
|
|
204
204
|
from { transform: rotate(0deg); }
|
|
205
205
|
to { transform: rotate(360deg); }
|
|
206
206
|
}
|
|
207
|
-
`})]})},es=async(t,e)=>{const{email:r,password:s,appId:o}=t,{baseUrl:a,apiKey:i}=e;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:r,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 h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},ts=({logoUrl:t,logoLinkUrl:e,title:r="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:h,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(""),[V,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,J]=w.useState(!1),z=l?"#ffffff":"#111827",R=l?"#a1a1aa":"#6b7280",K=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",te=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const $=()=>J(window.innerWidth<768);return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}},[]);const X=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await es({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${N.name}`}),d?.(N)}catch(N){const Y=N.message||"Login failed";O({type:"error",text:Y}),u?.(N)}finally{M(!1)}},f=$=>{Z({...V,[$.target.name]:$.target.value})},k=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/forgot-password`,{email:V.email,appId:S},{headers:{"x-api-key":y}});N.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:N.data.message||"Failed to send OTP"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},x=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/reset-password`,V,{headers:{"x-api-key":y}});N.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:N.data.message||"Reset failed"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},E={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:K,border:`1px solid ${te}`,borderRadius:"10px",color:z,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.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:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:z,margin:0},children:c==="login"?r:m===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:R},children:c==="login"?s:"Follow the steps to reset your password"})]}),c==="login"&&n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:$=>U($.target.value),style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:$=>F($.target.value),style:E}),n.jsx("button",{type:"button",onClick:()=>_(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:R,cursor:"pointer"},children:P?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.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"&&n.jsxs("form",{onSubmit:m===1?k:x,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:V.email,onChange:f,style:E})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(tr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:V.otp,onChange:f,style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:V.newPassword,onChange:f,style:E})]})]})]}),n.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"}),n.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:R,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&n.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"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:g.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:R,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},rs=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const[a,i]=w.useState(!1);return w.useEffect(()=>{const l=()=>{if(typeof window>"u")return!1;try{const d=localStorage.getItem("userInfo");return!!(d&&d!=="undefined"&&d!=="null")}catch{return!1}},h=()=>i(l());return h(),typeof window<"u"&&window.addEventListener("storage",h),()=>{typeof window<"u"&&window.removeEventListener("storage",h)}},[]),a?n.jsx("span",{className:r,style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:s,height:o},children:t}):n.jsx(n.Fragment,{children:e})},ns=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const[a,i]=w.useState(!0);return w.useEffect(()=>{const l=()=>{try{const d=localStorage.getItem("userInfo");return!!(d&&d!=="undefined"&&d!=="null")}catch{return!1}},h=()=>i(!l());return h(),window.addEventListener("storage",h),()=>window.removeEventListener("storage",h)},[]),a?n.jsx("span",{className:r,style:{display:"inline-flex",alignItems:"center",verticalAlign:"middle",width:s,height:o},children:t}):n.jsx(n.Fragment,{children:e})},ss=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:h,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)},[]),!t)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":h}});g.success?(r(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"&&e()},M=()=>{switch(c){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.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:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:e,"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:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(nr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Gn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),n.jsx("span",{children:g.text})]},O))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:e,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"}),n.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:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(nr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.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}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.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"}),n.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:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.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)=>n.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:[n.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"}}),n.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx(rr,{size:18,style:{color:i.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.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."})]}),n.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:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.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:[n.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()}),n.jsx("style",{children:`
|
|
207
|
+
`})]})},es=async(t,e)=>{const{email:r,password:s,appId:o}=t,{baseUrl:a,apiKey:i}=e;if(!i)throw new Error("API key is required for login");try{const l=await W.post(`${a}/users/login`,{email:r,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 h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},ts=({logoUrl:t,logoLinkUrl:e,title:r="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:h,onSuccess:d,onError:c})=>{const{baseUrl:b,apiKey:y,appId:S}=ue(),[u,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(""),[V,Z]=w.useState({email:"",otp:"",newPassword:"",appId:S}),[I,J]=w.useState(!1),z=l?"#ffffff":"#111827",R=l?"#a1a1aa":"#6b7280",K=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",te=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)";w.useEffect(()=>{if(typeof window<"u"){const $=()=>J(window.innerWidth<768);return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}},[]);const X=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await es({email:v,password:q,appId:S},{baseUrl:b,apiKey:y});O({type:"success",text:`Welcome ${N.name}`}),d?.(N)}catch(N){const Y=N.message||"Login failed";O({type:"error",text:Y}),c?.(N)}finally{M(!1)}},f=$=>{Z({...V,[$.target.name]:$.target.value})},k=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/forgot-password`,{email:V.email,appId:S},{headers:{"x-api-key":y}});N.data.success?(A(2),O({type:"success",text:"OTP sent to your email"})):O({type:"error",text:N.data.message||"Failed to send OTP"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},x=async $=>{$.preventDefault(),M(!0),O(null);try{const N=await W.post(`${b}/users/reset-password`,V,{headers:{"x-api-key":y}});N.data.success?(O({type:"success",text:"Password reset successfully!"}),A(1),Z({email:"",otp:"",newPassword:"",appId:S}),j("login")):O({type:"error",text:N.data.message||"Reset failed"})}catch(N){O({type:"error",text:N.response?.data?.message||"Something went wrong"})}finally{M(!1)}},E={width:"100%",padding:I?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:K,border:`1px solid ${te}`,borderRadius:"10px",color:z,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.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:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[t?n.jsx("a",{href:e||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:t,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(Se,{size:40,color:a,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:z,margin:0},children:u==="login"?r:m===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:R},children:u==="login"?s:"Follow the steps to reset your password"})]}),u==="login"&&n.jsxs("form",{onSubmit:X,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:v,onChange:$=>U($.target.value),style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"login-password",type:P?"text":"password",placeholder:"Enter your password",value:q,onChange:$=>F($.target.value),style:E}),n.jsx("button",{type:"button",onClick:()=>_(!P),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:R,cursor:"pointer"},children:P?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:a,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>j("forgot"),style:{background:"none",border:"none",color:a,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.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"})]}),u==="forgot"&&n.jsxs("form",{onSubmit:m===1?k:x,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[m===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:V.email,onChange:f,style:E})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(tr,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:V.otp,onChange:f,style:E})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(we,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:R}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:V.newPassword,onChange:f,style:E})]})]})]}),n.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"}),n.jsx("button",{type:"button",onClick:()=>{j("login"),A(1)},style:{background:"none",border:"none",fontSize:"14px",color:R,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),g&&n.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"?n.jsx(de,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:g.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:R,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:a,fontWeight:600},children:"Neuctra Authix"})]})]})})},rs=({children:t,fallback:e=null,className:r,width:s,height:o,appId:a})=>{const[i,l]=w.useState(!1),[h,d]=w.useState(!0);return w.useEffect(()=>{let c=!1;const b=async()=>{try{const S=localStorage.getItem("userInfo");if(!S||S==="undefined"||S==="null"){l(!1);return}const u=JSON.parse(S);if(!u?.id){l(!1);return}const j=await fetch(`https://server.authix.neuctra.com/api/users/check-user/${u.id}?appId=${a}`,{credentials:"include"});if(!j.ok){l(!1);return}const m=await j.json();c||l(!!m?.exists)}catch{c||l(!1)}finally{c||d(!1)}};b();const y=()=>b();return window.addEventListener("storage",y),()=>{c=!0,window.removeEventListener("storage",y)}},[a]),h?null:i?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ns=({children:t,fallback:e=null,className:r,width:s,height:o})=>{const[a,i]=w.useState(()=>{if(typeof window>"u")return!0;try{const l=localStorage.getItem("userInfo");return!l||l==="undefined"||l==="null"}catch{return!0}});return w.useEffect(()=>{const l=()=>{try{const h=localStorage.getItem("userInfo");i(!h||h==="undefined"||h==="null")}catch{i(!0)}};return l(),window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]),a?n.jsx("div",{className:r,style:{display:"flex",alignItems:"center",width:s,height:o},children:t}):typeof e=="function"?e():e},ss=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,token:a,colors:i})=>{const{baseUrl:l,apiKey:h,appId:d}=ue(),[c,b]=w.useState(!1),[y,S]=w.useState(""),[u,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)},[]),!t)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":h}});g.success?(r(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&&u!=="processing"&&u!=="success"&&e()},M=()=>{switch(u){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.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:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:e,"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:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${i.error}15`,border:`1px solid ${i.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:i.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(nr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:i.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Gn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(it,{size:16}),text:"You will lose access to all services"}].map((g,O)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx("div",{style:{color:i.error,flexShrink:0},children:g.icon}),n.jsx("span",{children:g.text})]},O))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:m?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:e,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"}),n.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:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(nr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:i.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:i.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.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}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:i.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.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"}),n.jsxs("button",{onClick:P,disabled:!_||c,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!_||c?"not-allowed":"pointer",flex:m?"none":1,minWidth:m?"100%":"140px",opacity:!_||c?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!_||c?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:g=>{_&&!c&&(g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(oe,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.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)=>n.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:[n.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"}}),n.jsx("span",{style:{fontSize:"14px",color:g.active?i.textPrimary:i.textSecondary,fontWeight:g.active?500:400},children:g.text})]},O))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${i.accent}10`,borderRadius:"10px",fontSize:"14px",color:i.textSecondary},children:[n.jsx(rr,{size:18,style:{color:i.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.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:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:i.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:i.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${i.success}10`,border:`1px solid ${i.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:i.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:i.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.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."})]}),n.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:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite",color:i.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.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:[n.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()}),n.jsx("style",{children:`
|
|
208
208
|
@keyframes fadeIn {
|
|
209
209
|
from { opacity: 0; }
|
|
210
210
|
to { opacity: 1; }
|
|
@@ -258,7 +258,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
258
258
|
animation: none !important;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
`})]})},os=({isOpen:t,onClose:e,onUpdate:r,colors:s})=>{const[o,a]=w.useState(""),[i,l]=w.useState(!1),[h,d]=w.useState(!1),[
|
|
261
|
+
`})]})},os=({isOpen:t,onClose:e,onUpdate:r,colors:s})=>{const[o,a]=w.useState(""),[i,l]=w.useState(!1),[h,d]=w.useState(!1),[c,b]=w.useState({isValid:!1,message:"",type:null});if(w.useEffect(()=>{if(typeof window>"u")return;const u=()=>{d(window.innerWidth<640)};return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]),w.useEffect(()=>{if(!o.trim()){b({isValid:!1,message:"",type:null});return}try{const u=new URL(o),j=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(u.pathname);b(j?{isValid:!0,message:"Valid image URL",type:"success"}:{isValid:!1,message:"URL should point to an image file",type:"warning"})}catch{b({isValid:!1,message:"Please enter a valid URL",type:"error"})}},[o]),!t)return null;const y=async()=>{if(!(!o||!c.isValid)){l(!0);try{await r(o)&&(a(""),e())}finally{l(!1)}}},S=u=>{u.target===u.currentTarget&&e()};return n.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:1e3},onClick:S,children:[n.jsxs("div",{style:{backgroundColor:s.surface,border:`1px solid ${s.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"modalSlideIn 0.3s ease-out"},className:"avatar-modal-container",children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"44px",height:"44px",borderRadius:"12px",background:`linear-gradient(135deg, ${s.accent}20, ${s.accent}40)`,display:"flex",alignItems:"center",justifyContent:"center",color:s.accent,flexShrink:0},children:n.jsx(tt,{size:22})}),n.jsx("div",{children:n.jsx("h3",{style:{color:s.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Update Avatar"})})]}),n.jsx("button",{onClick:e,"aria-label":"Close avatar modal",style:{background:"transparent",border:"none",color:s.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:u=>{u.currentTarget.style.backgroundColor=s.border,u.currentTarget.style.color=s.textPrimary},onMouseOut:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=s.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"avatar-url",style:{display:"flex",marginBottom:"8px",color:s.textPrimary,fontSize:"14px",fontWeight:500,alignItems:"center",gap:"6px"},children:[n.jsx(Bn,{size:16}),"Avatar URL"]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{type:"url",id:"avatar-url",placeholder:"https://example.com/your-avatar.jpg",value:o,onChange:u=>a(u.target.value),style:{width:"100%",padding:"14px 16px",paddingLeft:"44px",borderRadius:"12px",border:`1.5px solid ${c.type==="error"?s.error:c.type==="success"?s.success:s.border}`,backgroundColor:"transparent",color:s.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:u=>{u.target.style.borderColor=s.accent,u.target.style.boxShadow=`0 0 0 3px ${s.accent}20`},onBlur:u=>{u.target.style.borderColor=c.type==="error"?s.error:c.type==="success"?s.success:s.border,u.target.style.boxShadow="none"},disabled:i}),n.jsx("div",{style:{position:"absolute",left:"16px",top:"50%",transform:"translateY(-50%)",color:s.textTertiary},children:n.jsx(er,{size:18})})]}),c.message&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",fontSize:"13px",color:c.type==="success"?s.success:c.type==="error"?s.error:s.textTertiary},children:[c.type==="success"&&n.jsx(de,{size:14}),c.type==="error"&&n.jsx(le,{size:14}),c.type==="warning"&&n.jsx(le,{size:14}),c.message]})]}),o&&c.type==="success"&&n.jsxs("div",{style:{padding:"16px",backgroundColor:`${s.success}10`,border:`1px solid ${s.success}20`,borderRadius:"12px",textAlign:"center"},children:[n.jsx("p",{style:{color:s.textSecondary,fontSize:"13px",fontWeight:500,margin:"0 0 12px 0"},children:"Preview"}),n.jsx("img",{src:o,alt:"Avatar preview",style:{width:"80px",height:"80px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${s.success}40`,margin:"0 auto"},onError:u=>{u.currentTarget.style.display="none"}})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:h?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch",marginTop:"24px"},children:[n.jsx("button",{onClick:e,disabled:i,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${s.border}`,background:"transparent",color:s.textPrimary,fontSize:"14px",fontWeight:500,cursor:i?"not-allowed":"pointer",flex:h?"none":1,minWidth:h?"100%":"120px",opacity:i?.6:1,transition:"all 0.2s ease"},onMouseOver:u=>{i||(u.currentTarget.style.backgroundColor=s.border,u.currentTarget.style.transform="translateY(-1px)")},onMouseOut:u=>{i||(u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.transform="translateY(0)")},children:"Cancel"}),n.jsx("button",{onClick:y,disabled:i||!c.isValid,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:`linear-gradient(135deg, ${s.accent}, ${s.accent}E6)`,color:"#fff",fontSize:"14px",fontWeight:600,cursor:i||!c.isValid?"not-allowed":"pointer",flex:h?"none":1,minWidth:h?"100%":"140px",opacity:i||!c.isValid?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:i||!c.isValid?"none":`0 4px 12px ${s.accent}40`},onMouseOver:u=>{!i&&c.isValid&&(u.currentTarget.style.transform="translateY(-1px)",u.currentTarget.style.boxShadow=`0 6px 20px ${s.accent}60`)},onMouseOut:u=>{!i&&c.isValid&&(u.currentTarget.style.transform="translateY(0)",u.currentTarget.style.boxShadow=`0 4px 12px ${s.accent}40`)},children:i?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Updating..."]}):n.jsxs(n.Fragment,{children:[n.jsx(tt,{size:16}),"Update Avatar"]})})]})]}),n.jsx("style",{children:`
|
|
262
262
|
@keyframes modalSlideIn {
|
|
263
263
|
from {
|
|
264
264
|
opacity: 0;
|
|
@@ -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
|
-
`})]})},is=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:h}=ue(),[d,
|
|
309
|
+
`})]})},is=({isOpen:t,onClose:e,onSuccess:r,onError:s,userId:o,colors:a})=>{const{baseUrl:i,apiKey:l,appId:h}=ue(),[d,c]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState({}),[S,u]=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)},[]),!t)return null;const _=v=>{const{name:U,value:q}=v.target;c(F=>({...F,[U]:q})),b[U]&&y(F=>({...F,[U]:""}))},T=v=>{m(U=>({...U,[v]:!U[v]}))},M=()=>{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(),!!M()){u(!0);try{const{data:U}=await W.put(`${i}/users/change-password/${o}`,{appId:h,currentPassword:d.currentPassword,newPassword:d.newPassword},{headers:{"x-api-key":l}});U.success?(r(U.message||"Password updated successfully"),c({currentPassword:"",newPassword:"",confirmPassword:""}),e()):s(U.message||"Failed to update password")}catch(U){s(U.response?.data?.message||"Something went wrong")}finally{u(!1)}}},O=[{field:"currentPassword",label:"Current Password",icon:n.jsx(ot,{size:18})},{field:"newPassword",label:"New Password",icon:n.jsx(we,{size:18})},{field:"confirmPassword",label:"Confirm Password",icon:n.jsx(we,{size:18})}];return n.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:n.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:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px",gap:"12px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.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:n.jsx(we,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"18px",fontWeight:600,lineHeight:"1.4"},children:"Change Password"})})]}),n.jsx("button",{onClick:e,"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:n.jsx(Pe,{size:20})})]}),n.jsxs("form",{onSubmit:g,children:[O.map(({field:v,label:U,icon:q})=>n.jsxs("div",{style:{marginBottom:"20px",position:"relative"},children:[n.jsx("label",{htmlFor:v,style:{display:"block",marginBottom:"8px",color:a.textPrimary,fontSize:"14px",fontWeight:500,lineHeight:"1.4"},children:U}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:a.textTertiary,zIndex:2},children:q}),n.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:F=>{F.target.style.borderColor=a.accent,F.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:F=>{F.target.style.borderColor=b[v]?a.error:a.border,F.target.style.boxShadow="none"}}),n.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:F=>{F.currentTarget.style.backgroundColor=a.border,F.currentTarget.style.color=a.textPrimary},onMouseOut:F=>{F.currentTarget.style.backgroundColor="transparent",F.currentTarget.style.color=a.textTertiary},children:j[v]?n.jsx(nt,{size:18}):n.jsx(st,{size:18})})]}),b[v]&&n.jsxs("div",{style:{fontSize:"13px",color:a.error,marginTop:"6px",display:"flex",alignItems:"center",gap:"6px"},children:[n.jsx("span",{style:{fontSize:"16px"},children:"⚠"}),b[v]]})]},v)),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:A?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{type:"button",onClick:e,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"}),n.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?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Updating..."]}):"Update Password"})]})]}),n.jsx("style",{children:`
|
|
310
310
|
@keyframes spin {
|
|
311
311
|
from { transform: rotate(0deg); }
|
|
312
312
|
to { transform: rotate(360deg); }
|
|
@@ -344,7 +344,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
344
344
|
padding: 16px 12px;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
`})]})})},as=({isOpen:t,onClose:e,onVerify:r,onSendOTP:s,verifyFormData:o,setVerifyFormData:a,otpSent:i,verifying:l,user:h,colors:d,darkMode:
|
|
347
|
+
`})]})})},as=({isOpen:t,onClose:e,onVerify:r,onSendOTP:s,verifyFormData:o,setVerifyFormData:a,otpSent:i,verifying:l,user:h,colors:d,darkMode:c})=>{if(!t)return null;const b=()=>{e(),a({email:h?.email||"",otp:"",appId:o.appId})};return n.jsxs("div",{className:"modal-overlay",style:{backgroundColor:c?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.5)"},children:[n.jsxs("div",{className:"verify-email-modal",style:{backgroundColor:d.surface,border:`1px solid ${d.border}`},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{style:{color:d.textPrimary},children:"Verify Your Email"}),n.jsx("button",{onClick:b,className:"close-btn",style:{color:d.textTertiary},"aria-label":"Close verification modal",children:n.jsx(Pe,{size:20,"aria-hidden":"true"})})]}),n.jsxs("form",{className:"verify-form",onSubmit:r,children:[n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"Email"}),n.jsxs("div",{className:"input-container",children:[n.jsx(ce,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"email",value:o.email,onChange:y=>a(S=>({...S,email:y.target.value})),placeholder:"Enter your email",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"Email address"})]})]}),i&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{style:{color:d.textSecondary},children:"OTP"}),n.jsxs("div",{className:"input-container",children:[n.jsx(tr,{size:18,style:{color:d.textTertiary},"aria-hidden":"true"}),n.jsx("input",{type:"text",value:o.otp,onChange:y=>a(S=>({...S,otp:y.target.value})),placeholder:"Enter OTP",style:{backgroundColor:d.surfaceLight,color:d.textPrimary,borderColor:d.border},required:!0,"aria-required":"true","aria-label":"One-time password"})]})]}),n.jsx("div",{className:"modal-actions",children:i?n.jsxs("button",{type:"submit",disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Verifying email":"Verify email",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(de,{size:16,"aria-hidden":"true"}),l?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:s,disabled:l,className:"btn-primary",style:{background:`linear-gradient(to right, ${d.accent}, ${d.accentHover})`,opacity:l?.7:1},"aria-label":l?"Sending OTP":"Send OTP",children:[l?n.jsx(oe,{size:16,className:"spinner","aria-hidden":"true"}):n.jsx(at,{size:16,"aria-hidden":"true"}),l?"Sending...":"Send OTP"]})})]})]}),n.jsx("style",{children:`
|
|
348
348
|
.modal-overlay {
|
|
349
349
|
position: fixed;
|
|
350
350
|
top: 0;
|
|
@@ -393,7 +393,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
.close-btn:hover {
|
|
396
|
-
background-color: ${
|
|
396
|
+
background-color: ${c?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"};
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
.verify-form {
|
|
@@ -491,7 +491,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
491
491
|
animation: none;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
`})]})},ls=({token:t,user:e=null,darkMode:r=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:h,appId:d}=ue(),[u,b]=w.useState(null),[y,S]=w.useState(e),[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),[V,Z]=w.useState(!1),[I,J]=w.useState(!1),[z,R]=w.useState(null),[K,te]=w.useState(!1),[X,f]=w.useState({email:"",otp:"",appId:d}),[k,x]=w.useState(!1),[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 N=(C,H)=>{R({type:C,message:H}),setTimeout(()=>R(null),3e3)},Y=()=>{J(!0);const C=setTimeout(()=>{Z(!1),J(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=H=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(H.target)&&Y()};return V&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[V]);const ie=async()=>{if(!X.email||!/\S+@\S+\.\S+/.test(X.email)){N("error","Please enter a valid email");return}try{$(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:X.email},{headers:{"x-api-key":h,"x-app-id":d}});C.data.success?(N("success",C.data.message||"OTP sent to email!"),x(!0)):N("error",C.data.message||"Failed to send OTP")}catch(C){N("error",C.response?.data?.message||"Server error")}finally{$(!1)}},he=async C=>{if(C.preventDefault(),!X.email||!X.otp){N("error","Please fill in all fields");return}try{$(!0);const H=await W.post(`${l}/users/verify-email`,X);if(H.data.success){if(N("success",H.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:t})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),x(!1),F(!1)}else N("error",H.data.message||"Verification failed")}catch(H){N("error",H.response?.data?.message||"Something went wrong")}finally{$(!1)}},Oe=async C=>{if(!y)return!1;try{const H={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,H,{headers:{"x-api-key":h}});return G.success?(S(H),localStorage.setItem("userInfo",JSON.stringify({...H,token:t})),N("success","Avatar updated successfully!"),!0):(N("error",G.message||"Failed to update avatar"),!1)}catch(H){return console.error("Avatar update error:",H),N("error","Failed to update avatar"),!1}},us=async()=>{if(y){_(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":h}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:t})),N("success","Profile updated successfully")):N("error",C.message)}catch(C){console.error(C),N("error","Update failed")}finally{_(!1)}}},sr=async C=>{try{const{data:H}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":h}});H?.success===!0&&H?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(H){console.error("⚠️ User validation request failed:",H)}};w.useEffect(()=>{(()=>{if(e)S(e),j(!1),sr(e.id);else{const H=localStorage.getItem("userInfo");if(H){const G=JSON.parse(H);S(G),j(!1),sr(G.id)}else j(!1)}})()},[e]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const or=(C,H)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+H,lt=(G>>8&255)+H,dt=(G&255)+H;return ge=Math.min(255,Math.max(0,ge)),lt=Math.min(255,Math.max(0,lt)),dt=Math.min(255,Math.max(0,dt)),`#${(dt|lt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=r?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:or(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:or(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(c)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[n.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[n.jsx(le,{size:40,color:L.error,"aria-hidden":"true"}),n.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:Kn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Vn}];return n.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:[z&&n.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",...z.type==="success"?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:r?"#34d399":"#059669"}:{backgroundColor:r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:r?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:r?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[z.type==="success"?n.jsx(de,{size:20,"aria-hidden":"true"}):n.jsx(le,{size:20,"aria-hidden":"true"}),z.message]}),n.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:n.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:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[n.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&&n.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:n.jsx(qn,{size:20,style:{color:r?"#ffffff":"#000000"}})}),n.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[n.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"}),n.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:n.jsx(tt,{size:16,"aria-hidden":"true"})})]}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),n.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),n.jsxs("div",{style:{backgroundColor:y.isVerified?r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":r?"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?n.jsx(de,{size:16,"aria-hidden":"true"}):n.jsx(le,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),n.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?n.jsxs(n.Fragment,{children:[n.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:[n.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),n.jsxs("button",{onClick:us,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?n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(Jn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):n.jsxs(n.Fragment,{children:[n.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:[n.jsx(Yn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&n.jsxs("button",{onClick:()=>F(!0),disabled:K,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:K?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:K?.7:1,flex:u&&window.innerWidth<1024?"1":"auto"},children:[K?n.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(at,{size:14,"aria-hidden":"true"}),K?"Sending...":"Verify Email"]}),n.jsxs("div",{style:{position:"relative"},children:[n.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(!V),children:[n.jsx(Wn,{size:16,"aria-hidden":"true"}),"More Actions"]}),V&&n.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:[n.jsxs("button",{onClick:()=>{O(!0),Y()},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:[n.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&n.jsxs("button",{onClick:()=>{o(),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:r?"#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=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),n.jsxs("button",{onClick:()=>{U(!0),Y()},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=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),n.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),n.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...u&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const H=C.icon;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(H,{size:16,"aria-hidden":"true"}),C.label]}),m?n.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}):n.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:r?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(rr,{size:20,"aria-hidden":"true"}),"Security Status"]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[n.jsx(ce,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:"Email Verification"})]}),n.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?n.jsxs(n.Fragment,{children:[n.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):n.jsxs(n.Fragment,{children:[n.jsx(le,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&n.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:r?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:n.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),n.jsx(os,{isOpen:T,onClose:()=>{M(!1)},onUpdate:Oe,colors:L}),n.jsx(is,{baseUrl:l,apiKey:h,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(ss,{baseUrl:l,apiKey:h,appId:d,userId:y.id,token:t,isOpen:v,onClose:()=>U(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(as,{isOpen:q,onClose:()=>{F(!1),x(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:he,onSendOTP:ie,verifyFormData:X,setVerifyFormData:f,otpSent:k,verifying:E,user:y,colors:L,darkMode:r}),n.jsx("style",{children:`
|
|
494
|
+
`})]})},ls=({token:t,user:e=null,darkMode:r=!0,homeUrl:s,onLogout:o,onVerify:a,primaryColor:i="#00C212"})=>{const{baseUrl:l,apiKey:h,appId:d}=ue(),[c,b]=w.useState(null),[y,S]=w.useState(e),[u,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),[V,Z]=w.useState(!1),[I,J]=w.useState(!1),[z,R]=w.useState(null),[K,te]=w.useState(!1),[X,f]=w.useState({email:"",otp:"",appId:d}),[k,x]=w.useState(!1),[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 N=(C,H)=>{R({type:C,message:H}),setTimeout(()=>R(null),3e3)},Y=()=>{J(!0);const C=setTimeout(()=>{Z(!1),J(!1)},150);return()=>clearTimeout(C)};w.useEffect(()=>{const C=H=>{const G=document.querySelector(".dropdown-container");G&&!G.contains(H.target)&&Y()};return V&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[V]);const ie=async()=>{if(!X.email||!/\S+@\S+\.\S+/.test(X.email)){N("error","Please enter a valid email");return}try{$(!0);const C=await W.post(`${l}/users/send-verify-otp/${y?.id}`,{email:X.email},{headers:{"x-api-key":h,"x-app-id":d}});C.data.success?(N("success",C.data.message||"OTP sent to email!"),x(!0)):N("error",C.data.message||"Failed to send OTP")}catch(C){N("error",C.response?.data?.message||"Server error")}finally{$(!1)}},he=async C=>{if(C.preventDefault(),!X.email||!X.otp){N("error","Please fill in all fields");return}try{$(!0);const H=await W.post(`${l}/users/verify-email`,X);if(H.data.success){if(N("success",H.data.message||"Email verified!"),y){const G={...y,isVerified:!0};S(G),localStorage.setItem("userInfo",JSON.stringify({...G,token:t})),typeof a=="function"&&a(G)}f({email:"",otp:"",appId:d}),x(!1),F(!1)}else N("error",H.data.message||"Verification failed")}catch(H){N("error",H.response?.data?.message||"Something went wrong")}finally{$(!1)}},Oe=async C=>{if(!y)return!1;try{const H={...y,avatarUrl:C},{data:G}=await W.put(`${l}/users/update/${y.id}`,H,{headers:{"x-api-key":h}});return G.success?(S(H),localStorage.setItem("userInfo",JSON.stringify({...H,token:t})),N("success","Avatar updated successfully!"),!0):(N("error",G.message||"Failed to update avatar"),!1)}catch(H){return console.error("Avatar update error:",H),N("error","Failed to update avatar"),!1}},us=async()=>{if(y){_(!0);try{const{data:C}=await W.put(`${l}/users/update/${y.id}`,y,{headers:{"x-api-key":h}});C.success?(S(C.user),A(!1),localStorage.setItem("userInfo",JSON.stringify({...C.user,token:t})),N("success","Profile updated successfully")):N("error",C.message)}catch(C){console.error(C),N("error","Update failed")}finally{_(!1)}}},sr=async C=>{try{const{data:H}=await W.get(`${l}/users/check-user/${C}?appId=${d}`,{headers:{"x-api-key":h}});H?.success===!0&&H?.exists===!1&&(console.warn("❌ User does not exist on server. Clearing session..."),localStorage.removeItem("userInfo"),S(null))}catch(H){console.error("⚠️ User validation request failed:",H)}};w.useEffect(()=>{(()=>{if(e)S(e),j(!1),sr(e.id);else{const H=localStorage.getItem("userInfo");if(H){const G=JSON.parse(H);S(G),j(!1),sr(G.id)}else j(!1)}})()},[e]),w.useEffect(()=>{y?.email&&f(C=>({...C,email:y.email}))},[y?.email]);const or=(C,H)=>{let G=parseInt(C.replace("#",""),16),ge=(G>>16)+H,lt=(G>>8&255)+H,dt=(G&255)+H;return ge=Math.min(255,Math.max(0,ge)),lt=Math.min(255,Math.max(0,lt)),dt=Math.min(255,Math.max(0,dt)),`#${(dt|lt<<8|ge<<16).toString(16).padStart(6,"0")}`},L=r?{background:"#000000",surface:"#09090b",surfaceLight:"#27272a",surfaceLighter:"#3f3f46",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",accent:i,accentHover:or(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:or(i,-15),success:"#10b981",error:"#ef4444",border:"#e4e4e7",warning:"#d97706"};if(u)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center"},children:[n.jsx(oe,{size:40,color:L.accent,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}),n.jsx("p",{style:{color:L.textTertiary,margin:0},children:"Loading your profile..."})]})});if(!y)return n.jsx("div",{style:{width:"100%",minHeight:"400px",display:"flex",alignItems:"center",justifyContent:"center",color:L.textPrimary,fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",textAlign:"center"},children:[n.jsx(le,{size:40,color:L.error,"aria-hidden":"true"}),n.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:Kn},{label:"Address",value:y.address||"Not provided",name:"address",type:"text",icon:Vn}];return n.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:[z&&n.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",...z.type==="success"?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",borderColor:r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)",color:r?"#34d399":"#059669"}:{backgroundColor:r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)",borderColor:r?"rgba(239, 68, 68, 0.3)":"rgba(239, 68, 68, 0.2)",color:r?"#f87171":"#dc2626"}},role:"alert","aria-live":"polite",children:[z.type==="success"?n.jsx(de,{size:20,"aria-hidden":"true"}):n.jsx(le,{size:20,"aria-hidden":"true"}),z.message]}),n.jsx("div",{style:{maxWidth:"1200px",margin:"0 auto",width:"100%",boxSizing:"border-box"},children:n.jsxs("div",{style:{display:"grid",gap:"24px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=1024&&{gridTemplateColumns:"1fr 2fr",gap:"10px"},...c&&window.innerWidth>=768&&c&&window.innerWidth<1024&&{gap:"10px"},...c&&window.innerWidth>=600&&c&&window.innerWidth<768&&{gap:"28px"}},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",height:"100%"},children:[n.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&&n.jsx("a",{href:s||"/",target:"_self",rel:"noopener noreferrer",style:{position:"absolute",top:"18px",left:"18px"},children:n.jsx(qn,{size:20,style:{color:r?"#ffffff":"#000000"}})}),n.jsxs("div",{style:{position:"relative",display:"inline-block",marginBottom:"16px"},children:[n.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"}),n.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:n.jsx(tt,{size:16,"aria-hidden":"true"})})]}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:600,margin:"0 0 4px 0",color:L.textPrimary},children:y.name}),n.jsx("p",{style:{color:L.textTertiary,margin:"0 0 8px 0"},children:y.email}),n.jsxs("div",{style:{backgroundColor:y.isVerified?r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)":r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:y.isVerified?L.success:L.warning,border:`1px solid ${y.isVerified?r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)":r?"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?n.jsx(de,{size:16,"aria-hidden":"true"}):n.jsx(le,{size:16,"aria-hidden":"true"}),y.isVerified?"Email Verified":"Not Verified"]})]}),n.jsx("nav",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:m?n.jsxs(n.Fragment,{children:[n.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:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Pe,{size:16,"aria-hidden":"true"}),"Cancel"]}),n.jsxs("button",{onClick:us,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:c&&window.innerWidth<1024?"1":"auto"},children:[P?n.jsx(oe,{size:16,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(Jn,{size:16,"aria-hidden":"true"}),P?"Saving...":"Save Changes"]})]}):n.jsxs(n.Fragment,{children:[n.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:c&&window.innerWidth<1024?"1":"auto"},children:[n.jsx(Yn,{size:16,"aria-hidden":"true"}),"Edit Profile"]}),!y.isVerified&&n.jsxs("button",{onClick:()=>F(!0),disabled:K,style:{background:"linear-gradient(to right, #fbbf24, #f59e0b)",color:"white",padding:"10px 20px",borderRadius:"6px",border:"none",cursor:K?"not-allowed":"pointer",transition:"all 0.2s ease",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",minHeight:"36px",opacity:K?.7:1,flex:c&&window.innerWidth<1024?"1":"auto"},children:[K?n.jsx(oe,{size:14,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"}):n.jsx(at,{size:14,"aria-hidden":"true"}),K?"Sending...":"Verify Email"]}),n.jsxs("div",{style:{position:"relative"},children:[n.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(!V),children:[n.jsx(Wn,{size:16,"aria-hidden":"true"}),"More Actions"]}),V&&n.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:[n.jsxs("button",{onClick:()=>{O(!0),Y()},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:[n.jsx(ot,{size:14,"aria-hidden":"true"}),"Change Password"]}),o&&n.jsxs("button",{onClick:()=>{o(),Y()},style:{width:"100%",padding:"14px 18px",backgroundColor:"transparent",border:"none",color:r?"#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=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(it,{size:14,"aria-hidden":"true"}),"Logout"]}),n.jsxs("button",{onClick:()=>{U(!0),Y()},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=r?"rgba(239, 68, 68, 0.1)":"rgba(239, 68, 68, 0.05)"},onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[n.jsx(We,{size:14,"aria-hidden":"true"}),"Delete Account"]})]})]})]})})]}),n.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:"12px"},children:[n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(Se,{size:20,"aria-hidden":"true"}),"Personal Information"]}),n.jsx("div",{style:{display:"grid",gap:"20px",gridTemplateColumns:"1fr",...c&&window.innerWidth>=600&&{gridTemplateColumns:"1fr 1fr",gap:"20px"}},children:ps.map(C=>{const H=C.icon;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsxs("label",{style:{color:L.textTertiary,fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(H,{size:16,"aria-hidden":"true"}),C.label]}),m?n.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}):n.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:r?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},children:C.value})]},C.name)})})]}),n.jsxs("section",{style:{backgroundColor:L.surface,borderRadius:"16px",padding:"30px 24px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},children:[n.jsxs("h2",{style:{fontSize:"20px",fontWeight:600,margin:"0 0 24px 0",color:L.textSecondary,display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(rr,{size:20,"aria-hidden":"true"}),"Security Status"]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:L.textSecondary},children:[n.jsx(ce,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:"Email Verification"})]}),n.jsx("div",{style:{padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px",...y.isVerified?{backgroundColor:r?"rgba(16, 185, 129, 0.1)":"rgba(16, 185, 129, 0.05)",color:L.success,border:`1px solid ${r?"rgba(16, 185, 129, 0.3)":"rgba(16, 185, 129, 0.2)"}`}:{backgroundColor:r?"rgba(245, 158, 11, 0.1)":"rgba(245, 158, 11, 0.05)",color:L.warning,border:`1px solid ${r?"rgba(245, 158, 11, 0.3)":"rgba(245, 158, 11, 0.2)"}`}},children:y.isVerified?n.jsxs(n.Fragment,{children:[n.jsx(de,{size:16,"aria-hidden":"true"}),"Verified"]}):n.jsxs(n.Fragment,{children:[n.jsx(le,{size:16,"aria-hidden":"true"}),"Not Verified"]})})]}),!y.isVerified&&n.jsx("div",{style:{padding:"12px",borderRadius:"8px",backgroundColor:r?"rgba(100, 100, 100, 0.1)":"rgba(0, 0, 0, 0.05)"},children:n.jsx("p",{style:{color:L.textTertiary,fontSize:"12px",margin:0},children:"Verify your email to unlock all features and enhance your account security."})})]})]})]})]})}),n.jsx(os,{isOpen:T,onClose:()=>{M(!1)},onUpdate:Oe,colors:L}),n.jsx(is,{baseUrl:l,apiKey:h,appId:d,userId:y.id,isOpen:g,onClose:()=>O(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(ss,{baseUrl:l,apiKey:h,appId:d,userId:y.id,token:t,isOpen:v,onClose:()=>U(!1),onSuccess:C=>N("success",C),onError:C=>N("error",C),colors:L}),n.jsx(as,{isOpen:q,onClose:()=>{F(!1),x(!1),f({email:y?.email||"",otp:"",appId:d})},onVerify:he,onSendOTP:ie,verifyFormData:X,setVerifyFormData:f,otpSent:k,verifying:E,user:y,colors:L,darkMode:r}),n.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
|
-
`})]})},ds=({darkMode:t=!0,primaryColor:e="#3b82f6",onLogout:r,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:h=!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),[V,Z]=w.useState(!1),[I,J]=w.useState(!1);w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{J(window.innerWidth<768)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]),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)}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");M($)}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 x=()=>{if(!P||!F.current)return;const E=F.current.getBoundingClientRect(),$=window.innerWidth,N=window.innerHeight,Y=280,ie=$-E.right,he=E.left;N-E.bottom;const Oe=ie>=Y||ie>he;Z(Oe)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const x=N=>{q.current&&!q.current.contains(N.target)&&!F.current?.contains(N.target)&&_(!1)},E=N=>{N.key==="Escape"&&_(!1)},$=()=>{P&&_(!1)};return P&&(document.addEventListener("mousedown",x),document.addEventListener("keydown",E),window.addEventListener("scroll",$)),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",E),window.removeEventListener("scroll",$)}},[P]);const z=t?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:e,accentHover:`${e}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:e,accentHover:`${e}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",[V?"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"}},K=async()=>{U(null),O(!0);try{const x=localStorage.getItem("userInfo");if(x){const E=JSON.parse(x);M(E)}else o&&M(o)}catch(x){console.error("Retry failed:",x),U("Invalid user data"),localStorage.removeItem("userInfo"),M(null)}finally{O(!1)}},te=(x,E)=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),E())},X=()=>i||T?.profileUrl,f=()=>{const x=X();x&&window.open(x,"_self","noopener,noreferrer")},k=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return n.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?n.jsx("div",{ref:F,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?n.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:x=>{const E=x.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):n.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"})}):n.jsxs("div",{ref:F,style:R.avatarButton,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover,x.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.surface,x.currentTarget.style.boxShadow="none"},onBlur:x=>{x.currentTarget.style.outline="none"},children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:x=>{const E=x.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):n.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&n.jsxs("div",{style:R.userInfo,children:[n.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&n.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),n.jsx(Fn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&n.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?n.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:x=>{const E=x.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):n.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"}),n.jsxs("div",{style:R.dropdownUserInfo,children:[n.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),n.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),n.jsxs("div",{style:R.dropdownSection,children:[h&&X()&&n.jsxs("button",{style:R.menuItem,onClick:f,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,f),role:"menuitem",tabIndex:0,children:[n.jsx(Se,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&n.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,k),role:"menuitem",tabIndex:0,children:[n.jsx(Xn,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:y})]}),u&&T.profileUrl&&n.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[n.jsx(ce,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:S})]})]}),n.jsx("div",{style:R.dropdownSection,children:n.jsxs("button",{style:R.logoutButton,onClick:r,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,r),role:"menuitem",tabIndex:0,children:[n.jsx(it,{style:{...R.icon,color:z.error},"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:c})]})})]}):n.jsxs("div",{style:R.errorState,role:"alert",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(le,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&n.jsx("button",{style:R.retryButton,onClick:K,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.accentHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.accent},children:"Try Again"})]})})]})},cs=({user:t,darkMode:e=!0,primaryColor:r="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ue(),[l,h]=w.useState({email:t?.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=e?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#d97706"};w.useEffect(()=>{t?.email&&h(g=>({...g,email:t.email}))},[t?.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/${t?.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&&t){const v={...t,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),u(!1),h({email:t.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 n.jsxs("form",{onSubmit:_,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&n.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"?n.jsx(de,{size:16}):n.jsx(le,{size:16}),S.message]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"Email"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"email",value:l.email,onChange:g=>h(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"text",value:l.otp,onChange:g=>h(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),n.jsx("div",{style:{display:"flex",gap:12},children:d?n.jsxs("button",{type:"submit",disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:P,disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=On,Q.ReactEmailVerification=cs,Q.ReactSignedIn=rs,Q.ReactSignedOut=ns,Q.ReactUserButton=ds,Q.ReactUserLogin=ts,Q.ReactUserProfile=ls,Q.ReactUserSignUp=Qn,Q.getSdkConfig=ue,Q.setSdkConfig=Zn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
|
582
|
+
`})]})},ds=({darkMode:t=!0,primaryColor:e="#3b82f6",onLogout:r,varient:s="classic",propUser:o,className:a="",profileUrl:i,settingsUrl:l,showProfileMenuItem:h=!0,showSettingsMenuItem:d=!0,showViewProfileMenuItem:c=!0,profileLabel:b="My Profile",settingsLabel:y="Settings",viewProfileLabel:S="View Profile",logoutLabel:u="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),[V,Z]=w.useState(!1),[I,J]=w.useState(!1);w.useEffect(()=>{if(typeof window>"u")return;const x=()=>{J(window.innerWidth<768)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]),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)}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");M($)}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 x=()=>{if(!P||!F.current)return;const E=F.current.getBoundingClientRect(),$=window.innerWidth,N=window.innerHeight,Y=280,ie=$-E.right,he=E.left;N-E.bottom;const Oe=ie>=Y||ie>he;Z(Oe)};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[P]),w.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const x=N=>{q.current&&!q.current.contains(N.target)&&!F.current?.contains(N.target)&&_(!1)},E=N=>{N.key==="Escape"&&_(!1)},$=()=>{P&&_(!1)};return P&&(document.addEventListener("mousedown",x),document.addEventListener("keydown",E),window.addEventListener("scroll",$)),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",E),window.removeEventListener("scroll",$)}},[P]);const z=t?{surface:"#000000",surfaceElevated:"#000000",surfaceHover:"#262626",border:"#262626",borderLight:"#404040",textPrimary:"#ffffff",textSecondary:"#a3a3a3",textTertiary:"#737373",accent:e,accentHover:`${e}e6`,error:"#ef4444"}:{surface:"#ffffff",surfaceElevated:"#fafafa",surfaceHover:"#f5f5f5",border:"#e5e5e5",borderLight:"#f0f0f0",textPrimary:"#171717",textSecondary:"#525252",textTertiary:"#a3a3a3",accent:e,accentHover:`${e}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",[V?"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"}},K=async()=>{U(null),O(!0);try{const x=localStorage.getItem("userInfo");if(x){const E=JSON.parse(x);M(E)}else o&&M(o)}catch(x){console.error("Retry failed:",x),U("Invalid user data"),localStorage.removeItem("userInfo"),M(null)}finally{O(!1)}},te=(x,E)=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),E())},X=()=>i||T?.profileUrl,f=()=>{const x=X();x&&window.open(x,"_self","noopener,noreferrer")},k=()=>{l&&window.open(l,"_self","noopener,noreferrer")};return n.jsxs("div",{style:R.wrapper,ref:q,className:a,role:"menu","aria-label":"User menu",children:[s==="classic"?n.jsx("div",{ref:F,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",children:T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T?.name||"User"}'s avatar`,style:{width:I?"34px":"36px",height:I?"34px":"36px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${z.borderLight}`,flexShrink:0},loading:"lazy",onError:x=>{const E=x.target;E.onerror=null,E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(T?.name||"User")}`}}):n.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"})}):n.jsxs("div",{ref:F,style:R.avatarButton,onClick:()=>_(x=>!x),onKeyDown:x=>te(x,()=>_(E=>!E)),tabIndex:0,role:"button","aria-haspopup":"true","aria-expanded":P,"aria-label":"Toggle user menu",onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover,x.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.surface,x.currentTarget.style.boxShadow="none"},onBlur:x=>{x.currentTarget.style.outline="none"},children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s avatar`,style:R.avatarImage,loading:"lazy",onError:x=>{const E=x.target;E.src="https://api.dicebear.com/9.x/glass/svg?seed=Kingston"}}):n.jsx("img",{src:"https://api.dicebear.com/9.x/glass/svg?seed=Kingston",alt:"Default user avatar",style:R.avatarImage,loading:"lazy"}),!I&&n.jsxs("div",{style:R.userInfo,children:[n.jsx("div",{style:R.userName,title:T?.name,children:T?.name||"Guest"}),T?.email&&n.jsx("div",{style:R.userEmail,title:T.email,children:T.email})]}),n.jsx(Fn,{size:I?14:16,style:R.chevron,"aria-hidden":"true"})]}),P&&n.jsx("div",{style:R.dropdown,role:"menu","aria-label":"User options",children:g?n.jsx("div",{style:R.loadingText,role:"status","aria-live":"polite",children:"Loading user information..."}):T?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:R.userSection,children:[T?.avatarUrl?n.jsx("img",{src:T.avatarUrl,alt:`${T.name}'s profile picture`,style:R.dropdownAvatar,loading:"lazy",onError:x=>{const E=x.target;E.src=`https://api.dicebear.com/9.x/initials/svg?seed=${T.name}`}}):n.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"}),n.jsxs("div",{style:R.dropdownUserInfo,children:[n.jsx("div",{style:R.dropdownUserName,title:T.name,children:T.name}),n.jsx("div",{style:R.dropdownUserEmail,title:T.email,children:T.email})]})]}),n.jsxs("div",{style:R.dropdownSection,children:[h&&X()&&n.jsxs("button",{style:R.menuItem,onClick:f,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,f),role:"menuitem",tabIndex:0,children:[n.jsx(Se,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:b})]}),d&&l&&n.jsxs("button",{style:R.menuItem,onClick:k,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,k),role:"menuitem",tabIndex:0,children:[n.jsx(Xn,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:y})]}),c&&T.profileUrl&&n.jsxs("a",{href:T.profileUrl,target:"_self",rel:"noopener noreferrer",style:R.menuItem,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},role:"menuitem",tabIndex:0,children:[n.jsx(ce,{style:R.icon,"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:S})]})]}),n.jsx("div",{style:R.dropdownSection,children:n.jsxs("button",{style:R.logoutButton,onClick:r,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.surfaceHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent"},onKeyDown:x=>te(x,r),role:"menuitem",tabIndex:0,children:[n.jsx(it,{style:{...R.icon,color:z.error},"aria-hidden":"true"}),n.jsx("span",{style:R.menuItemText,children:u})]})})]}):n.jsxs("div",{style:R.errorState,role:"alert",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx(le,{size:16,"aria-hidden":"true"}),n.jsx("span",{children:v||"Not signed in"})]}),v&&v!=="Not signed in"&&n.jsx("button",{style:R.retryButton,onClick:K,onMouseOver:x=>{x.currentTarget.style.backgroundColor=z.accentHover},onMouseOut:x=>{x.currentTarget.style.backgroundColor=z.accent},children:"Try Again"})]})})]})},cs=({user:t,darkMode:e=!0,primaryColor:r="#00C212",onVerify:s})=>{const{appId:o,baseUrl:a,apiKey:i}=ue(),[l,h]=w.useState({email:t?.email||"",otp:"",appId:o}),[d,c]=w.useState(!1),[b,y]=w.useState(!1),[S,u]=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=e?{surface:"#09090b",surfaceLight:"#27272a",textPrimary:"#ffffff",textSecondary:"#d4d4d8",textTertiary:"#a1a1aa",border:"#27272a",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#f59e0b"}:{surface:"#fafafa",surfaceLight:"#f4f4f5",textPrimary:"#18181b",textSecondary:"#52525b",textTertiary:"#71717a",border:"#e4e4e7",accent:r,accentHover:j(r,-15),success:j(r,0),warning:"#d97706"};w.useEffect(()=>{t?.email&&h(g=>({...g,email:t.email}))},[t?.email]);const A=(g,O)=>{u({type:g,message:O}),setTimeout(()=>u(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/${t?.id}`,{email:l.email},{headers:{"x-api-key":i,"x-app-id":o}});g.data.success?(A("success",g.data.message||"OTP sent!"),c(!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&&t){const v={...t,isVerified:!0};s?.(v),A("success",O.data.message||"Email verified!"),c(!1),h({email:t.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 n.jsxs("form",{onSubmit:_,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:16,backgroundColor:m.surface,padding:24,borderRadius:16,border:`1px solid ${m.border}`},children:[S&&n.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"?n.jsx(de,{size:16}):n.jsx(le,{size:16}),S.message]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"Email"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ce,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"email",value:l.email,onChange:g=>h(O=>({...O,email:g.target.value})),placeholder:"Enter your email",style:T,required:!0})]})]}),d&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx("label",{style:{color:m.textSecondary},children:"OTP"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(ot,{size:18,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:m.textTertiary,pointerEvents:"none"}}),n.jsx("input",{type:"text",value:l.otp,onChange:g=>h(O=>({...O,otp:g.target.value})),placeholder:"Enter OTP",style:T,required:!0})]})]}),n.jsx("div",{style:{display:"flex",gap:12},children:d?n.jsxs("button",{type:"submit",disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(de,{size:16}),b?"Verifying...":"Verify Email"]}):n.jsxs("button",{type:"button",onClick:P,disabled:b,style:M(b),children:[b?n.jsx(oe,{size:16,className:"spinner"}):n.jsx(at,{size:16}),b?"Sending...":"Send OTP"]})})]})};Q.NeuctraAuthix=On,Q.ReactEmailVerification=cs,Q.ReactSignedIn=rs,Q.ReactSignedOut=ns,Q.ReactUserButton=ds,Q.ReactUserLogin=ts,Q.ReactUserProfile=ls,Q.ReactUserSignUp=Qn,Q.getSdkConfig=ue,Q.setSdkConfig=Zn,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|