@zango-core/crm-framework 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-duration:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}.mx-auto{margin-inline:auto}.mb-\\[18px\\]{margin-bottom:18px}.\\!line-clamp-2{-webkit-line-clamp:2!important;-webkit-box-orient:vertical!important;display:-webkit-box!important;overflow:hidden!important}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-\\[42px\\]{height:42px}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.min-h-\\[8rem\\]{min-height:8rem}.min-h-\\[300px\\]{min-height:300px}.min-h-\\[400px\\]{min-height:400px}.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-\\[150px\\]{max-width:150px}.flex-1{flex:1}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.object-cover{object-fit:cover}.\\!text-center{text-align:center!important}.text-center{text-align:center}.text-left{text-align:left}.text-\\[12px\\]{font-size:12px}.text-\\[40px\\]{font-size:40px}.leading-none{--tw-leading:1;line-height:1}.break-all{word-break:break-all}.text-\\[var\\(--color-brand-500\\,\\#5048ED\\)\\]{color:var(--color-brand-500,#5048ed)}.text-\\[var\\(--color-gray-700\\,\\#414651\\)\\]{color:var(--color-gray-700,#414651)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.duration-300{--tw-duration:.3s;transition-duration:.3s}.last\\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus\\:shadow-\\[0_0_0_2px_rgba\\(106\\,138\\,18\\,0\\.2\\)\\]:focus{--tw-shadow:0 0 0 2px var(--tw-shadow-color,#6a8a1233);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.brand-500{background-color:var(--color-brand-500)!important}.border-brand-500{border-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-tab-active{border-bottom-width:2px!important;border-bottom-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-ink-bar{background-color:var(--color-brand-500)!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}.wide-sidebar{width:244px;display:flex;height:100dvh;font-size:14px;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-style:normal;font-weight:500;border-right:1px solid #D5D7DA;flex-direction:column;position:relative;background-color:#fff;z-index:10}.frame-logo-container{height:64px;display:flex;align-items:center;gap:8px;padding:20px}.frame-logo-container a{display:flex;align-items:center;text-decoration:none}.frame-logo-container img{height:28px;width:auto}.frame-menu-container{display:flex;flex-direction:column;gap:16px;flex-grow:1;overflow-y:scroll;padding:8px 12px}#wideSidebarMenu{color:#414651;padding:0;flex-grow:1;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0}#wideSidebarMenu li{list-style:none;padding:12px;border-radius:6px;overflow:hidden;color:#414651;transition:all .3s ease-in-out;cursor:pointer}#wideSidebarMenu .menu-item{display:flex;align-items:center;gap:8px}#wideSidebarMenu li a{display:flex;align-items:center;color:var(--color-gray-700, #414651);text-decoration:none;padding:12px;margin:-12px;width:calc(100% + 24px);gap:8px;font-size:14px;font-weight:500;transition:all .3s ease-in-out}#wideSidebarMenu li:hover,#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED)}#wideSidebarMenu li:hover a,#wideSidebarMenu li:hover .menu-title{color:var(--color-brand-500, #5048ED)!important}#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED);font-weight:600}#wideSidebarMenu li.active .menu-title,#wideSidebarMenu li.active a{color:var(--color-brand-500, #5048ED)}.navbar-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.navbar-icon svg{width:16px;height:16px}.navbar-icon img{width:16px;height:16px;object-fit:contain}.navbar-icon-emoji{font-size:16px;line-height:1;width:auto;min-width:16px}#wideSidebarMenu .menu-title{flex-grow:1;color:var(--color-gray-700, #414651)}#wideSidebarMenu .menu-list-item{cursor:pointer}#wideSidebarMenu .downIcon{display:flex;justify-content:center;align-items:center;height:100%;transition:transform .3s ease}#wideSidebarMenu li.active .downIcon{transform:rotate(180deg)}#wideSidebarMenu .submenu-accordion-item{color:#414651}#wideSidebarMenu .submenu-list{padding:0;max-height:0;overflow:hidden;opacity:0;list-style:none;margin:0;border-radius:8px;transition:all .3s cubic-bezier(.16,1,.3,1);transform:translateY(-4px)}#wideSidebarMenu .submenu-list.active{padding:9px 0;max-height:500px;opacity:1;transform:translateY(0)}#wideSidebarMenu .submenu-list-item{padding:10px 36px;position:relative;color:var(--color-gray-700, #414651)}#wideSidebarMenu .submenu-list-item a{display:flex;align-items:center;color:inherit;text-decoration:none;padding:10px 36px;margin:-10px -36px;width:calc(100% + 72px);gap:8px;transition:all .3s ease-in-out}#wideSidebarMenu .submenu-list-item a .each-submenu-label{color:var(--color-gray-700, #414651);font-size:12px}#wideSidebarMenu .submenu-list-item a .each-submenu-label.active{color:var(--color-brand-500, #5048ED)}#wideSidebarMenu .submenu-item-icon{display:none}#wideSidebarMenu .submenu-item-icon-container{width:16px}#wideSidebarMenu .submenu-item-icon.active{display:block}.submenu-item-icon-container{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.submenu-dot{display:none}.submenu-dot.active{display:inline-block;width:14px;height:10px}.navbar-menu-container::-webkit-scrollbar{width:4px}.navbar-menu-container::-webkit-scrollbar-track{background:transparent}.navbar-menu-container::-webkit-scrollbar-thumb{background:var(--color-gray-300, #dde2e5);border-radius:2px}.navbar-menu-container::-webkit-scrollbar-thumb:hover{background:var(--color-gray-400, #d5d7da)}@media(max-width:768px){.navbar,.wide-sidebar{position:fixed;left:-244px;z-index:1000}.navbar.open,.wide-sidebar.open{left:0}}.user-profile-drawer{position:fixed;top:0;right:-100%;width:100%;height:100vh;background-color:var(--zango-gray-50, #F9FAFB);transition:right .3s ease-in-out;z-index:1300;overflow:hidden;display:flex;flex-direction:column}.user-profile-drawer *{box-sizing:border-box}.user-profile-drawer.open{right:0}.profile-header-gradient{height:100px;background:linear-gradient(135deg,var(--color-brand-500, #5048ED) 0%,#7C3AED 50%,#EC4899 100%);position:relative}.profile-close-btn{position:absolute;top:16px;right:16px;background:#fff3;border:none;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;color:#fff}.profile-close-btn:hover{background:#ffffff4d}.profile-info-section{background:#fff;padding:0 40px 20px;text-align:center;position:relative;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);width:100%;box-sizing:border-box}.profile-avatar-container{margin-top:-40px;margin-bottom:12px}.profile-avatar-circle{width:80px;height:80px;background:var(--zango-gray-100, #F3F4F6);border-radius:50%;display:inline-flex;align-items:center;justify-content:center;border:4px solid #FFFFFF;box-shadow:0 4px 6px #0000001a;position:relative}.profile-avatar-circle svg{width:40px;height:40px}.profile-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.profile-avatar-edit{position:absolute;bottom:-4px;right:-4px;background:var(--color-brand-500, #5048ED);color:#fff;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;border:2px solid white;box-shadow:0 2px 4px #0000001a}.profile-avatar-edit:hover{background:var(--color-brand-600, #433BD9);transform:scale(1.1)}.profile-avatar-edit svg{width:14px;height:14px}.profile-initials{font-size:32px;font-weight:600;color:var(--zango-gray-700, #4B5563)}.profile-name-section{margin-bottom:0}.profile-user-name{font-size:20px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 2px}.profile-user-role{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.profile-user-role-badge{display:inline-flex;align-items:center;gap:6px;background:linear-gradient(135deg,#5048ed1a,#7c3aed1a,#ec48991a);color:var(--color-brand-500, #5048ED);padding:6px 14px;border-radius:20px;font-size:13px;font-weight:500;border:1px solid rgba(80,72,237,.2);margin-top:6px;transition:all .2s ease}.profile-user-role-badge:hover{background:linear-gradient(135deg,#5048ed26,#7c3aed26,#ec489926);border-color:#5048ed4d;transform:translateY(-1px);box-shadow:0 2px 8px #5048ed33}.profile-user-role-badge svg{width:14px;height:14px;stroke:var(--color-brand-500, #5048ED);flex-shrink:0}.profile-user-role-badge span{letter-spacing:.3px;text-transform:capitalize}.profile-main-content{flex:1;overflow-y:auto;overflow-x:hidden;padding:20px;display:flex;justify-content:center;width:100%;box-sizing:border-box}.profile-content-wrapper{background:#fff;border-radius:12px;padding:20px;width:100%;max-width:700px;margin:0 auto;box-shadow:0 1px 3px #0000001a;box-sizing:border-box;height:fit-content}.profile-tabs{display:flex;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);margin-bottom:20px;width:100%;box-sizing:border-box}.profile-tab{padding:10px 20px;background:none;border:none;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);cursor:pointer;position:relative;transition:all .2s ease}.profile-tab:hover{color:var(--zango-gray-700, #4B5563)}.profile-tab.active{color:var(--color-brand-500, #5048ED)}.profile-tab.active:after{content:"";position:absolute;bottom:-1px;left:0;right:0;height:2px;background:var(--color-brand-500, #5048ED)}.profile-tab-content{padding:0;width:100%;box-sizing:border-box}.account-section{display:flex;flex-direction:column;gap:24px}.profile-photo-edit:hover{background:var(--color-brand-600, #433BD9)}.profile-field-section{border-bottom:1px solid var(--zango-gray-300, #E5E7EB);padding-bottom:16px}.profile-field-section:last-child{border-bottom:none}.profile-field-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.profile-field-label{font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280)}.profile-field-value{font-size:16px;color:var(--zango-gray-900, #111827);margin:0;display:flex;align-items:center;gap:8px}.profile-field-value.readonly{color:var(--zango-gray-600, #6B7280)}.profile-field-value .empty-value{color:#9ca3af;font-style:italic}.profile-field-value .field-icon{flex-shrink:0}.profile-field-edit-btn{background:none;border:none;color:var(--color-brand-500, #5048ED);font-size:14px;font-weight:500;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all .2s ease}.profile-field-edit-btn:hover{background:#5048ed1a}.profile-inline-form{width:100%}.profile-inline-actions{display:flex;gap:8px;margin-top:12px;justify-content:flex-end}.profile-save-btn{padding:8px 16px;font-size:14px;font-weight:500;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:6px;cursor:pointer;transition:all .2s ease}.profile-save-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-save-btn:disabled{opacity:.6;cursor:not-allowed}.roles-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}.role-item{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB;transition:all .2s ease}.role-item:hover{background:var(--zango-gray-100, #F3F4F6);border-color:#d1d5db}.role-item.active{background:#5048ed0d;border-color:var(--color-brand-500, #5048ED)}.role-info{display:flex;align-items:center;gap:10px}.role-info svg{width:16px;height:16px;stroke:#6b7280;flex-shrink:0}.role-item.active .role-info svg{stroke:var(--color-brand-500, #5048ED)}.role-name{font-size:14px;color:#374151;font-weight:500}.role-badge{font-size:12px;font-weight:500;color:var(--color-brand-500, #5048ED);background:#5048ed1a;padding:4px 12px;border-radius:12px}.role-switch-btn{font-size:12px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;padding:4px 12px;border-radius:6px;border:1px solid #E5E7EB;cursor:pointer;transition:all .2s ease}.role-switch-btn:hover{color:var(--color-brand-500, #5048ED);border-color:var(--color-brand-500, #5048ED);background:#5048ed0d}.security-section{display:flex;flex-direction:column;gap:24px}.security-block{border:1px solid #E5E7EB;border-radius:8px;padding:20px}.security-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px}.security-title{font-size:16px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 4px}.security-subtitle{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.toggle-btn{padding:8px 16px;font-size:14px;font-weight:500;border:1px solid #E5E7EB;border-radius:6px;background:#fff;color:#374151;cursor:pointer;transition:all .2s ease}.toggle-btn:hover{background:#f9fafb}.toggle-btn.enabled{background:var(--color-brand-500, #5048ED);color:#fff;border-color:var(--color-brand-500, #5048ED)}.toggle-btn.enabled:hover{background:var(--color-brand-600, #433BD9)}.password-form{margin-top:16px}.sessions-list{display:flex;flex-direction:column;gap:12px;margin-top:16px}.session-item{display:flex;justify-content:space-between;align-items:center;padding:16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB}.session-info{display:flex;align-items:center;gap:16px;flex:1}.session-device{display:flex;align-items:center;gap:12px}.session-device svg{color:var(--zango-gray-600, #6B7280)}.session-device-header{display:flex;align-items:center;gap:8px;margin-bottom:2px}.session-device-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0}.session-status-tag{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.session-status-tag.current{background:#22c55e1a;color:#16a34a;border:1px solid rgba(34,197,94,.2)}.session-status-tag.inactive{background:transparent;padding:0;border:none}.logout-tag-btn{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px;background:#ef44441a;color:#dc2626;border:1px solid rgba(239,68,68,.2);cursor:pointer;transition:all .2s ease}.logout-tag-btn:hover{background:#ef444426;border-color:#ef44444d}.logout-tag-btn-ghost{background:#9ca3af1a;color:#6b7280;border:1px solid rgba(156,163,175,.2)}.logout-tag-btn-ghost:hover{background:#9ca3af26;border-color:#9ca3af4d;color:#4b5563}.session-details{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-time{text-align:right}.session-time-info{display:flex;flex-direction:column;gap:4px;align-items:flex-end}.session-start-time{font-size:12px;color:var(--zango-gray-500, #9CA3AF);margin:0;font-weight:500}.session-last-active{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-logout-btn{padding:6px 12px;font-size:12px;font-weight:500;border:1px solid #E5E7EB;border-radius:4px;background:#fff;color:#dc2626;cursor:pointer;transition:all .2s ease}.session-logout-btn:hover{background:#fef2f2;border-color:#dc2626}.session-current{font-size:12px;color:var(--zango-gray-600, #6B7280);font-style:italic}.no-sessions{text-align:center;color:var(--zango-gray-600, #6B7280);font-size:14px;padding:20px}.logout-all-btn{width:100%;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease;margin-top:16px}.logout-all-btn:hover{background:#fef2f2}.tokens-list{margin-top:16px}.token-item{display:flex;align-items:center;justify-content:space-between;padding:16px;background:#f9fafb;border-radius:8px;margin-bottom:12px;transition:all .2s ease}.token-item:hover{background:var(--zango-gray-100, #F3F4F6)}.token-info{display:flex;align-items:center;justify-content:space-between;width:100%;gap:16px}.token-details{display:flex;align-items:center;gap:12px}.token-details svg{color:var(--zango-gray-600, #6B7280)}.token-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 4px}.token-created{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.token-revoke-btn{padding:6px 16px;font-size:13px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #FEE2E2;border-radius:6px;cursor:pointer;transition:all .2s ease}.token-revoke-btn:hover{background:#fef2f2;border-color:#fecaca}.no-tokens{text-align:center;padding:32px 16px;color:var(--zango-gray-600, #6B7280)}.no-tokens p{margin:0 0 8px;font-size:14px}.no-tokens-hint{font-size:12px;color:#9ca3af}.profile-form-group{margin-bottom:16px;width:100%;box-sizing:border-box}.profile-form-label{display:block;font-size:14px;font-weight:500;color:#374151;margin-bottom:6px}.profile-form-input{width:100%;padding:10px 14px;font-size:14px;border:1px solid #E5E7EB;border-radius:8px;background:#fff;transition:all .2s ease;box-sizing:border-box}.profile-form-input:focus{outline:none;border-color:var(--color-brand-500, #5048ED);background:#fff;box-shadow:0 0 0 3px #5048ed1a}.profile-form-input::placeholder{color:#9ca3af}.profile-form-error{color:#ef4444;font-size:12px;margin-top:4px}.profile-form-actions{display:flex;gap:12px;margin-top:20px;justify-content:flex-end}.profile-cancel-btn{padding:10px 20px;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;border:1px solid #E5E7EB;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-cancel-btn:hover{background:#f9fafb;color:var(--zango-gray-700, #4B5563)}.profile-submit-btn{padding:10px 20px;font-size:14px;font-weight:600;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-submit-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-submit-btn:disabled{opacity:.6;cursor:not-allowed}.profile-alert{padding:12px 16px;border-radius:8px;margin-bottom:20px;font-size:14px;display:flex;align-items:center;gap:8px}.profile-alert.error{background:#fee2e2;color:#dc2626;border:1px solid #FECACA}.profile-alert.success{background:#5048ed1a;color:var(--color-brand-500, #5048ED);border:1px solid rgba(80,72,237,.2)}.password-requirements{background:#f9fafb;border:1px solid #E5E7EB;border-radius:8px;padding:16px;margin:16px 0;width:100%;box-sizing:border-box}.password-requirement{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--zango-gray-600, #6B7280);margin-bottom:8px;transition:color .2s ease}.password-requirement:last-child{margin-bottom:0}.password-requirement svg{flex-shrink:0}.password-requirement svg path{fill:#9ca3af;transition:fill .2s ease}.password-requirement.met{color:var(--color-brand-500, #5048ED)}.password-requirement.met svg path{fill:var(--color-brand-500, #5048ED)}.welcome-banner{background:linear-gradient(135deg,#5048ed0d,#7c3aed0d,#ec48990d);border:1px solid rgba(80,72,237,.2);border-radius:12px;padding:24px;text-align:center;margin-bottom:24px}.welcome-banner svg{margin-bottom:16px}.welcome-banner h3{font-size:18px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 8px}.welcome-banner p{font-size:14px;color:var(--zango-gray-600, #6B7280);max-width:400px;margin:0 auto}.empty-value{color:#9ca3af;font-style:italic;font-weight:400}.field-icon{width:16px;height:16px;flex-shrink:0}.profile-field-section{transition:background .2s ease;padding:0 0 16px}.profile-field-section:hover{background:#00000003}.logout-section{margin-top:20px;padding-top:20px;border-top:1px solid #E5E7EB}.logout-button{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease}.logout-button:hover{background:#fef2f2;color:#b91c1c;border-color:#b91c1c}.logout-button svg{width:16px;height:16px;stroke:currentColor}@media(max-width:768px){.profile-main-content{padding:16px}.profile-content-wrapper{padding:16px;max-width:100%}.profile-tabs{margin:0 -16px 20px;padding:0 16px}.profile-tab{flex:1;text-align:center}.session-info{flex-direction:column;align-items:flex-start;gap:8px}.session-item{flex-direction:column;align-items:flex-start;gap:12px}}.password-history-list{margin-top:16px}.password-history-item{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--zango-gray-50, #F9FAFB);border-radius:8px;margin-bottom:12px;transition:all .2s ease}.password-history-item:last-child{margin-bottom:0}.password-history-item:hover{background:var(--zango-gray-100, #F3F4F6)}.history-icon{width:40px;height:40px;background:var(--zango-brand-100, rgba(80, 72, 237, .1));border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.history-icon svg{color:var(--zango-brand-600, #5048ED)}.history-details{flex:1}.history-text{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 2px}.history-time{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.no-password-history{text-align:center;padding:24px 16px;color:var(--zango-gray-600, #6B7280)}.no-password-history p{margin:0;font-size:14px}.password-disabled-badge{display:inline-block;margin-left:8px;padding:2px 8px;font-size:11px;font-weight:600;color:var(--zango-error-600, #DC2626);background:var(--zango-error-100, #FEE2E2);border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.password-expired{color:var(--zango-error-600, #DC2626);font-weight:600}.token-type{font-size:12px;color:var(--color-brand-500, #5048ED);margin:2px 0 4px;font-weight:500}.token-expiry{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:4px 0 0}.header-container{height:56px;width:100%;background:#fff;justify-content:flex-end;border-bottom:1px solid #E9EAEB;align-items:center;padding:0 20px;display:flex;position:relative}.topbar-content{width:100%;display:flex;justify-content:space-between;align-items:center}.topbar-left,.topbar-right{display:flex;align-items:center;gap:16px}.dropdown{position:relative}.profile-dropdown-menu-button{display:flex;gap:20px;align-items:center;cursor:pointer;padding:8px 12px;border-radius:8px;transition:background-color .2s ease}.profile-dropdown-menu-button:hover{background-color:var(--color-gray-100, #f5f5f5)}.profile-info-wrapper{display:flex;align-items:center;gap:8px}.profile-avatar{width:24px;height:24px;border-radius:50%;overflow:hidden}.profile-name{font-size:14px;font-weight:500;color:var(--color-Gray-900, #252b37)}.dropdown-arrow{transition:transform .2s cubic-bezier(.16,1,.3,1)}.dropdown-arrow.open{transform:rotate(180deg)}.profile-dropdown-menu{border-radius:8px;border:1px solid var(--color-gray-200, #E9EAEB);background:var(--color-background, #FFFFFF);box-shadow:0 12px 12px -4px #0a0d1214,0 -4px 6px -2px #0a0d120f,0 -2px 2px -2px #0a0d120d;min-width:158px;position:absolute;right:0;top:calc(100% + 10px);z-index:1000;list-style:none;margin:0;padding:0;opacity:0;visibility:hidden;transform:translateY(-8px) scale(.95);transition:all .2s cubic-bezier(.16,1,.3,1);overflow:hidden}.profile-dropdown-menu *{cursor:pointer!important}.profile-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0) scale(1)}.profile-dropdown-menu li{margin:0}.dropdown-item{display:flex;align-items:center;padding:8px 12px;color:#717680;text-decoration:none;font-size:14px;transition:all .2s ease;cursor:pointer!important;background:none;border:none;width:100%;text-align:left;gap:8px}.dropdown-item:hover{background-color:#f5f5f5;color:#252b37}.profile-dropdown-menu li:first-child .dropdown-item:hover{border-top-left-radius:8px;border-top-right-radius:8px}.profile-dropdown-menu li:last-child .dropdown-item:hover{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.dropdown-item.profile-info{padding:8px 12px;cursor:pointer}.dropdown-item.profile-info:hover{background-color:transparent;cursor:pointer}.dropdown-item.profile-info.clickable:hover{background-color:var(--color-Gray-100, #f5f5f5);cursor:pointer;border-radius:4px}.user-info-content{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-role{font-weight:500;color:var(--color-Gray-900, #252b37)}.role-arrow{display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.16,1,.3,1)}.role-arrow.expanded{transform:rotate(180deg)}.profile-roles{max-height:200px;overflow-y:auto;margin:0 -16px;padding:0 16px}.profile-each-role{display:flex;align-items:center;padding:8px 12px;gap:8px;cursor:pointer;transition:all .2s ease}.profile-each-role:hover{background-color:var(--color-Gray-100, #f5f5f5)}.profile-dropdown-menu .profile-each-role:hover{border-radius:4px}.profile-each-role .label{font-size:14px;color:var(--color-Gray-700, #717680)}.profile-dropdown-divider{border:none}.profile-menu-option{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-menu-name,.profile-name{font-size:12px;font-weight:500;cursor:pointer}.flex-row{flex-direction:row!important}.justify-content-between{justify-content:space-between!important}@media(max-width:768px){.topbar{padding:0 16px}.profile-dropdown-menu{right:-16px}}.layout{width:100vw;height:100vh;overflow:hidden}.layout-wrapper{display:flex;height:100vh;background-color:var(--color-background, #ffffff)}.layout-main{display:flex;flex-direction:column;overflow:hidden;transition:width .3s ease;flex:1;position:relative}.layout-content{flex:1;overflow-y:auto;background-color:var(--color-background, #ffffff);position:relative}.layout-content:has(.content-spinner-container.active)>:not(.content-spinner-container){opacity:0;transition:opacity .2s ease-in}.layout-content>:not(.content-spinner-container){opacity:1;transition:opacity .3s ease-in}.layout-loading,.layout-error{display:flex;align-items:center;justify-content:center;height:100vh;font-size:18px;color:var(--color-Gray-700, #717680)}.layout-error{color:var(--color-error-500, #f04438)}@media(max-width:768px){.layout-content{padding:16px}.layout-main{width:100vw!important}}.content-spinner-container{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:#fff;border-radius:18px;z-index:99;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-out}.content-spinner-container.active{opacity:1;visibility:visible;pointer-events:all;transition:none}.spinner{width:64px;height:64px;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.d-flex{display:flex!important}.flex-column{flex-direction:column!important}.flex-grow-1{flex-grow:1!important}.p-0{padding:0!important}.dvh-100{height:100dvh!important}.complete-hidden-scroll-style::-webkit-scrollbar{display:none}.complete-hidden-scroll-style{-ms-overflow-style:none;scrollbar-width:none}.zango-loading{display:flex;align-items:center;justify-content:center;height:100vh;font-size:16px;color:#6d7280}.zango-no-menu{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;padding:2rem;text-align:center;color:#374151}.zango-no-menu h2{font-size:1.5rem;font-weight:600;margin-bottom:.5rem;color:#1f2937}.zango-no-menu p{font-size:1rem;color:#6b7280;margin:0;max-width:400px}*{box-sizing:border-box}body{margin:0;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#root{height:100vh}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(B,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@zango-core/crud/table"),require("@zango-core/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router-dom","@zango-core/crud/table","@zango-core/components"],s):(B=typeof globalThis<"u"?globalThis:B||self,s(B.ZangoCRMFramework={},B["react/jsx-runtime"],B.React,B.ReactRouterDOM,B.table,B.components))})(this,(function(B,s,f,H,qo,p){"use strict";const Vo="zango_app_logo_cache";class $o{constructor(){this.cacheKey=Vo}getCachedLogo(){try{const t=localStorage.getItem(this.cacheKey);if(!t)return null;const r=JSON.parse(t);return this.isCacheExpired(r.timestamp)?(this.clearCache(),null):r}catch(t){return console.error("Error reading logo cache:",t),null}}async cacheLogoUrl(t,r){if(t)try{const o=await this.generateHash(t),a=this.getCachedLogo();if(a&&a.version===o)return a.timestamp=Date.now(),localStorage.setItem(this.cacheKey,JSON.stringify(a)),a;const n=await this.fetchAndConvertToBase64(t),i={url:t,base64Data:n,version:o,timestamp:Date.now(),appName:r||"Zango CRM"};return localStorage.setItem(this.cacheKey,JSON.stringify(i)),i}catch(o){return console.error("Error caching logo:",o),{url:t,base64Data:null,version:null,timestamp:Date.now(),appName:r||"Zango CRM"}}}async fetchAndConvertToBase64(t){try{const r=t.startsWith("http")?t:`${window.location.origin}${t}`,o=await fetch(r);if(!o.ok)throw new Error(`Failed to fetch logo: ${o.status}`);const a=await o.blob();return new Promise((n,i)=>{const c=new FileReader;c.onloadend=()=>n(c.result),c.onerror=i,c.readAsDataURL(a)})}catch(r){return console.error("Error converting logo to base64:",r),null}}async generateHash(t){let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o);r=(r<<5)-r+a,r=r&r}return Math.abs(r).toString(36)}isCacheExpired(t){return Date.now()-t>864e5}clearCache(){try{localStorage.removeItem(this.cacheKey)}catch(t){console.error("Error clearing logo cache:",t)}}async needsUpdate(t){const r=this.getCachedLogo();return!!(!r||r.url!==t||this.isCacheExpired(r.timestamp))}async updateInBackground(t,r,o){try{if(!await this.needsUpdate(t))return;setTimeout(async()=>{const n=await this.cacheLogoUrl(t,r);n&&o&&o(n)},100)}catch(a){console.error("Error updating logo in background:",a)}}}const Ue=new $o,It=()=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"62",height:"20",viewBox:"0 0 62 20",fill:"none",children:[s.jsx("path",{d:"M0 15.5495L0 13.7372L5.34244 6.80918L0.527365 6.80918L0.527365 4.17101L9.53843 4.17101L9.53843 5.96037L4.19599 12.9114L9.69894 12.9114V15.5495L0 15.5495Z",fill:"var(--Colours-Base-black, #000)"}),s.jsx("path",{d:"M16.605 15.8248C15.7949 15.8248 15.0382 15.6948 14.3351 15.4348C13.6319 15.1595 13.0205 14.7695 12.5007 14.2649C11.981 13.7449 11.5759 13.1178 11.2855 12.3837C10.9951 11.6496 10.8499 10.8085 10.8499 9.86027C10.8499 8.94265 11.0027 8.11679 11.3084 7.38269C11.6142 6.6333 12.0116 6.00626 12.5007 5.50156C13.0052 4.98158 13.5784 4.58394 14.2204 4.30865C14.8624 4.03337 15.5274 3.89573 16.2152 3.89573C17.0254 3.89573 17.7285 4.03337 18.3247 4.30865C18.9361 4.58394 19.4406 4.96628 19.838 5.45568C20.2507 5.94508 20.5564 6.52624 20.7552 7.19916C20.9539 7.85679 21.0532 8.5756 21.0532 9.35558C21.0532 9.66145 21.0379 9.95203 21.0074 10.2273C20.9768 10.5026 20.9462 10.7091 20.9157 10.8467L14.1058 10.8467C14.2586 11.6726 14.5949 12.2843 15.1146 12.682C15.6497 13.0643 16.2993 13.2555 17.0636 13.2555C17.8738 13.2555 18.6916 13.0031 19.517 12.4984L20.6405 14.5401C20.0596 14.9378 19.41 15.2513 18.6916 15.4807C17.9884 15.7101 17.2929 15.8248 16.605 15.8248ZM14.0828 8.62148L18.1871 8.62148C18.1871 7.97914 18.0419 7.45916 17.7515 7.06152C17.461 6.66389 16.9719 6.46507 16.284 6.46507C15.749 6.46507 15.2751 6.64094 14.8624 6.9927C14.465 7.34445 14.2051 7.88738 14.0828 8.62148Z",fill:"currentColor"}),s.jsx("path",{d:"M26.4777 15.8248C25.8969 15.8248 25.4077 15.7331 25.0103 15.5495C24.6128 15.366 24.2918 15.1137 24.0472 14.7925C23.818 14.456 23.6498 14.0584 23.5428 13.5996C23.4358 13.1255 23.3823 12.5978 23.3823 12.0167L23.3823 0L26.7529 0L26.7529 12.1543C26.7529 12.5061 26.814 12.7508 26.9363 12.8884C27.0739 13.0261 27.2114 13.0949 27.349 13.0949C27.4254 13.0949 27.4866 13.0949 27.5324 13.0949C27.5936 13.0949 27.67 13.0796 27.7617 13.049L28.1745 15.5495C27.991 15.626 27.7541 15.6872 27.4637 15.7331C27.1885 15.7942 26.8599 15.8248 26.4777 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M34.3225 15.8248C33.6193 15.8248 33.0155 15.7178 32.5111 15.5036C32.0219 15.2895 31.6168 14.9913 31.2958 14.609C30.9901 14.2266 30.7608 13.7678 30.608 13.2325C30.4704 12.682 30.4016 12.0779 30.4016 11.4202L30.4016 6.80918L28.8424 6.80918V4.30865L30.585 4.17101L30.9748 1.14286L33.7722 1.14286V4.17101L36.5007 4.17101V6.80918L33.7722 6.80918V11.3743C33.7722 12.0167 33.9021 12.4831 34.162 12.7737C34.4371 13.049 34.7963 13.1867 35.2396 13.1867C35.423 13.1867 35.6065 13.1637 35.7899 13.1178C35.9886 13.0719 36.1644 13.0184 36.3173 12.9572L36.8446 15.4119C36.5389 15.5036 36.1797 15.5954 35.767 15.6872C35.3543 15.7789 34.8727 15.8248 34.3225 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M38.7205 15.5495V0L42.0911 0V3.41397L41.9306 5.45568C42.3586 5.07334 42.8554 4.72158 43.4209 4.40042C43.9865 4.06396 44.6591 3.89573 45.4387 3.89573C46.6768 3.89573 47.5711 4.30101 48.1214 5.11157C48.687 5.92214 48.9697 7.04623 48.9697 8.48384V15.5495H45.5992V8.91971C45.5992 8.09385 45.4845 7.52798 45.2553 7.22211C45.0413 6.91623 44.6897 6.7633 44.2005 6.7633C43.7725 6.7633 43.4057 6.8627 43.0999 7.06152C42.7942 7.24505 42.4579 7.51269 42.0911 7.86444V15.5495H38.7205Z",fill:"currentColor"}),s.jsx("path",{d:"M53.0807 20C52.7291 20 52.431 19.9771 52.1864 19.9312C51.9418 19.9006 51.7049 19.8471 51.4756 19.7706L52.0718 17.2013C52.1788 17.2318 52.3011 17.2624 52.4386 17.293C52.5762 17.3236 52.7061 17.3389 52.8284 17.3389C53.394 17.3389 53.8297 17.2013 54.1354 16.926C54.4411 16.6507 54.6704 16.2913 54.8233 15.8478L54.9837 15.2513L50.6043 4.17101L53.9978 4.17101L55.6258 9.05735C55.7939 9.57734 55.9468 10.105 56.0843 10.6402C56.2219 11.1755 56.3671 11.7261 56.52 12.292H56.6117C56.734 11.7567 56.8563 11.2214 56.9786 10.6861C57.1161 10.1356 57.2537 9.59263 57.3913 9.05735L58.767 4.17101H62L58.0562 15.6642C57.7811 16.383 57.4906 17.0101 57.1849 17.5454C56.8945 18.0959 56.5506 18.5471 56.1531 18.8989C55.771 19.2659 55.3277 19.5412 54.8233 19.7247C54.3341 19.9082 53.7532 20 53.0807 20Z",fill:"currentColor"})]}),mr=({logoUrl:e,appName:t,height:r="28px",linkTo:o="/"})=>{const[a,n]=f.useState(null),[i,c]=f.useState(!0),[d,l]=f.useState(!1);f.useEffect(()=>{(async()=>{try{const g=Ue.getCachedLogo();g&&(g.base64Data||g.url)?(n(g.base64Data||g.url),c(!1)):e?(n(e),c(!1)):(l(!0),c(!1)),e&&Ue.updateInBackground(e,t,A=>{A.base64Data&&n(A.base64Data)})}catch(g){console.error("Error initializing logo:",g),l(!0),c(!1)}})()},[e,t]);const u=f.useCallback(()=>{console.error("Logo failed to load"),l(!0);const m=Ue.getCachedLogo();m&&a===m.base64Data&&Ue.clearCache()},[a]),h=f.useCallback(()=>{c(!1),l(!1)},[]),w=()=>d||!a&&!i?s.jsx(It,{}):a?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:a,height:r,alt:t||"Logo",onError:u,onLoad:h,style:{display:i?"none":"block",maxHeight:r,objectFit:"contain"}}),i&&s.jsx(It,{})]}):s.jsx(It,{});return s.jsx(H.Link,{to:o,className:"logo-link",children:w()})},ct=(e,t={})=>`${t.baseUrl||""}${e}`,jo=(e,t={})=>t.endpoints?.[e]||"",Do=(e={})=>e.timeout||3e4;function me(e,t){if(!e)return"/";const[r,o]=e.split("?"),a=r.replace(/\/+$/,"")+"/",n=new URLSearchParams;o&&new URLSearchParams(o).forEach((d,l)=>{n.set(l,d)}),t&&Object.keys(t).length>0&&Object.entries(t).forEach(([c,d])=>{d!=null&&n.set(c,String(d))});const i=n.toString();return i?`${a}?${i}`:a}const Xe="";function Ho(e){const t=document.cookie.split("; ");for(const r of t){const[o,a]=r.split("=");if(o===e)return decodeURIComponent(a)}return null}const Ye=async()=>({"X-Csrftoken":Ho("csrftoken")}),wr=async({fullUrl:e})=>{const t=`${Xe}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await Ye(),"Content-Type":"application/json"}})},yr=async({fullUrl:e,payload:t})=>await fetch(Xe+e,{method:"POST",redirect:"follow",headers:{...await Ye(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),br=async({fullUrl:e,payload:t})=>await fetch(Xe+e,{method:"PUT",redirect:"follow",headers:{...await Ye(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Cr=async({fullUrl:e,payload:t})=>await fetch(Xe+e,{method:"DELETE",redirect:"follow",headers:{...await Ye(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),vr=async({fullUrl:e,payload:t})=>await fetch(Xe+e,{method:"PATCH",redirect:"follow",headers:{...await Ye(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),we=async e=>{let t;try{const r={message:"Calling API endpoint",data:{endpoint:e.url,method:e.type}},o=ct(e.url);switch(e.type){case"POST":t=await yr({fullUrl:o,payload:e.payload});break;case"PUT":t=await br({fullUrl:o,payload:e.payload});break;case"PATCH":t=await vr({fullUrl:o,payload:e.payload});break;case"DELETE":t=await Cr({fullUrl:o,payload:e.payload});break;case"GET":default:t=await wr({fullUrl:o})}if(t.status===200)try{return{response:(await t.json()).response,success:!0,responseStatus:t.status}}catch{return{response:{message:"Server Error"},success:!1,responseStatus:t.status}}else return{response:(await t.json()).response||{message:"Server Error"},success:!1,responseStatus:t.status}}catch(r){return console.error("API Request Error:",r),{response:{message:"Network Error"},success:!1,responseStatus:500}}},zo=e=>{if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([o,a])=>{a!=null&&t.append(o,String(a))});const r=t.toString();return r?`?${r}`:""},xr=()=>{const t=typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",r=t.startsWith("/")?t:`/${t}`;return{url:me(r),type:"GET"}},Pr=()=>({url:me("/api/v1/profile"),type:"GET"}),Sr=e=>({url:me("/api/v1/profile"),type:"PUT",payload:e}),kr=e=>({url:me("/api/v1/profile/photo"),type:"POST",payload:e}),Ar=e=>({url:me("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),_r=e=>({url:me("/api/v1/profile/two-factor"),type:"POST",payload:e}),Lr=e=>({url:me(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Nr=()=>({url:me("/api/v1/appauth/sessions/"),type:"GET"}),Er=e=>({url:me("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Tr=e=>({url:me("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),Or=()=>({url:me("/api/v1/appauth/logout"),type:"DELETE"}),Fr=()=>({url:me("/logout"),type:"POST"}),Mr=async()=>we(xr()),Ur=async()=>we(Pr()),Br=async()=>we(Nr()),dt=async e=>we(Sr(e)),Wo=async e=>we(kr(e)),Ir=async e=>we(Ar(e)),Zo=async e=>we(_r({enabled:e})),qr=async e=>we(Lr(e)),Vr=async e=>we(Er(e)),$r=async e=>we(Tr(e)),jr=async()=>we(Or()),Dr=async()=>we(Fr());function ut(e){"@babel/helpers - typeof";return ut=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ut(e)}var Ko=/^\s+/,Jo=/\s+$/;function I(e,t){if(e=e||"",t=t||{},e instanceof I)return e;if(!(this instanceof I))return new I(e,t);var r=Go(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||r.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}I.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),r,o,a,n,i,c;return r=t.r/255,o=t.g/255,a=t.b/255,r<=.03928?n=r/12.92:n=Math.pow((r+.055)/1.055,2.4),o<=.03928?i=o/12.92:i=Math.pow((o+.055)/1.055,2.4),a<=.03928?c=a/12.92:c=Math.pow((a+.055)/1.055,2.4),.2126*n+.7152*i+.0722*c},setAlpha:function(t){return this._a=Jr(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=zr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=zr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.v*100);return this._a==1?"hsv("+r+", "+o+"%, "+a+"%)":"hsva("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=Hr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Hr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.l*100);return this._a==1?"hsl("+r+", "+o+"%, "+a+"%)":"hsla("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return Wr(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return Ro(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(oe(this._r,255)*100)+"%",g:Math.round(oe(this._g,255)*100)+"%",b:Math.round(oe(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(oe(this._r,255)*100)+"%, "+Math.round(oe(this._g,255)*100)+"%, "+Math.round(oe(this._b,255)*100)+"%)":"rgba("+Math.round(oe(this._r,255)*100)+"%, "+Math.round(oe(this._g,255)*100)+"%, "+Math.round(oe(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:ua[Wr(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+Zr(this._r,this._g,this._b,this._a),o=r,a=this._gradientType?"GradientType = 1, ":"";if(t){var n=I(t);o="#"+Zr(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+r+",endColorstr="+o+")"},toString:function(t){var r=!!t;t=t||this._format;var o=!1,a=this._a<1&&this._a>=0,n=!r&&a&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(o=this.toRgbString()),t==="prgb"&&(o=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(o=this.toHexString()),t==="hex3"&&(o=this.toHexString(!0)),t==="hex4"&&(o=this.toHex8String(!0)),t==="hex8"&&(o=this.toHex8String()),t==="name"&&(o=this.toName()),t==="hsl"&&(o=this.toHslString()),t==="hsv"&&(o=this.toHsvString()),o||this.toHexString())},clone:function(){return I(this.toString())},_applyModification:function(t,r){var o=t.apply(null,[this].concat([].slice.call(r)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(sa,arguments)},brighten:function(){return this._applyModification(oa,arguments)},darken:function(){return this._applyModification(aa,arguments)},desaturate:function(){return this._applyModification(ea,arguments)},saturate:function(){return this._applyModification(ta,arguments)},greyscale:function(){return this._applyModification(ra,arguments)},spin:function(){return this._applyModification(na,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(ca,arguments)},complement:function(){return this._applyCombination(ia,arguments)},monochromatic:function(){return this._applyCombination(da,arguments)},splitcomplement:function(){return this._applyCombination(la,arguments)},triad:function(){return this._applyCombination(Kr,[3])},tetrad:function(){return this._applyCombination(Kr,[4])}},I.fromRatio=function(e,t){if(ut(e)=="object"){var r={};for(var o in e)e.hasOwnProperty(o)&&(o==="a"?r[o]=e[o]:r[o]=Qe(e[o]));e=r}return I(e,t)};function Go(e){var t={r:0,g:0,b:0},r=1,o=null,a=null,n=null,i=!1,c=!1;return typeof e=="string"&&(e=ga(e)),ut(e)=="object"&&(Le(e.r)&&Le(e.g)&&Le(e.b)?(t=Xo(e.r,e.g,e.b),i=!0,c=String(e.r).substr(-1)==="%"?"prgb":"rgb"):Le(e.h)&&Le(e.s)&&Le(e.v)?(o=Qe(e.s),a=Qe(e.v),t=Qo(e.h,o,a),i=!0,c="hsv"):Le(e.h)&&Le(e.s)&&Le(e.l)&&(o=Qe(e.s),n=Qe(e.l),t=Yo(e.h,o,n),i=!0,c="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=Jr(r),{ok:i,format:e.format||c,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:r}}function Xo(e,t,r){return{r:oe(e,255)*255,g:oe(t,255)*255,b:oe(r,255)*255}}function Hr(e,t,r){e=oe(e,255),t=oe(t,255),r=oe(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=(o+a)/2;if(o==a)n=i=0;else{var d=o-a;switch(i=c>.5?d/(2-o-a):d/(o+a),o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,l:c}}function Yo(e,t,r){var o,a,n;e=oe(e,360),t=oe(t,100),r=oe(r,100);function i(l,u,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?l+(u-l)*6*h:h<1/2?u:h<2/3?l+(u-l)*(2/3-h)*6:l}if(t===0)o=a=n=r;else{var c=r<.5?r*(1+t):r+t-r*t,d=2*r-c;o=i(d,c,e+1/3),a=i(d,c,e),n=i(d,c,e-1/3)}return{r:o*255,g:a*255,b:n*255}}function zr(e,t,r){e=oe(e,255),t=oe(t,255),r=oe(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=o,d=o-a;if(i=o===0?0:d/o,o==a)n=0;else{switch(o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,v:c}}function Qo(e,t,r){e=oe(e,360)*6,t=oe(t,100),r=oe(r,100);var o=Math.floor(e),a=e-o,n=r*(1-t),i=r*(1-a*t),c=r*(1-(1-a)*t),d=o%6,l=[r,i,n,n,c,r][d],u=[c,r,r,i,n,n][d],h=[n,n,c,r,r,i][d];return{r:l*255,g:u*255,b:h*255}}function Wr(e,t,r,o){var a=[ve(Math.round(e).toString(16)),ve(Math.round(t).toString(16)),ve(Math.round(r).toString(16))];return o&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function Ro(e,t,r,o,a){var n=[ve(Math.round(e).toString(16)),ve(Math.round(t).toString(16)),ve(Math.round(r).toString(16)),ve(Gr(o))];return a&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Zr(e,t,r,o){var a=[ve(Gr(o)),ve(Math.round(e).toString(16)),ve(Math.round(t).toString(16)),ve(Math.round(r).toString(16))];return a.join("")}I.equals=function(e,t){return!e||!t?!1:I(e).toRgbString()==I(t).toRgbString()},I.random=function(){return I.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ea(e,t){t=t===0?0:t||10;var r=I(e).toHsl();return r.s-=t/100,r.s=ht(r.s),I(r)}function ta(e,t){t=t===0?0:t||10;var r=I(e).toHsl();return r.s+=t/100,r.s=ht(r.s),I(r)}function ra(e){return I(e).desaturate(100)}function sa(e,t){t=t===0?0:t||10;var r=I(e).toHsl();return r.l+=t/100,r.l=ht(r.l),I(r)}function oa(e,t){t=t===0?0:t||10;var r=I(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(t/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(t/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(t/100)))),I(r)}function aa(e,t){t=t===0?0:t||10;var r=I(e).toHsl();return r.l-=t/100,r.l=ht(r.l),I(r)}function na(e,t){var r=I(e).toHsl(),o=(r.h+t)%360;return r.h=o<0?360+o:o,I(r)}function ia(e){var t=I(e).toHsl();return t.h=(t.h+180)%360,I(t)}function Kr(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=I(e).toHsl(),o=[I(e)],a=360/t,n=1;n<t;n++)o.push(I({h:(r.h+n*a)%360,s:r.s,l:r.l}));return o}function la(e){var t=I(e).toHsl(),r=t.h;return[I(e),I({h:(r+72)%360,s:t.s,l:t.l}),I({h:(r+216)%360,s:t.s,l:t.l})]}function ca(e,t,r){t=t||6,r=r||30;var o=I(e).toHsl(),a=360/r,n=[I(e)];for(o.h=(o.h-(a*t>>1)+720)%360;--t;)o.h=(o.h+a)%360,n.push(I(o));return n}function da(e,t){t=t||6;for(var r=I(e).toHsv(),o=r.h,a=r.s,n=r.v,i=[],c=1/t;t--;)i.push(I({h:o,s:a,v:n})),n=(n+c)%1;return i}I.mix=function(e,t,r){r=r===0?0:r||50;var o=I(e).toRgb(),a=I(t).toRgb(),n=r/100,i={r:(a.r-o.r)*n+o.r,g:(a.g-o.g)*n+o.g,b:(a.b-o.b)*n+o.b,a:(a.a-o.a)*n+o.a};return I(i)},I.readability=function(e,t){var r=I(e),o=I(t);return(Math.max(r.getLuminance(),o.getLuminance())+.05)/(Math.min(r.getLuminance(),o.getLuminance())+.05)},I.isReadable=function(e,t,r){var o=I.readability(e,t),a,n;switch(n=!1,a=ma(r),a.level+a.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7;break}return n},I.mostReadable=function(e,t,r){var o=null,a=0,n,i,c,d;r=r||{},i=r.includeFallbackColors,c=r.level,d=r.size;for(var l=0;l<t.length;l++)n=I.readability(e,t[l]),n>a&&(a=n,o=I(t[l]));return I.isReadable(e,o,{level:c,size:d})||!i?o:(r.includeFallbackColors=!1,I.mostReadable(e,["#fff","#000"],r))};var qt=I.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},ua=I.hexNames=ha(qt);function ha(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function Jr(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function oe(e,t){pa(e)&&(e="100%");var r=fa(e);return e=Math.min(t,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function ht(e){return Math.min(1,Math.max(0,e))}function ye(e){return parseInt(e,16)}function pa(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function fa(e){return typeof e=="string"&&e.indexOf("%")!=-1}function ve(e){return e.length==1?"0"+e:""+e}function Qe(e){return e<=1&&(e=e*100+"%"),e}function Gr(e){return Math.round(parseFloat(e)*255).toString(16)}function Xr(e){return ye(e)/255}var xe=(function(){var e="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",r="(?:"+t+")|(?:"+e+")",o="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",a="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+o),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+o),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+o),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function Le(e){return!!xe.CSS_UNIT.exec(e)}function ga(e){e=e.replace(Ko,"").replace(Jo,"").toLowerCase();var t=!1;if(qt[e])e=qt[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=xe.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=xe.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=xe.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=xe.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=xe.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=xe.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=xe.hex8.exec(e))?{r:ye(r[1]),g:ye(r[2]),b:ye(r[3]),a:Xr(r[4]),format:t?"name":"hex8"}:(r=xe.hex6.exec(e))?{r:ye(r[1]),g:ye(r[2]),b:ye(r[3]),format:t?"name":"hex"}:(r=xe.hex4.exec(e))?{r:ye(r[1]+""+r[1]),g:ye(r[2]+""+r[2]),b:ye(r[3]+""+r[3]),a:Xr(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=xe.hex3.exec(e))?{r:ye(r[1]+""+r[1]),g:ye(r[2]+""+r[2]),b:ye(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function ma(e){var t,r;return e=e||{level:"AA",size:"small"},t=(e.level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),r!=="small"&&r!=="large"&&(r="small"),{level:t,size:r}}const Be=e=>({25:I.mix(e,"#FFFFFF",95).toHexString(),50:I.mix(e,"#FFFFFF",90).toHexString(),100:I.mix(e,"#FFFFFF",80).toHexString(),200:I.mix(e,"#FFFFFF",65).toHexString(),300:I.mix(e,"#FFFFFF",50).toHexString(),400:I.mix(e,"#FFFFFF",30).toHexString(),500:I(e).toHexString(),600:I.mix(e,"#000000",10).toHexString(),700:I.mix(e,"#000000",20).toHexString(),800:I.mix(e,"#000000",30).toHexString(),900:I.mix(e,"#000000",45).toHexString(),950:I.mix(e,"#000000",60).toHexString()}),pt=e=>{let t="";const r={brand:Be(e.colors.primary),success:Be(e.colors.success),warning:Be(e.colors.warning),gray:Be(e.colors.gray),error:Be(e.colors.error)};return t=Object.entries(r).map(([o,a])=>Object.entries(a).map(([n,i])=>`--color-${o}-${n}: ${i}`).join(`;
3
- `)).join(";"),e?.typography&&Object.entries(e.typography).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.borders&&Object.entries(e.borders).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.shadows&&Object.entries(e.shadows).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--shadow-${n}: ${a}; `}),e?.spacing&&Object.entries(e.spacing).forEach(([o,a])=>{t+=`--spacing-${o}: ${a}px; `}),t},Yr=e=>I(e).isLight(),wa=e=>Yr(e)?"#000000":"#FFFFFF",Qr=(e,t=500)=>{const r=`--color-${e}-${t}`;if(typeof window<"u"&&window.getComputedStyle){const h=window.getComputedStyle(document.documentElement).getPropertyValue(r).trim();if(h)return h}const o=document.documentElement,a=o.style.getPropertyValue("--color-brand-500")||"#5048ED",n=o.style.getPropertyValue("--color-success-500")||"#10B981",i=o.style.getPropertyValue("--color-error-500")||"#F04438",c=o.style.getPropertyValue("--color-warning-500")||"#F59E0B",d=o.style.getPropertyValue("--color-gray-500")||"#6B7280",l={brand:a,success:n,error:i,warning:c,gray:d};return l[e]?Be(l[e])[t]||l[e]:"#5048ED"},Vt=(e={})=>e.baseUrl||"",Rr=(e,t={})=>e?e.startsWith("http://")||e.startsWith("https://")?e:ct(e,t):Vt(t),Re=()=>{const e=H.useLocation(),{routes:t,apiConfig:r}=Se(),a=e.pathname.split("/").filter(Boolean)[0],n=[...t].sort((d,l)=>l.path.length-d.path.length);let i=null;for(const d of n){if(d.path===e.pathname){i=d;break}if(d.path?.includes(":")){const l=d.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${l}$`))){i=d;break}}if(e.pathname.startsWith(d.path+"/")){i=d;break}}const c=i?.extra_params||i?.exta_params||{};return{baseUrl:Vt(r),apiUrl:c.api_endpoint||"",fullUrl:Rr(c.api_endpoint||"",r),headers:c.headers||{},entity:a,...c}},ya=()=>{const e=H.useLocation(),{routes:t}=Se(),r=[...t].sort((o,a)=>a.path.length-o.path.length);for(const o of r){if(o.path===e.pathname)return o;if(o.path?.includes(":")){const a=o.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${a}$`)))return o}if(e.pathname.startsWith(o.path+"/"))return o}return null},ba=(e,t={},r={})=>({baseUrl:Vt(t),apiUrl:e,fullUrl:Rr(e,t),headers:r.headers||{},...r}),es=({basePath:e})=>{const t=Re();return s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(qo.CrudHandler,{api_endpoint:t.apiUrl})})},$t={crud:{requiredPackage:"@zango-core/crud",component:es},training:{requiredPackage:"@zango-core/training",component:({basePath:e})=>{Re();const[t,r]=f.useState(null),[o,a]=f.useState(null);return f.useEffect(()=>{(async()=>{try{const i=await import("@zango-core/training");r(()=>i.TrainingRouter)}catch(i){console.error("Failed to load training module:",i),a("Training module could not be loaded")}})()},[]),o?s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsxs("div",{className:"error-message",children:[s.jsx("h3",{children:"Training Module Error"}),s.jsx("p",{children:o})]})}):t?s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(t,{})}):s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsx("div",{className:"loading-spinner",children:"Loading training module..."})})}}};Object.fromEntries(Object.entries($t).map(([e,t])=>[e,()=>import(t.requiredPackage)])),Object.fromEntries(Object.keys($t).map(e=>[e,[e]]));const ts=Object.fromEntries(Object.entries($t).map(([e,t])=>[e,t.component])),Ca=e=>e.filter(t=>t in ts),va=e=>ts[e]||null,rs=({componentName:e,customPagesDir:t="src/custom/pages",fileExtension:r="js"})=>{const[o,a]=f.useState(null),n=(g,A)=>{navigator.clipboard.writeText(g).then(()=>{a(A),setTimeout(()=>a(null),2e3)})},i=e||"MyCustomPage",c=t,d=r,l=`import React from 'react';
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}.mx-auto{margin-inline:auto}.mb-\\[18px\\]{margin-bottom:18px}.\\!line-clamp-2{-webkit-line-clamp:2!important;-webkit-box-orient:vertical!important;display:-webkit-box!important;overflow:hidden!important}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.h-\\[42px\\]{height:42px}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.min-h-\\[8rem\\]{min-height:8rem}.min-h-\\[300px\\]{min-height:300px}.min-h-\\[400px\\]{min-height:400px}.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-\\[150px\\]{max-width:150px}.flex-1{flex:1}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-clip-text{-webkit-background-clip:text;background-clip:text}.object-cover{object-fit:cover}.\\!text-center{text-align:center!important}.text-center{text-align:center}.text-left{text-align:left}.text-\\[12px\\]{font-size:12px}.text-\\[40px\\]{font-size:40px}.leading-none{--tw-leading:1;line-height:1}.break-all{word-break:break-all}.text-\\[var\\(--color-brand-500\\,\\#5048ED\\)\\]{color:var(--color-brand-500,#5048ed)}.text-\\[var\\(--color-gray-700\\,\\#414651\\)\\]{color:var(--color-gray-700,#414651)}.text-transparent{color:#0000}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.duration-300{--tw-duration:.3s;transition-duration:.3s}.last\\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus\\:shadow-\\[0_0_0_2px_rgba\\(106\\,138\\,18\\,0\\.2\\)\\]:focus{--tw-shadow:0 0 0 2px var(--tw-shadow-color,#6a8a1233);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.brand-500{background-color:var(--color-brand-500)!important}.border-brand-500{border-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-tab-active{border-bottom-width:2px!important;border-bottom-color:var(--color-brand-500)!important}.login-tabs .ant-tabs-ink-bar{background-color:var(--color-brand-500)!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}.wide-sidebar{width:244px;display:flex;height:100dvh;font-size:14px;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-style:normal;font-weight:500;border-right:1px solid #D5D7DA;flex-direction:column;position:relative;background-color:#fff;z-index:10}.frame-logo-container{height:64px;display:flex;align-items:center;gap:8px;padding:20px}.frame-logo-container a{display:flex;align-items:center;text-decoration:none}.frame-logo-container img{height:28px;width:auto}.frame-menu-container{display:flex;flex-direction:column;gap:16px;flex-grow:1;overflow-y:scroll;padding:8px 12px}#wideSidebarMenu{color:#414651;padding:0;flex-grow:1;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0}#wideSidebarMenu li{list-style:none;padding:12px;border-radius:6px;overflow:hidden;color:#414651;transition:all .3s ease-in-out;cursor:pointer}#wideSidebarMenu .menu-item{display:flex;align-items:center;gap:8px}#wideSidebarMenu li a{display:flex;align-items:center;color:var(--color-gray-700, #414651);text-decoration:none;padding:12px;margin:-12px;width:calc(100% + 24px);gap:8px;font-size:14px;font-weight:500;transition:all .3s ease-in-out}#wideSidebarMenu li:hover,#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED)}#wideSidebarMenu li:hover a,#wideSidebarMenu li:hover .menu-title{color:var(--color-brand-500, #5048ED)!important}#wideSidebarMenu li.active{background-color:var(--color-brand-50, #EAE8FF);color:var(--color-brand-500, #5048ED);font-weight:600}#wideSidebarMenu li.active .menu-title,#wideSidebarMenu li.active a{color:var(--color-brand-500, #5048ED)}.navbar-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.navbar-icon svg{width:16px;height:16px}.navbar-icon img{width:16px;height:16px;object-fit:contain}.navbar-icon-emoji{font-size:16px;line-height:1;width:auto;min-width:16px}#wideSidebarMenu .menu-title{flex-grow:1;color:var(--color-gray-700, #414651)}#wideSidebarMenu .menu-list-item{cursor:pointer}#wideSidebarMenu .downIcon{display:flex;justify-content:center;align-items:center;height:100%;transition:transform .3s ease}#wideSidebarMenu li.active .downIcon{transform:rotate(180deg)}#wideSidebarMenu .submenu-accordion-item{color:#414651}#wideSidebarMenu .submenu-list{padding:0;max-height:0;overflow:hidden;opacity:0;list-style:none;margin:0;border-radius:8px;transition:all .3s cubic-bezier(.16,1,.3,1);transform:translateY(-4px)}#wideSidebarMenu .submenu-list.active{padding:9px 0;max-height:500px;opacity:1;transform:translateY(0)}#wideSidebarMenu .submenu-list-item{padding:10px 36px;position:relative;color:var(--color-gray-700, #414651)}#wideSidebarMenu .submenu-list-item a{display:flex;align-items:center;color:inherit;text-decoration:none;padding:10px 36px;margin:-10px -36px;width:calc(100% + 72px);gap:8px;transition:all .3s ease-in-out}#wideSidebarMenu .submenu-list-item a .each-submenu-label{color:var(--color-gray-700, #414651);font-size:12px}#wideSidebarMenu .submenu-list-item a .each-submenu-label.active{color:var(--color-brand-500, #5048ED)}#wideSidebarMenu .submenu-item-icon{display:none}#wideSidebarMenu .submenu-item-icon-container{width:16px}#wideSidebarMenu .submenu-item-icon.active{display:block}.submenu-item-icon-container{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.submenu-dot{display:none}.submenu-dot.active{display:inline-block;width:14px;height:10px}.navbar-menu-container::-webkit-scrollbar{width:4px}.navbar-menu-container::-webkit-scrollbar-track{background:transparent}.navbar-menu-container::-webkit-scrollbar-thumb{background:var(--color-gray-300, #dde2e5);border-radius:2px}.navbar-menu-container::-webkit-scrollbar-thumb:hover{background:var(--color-gray-400, #d5d7da)}@media(max-width:768px){.navbar,.wide-sidebar{position:fixed;left:-244px;z-index:1000}.navbar.open,.wide-sidebar.open{left:0}}.user-profile-drawer{position:fixed;top:0;right:-100%;width:100%;height:100vh;background-color:var(--zango-gray-50, #F9FAFB);transition:right .3s ease-in-out;z-index:1300;overflow:hidden;display:flex;flex-direction:column}.user-profile-drawer *{box-sizing:border-box}.user-profile-drawer.open{right:0}.profile-header-gradient{height:100px;background:linear-gradient(135deg,var(--color-brand-500, #5048ED) 0%,#7C3AED 50%,#EC4899 100%);position:relative}.profile-close-btn{position:absolute;top:16px;right:16px;background:#fff3;border:none;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;color:#fff}.profile-close-btn:hover{background:#ffffff4d}.profile-info-section{background:#fff;padding:0 40px 20px;text-align:center;position:relative;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);width:100%;box-sizing:border-box}.profile-avatar-container{margin-top:-40px;margin-bottom:12px}.profile-avatar-circle{width:80px;height:80px;background:var(--zango-gray-100, #F3F4F6);border-radius:50%;display:inline-flex;align-items:center;justify-content:center;border:4px solid #FFFFFF;box-shadow:0 4px 6px #0000001a;position:relative}.profile-avatar-circle svg{width:40px;height:40px}.profile-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.profile-avatar-edit{position:absolute;bottom:-4px;right:-4px;background:var(--color-brand-500, #5048ED);color:#fff;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s ease;border:2px solid white;box-shadow:0 2px 4px #0000001a}.profile-avatar-edit:hover{background:var(--color-brand-600, #433BD9);transform:scale(1.1)}.profile-avatar-edit svg{width:14px;height:14px}.profile-initials{font-size:32px;font-weight:600;color:var(--zango-gray-700, #4B5563)}.profile-name-section{margin-bottom:0}.profile-user-name{font-size:20px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 2px}.profile-user-role{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.profile-user-role-badge{display:inline-flex;align-items:center;gap:6px;background:linear-gradient(135deg,#5048ed1a,#7c3aed1a,#ec48991a);color:var(--color-brand-500, #5048ED);padding:6px 14px;border-radius:20px;font-size:13px;font-weight:500;border:1px solid rgba(80,72,237,.2);margin-top:6px;transition:all .2s ease}.profile-user-role-badge:hover{background:linear-gradient(135deg,#5048ed26,#7c3aed26,#ec489926);border-color:#5048ed4d;transform:translateY(-1px);box-shadow:0 2px 8px #5048ed33}.profile-user-role-badge svg{width:14px;height:14px;stroke:var(--color-brand-500, #5048ED);flex-shrink:0}.profile-user-role-badge span{letter-spacing:.3px;text-transform:capitalize}.profile-main-content{flex:1;overflow-y:auto;overflow-x:hidden;padding:20px;display:flex;justify-content:center;width:100%;box-sizing:border-box}.profile-content-wrapper{background:#fff;border-radius:12px;padding:20px;width:100%;max-width:700px;margin:0 auto;box-shadow:0 1px 3px #0000001a;box-sizing:border-box;height:fit-content}.profile-tabs{display:flex;border-bottom:1px solid var(--zango-gray-300, #E5E7EB);margin-bottom:20px;width:100%;box-sizing:border-box}.profile-tab{padding:10px 20px;background:none;border:none;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);cursor:pointer;position:relative;transition:all .2s ease}.profile-tab:hover{color:var(--zango-gray-700, #4B5563)}.profile-tab.active{color:var(--color-brand-500, #5048ED)}.profile-tab.active:after{content:"";position:absolute;bottom:-1px;left:0;right:0;height:2px;background:var(--color-brand-500, #5048ED)}.profile-tab-content{padding:0;width:100%;box-sizing:border-box}.account-section{display:flex;flex-direction:column;gap:24px}.profile-photo-edit:hover{background:var(--color-brand-600, #433BD9)}.profile-field-section{border-bottom:1px solid var(--zango-gray-300, #E5E7EB);padding-bottom:16px}.profile-field-section:last-child{border-bottom:none}.profile-field-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.profile-field-label{font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280)}.profile-field-value{font-size:16px;color:var(--zango-gray-900, #111827);margin:0;display:flex;align-items:center;gap:8px}.profile-field-value.readonly{color:var(--zango-gray-600, #6B7280)}.profile-field-value .empty-value{color:#9ca3af;font-style:italic}.profile-field-value .field-icon{flex-shrink:0}.profile-field-edit-btn{background:none;border:none;color:var(--color-brand-500, #5048ED);font-size:14px;font-weight:500;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all .2s ease}.profile-field-edit-btn:hover{background:#5048ed1a}.profile-inline-form{width:100%}.profile-inline-actions{display:flex;gap:8px;margin-top:12px;justify-content:flex-end}.profile-save-btn{padding:8px 16px;font-size:14px;font-weight:500;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:6px;cursor:pointer;transition:all .2s ease}.profile-save-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-save-btn:disabled{opacity:.6;cursor:not-allowed}.roles-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}.role-item{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB;transition:all .2s ease}.role-item:hover{background:var(--zango-gray-100, #F3F4F6);border-color:#d1d5db}.role-item.active{background:#5048ed0d;border-color:var(--color-brand-500, #5048ED)}.role-info{display:flex;align-items:center;gap:10px}.role-info svg{width:16px;height:16px;stroke:#6b7280;flex-shrink:0}.role-item.active .role-info svg{stroke:var(--color-brand-500, #5048ED)}.role-name{font-size:14px;color:#374151;font-weight:500}.role-badge{font-size:12px;font-weight:500;color:var(--color-brand-500, #5048ED);background:#5048ed1a;padding:4px 12px;border-radius:12px}.role-switch-btn{font-size:12px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;padding:4px 12px;border-radius:6px;border:1px solid #E5E7EB;cursor:pointer;transition:all .2s ease}.role-switch-btn:hover{color:var(--color-brand-500, #5048ED);border-color:var(--color-brand-500, #5048ED);background:#5048ed0d}.security-section{display:flex;flex-direction:column;gap:24px}.security-block{border:1px solid #E5E7EB;border-radius:8px;padding:20px}.security-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px}.security-title{font-size:16px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 4px}.security-subtitle{font-size:14px;color:var(--zango-gray-600, #6B7280);margin:0}.toggle-btn{padding:8px 16px;font-size:14px;font-weight:500;border:1px solid #E5E7EB;border-radius:6px;background:#fff;color:#374151;cursor:pointer;transition:all .2s ease}.toggle-btn:hover{background:#f9fafb}.toggle-btn.enabled{background:var(--color-brand-500, #5048ED);color:#fff;border-color:var(--color-brand-500, #5048ED)}.toggle-btn.enabled:hover{background:var(--color-brand-600, #433BD9)}.password-form{margin-top:16px}.sessions-list{display:flex;flex-direction:column;gap:12px;margin-top:16px}.session-item{display:flex;justify-content:space-between;align-items:center;padding:16px;background:#f9fafb;border-radius:8px;border:1px solid #E5E7EB}.session-info{display:flex;align-items:center;gap:16px;flex:1}.session-device{display:flex;align-items:center;gap:12px}.session-device svg{color:var(--zango-gray-600, #6B7280)}.session-device-header{display:flex;align-items:center;gap:8px;margin-bottom:2px}.session-device-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0}.session-status-tag{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.session-status-tag.current{background:#22c55e1a;color:#16a34a;border:1px solid rgba(34,197,94,.2)}.session-status-tag.inactive{background:transparent;padding:0;border:none}.logout-tag-btn{font-size:11px;font-weight:500;padding:2px 8px;border-radius:12px;text-transform:uppercase;letter-spacing:.5px;background:#ef44441a;color:#dc2626;border:1px solid rgba(239,68,68,.2);cursor:pointer;transition:all .2s ease}.logout-tag-btn:hover{background:#ef444426;border-color:#ef44444d}.logout-tag-btn-ghost{background:#9ca3af1a;color:#6b7280;border:1px solid rgba(156,163,175,.2)}.logout-tag-btn-ghost:hover{background:#9ca3af26;border-color:#9ca3af4d;color:#4b5563}.session-details{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-time{text-align:right}.session-time-info{display:flex;flex-direction:column;gap:4px;align-items:flex-end}.session-start-time{font-size:12px;color:var(--zango-gray-500, #9CA3AF);margin:0;font-weight:500}.session-last-active{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.session-logout-btn{padding:6px 12px;font-size:12px;font-weight:500;border:1px solid #E5E7EB;border-radius:4px;background:#fff;color:#dc2626;cursor:pointer;transition:all .2s ease}.session-logout-btn:hover{background:#fef2f2;border-color:#dc2626}.session-current{font-size:12px;color:var(--zango-gray-600, #6B7280);font-style:italic}.no-sessions{text-align:center;color:var(--zango-gray-600, #6B7280);font-size:14px;padding:20px}.logout-all-btn{width:100%;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease;margin-top:16px}.logout-all-btn:hover{background:#fef2f2}.tokens-list{margin-top:16px}.token-item{display:flex;align-items:center;justify-content:space-between;padding:16px;background:#f9fafb;border-radius:8px;margin-bottom:12px;transition:all .2s ease}.token-item:hover{background:var(--zango-gray-100, #F3F4F6)}.token-info{display:flex;align-items:center;justify-content:space-between;width:100%;gap:16px}.token-details{display:flex;align-items:center;gap:12px}.token-details svg{color:var(--zango-gray-600, #6B7280)}.token-name{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 4px}.token-created{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.token-revoke-btn{padding:6px 16px;font-size:13px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #FEE2E2;border-radius:6px;cursor:pointer;transition:all .2s ease}.token-revoke-btn:hover{background:#fef2f2;border-color:#fecaca}.no-tokens{text-align:center;padding:32px 16px;color:var(--zango-gray-600, #6B7280)}.no-tokens p{margin:0 0 8px;font-size:14px}.no-tokens-hint{font-size:12px;color:#9ca3af}.profile-form-group{margin-bottom:16px;width:100%;box-sizing:border-box}.profile-form-label{display:block;font-size:14px;font-weight:500;color:#374151;margin-bottom:6px}.profile-form-input{width:100%;padding:10px 14px;font-size:14px;border:1px solid #E5E7EB;border-radius:8px;background:#fff;transition:all .2s ease;box-sizing:border-box}.profile-form-input:focus{outline:none;border-color:var(--color-brand-500, #5048ED);background:#fff;box-shadow:0 0 0 3px #5048ed1a}.profile-form-input::placeholder{color:#9ca3af}.profile-form-error{color:#ef4444;font-size:12px;margin-top:4px}.profile-form-actions{display:flex;gap:12px;margin-top:20px;justify-content:flex-end}.profile-cancel-btn{padding:10px 20px;font-size:14px;font-weight:500;color:var(--zango-gray-600, #6B7280);background:#fff;border:1px solid #E5E7EB;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-cancel-btn:hover{background:#f9fafb;color:var(--zango-gray-700, #4B5563)}.profile-submit-btn{padding:10px 20px;font-size:14px;font-weight:600;color:#fff;background:var(--color-brand-500, #5048ED);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.profile-submit-btn:hover{background:var(--color-brand-600, #433BD9)}.profile-submit-btn:disabled{opacity:.6;cursor:not-allowed}.profile-alert{padding:12px 16px;border-radius:8px;margin-bottom:20px;font-size:14px;display:flex;align-items:center;gap:8px}.profile-alert.error{background:#fee2e2;color:#dc2626;border:1px solid #FECACA}.profile-alert.success{background:#5048ed1a;color:var(--color-brand-500, #5048ED);border:1px solid rgba(80,72,237,.2)}.password-requirements{background:#f9fafb;border:1px solid #E5E7EB;border-radius:8px;padding:16px;margin:16px 0;width:100%;box-sizing:border-box}.password-requirement{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--zango-gray-600, #6B7280);margin-bottom:8px;transition:color .2s ease}.password-requirement:last-child{margin-bottom:0}.password-requirement svg{flex-shrink:0}.password-requirement svg path{fill:#9ca3af;transition:fill .2s ease}.password-requirement.met{color:var(--color-brand-500, #5048ED)}.password-requirement.met svg path{fill:var(--color-brand-500, #5048ED)}.welcome-banner{background:linear-gradient(135deg,#5048ed0d,#7c3aed0d,#ec48990d);border:1px solid rgba(80,72,237,.2);border-radius:12px;padding:24px;text-align:center;margin-bottom:24px}.welcome-banner svg{margin-bottom:16px}.welcome-banner h3{font-size:18px;font-weight:600;color:var(--zango-gray-900, #111827);margin:0 0 8px}.welcome-banner p{font-size:14px;color:var(--zango-gray-600, #6B7280);max-width:400px;margin:0 auto}.empty-value{color:#9ca3af;font-style:italic;font-weight:400}.field-icon{width:16px;height:16px;flex-shrink:0}.profile-field-section{transition:background .2s ease;padding:0 0 16px}.profile-field-section:hover{background:#00000003}.logout-section{margin-top:20px;padding-top:20px;border-top:1px solid #E5E7EB}.logout-button{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:12px 20px;font-size:14px;font-weight:500;color:#dc2626;background:#fff;border:1px solid #DC2626;border-radius:8px;cursor:pointer;transition:all .2s ease}.logout-button:hover{background:#fef2f2;color:#b91c1c;border-color:#b91c1c}.logout-button svg{width:16px;height:16px;stroke:currentColor}@media(max-width:768px){.profile-main-content{padding:16px}.profile-content-wrapper{padding:16px;max-width:100%}.profile-tabs{margin:0 -16px 20px;padding:0 16px}.profile-tab{flex:1;text-align:center}.session-info{flex-direction:column;align-items:flex-start;gap:8px}.session-item{flex-direction:column;align-items:flex-start;gap:12px}}.password-history-list{margin-top:16px}.password-history-item{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--zango-gray-50, #F9FAFB);border-radius:8px;margin-bottom:12px;transition:all .2s ease}.password-history-item:last-child{margin-bottom:0}.password-history-item:hover{background:var(--zango-gray-100, #F3F4F6)}.history-icon{width:40px;height:40px;background:var(--zango-brand-100, rgba(80, 72, 237, .1));border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.history-icon svg{color:var(--zango-brand-600, #5048ED)}.history-details{flex:1}.history-text{font-size:14px;font-weight:500;color:var(--zango-gray-900, #111827);margin:0 0 2px}.history-time{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:0}.no-password-history{text-align:center;padding:24px 16px;color:var(--zango-gray-600, #6B7280)}.no-password-history p{margin:0;font-size:14px}.password-disabled-badge{display:inline-block;margin-left:8px;padding:2px 8px;font-size:11px;font-weight:600;color:var(--zango-error-600, #DC2626);background:var(--zango-error-100, #FEE2E2);border-radius:12px;text-transform:uppercase;letter-spacing:.5px}.password-expired{color:var(--zango-error-600, #DC2626);font-weight:600}.token-type{font-size:12px;color:var(--color-brand-500, #5048ED);margin:2px 0 4px;font-weight:500}.token-expiry{font-size:12px;color:var(--zango-gray-600, #6B7280);margin:4px 0 0}.header-container{height:56px;width:100%;background:#fff;justify-content:flex-end;border-bottom:1px solid #E9EAEB;align-items:center;padding:0 20px;display:flex;position:relative}.topbar-content{width:100%;display:flex;justify-content:space-between;align-items:center}.topbar-left,.topbar-right{display:flex;align-items:center;gap:16px}.dropdown{position:relative}.profile-dropdown-menu-button{display:flex;gap:20px;align-items:center;cursor:pointer;padding:8px 12px;border-radius:8px;transition:background-color .2s ease}.profile-dropdown-menu-button:hover{background-color:var(--color-gray-100, #f5f5f5)}.profile-info-wrapper{display:flex;align-items:center;gap:8px}.profile-avatar{width:24px;height:24px;border-radius:50%;overflow:hidden}.profile-name{font-size:14px;font-weight:500;color:var(--color-Gray-900, #252b37)}.dropdown-arrow{transition:transform .2s cubic-bezier(.16,1,.3,1)}.dropdown-arrow.open{transform:rotate(180deg)}.profile-dropdown-menu{border-radius:8px;border:1px solid var(--color-gray-200, #E9EAEB);background:var(--color-background, #FFFFFF);box-shadow:0 12px 12px -4px #0a0d1214,0 -4px 6px -2px #0a0d120f,0 -2px 2px -2px #0a0d120d;min-width:158px;position:absolute;right:0;top:calc(100% + 10px);z-index:1000;list-style:none;margin:0;padding:0;opacity:0;visibility:hidden;transform:translateY(-8px) scale(.95);transition:all .2s cubic-bezier(.16,1,.3,1);overflow:hidden}.profile-dropdown-menu *{cursor:pointer!important}.profile-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0) scale(1)}.profile-dropdown-menu li{margin:0}.dropdown-item{display:flex;align-items:center;padding:8px 12px;color:#717680;text-decoration:none;font-size:14px;transition:all .2s ease;cursor:pointer!important;background:none;border:none;width:100%;text-align:left;gap:8px}.dropdown-item:hover{background-color:#f5f5f5;color:#252b37}.profile-dropdown-menu li:first-child .dropdown-item:hover{border-top-left-radius:8px;border-top-right-radius:8px}.profile-dropdown-menu li:last-child .dropdown-item:hover{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.dropdown-item.profile-info{padding:8px 12px;cursor:pointer}.dropdown-item.profile-info:hover{background-color:transparent;cursor:pointer}.dropdown-item.profile-info.clickable:hover{background-color:var(--color-Gray-100, #f5f5f5);cursor:pointer;border-radius:4px}.user-info-content{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-role{font-weight:500;color:var(--color-Gray-900, #252b37)}.role-arrow{display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.16,1,.3,1)}.role-arrow.expanded{transform:rotate(180deg)}.profile-roles{max-height:200px;overflow-y:auto;margin:0 -16px;padding:0 16px}.profile-each-role{display:flex;align-items:center;padding:8px 12px;gap:8px;cursor:pointer;transition:all .2s ease}.profile-each-role:hover{background-color:var(--color-Gray-100, #f5f5f5)}.profile-dropdown-menu .profile-each-role:hover{border-radius:4px}.profile-each-role .label{font-size:14px;color:var(--color-Gray-700, #717680)}.profile-dropdown-divider{border:none}.profile-menu-option{display:flex;align-items:center;gap:8px;cursor:pointer}.profile-menu-name,.profile-name{font-size:12px;font-weight:500;cursor:pointer}.flex-row{flex-direction:row!important}.justify-content-between{justify-content:space-between!important}@media(max-width:768px){.topbar{padding:0 16px}.profile-dropdown-menu{right:-16px}}.layout{width:100vw;height:100vh;overflow:hidden}.layout-wrapper{display:flex;height:100vh;background-color:var(--color-background, #ffffff)}.layout-main{display:flex;flex-direction:column;overflow:hidden;transition:width .3s ease;flex:1;position:relative}.layout-content{flex:1;overflow-y:auto;background-color:var(--color-background, #ffffff);position:relative}.layout-content:has(.content-spinner-container.active)>:not(.content-spinner-container){opacity:0;transition:opacity .2s ease-in}.layout-content>:not(.content-spinner-container){opacity:1;transition:opacity .3s ease-in}.layout-loading,.layout-error{display:flex;align-items:center;justify-content:center;height:100vh;font-size:18px;color:var(--color-Gray-700, #717680)}.layout-error{color:var(--color-error-500, #f04438)}@media(max-width:768px){.layout-content{padding:16px}.layout-main{width:100vw!important}}.content-spinner-container{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:#fff;border-radius:18px;z-index:99;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-out}.content-spinner-container.active{opacity:1;visibility:visible;pointer-events:all;transition:none}.spinner{width:64px;height:64px;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.d-flex{display:flex!important}.flex-column{flex-direction:column!important}.flex-grow-1{flex-grow:1!important}.p-0{padding:0!important}.dvh-100{height:100dvh!important}.complete-hidden-scroll-style::-webkit-scrollbar{display:none}.complete-hidden-scroll-style{-ms-overflow-style:none;scrollbar-width:none}.zango-loading{display:flex;align-items:center;justify-content:center;height:100vh;font-size:16px;color:#6d7280}.zango-no-menu{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;padding:2rem;text-align:center;color:#374151}.zango-no-menu h2{font-size:1.5rem;font-weight:600;margin-bottom:.5rem;color:#1f2937}.zango-no-menu p{font-size:1rem;color:#6b7280;margin:0;max-width:400px}*{box-sizing:border-box}body{margin:0;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#root{height:100vh}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
+ (function(q,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-router-dom"),require("@zango-core/crud/table"),require("@zango-core/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router-dom","@zango-core/crud/table","@zango-core/components"],s):(q=typeof globalThis<"u"?globalThis:q||self,s(q.ZangoCRMFramework={},q["react/jsx-runtime"],q.React,q.ReactRouterDOM,q.table,q.components))})(this,(function(q,s,g,G,Go,p){"use strict";const Ko="zango_app_logo_cache";class Jo{constructor(){this.cacheKey=Ko}getCachedLogo(){try{const t=localStorage.getItem(this.cacheKey);if(!t)return null;const r=JSON.parse(t);return this.isCacheExpired(r.timestamp)?(this.clearCache(),null):r}catch(t){return console.error("Error reading logo cache:",t),null}}async cacheLogoUrl(t,r){if(t)try{const o=await this.generateHash(t),a=this.getCachedLogo();if(a&&a.version===o)return a.timestamp=Date.now(),localStorage.setItem(this.cacheKey,JSON.stringify(a)),a;const n=await this.fetchAndConvertToBase64(t),i={url:t,base64Data:n,version:o,timestamp:Date.now(),appName:r||"Zango CRM"};return localStorage.setItem(this.cacheKey,JSON.stringify(i)),i}catch(o){return console.error("Error caching logo:",o),{url:t,base64Data:null,version:null,timestamp:Date.now(),appName:r||"Zango CRM"}}}async fetchAndConvertToBase64(t){try{const r=t.startsWith("http")?t:`${window.location.origin}${t}`,o=await fetch(r);if(!o.ok)throw new Error(`Failed to fetch logo: ${o.status}`);const a=await o.blob();return new Promise((n,i)=>{const c=new FileReader;c.onloadend=()=>n(c.result),c.onerror=i,c.readAsDataURL(a)})}catch(r){return console.error("Error converting logo to base64:",r),null}}async generateHash(t){let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o);r=(r<<5)-r+a,r=r&r}return Math.abs(r).toString(36)}isCacheExpired(t){return Date.now()-t>864e5}clearCache(){try{localStorage.removeItem(this.cacheKey)}catch(t){console.error("Error clearing logo cache:",t)}}async needsUpdate(t){const r=this.getCachedLogo();return!!(!r||r.url!==t||this.isCacheExpired(r.timestamp))}async updateInBackground(t,r,o){try{if(!await this.needsUpdate(t))return;setTimeout(async()=>{const n=await this.cacheLogoUrl(t,r);n&&o&&o(n)},100)}catch(a){console.error("Error updating logo in background:",a)}}}const Ve=new Jo,Vt=()=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"62",height:"20",viewBox:"0 0 62 20",fill:"none",children:[s.jsx("path",{d:"M0 15.5495L0 13.7372L5.34244 6.80918L0.527365 6.80918L0.527365 4.17101L9.53843 4.17101L9.53843 5.96037L4.19599 12.9114L9.69894 12.9114V15.5495L0 15.5495Z",fill:"var(--Colours-Base-black, #000)"}),s.jsx("path",{d:"M16.605 15.8248C15.7949 15.8248 15.0382 15.6948 14.3351 15.4348C13.6319 15.1595 13.0205 14.7695 12.5007 14.2649C11.981 13.7449 11.5759 13.1178 11.2855 12.3837C10.9951 11.6496 10.8499 10.8085 10.8499 9.86027C10.8499 8.94265 11.0027 8.11679 11.3084 7.38269C11.6142 6.6333 12.0116 6.00626 12.5007 5.50156C13.0052 4.98158 13.5784 4.58394 14.2204 4.30865C14.8624 4.03337 15.5274 3.89573 16.2152 3.89573C17.0254 3.89573 17.7285 4.03337 18.3247 4.30865C18.9361 4.58394 19.4406 4.96628 19.838 5.45568C20.2507 5.94508 20.5564 6.52624 20.7552 7.19916C20.9539 7.85679 21.0532 8.5756 21.0532 9.35558C21.0532 9.66145 21.0379 9.95203 21.0074 10.2273C20.9768 10.5026 20.9462 10.7091 20.9157 10.8467L14.1058 10.8467C14.2586 11.6726 14.5949 12.2843 15.1146 12.682C15.6497 13.0643 16.2993 13.2555 17.0636 13.2555C17.8738 13.2555 18.6916 13.0031 19.517 12.4984L20.6405 14.5401C20.0596 14.9378 19.41 15.2513 18.6916 15.4807C17.9884 15.7101 17.2929 15.8248 16.605 15.8248ZM14.0828 8.62148L18.1871 8.62148C18.1871 7.97914 18.0419 7.45916 17.7515 7.06152C17.461 6.66389 16.9719 6.46507 16.284 6.46507C15.749 6.46507 15.2751 6.64094 14.8624 6.9927C14.465 7.34445 14.2051 7.88738 14.0828 8.62148Z",fill:"currentColor"}),s.jsx("path",{d:"M26.4777 15.8248C25.8969 15.8248 25.4077 15.7331 25.0103 15.5495C24.6128 15.366 24.2918 15.1137 24.0472 14.7925C23.818 14.456 23.6498 14.0584 23.5428 13.5996C23.4358 13.1255 23.3823 12.5978 23.3823 12.0167L23.3823 0L26.7529 0L26.7529 12.1543C26.7529 12.5061 26.814 12.7508 26.9363 12.8884C27.0739 13.0261 27.2114 13.0949 27.349 13.0949C27.4254 13.0949 27.4866 13.0949 27.5324 13.0949C27.5936 13.0949 27.67 13.0796 27.7617 13.049L28.1745 15.5495C27.991 15.626 27.7541 15.6872 27.4637 15.7331C27.1885 15.7942 26.8599 15.8248 26.4777 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M34.3225 15.8248C33.6193 15.8248 33.0155 15.7178 32.5111 15.5036C32.0219 15.2895 31.6168 14.9913 31.2958 14.609C30.9901 14.2266 30.7608 13.7678 30.608 13.2325C30.4704 12.682 30.4016 12.0779 30.4016 11.4202L30.4016 6.80918L28.8424 6.80918V4.30865L30.585 4.17101L30.9748 1.14286L33.7722 1.14286V4.17101L36.5007 4.17101V6.80918L33.7722 6.80918V11.3743C33.7722 12.0167 33.9021 12.4831 34.162 12.7737C34.4371 13.049 34.7963 13.1867 35.2396 13.1867C35.423 13.1867 35.6065 13.1637 35.7899 13.1178C35.9886 13.0719 36.1644 13.0184 36.3173 12.9572L36.8446 15.4119C36.5389 15.5036 36.1797 15.5954 35.767 15.6872C35.3543 15.7789 34.8727 15.8248 34.3225 15.8248Z",fill:"currentColor"}),s.jsx("path",{d:"M38.7205 15.5495V0L42.0911 0V3.41397L41.9306 5.45568C42.3586 5.07334 42.8554 4.72158 43.4209 4.40042C43.9865 4.06396 44.6591 3.89573 45.4387 3.89573C46.6768 3.89573 47.5711 4.30101 48.1214 5.11157C48.687 5.92214 48.9697 7.04623 48.9697 8.48384V15.5495H45.5992V8.91971C45.5992 8.09385 45.4845 7.52798 45.2553 7.22211C45.0413 6.91623 44.6897 6.7633 44.2005 6.7633C43.7725 6.7633 43.4057 6.8627 43.0999 7.06152C42.7942 7.24505 42.4579 7.51269 42.0911 7.86444V15.5495H38.7205Z",fill:"currentColor"}),s.jsx("path",{d:"M53.0807 20C52.7291 20 52.431 19.9771 52.1864 19.9312C51.9418 19.9006 51.7049 19.8471 51.4756 19.7706L52.0718 17.2013C52.1788 17.2318 52.3011 17.2624 52.4386 17.293C52.5762 17.3236 52.7061 17.3389 52.8284 17.3389C53.394 17.3389 53.8297 17.2013 54.1354 16.926C54.4411 16.6507 54.6704 16.2913 54.8233 15.8478L54.9837 15.2513L50.6043 4.17101L53.9978 4.17101L55.6258 9.05735C55.7939 9.57734 55.9468 10.105 56.0843 10.6402C56.2219 11.1755 56.3671 11.7261 56.52 12.292H56.6117C56.734 11.7567 56.8563 11.2214 56.9786 10.6861C57.1161 10.1356 57.2537 9.59263 57.3913 9.05735L58.767 4.17101H62L58.0562 15.6642C57.7811 16.383 57.4906 17.0101 57.1849 17.5454C56.8945 18.0959 56.5506 18.5471 56.1531 18.8989C55.771 19.2659 55.3277 19.5412 54.8233 19.7247C54.3341 19.9082 53.7532 20 53.0807 20Z",fill:"currentColor"})]}),Pr=({logoUrl:e,appName:t,height:r="28px",linkTo:o="/"})=>{const[a,n]=g.useState(null),[i,c]=g.useState(!0),[d,l]=g.useState(!1);g.useEffect(()=>{(async()=>{try{const f=Ve.getCachedLogo();f&&(f.base64Data||f.url)?(n(f.base64Data||f.url),c(!1)):e?(n(e),c(!1)):(l(!0),c(!1)),e&&Ve.updateInBackground(e,t,x=>{x.base64Data&&n(x.base64Data)})}catch(f){console.error("Error initializing logo:",f),l(!0),c(!1)}})()},[e,t]);const u=g.useCallback(()=>{console.error("Logo failed to load"),l(!0);const w=Ve.getCachedLogo();w&&a===w.base64Data&&Ve.clearCache()},[a]),h=g.useCallback(()=>{c(!1),l(!1)},[]),m=()=>d||!a&&!i?s.jsx(Vt,{}):a?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:a,height:r,alt:t||"Logo",onError:u,onLoad:h,style:{display:i?"none":"block",maxHeight:r,objectFit:"contain"}}),i&&s.jsx(Vt,{})]}):s.jsx(Vt,{});return s.jsx(G.Link,{to:o,className:"logo-link",children:m()})},pt=(e,t={})=>`${t.baseUrl||""}${e}`,Xo=(e,t={})=>t.endpoints?.[e]||"",Qo=(e={})=>e.timeout||3e4;function Ce(e,t){if(!e)return"/";const[r,o]=e.split("?"),a=r.replace(/\/+$/,"")+"/",n=new URLSearchParams;o&&new URLSearchParams(o).forEach((d,l)=>{n.set(l,d)}),t&&Object.keys(t).length>0&&Object.entries(t).forEach(([c,d])=>{d!=null&&n.set(c,String(d))});const i=n.toString();return i?`${a}?${i}`:a}const rt="";function Yo(e){const t=document.cookie.split("; ");for(const r of t){const[o,a]=r.split("=");if(o===e)return decodeURIComponent(a)}return null}const st=async()=>({"X-Csrftoken":Yo("csrftoken")}),Sr=async({fullUrl:e})=>{const t=`${rt}${e}${e.includes("?")?"&":"?"}_t=${Date.now()}`;return await fetch(t,{method:"GET",redirect:"follow",headers:{...await st(),"Content-Type":"application/json"}})},kr=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"POST",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),Ar=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"PUT",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),_r=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"DELETE",redirect:"follow",headers:{...await st(),"Content-Type":"application/json"},body:t instanceof FormData?t:JSON.stringify(t)}),Lr=async({fullUrl:e,payload:t})=>await fetch(rt+e,{method:"PATCH",redirect:"follow",headers:{...await st(),...!(t instanceof FormData)&&{"Content-Type":"application/json"}},body:t instanceof FormData?t:JSON.stringify(t)}),ve=async e=>{let t;try{const r={message:"Calling API endpoint",data:{endpoint:e.url,method:e.type}},o=pt(e.url);switch(e.type){case"POST":t=await kr({fullUrl:o,payload:e.payload});break;case"PUT":t=await Ar({fullUrl:o,payload:e.payload});break;case"PATCH":t=await Lr({fullUrl:o,payload:e.payload});break;case"DELETE":t=await _r({fullUrl:o,payload:e.payload});break;case"GET":default:t=await Sr({fullUrl:o})}if(t.status===200)try{return{response:(await t.json()).response,success:!0,responseStatus:t.status}}catch{return{response:{message:"Server Error"},success:!1,responseStatus:t.status}}else return{response:(await t.json()).response||{message:"Server Error"},success:!1,responseStatus:t.status}}catch(r){return console.error("API Request Error:",r),{response:{message:"Network Error"},success:!1,responseStatus:500}}},Ro=e=>{if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([o,a])=>{a!=null&&t.append(o,String(a))});const r=t.toString();return r?`?${r}`:""},Tr=()=>{const t=typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",r=t.startsWith("/")?t:`/${t}`;return{url:Ce(r),type:"GET"}},Nr=()=>({url:Ce("/api/v1/profile"),type:"GET"}),Er=e=>({url:Ce("/api/v1/profile"),type:"PUT",payload:e}),Fr=e=>({url:Ce("/api/v1/profile/photo"),type:"POST",payload:e}),Or=e=>({url:Ce("/api/v1/appauth/password/change/"),type:"PUT",payload:e}),Mr=e=>({url:Ce("/api/v1/profile/two-factor"),type:"POST",payload:e}),Ur=e=>({url:Ce(`/api/v1/appauth/role/switch/?role=${encodeURIComponent(e)}`),type:"POST"}),Br=()=>({url:Ce("/api/v1/appauth/sessions/"),type:"GET"}),qr=e=>({url:Ce("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:[e]}}),Ir=e=>({url:Ce("/api/v1/appauth/sessions/"),type:"DELETE",payload:{sessions:e}}),$r=()=>({url:Ce("/api/v1/appauth/logout"),type:"DELETE"}),Vr=()=>({url:Ce("/logout"),type:"POST"}),jr=async()=>ve(Tr()),Dr=async()=>ve(Nr()),Hr=async()=>ve(Br()),gt=async e=>ve(Er(e)),ea=async e=>ve(Fr(e)),zr=async e=>ve(Or(e)),ta=async e=>ve(Mr({enabled:e})),Wr=async e=>ve(Ur(e)),Zr=async e=>ve(qr(e)),Gr=async e=>ve(Ir(e)),Kr=async()=>ve($r()),Jr=async()=>ve(Vr());function mt(e){"@babel/helpers - typeof";return mt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(e)}var ra=/^\s+/,sa=/\s+$/;function $(e,t){if(e=e||"",t=t||{},e instanceof $)return e;if(!(this instanceof $))return new $(e,t);var r=oa(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||r.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}$.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),r,o,a,n,i,c;return r=t.r/255,o=t.g/255,a=t.b/255,r<=.03928?n=r/12.92:n=Math.pow((r+.055)/1.055,2.4),o<=.03928?i=o/12.92:i=Math.pow((o+.055)/1.055,2.4),a<=.03928?c=a/12.92:c=Math.pow((a+.055)/1.055,2.4),.2126*n+.7152*i+.0722*c},setAlpha:function(t){return this._a=ts(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Qr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Qr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.v*100);return this._a==1?"hsv("+r+", "+o+"%, "+a+"%)":"hsva("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=Xr(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Xr(this._r,this._g,this._b),r=Math.round(t.h*360),o=Math.round(t.s*100),a=Math.round(t.l*100);return this._a==1?"hsl("+r+", "+o+"%, "+a+"%)":"hsla("+r+", "+o+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return Yr(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return la(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(ae(this._r,255)*100)+"%",g:Math.round(ae(this._g,255)*100)+"%",b:Math.round(ae(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ae(this._r,255)*100)+"%, "+Math.round(ae(this._g,255)*100)+"%, "+Math.round(ae(this._b,255)*100)+"%)":"rgba("+Math.round(ae(this._r,255)*100)+"%, "+Math.round(ae(this._g,255)*100)+"%, "+Math.round(ae(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Ca[Yr(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+Rr(this._r,this._g,this._b,this._a),o=r,a=this._gradientType?"GradientType = 1, ":"";if(t){var n=$(t);o="#"+Rr(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+r+",endColorstr="+o+")"},toString:function(t){var r=!!t;t=t||this._format;var o=!1,a=this._a<1&&this._a>=0,n=!r&&a&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(o=this.toRgbString()),t==="prgb"&&(o=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(o=this.toHexString()),t==="hex3"&&(o=this.toHexString(!0)),t==="hex4"&&(o=this.toHex8String(!0)),t==="hex8"&&(o=this.toHex8String()),t==="name"&&(o=this.toName()),t==="hsl"&&(o=this.toHslString()),t==="hsv"&&(o=this.toHsvString()),o||this.toHexString())},clone:function(){return $(this.toString())},_applyModification:function(t,r){var o=t.apply(null,[this].concat([].slice.call(r)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(ha,arguments)},brighten:function(){return this._applyModification(fa,arguments)},darken:function(){return this._applyModification(pa,arguments)},desaturate:function(){return this._applyModification(ca,arguments)},saturate:function(){return this._applyModification(da,arguments)},greyscale:function(){return this._applyModification(ua,arguments)},spin:function(){return this._applyModification(ga,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(ya,arguments)},complement:function(){return this._applyCombination(ma,arguments)},monochromatic:function(){return this._applyCombination(ba,arguments)},splitcomplement:function(){return this._applyCombination(wa,arguments)},triad:function(){return this._applyCombination(es,[3])},tetrad:function(){return this._applyCombination(es,[4])}},$.fromRatio=function(e,t){if(mt(e)=="object"){var r={};for(var o in e)e.hasOwnProperty(o)&&(o==="a"?r[o]=e[o]:r[o]=ot(e[o]));e=r}return $(e,t)};function oa(e){var t={r:0,g:0,b:0},r=1,o=null,a=null,n=null,i=!1,c=!1;return typeof e=="string"&&(e=Sa(e)),mt(e)=="object"&&(Fe(e.r)&&Fe(e.g)&&Fe(e.b)?(t=aa(e.r,e.g,e.b),i=!0,c=String(e.r).substr(-1)==="%"?"prgb":"rgb"):Fe(e.h)&&Fe(e.s)&&Fe(e.v)?(o=ot(e.s),a=ot(e.v),t=ia(e.h,o,a),i=!0,c="hsv"):Fe(e.h)&&Fe(e.s)&&Fe(e.l)&&(o=ot(e.s),n=ot(e.l),t=na(e.h,o,n),i=!0,c="hsl"),e.hasOwnProperty("a")&&(r=e.a)),r=ts(r),{ok:i,format:e.format||c,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:r}}function aa(e,t,r){return{r:ae(e,255)*255,g:ae(t,255)*255,b:ae(r,255)*255}}function Xr(e,t,r){e=ae(e,255),t=ae(t,255),r=ae(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=(o+a)/2;if(o==a)n=i=0;else{var d=o-a;switch(i=c>.5?d/(2-o-a):d/(o+a),o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,l:c}}function na(e,t,r){var o,a,n;e=ae(e,360),t=ae(t,100),r=ae(r,100);function i(l,u,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?l+(u-l)*6*h:h<1/2?u:h<2/3?l+(u-l)*(2/3-h)*6:l}if(t===0)o=a=n=r;else{var c=r<.5?r*(1+t):r+t-r*t,d=2*r-c;o=i(d,c,e+1/3),a=i(d,c,e),n=i(d,c,e-1/3)}return{r:o*255,g:a*255,b:n*255}}function Qr(e,t,r){e=ae(e,255),t=ae(t,255),r=ae(r,255);var o=Math.max(e,t,r),a=Math.min(e,t,r),n,i,c=o,d=o-a;if(i=o===0?0:d/o,o==a)n=0;else{switch(o){case e:n=(t-r)/d+(t<r?6:0);break;case t:n=(r-e)/d+2;break;case r:n=(e-t)/d+4;break}n/=6}return{h:n,s:i,v:c}}function ia(e,t,r){e=ae(e,360)*6,t=ae(t,100),r=ae(r,100);var o=Math.floor(e),a=e-o,n=r*(1-t),i=r*(1-a*t),c=r*(1-(1-a)*t),d=o%6,l=[r,i,n,n,c,r][d],u=[c,r,r,i,n,n][d],h=[n,n,c,r,r,i][d];return{r:l*255,g:u*255,b:h*255}}function Yr(e,t,r,o){var a=[Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16))];return o&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function la(e,t,r,o,a){var n=[Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16)),Se(rs(o))];return a&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Rr(e,t,r,o){var a=[Se(rs(o)),Se(Math.round(e).toString(16)),Se(Math.round(t).toString(16)),Se(Math.round(r).toString(16))];return a.join("")}$.equals=function(e,t){return!e||!t?!1:$(e).toRgbString()==$(t).toRgbString()},$.random=function(){return $.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function ca(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.s-=t/100,r.s=wt(r.s),$(r)}function da(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.s+=t/100,r.s=wt(r.s),$(r)}function ua(e){return $(e).desaturate(100)}function ha(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.l+=t/100,r.l=wt(r.l),$(r)}function fa(e,t){t=t===0?0:t||10;var r=$(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(t/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(t/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(t/100)))),$(r)}function pa(e,t){t=t===0?0:t||10;var r=$(e).toHsl();return r.l-=t/100,r.l=wt(r.l),$(r)}function ga(e,t){var r=$(e).toHsl(),o=(r.h+t)%360;return r.h=o<0?360+o:o,$(r)}function ma(e){var t=$(e).toHsl();return t.h=(t.h+180)%360,$(t)}function es(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=$(e).toHsl(),o=[$(e)],a=360/t,n=1;n<t;n++)o.push($({h:(r.h+n*a)%360,s:r.s,l:r.l}));return o}function wa(e){var t=$(e).toHsl(),r=t.h;return[$(e),$({h:(r+72)%360,s:t.s,l:t.l}),$({h:(r+216)%360,s:t.s,l:t.l})]}function ya(e,t,r){t=t||6,r=r||30;var o=$(e).toHsl(),a=360/r,n=[$(e)];for(o.h=(o.h-(a*t>>1)+720)%360;--t;)o.h=(o.h+a)%360,n.push($(o));return n}function ba(e,t){t=t||6;for(var r=$(e).toHsv(),o=r.h,a=r.s,n=r.v,i=[],c=1/t;t--;)i.push($({h:o,s:a,v:n})),n=(n+c)%1;return i}$.mix=function(e,t,r){r=r===0?0:r||50;var o=$(e).toRgb(),a=$(t).toRgb(),n=r/100,i={r:(a.r-o.r)*n+o.r,g:(a.g-o.g)*n+o.g,b:(a.b-o.b)*n+o.b,a:(a.a-o.a)*n+o.a};return $(i)},$.readability=function(e,t){var r=$(e),o=$(t);return(Math.max(r.getLuminance(),o.getLuminance())+.05)/(Math.min(r.getLuminance(),o.getLuminance())+.05)},$.isReadable=function(e,t,r){var o=$.readability(e,t),a,n;switch(n=!1,a=ka(r),a.level+a.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7;break}return n},$.mostReadable=function(e,t,r){var o=null,a=0,n,i,c,d;r=r||{},i=r.includeFallbackColors,c=r.level,d=r.size;for(var l=0;l<t.length;l++)n=$.readability(e,t[l]),n>a&&(a=n,o=$(t[l]));return $.isReadable(e,o,{level:c,size:d})||!i?o:(r.includeFallbackColors=!1,$.mostReadable(e,["#fff","#000"],r))};var jt=$.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ca=$.hexNames=va(jt);function va(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}function ts(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ae(e,t){xa(e)&&(e="100%");var r=Pa(e);return e=Math.min(t,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function wt(e){return Math.min(1,Math.max(0,e))}function xe(e){return parseInt(e,16)}function xa(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function Pa(e){return typeof e=="string"&&e.indexOf("%")!=-1}function Se(e){return e.length==1?"0"+e:""+e}function ot(e){return e<=1&&(e=e*100+"%"),e}function rs(e){return Math.round(parseFloat(e)*255).toString(16)}function ss(e){return xe(e)/255}var ke=(function(){var e="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",r="(?:"+t+")|(?:"+e+")",o="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",a="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+o),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+o),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+o),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function Fe(e){return!!ke.CSS_UNIT.exec(e)}function Sa(e){e=e.replace(ra,"").replace(sa,"").toLowerCase();var t=!1;if(jt[e])e=jt[e],t=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=ke.rgb.exec(e))?{r:r[1],g:r[2],b:r[3]}:(r=ke.rgba.exec(e))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=ke.hsl.exec(e))?{h:r[1],s:r[2],l:r[3]}:(r=ke.hsla.exec(e))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=ke.hsv.exec(e))?{h:r[1],s:r[2],v:r[3]}:(r=ke.hsva.exec(e))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=ke.hex8.exec(e))?{r:xe(r[1]),g:xe(r[2]),b:xe(r[3]),a:ss(r[4]),format:t?"name":"hex8"}:(r=ke.hex6.exec(e))?{r:xe(r[1]),g:xe(r[2]),b:xe(r[3]),format:t?"name":"hex"}:(r=ke.hex4.exec(e))?{r:xe(r[1]+""+r[1]),g:xe(r[2]+""+r[2]),b:xe(r[3]+""+r[3]),a:ss(r[4]+""+r[4]),format:t?"name":"hex8"}:(r=ke.hex3.exec(e))?{r:xe(r[1]+""+r[1]),g:xe(r[2]+""+r[2]),b:xe(r[3]+""+r[3]),format:t?"name":"hex"}:!1}function ka(e){var t,r;return e=e||{level:"AA",size:"small"},t=(e.level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),r!=="small"&&r!=="large"&&(r="small"),{level:t,size:r}}const je=e=>({25:$.mix(e,"#FFFFFF",95).toHexString(),50:$.mix(e,"#FFFFFF",90).toHexString(),100:$.mix(e,"#FFFFFF",80).toHexString(),200:$.mix(e,"#FFFFFF",65).toHexString(),300:$.mix(e,"#FFFFFF",50).toHexString(),400:$.mix(e,"#FFFFFF",30).toHexString(),500:$(e).toHexString(),600:$.mix(e,"#000000",10).toHexString(),700:$.mix(e,"#000000",20).toHexString(),800:$.mix(e,"#000000",30).toHexString(),900:$.mix(e,"#000000",45).toHexString(),950:$.mix(e,"#000000",60).toHexString()}),yt=e=>{let t="";const r={brand:je(e.colors.primary),success:je(e.colors.success),warning:je(e.colors.warning),gray:je(e.colors.gray),error:je(e.colors.error)};return t=Object.entries(r).map(([o,a])=>Object.entries(a).map(([n,i])=>`--color-${o}-${n}: ${i}`).join(`;
3
+ `)).join(";"),e?.typography&&Object.entries(e.typography).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.borders&&Object.entries(e.borders).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--${n}: ${a}; `}),e?.shadows&&Object.entries(e.shadows).forEach(([o,a])=>{const n=o.replace(/_/g,"-");t+=`--shadow-${n}: ${a}; `}),e?.spacing&&Object.entries(e.spacing).forEach(([o,a])=>{t+=`--spacing-${o}: ${a}px; `}),t},os=e=>$(e).isLight(),Aa=e=>os(e)?"#000000":"#FFFFFF",as=(e,t=500)=>{const r=`--color-${e}-${t}`;if(typeof window<"u"&&window.getComputedStyle){const h=window.getComputedStyle(document.documentElement).getPropertyValue(r).trim();if(h)return h}const o=document.documentElement,a=o.style.getPropertyValue("--color-brand-500")||"#5048ED",n=o.style.getPropertyValue("--color-success-500")||"#10B981",i=o.style.getPropertyValue("--color-error-500")||"#F04438",c=o.style.getPropertyValue("--color-warning-500")||"#F59E0B",d=o.style.getPropertyValue("--color-gray-500")||"#6B7280",l={brand:a,success:n,error:i,warning:c,gray:d};return l[e]?je(l[e])[t]||l[e]:"#5048ED"},Dt=(e={})=>e.baseUrl||"",ns=(e,t={})=>e?e.startsWith("http://")||e.startsWith("https://")?e:pt(e,t):Dt(t),at=()=>{const e=G.useLocation(),{routes:t,apiConfig:r}=Pe(),a=e.pathname.split("/").filter(Boolean)[0],n=[...t].sort((d,l)=>l.path.length-d.path.length);let i=null;for(const d of n){if(d.path===e.pathname){i=d;break}if(d.path?.includes(":")){const l=d.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${l}$`))){i=d;break}}if(e.pathname.startsWith(d.path+"/")){i=d;break}}const c=i?.extra_params||i?.exta_params||{};return{baseUrl:Dt(r),apiUrl:c.api_endpoint||"",fullUrl:ns(c.api_endpoint||"",r),headers:c.headers||{},entity:a,...c}},_a=()=>{const e=G.useLocation(),{routes:t}=Pe(),r=[...t].sort((o,a)=>a.path.length-o.path.length);for(const o of r){if(o.path===e.pathname)return o;if(o.path?.includes(":")){const a=o.path.replace(/:[^/]+/g,"[^/]+");if(e.pathname.match(new RegExp(`^${a}$`)))return o}if(e.pathname.startsWith(o.path+"/"))return o}return null},La=(e,t={},r={})=>({baseUrl:Dt(t),apiUrl:e,fullUrl:ns(e,t),headers:r.headers||{},...r}),is=({basePath:e})=>{const t=at();return s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(Go.CrudHandler,{api_endpoint:t.apiUrl})})},Ht={crud:{requiredPackage:"@zango-core/crud",component:is},training:{requiredPackage:"@zango-core/training",component:({basePath:e})=>{at();const[t,r]=g.useState(null),[o,a]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const i=await import("@zango-core/training");r(()=>i.TrainingRouter)}catch(i){console.error("Failed to load training module:",i),a("Training module could not be loaded")}})()},[]),o?s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsxs("div",{className:"error-message",children:[s.jsx("h3",{children:"Training Module Error"}),s.jsx("p",{children:o})]})}):t?s.jsx("div",{className:"page-container",style:{height:"100%"},children:s.jsx(t,{})}):s.jsx("div",{className:"page-container",style:{height:"100%",padding:"20px"},children:s.jsx("div",{className:"loading-spinner",children:"Loading training module..."})})}}};Object.fromEntries(Object.entries(Ht).map(([e,t])=>[e,()=>import(t.requiredPackage)])),Object.fromEntries(Object.keys(Ht).map(e=>[e,[e]]));const ls=Object.fromEntries(Object.entries(Ht).map(([e,t])=>[e,t.component])),Ta=e=>e.filter(t=>t in ls),Na=e=>ls[e]||null,cs=({componentName:e,customPagesDir:t="src/custom/pages",fileExtension:r="js"})=>{const[o,a]=g.useState(null),n=(f,x)=>{navigator.clipboard.writeText(f).then(()=>{a(x),setTimeout(()=>a(null),2e3)})},i=e||"MyCustomPage",c=t,d=r,l=`import React from 'react';
4
4
 
5
5
  const ${i} = () => {
6
6
  return (
@@ -31,96 +31,115 @@ const App = () => {
31
31
  )
32
32
  };
33
33
 
34
- export default App;`,w=`mkdir -p ${c}`,m={container:{padding:"32px",maxWidth:"900px",margin:"0 auto",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},header:{marginBottom:"24px",borderBottom:"2px solid #e5e7eb",paddingBottom:"16px"},title:{fontSize:"28px",fontWeight:"600",color:"#111827",marginBottom:"8px"},subtitle:{fontSize:"16px",color:"#6b7280",marginTop:"8px"},errorBox:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"16px",marginBottom:"24px"},errorText:{color:"#dc2626",fontWeight:"500",fontSize:"15px"},setupGuide:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"24px",marginBottom:"24px"},sectionTitle:{fontSize:"20px",fontWeight:"600",color:"#111827",marginBottom:"16px",marginTop:"0"},stepTitle:{fontSize:"16px",fontWeight:"600",color:"#374151",marginBottom:"12px",marginTop:"20px"},stepList:{paddingLeft:"24px",color:"#4b5563",lineHeight:"1.8"},codeBlock:{position:"relative",marginTop:"12px",marginBottom:"20px"},pre:{backgroundColor:"#1f2937",color:"#f9fafb",padding:"16px",borderRadius:"6px",overflow:"auto",fontSize:"14px",lineHeight:"1.6",margin:"0",fontFamily:'"Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace'},copyButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"#374151",color:"#f9fafb",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},copiedButton:{backgroundColor:"#10b981"},inlineCode:{backgroundColor:"#f3f4f6",color:"#1f2937",padding:"2px 6px",borderRadius:"3px",fontSize:"14px",fontFamily:"monospace"},note:{backgroundColor:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:"6px",padding:"12px 16px",marginTop:"16px",fontSize:"14px",color:"#1e40af"}};return s.jsxs("div",{style:m.container,children:[s.jsxs("div",{style:m.header,children:[s.jsx("h1",{style:m.title,children:"Custom Page Setup Guide"}),s.jsx("p",{style:m.subtitle,children:"Follow the steps below to create your custom page component"})]}),s.jsxs("div",{style:m.errorBox,children:[s.jsxs("p",{style:m.errorText,children:['⚠️ Custom page component "',i,'" could not be loaded']}),s.jsxs("p",{style:{fontSize:"13px",color:"#991b1b",marginTop:"8px",marginBottom:"0"},children:["Expected location: ",s.jsxs("code",{style:{...m.inlineCode,backgroundColor:"#fee2e2",color:"#991b1b"},children:[c,"/",i,".",d]})]})]}),s.jsxs("div",{style:m.setupGuide,children:[s.jsx("h2",{style:m.sectionTitle,children:"📋 Quick Setup Steps"}),s.jsxs("ol",{style:m.stepList,children:[s.jsx("li",{children:"Create the custom pages directory structure"}),s.jsx("li",{children:"Create your component file with the required code"}),s.jsx("li",{children:"Export your component from the main index file"}),s.jsx("li",{children:"Ensure your App.js imports and passes customPages to ZangoApp"}),s.jsx("li",{children:"Refresh the browser to load your new page"})]}),s.jsx("h3",{style:m.stepTitle,children:"Step 1: Create Directory Structure"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"First, ensure the custom pages directory exists. Run this command in your terminal:"}),s.jsxs("div",{style:m.codeBlock,children:[s.jsx("button",{style:{...m.copyButton,...o===0?m.copiedButton:{}},onClick:()=>n(w,0),onMouseEnter:g=>{o!==0&&(g.target.style.backgroundColor="#4b5563")},onMouseLeave:g=>{o!==0&&(g.target.style.backgroundColor="#374151")},children:o===0?"✓ Copied!":"Copy"}),s.jsx("pre",{style:m.pre,children:w})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This creates the directory where all your custom page components will live."}),s.jsx("h3",{style:m.stepTitle,children:"Step 2: Create Your Component File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Create a new file at ",s.jsxs("code",{style:m.inlineCode,children:[c,"/",i,".",d]})," and paste this code:"]}),s.jsxs("div",{style:m.codeBlock,children:[s.jsx("button",{style:{...m.copyButton,...o===1?m.copiedButton:{}},onClick:()=>n(l,1),onMouseEnter:g=>{o!==1&&(g.target.style.backgroundColor="#4b5563")},onMouseLeave:g=>{o!==1&&(g.target.style.backgroundColor="#374151")},children:o===1?"✓ Copied!":"Copy"}),s.jsx("pre",{style:m.pre,children:l})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This is a basic React component. You can customize it with your own content, styles, and logic."}),s.jsx("h3",{style:m.stepTitle,children:"Step 3: Export from Main Index File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Add your component export to ",s.jsxs("code",{style:m.inlineCode,children:[c,"/index.",d]}),":"]}),s.jsxs("div",{style:m.codeBlock,children:[s.jsx("button",{style:{...m.copyButton,...o===2?m.copiedButton:{}},onClick:()=>n(u,2),onMouseEnter:g=>{o!==2&&(g.target.style.backgroundColor="#4b5563")},onMouseLeave:g=>{o!==2&&(g.target.style.backgroundColor="#374151")},children:o===2?"✓ Copied!":"Copy"}),s.jsx("pre",{style:m.pre,children:u})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"The index file exports all custom pages, making them available to the ZangoApp component."}),s.jsx("h3",{style:m.stepTitle,children:"Step 4: Verify App.js Configuration"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Ensure your ",s.jsx("code",{style:m.inlineCode,children:"App.js"})," imports custom pages and passes them to ",s.jsx("code",{style:m.inlineCode,children:"ZangoApp"}),":"]}),s.jsxs("div",{style:m.codeBlock,children:[s.jsx("button",{style:{...m.copyButton,...o===3?m.copiedButton:{}},onClick:()=>n(h,3),onMouseEnter:g=>{o!==3&&(g.target.style.backgroundColor="#4b5563")},onMouseLeave:g=>{o!==3&&(g.target.style.backgroundColor="#374151")},children:o===3?"✓ Copied!":"Copy"}),s.jsx("pre",{style:m.pre,children:h})]}),s.jsxs("div",{style:{backgroundColor:"#fef3c7",border:"1px solid #fcd34d",borderRadius:"6px",padding:"12px 16px",marginTop:"12px",fontSize:"13px",color:"#92400e"},children:[s.jsx("strong",{children:"⚠️ Important:"})," The ",s.jsx("code",{style:{...m.inlineCode,backgroundColor:"#fde68a",color:"#78350f"},children:"customPages"})," prop is required for ZangoApp to load your custom page components."]}),s.jsx("h3",{style:m.stepTitle,children:"Step 5: Refresh Your Browser"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"After saving all files, refresh your browser to load the new component. The custom page should now appear without errors."}),s.jsxs("div",{style:m.note,children:[s.jsx("strong",{children:"💡 Quick Reference:"}),s.jsx("br",{}),s.jsxs("div",{style:{marginTop:"8px",lineHeight:"2"},children:[s.jsx("strong",{children:"Component file:"})," ",s.jsxs("code",{style:{...m.inlineCode,marginLeft:"4px"},children:[c,"/",i,".",d]}),s.jsx("br",{}),s.jsx("strong",{children:"Export name:"})," ",s.jsx("code",{style:{...m.inlineCode,marginLeft:"4px"},children:i}),s.jsx("br",{}),s.jsx("strong",{children:"Index export:"})," ",s.jsxs("code",{style:{...m.inlineCode,marginLeft:"4px"},children:[c,"/index.",d]}),s.jsx("br",{}),s.jsx("strong",{children:"App import:"})," ",s.jsxs("code",{style:{...m.inlineCode,marginLeft:"4px"},children:["import * as customPages from './",c.replace("src/",""),"'"]})]})]})]}),s.jsxs("div",{style:{backgroundColor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"8px",padding:"16px",marginTop:"24px"},children:[s.jsx("h3",{style:{margin:"0 0 8px 0",color:"#15803d",fontSize:"16px"},children:"✅ Need Help?"}),s.jsx("p",{style:{margin:"0",color:"#166534",fontSize:"14px"},children:"Make sure the component name matches exactly between the filename, export statement, and route configuration. Check the browser console for any additional error messages."})]})]})},ss=({componentName:e,customPagesDir:t="src/custom/pages",customPagesGlob:r="../../custom/pages/*.js",fileExtension:o="js"})=>{const[a,n]=f.useState(null),[i,c]=f.useState(!1);return f.useEffect(()=>{if(n(null),c(!1),!e){c(!0);return}(async()=>{try{const l=Object.assign({}),u=`../../custom/pages/${e}.${o}`;if(l[u]){const h=await l[u]();n(()=>h.default)}else console.error(`Custom page not found: ${e} at ${u}`),c(!0)}catch(l){console.error("Error loading custom page:",l),c(!0)}})()},[e,o]),i?s.jsx(rs,{componentName:e,customPagesDir:t,fileExtension:o}):a?s.jsx(f.Suspense,{fallback:s.jsx("div",{style:{padding:"24px"},children:"Loading..."}),children:s.jsx(a,{})}):s.jsx("div",{style:{padding:"24px"},children:"Loading custom page..."})},jt=({message:e})=>s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",textAlign:"center",padding:"24px",backgroundColor:"#f5f5f5"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"48px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",maxWidth:"500px",width:"100%"},children:[s.jsx("h1",{style:{fontSize:"72px",margin:"0",color:"#e9eaeb",fontWeight:"bold",lineHeight:"1"},children:"404"}),s.jsx("h2",{style:{fontSize:"24px",margin:"16px 0",color:"#252b37",fontWeight:"600"},children:"Page Not Found"}),s.jsx("p",{style:{fontSize:"16px",color:"#717680",marginBottom:"32px",lineHeight:"1.5"},children:e||"The page you are looking for doesn't exist or has been moved."}),s.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[s.jsx("button",{onClick:()=>window.history.back(),style:{padding:"10px 24px",backgroundColor:"#5048ed",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},onMouseEnter:t=>t.target.style.backgroundColor="#4038d8",onMouseLeave:t=>t.target.style.backgroundColor="#5048ed",children:"Go Back"}),s.jsx("button",{onClick:()=>window.location.href="/",style:{padding:"10px 24px",backgroundColor:"transparent",color:"#5048ed",border:"1px solid #5048ed",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:t=>{const r=t.target;r.style.backgroundColor="#5048ed",r.style.color="white"},onMouseLeave:t=>{const r=t.target;r.style.backgroundColor="transparent",r.style.color="#5048ed"},children:"Go Home"})]})]})});/**
34
+ export default App;`,m=`mkdir -p ${c}`,w={container:{padding:"32px",maxWidth:"900px",margin:"0 auto",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},header:{marginBottom:"24px",borderBottom:"2px solid #e5e7eb",paddingBottom:"16px"},title:{fontSize:"28px",fontWeight:"600",color:"#111827",marginBottom:"8px"},subtitle:{fontSize:"16px",color:"#6b7280",marginTop:"8px"},errorBox:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"16px",marginBottom:"24px"},errorText:{color:"#dc2626",fontWeight:"500",fontSize:"15px"},setupGuide:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"24px",marginBottom:"24px"},sectionTitle:{fontSize:"20px",fontWeight:"600",color:"#111827",marginBottom:"16px",marginTop:"0"},stepTitle:{fontSize:"16px",fontWeight:"600",color:"#374151",marginBottom:"12px",marginTop:"20px"},stepList:{paddingLeft:"24px",color:"#4b5563",lineHeight:"1.8"},codeBlock:{position:"relative",marginTop:"12px",marginBottom:"20px"},pre:{backgroundColor:"#1f2937",color:"#f9fafb",padding:"16px",borderRadius:"6px",overflow:"auto",fontSize:"14px",lineHeight:"1.6",margin:"0",fontFamily:'"Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace'},copyButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"#374151",color:"#f9fafb",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},copiedButton:{backgroundColor:"#10b981"},inlineCode:{backgroundColor:"#f3f4f6",color:"#1f2937",padding:"2px 6px",borderRadius:"3px",fontSize:"14px",fontFamily:"monospace"},note:{backgroundColor:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:"6px",padding:"12px 16px",marginTop:"16px",fontSize:"14px",color:"#1e40af"}};return s.jsxs("div",{style:w.container,children:[s.jsxs("div",{style:w.header,children:[s.jsx("h1",{style:w.title,children:"Custom Page Setup Guide"}),s.jsx("p",{style:w.subtitle,children:"Follow the steps below to create your custom page component"})]}),s.jsxs("div",{style:w.errorBox,children:[s.jsxs("p",{style:w.errorText,children:['⚠️ Custom page component "',i,'" could not be loaded']}),s.jsxs("p",{style:{fontSize:"13px",color:"#991b1b",marginTop:"8px",marginBottom:"0"},children:["Expected location: ",s.jsxs("code",{style:{...w.inlineCode,backgroundColor:"#fee2e2",color:"#991b1b"},children:[c,"/",i,".",d]})]})]}),s.jsxs("div",{style:w.setupGuide,children:[s.jsx("h2",{style:w.sectionTitle,children:"📋 Quick Setup Steps"}),s.jsxs("ol",{style:w.stepList,children:[s.jsx("li",{children:"Create the custom pages directory structure"}),s.jsx("li",{children:"Create your component file with the required code"}),s.jsx("li",{children:"Export your component from the main index file"}),s.jsx("li",{children:"Ensure your App.js imports and passes customPages to ZangoApp"}),s.jsx("li",{children:"Refresh the browser to load your new page"})]}),s.jsx("h3",{style:w.stepTitle,children:"Step 1: Create Directory Structure"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"First, ensure the custom pages directory exists. Run this command in your terminal:"}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===0?w.copiedButton:{}},onClick:()=>n(m,0),onMouseEnter:f=>{o!==0&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==0&&(f.target.style.backgroundColor="#374151")},children:o===0?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:m})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This creates the directory where all your custom page components will live."}),s.jsx("h3",{style:w.stepTitle,children:"Step 2: Create Your Component File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Create a new file at ",s.jsxs("code",{style:w.inlineCode,children:[c,"/",i,".",d]})," and paste this code:"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===1?w.copiedButton:{}},onClick:()=>n(l,1),onMouseEnter:f=>{o!==1&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==1&&(f.target.style.backgroundColor="#374151")},children:o===1?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:l})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"This is a basic React component. You can customize it with your own content, styles, and logic."}),s.jsx("h3",{style:w.stepTitle,children:"Step 3: Export from Main Index File"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Add your component export to ",s.jsxs("code",{style:w.inlineCode,children:[c,"/index.",d]}),":"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===2?w.copiedButton:{}},onClick:()=>n(u,2),onMouseEnter:f=>{o!==2&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==2&&(f.target.style.backgroundColor="#374151")},children:o===2?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:u})]}),s.jsx("p",{style:{fontSize:"13px",color:"#6b7280",marginTop:"8px"},children:"The index file exports all custom pages, making them available to the ZangoApp component."}),s.jsx("h3",{style:w.stepTitle,children:"Step 4: Verify App.js Configuration"}),s.jsxs("p",{style:{color:"#4b5563",marginBottom:"12px"},children:["Ensure your ",s.jsx("code",{style:w.inlineCode,children:"App.js"})," imports custom pages and passes them to ",s.jsx("code",{style:w.inlineCode,children:"ZangoApp"}),":"]}),s.jsxs("div",{style:w.codeBlock,children:[s.jsx("button",{style:{...w.copyButton,...o===3?w.copiedButton:{}},onClick:()=>n(h,3),onMouseEnter:f=>{o!==3&&(f.target.style.backgroundColor="#4b5563")},onMouseLeave:f=>{o!==3&&(f.target.style.backgroundColor="#374151")},children:o===3?"✓ Copied!":"Copy"}),s.jsx("pre",{style:w.pre,children:h})]}),s.jsxs("div",{style:{backgroundColor:"#fef3c7",border:"1px solid #fcd34d",borderRadius:"6px",padding:"12px 16px",marginTop:"12px",fontSize:"13px",color:"#92400e"},children:[s.jsx("strong",{children:"⚠️ Important:"})," The ",s.jsx("code",{style:{...w.inlineCode,backgroundColor:"#fde68a",color:"#78350f"},children:"customPages"})," prop is required for ZangoApp to load your custom page components."]}),s.jsx("h3",{style:w.stepTitle,children:"Step 5: Refresh Your Browser"}),s.jsx("p",{style:{color:"#4b5563",marginBottom:"12px"},children:"After saving all files, refresh your browser to load the new component. The custom page should now appear without errors."}),s.jsxs("div",{style:w.note,children:[s.jsx("strong",{children:"💡 Quick Reference:"}),s.jsx("br",{}),s.jsxs("div",{style:{marginTop:"8px",lineHeight:"2"},children:[s.jsx("strong",{children:"Component file:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:[c,"/",i,".",d]}),s.jsx("br",{}),s.jsx("strong",{children:"Export name:"})," ",s.jsx("code",{style:{...w.inlineCode,marginLeft:"4px"},children:i}),s.jsx("br",{}),s.jsx("strong",{children:"Index export:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:[c,"/index.",d]}),s.jsx("br",{}),s.jsx("strong",{children:"App import:"})," ",s.jsxs("code",{style:{...w.inlineCode,marginLeft:"4px"},children:["import * as customPages from './",c.replace("src/",""),"'"]})]})]})]}),s.jsxs("div",{style:{backgroundColor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"8px",padding:"16px",marginTop:"24px"},children:[s.jsx("h3",{style:{margin:"0 0 8px 0",color:"#15803d",fontSize:"16px"},children:"✅ Need Help?"}),s.jsx("p",{style:{margin:"0",color:"#166534",fontSize:"14px"},children:"Make sure the component name matches exactly between the filename, export statement, and route configuration. Check the browser console for any additional error messages."})]})]})},ds=({componentName:e,customPagesDir:t="src/custom/pages",customPagesGlob:r="../../custom/pages/*.js",fileExtension:o="js"})=>{const[a,n]=g.useState(null),[i,c]=g.useState(!1);return g.useEffect(()=>{if(n(null),c(!1),!e){c(!0);return}(async()=>{try{const l=Object.assign({}),u=`../../custom/pages/${e}.${o}`;if(l[u]){const h=await l[u]();n(()=>h.default)}else console.error(`Custom page not found: ${e} at ${u}`),c(!0)}catch(l){console.error("Error loading custom page:",l),c(!0)}})()},[e,o]),i?s.jsx(cs,{componentName:e,customPagesDir:t,fileExtension:o}):a?s.jsx(g.Suspense,{fallback:s.jsx("div",{style:{padding:"24px"},children:"Loading..."}),children:s.jsx(a,{})}):s.jsx("div",{style:{padding:"24px"},children:"Loading custom page..."})},zt=({message:e})=>s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",textAlign:"center",padding:"24px",backgroundColor:"#f5f5f5"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"48px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",maxWidth:"500px",width:"100%"},children:[s.jsx("h1",{style:{fontSize:"72px",margin:"0",color:"#e9eaeb",fontWeight:"bold",lineHeight:"1"},children:"404"}),s.jsx("h2",{style:{fontSize:"24px",margin:"16px 0",color:"#252b37",fontWeight:"600"},children:"Page Not Found"}),s.jsx("p",{style:{fontSize:"16px",color:"#717680",marginBottom:"32px",lineHeight:"1.5"},children:e||"The page you are looking for doesn't exist or has been moved."}),s.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[s.jsx("button",{onClick:()=>window.history.back(),style:{padding:"10px 24px",backgroundColor:"#5048ed",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"background-color 0.2s"},onMouseEnter:t=>t.target.style.backgroundColor="#4038d8",onMouseLeave:t=>t.target.style.backgroundColor="#5048ed",children:"Go Back"}),s.jsx("button",{onClick:()=>window.location.href="/",style:{padding:"10px 24px",backgroundColor:"transparent",color:"#5048ed",border:"1px solid #5048ed",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:t=>{const r=t.target;r.style.backgroundColor="#5048ed",r.style.color="white"},onMouseLeave:t=>{const r=t.target;r.style.backgroundColor="transparent",r.style.color="#5048ed"},children:"Go Home"})]})]})});/**
35
35
  * @license lucide-react v0.544.0 - ISC
36
36
  *
37
37
  * This source code is licensed under the ISC license.
38
38
  * See the LICENSE file in the root directory of this source tree.
39
- */const xa=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pa=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase()),os=e=>{const t=Pa(e);return t.charAt(0).toUpperCase()+t.slice(1)},as=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim(),Sa=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
39
+ */const Ea=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fa=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase()),us=e=>{const t=Fa(e);return t.charAt(0).toUpperCase()+t.slice(1)},hs=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim(),Oa=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
40
40
  * @license lucide-react v0.544.0 - ISC
41
41
  *
42
42
  * This source code is licensed under the ISC license.
43
43
  * See the LICENSE file in the root directory of this source tree.
44
- */var ka={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
44
+ */var Ma={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
45
45
  * @license lucide-react v0.544.0 - ISC
46
46
  *
47
47
  * This source code is licensed under the ISC license.
48
48
  * See the LICENSE file in the root directory of this source tree.
49
- */const Aa=f.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:a="",children:n,iconNode:i,...c},d)=>f.createElement("svg",{ref:d,...ka,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:as("lucide",a),...!n&&!Sa(c)&&{"aria-hidden":"true"},...c},[...i.map(([l,u])=>f.createElement(l,u)),...Array.isArray(n)?n:[n]]));/**
49
+ */const Ua=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:a="",children:n,iconNode:i,...c},d)=>g.createElement("svg",{ref:d,...Ma,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:hs("lucide",a),...!n&&!Oa(c)&&{"aria-hidden":"true"},...c},[...i.map(([l,u])=>g.createElement(l,u)),...Array.isArray(n)?n:[n]]));/**
50
50
  * @license lucide-react v0.544.0 - ISC
51
51
  *
52
52
  * This source code is licensed under the ISC license.
53
53
  * See the LICENSE file in the root directory of this source tree.
54
- */const be=(e,t)=>{const r=f.forwardRef(({className:o,...a},n)=>f.createElement(Aa,{ref:n,iconNode:t,className:as(`lucide-${xa(os(e))}`,`lucide-${e}`,o),...a}));return r.displayName=os(e),r};/**
54
+ */const Ae=(e,t)=>{const r=g.forwardRef(({className:o,...a},n)=>g.createElement(Ua,{ref:n,iconNode:t,className:hs(`lucide-${Ea(us(e))}`,`lucide-${e}`,o),...a}));return r.displayName=us(e),r};/**
55
55
  * @license lucide-react v0.544.0 - ISC
56
56
  *
57
57
  * This source code is licensed under the ISC license.
58
58
  * See the LICENSE file in the root directory of this source tree.
59
- */const Dt=be("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
59
+ */const Wt=Ae("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
60
60
  * @license lucide-react v0.544.0 - ISC
61
61
  *
62
62
  * This source code is licensed under the ISC license.
63
63
  * See the LICENSE file in the root directory of this source tree.
64
- */const Te=be("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
64
+ */const Oe=Ae("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
65
65
  * @license lucide-react v0.544.0 - ISC
66
66
  *
67
67
  * This source code is licensed under the ISC license.
68
68
  * See the LICENSE file in the root directory of this source tree.
69
- */const _a=be("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
69
+ */const Ba=Ae("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
70
70
  * @license lucide-react v0.544.0 - ISC
71
71
  *
72
72
  * This source code is licensed under the ISC license.
73
73
  * See the LICENSE file in the root directory of this source tree.
74
- */const La=be("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
74
+ */const qa=Ae("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
75
75
  * @license lucide-react v0.544.0 - ISC
76
76
  *
77
77
  * This source code is licensed under the ISC license.
78
78
  * See the LICENSE file in the root directory of this source tree.
79
- */const Na=be("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);/**
79
+ */const bt=Ae("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
80
80
  * @license lucide-react v0.544.0 - ISC
81
81
  *
82
82
  * This source code is licensed under the ISC license.
83
83
  * See the LICENSE file in the root directory of this source tree.
84
- */const ft=be("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
84
+ */const Ct=Ae("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
85
85
  * @license lucide-react v0.544.0 - ISC
86
86
  *
87
87
  * This source code is licensed under the ISC license.
88
88
  * See the LICENSE file in the root directory of this source tree.
89
- */const gt=be("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);/**
89
+ */const Ia=Ae("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);/**
90
90
  * @license lucide-react v0.544.0 - ISC
91
91
  *
92
92
  * This source code is licensed under the ISC license.
93
93
  * See the LICENSE file in the root directory of this source tree.
94
- */const Ea=be("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);/**
94
+ */const fs=Ae("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
95
95
  * @license lucide-react v0.544.0 - ISC
96
96
  *
97
97
  * This source code is licensed under the ISC license.
98
98
  * See the LICENSE file in the root directory of this source tree.
99
- */const ns=be("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
99
+ */const Zt=Ae("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
100
100
  * @license lucide-react v0.544.0 - ISC
101
101
  *
102
102
  * This source code is licensed under the ISC license.
103
103
  * See the LICENSE file in the root directory of this source tree.
104
- */const Ht=be("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
104
+ */const Gt=Ae("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
105
105
  * @license lucide-react v0.544.0 - ISC
106
106
  *
107
107
  * This source code is licensed under the ISC license.
108
108
  * See the LICENSE file in the root directory of this source tree.
109
- */const zt=be("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
110
- * @license lucide-react v0.544.0 - ISC
111
- *
112
- * This source code is licensed under the ISC license.
113
- * See the LICENSE file in the root directory of this source tree.
114
- */const Ta=be("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);function is(e,t){return function(){return e.apply(t,arguments)}}const{toString:Oa}=Object.prototype,{getPrototypeOf:Wt}=Object,{iterator:mt,toStringTag:ls}=Symbol,wt=(e=>t=>{const r=Oa.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Pe=e=>(e=e.toLowerCase(),t=>wt(t)===e),yt=e=>t=>typeof t===e,{isArray:je}=Array,De=yt("undefined");function et(e){return e!==null&&!De(e)&&e.constructor!==null&&!De(e.constructor)&&fe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cs=Pe("ArrayBuffer");function Fa(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cs(e.buffer),t}const Ma=yt("string"),fe=yt("function"),ds=yt("number"),tt=e=>e!==null&&typeof e=="object",Ua=e=>e===!0||e===!1,bt=e=>{if(wt(e)!=="object")return!1;const t=Wt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ls in e)&&!(mt in e)},Ba=e=>{if(!tt(e)||et(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ia=Pe("Date"),qa=Pe("File"),Va=Pe("Blob"),$a=Pe("FileList"),ja=e=>tt(e)&&fe(e.pipe),Da=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||fe(e.append)&&((t=wt(e))==="formdata"||t==="object"&&fe(e.toString)&&e.toString()==="[object FormData]"))},Ha=Pe("URLSearchParams"),[za,Wa,Za,Ka]=["ReadableStream","Request","Response","Headers"].map(Pe),Ja=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let o,a;if(typeof e!="object"&&(e=[e]),je(e))for(o=0,a=e.length;o<a;o++)t.call(null,e[o],o,e);else{if(et(e))return;const n=r?Object.getOwnPropertyNames(e):Object.keys(e),i=n.length;let c;for(o=0;o<i;o++)c=n[o],t.call(null,e[c],c,e)}}function us(e,t){if(et(e))return null;t=t.toLowerCase();const r=Object.keys(e);let o=r.length,a;for(;o-- >0;)if(a=r[o],t===a.toLowerCase())return a;return null}const Ie=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,hs=e=>!De(e)&&e!==Ie;function Zt(){const{caseless:e,skipUndefined:t}=hs(this)&&this||{},r={},o=(a,n)=>{const i=e&&us(r,n)||n;bt(r[i])&&bt(a)?r[i]=Zt(r[i],a):bt(a)?r[i]=Zt({},a):je(a)?r[i]=a.slice():(!t||!De(a))&&(r[i]=a)};for(let a=0,n=arguments.length;a<n;a++)arguments[a]&&rt(arguments[a],o);return r}const Ga=(e,t,r,{allOwnKeys:o}={})=>(rt(t,(a,n)=>{r&&fe(a)?e[n]=is(a,r):e[n]=a},{allOwnKeys:o}),e),Xa=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ya=(e,t,r,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Qa=(e,t,r,o)=>{let a,n,i;const c={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),n=a.length;n-- >0;)i=a[n],(!o||o(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&Wt(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Ra=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const o=e.indexOf(t,r);return o!==-1&&o===r},en=e=>{if(!e)return null;if(je(e))return e;let t=e.length;if(!ds(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Wt(Uint8Array)),rn=(e,t)=>{const o=(e&&e[mt]).call(e);let a;for(;(a=o.next())&&!a.done;){const n=a.value;t.call(e,n[0],n[1])}},sn=(e,t)=>{let r;const o=[];for(;(r=e.exec(t))!==null;)o.push(r);return o},on=Pe("HTMLFormElement"),an=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,a){return o.toUpperCase()+a}),ps=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),nn=Pe("RegExp"),fs=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),o={};rt(r,(a,n)=>{let i;(i=t(a,n,e))!==!1&&(o[n]=i||a)}),Object.defineProperties(e,o)},ln=e=>{fs(e,(t,r)=>{if(fe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=e[r];if(fe(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},cn=(e,t)=>{const r={},o=a=>{a.forEach(n=>{r[n]=!0})};return je(e)?o(e):o(String(e).split(t)),r},dn=()=>{},un=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function hn(e){return!!(e&&fe(e.append)&&e[ls]==="FormData"&&e[mt])}const pn=e=>{const t=new Array(10),r=(o,a)=>{if(tt(o)){if(t.indexOf(o)>=0)return;if(et(o))return o;if(!("toJSON"in o)){t[a]=o;const n=je(o)?[]:{};return rt(o,(i,c)=>{const d=r(i,a+1);!De(d)&&(n[c]=d)}),t[a]=void 0,n}}return o};return r(e,0)},fn=Pe("AsyncFunction"),gn=e=>e&&(tt(e)||fe(e))&&fe(e.then)&&fe(e.catch),gs=((e,t)=>e?setImmediate:t?((r,o)=>(Ie.addEventListener("message",({source:a,data:n})=>{a===Ie&&n===r&&o.length&&o.shift()()},!1),a=>{o.push(a),Ie.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",fe(Ie.postMessage)),mn=typeof queueMicrotask<"u"?queueMicrotask.bind(Ie):typeof process<"u"&&process.nextTick||gs,y={isArray:je,isArrayBuffer:cs,isBuffer:et,isFormData:Da,isArrayBufferView:Fa,isString:Ma,isNumber:ds,isBoolean:Ua,isObject:tt,isPlainObject:bt,isEmptyObject:Ba,isReadableStream:za,isRequest:Wa,isResponse:Za,isHeaders:Ka,isUndefined:De,isDate:Ia,isFile:qa,isBlob:Va,isRegExp:nn,isFunction:fe,isStream:ja,isURLSearchParams:Ha,isTypedArray:tn,isFileList:$a,forEach:rt,merge:Zt,extend:Ga,trim:Ja,stripBOM:Xa,inherits:Ya,toFlatObject:Qa,kindOf:wt,kindOfTest:Pe,endsWith:Ra,toArray:en,forEachEntry:rn,matchAll:sn,isHTMLForm:on,hasOwnProperty:ps,hasOwnProp:ps,reduceDescriptors:fs,freezeMethods:ln,toObjectSet:cn,toCamelCase:an,noop:dn,toFiniteNumber:un,findKey:us,global:Ie,isContextDefined:hs,isSpecCompliantForm:hn,toJSONObject:pn,isAsyncFn:fn,isThenable:gn,setImmediate:gs,asap:mn,isIterable:e=>e!=null&&fe(e[mt])};function G(e,t,r,o,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),o&&(this.request=o),a&&(this.response=a,this.status=a.status?a.status:null)}y.inherits(G,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:y.toJSONObject(this.config),code:this.code,status:this.status}}});const ms=G.prototype,ws={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ws[e]={value:e}}),Object.defineProperties(G,ws),Object.defineProperty(ms,"isAxiosError",{value:!0}),G.from=(e,t,r,o,a,n)=>{const i=Object.create(ms);y.toFlatObject(e,i,function(u){return u!==Error.prototype},l=>l!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return G.call(i,c,d,r,o,a),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",n&&Object.assign(i,n),i};const wn=null;function Kt(e){return y.isPlainObject(e)||y.isArray(e)}function ys(e){return y.endsWith(e,"[]")?e.slice(0,-2):e}function bs(e,t,r){return e?e.concat(t).map(function(a,n){return a=ys(a),!r&&n?"["+a+"]":a}).join(r?".":""):t}function yn(e){return y.isArray(e)&&!e.some(Kt)}const bn=y.toFlatObject(y,{},null,function(t){return/^is[A-Z]/.test(t)});function Ct(e,t,r){if(!y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,C){return!y.isUndefined(C[A])});const o=r.metaTokens,a=r.visitor||u,n=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&y.isSpecCompliantForm(t);if(!y.isFunction(a))throw new TypeError("visitor must be a function");function l(g){if(g===null)return"";if(y.isDate(g))return g.toISOString();if(y.isBoolean(g))return g.toString();if(!d&&y.isBlob(g))throw new G("Blob is not supported. Use a Buffer instead.");return y.isArrayBuffer(g)||y.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,A,C){let b=g;if(g&&!C&&typeof g=="object"){if(y.endsWith(A,"{}"))A=o?A:A.slice(0,-2),g=JSON.stringify(g);else if(y.isArray(g)&&yn(g)||(y.isFileList(g)||y.endsWith(A,"[]"))&&(b=y.toArray(g)))return A=ys(A),b.forEach(function(O,F){!(y.isUndefined(O)||O===null)&&t.append(i===!0?bs([A],F,n):i===null?A:A+"[]",l(O))}),!1}return Kt(g)?!0:(t.append(bs(C,A,n),l(g)),!1)}const h=[],w=Object.assign(bn,{defaultVisitor:u,convertValue:l,isVisitable:Kt});function m(g,A){if(!y.isUndefined(g)){if(h.indexOf(g)!==-1)throw Error("Circular reference detected in "+A.join("."));h.push(g),y.forEach(g,function(b,_){(!(y.isUndefined(b)||b===null)&&a.call(t,b,y.isString(_)?_.trim():_,A,w))===!0&&m(b,A?A.concat(_):[_])}),h.pop()}}if(!y.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Cs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(o){return t[o]})}function Jt(e,t){this._pairs=[],e&&Ct(e,this,t)}const vs=Jt.prototype;vs.append=function(t,r){this._pairs.push([t,r])},vs.toString=function(t){const r=t?function(o){return t.call(this,o,Cs)}:Cs;return this._pairs.map(function(a){return r(a[0])+"="+r(a[1])},"").join("&")};function Cn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xs(e,t,r){if(!t)return e;const o=r&&r.encode||Cn;y.isFunction(r)&&(r={serialize:r});const a=r&&r.serialize;let n;if(a?n=a(t,r):n=y.isURLSearchParams(t)?t.toString():new Jt(t,r).toString(o),n){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}class Ps{constructor(){this.handlers=[]}use(t,r,o){return this.handlers.push({fulfilled:t,rejected:r,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){y.forEach(this.handlers,function(o){o!==null&&t(o)})}}const Ss={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Jt,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Gt=typeof window<"u"&&typeof document<"u",Xt=typeof navigator=="object"&&navigator||void 0,xn=Gt&&(!Xt||["ReactNative","NativeScript","NS"].indexOf(Xt.product)<0),Pn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Sn=Gt&&window.location.href||"http://localhost",ie={...Object.freeze({__proto__:null,hasBrowserEnv:Gt,hasStandardBrowserEnv:xn,hasStandardBrowserWebWorkerEnv:Pn,navigator:Xt,origin:Sn}),...vn};function kn(e,t){return Ct(e,new ie.classes.URLSearchParams,{visitor:function(r,o,a,n){return ie.isNode&&y.isBuffer(r)?(this.append(o,r.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}function An(e){return y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},r=Object.keys(e);let o;const a=r.length;let n;for(o=0;o<a;o++)n=r[o],t[n]=e[n];return t}function ks(e){function t(r,o,a,n){let i=r[n++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=n>=r.length;return i=!i&&y.isArray(a)?a.length:i,d?(y.hasOwnProp(a,i)?a[i]=[a[i],o]:a[i]=o,!c):((!a[i]||!y.isObject(a[i]))&&(a[i]=[]),t(r,o,a[i],n)&&y.isArray(a[i])&&(a[i]=_n(a[i])),!c)}if(y.isFormData(e)&&y.isFunction(e.entries)){const r={};return y.forEachEntry(e,(o,a)=>{t(An(o),a,r,0)}),r}return null}function Ln(e,t,r){if(y.isString(e))try{return(t||JSON.parse)(e),y.trim(e)}catch(o){if(o.name!=="SyntaxError")throw o}return(r||JSON.stringify)(e)}const st={transitional:Ss,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const o=r.getContentType()||"",a=o.indexOf("application/json")>-1,n=y.isObject(t);if(n&&y.isHTMLForm(t)&&(t=new FormData(t)),y.isFormData(t))return a?JSON.stringify(ks(t)):t;if(y.isArrayBuffer(t)||y.isBuffer(t)||y.isStream(t)||y.isFile(t)||y.isBlob(t)||y.isReadableStream(t))return t;if(y.isArrayBufferView(t))return t.buffer;if(y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(n){if(o.indexOf("application/x-www-form-urlencoded")>-1)return kn(t,this.formSerializer).toString();if((c=y.isFileList(t))||o.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ct(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return n||a?(r.setContentType("application/json",!1),Ln(t)):t}],transformResponse:[function(t){const r=this.transitional||st.transitional,o=r&&r.forcedJSONParsing,a=this.responseType==="json";if(y.isResponse(t)||y.isReadableStream(t))return t;if(t&&y.isString(t)&&(o&&!this.responseType||a)){const i=!(r&&r.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?G.from(c,G.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};y.forEach(["delete","get","head","post","put","patch"],e=>{st.headers[e]={}});const Nn=y.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"]),En=e=>{const t={};let r,o,a;return e&&e.split(`
115
- `).forEach(function(i){a=i.indexOf(":"),r=i.substring(0,a).trim().toLowerCase(),o=i.substring(a+1).trim(),!(!r||t[r]&&Nn[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},As=Symbol("internals");function ot(e){return e&&String(e).trim().toLowerCase()}function vt(e){return e===!1||e==null?e:y.isArray(e)?e.map(vt):String(e)}function Tn(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(e);)t[o[1]]=o[2];return t}const On=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Yt(e,t,r,o,a){if(y.isFunction(o))return o.call(this,t,r);if(a&&(t=r),!!y.isString(t)){if(y.isString(o))return t.indexOf(o)!==-1;if(y.isRegExp(o))return o.test(t)}}function Fn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function Mn(e,t){const r=y.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+r,{value:function(a,n,i){return this[o].call(this,t,a,n,i)},configurable:!0})})}let ge=class{constructor(t){t&&this.set(t)}set(t,r,o){const a=this;function n(c,d,l){const u=ot(d);if(!u)throw new Error("header name must be a non-empty string");const h=y.findKey(a,u);(!h||a[h]===void 0||l===!0||l===void 0&&a[h]!==!1)&&(a[h||d]=vt(c))}const i=(c,d)=>y.forEach(c,(l,u)=>n(l,u,d));if(y.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(y.isString(t)&&(t=t.trim())&&!On(t))i(En(t),r);else if(y.isObject(t)&&y.isIterable(t)){let c={},d,l;for(const u of t){if(!y.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?y.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,r)}else t!=null&&n(r,t,o);return this}get(t,r){if(t=ot(t),t){const o=y.findKey(this,t);if(o){const a=this[o];if(!r)return a;if(r===!0)return Tn(a);if(y.isFunction(r))return r.call(this,a,o);if(y.isRegExp(r))return r.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ot(t),t){const o=y.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||Yt(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let a=!1;function n(i){if(i=ot(i),i){const c=y.findKey(o,i);c&&(!r||Yt(o,o[c],c,r))&&(delete o[c],a=!0)}}return y.isArray(t)?t.forEach(n):n(t),a}clear(t){const r=Object.keys(this);let o=r.length,a=!1;for(;o--;){const n=r[o];(!t||Yt(this,this[n],n,t,!0))&&(delete this[n],a=!0)}return a}normalize(t){const r=this,o={};return y.forEach(this,(a,n)=>{const i=y.findKey(o,n);if(i){r[i]=vt(a),delete r[n];return}const c=t?Fn(n):String(n).trim();c!==n&&delete r[n],r[c]=vt(a),o[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return y.forEach(this,(o,a)=>{o!=null&&o!==!1&&(r[a]=t&&y.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
116
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(a=>o.set(a)),o}static accessor(t){const o=(this[As]=this[As]={accessors:{}}).accessors,a=this.prototype;function n(i){const c=ot(i);o[c]||(Mn(a,i),o[c]=!0)}return y.isArray(t)?t.forEach(n):n(t),this}};ge.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),y.reduceDescriptors(ge.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(o){this[r]=o}}}),y.freezeMethods(ge);function Qt(e,t){const r=this||st,o=t||r,a=ge.from(o.headers);let n=o.data;return y.forEach(e,function(c){n=c.call(r,n,a.normalize(),t?t.status:void 0)}),a.normalize(),n}function _s(e){return!!(e&&e.__CANCEL__)}function He(e,t,r){G.call(this,e??"canceled",G.ERR_CANCELED,t,r),this.name="CanceledError"}y.inherits(He,G,{__CANCEL__:!0});function Ls(e,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?e(r):t(new G("Request failed with status code "+r.status,[G.ERR_BAD_REQUEST,G.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Un(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Bn(e,t){e=e||10;const r=new Array(e),o=new Array(e);let a=0,n=0,i;return t=t!==void 0?t:1e3,function(d){const l=Date.now(),u=o[n];i||(i=l),r[a]=d,o[a]=l;let h=n,w=0;for(;h!==a;)w+=r[h++],h=h%e;if(a=(a+1)%e,a===n&&(n=(n+1)%e),l-i<t)return;const m=u&&l-u;return m?Math.round(w*1e3/m):void 0}}function In(e,t){let r=0,o=1e3/t,a,n;const i=(l,u=Date.now())=>{r=u,a=null,n&&(clearTimeout(n),n=null),e(...l)};return[(...l)=>{const u=Date.now(),h=u-r;h>=o?i(l,u):(a=l,n||(n=setTimeout(()=>{n=null,i(a)},o-h)))},()=>a&&i(a)]}const xt=(e,t,r=3)=>{let o=0;const a=Bn(50,250);return In(n=>{const i=n.loaded,c=n.lengthComputable?n.total:void 0,d=i-o,l=a(d),u=i<=c;o=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:n,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},r)},Ns=(e,t)=>{const r=e!=null;return[o=>t[0]({lengthComputable:r,total:e,loaded:o}),t[1]]},Es=e=>(...t)=>y.asap(()=>e(...t)),qn=ie.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ie.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,Vn=ie.hasStandardBrowserEnv?{write(e,t,r,o,a,n,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];y.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),y.isString(o)&&c.push(`path=${o}`),y.isString(a)&&c.push(`domain=${a}`),n===!0&&c.push("secure"),y.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function $n(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ts(e,t,r){let o=!$n(t);return e&&(o||r==!1)?jn(e,t):t}const Os=e=>e instanceof ge?{...e}:e;function qe(e,t){t=t||{};const r={};function o(l,u,h,w){return y.isPlainObject(l)&&y.isPlainObject(u)?y.merge.call({caseless:w},l,u):y.isPlainObject(u)?y.merge({},u):y.isArray(u)?u.slice():u}function a(l,u,h,w){if(y.isUndefined(u)){if(!y.isUndefined(l))return o(void 0,l,h,w)}else return o(l,u,h,w)}function n(l,u){if(!y.isUndefined(u))return o(void 0,u)}function i(l,u){if(y.isUndefined(u)){if(!y.isUndefined(l))return o(void 0,l)}else return o(void 0,u)}function c(l,u,h){if(h in t)return o(l,u);if(h in e)return o(void 0,l)}const d={url:n,method:n,data:n,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:c,headers:(l,u,h)=>a(Os(l),Os(u),h,!0)};return y.forEach(Object.keys({...e,...t}),function(u){const h=d[u]||a,w=h(e[u],t[u],u);y.isUndefined(w)&&h!==c||(r[u]=w)}),r}const Fs=e=>{const t=qe({},e);let{data:r,withXSRFToken:o,xsrfHeaderName:a,xsrfCookieName:n,headers:i,auth:c}=t;if(t.headers=i=ge.from(i),t.url=xs(Ts(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),y.isFormData(r)){if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(y.isFunction(r.getHeaders)){const d=r.getHeaders(),l=["content-type","content-length"];Object.entries(d).forEach(([u,h])=>{l.includes(u.toLowerCase())&&i.set(u,h)})}}if(ie.hasStandardBrowserEnv&&(o&&y.isFunction(o)&&(o=o(t)),o||o!==!1&&qn(t.url))){const d=a&&n&&Vn.read(n);d&&i.set(a,d)}return t},Dn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,o){const a=Fs(e);let n=a.data;const i=ge.from(a.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=a,u,h,w,m,g;function A(){m&&m(),g&&g(),a.cancelToken&&a.cancelToken.unsubscribe(u),a.signal&&a.signal.removeEventListener("abort",u)}let C=new XMLHttpRequest;C.open(a.method.toUpperCase(),a.url,!0),C.timeout=a.timeout;function b(){if(!C)return;const O=ge.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),W={data:!c||c==="text"||c==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:O,config:e,request:C};Ls(function(P){r(P),A()},function(P){o(P),A()},W),C=null}"onloadend"in C?C.onloadend=b:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.indexOf("file:")===0)||setTimeout(b)},C.onabort=function(){C&&(o(new G("Request aborted",G.ECONNABORTED,e,C)),C=null)},C.onerror=function(F){const W=F&&F.message?F.message:"Network Error",q=new G(W,G.ERR_NETWORK,e,C);q.event=F||null,o(q),C=null},C.ontimeout=function(){let F=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const W=a.transitional||Ss;a.timeoutErrorMessage&&(F=a.timeoutErrorMessage),o(new G(F,W.clarifyTimeoutError?G.ETIMEDOUT:G.ECONNABORTED,e,C)),C=null},n===void 0&&i.setContentType(null),"setRequestHeader"in C&&y.forEach(i.toJSON(),function(F,W){C.setRequestHeader(W,F)}),y.isUndefined(a.withCredentials)||(C.withCredentials=!!a.withCredentials),c&&c!=="json"&&(C.responseType=a.responseType),l&&([w,g]=xt(l,!0),C.addEventListener("progress",w)),d&&C.upload&&([h,m]=xt(d),C.upload.addEventListener("progress",h),C.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(u=O=>{C&&(o(!O||O.type?new He(null,e,C):O),C.abort(),C=null)},a.cancelToken&&a.cancelToken.subscribe(u),a.signal&&(a.signal.aborted?u():a.signal.addEventListener("abort",u)));const _=Un(a.url);if(_&&ie.protocols.indexOf(_)===-1){o(new G("Unsupported protocol "+_+":",G.ERR_BAD_REQUEST,e));return}C.send(n||null)})},Hn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let o=new AbortController,a;const n=function(l){if(!a){a=!0,c();const u=l instanceof Error?l:this.reason;o.abort(u instanceof G?u:new He(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,n(new G(`timeout ${t} of ms exceeded`,G.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(n):l.removeEventListener("abort",n)}),e=null)};e.forEach(l=>l.addEventListener("abort",n));const{signal:d}=o;return d.unsubscribe=()=>y.asap(c),d}},zn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let o=0,a;for(;o<r;)a=o+t,yield e.slice(o,a),o=a},Wn=async function*(e,t){for await(const r of Zn(e))yield*zn(r,t)},Zn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)break;yield o}}finally{await t.cancel()}},Ms=(e,t,r,o)=>{const a=Wn(e,t);let n=0,i,c=d=>{i||(i=!0,o&&o(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await a.next();if(l){c(),d.close();return}let h=u.byteLength;if(r){let w=n+=h;r(w)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),a.return()}},{highWaterMark:2})},Us=64*1024,{isFunction:Pt}=y,Kn=(({Request:e,Response:t})=>({Request:e,Response:t}))(y.global),{ReadableStream:Bs,TextEncoder:Is}=y.global,qs=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Jn=e=>{e=y.merge.call({skipUndefined:!0},Kn,e);const{fetch:t,Request:r,Response:o}=e,a=t?Pt(t):typeof fetch=="function",n=Pt(r),i=Pt(o);if(!a)return!1;const c=a&&Pt(Bs),d=a&&(typeof Is=="function"?(g=>A=>g.encode(A))(new Is):async g=>new Uint8Array(await new r(g).arrayBuffer())),l=n&&c&&qs(()=>{let g=!1;const A=new r(ie.origin,{body:new Bs,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!A}),u=i&&c&&qs(()=>y.isReadableStream(new o("").body)),h={stream:u&&(g=>g.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!h[g]&&(h[g]=(A,C)=>{let b=A&&A[g];if(b)return b.call(A);throw new G(`Response type '${g}' is not supported`,G.ERR_NOT_SUPPORT,C)})});const w=async g=>{if(g==null)return 0;if(y.isBlob(g))return g.size;if(y.isSpecCompliantForm(g))return(await new r(ie.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(y.isArrayBufferView(g)||y.isArrayBuffer(g))return g.byteLength;if(y.isURLSearchParams(g)&&(g=g+""),y.isString(g))return(await d(g)).byteLength},m=async(g,A)=>{const C=y.toFiniteNumber(g.getContentLength());return C??w(A)};return async g=>{let{url:A,method:C,data:b,signal:_,cancelToken:O,timeout:F,onDownloadProgress:W,onUploadProgress:q,responseType:P,headers:S,withCredentials:z="same-origin",fetchOptions:V}=Fs(g),N=t||fetch;P=P?(P+"").toLowerCase():"text";let M=Hn([_,O&&O.toAbortSignal()],F),K=null;const x=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let E;try{if(q&&l&&C!=="get"&&C!=="head"&&(E=await m(S,b))!==0){let $=new r(A,{method:"POST",body:b,duplex:"half"}),L;if(y.isFormData(b)&&(L=$.headers.get("content-type"))&&S.setContentType(L),$.body){const[D,R]=Ns(E,xt(Es(q)));b=Ms($.body,Us,D,R)}}y.isString(z)||(z=z?"include":"omit");const v=n&&"credentials"in r.prototype,k={...V,signal:M,method:C.toUpperCase(),headers:S.normalize().toJSON(),body:b,duplex:"half",credentials:v?z:void 0};K=n&&new r(A,k);let U=await(n?N(K,V):N(A,k));const Z=u&&(P==="stream"||P==="response");if(u&&(W||Z&&x)){const $={};["status","statusText","headers"].forEach(ae=>{$[ae]=U[ae]});const L=y.toFiniteNumber(U.headers.get("content-length")),[D,R]=W&&Ns(L,xt(Es(W),!0))||[];U=new o(Ms(U.body,Us,D,()=>{R&&R(),x&&x()}),$)}P=P||"text";let Q=await h[y.findKey(h,P)||"text"](U,g);return!Z&&x&&x(),await new Promise(($,L)=>{Ls($,L,{data:Q,headers:ge.from(U.headers),status:U.status,statusText:U.statusText,config:g,request:K})})}catch(v){throw x&&x(),v&&v.name==="TypeError"&&/Load failed|fetch/i.test(v.message)?Object.assign(new G("Network Error",G.ERR_NETWORK,g,K),{cause:v.cause||v}):G.from(v,v&&v.code,g,K)}}},Gn=new Map,Vs=e=>{let t=e&&e.env||{};const{fetch:r,Request:o,Response:a}=t,n=[o,a,r];let i=n.length,c=i,d,l,u=Gn;for(;c--;)d=n[c],l=u.get(d),l===void 0&&u.set(d,l=c?new Map:Jn(t)),u=l;return l};Vs();const Rt={http:wn,xhr:Dn,fetch:{get:Vs}};y.forEach(Rt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const $s=e=>`- ${e}`,Xn=e=>y.isFunction(e)||e===null||e===!1;function Yn(e,t){e=y.isArray(e)?e:[e];const{length:r}=e;let o,a;const n={};for(let i=0;i<r;i++){o=e[i];let c;if(a=o,!Xn(o)&&(a=Rt[(c=String(o)).toLowerCase()],a===void 0))throw new G(`Unknown adapter '${c}'`);if(a&&(y.isFunction(a)||(a=a.get(t))))break;n[c||"#"+i]=a}if(!a){const i=Object.entries(n).map(([d,l])=>`adapter ${d} `+(l===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
117
- `+i.map($s).join(`
118
- `):" "+$s(i[0]):"as no adapter specified";throw new G("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return a}const js={getAdapter:Yn,adapters:Rt};function er(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new He(null,e)}function Ds(e){return er(e),e.headers=ge.from(e.headers),e.data=Qt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),js.getAdapter(e.adapter||st.adapter,e)(e).then(function(o){return er(e),o.data=Qt.call(e,e.transformResponse,o),o.headers=ge.from(o.headers),o},function(o){return _s(o)||(er(e),o&&o.response&&(o.response.data=Qt.call(e,e.transformResponse,o.response),o.response.headers=ge.from(o.response.headers))),Promise.reject(o)})}const Hs="1.13.0",St={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{St[e]=function(o){return typeof o===e||"a"+(t<1?"n ":" ")+e}});const zs={};St.transitional=function(t,r,o){function a(n,i){return"[Axios v"+Hs+"] Transitional option '"+n+"'"+i+(o?". "+o:"")}return(n,i,c)=>{if(t===!1)throw new G(a(i," has been removed"+(r?" in "+r:"")),G.ERR_DEPRECATED);return r&&!zs[i]&&(zs[i]=!0,console.warn(a(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(n,i,c):!0}},St.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function Qn(e,t,r){if(typeof e!="object")throw new G("options must be an object",G.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let a=o.length;for(;a-- >0;){const n=o[a],i=t[n];if(i){const c=e[n],d=c===void 0||i(c,n,e);if(d!==!0)throw new G("option "+n+" must be "+d,G.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new G("Unknown option "+n,G.ERR_BAD_OPTION)}}const kt={assertOptions:Qn,validators:St},ke=kt.validators;let Ve=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ps,response:new Ps}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const n=a.stack?a.stack.replace(/^.+\n/,""):"";try{o.stack?n&&!String(o.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(o.stack+=`
119
- `+n):o.stack=n}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=qe(this.defaults,r);const{transitional:o,paramsSerializer:a,headers:n}=r;o!==void 0&&kt.assertOptions(o,{silentJSONParsing:ke.transitional(ke.boolean),forcedJSONParsing:ke.transitional(ke.boolean),clarifyTimeoutError:ke.transitional(ke.boolean)},!1),a!=null&&(y.isFunction(a)?r.paramsSerializer={serialize:a}:kt.assertOptions(a,{encode:ke.function,serialize:ke.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),kt.assertOptions(r,{baseUrl:ke.spelling("baseURL"),withXsrfToken:ke.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=n&&y.merge(n.common,n[r.method]);n&&y.forEach(["delete","get","head","post","put","patch","common"],g=>{delete n[g]}),r.headers=ge.concat(i,n);const c=[];let d=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(r)===!1||(d=d&&A.synchronous,c.unshift(A.fulfilled,A.rejected))});const l=[];this.interceptors.response.forEach(function(A){l.push(A.fulfilled,A.rejected)});let u,h=0,w;if(!d){const g=[Ds.bind(this),void 0];for(g.unshift(...c),g.push(...l),w=g.length,u=Promise.resolve(r);h<w;)u=u.then(g[h++],g[h++]);return u}w=c.length;let m=r;for(;h<w;){const g=c[h++],A=c[h++];try{m=g(m)}catch(C){A.call(this,C);break}}try{u=Ds.call(this,m)}catch(g){return Promise.reject(g)}for(h=0,w=l.length;h<w;)u=u.then(l[h++],l[h++]);return u}getUri(t){t=qe(this.defaults,t);const r=Ts(t.baseURL,t.url,t.allowAbsoluteUrls);return xs(r,t.params,t.paramsSerializer)}};y.forEach(["delete","get","head","options"],function(t){Ve.prototype[t]=function(r,o){return this.request(qe(o||{},{method:t,url:r,data:(o||{}).data}))}}),y.forEach(["post","put","patch"],function(t){function r(o){return function(n,i,c){return this.request(qe(c||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}Ve.prototype[t]=r(),Ve.prototype[t+"Form"]=r(!0)});let Rn=class Io{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(n){r=n});const o=this;this.promise.then(a=>{if(!o._listeners)return;let n=o._listeners.length;for(;n-- >0;)o._listeners[n](a);o._listeners=null}),this.promise.then=a=>{let n;const i=new Promise(c=>{o.subscribe(c),n=c}).then(a);return i.cancel=function(){o.unsubscribe(n)},i},t(function(n,i,c){o.reason||(o.reason=new He(n,i,c),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Io(function(a){t=a}),cancel:t}}};function ei(e){return function(r){return e.apply(null,r)}}function ti(e){return y.isObject(e)&&e.isAxiosError===!0}const tr={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(tr).forEach(([e,t])=>{tr[t]=e});function Ws(e){const t=new Ve(e),r=is(Ve.prototype.request,t);return y.extend(r,Ve.prototype,t,{allOwnKeys:!0}),y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(a){return Ws(qe(e,a))},r}const Y=Ws(st);Y.Axios=Ve,Y.CanceledError=He,Y.CancelToken=Rn,Y.isCancel=_s,Y.VERSION=Hs,Y.toFormData=Ct,Y.AxiosError=G,Y.Cancel=Y.CanceledError,Y.all=function(t){return Promise.all(t)},Y.spread=ei,Y.isAxiosError=ti,Y.mergeConfig=qe,Y.AxiosHeaders=ge,Y.formToJSON=e=>ks(y.isHTMLForm(e)?new FormData(e):e),Y.getAdapter=js.getAdapter,Y.HttpStatusCode=tr,Y.default=Y;const{Axios:Gl,AxiosError:Xl,CanceledError:Yl,isCancel:Ql,CancelToken:Rl,VERSION:ec,all:tc,Cancel:rc,isAxiosError:sc,spread:oc,toFormData:ac,AxiosHeaders:nc,HttpStatusCode:ic,formToJSON:lc,getAdapter:cc,mergeConfig:dc}=Y,ne="/api/v1/appauth".replace(/\/+$/,"");class Oe{constructor(t,r=ne,o=Y){this.basePath=r,this.axios=o,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class ri extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}const le={"UserProfileApi.getUserProfile":[{url:"/api/v1",description:"Profile API base URL"}],"UserProfileApi.updateUserProfile":[{url:"/api/v1",description:"Profile API base URL"}]},ce="https://example.com",te=function(e,t,r){if(r==null)throw new ri(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function rr(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(o=>rr(e,o,r)):Object.keys(t).forEach(o=>rr(e,t[o],`${r}${r!==""?".":""}${o}`)):e.has(r)?e.append(r,t):e.set(r,t))}const de=function(e,...t){const r=new URLSearchParams(e.search);rr(r,t),e.search=r.toString()},ze=function(e,t,r){const o=typeof e!="string";return(o&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):o)?JSON.stringify(e!==void 0?e:{}):e||""},ue=function(e){return e.pathname+e.search+e.hash},he=function(e,t,r,o){return(a=t,n=r)=>{const i={...e.options,url:(a.defaults.baseURL?"":o?.basePath??n)+e.url};return a.request(i)}},si=function(e){return{getAppAuthConfig:async(t={})=>{const r="/config/",o=new URL(r,ce);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};de(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:ue(o),options:n}},updateAppAuthConfig:async(t,r,o={})=>{te("updateAppAuthConfig","xCSRFToken",t),te("updateAppAuthConfig","authConfig",r);const a="/config/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={},u=new(e&&e.formDataCtor||FormData);r!==void 0&&u.append("auth_config",r),d["Content-Type"]="multipart/form-data",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let h=i&&i.headers?i.headers:{};return c.headers={...d,...h,...o.headers},c.data=u,{url:ue(n),options:c}}}},Zs=function(e){const t=si(e);return{async getAppAuthConfig(r){const o=await t.getAppAuthConfig(r),a=e?.serverIndex??0,n=le["ApplicationConfigurationApi.getAppAuthConfig"]?.[a]?.url;return(i,c)=>he(o,Y,ne,e)(i,n||c)},async updateAppAuthConfig(r,o,a){const n=await t.updateAppAuthConfig(r,o,a),i=e?.serverIndex??0,c=le["ApplicationConfigurationApi.updateAppAuthConfig"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)}}};class oi extends Oe{getAppAuthConfig(t){return Zs(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,o){return Zs(this.configuration).updateAppAuthConfig(t,r,o).then(a=>a(this.axios,this.basePath))}}const ai=function(e){return{loginUser:async(t,r,o={})=>{te("loginUser","xCSRFToken",t),te("loginUser","loginUserRequest",r);const a="/login/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}},logoutUser:async(t,r={})=>{te("logoutUser","xCSRFToken",t);const o="/logout/",a=new URL(o,ce);let n;e&&(n=e.baseOptions);const i={method:"DELETE",...n,...r},c={},d={};t!=null&&(c["X-CSRFToken"]=String(t)),de(a,d);let l=n&&n.headers?n.headers:{};return i.headers={...c,...l,...r.headers},{url:ue(a),options:i}}}},Ks=function(e){const t=ai(e);return{async loginUser(r,o,a){const n=await t.loginUser(r,o,a),i=e?.serverIndex??0,c=le["AuthenticationApi.loginUser"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)},async logoutUser(r,o){const a=await t.logoutUser(r,o),n=e?.serverIndex??0,i=le["AuthenticationApi.logoutUser"]?.[n]?.url;return(c,d)=>he(a,Y,ne,e)(c,i||d)}}};class ni extends Oe{loginUser(t,r,o){return Ks(this.configuration).loginUser(t,r,o).then(a=>a(this.axios,this.basePath))}logoutUser(t,r){return Ks(this.configuration).logoutUser(t,r).then(o=>o(this.axios,this.basePath))}}const ii=function(e){return{requestLoginOTP:async(t,r,o={})=>{te("requestLoginOTP","xCSRFToken",t),te("requestLoginOTP","loginOTPRequest",r);const a="/login/code/request/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}},verifyLoginOTP:async(t,r,o={})=>{te("verifyLoginOTP","xCSRFToken",t),te("verifyLoginOTP","loginOTPVerifyRequest",r);const a="/login/code/confirm/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}}}},Js=function(e){const t=ii(e);return{async requestLoginOTP(r,o,a){const n=await t.requestLoginOTP(r,o,a),i=e?.serverIndex??0,c=le["LoginWithOTPApi.requestLoginOTP"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)},async verifyLoginOTP(r,o,a){const n=await t.verifyLoginOTP(r,o,a),i=e?.serverIndex??0,c=le["LoginWithOTPApi.verifyLoginOTP"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)}}};class li extends Oe{requestLoginOTP(t,r,o){return Js(this.configuration).requestLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}verifyLoginOTP(t,r,o){return Js(this.configuration).verifyLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}}const ci=function(e){return{getMfaCode:async(t={})=>{const r="/mfa/getcode/",o=new URL(r,ce);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};de(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:ue(o),options:n}},verifyMfaCode:async(t,r,o={})=>{te("verifyMfaCode","xCSRFToken",t),te("verifyMfaCode","mfaVerifyRequest",r);const a="/mfa/verify/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}}}},Gs=function(e){const t=ci(e);return{async getMfaCode(r){const o=await t.getMfaCode(r),a=e?.serverIndex??0,n=le["MultiFactorAuthenticationApi.getMfaCode"]?.[a]?.url;return(i,c)=>he(o,Y,ne,e)(i,n||c)},async verifyMfaCode(r,o,a){const n=await t.verifyMfaCode(r,o,a),i=e?.serverIndex??0,c=le["MultiFactorAuthenticationApi.verifyMfaCode"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)}}};class di extends Oe{getMfaCode(t){return Gs(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,o){return Gs(this.configuration).verifyMfaCode(t,r,o).then(a=>a(this.axios,this.basePath))}}const ui=function(e){return{oauthCallback:async(t,r,o,a,n,i,c,d,l={})=>{te("oauthCallback","provider",t),te("oauthCallback","state",r),te("oauthCallback","code",o),te("oauthCallback","scope",a),te("oauthCallback","xCSRFToken",n);const u="/oauth/{provider}/callback/".replace("{provider}",encodeURIComponent(String(t))),h=new URL(u,ce);let w;e&&(w=e.baseOptions);const m={method:"POST",...w,...l},g={},A={};r!==void 0&&(A.state=r),o!==void 0&&(A.code=o),a!==void 0&&(A.scope=a),i!==void 0&&(A.authuser=i),c!==void 0&&(A.hd=c),d!==void 0&&(A.prompt=d),n!=null&&(g["X-CSRFToken"]=String(n)),de(h,A);let C=w&&w.headers?w.headers:{};return m.headers={...g,...C,...l.headers},{url:ue(h),options:m}},oauthRedirect:async(t,r,o,a,n={})=>{te("oauthRedirect","xCsrftoken",t),te("oauthRedirect","provider",r),te("oauthRedirect","process",o),te("oauthRedirect","callbackUrl",a);const i="/oauth/redirect/",c=new URL(i,ce);let d;e&&(d=e.baseOptions);const l={method:"POST",...d,...n},u={},h={},w=new URLSearchParams;r!==void 0&&w.set("provider",r),o!==void 0&&w.set("process",o),a!==void 0&&w.set("callback_url",a),u["Content-Type"]="application/x-www-form-urlencoded",t!=null&&(u["x-csrftoken"]=String(t)),de(c,h);let m=d&&d.headers?d.headers:{};return l.headers={...u,...m,...n.headers},l.data=w.toString(),{url:ue(c),options:l}}}},Xs=function(e){const t=ui(e);return{async oauthCallback(r,o,a,n,i,c,d,l,u){const h=await t.oauthCallback(r,o,a,n,i,c,d,l,u),w=e?.serverIndex??0,m=le["OAuthApi.oauthCallback"]?.[w]?.url;return(g,A)=>he(h,Y,ne,e)(g,m||A)},async oauthRedirect(r,o,a,n,i){const c=await t.oauthRedirect(r,o,a,n,i),d=e?.serverIndex??0,l=le["OAuthApi.oauthRedirect"]?.[d]?.url;return(u,h)=>he(c,Y,ne,e)(u,l||h)}}};class hi extends Oe{oauthCallback(t,r,o,a,n,i,c,d,l){return Xs(this.configuration).oauthCallback(t,r,o,a,n,i,c,d,l).then(u=>u(this.axios,this.basePath))}oauthRedirect(t,r,o,a,n){return Xs(this.configuration).oauthRedirect(t,r,o,a,n).then(i=>i(this.axios,this.basePath))}}const pi=function(e){return{changePassword:async(t,r,o={})=>{te("changePassword","xCSRFToken",t),te("changePassword","passwordChangeRequest",r);const a="/password/change/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}},setPassword:async(t,r,o={})=>{te("setPassword","xCSRFToken",t),te("setPassword","passwordSetRequest",r);const a="/password/set/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=ze(r,c,e),{url:ue(n),options:c}}}},Ys=function(e){const t=pi(e);return{async changePassword(r,o,a){const n=await t.changePassword(r,o,a),i=e?.serverIndex??0,c=le["PasswordManagementApi.changePassword"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)},async setPassword(r,o,a){const n=await t.setPassword(r,o,a),i=e?.serverIndex??0,c=le["PasswordManagementApi.setPassword"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)}}};class fi extends Oe{changePassword(t,r,o){return Ys(this.configuration).changePassword(t,r,o).then(a=>a(this.axios,this.basePath))}setPassword(t,r,o){return Ys(this.configuration).setPassword(t,r,o).then(a=>a(this.axios,this.basePath))}}const gi=function(e){return{setRole:async(t,r,o={})=>{te("setRole","xCSRFToken",t),te("setRole","role",r);const a="/role/set/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:ue(n),options:c}},switchRole:async(t,r,o={})=>{te("switchRole","xCSRFToken",t),te("switchRole","role",r);const a="/role/switch/",n=new URL(a,ce);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),de(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:ue(n),options:c}}}},Qs=function(e){const t=gi(e);return{async setRole(r,o,a){const n=await t.setRole(r,o,a),i=e?.serverIndex??0,c=le["RoleManagementApi.setRole"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)},async switchRole(r,o,a){const n=await t.switchRole(r,o,a),i=e?.serverIndex??0,c=le["RoleManagementApi.switchRole"]?.[i]?.url;return(d,l)=>he(n,Y,ne,e)(d,c||l)}}};class mi extends Oe{setRole(t,r,o){return Qs(this.configuration).setRole(t,r,o).then(a=>a(this.axios,this.basePath))}switchRole(t,r,o){return Qs(this.configuration).switchRole(t,r,o).then(a=>a(this.axios,this.basePath))}}const wi=function(e){return{getUserProfile:async(t={})=>{const r="/profile/",o=new URL(r,ce);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};de(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:ue(o),options:n}},updateUserProfile:async(t,r,o,a,n,i={})=>{te("updateUserProfile","xCSRFToken",t);const c="/profile/",d=new URL(c,ce);let l;e&&(l=e.baseOptions);const u={method:"PUT",...l,...i},h={},w={},m=new(e&&e.formDataCtor||FormData);r!==void 0&&m.append("name",r),o!==void 0&&m.append("mobile",o),a!==void 0&&m.append("auth_config",a),n!==void 0&&m.append("profile_pic",n),h["Content-Type"]="multipart/form-data",t!=null&&(h["X-CSRFToken"]=String(t)),de(d,w);let g=l&&l.headers?l.headers:{};return u.headers={...h,...g,...i.headers},u.data=m,{url:ue(d),options:u}}}},Rs=function(e){const t=wi(e);return{async getUserProfile(r){const o=await t.getUserProfile(r),a=e?.serverIndex??0,n=le["UserProfileApi.getUserProfile"]?.[a]?.url;return(i,c)=>he(o,Y,ne,e)(i,n||c)},async updateUserProfile(r,o,a,n,i,c){const d=await t.updateUserProfile(r,o,a,n,i,c),l=e?.serverIndex??0,u=le["UserProfileApi.updateUserProfile"]?.[l]?.url;return(h,w)=>he(d,Y,ne,e)(h,u||w)}}};class eo extends Oe{getUserProfile(t){return Rs(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,o,a,n,i){return Rs(this.configuration).updateUserProfile(t,r,o,a,n,i).then(c=>c(this.axios,this.basePath))}}class to{constructor(t={}){this.apiKey=t.apiKey,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.serverIndex=t.serverIndex,this.baseOptions={...t.baseOptions,headers:{...t.baseOptions?.headers}},this.formDataCtor=t.formDataCtor}isJsonMime(t){const r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}}const Fe=new to({basePath:"/api/v1/appauth",baseOptions:{withCredentials:!0}}),ro=new ni(Fe),yi=new oi(Fe),so=new li(Fe),oo=new di(Fe),ao=new fi(Fe),bi=new mi(Fe),no=new hi(Fe);new eo(Fe);const Ae=()=>{const e=document.cookie.match(/csrftoken=([^;]+)/);if(e)return decodeURIComponent(e[1]);const t=document.querySelector('meta[name="csrf-token"]');if(t)return t.getAttribute("content");const r=document.cookie.match(/csrf_token=([^;]+)/);return r?decodeURIComponent(r[1]):(console.warn("CSRF token not found. OTP requests may fail."),"")};let ee=null,$e=null;const j={async getAuthConfig(){return ee||$e||($e=(async()=>{try{const t=(await yi.getAppAuthConfig()).data;return t?.response?.auth_config?ee=t.response.auth_config:t?.auth_config?ee=t.auth_config:ee=t,console.log("Auth configuration loaded:",ee),ee}catch(e){throw console.error("Failed to fetch auth config:",e),$e=null,e}finally{$e=null}})(),$e)},getConfig(){return ee},isPasswordLoginEnabled(){return ee?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return ee?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return ee?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return ee?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return console.log("OIDC providers:",ee?.login_methods?.oidc?.providers),ee?.login_methods?.oidc?.providers||[]},getAllowedUsernames(){return(ee?.login_methods?.password?.allowed_usernames||ee?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return ee?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return ee?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return ee?.session_policy||{}},isRememberMeEnabled(){return ee?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return ee?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return ee?.password_policy||{}},getPasswordResetMethods(){return ee?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return ee?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return ee?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return ee?.two_factor_auth?.required||!1},getTwoFactorMethods(){return ee?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:ee?.two_factor_auth?.email_hook,sms:ee?.two_factor_auth?.sms_hook}},async login(e,t={}){try{ee||await this.getAuthConfig();const r=Ae()||"";console.log("Login csrfToken:",r);const o=e,a=await ro.loginUser(r,o);console.log("Login response:",a.data);const n=a.data;if(n?.success&&n?.response){const i=n.response;return i.status===401&&i.data?.next_step?(console.log("Multi-step authentication required:",i),i):i.data||i}return a.data}catch(r){if(console.error("Login error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required:",o),o}throw r}},async logout(e={}){try{const t=Ae()||"";await ro.logoutUser(t)}catch(t){console.error("Logout error:",t)}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return So});if(!e())throw new Error("Not authenticated - no valid session cookie");return{id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}}catch(e){throw console.error("Get current user failed:",e),new Error("Authentication verification failed")}},async verifyToken(e,t={}){return this.getCurrentUser()},async forgotPassword(e){try{return{message:"Reset email sent"}}catch(t){throw t}},async resetPassword(e){try{return{message:"Password reset successful"}}catch(t){throw t}},async fetchLoginMethods(){try{return(await this.getAuthConfig())?.login_methods||{}}catch(e){throw e}},async requestOTP(e){try{const t=Ae()||"";console.log("Requesting OTP for:",e,"CSRF token:",t?"present":"missing");const o=e.includes("@")?{email:e}:{phone:e};console.log("OTP request payload:",o);const a=await so.requestLoginOTP(t,o),n=a.data;return n?.success&&n?.response?n.response.data||n.response:a.data}catch(t){if(console.error("Request OTP error:",t),t.response?.data){const r=t.response.data;if(r?.response?.data?.message)throw new Error(r.response.data.message);if(r?.message)throw new Error(r.message)}throw t}},async verifyOTP(e,t){try{const r=Ae()||"";console.log("Verifying OTP for:",e,"code:",t,"CSRF token:",r?"present":"missing");const o={code:t};console.log("OTP verify payload:",o);const a=await so.verifyLoginOTP(r,o),n=a.data;return n?.success&&n?.response?n.response.status===401&&n.response.data?.next_step?(console.log("Multi-step authentication required after OTP verification:",n),n.response):n.response.data||n.response:a.data}catch(r){if(console.error("Verify OTP error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",o),o}if(r.response?.data){const o=r.response.data;if(o?.response?.data?.message)throw new Error(o.response.data.message);if(o?.message)throw new Error(o.message)}throw r}},async selectRole(e){try{const t=Ae()||"",r=await bi.setRole(t,e),o=r.data;if(o?.success&&o?.response){const a=o.response;return a.status===401&&a.data?.next_step?(console.log("Multi-step authentication after role selection:",a),a):a.data||a}return r.data}catch(t){if(console.error("Select role error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.success&&r?.response){const o=r.response;if(o.status===401&&o.data?.next_step)return console.log("Multi-step authentication after role selection:",o),o}if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after role selection:",r),r}throw t}},async sendTwoFactorCode(){try{return(await oo.getMfaCode()).data}catch(e){throw console.error("Send 2FA code error:",e),e}},async verifyTwoFactorCode(e){try{const t=Ae()||"";return(await oo.verifyMfaCode(t,{code:e})).data}catch(t){throw console.error("Verify 2FA code error:",t),t}},async changePassword(e,t){try{const r=Ae()||"";return(await ao.changePassword(r,{current_password:e,new_password:t})).data}catch(r){throw console.error("Change password error:",r),r}},async setPassword(e){try{const t=Ae()||"",r=await ao.setPassword(t,{new_password:e});return console.log("Set password response:",r.data),r.data}catch(t){if(console.error("Set password error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after password set:",r),r}throw t}},async processOAuthCallback(e,t,r,o,a,n,i,c){try{const d=Ae()||"",l=await no.oauthCallback(e,t,r,o,d,a,n,i,c),u=l.data;if(u?.success&&u?.response){const h=u.response;return h.status===401&&h.data?.next_step?(console.log("Multi-step authentication required:",h),h):h.data||h}return l.data}catch(d){if(d.response?.status===401&&d.response?.data){const l=d.response.data;if(l?.success&&l?.response){const u=l.response;if(u.status===401&&u.data?.next_step)return console.log("Multi-step authentication required:",u),u}if(l?.response?.data?.next_step||l?.data?.next_step)return console.log("Multi-step authentication required:",l),l}throw d}},clearConfig(){ee=null,$e=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return So});return e()}catch(e){return console.error("Authentication check failed:",e),!1}},validatePassword(e){const t=this.getPasswordPolicy(),r=[];return t.min_length&&e.length<t.min_length&&r.push(`Password must be at least ${t.min_length} characters long`),t.max_length&&e.length>t.max_length&&r.push(`Password must be at most ${t.max_length} characters long`),t.require_numbers&&!/\d/.test(e)&&r.push("Password must contain at least one number"),t.require_lowercase&&!/[a-z]/.test(e)&&r.push("Password must contain at least one lowercase letter"),t.require_uppercase&&!/[A-Z]/.test(e)&&r.push("Password must contain at least one uppercase letter"),t.require_special_chars&&!/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r.push("Password must contain at least one special character"),{valid:r.length===0,errors:r}},async oauthRedirect(e,t){try{const r=Ae()||"";return(await no.oauthRedirectPost(r,e,"login",t)).data}catch(r){throw r}},async getUserProfile(){try{const e=new to({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new eo(e).getUserProfile()).data}catch(e){throw console.error("Get user profile error:",e),e}}},io=e=>{let t;const r=new Set,o=(l,u)=>{const h=typeof l=="function"?l(t):l;if(!Object.is(h,t)){const w=t;t=u??(typeof h!="object"||h===null)?h:Object.assign({},t,h),r.forEach(m=>m(t,w))}},a=()=>t,c={setState:o,getState:a,getInitialState:()=>d,subscribe:l=>(r.add(l),()=>r.delete(l))},d=t=e(o,a,c);return c},Ci=(e=>e?io(e):io),vi=e=>e;function xi(e,t=vi){const r=f.useSyncExternalStore(e.subscribe,f.useCallback(()=>t(e.getState()),[e,t]),f.useCallback(()=>t(e.getInitialState()),[e,t]));return f.useDebugValue(r),r}const lo=e=>{const t=Ci(e),r=o=>xi(t,o);return Object.assign(r,t),r},At=(e=>e?lo(e):lo)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),Pi=({onSubmit:e})=>{const[t,r]=f.useState(!1),[o,a]=f.useState(!1),[n,i]=f.useState(0),[c,d]=f.useState(["email"]),[l,u]=f.useState("email"),{basePath:h}=At();f.useEffect(()=>{(async()=>{try{await j.getAuthConfig();const b=j.getPasswordResetMethods();b&&b.length>0&&(d(b),u(b[0]))}catch(b){console.error("Failed to load reset configuration:",b)}})()},[]);const w=async C=>{r(!0);try{if(e){const b={method:l,email:l==="email"?C.contact:void 0,phone:l==="sms"?C.contact:void 0};await e(b)}a(!0),i(b=>b+1)}catch(b){const _=l==="email"?"email":"SMS";p.toast.error(b.message||`Failed to send reset ${_}. Please try again.`)}finally{r(!1)}},m=()=>l==="email"?"Email address":"Phone number",g=()=>l==="email"?[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email address!"}]:[{required:!0,message:"Please input your phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}],A=()=>{const C=l==="email"?"Email":"SMS",b=l==="email"?"email":"phone";return{title:`${C} Sent!`,subTitle:`Please check your ${b} for password reset instructions.`}};if(o){const C=A();return s.jsx(p.Result,{status:"success",title:C.title,subTitle:C.subTitle,extra:[s.jsx(H.Link,{to:h,children:s.jsx(p.Button,{variant:"primary",children:"Back to Login"})},"login")]})}return s.jsxs("div",{className:"w-full max-w-md mx-auto",children:[s.jsx(H.Link,{to:h,className:"inline-block mb-6",children:s.jsx(p.Button,{variant:"link",size:"link",icon:s.jsx(Dt,{size:16}),children:"Back to Login"})}),s.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-3",children:"Forgot Password"}),s.jsxs("p",{className:"text-sm text-gray-600 mb-6",children:["Enter your"," ",l==="email"?"email address":"phone number"," and we'll send you instructions to reset your password."]}),s.jsxs(p.Form,{name:"forgot-password",className:"space-y-4",onFinish:w,layout:"vertical",children:[c.length>1&&s.jsx(p.FormItem,{label:"Reset method",children:s.jsxs(p.Select,{value:l,onChange:C=>{u(C),i(b=>b+1)},children:["options=",c.map(C=>({value:C,label:s.jsxs(p.Space,{children:[C==="email"?s.jsx(gt,{size:16}):s.jsx(Ea,{size:16}),C==="email"?"Email":"SMS"]})}))]})}),s.jsx(p.FormItem,{name:"contact",rules:g(),children:s.jsx(p.Input,{placeholder:m(),autoComplete:l==="email"?"email":"tel"})}),s.jsx(p.FormItem,{children:s.jsxs(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:t,fullWidth:!0,children:["Send Reset ",l==="email"?"Email":"SMS"]})})]},n)]})},Si=({onSubmit:e,token:t})=>{const[r,o]=f.useState(!1),[a,n]=f.useState(!1),[i,c]=f.useState(0),{basePath:d}=At(),l=(h,w)=>{if(!w)return Promise.reject(new Error("Please input your new password!"));const m=j.validatePassword(w);return m.valid?Promise.resolve():Promise.reject(new Error(m.errors.join(", ")))},u=async h=>{o(!0);try{e&&await e({...h,token:t}),n(!0),c(w=>w+1)}catch(w){p.toast.error(w.message||"Failed to reset password. Please try again.")}finally{o(!1)}};return a?s.jsx(p.Result,{status:"success",title:"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[s.jsx(H.Link,{to:d,children:s.jsx(p.Button,{variant:"primary",children:"Go to Login"})},"login")]}):s.jsxs("div",{className:"w-full max-w-md mx-auto",children:[s.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-3",children:"Reset Password"}),s.jsx("p",{className:"text-sm text-gray-600 mb-6",children:"Please enter your new password below."}),s.jsxs(p.Form,{name:"reset-password",className:"space-y-4",onFinish:u,layout:"vertical",children:[s.jsx(p.FormItem,{name:"password",rules:[{validator:l}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(ft,{size:16,className:"text-gray-400"}),placeholder:"New Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:"Please confirm your password!"},({getFieldValue:h})=>({validator(w,m){return!m||h("password")===m?Promise.resolve():Promise.reject(new Error("The two passwords do not match!"))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(ft,{size:16,className:"text-gray-400"}),placeholder:"Confirm Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:r,fullWidth:!0,children:"Reset Password"})})]},i)]})},ki=({onSuccess:e,onError:t,apiConfig:r={},redirectPath:o="/",title:a="Completing sign in...",errorTitle:n="Authentication Error",logo:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:w})=>{const[m,g]=f.useState(!0),[A,C]=f.useState(null),[b,_]=f.useState(!1),[O,F]=f.useState(null),[W,q]=f.useState("login"),[P,S]=f.useState({}),[z,V]=f.useState(["email"]),[N,M]=f.useState(""),K=f.useRef(!1),x=H.useLocation(),E=H.useNavigate(),{basePath:v,setAuthToken:k}=At(),U=async L=>{console.log("Login success result:",L);let D=L,R=null;L?.status===401&&L?.data?(D=L.data,R=L.data?.next_step):(D=L?.response?.data||L?.data||L,R=D?.next_step);const ae=L?.loginUser;(L?.token||D?.token)&&k(L.token||D.token);let se=L?.user||D?.user||ae||{};if((typeof se!="object"||se===null)&&(se={}),ae&&typeof ae=="object"&&(se={...se,email:se.email||ae.email,username:se.username||ae.username,phone:se.phone||ae.phone,name:se.name||ae.display}),R&&R.is_pending)switch(R.id){case"role_selection":let Ne=[];Array.isArray(R.metadata.roles)?Ne=R.metadata.roles:typeof R.metadata.roles=="object"&&(Ne=Object.entries(R.metadata.roles).map(([lt,Ke])=>({id:lt,name:Ke,is_default:!1}))),S({...L,roles:Ne,user:se,nextStep:R,loginUser:ae}),q("roleSelection"),_(!0),g(!1);return;case"mfa_authenticate":k(L.token||D?.token),V(R.metadata?.methods||["email"]),q("twoFactor"),_(!0),g(!1);return;case"set_password":k(L.token||D?.token);const Ee=R.metadata?.password_policy;M(R.metadata?.reason||"Password update required"),S({...L,passwordPolicy:Ee,user:se,loginUser:ae}),q("passwordReset"),_(!0),g(!1);return;case"password_expiry":k(L.token||D?.token),M("Your password has expired"),S({...L,passwordPolicy:R.metadata?.password_policy,user:se,loginUser:ae}),q("passwordReset"),_(!0),g(!1);return;case"first_login":k(L.token||D?.token),M("Please set up your password for first login"),S({...L,passwordPolicy:R.metadata?.password_policy,user:se,loginUser:ae}),q("passwordReset"),_(!0),g(!1);return;case"login_by_code":k(L.token||D?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),e&&e({...L,user:se,requiresOTP:!0});return}if(L.requires2FA){k(L.token),V(L.twoFactorMethods||["email"]),S({...L,user:se,loginUser:ae}),q("twoFactor"),_(!0),g(!1);return}if(L.requiresPasswordReset){k(L.token),M(L.passwordResetReason||"Your password has expired"),S({...L,user:se,loginUser:ae}),q("passwordReset"),_(!0),g(!1);return}};f.useEffect(()=>{K.current||Z()},[]);const Z=async()=>{try{K.current=!0;const L=new URLSearchParams(x.search),D=new URLSearchParams(x.hash.slice(1)),R=L.get("error")||D.get("error"),ae=L.get("error_description")||D.get("error_description");if(R)throw new Error(ae||`Authentication failed: ${R}`);const se=L.get("code"),Ne=L.get("state"),Ee=L.get("scope")||"",lt=L.get("authuser"),Ke=L.get("hd"),hr=L.get("prompt"),Ot=L.get("provider")||Ne?.split(":")[0];if(!se||!Ot)throw new Error("Missing required OAuth parameters (code or provider)");const Ce=await j.processOAuthCallback(Ot,Ne||"",se,Ee,lt||void 0,Ke||void 0,hr||void 0);if(console.log("OAuth callback result:",Ce),await U(Ce),Ce?.status===401&&Ce?.data?.next_step){const Ft=Ce.data.next_step;if(Ft.is_pending){console.log("Additional authentication step required after OAuth callback:",Ft.id),g(!1),e?e(Ce):(F(Ce),_(!0));return}}g(!1),e?e(Ce):setTimeout(()=>{E(o,{replace:!0})},1e3)}catch(L){console.error("OAuth callback error:",L),C(L.message||"Authentication failed"),g(!1),t&&t(L)}},Q=()=>{E(v,{replace:!0})},$=async L=>{console.log("Authentication complete:",L),p.toast.success("Authentication complete!");try{let D="/dashboard";L?.response?.data?.redirect_url?D=L.response.data.redirect_url:L?.data?.redirect_url?D=L.data.redirect_url:L?.redirect_url&&(D=L.redirect_url),console.log("Redirecting to:",D),window.location.href=D}catch(D){console.error("Error handling auth completion:",D)}};return b?s.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:O||P,onAuthComplete:$,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:w,redirectPath:o}):m?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsxs("div",{className:"text-center py-10 px-5",children:[s.jsx(p.Spin,{size:"large"}),s.jsx("h2",{className:"mt-6 mb-2 text-gray-800 text-xl font-medium",children:a}),s.jsx("p",{className:"text-gray-500 text-sm mb-0",children:"Please wait while we complete your authentication..."})]})})}):A?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:n,description:A,type:"error",showIcon:!0,action:s.jsx("a",{onClick:Q,children:"Return to login"})})})})}):s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:"Authentication Successful",description:"You have been successfully authenticated. Redirecting...",type:"success",showIcon:!0})})})})},Ai=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),s.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),s.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),s.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),_i=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M11.4 24H0V12.6h11.4V24z",fill:"#f25022"}),s.jsx("path",{d:"M24 24H12.6V12.6H24V24z",fill:"#00a4ef"}),s.jsx("path",{d:"M11.4 11.4H0V0h11.4v11.4z",fill:"#7fba00"}),s.jsx("path",{d:"M24 11.4H12.6V0H24v11.4z",fill:"#ffb900"})]}),Li=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),Ni=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#0077b5",children:s.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),Ei=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#1877f2",children:s.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Ti=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Oi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Fi=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z",fill:"#e01e5a"}),s.jsx("path",{d:"M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z",fill:"#e01e5a"}),s.jsx("path",{d:"M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z",fill:"#36c5f0"}),s.jsx("path",{d:"M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z",fill:"#36c5f0"}),s.jsx("path",{d:"M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z",fill:"#2eb67d"}),s.jsx("path",{d:"M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z",fill:"#2eb67d"}),s.jsx("path",{d:"M15.165 18.956a2.527 2.527 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z",fill:"#ecb22e"}),s.jsx("path",{d:"M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",fill:"#ecb22e"})]}),Mi=e=>{const t=e?e.toLowerCase():"";return t.includes("google")?s.jsx(Ai,{}):t.includes("microsoft")||t.includes("azure")?s.jsx(_i,{}):t.includes("github")?s.jsx(Li,{}):t.includes("linkedin")?s.jsx(Ni,{}):t.includes("facebook")?s.jsx(Ei,{}):t.includes("twitter")||t.includes("x.com")?s.jsx(Ti,{}):t.includes("apple")?s.jsx(Oi,{}):t.includes("slack")?s.jsx(Fi,{}):s.jsx(La,{size:16})},co=({provider:e,type:t="default"})=>{const r=async()=>{const a=await j.oauthRedirect(e.provider,window.location.href);console.log("redirect url:",a.response.redirect_url),a.success?window.location.href=a.response.redirect_url:console.error("Error authenticating:")},o=Mi(e.provider);return s.jsxs(p.Button,{className:`flex items-center justify-center gap-2 h-[42px] text-sm font-medium rounded-md transition-all duration-300 mb-2 last:mb-0 ${t==="oidc"?"bg-gray-100 border border-gray-200 text-gray-800 hover:bg-gray-200 hover:border-gray-300":t==="sso"?"bg-brand-500 border border-brand-500 text-white hover:bg-brand-600 hover:border-brand-600":"bg-white border border-gray-300 text-gray-800 hover:border-brand-500 hover:text-brand-500"}`,icon:o,block:!0,onClick:r,children:["Continue with ",e.provider]})},uo=({length:e=6,value:t="",onChange:r,disabled:o=!1})=>{const[a,n]=f.useState(new Array(e).fill("")),i=f.useRef([]);f.useEffect(()=>{if(t){const u=t.split("").slice(0,e),h=[...new Array(e).fill("")];u.forEach((w,m)=>{h[m]=w}),n(h)}},[t,e]);const c=(u,h)=>{const w=u.value;if(isNaN(w))return;const m=[...a];m[h]=w,n(m),r&&r(m.join("")),w&&h<e-1&&i.current[h+1].focus()},d=(u,h)=>{u.key==="Backspace"&&!a[h]&&h>0&&i.current[h-1].focus()},l=u=>{u.preventDefault();const w=u.clipboardData.getData("text/plain").slice(0,e).split(""),m=[...a];w.forEach((A,C)=>{!isNaN(A)&&C<e&&(m[C]=A)}),n(m),r&&r(m.join(""));const g=m.findIndex(A=>A==="");g!==-1?i.current[g].focus():i.current[e-1].focus()};return s.jsx(p.Space,{className:"flex justify-center gap-2",size:"small",children:a.map((u,h)=>s.jsx(p.Input,{ref:w=>i.current[h]=w,type:"text",inputMode:"numeric",maxLength:1,value:u,onChange:w=>c(w.target,h),onKeyDown:w=>d(w,h),onPaste:l,className:"!w-12 !h-12 text-center text-xl font-semibold rounded-lg transition-all duration-300 focus:border-brand-500 focus:shadow-[0_0_0_2px_rgba(106,138,18,0.2)] disabled:bg-gray-100 disabled:cursor-not-allowed",disabled:o},h))})},ho=f.createContext(null),We=()=>{const e=f.useContext(ho);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},Ui=({children:e,config:t={}})=>{const[r,o]=f.useState(null),[a,n]=f.useState(!0),[i,c]=f.useState(null),[d,l]=f.useState(null),[u,h]=f.useState(null),[w,m]=f.useState(null),g=f.useRef(!1);f.useEffect(()=>{g.current||(g.current=!0,A())},[]);const A=async()=>{try{const P=await j.getAuthConfig();m(P),await C()}catch(P){c(P.message),n(!1)}},C=async()=>{try{await j.isAuthenticated()?(o({id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}),c(null)):(o(null),c(null))}catch(P){console.error("Auth check failed:",P),o(null),c(null)}finally{n(!1)}},q={user:r,loading:a,error:i,login:async P=>{n(!0),c(null);try{const S=await j.login(P,t);let z=S,V=null;S?.status===401&&S?.data?(z=S.data,V=S.data?.next_step):(z=S?.response?.data||S?.data||S,V=z?.next_step);const N=S?.user||z?.user||{};if(N.email=N.email||P.email,N.username=N.username||P.username,N.phone=N.phone||P.phone,N.name=N.name||P.email||P.username||P.phone,l({user:N,token:S.token||z?.token,roles:S.roles,requires2FA:S.requires2FA,twoFactorMethods:S.twoFactorMethods,requiresPasswordReset:S.requiresPasswordReset,passwordResetReason:S.passwordResetReason}),V&&V.is_pending&&V.id==="role_selection")return{...S,user:N};if(S.roles&&S.roles.length>1)return h(S.roles),{requiresRoleSelection:!0,roles:S.roles,user:N,token:S.token};let M=S;return S.roles&&S.roles.length===1?M.user={...N,role:S.roles[0]}:M.user=N,S.requires2FA?{...M,requires2FA:!0,twoFactorMethods:S.twoFactorMethods||["email"]}:S.requiresPasswordReset?{...M,requiresPasswordReset:!0,passwordResetReason:S.passwordResetReason}:(o(M.user),l(null),h(null),{...M,user:N})}catch(S){throw console.error("AuthProvider login caught error:",S),console.error("AuthProvider error.message:",S.message),c(S.message),S}finally{n(!1)}},logout:async()=>{n(!0);try{await j.logout(t),o(null),l(null),h(null)}catch(P){console.error("Logout failed:",P)}finally{n(!1)}},selectRole:async P=>{if(!d)throw new Error("No pending authentication");n(!0);try{t.roleSelectionEndpoint&&await j.selectRole(P,d.token,t);const S={...d.user,role:P},z={...d,user:S};return z.requires2FA?(l(z),{...z,requires2FA:!0,twoFactorMethods:z.twoFactorMethods||["email"]}):z.requiresPasswordReset?(l(z),{...z,requiresPasswordReset:!0,passwordResetReason:z.passwordResetReason}):(o(S),l(null),h(null),{user:S,token:d.token})}catch(S){throw c(S.message),S}finally{n(!1)}},checkAuth:C,forgotPassword:async P=>j.forgotPassword(P),resetPassword:async P=>j.resetPassword(P),isAuthenticated:!!r,pendingAuth:d,availableRoles:u,authConfig:w,requiresRoleSelection:!!d&&!!u};return s.jsx(ho.Provider,{value:q,children:e})},{Text:sr,Title:_t}=p.Typography,po=({onSuccess:e,onBack:t})=>{const[r,o]=f.useState("request"),[a,n]=f.useState(!1),[i,c]=f.useState(""),[d,l]=f.useState("email"),[u,h]=f.useState(""),[w,m]=f.useState(0),[g,A]=f.useState(0),[C,b]=f.useState(null),[_,O]=f.useState(!1),[F,W]=f.useState(""),[q,P]=f.useState(""),[S,z]=f.useState(!1),{authConfig:V}=We(),N=async()=>{try{return await j.isAuthenticated()}catch{return!1}};f.useEffect(()=>{if(V){const L=j.getAllowedUsernames();L&&L.length>0&&l(L[0])}},[V]),f.useEffect(()=>{(async()=>{const D=await N();z(D),D&&r!=="success"&&o("success")})()},[r]),f.useEffect(()=>{if(w>0){const L=setTimeout(()=>m(w-1),1e3);return()=>clearTimeout(L)}},[w]);const M=L=>L==="email"?"Enter your email":"Enter your mobile number",K=L=>L==="email"?[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email!"}]:L==="mobile"?[{required:!0,message:"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid mobile number!"}]:[{required:!0,message:"Please input your username!"},{min:3,message:"Username must be at least 3 characters long"}],x=async L=>{n(!0);try{await j.requestOTP(L.username),c(L.username),o("verify"),m(30),p.toast.success("OTP sent successfully!")}catch(D){D?.response?.status===401?(c(L.username),o("verify"),m(30),p.toast.success("Please check your email/phone for the OTP code")):p.toast.error(D.message||"Failed to send OTP")}finally{n(!1)}},E=async()=>{if(u.length!==6){p.toast.error("Please enter 6 digit OTP");return}n(!0);try{const D=await j.verifyOTP(i,u);b(D),o("success"),p.toast.success("Login successful!")}catch(D){p.toast.error(D.message||"Invalid OTP"),h("")}finally{n(!1)}},v=async()=>{if(!F||!q){p.toast.error("Please fill in all password fields");return}if(F!==q){p.toast.error("Passwords do not match");return}if(F.length<8){p.toast.error("Password must be at least 8 characters long");return}n(!0);try{await j.setPassword(F),p.toast.success("Password changed successfully!"),O(!1),W(""),P("")}catch(L){p.toast.error(L.message||"Failed to change password")}finally{n(!1)}},k=()=>{C&&e(C)},U=async()=>{n(!0);try{await j.logout(),p.toast.success("Logged out successfully"),o("request"),b(null),c(""),h(""),z(!1)}catch(L){p.toast.error(L.message||"Failed to logout")}finally{n(!1)}},Z=async()=>{if(!(w>0)){n(!0);try{await j.requestOTP(i),m(30),p.toast.success("OTP resent successfully!")}catch(L){p.toast.error(L.message||"Failed to resend OTP")}finally{n(!1)}}};if(!V)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const Q=j.getAllowedUsernames(),$=6;return r==="success"&&S?s.jsxs("div",{className:"w-full",children:[s.jsx(_t,{level:4,className:"!mb-2 text-center",children:C?"Login Successful!":"Already Logged In"}),s.jsx(sr,{className:"block text-center text-gray-500 mb-6",children:C?"You have successfully logged in.":"You are currently logged in."}),_?s.jsxs("div",{className:"space-y-4",children:[s.jsx(_t,{level:5,className:"!mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.Input.Password,{value:F,onChange:L=>W(L.target.value),placeholder:"Enter new password",disabled:a})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.Input.Password,{value:q,onChange:L=>P(L.target.value),placeholder:"Confirm new password",disabled:a})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:v,loading:a,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{O(!1),W(""),P("")},disabled:a,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[C&&s.jsx(p.Button,{type:"primary",block:!0,onClick:k,children:"Continue to Dashboard"}),s.jsx(p.Button,{block:!0,onClick:()=>O(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:U,loading:a,children:"Logout"})]})]}):r==="verify"?s.jsxs("div",{className:"w-full",children:[s.jsx(p.Button,{variant:"link",icon:s.jsx(Dt,{size:16}),onClick:()=>o("request"),className:"mb-4",children:"Back"}),s.jsx(_t,{level:4,className:"!mb-2 text-center",children:"Verify OTP"}),s.jsxs(sr,{className:"block text-center text-gray-500 mb-6",children:["We've sent a ",$,"-digit code to ",i]}),s.jsx("div",{className:"my-8 flex justify-center",children:s.jsx(uo,{length:$,value:u,onChange:h,disabled:a})}),s.jsx(p.Button,{type:"primary",block:!0,loading:a,onClick:E,className:"mt-6",children:"Verify OTP"}),s.jsx("div",{className:"text-center mt-4",children:w>0?s.jsxs(sr,{type:"secondary",children:["Resend OTP in ",w,"s"]}):s.jsx(p.Button,{type:"link",onClick:Z,loading:a,children:"Resend OTP"})})]}):s.jsxs("div",{className:"w-full",children:[t&&s.jsx(p.Button,{variant:"link",icon:s.jsx(Dt,{size:16}),onClick:t,className:"mb-4",children:"Back to other methods"}),s.jsx(_t,{level:4,className:"!mb-2 text-center",children:"Sign in with OTP"}),s.jsxs(p.Form,{name:"otp-request",onFinish:x,layout:"vertical",children:[Q.length>1&&s.jsx(p.FormItem,{children:s.jsx(p.Segmented,{options:Q.map(L=>({label:s.jsxs(p.Space,{children:[L==="email"?s.jsx(gt,{size:16}):L==="mobile"?s.jsx(Ht,{size:16}):s.jsx(zt,{size:16}),s.jsx("span",{children:L==="mobile"?"Phone":L==="email"?"Email":"Username"})]}),value:L})),value:d,onChange:L=>l(L),block:!0,className:"bg-gray-100 mb-2"})}),s.jsx(p.FormItem,{name:"username",rules:K(d),children:s.jsx(p.Input,{placeholder:M(d)})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:a,children:"Send OTP"})})]},g)]})},Bi=({onLogin:e,showRememberMe:t=!0})=>{const[r,o]=f.useState(!1),[a,n]=f.useState(null),[i,c]=f.useState(null),[d,l]=f.useState("email"),[u,h]=f.useState(!1),[w,m]=f.useState(0),[g,A]=f.useState(!1),[C,b]=f.useState(!1),[_,O]=f.useState(""),[F,W]=f.useState(""),{authConfig:q}=We(),P=async()=>{try{return await j.isAuthenticated()}catch{return!1}};if(f.useEffect(()=>{if(q){const v=j.getAllowedUsernames();if(v&&v.length>0){const k=v.includes("email"),U=v.includes("mobile");k?l("email"):U&&l("mobile")}j.isPasswordLoginEnabled()?c("password"):j.isOTPLoginEnabled()&&c("otp")}},[q]),f.useEffect(()=>{(async()=>{const k=await P();A(k)})()},[]),!q)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})});const S=v=>v==="email"?[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email!"}]:v==="mobile"?[{required:!0,message:"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email!"}],z=async v=>{o(!0),n(null);try{const k=j.getAllowedUsernames(),U=k.includes("email"),Z=k.includes("mobile"),Q=U&&Z?d:U?"email":"mobile",$={email:Q==="email"?v.username:void 0,phone:Q==="mobile"?v.username:void 0,password:v.password,remember_me:v.remember||!1};await e($)}catch(k){const U=k.message||"Login failed. Please try again.";n(U)}finally{o(!1)}},V=async v=>{await e(v)},N=async()=>{o(!0);try{await j.logout(),p.toast.success("Logged out successfully"),A(!1)}catch(v){p.toast.error(v.message||"Failed to logout")}finally{o(!1)}},M=async()=>{if(!_||!F){p.toast.error("Please fill in all password fields");return}if(_!==F){p.toast.error("Passwords do not match");return}if(_.length<8){p.toast.error("Password must be at least 8 characters long");return}o(!0);try{await j.setPassword(_),p.toast.success("Password changed successfully!"),b(!1),O(""),W("")}catch(v){p.toast.error(v.message||"Failed to change password")}finally{o(!1)}},K=v=>s.jsxs(p.Form,{name:`${v}-password-login`,className:"w-full",onFinish:z,onFinishFailed:()=>{n("Please check your input and try again")},layout:"vertical",initialValues:{remember:!1},children:[a&&s.jsx(p.Alert,{message:a,type:"error",showIcon:!0,closable:!0,onClose:()=>n(null),className:"mb-4"}),s.jsx(p.FormItem,{name:"username",rules:S(v),children:s.jsx(p.Input,{placeholder:v==="email"?"Email address":"Mobile number (+919876543210)",autoComplete:v==="email"?"email":"tel",onKeyDown:v==="mobile"?k=>{const U=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],Z=k.key;!U.includes(Z)&&!/[0-9+]/.test(Z)&&k.preventDefault()}:void 0})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:"Please input your password!"},{min:q?.password_policy?.min_length||6,message:`Password must be at least ${q?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs("div",{className:"flex justify-between items-center w-full",children:[s.jsx("div",{children:t&&j.isRememberMeEnabled()&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx(p.Checkbox,{label:"Remember me"})})}),s.jsx("div",{children:j.isForgotPasswordEnabled()&&s.jsx(H.Link,{to:"forgot-password",className:"text-brand-500 hover:text-brand-600 text-sm transition-colors duration-300",children:"Forgot password?"})})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full text-base font-medium",disabled:r,fullWidth:!0,children:"Sign in"})})]},`${v}-${w}`),x=()=>j.isOTPLoginEnabled()?u?s.jsx(po,{onSuccess:V,onBack:()=>h(!1)}):s.jsx(p.Button,{variant:"secondary",fullWidth:!0,onClick:()=>h(!0),className:"bg-gray-100 border-gray-300",children:"Sign in with OTP"}):null,E=()=>{if(!q)return null;const v=j.getAllowedUsernames(),k=v.includes("email"),U=v.includes("mobile"),Z=j.isSSOEnabled()||j.isOIDCEnabled(),Q=j.isPasswordLoginEnabled(),$=j.isOTPLoginEnabled();if(!Q&&!$)return null;if($&&!Q)return s.jsx("div",{className:"w-full",children:s.jsx(po,{onSuccess:V})});if(!Q)return null;if(k&&U&&Q)return s.jsx("div",{className:"w-full",children:s.jsx(p.Tabs,{className:"login-tabs",activeKey:d,onChange:D=>{l(D),m(R=>R+1)},items:[{key:"email",label:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(gt,{size:16}),"Email"]}),children:s.jsxs(s.Fragment,{children:[K("email"),$&&Q&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),x()]}),u&&x(),!u&&Z&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),j.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),j.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((D,R)=>s.jsx(co,{provider:D,type:"oidc"},`oidc-email-${R}`))})})]})]})},{key:"mobile",label:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Ht,{size:16}),"Mobile"]}),children:s.jsxs(s.Fragment,{children:[K("mobile"),$&&Q&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),x()]}),u&&x(),!u&&Z&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),j.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),j.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:j.getOIDCProviders().map((D,R)=>s.jsx(co,{provider:D,type:"oidc",onClick:ae=>{console.log("OIDC provider clicked:",ae)}},`oidc-${R}`))})})]})]})}]})});{const D=k?"email":"mobile";return s.jsxs("div",{className:"w-full",children:[K(D),$&&Q&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),x()]}),u&&x(),!u&&Z&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),j.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),j.isOIDCEnabled()&&s.jsx("div",{className:"mt-4"})]})]})}};return q?g?s.jsx("div",{className:"w-full",children:C?s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-base font-medium mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.PasswordInput,{value:_,onChange:v=>O(v.target.value),placeholder:"Enter new password",disabled:r})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.PasswordInput,{value:F,onChange:v=>W(v.target.value),placeholder:"Confirm new password",disabled:r})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:M,loading:r,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{b(!1),O(""),W("")},disabled:r,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-center mb-4",children:[s.jsx("h3",{className:"text-lg font-medium",children:"Already Logged In"}),s.jsx("p",{className:"text-gray-500 text-sm mt-2",children:"You are currently logged in."})]}),s.jsx(p.Button,{block:!0,onClick:()=>b(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:N,loading:r,children:"Logout"})]})}):E():s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})})},Ii=({onLogin:e,showRememberMe:t=!0,showForgotPassword:r=!0})=>{const[o,a]=f.useState(!1),[n,i]=f.useState(0),[c,d]=f.useState("email"),{authConfig:l}=We();f.useEffect(()=>{if(l){const b=j.getAllowedUsernames();b&&b.length>0&&d(b[0])}},[l]);const u=async b=>{a(!0);try{if(e){const _={email:c==="email"?b.username:void 0,phone:c==="mobile"?b.username:void 0,username:b.username,password:b.password,remember_me:b.remember||!1};await e(_)}}catch(_){p.toast.error(_.message||"Login failed. Please try again.")}finally{a(!1)}},h=()=>{switch(c){case"email":return"Email address";case"mobile":return"Phone number";case"username":return"Username";default:return"Username"}},w=()=>{const b=[{required:!0,message:`Please input your ${c}!`}];switch(c){case"email":return[...b,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...b,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...b,{min:3,message:"Username must be at least 3 characters long"}];default:return b}};if(!l)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const m=j.getAllowedUsernames(),g=m.length>1,A=j.isRememberMeEnabled(),C=j.isForgotPasswordEnabled();return s.jsxs(p.Form,{name:"login",className:"w-full space-y-4",initialValues:{remember:!1},onFinish:u,autoComplete:"off",layout:"vertical",children:[g&&s.jsx(p.FormItem,{label:"Login with",className:"mb-4",children:s.jsx(p.Select,{value:c,onChange:d,options:m.map(b=>({value:b,label:b==="mobile"?"Phone":b.charAt(0).toUpperCase()+b.slice(1)}))})}),s.jsx(p.FormItem,{name:"username",rules:w(),children:s.jsx(p.Input,{placeholder:h(),autoComplete:c==="email"?"email":"username"})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:"Please input your password!"},{min:l?.password_policy?.min_length||6,message:`Password must be at least ${l?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs(p.Space,{className:"flex justify-between items-center w-full",children:[t&&A&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx(p.Checkbox,{label:"Remember me"})}),r&&C&&s.jsx(H.Link,{to:"forgot-password",className:"text-brand-500 text-sm hover:text-brand-600 transition-colors",children:"Forgot password?"})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:o,fullWidth:!0,children:"Log in"})})]},n)},qi=({onLogin:e,logo:t,title:r,subtitle:o,apiConfig:a={},useDynamicConfig:n=!0,staticConfig:i=null})=>{const[c,d]=f.useState(null),[l,u]=f.useState(n),[h,w]=f.useState(null);f.useEffect(()=>{n&&!i?m():i&&(d(i),u(!1))},[n,i]);const m=async()=>{try{const A=await j.getAuthConfig();d(A),w(null)}catch(A){console.error("Failed to fetch login methods:",A),w("Failed to load login methods. Please refresh the page.")}finally{u(!1)}},g=()=>l?s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading login methods..."})}):h?s.jsx(p.Alert,{message:"Error",description:h,type:"error",showIcon:!0,action:s.jsx("a",{onClick:m,children:"Retry"})}):c&&n?s.jsx(Bi,{onLogin:e}):s.jsx(Ii,{onLogin:e});return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(p.Layout.Content,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsxs(p.Card,{className:"w-full max-w-md shadow-lg rounded-lg",bordered:!1,children:[t&&s.jsx("div",{className:"text-center mb-6",children:typeof t=="string"?s.jsx("img",{src:t,alt:"Logo",className:"max-w-[150px] h-auto mx-auto"}):t}),s.jsxs("div",{className:"text-center mb-[18px]",children:[s.jsx("h1",{className:"text-3xl font-semibold text-gray-900 mb-2",children:r||"Welcome Back"}),o&&s.jsx("p",{className:"text-base text-gray-600",children:o})]}),g()]})})})},{Title:fo,Text:at,Paragraph:Vi}=p.Typography,$i=({size:e="default",icon:t,src:r,style:o,className:a,children:n})=>{const c=typeof e=="number"?e:{small:24,default:32,large:40}[e];return s.jsx("div",{className:`inline-flex items-center justify-center bg-blue-500 text-white rounded-full overflow-hidden ${a||""}`,style:{width:c,height:c,fontSize:c*.45,...o},children:r?s.jsx("img",{src:r,alt:"Avatar",className:"w-full h-full object-cover"}):t||n||s.jsx(zt,{size:c*.6})})},ji=({description:e,className:t,image:r})=>s.jsxs("div",{className:`flex flex-col items-center justify-center py-8 ${t||""}`,children:[!r&&s.jsx("div",{className:"mb-4 text-gray-400",children:s.jsx("svg",{width:"64",height:"41",viewBox:"0 0 64 41",fill:"currentColor",children:s.jsxs("g",{transform:"translate(0 1)",fillRule:"evenodd",children:[s.jsx("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),s.jsxs("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[s.jsx("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),s.jsx("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})})}),e&&s.jsx("div",{className:"text-sm text-gray-500",children:e})]}),Di=e=>{const t=e.toLowerCase();return t.includes("admin")?s.jsx(_a,{size:20}):t.includes("manager")||t.includes("supervisor")?s.jsx(Ta,{size:20}):t.includes("security")||t.includes("compliance")?s.jsx(ns,{size:20}):s.jsx(zt,{size:20})},go=({user:e,roles:t,onRoleSelect:r,loading:o=!1,title:a="Choose Your Role",subtitle:n="Select the role that best matches your current responsibilities"})=>{const[i,c]=f.useState(null),[d,l]=f.useState(!1),u=async()=>{if(i){l(!0);try{await r(i)}catch(h){console.error("Role selection failed:",h)}finally{l(!1)}}};return o?s.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading your available roles..."})}):!t||t.length===0?s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsx("div",{className:"bg-white rounded-2xl p-8",children:s.jsx(ji,{className:"text-center py-12 px-5 text-gray-500",description:s.jsxs("div",{children:[s.jsx(at,{className:"text-gray-600 text-base block mb-2",children:"No roles available"}),s.jsx(at,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})}):s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsxs("div",{className:"bg-white rounded-2xl p-8",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx(fo,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",children:a}),s.jsx(Vi,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",children:n}),e&&s.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-3 bg-gray-50 rounded-xl border border-gray-200",children:[s.jsx($i,{size:"default",className:"bg-blue-500",children:(e.name||e.username||"U").split(" ").map(h=>h[0]).join("").toUpperCase().slice(0,2)}),s.jsxs("div",{className:"text-left",children:[s.jsx(at,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&s.jsx(at,{type:"secondary",className:"text-xs",children:e.email})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"max-h-96 overflow-y-auto px-2 py-2",children:s.jsx("div",{className:`grid gap-4 ${t.length<=2?"grid-cols-2":"grid-cols-3"}`,children:t.map(h=>s.jsxs("div",{className:`
120
- cursor-pointer transition-all duration-300 border rounded-2xl relative p-4 bg-white
121
- hover:-translate-y-1 flex flex-col items-center h-32 min-h-[8rem]
122
- ${i?.id===h.id?"border-brand-500 bg-brand-500/10":"border-gray-200 hover:border-brand-300"}
123
- `,onClick:()=>c(h),children:[i?.id===h.id&&s.jsx("div",{className:"absolute -top-2 -right-2 bg-brand-500 rounded-full p-2",children:s.jsx(Te,{size:16,className:"text-white"})}),s.jsx("div",{className:"flex justify-center mt-2 mb-3",children:s.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-xl flex items-center justify-center",children:Di(h.name)})}),s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[s.jsx(fo,{level:5,className:"!mb-0 !text-sm !font-semibold !text-gray-900 !leading-tight !line-clamp-2 !text-center",title:h.name,children:h.name}),h.is_default&&s.jsx("div",{className:"mt-1",children:s.jsx(p.Tag,{color:"warning",className:"bg-yellow-50 border-yellow-300 text-yellow-700 font-medium text-xs px-1",children:"Recommended"})})]})]},h.id))})})}),s.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[s.jsx(p.Button,{type:"primary",block:!0,onClick:u,disabled:!i,loading:d,icon:i?s.jsx(Te,{size:16}):null,className:"w-full",children:i?`Continue as ${i.name}`:"Please select a role to continue"}),i?.is_default&&s.jsx(at,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Content:Hi}=p.Layout,zi=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onLoginSuccess:i,roleSelectionTitle:c,roleSelectionSubtitle:d})=>{const{pendingAuth:l,availableRoles:u,selectRole:h,login:w}=We(),[m,g]=f.useState(null),A=async b=>{g(null);try{const _=await w(b),O={email:b.email,username:b.username,phone:b.phone,display:b.email||b.username||b.phone};if(_.requiresRoleSelection)return;i&&i({..._,loginUser:O})}catch(_){throw g(_.message),_}},C=async b=>{try{const _=await h(b);i&&i(_)}catch(_){throw console.error("Role selection failed:",_),_}};return l&&u?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Hi,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(go,{user:l.user,roles:u,onRoleSelect:C,title:c,subtitle:d})})}):s.jsx(qi,{onLogin:A,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n})},{Title:Wi,Text:or,Paragraph:Zi}=p.Typography,Ki=({user:e,availableMethods:t=["email","sms"],onVerify:r,loading:o=!1,otpDigits:a=6,retryInterval:n=30,title:i="Two-Factor Authentication",subtitle:c="For your security, please verify your identity"})=>{const[d,l]=f.useState(t[0]||"email"),[u,h]=f.useState(""),[w,m]=f.useState(0),[g,A]=f.useState(!1),[C,b]=f.useState(!1);f.useEffect(()=>{if(w>0){const P=setTimeout(()=>m(w-1),1e3);return()=>clearTimeout(P)}},[w]);const _=P=>{if(P==="email"&&e?.email){const[S,z]=e.email.split("@");return`${S.substring(0,3)+"****"+S.substring(S.length-1)}@${z}`}return(P==="sms"||P==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:P==="totp"?"your authenticator app":P==="email"?"your email":P==="sms"?"your mobile":"your authenticator app"},O=async()=>{A(!0);try{await j.sendTwoFactorCode(d),b(!0),m(n),p.toast.success(`OTP sent to ${_(d)}`)}catch(P){p.toast.error(P.message||"Failed to send OTP")}finally{A(!1)}},F=async()=>{if(u.length!==a){p.toast.error(`Please enter ${a} digit OTP`);return}A(!0);try{const P=await j.verifyTwoFactorCode(u);await r(P)}catch(P){p.toast.error(P.message||"Invalid OTP"),h("")}finally{A(!1)}},W=async()=>{w>0||await O()},q=()=>{if(t.length<=1)return null;const P=t.map(S=>({label:s.jsxs(p.Space,{children:[S==="email"?s.jsx(gt,{size:16}):S==="sms"?s.jsx(Ht,{size:16}):s.jsx(ns,{size:16}),s.jsx("span",{children:S==="email"?"Email":S==="sms"?"SMS":"Authenticator"})]}),value:S}));return s.jsxs("div",{className:"mb-6",children:[s.jsx(or,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),s.jsx(p.Segmented,{options:P,value:d,onChange:S=>{l(S),b(!1),h("")},block:!0})]})};return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx(Wi,{level:3,className:"!mb-2",children:i}),s.jsx(Zi,{className:"!mb-0 text-sm",type:"secondary",children:c})]}),s.jsxs("div",{className:"mt-6",children:[q(),C?s.jsxs("div",{className:"mt-6",children:[s.jsxs(or,{className:"block text-center mb-6 text-gray-700",children:["Enter the ",a,"-digit code sent to ",_(d)]}),s.jsx("div",{className:"flex justify-center mb-6",children:s.jsx(uo,{length:a,value:u,onChange:h,disabled:g})}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:g,onClick:F,className:"mb-4",children:"Verify"}),s.jsx("div",{className:"text-center",children:w>0?s.jsxs(or,{type:"secondary",children:["Resend code in ",w,"s"]}):s.jsx(p.Button,{variant:"link",onClick:W,disabled:g,children:"Resend Code"})})]}):s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Alert,{message:`We'll send a verification code to ${_(d)}`,type:"info",showIcon:!0,className:"mb-6"}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:g,onClick:O,children:"Send Verification Code"})]})]})]})})},{Title:Ji,Text:Me,Paragraph:Gi}=p.Typography,Xi=({reason:e="Your password has expired",onReset:t,loading:r=!1,title:o="Password Reset Required",subtitle:a="Please create a new password to continue",passwordRules:n})=>{const[i,c]=f.useState(0),[d,l]=f.useState(!1),[u,h]=f.useState(""),[w,m]=f.useState({minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSpecialChars:!0});f.useEffect(()=>{if(n)m(n);else{const _=j.getPasswordPolicy();m({minLength:_.min_length||8,maxLength:_.max_length,requireUppercase:_.require_uppercase||!1,requireLowercase:_.require_lowercase||!1,requireNumbers:_.require_numbers||!1,requireSpecialChars:_.require_special_chars||!1})}},[n]);const g=_=>{if(!_)return{percent:0,status:"exception"};let O=0;return _.length>=w.minLength&&(O+=20),_.length>=12&&(O+=10),w.requireUppercase&&/[A-Z]/.test(_)&&(O+=20),w.requireLowercase&&/[a-z]/.test(_)&&(O+=20),w.requireNumbers&&/\d/.test(_)&&(O+=15),w.requireSpecialChars&&/[!@#$%^&*]/.test(_)&&(O+=15),O<40?{percent:O,status:"exception"}:O<70?{percent:O,status:"normal"}:{percent:O,status:"success"}},A=(_,O)=>{if(!O)return Promise.reject(new Error("Please input your password!"));const F=j.validatePassword(O);return F.valid?Promise.resolve():Promise.reject(new Error(F.errors.join(", ")))},C=async _=>{l(!0);try{await j.setPassword(_.password),await t({password:_.password,confirmPassword:_.confirmPassword})}catch(O){throw O}finally{l(!1)}},b=g(u);return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx(Ji,{level:3,className:"!mb-2",children:o}),s.jsx(Gi,{className:"!mb-0 text-sm",type:"secondary",children:a})]}),s.jsx(p.Alert,{message:e,type:"warning",showIcon:!0,className:"mb-6"}),s.jsxs(p.Form,{name:"password-reset-required",onFinish:C,layout:"vertical",className:"mt-6",children:[s.jsx(p.FormItem,{name:"password",rules:[{validator:A}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(ft,{size:16}),placeholder:"New Password",onChange:_=>h(_.target.value)})}),u&&s.jsxs("div",{className:"-mt-4 mb-4",children:[s.jsx(Me,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),s.jsx(p.Progress,{percent:b.percent,status:b.status,showInfo:!1,strokeWidth:4})]}),s.jsx(p.FormItem,{name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:"Please confirm your password!"},({getFieldValue:_})=>({validator(O,F){return!F||_("password")===F?Promise.resolve():Promise.reject(new Error("Passwords do not match!"))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(ft,{size:16}),placeholder:"Confirm Password"})}),s.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[s.jsx(Me,{type:"secondary",className:"block font-medium mb-2",children:"Password Requirements:"}),s.jsxs(p.Space,{direction:"vertical",size:"small",children:[s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:u.length>=w.minLength?"text-green-500":"text-gray-300"}),"At least ",w.minLength," characters"]}),w.maxLength&&s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:u.length<=w.maxLength?"text-green-500":"text-gray-300"}),"At most ",w.maxLength," characters"]}),w.requireUppercase&&s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:/[A-Z]/.test(u)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),w.requireLowercase&&s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:/[a-z]/.test(u)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),w.requireNumbers&&s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:/\d/.test(u)?"text-green-500":"text-gray-300"}),"One number"]}),w.requireSpecialChars&&s.jsxs(Me,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Te,{size:16,className:/[!@#$%^&*]/.test(u)?"text-green-500":"text-gray-300"}),"One special character (!@#$%^&*)"]})]})]}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:d||r,children:"Reset Password"})})]},i)]})})},{Content:Lt}=p.Layout,ar=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onAuthComplete:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:w,initialAuthState:m=null})=>{const{user:g,pendingAuth:A}=We(),[C,b]=f.useState(()=>{if(m){if(m.roles&&m.roles.length>1)return"roleSelection";if(m.requires2FA)return"twoFactor";if(m.requiresPasswordReset)return"passwordReset"}return"login"}),[_,O]=f.useState(m?.token||null),[F,W]=f.useState(m?.twoFactorMethods||null),[q,P]=f.useState(m?.passwordResetReason||null),[S,z]=f.useState(m||null),V=async x=>{console.log("Login success result:",x);let E=x,v=null;x?.status===401&&x?.data?(E=x.data,v=x.data?.next_step):x?.next_step?(E=x,v=x.next_step):(E=x?.response?.data||x?.data||x,v=E?.next_step);const k=x?.loginUser;(x?.token||E?.token)&&O(x.token||E.token);let U=x?.user||E?.user||k||{};if((typeof U!="object"||U===null)&&(U={}),k&&typeof k=="object"&&(U={...U,email:U.email||k.email,username:U.username||k.username,phone:U.phone||k.phone,name:U.name||k.display}),v&&v.is_pending)switch(v.id){case"role_selection":let Z=[];Array.isArray(v.metadata.roles)?Z=v.metadata.roles:typeof v.metadata.roles=="object"&&(Z=Object.entries(v.metadata.roles).map(([L,D])=>({id:L,name:D,is_default:!1}))),z({...x,roles:Z,user:U,nextStep:v,loginUser:k}),b("roleSelection");return;case"mfa_authenticate":O(x.token||E?.token);const Q=v.metadata?.type?[v.metadata.type]:v.metadata?.methods||["email"];W(Q),b("twoFactor");return;case"set_password":O(x.token||E?.token);const $=v.metadata?.password_policy;P(v.metadata?.reason||"Password update required"),z({...x,passwordPolicy:$,user:U,loginUser:k}),b("passwordReset");return;case"password_expiry":O(x.token||E?.token),P("Your password has expired"),z({...x,passwordPolicy:v.metadata?.password_policy,user:U,loginUser:k}),b("passwordReset");return;case"first_login":O(x.token||E?.token),P("Please set up your password for first login"),z({...x,passwordPolicy:v.metadata?.password_policy,user:U,loginUser:k}),b("passwordReset");return;case"login_by_code":O(x.token||E?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),i&&i({...x,user:U,requiresOTP:!0});return}if(x.requires2FA){O(x.token),W(x.twoFactorMethods||["email"]),z({...x,user:U,loginUser:k}),b("twoFactor");return}if(x.requiresPasswordReset){O(x.token),P(x.passwordResetReason||"Your password has expired"),z({...x,user:U,loginUser:k}),b("passwordReset");return}i&&i({...x,user:U})},N=async x=>{try{console.log("2FA verification result:",x);let E=x,v=null,k=!1,U=null;if(x?.status===401&&x?.data?(E=x.data,v=x.data?.next_step,U=x.status,k=x?.meta?.is_authenticated||!1):x?.response?(U=x.response.status,E=x.response.data,v=E?.next_step,k=x.response.meta?.is_authenticated||!1):(E=x?.data||x,v=E?.next_step,k=x?.meta?.is_authenticated||E?.meta?.is_authenticated||!1,U=x?.status||E?.status),U===200&&k){console.log("Authentication completed successfully after 2FA"),p.toast.success("Two-factor authentication successful!"),i&&i({...x,token:_,user:S?.user,authenticated:!0});return}if(v&&v.is_pending)switch(v.id){case"set_password":const Z=v.metadata?.password_policy;P(v.metadata?.reason||"Password reset required"),z({...S,passwordPolicy:Z}),b("passwordReset");return;default:console.warn("Unknown next step after 2FA:",v.id);break}if(x.requiresPasswordReset){P(x.passwordResetReason||"Your password has expired"),b("passwordReset");return}p.toast.success("Two-factor authentication successful!"),i&&i({...x,token:_,user:S?.user,authenticated:!0})}catch(E){throw E}},M=async x=>{try{const E=await j.setPassword(x.password);console.log("Password reset result:",E);let v=E,k=null,U=!1,Z=null;if(E?.status===401&&E?.data?(v=E.data,k=E.data?.next_step,Z=E.status,U=E?.meta?.is_authenticated||!1):E?.response?(Z=E.response.status,v=E.response.data,k=v?.next_step,U=E.response.meta?.is_authenticated||!1):(v=E?.data||E,k=v?.next_step,U=E?.meta?.is_authenticated||v?.meta?.is_authenticated||!1,Z=E?.status||v?.status),Z===200&&U){console.log("Authentication completed successfully after password reset"),p.toast.success("Password reset successful!"),i&&i({...E,token:_,user:S?.user,authenticated:!0});return}if(k&&k.is_pending)switch(k.id){case"mfa_authenticate":const Q=k.metadata?.type?[k.metadata.type]:k.metadata?.methods||["email"];W(Q),b("twoFactor");return;default:console.warn("Unknown next step after password reset:",k.id);break}p.toast.success("Password reset successful!"),i&&i({...E,token:_,user:S?.user,authenticated:!0})}catch(E){throw p.toast.error(E.message||"Failed to reset password"),E}};return(()=>{switch(C){case"login":return s.jsx(zi,{onLoginSuccess:V,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n,roleSelectionTitle:c,roleSelectionSubtitle:d});case"roleSelection":return S?.roles?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsxs(Lt,{className:"flex justify-center items-center min-h-screen p-5",children:[s.jsx("div",{className:"text-center mb-8",children:e&&s.jsx("div",{className:"mb-6",children:e})}),s.jsx(go,{user:S?.user,roles:S?.roles||[],onRoleSelect:async v=>{try{const k=await j.selectRole(v.id);console.log("Role selection result:",k);let U=k,Z=null,Q=!1,$=null;if(k?.status===401&&k?.data?(U=k.data,Z=k.data?.next_step,$=k.status,Q=k?.meta?.is_authenticated||!1):k?.response?($=k.response.status,U=k.response.data,Z=U?.next_step,Q=k.response.meta?.is_authenticated||!1):(U=k?.data||k,Z=U?.next_step,Q=k?.meta?.is_authenticated||U?.meta?.is_authenticated||!1,$=k?.status||U?.status),$===200&&Q){console.log("Authentication completed successfully after role selection"),p.toast.success("Role selected successfully!"),i&&i({...k,user:{...S.user,role:v},authenticated:!0});return}if(Z&&Z.is_pending)switch(Z.id){case"mfa_authenticate":const L=Z.metadata?.type?[Z.metadata.type]:Z.metadata?.methods||["email"];W(L),b("twoFactor");return;case"set_password":const D=Z.metadata?.password_policy;P(Z.metadata?.reason||"Password update required"),z({...S,passwordPolicy:D}),b("passwordReset");return;case"password_expiry":P("Your password has expired"),z({...S,passwordPolicy:Z.metadata?.password_policy}),b("passwordReset");return;case"first_login":P("Please set up your password for first login"),z({...S,passwordPolicy:Z.metadata?.password_policy}),b("passwordReset");return;case"login_by_code":console.log("OTP login flow required after role selection"),p.toast.info("OTP verification required"),i&&i({...k,user:{...S.user,role:v},requiresOTP:!0});return;default:console.warn("Unknown next step:",Z.id);break}p.toast.success("Role selected successfully!"),i&&i({...k,user:{...S.user,role:v}})}catch(k){throw p.toast.error(k.message||"Failed to select role"),k}},title:c||"Select Your Role",subtitle:d||"Choose a role to continue"})]})}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Lt,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx("div",{className:"text-center py-16 px-5",children:s.jsx(p.Spin,{size:"large",tip:"Loading..."})})})});case"twoFactor":return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Lt,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(Ki,{user:S?.user||A?.user||g,availableMethods:F,onVerify:N,title:l,subtitle:u})})});case"passwordReset":const x=S?.passwordPolicy,E=x?{minLength:x.min_length||8,maxLength:x.max_length,requireUppercase:x.require_uppercase||!1,requireLowercase:x.require_lowercase||!1,requireNumbers:x.require_numbers||!1,requireSpecialChars:x.require_special_chars||!1}:void 0;return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Lt,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(Xi,{reason:q,onReset:M,title:h,subtitle:w,passwordRules:E})})});default:return null}})()},{Content:Yi}=p.Layout,Qi=({logo:e,apiConfig:t,onAuthComplete:r,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,redirectPath:l="/"})=>{const[u,h]=f.useState(null),[w,m]=f.useState(!1),g=async b=>{b.requiresRoleSelection||b.requires2FA||b.requiresPasswordReset?(h(b),m(!0)):(b.token&&localStorage.setItem(t?.tokenKey||"authToken",b.token),r&&r(b))},A=b=>{console.error("OAuth callback error:",b)},C=b=>{const _={...u,...b,authMethod:"oauth",provider:u?.provider};r&&r(_)};return w&&u?s.jsx(ar,{logo:e,apiConfig:t,onAuthComplete:C,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,initialAuthState:{user:u.user,token:u.token,roles:u.roles,requires2FA:u.requires2FA,twoFactorMethods:u.twoFactorMethods,requiresPasswordReset:u.requiresPasswordReset,passwordResetReason:u.passwordResetReason}}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Yi,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(ki,{onSuccess:g,onError:A,apiConfig:t,redirectPath:l})})})},mo=()=>We(),{Header:hc,Content:wo}=p.Layout,nr={},ir={},lr={"admin@example.com":{requires2FA:!0,requiresPasswordReset:!1,twoFactorMethods:["email","mobile"]},"+919876543210":{requires2FA:!0,requiresPasswordReset:!0,passwordResetReason:"Your password will expire in 7 days",twoFactorMethods:["mobile"]},"test@example.com":{requires2FA:!1,requiresPasswordReset:!0,passwordResetReason:"Password has expired"}},nt={"admin@example.com":[{id:1,name:"Super Admin",description:"Full system access with all administrative privileges",permissions:["system.manage","users.manage","roles.manage","settings.manage"],is_default:!1},{id:2,name:"Organization Admin",description:"Manage organization settings and users",permissions:["org.manage","users.manage","reports.view"],is_default:!0},{id:3,name:"Compliance Officer",description:"Monitor compliance and security settings",permissions:["compliance.view","audit.view","reports.generate"],is_default:!1}],"+919876543210":[{id:4,name:"Team Manager",description:"Manage team members and projects",permissions:["team.manage","projects.manage","reports.view"],is_default:!0},{id:5,name:"Employee",description:"Standard employee access",permissions:["profile.edit","tasks.manage","reports.view"],is_default:!1}],default:[{id:6,name:"User",description:"Standard user access",permissions:["profile.view","profile.edit"],is_default:!0}]},cr=e=>({loginEndpoint:"/api/auth/login",logoutEndpoint:"/api/auth/logout",verifyEndpoint:"/api/auth/verify",forgotPasswordEndpoint:"/api/auth/forgot-password",resetPasswordEndpoint:"/api/auth/reset-password",loginMethodsEndpoint:"/api/v1/login/?action=fetch_methods",otpRequestEndpoint:"/api/auth/otp/request",otpVerifyEndpoint:"/api/auth/otp/verify",apiClient:{post:async(t,r)=>{if(console.log("Mock API POST:",t,r),await new Promise(o=>setTimeout(o,1e3)),t.includes("login")){const o=r.email||r.phone||r.username;if(["admin@example.com","+919876543210","test@example.com","admin"].includes(o)&&r.password==="password"){const i=nt[o]||nt.default,c=lr[o]||{};return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o==="admin@example.com"?"John Admin":o.startsWith("+")?"Mobile User":"Test User"},token:"mock-jwt-token-12345",roles:i,...c}}throw new Error("Invalid credentials")}if(t.includes("otp/request")){const o=r.email_or_phone||r.email||r.phone||r.username,a=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return nr[o]=a,console.log(`📱 Mock OTP for ${o}: ${a}`),p.toast.info(`Mock OTP sent! Check console for OTP: ${a}`),{success:!0,message:"OTP sent successfully"}}if(t.includes("otp/verify")){const o=r.email_or_phone||r.email||r.phone||r.username;if(nr[o]===r.otp){delete nr[o];const n=nt[o]||nt.default;return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o.includes("@")?"OTP User":"Mobile User"},token:"mock-jwt-token-otp-12345",roles:n}}throw new Error("Invalid OTP")}if(t.includes("forgot-password"))return{message:"Reset email sent successfully"};if(t.includes("reset-password"))return{message:"Password reset successfully"};if(t.includes("role/select"))return console.log("Role selected:",r),{success:!0,...lr["admin@example.com"]||{}};if(t.includes("2fa/send")){const o=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return ir[r.method]=o,console.log(`📱 2FA OTP for ${r.method}: ${o}`),p.toast.info(`2FA OTP sent! Check console for OTP: ${o}`),{success:!0,message:"2FA code sent successfully"}}if(t.includes("2fa/verify")){if(ir[r.method]===r.otp){delete ir[r.method];const n=lr["admin@example.com"]||{};return{success:!0,requiresPasswordReset:n.requiresPasswordReset,passwordResetReason:n.passwordResetReason}}throw new Error("Invalid 2FA code")}if(t.includes("password/change"))return console.log("Password changed:",r),{success:!0,message:"Password changed successfully"};if(t.includes("oauth/callback")){console.log("OAuth callback:",r);const o=r.provider||"google",a={id:1,email:`user@${o}.com`,name:`${o.charAt(0).toUpperCase()+o.slice(1)} User`,username:`user@${o}.com`};return o==="google"?{user:a,token:"mock-oauth-token-12345",roles:nt["admin@example.com"],requires2FA:!0,twoFactorMethods:["email"]}:o==="microsoft"?{user:a,token:"mock-oauth-token-12345",requiresPasswordReset:!0,passwordResetReason:"first_login"}:{user:a,token:"mock-oauth-token-12345"}}return{success:!0}},get:async t=>{if(console.log("Mock API GET:",t),await new Promise(r=>setTimeout(r,500)),t.includes("fetch_methods")||t.includes("config"))return{success:!0,response:{auth_config:{login_methods:{password:{enabled:!0,forgot_password_enabled:!0,allowed_usernames:["email","phone"]},otp:{enabled:!0,allowed_methods:["email","sms"]},sso:{enabled:!1},oidc:{enabled:!1}},password_policy:{min_length:8,require_numbers:!0,require_lowercase:!0,require_uppercase:!0,require_special_chars:!0,password_expiry_days:90,password_history_count:3,allow_change:!0,reset:{enabled:!0,method:["email"],expiry_hours:2}},session_policy:{remember_me_enabled:!0,remember_me_duration_days:30},two_factor_auth:{required:!0,allowed_methods:[]}}}};if(t.includes("verify")){console.log("Inside verify");const r=localStorage.getItem("authToken");if(r&&r.startsWith("mock-jwt-token"))return{id:1,username:"admin",email:"admin@example.com"};throw new Error("Invalid token")}return{}}}}),Ri=({basePath:e="/login",apiConfig:t={},onAuthComplete:r,logo:o,title:a="Welcome Back",subtitle:n="Please sign in to your account",roleSelectionTitle:i="Select Your Role",roleSelectionSubtitle:c="Choose a role to continue",twoFactorTitle:d="Two-Factor Authentication",twoFactorSubtitle:l="Please enter your verification code",passwordResetTitle:u="Reset Password",passwordResetSubtitle:h="Please enter your new password"})=>{H.useLocation(),H.useNavigate();const[w,m]=f.useState(null),{setBasePath:g}=At();f.useEffect(()=>{g(e)},[e,g]),console.log("basePath",e),console.log("apiConfig",t);const A=async F=>{try{return F}catch(W){throw W}},C=F=>{m(F),r&&r(F)},b=()=>{H.useNavigate();const F=async W=>{console.log("Authentication complete:",W),p.toast.success("Authentication complete!");try{const P=new URLSearchParams(window.location.search).get("next");let S="/app";P&&(S=decodeURIComponent(P),console.log("Redirecting to 'next' parameter:",S)),console.log("Final redirect URL:",S),window.location.href=S}catch(q){console.error("Error handling auth completion:",q),window.location.href="/app"}};return s.jsx(ar,{onAuthComplete:F,title:"Login",subtitle:"Enter your credetials to login",apiConfig:cr(),useDynamicConfig:!0,roleSelectionTitle:"Select Your Role",roleSelectionSubtitle:"You have access to multiple roles. Please select one to continue.",twoFactorTitle:"Two-Factor Authentication",twoFactorSubtitle:"For your security, please verify your identity",passwordResetTitle:"Password Update Required",passwordResetSubtitle:"Please create a new password to continue"})},_=()=>{const{forgotPassword:F}=mo(),W=async q=>{try{await F(q),p.toast.success("Reset email sent successfully!")}catch(P){p.toast.error(P.message||"Failed to send reset email")}};return s.jsx(p.Layout,{style:{minHeight:"100vh",background:"#f0f2f5"},children:s.jsx(wo,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{background:"#fff",padding:40,borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:"100%",maxWidth:400},children:s.jsx(Pi,{onSubmit:W})})})})},O=()=>{const{resetPassword:F}=mo(),W=async q=>{await F(q),p.toast.success("Password reset successfully! (This is a demo)")};return s.jsx(p.Layout,{style:{minHeight:"100vh",background:"#f0f2f5"},children:s.jsx(wo,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{background:"#fff",padding:40,borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:"100%",maxWidth:400},children:s.jsx(Si,{onSubmit:W,token:"demo-reset-token"})})})})};return e.endsWith("/")&&e.slice(0,-1),s.jsx(Ui,{config:cr(),children:s.jsxs(H.Routes,{children:[s.jsx(H.Route,{path:"/",element:s.jsx(b,{onLogin:A,apiConfig:t,logo:o,title:a,subtitle:n})}),s.jsx(H.Route,{path:"forgot-password",element:s.jsx(_,{})}),s.jsx(H.Route,{path:"reset-password",element:s.jsx(O,{})}),s.jsx(H.Route,{path:"/oauth/callback",element:s.jsx(Qi,{logo:s.jsx(Na,{size:48,style:{color:"#1890ff"}}),apiConfig:cr(),onAuthComplete:F=>{console.log("OAuth auth complete:",F),(async()=>{const q=F?.response?.data?.redirect_url;q&&(window.location.href=q)})()},roleSelectionTitle:"Select Your Role",roleSelectionSubtitle:"Choose a role to continue",twoFactorTitle:"Two-Factor Authentication",twoFactorSubtitle:"For your security, please verify your identity",passwordResetTitle:"Password Update Required",passwordResetSubtitle:"Please create a new password to continue"})}),s.jsx(H.Route,{path:"/complete",element:s.jsx(ar,{authData:w,apiConfig:t,logo:o,onComplete:C,roleSelectionTitle:i,roleSelectionSubtitle:c,twoFactorTitle:d,twoFactorSubtitle:l,passwordResetTitle:u,passwordResetSubtitle:h})}),s.jsx(H.Route,{path:"*",element:s.jsx(H.Navigate,{to:"/404",replace:!0})})]})})},dr=({basePath:e="/app"})=>{const t=Re();return s.jsx("div",{className:"page-container",children:s.jsx(Ri,{basePath:e,apiConfig:t})})},el=async(e=[])=>{console.log("🚀 Creating dynamic page registry..."),console.log("📋 Requested page types:",e);const t=Ca(e);console.log("✅ Available page types:",t);const r={login:{component:dr,includeBasePath:!0,standalone:!0,propsBuilder:({matchedRoutePath:c})=>({basePath:c})},custom:{component:null,includeBasePath:!1,handler:({customPages:c,customPagePath:d,location:l})=>{const u=c[d];return u?f.createElement(u):f.createElement(ss,{componentName:d})}},404:{component:jt,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:jt,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:c})=>({message:`Unknown page type: ${c}`})}};for(const c of t){const d=va(c);d?(r[c]={component:d,includeBasePath:!0,propsBuilder:({matchedRoutePath:l})=>({basePath:l})},console.log(`✅ Registered static page type: ${c}`)):console.warn(`⚠️ Failed to get component for page type: ${c}`)}const o=t.length,a=4,n=o+a;console.log(`📊 Registry created with ${n} page types:`),console.log(` • Dynamic framework pages (${o}): ${t.join(", ")||"none"}`),console.log(` • Static pages (${a}): login, custom, 404, default`);const i=e.filter(c=>!t.includes(c));return i.length>0&&console.warn(`⚠️ Unconfigured page types (not in PAGE_CONFIG): ${i.join(", ")}`),r},tl=e=>{const t=new Set;return e.forEach(r=>{r.page_type&&r.page_type!=="custom"&&r.page_type!=="login"&&t.add(r.page_type)}),Array.from(t)},rl=async e=>{const t=tl(e);return el(t)},yo=f.createContext(void 0);let Ze=!1;typeof window<"u"&&(Ze=!1);const Se=()=>{const e=f.useContext(yo);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},bo=({children:e,config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={}})=>{const i=H.useNavigate(),c=H.useLocation(),[d,l]=f.useState(null),[u,h]=f.useState(!0),[w,m]=f.useState(null),[g,A]=f.useState(null);f.useEffect(()=>{console.log("🔄 Loading state changed to:",u)},[u]);const[C,b]=f.useState(null),[_,O]=f.useState(!1),[F,W]=f.useState(null),q=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",P=t,S=P.apiConfig||{};f.useEffect(()=>{const V={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},N="default-theme-variables";let M=document.getElementById(N);M||(M=document.createElement("style"),M.id=N,document.head.appendChild(M)),M.innerHTML=`:root { ${pt(V)} }`},[]),f.useEffect(()=>{const V=Ue.getCachedLogo();V&&A(V.base64Data||V.url)},[]),f.useEffect(()=>{let V=!1;return(async()=>{const M=window.location.pathname,K=M.startsWith("/app/login");if(console.log("🔍 AppContext useEffect triggered:",{currentPath:M,isLoginPage:K,fetchInProgress:Ze}),K){console.log("✅ Login page detected - skipping API call"),h(!1),l({app_name:"Zango CRM",is_user_anonymous:!0,routes:[],menu:[]});return}if(Ze){console.log("⚠️ Fetch already in progress, skipping...");return}Ze=!0,console.log("🚀 Starting fetchAppInitData...");try{const x=await Mr(),E=x.success?x.response:null;if(console.log("✅ fetchAppInitData completed:",{success:x.success,hasMenu:E?.menu?.length>0,menuCount:E?.menu?.length,userRole:E?.profile_info?.user_role}),!x.success)throw new Error(x.response?.message||"Failed to fetch app data");if(console.log("📦 Setting app data"),l(E),E?.theme){console.log("🎨 Applying theme");const v=document.getElementById("default-theme-variables");if(v)v.innerHTML=`:root { ${pt(E.theme)} }`;else{const k=document.createElement("style");k.id="default-theme-variables",k.innerHTML=`:root { ${pt(E.theme)} }`,document.head.appendChild(k)}E?.app_logo&&Ue.updateInBackground(E.app_logo,E.app_name,k=>{k.base64Data&&A(k.base64Data)})}}catch(x){console.error("❌ fetchAppInitData error:",x),m(x.message)}finally{console.log("🏁 Finally block executing:",{cancelled:V,loading:u}),console.log("✅ Setting loading to FALSE (ignoring cancelled state)"),h(!1),Ze=!1,console.log("✅ fetchAppInitData finally block completed:",{fetchInProgress:Ze,cancelled:V})}})(),()=>{V=!0,console.log("🧹 AppContext cleanup - useEffect unmounting")}},[]),f.useEffect(()=>{if(u||!d)return;const V=c.pathname,N=V.startsWith("/app/login"),M=V==="/app/configuration-error";if(N||V==="/app/logout")return;const x=d.menu&&d.menu.length>0,E=d.routes&&d.routes.length>0,v=d.profile_info?.user_role,k=v==="AnonymousUsers",U=v&&v!=="AnonymousUsers",Z=E&&d.routes.some(Q=>{const $=Q.path;return V===$||V.startsWith($+"/")});if(console.log("🔍 Redirect logic check:",{currentPath:V,hasMenu:x,hasRoutes:E,userRole:v,isAnonymous:k,isAuthenticated:U,isConfigPage:M,isValidPath:Z}),U&&!x&&!M){console.log("🚀 Flow 1: Authenticated user without menu → configuration-error"),i("/app/configuration-error",{replace:!0});return}if(k&&!x){console.log("🚀 Flow 2: Anonymous user without menu → login"),i("/app/login",{replace:!0});return}if(x&&d.menu){const Q=d.menu[0]?.path||d.menu[0]?.uri;if(Q&&(V==="/app"||V==="/app/"||!Z&&!M)){console.log("🚀 Flow 3/4: Redirecting to first menu item:",Q,{reason:V==="/app"||V==="/app/"?"/app root":"invalid path"}),i(Q,{replace:!0});return}}},[u,d,c.pathname,i]),f.useEffect(()=>{let V=!1;return(async()=>{if(u){console.log("⏳ Still loading app data, skipping registry creation");return}if(!d){console.log("⏳ No app data yet, skipping registry creation");return}if(console.log("🚀 Starting registry creation...",{isAnonymous:d.is_user_anonymous,hasRoutes:!!d.routes,routesLength:d.routes?.length}),d.is_user_anonymous){console.log("✅ Anonymous user - creating minimal registry"),V||(b({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),O(!1));return}if(!d.routes||d.routes.length===0){console.log("⚠️ No routes found - creating fallback registry"),V||(b({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),O(!1));return}try{V||(O(!0),W(null)),console.log("🚀 Creating dynamic page registry from routes...");const M=await rl(d.routes);V||(b(M),O(!1),console.log("✅ Dynamic page registry created successfully"))}catch(M){console.error("❌ Failed to create dynamic page registry:",M),V||(W(M.message||"Failed to create page registry"),b({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),O(!1))}})(),()=>{V=!0}},[d,u]);const z={appData:d,loading:u,error:w,config:P,apiConfig:S,menu:d?.menu||[],routes:d?.routes||[],profileInfo:d?.profile_info||{},appLogo:g||d?.app_logo||"",appName:d?.app_name||"Zango CRM",metadata:d?.metadata||{},theme:d?.theme||{},layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,pageTypeRegistry:C,registryLoading:_,registryError:F,initializerEndpoint:q()};return s.jsx(yo.Provider,{value:z,children:e})},Co=()=>{const e=H.useNavigate(),{routes:t}=Se(),r=f.useCallback(a=>{if(!a)return!1;const n=a.endsWith("/")&&a!=="/"?a.slice(0,-1):a;return t.some(i=>{const c=i.path,d=c.endsWith("/")&&c!=="/"?c.slice(0,-1):c;if(d===n)return!0;if(d.includes(":")){const l=d.split("/").map(h=>h.startsWith(":")?"[^/]+":h).join("/");return new RegExp(`^${l}(/.*)?$`).test(n)}return i.exact===!1?n.startsWith(d):!1})},[t]);return{navigateTo:f.useCallback((a,n={})=>{if(a){if(a.startsWith("http://")||a.startsWith("https://")){n.newTab?window.open(a,"_blank"):window.location.href=a;return}r(a)?e(a,n):n.newTab?window.open(a,"_blank"):window.location.href=a}},[e,r]),isInternalRoute:r}},Nt=({to:e,children:t,className:r,onClick:o,...a})=>{const{isInternalRoute:n}=Co(),i=d=>{o&&o(d)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&n(e)?s.jsx(H.Link,{to:e,className:r,onClick:i,...a,children:t}):s.jsx("a",{href:e,className:r,onClick:i,...a,children:t})},Et=(e,t)=>{if(!e)return;e.querySelectorAll("svg").forEach(o=>{o.getAttribute("fill")&&o.getAttribute("fill")!=="none"&&o.setAttribute("fill",t),o.getAttribute("stroke")&&o.getAttribute("stroke")!=="none"&&o.setAttribute("stroke",t),o.querySelectorAll("*").forEach(n=>{n.getAttribute("fill")&&n.getAttribute("fill")!=="none"&&n.setAttribute("fill",t),n.getAttribute("stroke")&&n.getAttribute("stroke")!=="none"&&n.setAttribute("stroke",t)})})},sl=({appLogo:e,appName:t,linkTo:r="/app",collapsed:o=!1})=>{if(o){const a=t?t.charAt(0).toUpperCase():"A";return s.jsx("div",{className:"navbar-logo-container frame-logo-container",style:{padding:"16px",justifyContent:"center"},children:s.jsx(Nt,{to:r,style:{textDecoration:"none"},children:s.jsx("div",{className:"collapsed-logo-initial",style:{width:"32px",height:"32px",backgroundColor:"var(--color-brand-500, #5048ED)",color:"white",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:"bold"},children:a})})})}return s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:s.jsx(mr,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},vo=({menuItems:e=[],appLogo:t,theme:r={},config:o={}})=>{const a=H.useLocation(),[n,i]=f.useState({}),{appName:c}=Se(),d=f.useRef(null);f.useEffect(()=>{if(!d.current)return;const N=d.current.querySelector("#wideSidebarMenu");if(!N)return;N.querySelectorAll("li").forEach(K=>{const x=K.classList.contains("active"),E="var(--color-gray-700, #414651)",v="var(--color-brand-500, #5048ED)";Et(K,x?v:E);const k=()=>{K.classList.contains("active")||Et(K,v)},U=()=>{K.classList.contains("active")||Et(K,E)};return K.addEventListener("mouseenter",k),K.addEventListener("mouseleave",U),()=>{K.removeEventListener("mouseenter",k),K.removeEventListener("mouseleave",U)}})},[a.pathname,e]);const l=(N,M)=>{const K=N.url||N.uri,x=K?.endsWith("/")?K:`${K}/`,E=M.endsWith("/")?M:`${M}/`;return x===E?!0:N.children?.length?N.children.some(v=>{const k=v.url||v.uri;return(k?.endsWith("/")?k:`${k}/`)===E}):!1},u=N=>{i(M=>({...M,[N]:!M[N]}))};f.useEffect(()=>{const N={};e.forEach(M=>{M.children?.length&&l(M,a.pathname)&&(N[M.name]=!0)}),i(N)},[a.pathname,e]);const h=N=>N.icon?N.icon.includes("<svg")?s.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:N.icon}}):/^[\u{1F300}-\u{1F9FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]|[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(N.icon)||N.icon.length<=4?s.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:N.icon}):s.jsx("span",{className:"navbar-icon",children:s.jsx("img",{src:N.icon,alt:N.name,width:"16",height:"16"})}):s.jsx("span",{className:"navbar-icon",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M1.66675 8.00002C1.66675 5.1802 1.66675 3.77029 2.46539 2.83519C2.5788 2.70241 2.70247 2.57874 2.83525 2.46533C3.77035 1.66669 5.18026 1.66669 8.00008 1.66669C10.8199 1.66669 12.2298 1.66669 13.1649 2.46533C13.2977 2.57874 13.4213 2.70241 13.5347 2.83519C14.3334 3.77029 14.3334 5.1802 14.3334 8.00002C14.3334 10.8198 14.3334 12.2298 13.5347 13.1648C13.4213 13.2976 13.2977 13.4213 13.1649 13.5347C12.2298 14.3334 10.8199 14.3334 8.00008 14.3334C5.18026 14.3334 3.77035 14.3334 2.83525 13.5347C2.70247 13.4213 2.5788 13.2976 2.46539 13.1648C1.66675 12.2298 1.66675 10.8198 1.66675 8.00002Z",stroke:"currentColor",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.69235 4.83562C7.83568 4.61038 8.16448 4.61038 8.30782 4.83562L8.72255 5.48724C9.18115 6.20782 9.79228 6.81896 10.5129 7.27756L11.1645 7.69229C11.3897 7.83562 11.3897 8.16442 11.1645 8.30776L10.5129 8.72249C9.79228 9.18109 9.18115 9.79222 8.72255 10.5128L8.30782 11.1644C8.16448 11.3897 7.83568 11.3897 7.69235 11.1644L7.27762 10.5128C6.81902 9.79222 6.20788 9.18109 5.4873 8.72249L4.83568 8.30776C4.61044 8.16442 4.61044 7.83562 4.83568 7.69229L5.4873 7.27756C6.20788 6.81896 6.81902 6.20782 7.27762 5.48724L7.69235 4.83562Z",stroke:"currentColor",strokeLinejoin:"round"})]})}),{showLogo:w=!0,showMenu:m=!0,isCollapsed:g=!1,collapsible:A=!1,customLogo:C=null,customMenuContent:b=null,customBottomContent:_=null,customNavbar:O=null,customMenu:F=null,menuConfig:W={},className:q="",style:P={}}=o,[S,z]=f.useState(g),V=S?"80px":"244px";return s.jsxs("nav",{ref:d,className:`navbar ${S?"collapsed-sidebar":"wide-sidebar"} ${q}`,style:{width:V,...P,display:"flex",flexDirection:"column",transition:"width 0.3s ease"},children:[w&&(C?s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:C}):s.jsx(sl,{appLogo:t,appName:c,collapsed:S})),A&&s.jsx("div",{className:"navbar-toggle-container",style:{padding:"8px 16px",borderBottom:"1px solid var(--color-gray-200, #e5e7eb)"},children:s.jsx("button",{onClick:()=>z(!S),className:"navbar-toggle-btn",style:{width:"100%",padding:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background-color 0.2s ease"},onMouseEnter:N=>N.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:N=>N.target.style.backgroundColor="transparent",title:S?"Expand navbar":"Collapse navbar",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:S?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"var(--color-gray-600, #4b5563)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),s.jsx("div",{className:"navbar-menu-container frame-menu-container complete-hidden-scroll-style",style:{flex:1,overflow:"auto"},children:m&&(F||s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(N=>{const M=N.url||N.uri,K=l(N,a.pathname),x=n[N.name]||!1,E=N.children&&N.children.length>0;return s.jsxs(f.Fragment,{children:[s.jsx("li",{className:`menu-list-item ${E?"menu-list-item-with-sub-menu":""} ${K?"active":""}`,children:E?s.jsxs("div",{className:"menu-item",onClick:()=>!S&&u(N.name),style:{justifyContent:S?"center":"flex-start",padding:S?"8px":void 0},title:S?N.name:void 0,children:[h(N),!S&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`menu-title ${K?"font-semibold":""}`,children:N.name}),s.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${K&&x?"rotate-180":""}`,children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:s.jsx("path",{d:"M9.74976 3.99963C9.81538 3.99963 9.88053 4.01263 9.94116 4.03772C10.0018 4.06282 10.0569 4.09977 10.1033 4.14612C10.1496 4.19249 10.1865 4.24766 10.2117 4.30823C10.2368 4.36885 10.2497 4.43402 10.2498 4.49963C10.2498 4.56531 10.2368 4.63036 10.2117 4.69104C10.1865 4.75173 10.1497 4.8067 10.1033 4.85315L6.35327 8.60315C6.30685 8.64961 6.25184 8.68639 6.19116 8.71155C6.13048 8.73669 6.06544 8.75061 5.99976 8.75061C5.93412 8.75058 5.86899 8.73668 5.80835 8.71155C5.77819 8.69902 5.74944 8.6837 5.72241 8.66565L5.64624 8.60315L1.89624 4.85315C1.80256 4.75936 1.74976 4.6322 1.74976 4.49963C1.74981 4.36705 1.80248 4.23988 1.89624 4.14612C1.99 4.05236 2.11717 3.99969 2.24976 3.99963C2.38232 3.99963 2.50948 4.05244 2.60327 4.14612L5.99976 7.5426L9.39624 4.14612C9.44265 4.09971 9.49773 4.06286 9.55835 4.03772C9.61897 4.01261 9.68414 3.99966 9.74976 3.99963Z",fill:"#414651",stroke:"#414651",strokeWidth:"0.25"})})})]})]}):s.jsxs(Nt,{to:M,className:"menu-item",style:{justifyContent:S?"center":"flex-start",padding:S?"8px":void 0},title:S?N.name:void 0,children:[h(N),!S&&s.jsx("span",{className:`menu-title ${K?"font-semibold":""}`,children:N.name})]})}),E&&!S&&s.jsx("ul",{className:`submenu-list ${x?"active":""}`,children:N.children.map(v=>{const k=v.url||v.uri,U=a.pathname===k||a.pathname===`${k}/`;return s.jsx("li",{className:"submenu-list-item",children:s.jsxs(Nt,{to:k,className:`submenu-item d-flex ${U?"selected-each-wide-submenu":""}`,children:[s.jsx("span",{className:"submenu-item-icon-container",children:U?s.jsx("svg",{className:"w-3.5 h-2.5 inline-block",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:s.jsx("path",{d:"M13.3538 6.85375L10.3538 9.85375C10.2599 9.94757 10.1327 10.0003 10 10.0003C9.86732 10.0003 9.74007 9.94757 9.64625 9.85375C9.55243 9.75993 9.49972 9.63268 9.49972 9.5C9.49972 9.36732 9.55243 9.24007 9.64625 9.14625L11.7931 7H7C5.27665 6.99818 3.62441 6.31278 2.40582 5.09418C1.18722 3.87559 0.50182 2.22335 0.5 0.5C0.5 0.367392 0.552678 0.240215 0.646447 0.146447C0.740215 0.0526785 0.867392 0 1 0C1.13261 0 1.25979 0.0526785 1.35355 0.146447C1.44732 0.240215 1.5 0.367392 1.5 0.5C1.50165 1.95818 2.08165 3.35617 3.11274 4.38726C4.14383 5.41835 5.54182 5.99835 7 6H11.7931L9.64625 3.85375C9.55243 3.75993 9.49972 3.63268 9.49972 3.5C9.49972 3.36732 9.55243 3.24007 9.64625 3.14625C9.74007 3.05243 9.86732 2.99972 10 2.99972C10.1327 2.99972 10.2599 3.05243 10.3538 3.14625L13.3538 6.14625C13.4002 6.19269 13.4371 6.24783 13.4623 6.30853C13.4874 6.36923 13.5004 6.43429 13.5004 6.5C13.5004 6.56571 13.4874 6.63077 13.4623 6.69147C13.4371 6.75217 13.4002 6.80731 13.3538 6.85375Z",fill:"var(--color-brand-500, #5048ED)"})}):s.jsx("span",{className:"hidden"})}),s.jsx("span",{className:`text-xs ${U?"text-[var(--color-brand-500,#5048ED)]":"text-[var(--color-gray-700,#414651)]"}`,children:v.name})]})},k)})})]},N.name)})}),b&&!S&&s.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:b})]}))}),_&&s.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:_})]})},ol=(e=!0)=>{const[t,r]=f.useState(null),[o,a]=f.useState(!1),[n,i]=f.useState(null),[c,d]=f.useState(!1),[l,u]=f.useState(!1),h=async()=>{if(!(!e||t&&!c)){a(!0),i(null);try{const m=await Ur();if(m.success&&m.response){const g=m.response.profile_data||m.response;m.response.password_policy&&!g.password_policy&&(g.password_policy=m.response.password_policy),u(m.response.should_set_password||!1),r(g),i(null)}else{const g=m.response?.message||"Failed to fetch profile data";i(g),console.error("Profile API Error:",m)}}catch(m){const g=m.message||"Network error while fetching profile";i(g),console.error("Profile fetch error:",m)}finally{a(!1),d(!0)}}},w=()=>{d(!1),h()};return f.useEffect(()=>{e&&!c&&h()},[e]),{profileData:t,loading:o,error:n,refetch:w,shouldSetPassword:l}},_e=(e,t="/",r=null)=>{let o=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`;r&&(o+=` domain=${r};`),document.cookie=o,r||(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t}; domain=${window.location.hostname};`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`)},ur=e=>{const t=e+"=",r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},xo=(e,t,r=null,o="/",a=null)=>{let n="";if(r){const c=new Date;c.setTime(c.getTime()+r*24*60*60*1e3),n="; expires="+c.toUTCString()}let i=`${e}=${t}${n}; path=${o}`;a&&(i+=`; domain=${a}`),document.cookie=i},Po=()=>{const e=ur("zangocookie");return e!==null&&e!==""},So=Object.freeze({__proto__:null,deleteCookie:_e,getCookie:ur,isAuthenticatedViaCookie:Po,setCookie:xo}),ko=async(e={})=>{try{const t=await jr();if(t.success||t.responseStatus===401){_e("zangocookie","/"),_e("zangocookie","/app"),_e("zangocookie","/app/"),_e("zangocookie");const r=window.location.hostname;if(_e("zangocookie","/",r),_e("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");_e("zangocookie","/",a),_e("zangocookie","/app",a)}localStorage.removeItem("authToken"),localStorage.clear(),sessionStorage.clear();const o=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=o},100)}else p.toast.error({title:"Logout Failed",description:t.response?.message||"Unable to logout. Please try again.",duration:5e3})}catch(t){console.error("Logout error:",t),p.toast.error({title:"Logout Error",description:"An error occurred while logging out. Please try again.",duration:5e3});const r=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=r},100)}},Ao=e=>{const t=document.createElement("div");t.style.cssText=`
109
+ */const $a=Ae("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);function ps(e,t){return function(){return e.apply(t,arguments)}}const{toString:Va}=Object.prototype,{getPrototypeOf:Kt}=Object,{iterator:vt,toStringTag:gs}=Symbol,xt=(e=>t=>{const r=Va.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),_e=e=>(e=e.toLowerCase(),t=>xt(t)===e),Pt=e=>t=>typeof t===e,{isArray:Ke}=Array,Je=Pt("undefined");function nt(e){return e!==null&&!Je(e)&&e.constructor!==null&&!Je(e.constructor)&&ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ms=_e("ArrayBuffer");function ja(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ms(e.buffer),t}const Da=Pt("string"),ye=Pt("function"),ws=Pt("number"),it=e=>e!==null&&typeof e=="object",Ha=e=>e===!0||e===!1,St=e=>{if(xt(e)!=="object")return!1;const t=Kt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gs in e)&&!(vt in e)},za=e=>{if(!it(e)||nt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Wa=_e("Date"),Za=_e("File"),Ga=_e("Blob"),Ka=_e("FileList"),Ja=e=>it(e)&&ye(e.pipe),Xa=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||ye(e.append)&&((t=xt(e))==="formdata"||t==="object"&&ye(e.toString)&&e.toString()==="[object FormData]"))},Qa=_e("URLSearchParams"),[Ya,Ra,en,tn]=["ReadableStream","Request","Response","Headers"].map(_e),rn=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function lt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let o,a;if(typeof e!="object"&&(e=[e]),Ke(e))for(o=0,a=e.length;o<a;o++)t.call(null,e[o],o,e);else{if(nt(e))return;const n=r?Object.getOwnPropertyNames(e):Object.keys(e),i=n.length;let c;for(o=0;o<i;o++)c=n[o],t.call(null,e[c],c,e)}}function ys(e,t){if(nt(e))return null;t=t.toLowerCase();const r=Object.keys(e);let o=r.length,a;for(;o-- >0;)if(a=r[o],t===a.toLowerCase())return a;return null}const De=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,bs=e=>!Je(e)&&e!==De;function Jt(){const{caseless:e,skipUndefined:t}=bs(this)&&this||{},r={},o=(a,n)=>{const i=e&&ys(r,n)||n;St(r[i])&&St(a)?r[i]=Jt(r[i],a):St(a)?r[i]=Jt({},a):Ke(a)?r[i]=a.slice():(!t||!Je(a))&&(r[i]=a)};for(let a=0,n=arguments.length;a<n;a++)arguments[a]&&lt(arguments[a],o);return r}const sn=(e,t,r,{allOwnKeys:o}={})=>(lt(t,(a,n)=>{r&&ye(a)?e[n]=ps(a,r):e[n]=a},{allOwnKeys:o}),e),on=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),an=(e,t,r,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},nn=(e,t,r,o)=>{let a,n,i;const c={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),n=a.length;n-- >0;)i=a[n],(!o||o(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&Kt(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},ln=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const o=e.indexOf(t,r);return o!==-1&&o===r},cn=e=>{if(!e)return null;if(Ke(e))return e;let t=e.length;if(!ws(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},dn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Kt(Uint8Array)),un=(e,t)=>{const o=(e&&e[vt]).call(e);let a;for(;(a=o.next())&&!a.done;){const n=a.value;t.call(e,n[0],n[1])}},hn=(e,t)=>{let r;const o=[];for(;(r=e.exec(t))!==null;)o.push(r);return o},fn=_e("HTMLFormElement"),pn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,a){return o.toUpperCase()+a}),Cs=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gn=_e("RegExp"),vs=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),o={};lt(r,(a,n)=>{let i;(i=t(a,n,e))!==!1&&(o[n]=i||a)}),Object.defineProperties(e,o)},mn=e=>{vs(e,(t,r)=>{if(ye(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=e[r];if(ye(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},wn=(e,t)=>{const r={},o=a=>{a.forEach(n=>{r[n]=!0})};return Ke(e)?o(e):o(String(e).split(t)),r},yn=()=>{},bn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Cn(e){return!!(e&&ye(e.append)&&e[gs]==="FormData"&&e[vt])}const vn=e=>{const t=new Array(10),r=(o,a)=>{if(it(o)){if(t.indexOf(o)>=0)return;if(nt(o))return o;if(!("toJSON"in o)){t[a]=o;const n=Ke(o)?[]:{};return lt(o,(i,c)=>{const d=r(i,a+1);!Je(d)&&(n[c]=d)}),t[a]=void 0,n}}return o};return r(e,0)},xn=_e("AsyncFunction"),Pn=e=>e&&(it(e)||ye(e))&&ye(e.then)&&ye(e.catch),xs=((e,t)=>e?setImmediate:t?((r,o)=>(De.addEventListener("message",({source:a,data:n})=>{a===De&&n===r&&o.length&&o.shift()()},!1),a=>{o.push(a),De.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",ye(De.postMessage)),Sn=typeof queueMicrotask<"u"?queueMicrotask.bind(De):typeof process<"u"&&process.nextTick||xs,b={isArray:Ke,isArrayBuffer:ms,isBuffer:nt,isFormData:Xa,isArrayBufferView:ja,isString:Da,isNumber:ws,isBoolean:Ha,isObject:it,isPlainObject:St,isEmptyObject:za,isReadableStream:Ya,isRequest:Ra,isResponse:en,isHeaders:tn,isUndefined:Je,isDate:Wa,isFile:Za,isBlob:Ga,isRegExp:gn,isFunction:ye,isStream:Ja,isURLSearchParams:Qa,isTypedArray:dn,isFileList:Ka,forEach:lt,merge:Jt,extend:sn,trim:rn,stripBOM:on,inherits:an,toFlatObject:nn,kindOf:xt,kindOfTest:_e,endsWith:ln,toArray:cn,forEachEntry:un,matchAll:hn,isHTMLForm:fn,hasOwnProperty:Cs,hasOwnProp:Cs,reduceDescriptors:vs,freezeMethods:mn,toObjectSet:wn,toCamelCase:pn,noop:yn,toFiniteNumber:bn,findKey:ys,global:De,isContextDefined:bs,isSpecCompliantForm:Cn,toJSONObject:vn,isAsyncFn:xn,isThenable:Pn,setImmediate:xs,asap:Sn,isIterable:e=>e!=null&&ye(e[vt])};function Y(e,t,r,o,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),o&&(this.request=o),a&&(this.response=a,this.status=a.status?a.status:null)}b.inherits(Y,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:b.toJSONObject(this.config),code:this.code,status:this.status}}});const Ps=Y.prototype,Ss={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ss[e]={value:e}}),Object.defineProperties(Y,Ss),Object.defineProperty(Ps,"isAxiosError",{value:!0}),Y.from=(e,t,r,o,a,n)=>{const i=Object.create(Ps);b.toFlatObject(e,i,function(u){return u!==Error.prototype},l=>l!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return Y.call(i,c,d,r,o,a),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",n&&Object.assign(i,n),i};const kn=null;function Xt(e){return b.isPlainObject(e)||b.isArray(e)}function ks(e){return b.endsWith(e,"[]")?e.slice(0,-2):e}function As(e,t,r){return e?e.concat(t).map(function(a,n){return a=ks(a),!r&&n?"["+a+"]":a}).join(r?".":""):t}function An(e){return b.isArray(e)&&!e.some(Xt)}const _n=b.toFlatObject(b,{},null,function(t){return/^is[A-Z]/.test(t)});function kt(e,t,r){if(!b.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=b.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,y){return!b.isUndefined(y[x])});const o=r.metaTokens,a=r.visitor||u,n=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(t);if(!b.isFunction(a))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(b.isDate(f))return f.toISOString();if(b.isBoolean(f))return f.toString();if(!d&&b.isBlob(f))throw new Y("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(f)||b.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,x,y){let P=f;if(f&&!y&&typeof f=="object"){if(b.endsWith(x,"{}"))x=o?x:x.slice(0,-2),f=JSON.stringify(f);else if(b.isArray(f)&&An(f)||(b.isFileList(f)||b.endsWith(x,"[]"))&&(P=b.toArray(f)))return x=ks(x),P.forEach(function(B,N){!(b.isUndefined(B)||B===null)&&t.append(i===!0?As([x],N,n):i===null?x:x+"[]",l(B))}),!1}return Xt(f)?!0:(t.append(As(y,x,n),l(f)),!1)}const h=[],m=Object.assign(_n,{defaultVisitor:u,convertValue:l,isVisitable:Xt});function w(f,x){if(!b.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));h.push(f),b.forEach(f,function(P,A){(!(b.isUndefined(P)||P===null)&&a.call(t,P,b.isString(A)?A.trim():A,x,m))===!0&&w(P,x?x.concat(A):[A])}),h.pop()}}if(!b.isObject(e))throw new TypeError("data must be an object");return w(e),t}function _s(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(o){return t[o]})}function Qt(e,t){this._pairs=[],e&&kt(e,this,t)}const Ls=Qt.prototype;Ls.append=function(t,r){this._pairs.push([t,r])},Ls.toString=function(t){const r=t?function(o){return t.call(this,o,_s)}:_s;return this._pairs.map(function(a){return r(a[0])+"="+r(a[1])},"").join("&")};function Ln(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ts(e,t,r){if(!t)return e;const o=r&&r.encode||Ln;b.isFunction(r)&&(r={serialize:r});const a=r&&r.serialize;let n;if(a?n=a(t,r):n=b.isURLSearchParams(t)?t.toString():new Qt(t,r).toString(o),n){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}class Ns{constructor(){this.handlers=[]}use(t,r,o){return this.handlers.push({fulfilled:t,rejected:r,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){b.forEach(this.handlers,function(o){o!==null&&t(o)})}}const Es={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Tn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Qt,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Yt=typeof window<"u"&&typeof document<"u",Rt=typeof navigator=="object"&&navigator||void 0,Nn=Yt&&(!Rt||["ReactNative","NativeScript","NS"].indexOf(Rt.product)<0),En=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Fn=Yt&&window.location.href||"http://localhost",de={...Object.freeze({__proto__:null,hasBrowserEnv:Yt,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:En,navigator:Rt,origin:Fn}),...Tn};function On(e,t){return kt(e,new de.classes.URLSearchParams,{visitor:function(r,o,a,n){return de.isNode&&b.isBuffer(r)?(this.append(o,r.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}function Mn(e){return b.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Un(e){const t={},r=Object.keys(e);let o;const a=r.length;let n;for(o=0;o<a;o++)n=r[o],t[n]=e[n];return t}function Fs(e){function t(r,o,a,n){let i=r[n++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=n>=r.length;return i=!i&&b.isArray(a)?a.length:i,d?(b.hasOwnProp(a,i)?a[i]=[a[i],o]:a[i]=o,!c):((!a[i]||!b.isObject(a[i]))&&(a[i]=[]),t(r,o,a[i],n)&&b.isArray(a[i])&&(a[i]=Un(a[i])),!c)}if(b.isFormData(e)&&b.isFunction(e.entries)){const r={};return b.forEachEntry(e,(o,a)=>{t(Mn(o),a,r,0)}),r}return null}function Bn(e,t,r){if(b.isString(e))try{return(t||JSON.parse)(e),b.trim(e)}catch(o){if(o.name!=="SyntaxError")throw o}return(r||JSON.stringify)(e)}const ct={transitional:Es,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const o=r.getContentType()||"",a=o.indexOf("application/json")>-1,n=b.isObject(t);if(n&&b.isHTMLForm(t)&&(t=new FormData(t)),b.isFormData(t))return a?JSON.stringify(Fs(t)):t;if(b.isArrayBuffer(t)||b.isBuffer(t)||b.isStream(t)||b.isFile(t)||b.isBlob(t)||b.isReadableStream(t))return t;if(b.isArrayBufferView(t))return t.buffer;if(b.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(n){if(o.indexOf("application/x-www-form-urlencoded")>-1)return On(t,this.formSerializer).toString();if((c=b.isFileList(t))||o.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return kt(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return n||a?(r.setContentType("application/json",!1),Bn(t)):t}],transformResponse:[function(t){const r=this.transitional||ct.transitional,o=r&&r.forcedJSONParsing,a=this.responseType==="json";if(b.isResponse(t)||b.isReadableStream(t))return t;if(t&&b.isString(t)&&(o&&!this.responseType||a)){const i=!(r&&r.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?Y.from(c,Y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:de.classes.FormData,Blob:de.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],e=>{ct.headers[e]={}});const qn=b.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"]),In=e=>{const t={};let r,o,a;return e&&e.split(`
110
+ `).forEach(function(i){a=i.indexOf(":"),r=i.substring(0,a).trim().toLowerCase(),o=i.substring(a+1).trim(),!(!r||t[r]&&qn[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},Os=Symbol("internals");function dt(e){return e&&String(e).trim().toLowerCase()}function At(e){return e===!1||e==null?e:b.isArray(e)?e.map(At):String(e)}function $n(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(e);)t[o[1]]=o[2];return t}const Vn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function er(e,t,r,o,a){if(b.isFunction(o))return o.call(this,t,r);if(a&&(t=r),!!b.isString(t)){if(b.isString(o))return t.indexOf(o)!==-1;if(b.isRegExp(o))return o.test(t)}}function jn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function Dn(e,t){const r=b.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+r,{value:function(a,n,i){return this[o].call(this,t,a,n,i)},configurable:!0})})}let be=class{constructor(t){t&&this.set(t)}set(t,r,o){const a=this;function n(c,d,l){const u=dt(d);if(!u)throw new Error("header name must be a non-empty string");const h=b.findKey(a,u);(!h||a[h]===void 0||l===!0||l===void 0&&a[h]!==!1)&&(a[h||d]=At(c))}const i=(c,d)=>b.forEach(c,(l,u)=>n(l,u,d));if(b.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(b.isString(t)&&(t=t.trim())&&!Vn(t))i(In(t),r);else if(b.isObject(t)&&b.isIterable(t)){let c={},d,l;for(const u of t){if(!b.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?b.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,r)}else t!=null&&n(r,t,o);return this}get(t,r){if(t=dt(t),t){const o=b.findKey(this,t);if(o){const a=this[o];if(!r)return a;if(r===!0)return $n(a);if(b.isFunction(r))return r.call(this,a,o);if(b.isRegExp(r))return r.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=dt(t),t){const o=b.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||er(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let a=!1;function n(i){if(i=dt(i),i){const c=b.findKey(o,i);c&&(!r||er(o,o[c],c,r))&&(delete o[c],a=!0)}}return b.isArray(t)?t.forEach(n):n(t),a}clear(t){const r=Object.keys(this);let o=r.length,a=!1;for(;o--;){const n=r[o];(!t||er(this,this[n],n,t,!0))&&(delete this[n],a=!0)}return a}normalize(t){const r=this,o={};return b.forEach(this,(a,n)=>{const i=b.findKey(o,n);if(i){r[i]=At(a),delete r[n];return}const c=t?jn(n):String(n).trim();c!==n&&delete r[n],r[c]=At(a),o[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return b.forEach(this,(o,a)=>{o!=null&&o!==!1&&(r[a]=t&&b.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
111
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(a=>o.set(a)),o}static accessor(t){const o=(this[Os]=this[Os]={accessors:{}}).accessors,a=this.prototype;function n(i){const c=dt(i);o[c]||(Dn(a,i),o[c]=!0)}return b.isArray(t)?t.forEach(n):n(t),this}};be.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(be.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(o){this[r]=o}}}),b.freezeMethods(be);function tr(e,t){const r=this||ct,o=t||r,a=be.from(o.headers);let n=o.data;return b.forEach(e,function(c){n=c.call(r,n,a.normalize(),t?t.status:void 0)}),a.normalize(),n}function Ms(e){return!!(e&&e.__CANCEL__)}function Xe(e,t,r){Y.call(this,e??"canceled",Y.ERR_CANCELED,t,r),this.name="CanceledError"}b.inherits(Xe,Y,{__CANCEL__:!0});function Us(e,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?e(r):t(new Y("Request failed with status code "+r.status,[Y.ERR_BAD_REQUEST,Y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function zn(e,t){e=e||10;const r=new Array(e),o=new Array(e);let a=0,n=0,i;return t=t!==void 0?t:1e3,function(d){const l=Date.now(),u=o[n];i||(i=l),r[a]=d,o[a]=l;let h=n,m=0;for(;h!==a;)m+=r[h++],h=h%e;if(a=(a+1)%e,a===n&&(n=(n+1)%e),l-i<t)return;const w=u&&l-u;return w?Math.round(m*1e3/w):void 0}}function Wn(e,t){let r=0,o=1e3/t,a,n;const i=(l,u=Date.now())=>{r=u,a=null,n&&(clearTimeout(n),n=null),e(...l)};return[(...l)=>{const u=Date.now(),h=u-r;h>=o?i(l,u):(a=l,n||(n=setTimeout(()=>{n=null,i(a)},o-h)))},()=>a&&i(a)]}const _t=(e,t,r=3)=>{let o=0;const a=zn(50,250);return Wn(n=>{const i=n.loaded,c=n.lengthComputable?n.total:void 0,d=i-o,l=a(d),u=i<=c;o=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:n,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},r)},Bs=(e,t)=>{const r=e!=null;return[o=>t[0]({lengthComputable:r,total:e,loaded:o}),t[1]]},qs=e=>(...t)=>b.asap(()=>e(...t)),Zn=de.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,de.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(de.origin),de.navigator&&/(msie|trident)/i.test(de.navigator.userAgent)):()=>!0,Gn=de.hasStandardBrowserEnv?{write(e,t,r,o,a,n,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];b.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),b.isString(o)&&c.push(`path=${o}`),b.isString(a)&&c.push(`domain=${a}`),n===!0&&c.push("secure"),b.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Kn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Is(e,t,r){let o=!Kn(t);return e&&(o||r==!1)?Jn(e,t):t}const $s=e=>e instanceof be?{...e}:e;function He(e,t){t=t||{};const r={};function o(l,u,h,m){return b.isPlainObject(l)&&b.isPlainObject(u)?b.merge.call({caseless:m},l,u):b.isPlainObject(u)?b.merge({},u):b.isArray(u)?u.slice():u}function a(l,u,h,m){if(b.isUndefined(u)){if(!b.isUndefined(l))return o(void 0,l,h,m)}else return o(l,u,h,m)}function n(l,u){if(!b.isUndefined(u))return o(void 0,u)}function i(l,u){if(b.isUndefined(u)){if(!b.isUndefined(l))return o(void 0,l)}else return o(void 0,u)}function c(l,u,h){if(h in t)return o(l,u);if(h in e)return o(void 0,l)}const d={url:n,method:n,data:n,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:c,headers:(l,u,h)=>a($s(l),$s(u),h,!0)};return b.forEach(Object.keys({...e,...t}),function(u){const h=d[u]||a,m=h(e[u],t[u],u);b.isUndefined(m)&&h!==c||(r[u]=m)}),r}const Vs=e=>{const t=He({},e);let{data:r,withXSRFToken:o,xsrfHeaderName:a,xsrfCookieName:n,headers:i,auth:c}=t;if(t.headers=i=be.from(i),t.url=Ts(Is(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),b.isFormData(r)){if(de.hasStandardBrowserEnv||de.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(b.isFunction(r.getHeaders)){const d=r.getHeaders(),l=["content-type","content-length"];Object.entries(d).forEach(([u,h])=>{l.includes(u.toLowerCase())&&i.set(u,h)})}}if(de.hasStandardBrowserEnv&&(o&&b.isFunction(o)&&(o=o(t)),o||o!==!1&&Zn(t.url))){const d=a&&n&&Gn.read(n);d&&i.set(a,d)}return t},Xn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,o){const a=Vs(e);let n=a.data;const i=be.from(a.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=a,u,h,m,w,f;function x(){w&&w(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(u),a.signal&&a.signal.removeEventListener("abort",u)}let y=new XMLHttpRequest;y.open(a.method.toUpperCase(),a.url,!0),y.timeout=a.timeout;function P(){if(!y)return;const B=be.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),H={data:!c||c==="text"||c==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:B,config:e,request:y};Us(function(v){r(v),x()},function(v){o(v),x()},H),y=null}"onloadend"in y?y.onloadend=P:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(P)},y.onabort=function(){y&&(o(new Y("Request aborted",Y.ECONNABORTED,e,y)),y=null)},y.onerror=function(N){const H=N&&N.message?N.message:"Network Error",S=new Y(H,Y.ERR_NETWORK,e,y);S.event=N||null,o(S),y=null},y.ontimeout=function(){let N=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const H=a.transitional||Es;a.timeoutErrorMessage&&(N=a.timeoutErrorMessage),o(new Y(N,H.clarifyTimeoutError?Y.ETIMEDOUT:Y.ECONNABORTED,e,y)),y=null},n===void 0&&i.setContentType(null),"setRequestHeader"in y&&b.forEach(i.toJSON(),function(N,H){y.setRequestHeader(H,N)}),b.isUndefined(a.withCredentials)||(y.withCredentials=!!a.withCredentials),c&&c!=="json"&&(y.responseType=a.responseType),l&&([m,f]=_t(l,!0),y.addEventListener("progress",m)),d&&y.upload&&([h,w]=_t(d),y.upload.addEventListener("progress",h),y.upload.addEventListener("loadend",w)),(a.cancelToken||a.signal)&&(u=B=>{y&&(o(!B||B.type?new Xe(null,e,y):B),y.abort(),y=null)},a.cancelToken&&a.cancelToken.subscribe(u),a.signal&&(a.signal.aborted?u():a.signal.addEventListener("abort",u)));const A=Hn(a.url);if(A&&de.protocols.indexOf(A)===-1){o(new Y("Unsupported protocol "+A+":",Y.ERR_BAD_REQUEST,e));return}y.send(n||null)})},Qn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let o=new AbortController,a;const n=function(l){if(!a){a=!0,c();const u=l instanceof Error?l:this.reason;o.abort(u instanceof Y?u:new Xe(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,n(new Y(`timeout ${t} of ms exceeded`,Y.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(n):l.removeEventListener("abort",n)}),e=null)};e.forEach(l=>l.addEventListener("abort",n));const{signal:d}=o;return d.unsubscribe=()=>b.asap(c),d}},Yn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let o=0,a;for(;o<r;)a=o+t,yield e.slice(o,a),o=a},Rn=async function*(e,t){for await(const r of ei(e))yield*Yn(r,t)},ei=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)break;yield o}}finally{await t.cancel()}},js=(e,t,r,o)=>{const a=Rn(e,t);let n=0,i,c=d=>{i||(i=!0,o&&o(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await a.next();if(l){c(),d.close();return}let h=u.byteLength;if(r){let m=n+=h;r(m)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),a.return()}},{highWaterMark:2})},Ds=64*1024,{isFunction:Lt}=b,ti=(({Request:e,Response:t})=>({Request:e,Response:t}))(b.global),{ReadableStream:Hs,TextEncoder:zs}=b.global,Ws=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ri=e=>{e=b.merge.call({skipUndefined:!0},ti,e);const{fetch:t,Request:r,Response:o}=e,a=t?Lt(t):typeof fetch=="function",n=Lt(r),i=Lt(o);if(!a)return!1;const c=a&&Lt(Hs),d=a&&(typeof zs=="function"?(f=>x=>f.encode(x))(new zs):async f=>new Uint8Array(await new r(f).arrayBuffer())),l=n&&c&&Ws(()=>{let f=!1;const x=new r(de.origin,{body:new Hs,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!x}),u=i&&c&&Ws(()=>b.isReadableStream(new o("").body)),h={stream:u&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(x,y)=>{let P=x&&x[f];if(P)return P.call(x);throw new Y(`Response type '${f}' is not supported`,Y.ERR_NOT_SUPPORT,y)})});const m=async f=>{if(f==null)return 0;if(b.isBlob(f))return f.size;if(b.isSpecCompliantForm(f))return(await new r(de.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(b.isArrayBufferView(f)||b.isArrayBuffer(f))return f.byteLength;if(b.isURLSearchParams(f)&&(f=f+""),b.isString(f))return(await d(f)).byteLength},w=async(f,x)=>{const y=b.toFiniteNumber(f.getContentLength());return y??m(x)};return async f=>{let{url:x,method:y,data:P,signal:A,cancelToken:B,timeout:N,onDownloadProgress:H,onUploadProgress:S,responseType:v,headers:C,withCredentials:F="same-origin",fetchOptions:D}=Vs(f),k=t||fetch;v=v?(v+"").toLowerCase():"text";let U=Qn([A,B&&B.toAbortSignal()],N),I=null;const j=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let L;try{if(S&&l&&y!=="get"&&y!=="head"&&(L=await w(C,P))!==0){let z=new r(x,{method:"POST",body:P,duplex:"half"}),_;if(b.isFormData(P)&&(_=z.headers.get("content-type"))&&C.setContentType(_),z.body){const[J,V]=Bs(L,_t(qs(S)));P=js(z.body,Ds,J,V)}}b.isString(F)||(F=F?"include":"omit");const T=n&&"credentials"in r.prototype,M={...D,signal:U,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:P,duplex:"half",credentials:T?F:void 0};I=n&&new r(x,M);let E=await(n?k(I,D):k(x,M));const Z=u&&(v==="stream"||v==="response");if(u&&(H||Z&&j)){const z={};["status","statusText","headers"].forEach(K=>{z[K]=E[K]});const _=b.toFiniteNumber(E.headers.get("content-length")),[J,V]=H&&Bs(_,_t(qs(H),!0))||[];E=new o(js(E.body,Ds,J,()=>{V&&V(),j&&j()}),z)}v=v||"text";let Q=await h[b.findKey(h,v)||"text"](E,f);return!Z&&j&&j(),await new Promise((z,_)=>{Us(z,_,{data:Q,headers:be.from(E.headers),status:E.status,statusText:E.statusText,config:f,request:I})})}catch(T){throw j&&j(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Y("Network Error",Y.ERR_NETWORK,f,I),{cause:T.cause||T}):Y.from(T,T&&T.code,f,I)}}},si=new Map,Zs=e=>{let t=e&&e.env||{};const{fetch:r,Request:o,Response:a}=t,n=[o,a,r];let i=n.length,c=i,d,l,u=si;for(;c--;)d=n[c],l=u.get(d),l===void 0&&u.set(d,l=c?new Map:ri(t)),u=l;return l};Zs();const rr={http:kn,xhr:Xn,fetch:{get:Zs}};b.forEach(rr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gs=e=>`- ${e}`,oi=e=>b.isFunction(e)||e===null||e===!1;function ai(e,t){e=b.isArray(e)?e:[e];const{length:r}=e;let o,a;const n={};for(let i=0;i<r;i++){o=e[i];let c;if(a=o,!oi(o)&&(a=rr[(c=String(o)).toLowerCase()],a===void 0))throw new Y(`Unknown adapter '${c}'`);if(a&&(b.isFunction(a)||(a=a.get(t))))break;n[c||"#"+i]=a}if(!a){const i=Object.entries(n).map(([d,l])=>`adapter ${d} `+(l===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
112
+ `+i.map(Gs).join(`
113
+ `):" "+Gs(i[0]):"as no adapter specified";throw new Y("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return a}const Ks={getAdapter:ai,adapters:rr};function sr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xe(null,e)}function Js(e){return sr(e),e.headers=be.from(e.headers),e.data=tr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ks.getAdapter(e.adapter||ct.adapter,e)(e).then(function(o){return sr(e),o.data=tr.call(e,e.transformResponse,o),o.headers=be.from(o.headers),o},function(o){return Ms(o)||(sr(e),o&&o.response&&(o.response.data=tr.call(e,e.transformResponse,o.response),o.response.headers=be.from(o.response.headers))),Promise.reject(o)})}const Xs="1.13.0",Tt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Tt[e]=function(o){return typeof o===e||"a"+(t<1?"n ":" ")+e}});const Qs={};Tt.transitional=function(t,r,o){function a(n,i){return"[Axios v"+Xs+"] Transitional option '"+n+"'"+i+(o?". "+o:"")}return(n,i,c)=>{if(t===!1)throw new Y(a(i," has been removed"+(r?" in "+r:"")),Y.ERR_DEPRECATED);return r&&!Qs[i]&&(Qs[i]=!0,console.warn(a(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(n,i,c):!0}},Tt.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function ni(e,t,r){if(typeof e!="object")throw new Y("options must be an object",Y.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let a=o.length;for(;a-- >0;){const n=o[a],i=t[n];if(i){const c=e[n],d=c===void 0||i(c,n,e);if(d!==!0)throw new Y("option "+n+" must be "+d,Y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Y("Unknown option "+n,Y.ERR_BAD_OPTION)}}const Nt={assertOptions:ni,validators:Tt},Le=Nt.validators;let ze=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ns,response:new Ns}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const n=a.stack?a.stack.replace(/^.+\n/,""):"";try{o.stack?n&&!String(o.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(o.stack+=`
114
+ `+n):o.stack=n}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=He(this.defaults,r);const{transitional:o,paramsSerializer:a,headers:n}=r;o!==void 0&&Nt.assertOptions(o,{silentJSONParsing:Le.transitional(Le.boolean),forcedJSONParsing:Le.transitional(Le.boolean),clarifyTimeoutError:Le.transitional(Le.boolean)},!1),a!=null&&(b.isFunction(a)?r.paramsSerializer={serialize:a}:Nt.assertOptions(a,{encode:Le.function,serialize:Le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Nt.assertOptions(r,{baseUrl:Le.spelling("baseURL"),withXsrfToken:Le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=n&&b.merge(n.common,n[r.method]);n&&b.forEach(["delete","get","head","post","put","patch","common"],f=>{delete n[f]}),r.headers=be.concat(i,n);const c=[];let d=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(r)===!1||(d=d&&x.synchronous,c.unshift(x.fulfilled,x.rejected))});const l=[];this.interceptors.response.forEach(function(x){l.push(x.fulfilled,x.rejected)});let u,h=0,m;if(!d){const f=[Js.bind(this),void 0];for(f.unshift(...c),f.push(...l),m=f.length,u=Promise.resolve(r);h<m;)u=u.then(f[h++],f[h++]);return u}m=c.length;let w=r;for(;h<m;){const f=c[h++],x=c[h++];try{w=f(w)}catch(y){x.call(this,y);break}}try{u=Js.call(this,w)}catch(f){return Promise.reject(f)}for(h=0,m=l.length;h<m;)u=u.then(l[h++],l[h++]);return u}getUri(t){t=He(this.defaults,t);const r=Is(t.baseURL,t.url,t.allowAbsoluteUrls);return Ts(r,t.params,t.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(t){ze.prototype[t]=function(r,o){return this.request(He(o||{},{method:t,url:r,data:(o||{}).data}))}}),b.forEach(["post","put","patch"],function(t){function r(o){return function(n,i,c){return this.request(He(c||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ze.prototype[t]=r(),ze.prototype[t+"Form"]=r(!0)});let ii=class Zo{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(n){r=n});const o=this;this.promise.then(a=>{if(!o._listeners)return;let n=o._listeners.length;for(;n-- >0;)o._listeners[n](a);o._listeners=null}),this.promise.then=a=>{let n;const i=new Promise(c=>{o.subscribe(c),n=c}).then(a);return i.cancel=function(){o.unsubscribe(n)},i},t(function(n,i,c){o.reason||(o.reason=new Xe(n,i,c),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Zo(function(a){t=a}),cancel:t}}};function li(e){return function(r){return e.apply(null,r)}}function ci(e){return b.isObject(e)&&e.isAxiosError===!0}const or={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(or).forEach(([e,t])=>{or[t]=e});function Ys(e){const t=new ze(e),r=ps(ze.prototype.request,t);return b.extend(r,ze.prototype,t,{allOwnKeys:!0}),b.extend(r,t,null,{allOwnKeys:!0}),r.create=function(a){return Ys(He(e,a))},r}const te=Ys(ct);te.Axios=ze,te.CanceledError=Xe,te.CancelToken=ii,te.isCancel=Ms,te.VERSION=Xs,te.toFormData=kt,te.AxiosError=Y,te.Cancel=te.CanceledError,te.all=function(t){return Promise.all(t)},te.spread=li,te.isAxiosError=ci,te.mergeConfig=He,te.AxiosHeaders=be,te.formToJSON=e=>Fs(b.isHTMLForm(e)?new FormData(e):e),te.getAdapter=Ks.getAdapter,te.HttpStatusCode=or,te.default=te;const{Axios:ic,AxiosError:lc,CanceledError:cc,isCancel:dc,CancelToken:uc,VERSION:hc,all:fc,Cancel:pc,isAxiosError:gc,spread:mc,toFormData:wc,AxiosHeaders:yc,HttpStatusCode:bc,formToJSON:Cc,getAdapter:vc,mergeConfig:xc}=te,ce="/api/v1/appauth".replace(/\/+$/,"");class Me{constructor(t,r=ce,o=te){this.basePath=r,this.axios=o,t&&(this.configuration=t,this.basePath=t.basePath??r)}}class di extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}const ue={"UserProfileApi.getUserProfile":[{url:"/api/v1",description:"Profile API base URL"}],"UserProfileApi.updateUserProfile":[{url:"/api/v1",description:"Profile API base URL"}]},he="https://example.com",se=function(e,t,r){if(r==null)throw new di(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function ar(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(o=>ar(e,o,r)):Object.keys(t).forEach(o=>ar(e,t[o],`${r}${r!==""?".":""}${o}`)):e.has(r)?e.append(r,t):e.set(r,t))}const fe=function(e,...t){const r=new URLSearchParams(e.search);ar(r,t),e.search=r.toString()},Qe=function(e,t,r){const o=typeof e!="string";return(o&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):o)?JSON.stringify(e!==void 0?e:{}):e||""},pe=function(e){return e.pathname+e.search+e.hash},ge=function(e,t,r,o){return(a=t,n=r)=>{const i={...e.options,url:(a.defaults.baseURL?"":o?.basePath??n)+e.url};return a.request(i)}},ui=function(e){return{getAppAuthConfig:async(t={})=>{const r="/config/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},updateAppAuthConfig:async(t,r,o={})=>{se("updateAppAuthConfig","xCSRFToken",t),se("updateAppAuthConfig","authConfig",r);const a="/config/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={},u=new(e&&e.formDataCtor||FormData);r!==void 0&&u.append("auth_config",r),d["Content-Type"]="multipart/form-data",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let h=i&&i.headers?i.headers:{};return c.headers={...d,...h,...o.headers},c.data=u,{url:pe(n),options:c}}}},Rs=function(e){const t=ui(e);return{async getAppAuthConfig(r){const o=await t.getAppAuthConfig(r),a=e?.serverIndex??0,n=ue["ApplicationConfigurationApi.getAppAuthConfig"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async updateAppAuthConfig(r,o,a){const n=await t.updateAppAuthConfig(r,o,a),i=e?.serverIndex??0,c=ue["ApplicationConfigurationApi.updateAppAuthConfig"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class hi extends Me{getAppAuthConfig(t){return Rs(this.configuration).getAppAuthConfig(t).then(r=>r(this.axios,this.basePath))}updateAppAuthConfig(t,r,o){return Rs(this.configuration).updateAppAuthConfig(t,r,o).then(a=>a(this.axios,this.basePath))}}const fi=function(e){return{loginUser:async(t,r,o={})=>{se("loginUser","xCSRFToken",t),se("loginUser","loginUserRequest",r);const a="/login/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},logoutUser:async(t,r={})=>{se("logoutUser","xCSRFToken",t);const o="/logout/",a=new URL(o,he);let n;e&&(n=e.baseOptions);const i={method:"DELETE",...n,...r},c={},d={};t!=null&&(c["X-CSRFToken"]=String(t)),fe(a,d);let l=n&&n.headers?n.headers:{};return i.headers={...c,...l,...r.headers},{url:pe(a),options:i}}}},eo=function(e){const t=fi(e);return{async loginUser(r,o,a){const n=await t.loginUser(r,o,a),i=e?.serverIndex??0,c=ue["AuthenticationApi.loginUser"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async logoutUser(r,o){const a=await t.logoutUser(r,o),n=e?.serverIndex??0,i=ue["AuthenticationApi.logoutUser"]?.[n]?.url;return(c,d)=>ge(a,te,ce,e)(c,i||d)}}};class pi extends Me{loginUser(t,r,o){return eo(this.configuration).loginUser(t,r,o).then(a=>a(this.axios,this.basePath))}logoutUser(t,r){return eo(this.configuration).logoutUser(t,r).then(o=>o(this.axios,this.basePath))}}const gi=function(e){return{requestLoginOTP:async(t,r,o={})=>{se("requestLoginOTP","xCSRFToken",t),se("requestLoginOTP","loginOTPRequest",r);const a="/login/code/request/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},verifyLoginOTP:async(t,r,o={})=>{se("verifyLoginOTP","xCSRFToken",t),se("verifyLoginOTP","loginOTPVerifyRequest",r);const a="/login/code/confirm/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},to=function(e){const t=gi(e);return{async requestLoginOTP(r,o,a){const n=await t.requestLoginOTP(r,o,a),i=e?.serverIndex??0,c=ue["LoginWithOTPApi.requestLoginOTP"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async verifyLoginOTP(r,o,a){const n=await t.verifyLoginOTP(r,o,a),i=e?.serverIndex??0,c=ue["LoginWithOTPApi.verifyLoginOTP"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class mi extends Me{requestLoginOTP(t,r,o){return to(this.configuration).requestLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}verifyLoginOTP(t,r,o){return to(this.configuration).verifyLoginOTP(t,r,o).then(a=>a(this.axios,this.basePath))}}const wi=function(e){return{getMfaCode:async(t={})=>{const r="/mfa/getcode/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},verifyMfaCode:async(t,r,o={})=>{se("verifyMfaCode","xCSRFToken",t),se("verifyMfaCode","mfaVerifyRequest",r);const a="/mfa/verify/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},ro=function(e){const t=wi(e);return{async getMfaCode(r){const o=await t.getMfaCode(r),a=e?.serverIndex??0,n=ue["MultiFactorAuthenticationApi.getMfaCode"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async verifyMfaCode(r,o,a){const n=await t.verifyMfaCode(r,o,a),i=e?.serverIndex??0,c=ue["MultiFactorAuthenticationApi.verifyMfaCode"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class yi extends Me{getMfaCode(t){return ro(this.configuration).getMfaCode(t).then(r=>r(this.axios,this.basePath))}verifyMfaCode(t,r,o){return ro(this.configuration).verifyMfaCode(t,r,o).then(a=>a(this.axios,this.basePath))}}const bi=function(e){return{oauthCallback:async(t,r,o,a,n,i,c,d,l={})=>{se("oauthCallback","provider",t),se("oauthCallback","state",r),se("oauthCallback","code",o),se("oauthCallback","scope",a),se("oauthCallback","xCSRFToken",n);const u="/oauth/{provider}/callback/".replace("{provider}",encodeURIComponent(String(t))),h=new URL(u,he);let m;e&&(m=e.baseOptions);const w={method:"POST",...m,...l},f={},x={};r!==void 0&&(x.state=r),o!==void 0&&(x.code=o),a!==void 0&&(x.scope=a),i!==void 0&&(x.authuser=i),c!==void 0&&(x.hd=c),d!==void 0&&(x.prompt=d),n!=null&&(f["X-CSRFToken"]=String(n)),fe(h,x);let y=m&&m.headers?m.headers:{};return w.headers={...f,...y,...l.headers},{url:pe(h),options:w}},oauthRedirect:async(t,r,o,a,n={})=>{se("oauthRedirect","xCsrftoken",t),se("oauthRedirect","provider",r),se("oauthRedirect","process",o),se("oauthRedirect","callbackUrl",a);const i="/oauth/redirect/",c=new URL(i,he);let d;e&&(d=e.baseOptions);const l={method:"POST",...d,...n},u={},h={},m=new URLSearchParams;r!==void 0&&m.set("provider",r),o!==void 0&&m.set("process",o),a!==void 0&&m.set("callback_url",a),u["Content-Type"]="application/x-www-form-urlencoded",t!=null&&(u["x-csrftoken"]=String(t)),fe(c,h);let w=d&&d.headers?d.headers:{};return l.headers={...u,...w,...n.headers},l.data=m.toString(),{url:pe(c),options:l}}}},so=function(e){const t=bi(e);return{async oauthCallback(r,o,a,n,i,c,d,l,u){const h=await t.oauthCallback(r,o,a,n,i,c,d,l,u),m=e?.serverIndex??0,w=ue["OAuthApi.oauthCallback"]?.[m]?.url;return(f,x)=>ge(h,te,ce,e)(f,w||x)},async oauthRedirect(r,o,a,n,i){const c=await t.oauthRedirect(r,o,a,n,i),d=e?.serverIndex??0,l=ue["OAuthApi.oauthRedirect"]?.[d]?.url;return(u,h)=>ge(c,te,ce,e)(u,l||h)}}};class Ci extends Me{oauthCallback(t,r,o,a,n,i,c,d,l){return so(this.configuration).oauthCallback(t,r,o,a,n,i,c,d,l).then(u=>u(this.axios,this.basePath))}oauthRedirect(t,r,o,a,n){return so(this.configuration).oauthRedirect(t,r,o,a,n).then(i=>i(this.axios,this.basePath))}}const vi=function(e){return{changePassword:async(t,r,o={})=>{se("changePassword","xCSRFToken",t),se("changePassword","passwordChangeRequest",r);const a="/password/change/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"PUT",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}},setPassword:async(t,r,o={})=>{se("setPassword","xCSRFToken",t),se("setPassword","passwordSetRequest",r);const a="/password/set/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};d["Content-Type"]="application/json",t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},c.data=Qe(r,c,e),{url:pe(n),options:c}}}},oo=function(e){const t=vi(e);return{async changePassword(r,o,a){const n=await t.changePassword(r,o,a),i=e?.serverIndex??0,c=ue["PasswordManagementApi.changePassword"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async setPassword(r,o,a){const n=await t.setPassword(r,o,a),i=e?.serverIndex??0,c=ue["PasswordManagementApi.setPassword"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class xi extends Me{changePassword(t,r,o){return oo(this.configuration).changePassword(t,r,o).then(a=>a(this.axios,this.basePath))}setPassword(t,r,o){return oo(this.configuration).setPassword(t,r,o).then(a=>a(this.axios,this.basePath))}}const Pi=function(e){return{setRole:async(t,r,o={})=>{se("setRole","xCSRFToken",t),se("setRole","role",r);const a="/role/set/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:pe(n),options:c}},switchRole:async(t,r,o={})=>{se("switchRole","xCSRFToken",t),se("switchRole","role",r);const a="/role/switch/",n=new URL(a,he);let i;e&&(i=e.baseOptions);const c={method:"POST",...i,...o},d={},l={};r!==void 0&&(l.role=r),t!=null&&(d["X-CSRFToken"]=String(t)),fe(n,l);let u=i&&i.headers?i.headers:{};return c.headers={...d,...u,...o.headers},{url:pe(n),options:c}}}},ao=function(e){const t=Pi(e);return{async setRole(r,o,a){const n=await t.setRole(r,o,a),i=e?.serverIndex??0,c=ue["RoleManagementApi.setRole"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)},async switchRole(r,o,a){const n=await t.switchRole(r,o,a),i=e?.serverIndex??0,c=ue["RoleManagementApi.switchRole"]?.[i]?.url;return(d,l)=>ge(n,te,ce,e)(d,c||l)}}};class Si extends Me{setRole(t,r,o){return ao(this.configuration).setRole(t,r,o).then(a=>a(this.axios,this.basePath))}switchRole(t,r,o){return ao(this.configuration).switchRole(t,r,o).then(a=>a(this.axios,this.basePath))}}const ki=function(e){return{getUserProfile:async(t={})=>{const r="/profile/",o=new URL(r,he);let a;e&&(a=e.baseOptions);const n={method:"GET",...a,...t},i={};fe(o,{});let d=a&&a.headers?a.headers:{};return n.headers={...i,...d,...t.headers},{url:pe(o),options:n}},updateUserProfile:async(t,r,o,a,n,i={})=>{se("updateUserProfile","xCSRFToken",t);const c="/profile/",d=new URL(c,he);let l;e&&(l=e.baseOptions);const u={method:"PUT",...l,...i},h={},m={},w=new(e&&e.formDataCtor||FormData);r!==void 0&&w.append("name",r),o!==void 0&&w.append("mobile",o),a!==void 0&&w.append("auth_config",a),n!==void 0&&w.append("profile_pic",n),h["Content-Type"]="multipart/form-data",t!=null&&(h["X-CSRFToken"]=String(t)),fe(d,m);let f=l&&l.headers?l.headers:{};return u.headers={...h,...f,...i.headers},u.data=w,{url:pe(d),options:u}}}},no=function(e){const t=ki(e);return{async getUserProfile(r){const o=await t.getUserProfile(r),a=e?.serverIndex??0,n=ue["UserProfileApi.getUserProfile"]?.[a]?.url;return(i,c)=>ge(o,te,ce,e)(i,n||c)},async updateUserProfile(r,o,a,n,i,c){const d=await t.updateUserProfile(r,o,a,n,i,c),l=e?.serverIndex??0,u=ue["UserProfileApi.updateUserProfile"]?.[l]?.url;return(h,m)=>ge(d,te,ce,e)(h,u||m)}}};class io extends Me{getUserProfile(t){return no(this.configuration).getUserProfile(t).then(r=>r(this.axios,this.basePath))}updateUserProfile(t,r,o,a,n,i){return no(this.configuration).updateUserProfile(t,r,o,a,n,i).then(c=>c(this.axios,this.basePath))}}class lo{constructor(t={}){this.apiKey=t.apiKey,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.serverIndex=t.serverIndex,this.baseOptions={...t.baseOptions,headers:{...t.baseOptions?.headers}},this.formDataCtor=t.formDataCtor}isJsonMime(t){const r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}}const Ue=new lo({basePath:"/api/v1/appauth",baseOptions:{withCredentials:!0}}),co=new pi(Ue),Ai=new hi(Ue),uo=new mi(Ue),ho=new yi(Ue),fo=new xi(Ue),_i=new Si(Ue),po=new Ci(Ue);new io(Ue);const Te=()=>{const e=document.cookie.match(/csrftoken=([^;]+)/);if(e)return decodeURIComponent(e[1]);const t=document.querySelector('meta[name="csrf-token"]');if(t)return t.getAttribute("content");const r=document.cookie.match(/csrf_token=([^;]+)/);return r?decodeURIComponent(r[1]):(console.warn("CSRF token not found. OTP requests may fail."),"")};let re=null,We=null;const W={async getAuthConfig(){return re||We||(We=(async()=>{try{const t=(await Ai.getAppAuthConfig()).data;return t?.response?.auth_config?re=t.response.auth_config:t?.auth_config?re=t.auth_config:re=t,console.log("Auth configuration loaded:",re),re}catch(e){throw console.error("Failed to fetch auth config:",e),We=null,e}finally{We=null}})(),We)},getConfig(){return re},isPasswordLoginEnabled(){return re?.login_methods?.password?.enabled||!1},isOTPLoginEnabled(){return re?.login_methods?.otp?.enabled||!1},isSSOEnabled(){return re?.login_methods?.sso?.enabled||!1},isOIDCEnabled(){return re?.login_methods?.oidc?.enabled||!1},getOIDCProviders(){return console.log("OIDC providers:",re?.login_methods?.oidc?.providers),re?.login_methods?.oidc?.providers||[]},getAllowedUsernames(){return(re?.login_methods?.password?.allowed_usernames||re?.login_methods?.allowed_usernames||["email"]).map(t=>t==="phone"?"mobile":t)},isForgotPasswordEnabled(){return re?.password_policy?.reset?.enabled||!1},getPasswordResetLinkExpiry(){return re?.login_methods?.password?.password_reset_link_expiry_hours||24},getSessionPolicy(){return re?.session_policy||{}},isRememberMeEnabled(){return re?.session_policy?.remember_me_enabled!==!1},getRememberMeDurationDays(){return re?.session_policy?.remember_me_duration_days||30},getPasswordPolicy(){return re?.password_policy||{}},getPasswordResetMethods(){return re?.password_policy?.reset?.method||[]},isPasswordResetEnabled(){return re?.password_policy?.reset?.enabled||!1},getPasswordResetExpiry(){return re?.password_policy?.reset?.expiry_hours||24},isTwoFactorRequired(){return re?.two_factor_auth?.required||!1},getTwoFactorMethods(){return re?.two_factor_auth?.allowedMethods||[]},getTwoFactorHooks(){return{email:re?.two_factor_auth?.email_hook,sms:re?.two_factor_auth?.sms_hook}},async login(e,t={}){try{re||await this.getAuthConfig();const r=Te()||"";console.log("Login csrfToken:",r);const o=e,a=await co.loginUser(r,o);console.log("Login response:",a.data);const n=a.data;if(n?.success&&n?.response){const i=n.response;return i.status===401&&i.data?.next_step?(console.log("Multi-step authentication required:",i),i):i.data||i}return a.data}catch(r){if(console.error("Login error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required:",o),o}throw r}},async logout(e={}){try{const t=Te()||"";await co.logoutUser(t)}catch(t){console.error("Logout error:",t)}},async getCurrentUser(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Oo});if(!e())throw new Error("Not authenticated - no valid session cookie");return{id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}}catch(e){throw console.error("Get current user failed:",e),new Error("Authentication verification failed")}},async verifyToken(e,t={}){return this.getCurrentUser()},async forgotPassword(e){try{return{message:"Reset email sent"}}catch(t){throw t}},async resetPassword(e){try{return{message:"Password reset successful"}}catch(t){throw t}},async fetchLoginMethods(){try{return(await this.getAuthConfig())?.login_methods||{}}catch(e){throw e}},async requestOTP(e){try{const t=Te()||"";console.log("Requesting OTP for:",e,"CSRF token:",t?"present":"missing");const o=e.includes("@")?{email:e}:{phone:e};console.log("OTP request payload:",o);const a=await uo.requestLoginOTP(t,o),n=a.data;return n?.success&&n?.response?n.response.data||n.response:a.data}catch(t){if(console.error("Request OTP error:",t),t.response?.data){const r=t.response.data;if(r?.response?.data?.message)throw new Error(r.response.data.message);if(r?.message)throw new Error(r.message)}throw t}},async verifyOTP(e,t){try{const r=Te()||"";console.log("Verifying OTP for:",e,"code:",t,"CSRF token:",r?"present":"missing");const o={code:t};console.log("OTP verify payload:",o);const a=await uo.verifyLoginOTP(r,o),n=a.data;return n?.success&&n?.response?n.response.status===401&&n.response.data?.next_step?(console.log("Multi-step authentication required after OTP verification:",n),n.response):n.response.data||n.response:a.data}catch(r){if(console.error("Verify OTP error:",r),r.response?.status===401&&r.response?.data){const o=r.response.data;if(o?.success&&o?.response){const a=o.response;if(a.status===401&&a.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",a),a}if(o?.response?.data?.next_step||o?.data?.next_step)return console.log("Multi-step authentication required after OTP verification:",o),o}if(r.response?.data){const o=r.response.data;if(o?.response?.data?.message)throw new Error(o.response.data.message);if(o?.message)throw new Error(o.message)}throw r}},async selectRole(e){try{const t=Te()||"",r=await _i.setRole(t,e),o=r.data;if(o?.success&&o?.response){const a=o.response;return a.status===401&&a.data?.next_step?(console.log("Multi-step authentication after role selection:",a),a):a.data||a}return r.data}catch(t){if(console.error("Select role error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.success&&r?.response){const o=r.response;if(o.status===401&&o.data?.next_step)return console.log("Multi-step authentication after role selection:",o),o}if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after role selection:",r),r}throw t}},async sendTwoFactorCode(){try{return(await ho.getMfaCode()).data}catch(e){throw console.error("Send 2FA code error:",e),e}},async verifyTwoFactorCode(e){try{const t=Te()||"";return(await ho.verifyMfaCode(t,{code:e})).data}catch(t){throw console.error("Verify 2FA code error:",t),t}},async changePassword(e,t){try{const r=Te()||"";return(await fo.changePassword(r,{current_password:e,new_password:t})).data}catch(r){throw console.error("Change password error:",r),r}},async setPassword(e){try{const t=Te()||"",r=await fo.setPassword(t,{new_password:e});return console.log("Set password response:",r.data),r.data}catch(t){if(console.error("Set password error:",t),t.response?.status===401&&t.response?.data){const r=t.response.data;if(r?.response?.data?.next_step||r?.data?.next_step)return console.log("Multi-step authentication after password set:",r),r}throw t}},async processOAuthCallback(e,t,r,o,a,n,i,c){try{const d=Te()||"",l=await po.oauthCallback(e,t,r,o,d,a,n,i,c),u=l.data;if(u?.success&&u?.response){const h=u.response;return h.status===401&&h.data?.next_step?(console.log("Multi-step authentication required:",h),h):h.data||h}return l.data}catch(d){if(d.response?.status===401&&d.response?.data){const l=d.response.data;if(l?.success&&l?.response){const u=l.response;if(u.status===401&&u.data?.next_step)return console.log("Multi-step authentication required:",u),u}if(l?.response?.data?.next_step||l?.data?.next_step)return console.log("Multi-step authentication required:",l),l}throw d}},clearConfig(){re=null,We=null},async isAuthenticated(){try{const{isAuthenticatedViaCookie:e}=await Promise.resolve().then(function(){return Oo});return e()}catch(e){return console.error("Authentication check failed:",e),!1}},validatePassword(e){const t=this.getPasswordPolicy(),r=[];return t.min_length&&e.length<t.min_length&&r.push(`Password must be at least ${t.min_length} characters long`),t.max_length&&e.length>t.max_length&&r.push(`Password must be at most ${t.max_length} characters long`),t.require_numbers&&!/\d/.test(e)&&r.push("Password must contain at least one number"),t.require_lowercase&&!/[a-z]/.test(e)&&r.push("Password must contain at least one lowercase letter"),t.require_uppercase&&!/[A-Z]/.test(e)&&r.push("Password must contain at least one uppercase letter"),t.require_special_chars&&!/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r.push("Password must contain at least one special character"),{valid:r.length===0,errors:r}},async oauthRedirect(e,t){try{const r=Te()||"";return(await po.oauthRedirectPost(r,e,"login",t)).data}catch(r){throw r}},async getUserProfile(){try{const e=new lo({basePath:"/api/v1",baseOptions:{withCredentials:!0}});return(await new io(e).getUserProfile()).data}catch(e){throw console.error("Get user profile error:",e),e}}},go=e=>{let t;const r=new Set,o=(l,u)=>{const h=typeof l=="function"?l(t):l;if(!Object.is(h,t)){const m=t;t=u??(typeof h!="object"||h===null)?h:Object.assign({},t,h),r.forEach(w=>w(t,m))}},a=()=>t,c={setState:o,getState:a,getInitialState:()=>d,subscribe:l=>(r.add(l),()=>r.delete(l))},d=t=e(o,a,c);return c},Li=(e=>e?go(e):go),Ti=e=>e;function Ni(e,t=Ti){const r=g.useSyncExternalStore(e.subscribe,g.useCallback(()=>t(e.getState()),[e,t]),g.useCallback(()=>t(e.getInitialState()),[e,t]));return g.useDebugValue(r),r}const mo=e=>{const t=Li(e),r=o=>Ni(t,o);return Object.assign(r,t),r},Et=(e=>e?mo(e):mo)(e=>({basePath:"/login",setBasePath:t=>e({basePath:t})})),wo=g.createContext(void 0),Be=()=>{const e=g.useContext(wo);if(!e)throw new Error("useAuthConfig must be used within AuthConfigProvider");return e},Ei=({children:e,authConfig:t={}})=>{const r={theme:{background:{color:"#f0f2f5"},primaryColor:"#1890ff",secondaryColor:"#6d7280",borderRadius:"8px"},card:{backgroundColor:"#ffffff",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:"400px",padding:"40px"},logo:{position:"center",alt:"Logo"},login:{title:"Welcome Back",subtitle:"Please sign in to your account",submitButtonText:"Sign in",rememberMeText:"Remember me",forgotPasswordText:"Forgot password?",otpButtonText:"Sign in with OTP",showRememberMe:!0,enableTabSwitching:!0,defaultTab:"email",formLabels:{email:"Email",mobile:"Mobile",password:"Password"},formPlaceholders:{email:"Email address",mobile:"Mobile number (+919876543210)",password:"Password"},tabLabels:{email:"Email",mobile:"Mobile"}},roleSelection:{title:"Choose Your Role",subtitle:"Select the role that best matches your current responsibilities",continueButtonText:"Continue as {roleName}",recommendedBadgeText:"Recommended",emptyStateMessage:"No roles available",cardLayout:"grid",gridColumns:3,roleCardStyling:{backgroundColor:"#ffffff",selectedColor:"#1890ff",hoverColor:"#f0f2f5",borderRadius:"8px"}},twoFactor:{title:"Two-Factor Authentication",subtitle:"Please enter your verification code",instructionText:"Enter the verification code sent to your device",codeInputLabel:"Verification Code",submitButtonText:"Verify",resendButtonText:"Resend Code",backButtonText:"Back",resendCountdown:60,codeLength:6,methodLabels:{email:"Email",sms:"SMS",mobile:"Mobile"}},resetPassword:{forgotPassword:{title:"Forgot Password",subtitle:"Enter your email to reset your password",instructionText:"We will send you a reset link",emailLabel:"Email",emailPlaceholder:"Enter your email address",submitButtonText:"Send Reset Link",backToLoginText:"Back to Login",successMessage:"Reset email sent successfully",errorMessage:"Failed to send reset email"},resetForm:{title:"Reset Password",subtitle:"Enter your new password",passwordLabel:"New Password",confirmPasswordLabel:"Confirm Password",passwordPlaceholder:"Enter new password",confirmPasswordPlaceholder:"Confirm new password",submitButtonText:"Reset Password",successMessage:"Password reset successfully",showPasswordRequirements:!0,passwordRequirementsText:"Password requirements:"}},providers:{buttonStyle:"outline",showProviderIcons:!0,separatorText:"OR"},messages:{validation:{required:"This field is required",invalidEmail:"Please enter a valid email",invalidMobile:"Please enter a valid mobile number",passwordTooShort:"Password is too short",passwordsDoNotMatch:"Passwords do not match"},errors:{loginFailed:"Login failed. Please try again.",networkError:"Network error. Please check your connection.",invalidOTP:"Invalid verification code",expiredToken:"Token has expired"},success:{loginSuccess:"Login successful!",otpSent:"Verification code sent!",passwordReset:"Password reset successfully!",roleSelected:"Role selected successfully!"}}},o=(i,c)=>{const d={...i};for(const l in c)c[l]!==null&&typeof c[l]=="object"&&!Array.isArray(c[l])&&!g.isValidElement(c[l])?d[l]=o(i[l]||{},c[l]):d[l]=c[l];return d},a=o(r,t),n={authConfig:a,getLoginConfig:()=>a.login||{},getRoleSelectionConfig:()=>a.roleSelection||{},getTwoFactorConfig:()=>a.twoFactor||{},getResetPasswordConfig:()=>a.resetPassword||{},getThemeConfig:()=>a.theme||{},getCardConfig:()=>a.card||{},getLogoConfig:()=>a.logo||{},getProvidersConfig:()=>a.providers||{},getMessagesConfig:()=>a.messages||{},getCustomComponents:()=>a.customComponents||{}};return s.jsx(wo.Provider,{value:n,children:e})},Fi=e=>{const t=e?.theme||{},r=e?.card||{};let o="";return t.primaryColor&&(o+=`--auth-primary-color: ${t.primaryColor}; `),t.secondaryColor&&(o+=`--auth-secondary-color: ${t.secondaryColor}; `),t.fontFamily&&(o+=`--auth-font-family: ${t.fontFamily}; `),t.borderRadius&&(o+=`--auth-border-radius: ${t.borderRadius}; `),t.textColor&&(o+=`--auth-text-color: ${t.textColor}; `),t.secondaryTextColor&&(o+=`--auth-secondary-text-color: ${t.secondaryTextColor}; `),t.mutedTextColor&&(o+=`--auth-muted-text-color: ${t.mutedTextColor}; `),t.linkColor&&(o+=`--auth-link-color: ${t.linkColor}; `),t.linkHoverColor&&(o+=`--auth-link-hover-color: ${t.linkHoverColor}; `),t.background?.color&&(o+=`--auth-bg-color: ${t.background.color}; `),t.background?.gradient&&(o+=`--auth-bg-gradient: ${t.background.gradient}; `),t.background?.image&&(o+=`--auth-bg-image: url(${t.background.image}); `),r.backgroundColor&&(o+=`--auth-card-bg: ${r.backgroundColor}; `),r.borderRadius&&(o+=`--auth-card-border-radius: ${r.borderRadius}; `),r.boxShadow&&(o+=`--auth-card-shadow: ${r.boxShadow}; `),r.maxWidth&&(o+=`--auth-card-max-width: ${r.maxWidth}; `),r.padding&&(o+=`--auth-card-padding: ${r.padding}; `),r.border&&(o+=`--auth-card-border: ${r.border}; `),o},Oi=e=>{const t=Fi(e);if(e?.debug&&(console.log("🎨 Applying auth theme:",e),console.log("🎨 Generated CSS variables:",t)),!t){e?.debug&&console.log("🎨 No CSS variables generated from auth config");return}let r=document.getElementById("auth-theme-variables");r||(r=document.createElement("style"),r.id="auth-theme-variables",document.head.appendChild(r));const o=`
115
+ :root { ${t} }
116
+
117
+ /* Auth component text styling using CSS variables */
118
+ .auth-remember-me,
119
+ .auth-remember-me .ant-checkbox-wrapper,
120
+ .auth-remember-me .ant-checkbox + span,
121
+ .auth-remember-me label,
122
+ .auth-remember-me span {
123
+ color: var(--auth-secondary-text-color, #cbd5e1) !important;
124
+ }
125
+
126
+ /* Auth text color classes for easy application */
127
+ .auth-text {
128
+ color: var(--auth-text-color, #f1f5f9) !important;
129
+ }
130
+
131
+ .auth-secondary-text {
132
+ color: var(--auth-secondary-text-color, #cbd5e1) !important;
133
+ }
134
+
135
+ .auth-link {
136
+ color: var(--auth-link-color, #60a5fa) !important;
137
+ }
138
+
139
+ .auth-link:hover {
140
+ color: var(--auth-link-hover-color, #3b82f6) !important;
141
+ }
142
+ `;r.innerHTML=o,e?.debug&&console.log("🎨 Applied CSS to DOM:",o)},Mi=()=>{const e=document.getElementById("auth-theme-variables");e&&e.remove()},yo=e=>{const t=e?.theme?.background;if(!t)return{};const r={};return t.image?(r.backgroundImage=`url(${t.image})`,r.backgroundSize="cover",r.backgroundPosition="center",r.backgroundRepeat="no-repeat"):t.gradient?r.background=t.gradient:t.color&&(r.backgroundColor=t.color),e?.debug&&console.log("🎨 Generated background style:",r),r},qe=e=>{const t=e?.card;if(!t)return{};const r={};return t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.borderRadius&&(r.borderRadius=t.borderRadius),t.boxShadow&&(r.boxShadow=t.boxShadow),t.maxWidth&&(r.maxWidth=t.maxWidth),t.padding&&(r.padding=t.padding),t.border&&(r.border=t.border),e?.debug&&console.log("🎨 Generated card style:",r),r},nr=e=>{const t=e?.logo;if(!t)return{};const r={};return t.width&&(r.width=t.width),t.height&&(r.height=t.height),t.style&&Object.assign(r,t.style),r},Ui=e=>e?.logo?.position||"center",ir=e=>{const t=Ui(e),r=e?.logo;let o="flex items-center mb-6";const a={};switch(t){case"left":o+=" justify-start";break;case"right":o+=" justify-end";break;case"center":default:o+=" justify-center";break}return r?.className&&(o+=` ${r.className}`),e?.debug&&console.log("🎨 Generated logo container style:",{className:o,style:a,position:t}),{className:o,style:a}},lr=e=>{const t=e?.theme;if(!t)return{};const r={};return t.textColor&&(r.color=t.textColor),t.fontFamily&&(r.fontFamily=t.fontFamily),e?.debug&&console.log("🎨 Generated text style:",r),r},cr=e=>{const t=e?.theme;if(!t)return{};const r={};return t.secondaryTextColor&&(r.color=t.secondaryTextColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},Bi=e=>{const t=e?.theme;if(!t)return{};const r={};return t.linkColor&&(r.color=t.linkColor),t.fontFamily&&(r.fontFamily=t.fontFamily),r},qi=({onSubmit:e})=>{const[t,r]=g.useState(!1),[o,a]=g.useState(!1),[n,i]=g.useState(0),[c,d]=g.useState(["email"]),[l,u]=g.useState("email"),{basePath:h}=Et(),{authConfig:m,getResetPasswordConfig:w,getMessagesConfig:f}=Be(),x=w(),y=f(),P=qe(m);g.useEffect(()=>{(async()=>{try{await W.getAuthConfig();const v=W.getPasswordResetMethods();v&&v.length>0&&(d(v),u(v[0]))}catch(v){console.error("Failed to load reset configuration:",v)}})()},[]);const A=async S=>{r(!0);try{if(e){const v={method:l,email:l==="email"?S.contact:void 0,phone:l==="sms"?S.contact:void 0};await e(v)}a(!0),i(v=>v+1)}catch(v){const C=l==="email"?"email":"SMS",F=y?.errors?.networkError||v.message||`Failed to send reset ${C}. Please try again.`;p.toast.error(F)}finally{r(!1)}},B=()=>l==="email"?x?.forgotPassword?.emailPlaceholder||"Email address":"Phone number",N=()=>l==="email"?[{required:!0,message:y?.validation?.required||"Please input your email!"},{type:"email",message:y?.validation?.invalidEmail||"Please enter a valid email address!"}]:[{required:!0,message:y?.validation?.required||"Please input your phone number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:y?.validation?.invalidMobile||"Please enter a valid phone number!"}],H=()=>{const S=l==="email"?"Email":"SMS",v=l==="email"?"email":"phone";return{title:x?.forgotPassword?.successMessage||`${S} Sent!`,subTitle:`Please check your ${v} for password reset instructions.`}};if(o){const S=H();return s.jsx(p.Result,{status:"success",title:S.title,subTitle:S.subTitle,extra:[s.jsx(G.Link,{to:h,children:s.jsx(p.Button,{variant:"primary",children:x?.forgotPassword?.backToLoginText||"Back to Login"})},"login")]})}return s.jsxs("div",{className:"w-full max-w-md mx-auto",style:P,children:[s.jsx(G.Link,{to:h,className:"inline-block mb-6",children:s.jsx(p.Button,{variant:"link",size:"link",icon:s.jsx(Wt,{size:16}),children:x?.forgotPassword?.backToLoginText||"Back to Login"})}),s.jsx("h2",{className:"text-2xl font-semibold mb-3",style:lr(m),children:x?.forgotPassword?.title||"Forgot Password"}),s.jsx("p",{className:"text-sm mb-6",style:cr(m),children:x?.forgotPassword?.subtitle||x?.forgotPassword?.instructionText||`Enter your ${l==="email"?"email address":"phone number"} and we'll send you instructions to reset your password.`}),s.jsxs(p.Form,{name:"forgot-password",className:"space-y-4",onFinish:A,layout:"vertical",children:[c.length>1&&s.jsx(p.FormItem,{label:"Reset method",children:s.jsxs(p.Select,{value:l,onChange:S=>{u(S),i(v=>v+1)},children:["options=",c.map(S=>({value:S,label:s.jsxs(p.Space,{children:[S==="email"?s.jsx(Ct,{size:16}):s.jsx(Ia,{size:16}),S==="email"?"Email":"SMS"]})}))]})}),s.jsx(p.FormItem,{name:"contact",label:l==="email"?x?.forgotPassword?.emailLabel||"Email":"Phone",rules:N(),children:s.jsx(p.Input,{placeholder:B(),autoComplete:l==="email"?"email":"tel"})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:t,fullWidth:!0,children:x?.forgotPassword?.submitButtonText||`Send Reset ${l==="email"?"Email":"SMS"}`})})]},n)]})},Ii=({onSubmit:e,token:t})=>{const[r,o]=g.useState(!1),[a,n]=g.useState(!1),[i,c]=g.useState(0),{basePath:d}=Et(),{authConfig:l,getResetPasswordConfig:u,getMessagesConfig:h}=Be(),m=u(),w=h(),f=qe(l),x=(P,A)=>{if(!A){const N=w?.validation?.required||"Please input your new password!";return Promise.reject(new Error(N))}const B=W.validatePassword(A);if(!B.valid){const N=w?.validation?.passwordTooShort||B.errors.join(", ");return Promise.reject(new Error(N))}return Promise.resolve()},y=async P=>{o(!0);try{e&&await e({...P,token:t}),n(!0),c(A=>A+1)}catch(A){const B=w?.errors?.networkError||A.message||"Failed to reset password. Please try again.";p.toast.error(B)}finally{o(!1)}};return a?s.jsx(p.Result,{status:"success",title:m?.resetForm?.successMessage||"Password Reset Successful!",subTitle:"Your password has been successfully reset. You can now login with your new password.",extra:[s.jsx(G.Link,{to:d,children:s.jsx(p.Button,{variant:"primary",children:"Go to Login"})},"login")]}):s.jsxs("div",{className:"w-full max-w-md mx-auto",style:f,children:[s.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-3",children:m?.resetForm?.title||"Reset Password"}),s.jsx("p",{className:"text-sm text-gray-600 mb-6",children:m?.resetForm?.subtitle||"Please enter your new password below."}),s.jsxs(p.Form,{name:"reset-password",className:"space-y-4",onFinish:y,layout:"vertical",children:[s.jsx(p.FormItem,{name:"password",label:m?.resetForm?.passwordLabel||"New Password",rules:[{validator:x}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16,className:"text-gray-400"}),placeholder:m?.resetForm?.passwordPlaceholder||"New Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{name:"confirmPassword",label:m?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:w?.validation?.required||"Please confirm your password!"},({getFieldValue:P})=>({validator(A,B){if(!B||P("password")===B)return Promise.resolve();const N=w?.validation?.passwordsDoNotMatch||"The two passwords do not match!";return Promise.reject(new Error(N))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16,className:"text-gray-400"}),placeholder:m?.resetForm?.confirmPasswordPlaceholder||"Confirm Password",autoComplete:"new-password"})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:r,fullWidth:!0,children:m?.resetForm?.submitButtonText||"Reset Password"})})]},i)]})},$i=({onSuccess:e,onError:t,apiConfig:r={},redirectPath:o="/",title:a="Completing sign in...",errorTitle:n="Authentication Error",logo:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m})=>{const[w,f]=g.useState(!0),[x,y]=g.useState(null),[P,A]=g.useState(!1),[B,N]=g.useState(null),[H,S]=g.useState("login"),[v,C]=g.useState({}),[F,D]=g.useState(["email"]),[k,U]=g.useState(""),I=g.useRef(!1),j=G.useLocation(),L=G.useNavigate(),{basePath:T,setAuthToken:M}=Et(),E=async _=>{console.log("Login success result:",_);let J=_,V=null;_?.status===401&&_?.data?(J=_.data,V=_.data?.next_step):(J=_?.response?.data||_?.data||_,V=J?.next_step);const K=_?.loginUser;(_?.token||J?.token)&&M(_.token||J.token);let ee=_?.user||J?.user||K||{};if((typeof ee!="object"||ee===null)&&(ee={}),K&&typeof K=="object"&&(ee={...ee,email:ee.email||K.email,username:ee.username||K.username,phone:ee.phone||K.phone,name:ee.name||K.display}),V&&V.is_pending)switch(V.id){case"role_selection":let ne=[];Array.isArray(V.metadata.roles)?ne=V.metadata.roles:typeof V.metadata.roles=="object"&&(ne=Object.entries(V.metadata.roles).map(([me,Ze])=>({id:me,name:Ze,is_default:!1}))),C({..._,roles:ne,user:ee,nextStep:V,loginUser:K}),S("roleSelection"),A(!0),f(!1);return;case"mfa_authenticate":M(_.token||J?.token),D(V.metadata?.methods||["email"]),S("twoFactor"),A(!0),f(!1);return;case"set_password":M(_.token||J?.token);const ie=V.metadata?.password_policy;U(V.metadata?.reason||"Password update required"),C({..._,passwordPolicy:ie,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"password_expiry":M(_.token||J?.token),U("Your password has expired"),C({..._,passwordPolicy:V.metadata?.password_policy,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"first_login":M(_.token||J?.token),U("Please set up your password for first login"),C({..._,passwordPolicy:V.metadata?.password_policy,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return;case"login_by_code":M(_.token||J?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),e&&e({..._,user:ee,requiresOTP:!0});return}if(_.requires2FA){M(_.token),D(_.twoFactorMethods||["email"]),C({..._,user:ee,loginUser:K}),S("twoFactor"),A(!0),f(!1);return}if(_.requiresPasswordReset){M(_.token),U(_.passwordResetReason||"Your password has expired"),C({..._,user:ee,loginUser:K}),S("passwordReset"),A(!0),f(!1);return}};g.useEffect(()=>{I.current||Z()},[]);const Z=async()=>{try{I.current=!0;const _=new URLSearchParams(j.search),J=new URLSearchParams(j.hash.slice(1)),V=_.get("error")||J.get("error"),K=_.get("error_description")||J.get("error_description");if(V)throw new Error(K||`Authentication failed: ${V}`);const ee=_.get("code"),ne=_.get("state"),ie=_.get("scope")||"",me=_.get("authuser"),Ze=_.get("hd"),$e=_.get("prompt"),Ge=_.get("provider")||ne?.split(":")[0];if(!ee||!Ge)throw new Error("Missing required OAuth parameters (code or provider)");const le=await W.processOAuthCallback(Ge,ne||"",ee,ie,me||void 0,Ze||void 0,$e||void 0);if(console.log("OAuth callback result:",le),await E(le),le?.status===401&&le?.data?.next_step){const Ee=le.data.next_step;if(Ee.is_pending){console.log("Additional authentication step required after OAuth callback:",Ee.id),f(!1),e?e(le):(N(le),A(!0));return}}f(!1),e?e(le):setTimeout(()=>{L(o,{replace:!0})},1e3)}catch(_){console.error("OAuth callback error:",_),y(_.message||"Authentication failed"),f(!1),t&&t(_)}},Q=()=>{L(T,{replace:!0})},z=async _=>{console.log("Authentication complete:",_),p.toast.success("Authentication complete!");try{let J="/dashboard";_?.response?.data?.redirect_url?J=_.response.data.redirect_url:_?.data?.redirect_url?J=_.data.redirect_url:_?.redirect_url&&(J=_.redirect_url),console.log("Redirecting to:",J),window.location.href=J}catch(J){console.error("Error handling auth completion:",J)}};return P?s.jsx(CompleteAuthFlow,{logo:i,apiConfig:r,initialAuthState:B||v,onAuthComplete:z,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m,redirectPath:o}):w?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsxs("div",{className:"text-center py-10 px-5",children:[s.jsx(p.Spin,{size:"large"}),s.jsx("h2",{className:"mt-6 mb-2 text-gray-800 text-xl font-medium",children:a}),s.jsx("p",{className:"text-gray-500 text-sm mb-0",children:"Please wait while we complete your authentication..."})]})})}):x?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:n,description:x,type:"error",showIcon:!0,action:s.jsx("a",{onClick:Q,children:"Return to login"})})})})}):s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100 p-5",children:s.jsx(p.Card,{className:"w-full max-w-md shadow-md",bordered:!1,children:s.jsx("div",{className:"text-center py-10 px-5",children:s.jsx(p.Alert,{message:"Authentication Successful",description:"You have been successfully authenticated. Redirecting...",type:"success",showIcon:!0})})})})},Vi=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),s.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),s.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),s.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),ji=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M11.4 24H0V12.6h11.4V24z",fill:"#f25022"}),s.jsx("path",{d:"M24 24H12.6V12.6H24V24z",fill:"#00a4ef"}),s.jsx("path",{d:"M11.4 11.4H0V0h11.4v11.4z",fill:"#7fba00"}),s.jsx("path",{d:"M24 11.4H12.6V0H24v11.4z",fill:"#ffb900"})]}),Di=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),Hi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#0077b5",children:s.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),zi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#1877f2",children:s.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Wi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Zi=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Gi=()=>s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52z",fill:"#e01e5a"}),s.jsx("path",{d:"M6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z",fill:"#e01e5a"}),s.jsx("path",{d:"M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834z",fill:"#36c5f0"}),s.jsx("path",{d:"M8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z",fill:"#36c5f0"}),s.jsx("path",{d:"M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834z",fill:"#2eb67d"}),s.jsx("path",{d:"M17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z",fill:"#2eb67d"}),s.jsx("path",{d:"M15.165 18.956a2.527 2.527 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52z",fill:"#ecb22e"}),s.jsx("path",{d:"M15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",fill:"#ecb22e"})]}),Ki=e=>{const t=e?e.toLowerCase():"";return t.includes("google")?s.jsx(Vi,{}):t.includes("microsoft")||t.includes("azure")?s.jsx(ji,{}):t.includes("github")?s.jsx(Di,{}):t.includes("linkedin")?s.jsx(Hi,{}):t.includes("facebook")?s.jsx(zi,{}):t.includes("twitter")||t.includes("x.com")?s.jsx(Wi,{}):t.includes("apple")?s.jsx(Zi,{}):t.includes("slack")?s.jsx(Gi,{}):s.jsx(qa,{size:16})},bo=({provider:e,type:t="default"})=>{const r=async()=>{const a=await W.oauthRedirect(e.provider,window.location.href);console.log("redirect url:",a.response.redirect_url),a.success?window.location.href=a.response.redirect_url:console.error("Error authenticating:")},o=Ki(e.provider);return s.jsxs(p.Button,{className:`flex items-center justify-center gap-2 h-[42px] text-sm font-medium rounded-md transition-all duration-300 mb-2 last:mb-0 ${t==="oidc"?"bg-gray-100 border border-gray-200 text-gray-800 hover:bg-gray-200 hover:border-gray-300":t==="sso"?"bg-brand-500 border border-brand-500 text-white hover:bg-brand-600 hover:border-brand-600":"bg-white border border-gray-300 text-gray-800 hover:border-brand-500 hover:text-brand-500"}`,icon:o,block:!0,onClick:r,children:["Continue with ",e.provider]})},Co=({length:e=6,value:t="",onChange:r,disabled:o=!1})=>{const[a,n]=g.useState(new Array(e).fill("")),i=g.useRef([]);g.useEffect(()=>{if(t){const u=t.split("").slice(0,e),h=[...new Array(e).fill("")];u.forEach((m,w)=>{h[w]=m}),n(h)}},[t,e]);const c=(u,h)=>{const m=u.value;if(isNaN(m))return;const w=[...a];w[h]=m,n(w),r&&r(w.join("")),m&&h<e-1&&i.current[h+1].focus()},d=(u,h)=>{u.key==="Backspace"&&!a[h]&&h>0&&i.current[h-1].focus()},l=u=>{u.preventDefault();const m=u.clipboardData.getData("text/plain").slice(0,e).split(""),w=[...a];m.forEach((x,y)=>{!isNaN(x)&&y<e&&(w[y]=x)}),n(w),r&&r(w.join(""));const f=w.findIndex(x=>x==="");f!==-1?i.current[f].focus():i.current[e-1].focus()};return s.jsx(p.Space,{className:"flex justify-center gap-2",size:"small",children:a.map((u,h)=>s.jsx(p.Input,{ref:m=>i.current[h]=m,type:"text",inputMode:"numeric",maxLength:1,value:u,onChange:m=>c(m.target,h),onKeyDown:m=>d(m,h),onPaste:l,className:"!w-12 !h-12 text-center text-xl font-semibold rounded-lg transition-all duration-300 focus:border-brand-500 focus:shadow-[0_0_0_2px_rgba(106,138,18,0.2)] disabled:bg-gray-100 disabled:cursor-not-allowed",disabled:o},h))})},vo=g.createContext(null),Ye=()=>{const e=g.useContext(vo);if(!e)throw new Error("useAuthContext must be used within an AuthProvider");return e},Ji=({children:e,config:t={}})=>{const[r,o]=g.useState(null),[a,n]=g.useState(!0),[i,c]=g.useState(null),[d,l]=g.useState(null),[u,h]=g.useState(null),[m,w]=g.useState(null),f=g.useRef(!1);g.useEffect(()=>{f.current||(f.current=!0,x())},[]);const x=async()=>{try{const v=await W.getAuthConfig();w(v),await y()}catch(v){c(v.message),n(!1)}},y=async()=>{try{await W.isAuthenticated()?(o({id:1,username:"authenticated_user",email:"user@example.com",authenticated:!0}),c(null)):(o(null),c(null))}catch(v){console.error("Auth check failed:",v),o(null),c(null)}finally{n(!1)}},S={user:r,loading:a,error:i,login:async v=>{n(!0),c(null);try{const C=await W.login(v,t);let F=C,D=null;C?.status===401&&C?.data?(F=C.data,D=C.data?.next_step):(F=C?.response?.data||C?.data||C,D=F?.next_step);const k=C?.user||F?.user||{};if(k.email=k.email||v.email,k.username=k.username||v.username,k.phone=k.phone||v.phone,k.name=k.name||v.email||v.username||v.phone,l({user:k,token:C.token||F?.token,roles:C.roles,requires2FA:C.requires2FA,twoFactorMethods:C.twoFactorMethods,requiresPasswordReset:C.requiresPasswordReset,passwordResetReason:C.passwordResetReason}),D&&D.is_pending&&D.id==="role_selection")return{...C,user:k};if(C.roles&&C.roles.length>1)return h(C.roles),{requiresRoleSelection:!0,roles:C.roles,user:k,token:C.token};let U=C;return C.roles&&C.roles.length===1?U.user={...k,role:C.roles[0]}:U.user=k,C.requires2FA?{...U,requires2FA:!0,twoFactorMethods:C.twoFactorMethods||["email"]}:C.requiresPasswordReset?{...U,requiresPasswordReset:!0,passwordResetReason:C.passwordResetReason}:(o(U.user),l(null),h(null),{...U,user:k})}catch(C){throw console.error("AuthProvider login caught error:",C),console.error("AuthProvider error.message:",C.message),c(C.message),C}finally{n(!1)}},logout:async()=>{n(!0);try{await W.logout(t),o(null),l(null),h(null)}catch(v){console.error("Logout failed:",v)}finally{n(!1)}},selectRole:async v=>{if(!d)throw new Error("No pending authentication");n(!0);try{t.roleSelectionEndpoint&&await W.selectRole(v,d.token,t);const C={...d.user,role:v},F={...d,user:C};return F.requires2FA?(l(F),{...F,requires2FA:!0,twoFactorMethods:F.twoFactorMethods||["email"]}):F.requiresPasswordReset?(l(F),{...F,requiresPasswordReset:!0,passwordResetReason:F.passwordResetReason}):(o(C),l(null),h(null),{user:C,token:d.token})}catch(C){throw c(C.message),C}finally{n(!1)}},checkAuth:y,forgotPassword:async v=>W.forgotPassword(v),resetPassword:async v=>W.resetPassword(v),isAuthenticated:!!r,pendingAuth:d,availableRoles:u,authConfig:m,requiresRoleSelection:!!d&&!!u};return s.jsx(vo.Provider,{value:S,children:e})},{Text:dr,Title:Ft}=p.Typography,xo=({onSuccess:e,onBack:t})=>{const[r,o]=g.useState("request"),[a,n]=g.useState(!1),[i,c]=g.useState(""),[d,l]=g.useState("email"),[u,h]=g.useState(""),[m,w]=g.useState(0),[f,x]=g.useState(0),[y,P]=g.useState(null),[A,B]=g.useState(!1),[N,H]=g.useState(""),[S,v]=g.useState(""),[C,F]=g.useState(!1),{authConfig:D}=Ye(),k=async()=>{try{return await W.isAuthenticated()}catch{return!1}};g.useEffect(()=>{if(D){const _=W.getAllowedUsernames();_&&_.length>0&&l(_[0])}},[D]),g.useEffect(()=>{(async()=>{const J=await k();F(J),J&&r!=="success"&&o("success")})()},[r]),g.useEffect(()=>{if(m>0){const _=setTimeout(()=>w(m-1),1e3);return()=>clearTimeout(_)}},[m]);const U=_=>_==="email"?"Enter your email":"Enter your mobile number",I=_=>_==="email"?[{required:!0,message:"Please input your email!"},{type:"email",message:"Please enter a valid email!"}]:_==="mobile"?[{required:!0,message:"Please input your mobile number!"},{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid mobile number!"}]:[{required:!0,message:"Please input your username!"},{min:3,message:"Username must be at least 3 characters long"}],j=async _=>{n(!0);try{await W.requestOTP(_.username),c(_.username),o("verify"),w(30),p.toast.success("OTP sent successfully!")}catch(J){J?.response?.status===401?(c(_.username),o("verify"),w(30),p.toast.success("Please check your email/phone for the OTP code")):p.toast.error(J.message||"Failed to send OTP")}finally{n(!1)}},L=async()=>{if(u.length!==6){p.toast.error("Please enter 6 digit OTP");return}n(!0);try{const J=await W.verifyOTP(i,u);P(J),o("success"),p.toast.success("Login successful!")}catch(J){p.toast.error(J.message||"Invalid OTP"),h("")}finally{n(!1)}},T=async()=>{if(!N||!S){p.toast.error("Please fill in all password fields");return}if(N!==S){p.toast.error("Passwords do not match");return}if(N.length<8){p.toast.error("Password must be at least 8 characters long");return}n(!0);try{await W.setPassword(N),p.toast.success("Password changed successfully!"),B(!1),H(""),v("")}catch(_){p.toast.error(_.message||"Failed to change password")}finally{n(!1)}},M=()=>{y&&e(y)},E=async()=>{n(!0);try{await W.logout(),p.toast.success("Logged out successfully"),o("request"),P(null),c(""),h(""),F(!1)}catch(_){p.toast.error(_.message||"Failed to logout")}finally{n(!1)}},Z=async()=>{if(!(m>0)){n(!0);try{await W.requestOTP(i),w(30),p.toast.success("OTP resent successfully!")}catch(_){p.toast.error(_.message||"Failed to resend OTP")}finally{n(!1)}}};if(!D)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const Q=W.getAllowedUsernames(),z=6;return r==="success"&&C?s.jsxs("div",{className:"w-full",children:[s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:y?"Login Successful!":"Already Logged In"}),s.jsx(dr,{className:"block text-center text-gray-500 mb-6",children:y?"You have successfully logged in.":"You are currently logged in."}),A?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ft,{level:5,className:"!mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.Input.Password,{value:N,onChange:_=>H(_.target.value),placeholder:"Enter new password",disabled:a})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.Input.Password,{value:S,onChange:_=>v(_.target.value),placeholder:"Confirm new password",disabled:a})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:T,loading:a,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{B(!1),H(""),v("")},disabled:a,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[y&&s.jsx(p.Button,{type:"primary",block:!0,onClick:M,children:"Continue to Dashboard"}),s.jsx(p.Button,{block:!0,onClick:()=>B(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:E,loading:a,children:"Logout"})]})]}):r==="verify"?s.jsxs("div",{className:"w-full",children:[s.jsx(p.Button,{variant:"link",icon:s.jsx(Wt,{size:16}),onClick:()=>o("request"),className:"mb-4",children:"Back"}),s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:"Verify OTP"}),s.jsxs(dr,{className:"block text-center text-gray-500 mb-6",children:["We've sent a ",z,"-digit code to ",i]}),s.jsx("div",{className:"my-8 flex justify-center",children:s.jsx(Co,{length:z,value:u,onChange:h,disabled:a})}),s.jsx(p.Button,{type:"primary",block:!0,loading:a,onClick:L,className:"mt-6",children:"Verify OTP"}),s.jsx("div",{className:"text-center mt-4",children:m>0?s.jsxs(dr,{type:"secondary",children:["Resend OTP in ",m,"s"]}):s.jsx(p.Button,{type:"link",onClick:Z,loading:a,children:"Resend OTP"})})]}):s.jsxs("div",{className:"w-full",children:[t&&s.jsx(p.Button,{variant:"link",icon:s.jsx(Wt,{size:16}),onClick:t,className:"mb-4",children:"Back to other methods"}),s.jsx(Ft,{level:4,className:"!mb-2 text-center",children:"Sign in with OTP"}),s.jsxs(p.Form,{name:"otp-request",onFinish:j,layout:"vertical",children:[Q.length>1&&s.jsx(p.FormItem,{children:s.jsx(p.Segmented,{options:Q.map(_=>({label:s.jsxs(p.Space,{children:[_==="email"?s.jsx(Ct,{size:16}):_==="mobile"?s.jsx(Zt,{size:16}):s.jsx(Gt,{size:16}),s.jsx("span",{children:_==="mobile"?"Phone":_==="email"?"Email":"Username"})]}),value:_})),value:d,onChange:_=>l(_),block:!0,className:"bg-gray-100 mb-2"})}),s.jsx(p.FormItem,{name:"username",rules:I(d),children:s.jsx(p.Input,{placeholder:U(d)})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:a,children:"Send OTP"})})]},f)]})},Xi=({onLogin:e,showRememberMe:t=!0})=>{const[r,o]=g.useState(!1),[a,n]=g.useState(null),[i,c]=g.useState(null),[d,l]=g.useState("email"),[u,h]=g.useState(!1),[m,w]=g.useState(0),[f,x]=g.useState(!1),[y,P]=g.useState(!1),[A,B]=g.useState(""),[N,H]=g.useState(""),{authConfig:S}=Ye(),{getLoginConfig:v,getMessagesConfig:C,getProvidersConfig:F,authConfig:D}=Be(),k=D||S,U=lr(k),I=cr(k),j=Bi(k),L=async()=>{try{return await W.isAuthenticated()}catch{return!1}};if(g.useEffect(()=>{if(S){const V=W.getAllowedUsernames();if(V&&V.length>0){const K=V.includes("email"),ee=V.includes("mobile");K?l("email"):ee&&l("mobile")}W.isPasswordLoginEnabled()?c("password"):W.isOTPLoginEnabled()&&c("otp")}},[S]),g.useEffect(()=>{(async()=>{const K=await L();x(K)})()},[]),!S)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})});const T=V=>{const K=C();return V==="email"?[{required:!0,message:K?.validation?.required||"Please input your email!"},{type:"email",message:K?.validation?.invalidEmail||"Please enter a valid email!"}]:V==="mobile"?[{required:!0,message:K?.validation?.required||"Please input your mobile number!"},{pattern:/^\+\d{7,15}$/,message:K?.validation?.invalidMobile||"Please enter a valid mobile number with country code (e.g., +919876543210)"}]:[{required:!0,message:K?.validation?.required||"Please input your email!"},{type:"email",message:K?.validation?.invalidEmail||"Please enter a valid email!"}]},M=async V=>{o(!0),n(null);try{const K=W.getAllowedUsernames(),ee=K.includes("email"),ne=K.includes("mobile"),ie=ee&&ne?d:ee?"email":"mobile",me={email:ie==="email"?V.username:void 0,phone:ie==="mobile"?V.username:void 0,password:V.password,remember_me:V.remember||!1};await e(me)}catch(K){const ee=C(),ne=K.message||ee?.errors?.loginFailed||"Login failed. Please try again.";n(ne)}finally{o(!1)}},E=async V=>{await e(V)},Z=async()=>{o(!0);try{await W.logout(),p.toast.success("Logged out successfully"),x(!1)}catch(V){p.toast.error(V.message||"Failed to logout")}finally{o(!1)}},Q=async()=>{if(!A||!N){p.toast.error("Please fill in all password fields");return}if(A!==N){p.toast.error("Passwords do not match");return}if(A.length<8){p.toast.error("Password must be at least 8 characters long");return}o(!0);try{await W.setPassword(A),p.toast.success("Password changed successfully!"),P(!1),B(""),H("")}catch(V){p.toast.error(V.message||"Failed to change password")}finally{o(!1)}},z=V=>{const K=v(),ee=C();return s.jsxs(p.Form,{name:`${V}-password-login`,className:"w-full",onFinish:M,onFinishFailed:()=>{const ne=ee?.validation?.required||"Please check your input and try again";n(ne)},layout:"vertical",initialValues:{remember:!1},children:[a&&s.jsx(p.Alert,{message:a,type:"error",showIcon:!0,closable:!0,onClose:()=>n(null),className:"mb-4"}),s.jsx(p.FormItem,{name:"username",rules:T(V),children:s.jsx(p.Input,{placeholder:V==="email"?K?.formPlaceholders?.email||"Email address":K?.formPlaceholders?.mobile||"Mobile number (+919876543210)",autoComplete:V==="email"?"email":"tel",onKeyDown:V==="mobile"?ne=>{const ie=["Backspace","Delete","Tab","Enter","ArrowLeft","ArrowRight"],me=ne.key;!ie.includes(me)&&!/[0-9+]/.test(me)&&ne.preventDefault()}:void 0})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:ee?.validation?.required||"Please input your password!"},{min:S?.password_policy?.min_length||6,message:ee?.validation?.passwordTooShort||`Password must be at least ${S?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:K?.formPlaceholders?.password||"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs("div",{className:"flex justify-between items-center w-full",children:[s.jsx("div",{children:K?.showRememberMe!==!1&&t&&W.isRememberMeEnabled()&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx("div",{className:"auth-remember-me",style:I,children:s.jsx(p.Checkbox,{label:K?.rememberMeText||"Remember me"})})})}),s.jsx("div",{children:W.isForgotPasswordEnabled()&&s.jsx(G.Link,{to:"forgot-password",className:"text-sm transition-colors duration-300",style:j,children:K?.forgotPasswordText||"Forgot password?"})})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full text-base font-medium",disabled:r,fullWidth:!0,children:K?.submitButtonText||"Sign in"})})]},`${V}-${m}`)},_=()=>{if(!W.isOTPLoginEnabled())return null;const V=v();return u?s.jsx(xo,{onSuccess:E,onBack:()=>h(!1)}):s.jsx(p.Button,{variant:"secondary",fullWidth:!0,onClick:()=>h(!0),className:"bg-gray-100 border-gray-300",children:V?.otpButtonText||"Sign in with OTP"})},J=()=>{if(!S)return null;const V=W.getAllowedUsernames(),K=V.includes("email"),ee=V.includes("mobile"),ne=W.isSSOEnabled()||W.isOIDCEnabled(),ie=W.isPasswordLoginEnabled(),me=W.isOTPLoginEnabled();if(!ie&&!me)return null;if(me&&!ie)return s.jsx("div",{className:"w-full",children:s.jsx(xo,{onSuccess:E})});if(!ie)return null;if(K&&ee&&ie){const $e=v(),Ge=F();return s.jsx("div",{className:"w-full",children:s.jsx(p.Tabs,{className:"login-tabs",activeKey:d,onChange:le=>{l(le),w(Ee=>Ee+1)},items:[{key:"email",label:s.jsxs("span",{className:"flex items-center gap-1",style:U,children:[s.jsx(Ct,{size:16}),$e?.tabLabels?.email||"Email"]}),children:s.jsxs(s.Fragment,{children:[z("email"),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:Ge?.separatorText||"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:Ge?.separatorText||"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((le,Ee)=>s.jsx(bo,{provider:le,type:"oidc"},`oidc-email-${Ee}`))})})]})]})},{key:"mobile",label:s.jsxs("span",{className:"flex items-center gap-1",style:U,children:[s.jsx(Zt,{size:16}),$e?.tabLabels?.mobile||"Mobile"]}),children:s.jsxs(s.Fragment,{children:[z("mobile"),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4",children:s.jsx("div",{className:"space-y-2",children:W.getOIDCProviders().map((le,Ee)=>s.jsx(bo,{provider:le,type:"oidc",onClick:br=>{console.log("OIDC provider clicked:",br)}},`oidc-${Ee}`))})})]})]})}]})})}else{const $e=K?"email":"mobile";return s.jsxs("div",{className:"w-full",children:[z($e),me&&ie&&!u&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),_()]}),u&&_(),!u&&ne&&s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Divider,{children:"OR"}),W.isSSOEnabled()&&s.jsx("div",{className:"mb-4"}),W.isOIDCEnabled()&&s.jsx("div",{className:"mt-4"})]})]})}};return S?f?s.jsx("div",{className:"w-full",children:y?s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-base font-medium mb-4",children:"Change Your Password"}),s.jsx(p.FormItem,{label:"New Password",children:s.jsx(p.PasswordInput,{value:A,onChange:V=>B(V.target.value),placeholder:"Enter new password",disabled:r})}),s.jsx(p.FormItem,{label:"Confirm Password",children:s.jsx(p.PasswordInput,{value:N,onChange:V=>H(V.target.value),placeholder:"Confirm new password",disabled:r})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(p.Button,{type:"primary",onClick:Q,loading:r,className:"flex-1",children:"Change Password"}),s.jsx(p.Button,{onClick:()=>{P(!1),B(""),H("")},disabled:r,className:"flex-1",children:"Cancel"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-center mb-4",children:[s.jsx("h3",{className:"text-lg font-medium",style:U,children:"Already Logged In"}),s.jsx("p",{className:"text-sm mt-2",style:I,children:"You are currently logged in."})]}),s.jsx(p.Button,{block:!0,onClick:()=>P(!0),children:"Change Password"}),s.jsx(p.Button,{block:!0,danger:!0,onClick:Z,loading:r,children:"Logout"})]})}):J():s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large"})})},Qi=({onLogin:e,showRememberMe:t=!0,showForgotPassword:r=!0})=>{const[o,a]=g.useState(!1),[n,i]=g.useState(0),[c,d]=g.useState("email"),{authConfig:l}=Ye();g.useEffect(()=>{if(l){const P=W.getAllowedUsernames();P&&P.length>0&&d(P[0])}},[l]);const u=async P=>{a(!0);try{if(e){const A={email:c==="email"?P.username:void 0,phone:c==="mobile"?P.username:void 0,username:P.username,password:P.password,remember_me:P.remember||!1};await e(A)}}catch(A){p.toast.error(A.message||"Login failed. Please try again.")}finally{a(!1)}},h=()=>{switch(c){case"email":return"Email address";case"mobile":return"Phone number";case"username":return"Username";default:return"Username"}},m=()=>{const P=[{required:!0,message:`Please input your ${c}!`}];switch(c){case"email":return[...P,{type:"email",message:"Please enter a valid email address!"}];case"mobile":return[...P,{pattern:/^\+?[1-9]\d{1,14}$/,message:"Please enter a valid phone number!"}];case"username":return[...P,{min:3,message:"Username must be at least 3 characters long"}];default:return P}};if(!l)return s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:"Loading..."});const w=W.getAllowedUsernames(),f=w.length>1,x=W.isRememberMeEnabled(),y=W.isForgotPasswordEnabled();return s.jsxs(p.Form,{name:"login",className:"w-full space-y-4",initialValues:{remember:!1},onFinish:u,autoComplete:"off",layout:"vertical",children:[f&&s.jsx(p.FormItem,{label:"Login with",className:"mb-4",children:s.jsx(p.Select,{value:c,onChange:d,options:w.map(P=>({value:P,label:P==="mobile"?"Phone":P.charAt(0).toUpperCase()+P.slice(1)}))})}),s.jsx(p.FormItem,{name:"username",rules:m(),children:s.jsx(p.Input,{placeholder:h(),autoComplete:c==="email"?"email":"username"})}),s.jsx(p.FormItem,{name:"password",rules:[{required:!0,message:"Please input your password!"},{min:l?.password_policy?.min_length||6,message:`Password must be at least ${l?.password_policy?.min_length||6} characters long`}],children:s.jsx(p.PasswordInput,{placeholder:"Password",autoComplete:"current-password"})}),s.jsx(p.FormItem,{children:s.jsxs(p.Space,{className:"flex justify-between items-center w-full",children:[t&&x&&s.jsx(p.FormItem,{name:"remember",valuePropName:"checked",noStyle:!0,children:s.jsx(p.Checkbox,{label:"Remember me"})}),r&&y&&s.jsx(G.Link,{to:"forgot-password",className:"text-brand-500 text-sm hover:text-brand-600 transition-colors",children:"Forgot password?"})]})}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",className:"w-full h-10 text-base font-medium",disabled:o,fullWidth:!0,children:"Log in"})})]},n)},Yi=({onLogin:e,logo:t,title:r,subtitle:o,apiConfig:a={},useDynamicConfig:n=!0,staticConfig:i=null})=>{const[c,d]=g.useState(null),[l,u]=g.useState(n),[h,m]=g.useState(null),{authConfig:w}=Be(),f=qe(w),x=yo(w),y=lr(w),P=cr(w),A=ir(w),B=nr(w);g.useEffect(()=>{n&&!i?N():i&&(d(i),u(!1))},[n,i]);const N=async()=>{try{const S=await W.getAuthConfig();d(S),m(null)}catch(S){console.error("Failed to fetch login methods:",S),m("Failed to load login methods. Please refresh the page.")}finally{u(!1)}},H=()=>l?s.jsx("div",{className:"flex justify-center items-center min-h-[300px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading login methods..."})}):h?s.jsx(p.Alert,{message:"Error",description:h,type:"error",showIcon:!0,action:s.jsx("a",{onClick:N,children:"Retry"})}):c&&n?s.jsx(Xi,{onLogin:e}):s.jsx(Qi,{onLogin:e});return s.jsx(p.Layout,{className:"min-h-screen",style:x,children:s.jsx(p.Layout.Content,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsxs(p.Card,{className:"w-full max-w-md",bordered:!1,style:f,children:[t&&s.jsx("div",{className:A.className,style:A.style,children:typeof t=="string"?s.jsx("img",{src:t,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:B}):t}),s.jsxs("div",{className:"text-center mb-[18px]",children:[s.jsx("h1",{className:"text-3xl font-semibold mb-2",style:y,children:r||"Welcome Back"}),o&&s.jsx("p",{className:"text-base",style:P,children:o})]}),H()]})})})},{Title:Po,Text:ut,Paragraph:Ri}=p.Typography,el=({size:e="default",icon:t,src:r,style:o,className:a,children:n})=>{const c=typeof e=="number"?e:{small:24,default:32,large:40}[e];return s.jsx("div",{className:`inline-flex items-center justify-center bg-blue-500 text-white rounded-full overflow-hidden ${a||""}`,style:{width:c,height:c,fontSize:c*.45,...o},children:r?s.jsx("img",{src:r,alt:"Avatar",className:"w-full h-full object-cover"}):t||n||s.jsx(Gt,{size:c*.6})})},tl=({description:e,className:t,image:r})=>s.jsxs("div",{className:`flex flex-col items-center justify-center py-8 ${t||""}`,children:[!r&&s.jsx("div",{className:"mb-4 text-gray-400",children:s.jsx("svg",{width:"64",height:"41",viewBox:"0 0 64 41",fill:"currentColor",children:s.jsxs("g",{transform:"translate(0 1)",fillRule:"evenodd",children:[s.jsx("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),s.jsxs("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[s.jsx("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),s.jsx("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})})}),e&&s.jsx("div",{className:"text-sm text-gray-500",children:e})]}),rl=e=>{const t=e.toLowerCase();return t.includes("admin")?s.jsx(Ba,{size:20}):t.includes("manager")||t.includes("supervisor")?s.jsx($a,{size:20}):t.includes("security")||t.includes("compliance")?s.jsx(fs,{size:20}):s.jsx(Gt,{size:20})},So=({user:e,roles:t,onRoleSelect:r,loading:o=!1,title:a="Choose Your Role",subtitle:n="Select the role that best matches your current responsibilities",logo:i})=>{const[c,d]=g.useState(null),[l,u]=g.useState(!1),{getRoleSelectionConfig:h,getCardConfig:m,authConfig:w}=Be(),f=h(),x=qe(w),y=ir(w),P=nr(w),A=async()=>{if(c){u(!0);try{await r(c)}catch(S){console.error("Role selection failed:",S)}finally{u(!1)}}};if(o)return s.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:s.jsx(p.Spin,{size:"large",tip:"Loading your available roles..."})});if(!t||t.length===0){const S=f?.customEmptyState;return S?s.jsx(S,{}):s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsx("div",{style:x,children:s.jsx(tl,{className:"text-center py-12 px-5 text-gray-500",description:s.jsxs("div",{children:[s.jsx(ut,{className:"text-gray-600 text-base block mb-2",children:f?.emptyStateMessage||"No roles available"}),s.jsx(ut,{type:"secondary",className:"text-sm",children:"Please contact your administrator for role assignment"})]})})})})}const B=g.isValidElement(f?.title)?f.title:f?.title||a,N=g.isValidElement(f?.subtitle)?f.subtitle:f?.subtitle||n,H=f?.gridColumns||(t.length<=2?2:3);return s.jsx("div",{className:"max-w-lg mx-auto p-5",children:s.jsxs("div",{style:x,children:[i&&s.jsx("div",{className:y.className,style:y.style,children:typeof i=="string"?s.jsx("img",{src:i,alt:w?.logo?.alt||"Logo",className:"max-w-[150px] h-auto",style:P}):i}),s.jsxs("div",{className:"text-center mb-8",children:[g.isValidElement(B)?B:s.jsx(Po,{level:3,className:"!mb-3 !text-2xl !font-semibold !text-gray-800",children:B}),g.isValidElement(N)?N:s.jsx(Ri,{className:"!mb-6 text-base text-gray-600 !leading-relaxed",children:N}),e&&s.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-3 bg-gray-50 rounded-xl border border-gray-200",children:[s.jsx(el,{size:"default",className:"bg-blue-500",children:(e.name||e.username||"U").split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2)}),s.jsxs("div",{className:"text-left",children:[s.jsx(ut,{strong:!0,className:"text-sm block text-gray-800",children:e.name||e.username||"User"}),e.email&&s.jsx(ut,{type:"secondary",className:"text-xs",children:e.email})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"max-h-96 overflow-y-auto px-2 py-2",style:{maxHeight:f?.maxHeight||"24rem"},children:s.jsx("div",{className:`grid gap-4 grid-cols-${H}`,children:t.map(S=>{const v=f?.customRoleCard;if(v)return s.jsx(v,{role:S,selected:c?.id===S.id,onSelect:()=>d(S)},S.id);const C=f?.roleCardStyling||{},F=c?.id===S.id;return s.jsxs("div",{className:"cursor-pointer transition-all duration-300 border relative p-4 hover:-translate-y-1 flex flex-col items-center h-32 min-h-[8rem]",style:{backgroundColor:F?C.selectedColor||"#e6f7ff":C.backgroundColor||"#ffffff",borderColor:F?C.selectedColor||"#1890ff":"#d9d9d9",borderRadius:C.borderRadius||"16px",...f?.roleCardStyling},onClick:()=>d(S),children:[c?.id===S.id&&s.jsx("div",{className:"absolute -top-2 -right-2 bg-brand-500 rounded-full p-2",children:s.jsx(Oe,{size:16,className:"text-white"})}),s.jsx("div",{className:"flex justify-center mt-2 mb-3",children:s.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-xl flex items-center justify-center",children:rl(S.name)})}),s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-1",children:[s.jsx(Po,{level:5,className:"!mb-0 !text-sm !font-semibold !text-gray-900 !leading-tight !line-clamp-2 !text-center",title:S.name,children:S.name}),S.is_default&&s.jsx("div",{className:"mt-1",children:s.jsx(p.Tag,{color:"warning",className:"bg-yellow-50 border-yellow-300 text-yellow-700 font-medium text-xs px-1",children:f?.recommendedBadgeText||"Recommended"})})]})]},S.id)})})})}),s.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[s.jsx(p.Button,{type:"primary",block:!0,onClick:A,disabled:!c,loading:l,icon:c?s.jsx(Oe,{size:16}):null,className:"w-full",children:c?f?.continueButtonText?.replace("{roleName}",c.name)||`Continue as ${c.name}`:"Please select a role to continue"}),c?.is_default&&s.jsx(ut,{type:"secondary",className:"block text-center mt-3 text-sm",children:"This is your recommended role based on your permissions"})]})]})})},{Content:sl}=p.Layout,ol=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onLoginSuccess:i,roleSelectionTitle:c,roleSelectionSubtitle:d})=>{const{pendingAuth:l,availableRoles:u,selectRole:h,login:m}=Ye(),[w,f]=g.useState(null),x=async P=>{f(null);try{const A=await m(P),B={email:P.email,username:P.username,phone:P.phone,display:P.email||P.username||P.phone};if(A.requiresRoleSelection)return;i&&i({...A,loginUser:B})}catch(A){throw f(A.message),A}},y=async P=>{try{const A=await h(P);i&&i(A)}catch(A){throw console.error("Role selection failed:",A),A}};return l&&u?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(sl,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(So,{user:l.user,roles:u,onRoleSelect:y,title:c,subtitle:d})})}):s.jsx(Yi,{onLogin:x,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n})},{Title:al,Text:ur,Paragraph:nl}=p.Typography,il=({user:e,availableMethods:t=["email","sms"],onVerify:r,loading:o=!1,otpDigits:a=6,retryInterval:n=30,title:i="Two-Factor Authentication",subtitle:c="For your security, please verify your identity"})=>{const[d,l]=g.useState(t[0]||"email"),[u,h]=g.useState(""),[m,w]=g.useState(0),[f,x]=g.useState(!1),[y,P]=g.useState(!1),{authConfig:A,getTwoFactorConfig:B,getMessagesConfig:N}=Be(),H=B(),S=N(),v=qe(A);g.useEffect(()=>{if(m>0){const I=setTimeout(()=>w(m-1),1e3);return()=>clearTimeout(I)}},[m]);const C=I=>{if(I==="email"&&e?.email){const[j,L]=e.email.split("@");return`${j.substring(0,3)+"****"+j.substring(j.length-1)}@${L}`}return(I==="sms"||I==="mobile")&&e?.mobile?`****${e.mobile.substring(e.mobile.length-4)}`:I==="totp"?"your authenticator app":I==="email"?"your email":I==="sms"?"your mobile":"your authenticator app"},F=async()=>{x(!0);try{await W.sendTwoFactorCode(d),P(!0),w(H?.resendCountdown||n);const I=S?.success?.otpSent||`OTP sent to ${C(d)}`;p.toast.success(I)}catch(I){const j=S?.errors?.networkError||I.message||"Failed to send OTP";p.toast.error(j)}finally{x(!1)}},D=async()=>{const I=H?.codeLength||a;if(u.length!==I){const j=S?.validation?.required||`Please enter ${I} digit OTP`;p.toast.error(j);return}x(!0);try{const j=await W.verifyTwoFactorCode(u);await r(j)}catch(j){const L=S?.errors?.invalidOTP||j.message||"Invalid OTP";p.toast.error(L),h("")}finally{x(!1)}},k=async()=>{m>0||await F()},U=()=>{if(t.length<=1)return null;const I=t.map(j=>({label:s.jsxs(p.Space,{children:[j==="email"?s.jsx(Ct,{size:16}):j==="sms"?s.jsx(Zt,{size:16}):s.jsx(fs,{size:16}),s.jsx("span",{children:j==="email"?H?.methodLabels?.email||"Email":j==="sms"?H?.methodLabels?.sms||"SMS":H?.methodLabels?.mobile||"Authenticator"})]}),value:j}));return s.jsxs("div",{className:"mb-6",children:[s.jsx(ur,{type:"secondary",className:"block mb-2 text-xs",children:"Verification Method"}),s.jsx(p.Segmented,{options:I,value:d,onChange:j=>{l(j),P(!1),h("")},block:!0})]})};return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:v,children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx(al,{level:3,className:"!mb-2",children:H?.title||i}),s.jsx(nl,{className:"!mb-0 text-sm",type:"secondary",children:H?.subtitle||c})]}),s.jsxs("div",{className:"mt-6",children:[U(),y?s.jsxs("div",{className:"mt-6",children:[s.jsx(ur,{className:"block text-center mb-6 text-gray-700",children:H?.instructionText||`Enter the ${H?.codeLength||a}-digit code sent to ${C(d)}`}),s.jsx("div",{className:"flex justify-center mb-6",children:s.jsx(Co,{length:H?.codeLength||a,value:u,onChange:h,disabled:f})}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:f,onClick:D,className:"mb-4",children:H?.submitButtonText||"Verify"}),s.jsx("div",{className:"text-center",children:m>0?s.jsxs(ur,{type:"secondary",children:["Resend code in ",m,"s"]}):s.jsx(p.Button,{variant:"link",onClick:k,disabled:f,children:H?.resendButtonText||"Resend Code"})})]}):s.jsxs("div",{className:"mt-6",children:[s.jsx(p.Alert,{message:H?.instructionText||`We'll send a verification code to ${C(d)}`,type:"info",showIcon:!0,className:"mb-6"}),s.jsx(p.Button,{variant:"primary",fullWidth:!0,disabled:f,onClick:F,children:"Send Verification Code"})]})]})]})})},{Title:ll,Text:Ie,Paragraph:cl}=p.Typography,dl=({reason:e="Your password has expired",onReset:t,loading:r=!1,title:o="Password Reset Required",subtitle:a="Please create a new password to continue",passwordRules:n})=>{const[i,c]=g.useState(0),[d,l]=g.useState(!1),[u,h]=g.useState(""),[m,w]=g.useState({minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSpecialChars:!0}),{authConfig:f,getResetPasswordConfig:x,getMessagesConfig:y}=Be(),P=x(),A=y(),B=qe(f);g.useEffect(()=>{if(n)w(n);else{const C=W.getPasswordPolicy();w({minLength:C.min_length||8,maxLength:C.max_length,requireUppercase:C.require_uppercase||!1,requireLowercase:C.require_lowercase||!1,requireNumbers:C.require_numbers||!1,requireSpecialChars:C.require_special_chars||!1})}},[n]);const N=C=>{if(!C)return{percent:0,status:"exception"};let F=0;return C.length>=m.minLength&&(F+=20),C.length>=12&&(F+=10),m.requireUppercase&&/[A-Z]/.test(C)&&(F+=20),m.requireLowercase&&/[a-z]/.test(C)&&(F+=20),m.requireNumbers&&/\d/.test(C)&&(F+=15),m.requireSpecialChars&&/[!@#$%^&*]/.test(C)&&(F+=15),F<40?{percent:F,status:"exception"}:F<70?{percent:F,status:"normal"}:{percent:F,status:"success"}},H=(C,F)=>{if(!F){const k=A?.validation?.required||"Please input your password!";return Promise.reject(new Error(k))}const D=W.validatePassword(F);if(!D.valid){const k=A?.validation?.passwordTooShort||D.errors.join(", ");return Promise.reject(new Error(k))}return Promise.resolve()},S=async C=>{l(!0);try{await W.setPassword(C.password),await t({password:C.password,confirmPassword:C.confirmPassword})}catch(F){throw F}finally{l(!1)}},v=N(u);return s.jsx("div",{className:"w-full max-w-lg mx-auto",children:s.jsxs(p.Card,{className:"shadow-lg rounded-lg",bordered:!1,style:B,children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx(ll,{level:3,className:"!mb-2",children:P?.resetForm?.title||o}),s.jsx(cl,{className:"!mb-0 text-sm",type:"secondary",children:P?.resetForm?.subtitle||a})]}),s.jsx(p.Alert,{message:e,type:"warning",showIcon:!0,className:"mb-6"}),s.jsxs(p.Form,{name:"password-reset-required",onFinish:S,layout:"vertical",className:"mt-6",children:[s.jsx(p.FormItem,{name:"password",label:P?.resetForm?.passwordLabel||"New Password",rules:[{validator:H}],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16}),placeholder:P?.resetForm?.passwordPlaceholder||"New Password",onChange:C=>h(C.target.value)})}),u&&s.jsxs("div",{className:"-mt-4 mb-4",children:[s.jsx(Ie,{type:"secondary",className:"text-xs block mb-1",children:"Password Strength"}),s.jsx(p.Progress,{percent:v.percent,status:v.status,showInfo:!1,strokeWidth:4})]}),s.jsx(p.FormItem,{name:"confirmPassword",label:P?.resetForm?.confirmPasswordLabel||"Confirm Password",dependencies:["password"],rules:[{required:!0,message:A?.validation?.required||"Please confirm your password!"},({getFieldValue:C})=>({validator(F,D){if(!D||C("password")===D)return Promise.resolve();const k=A?.validation?.passwordsDoNotMatch||"Passwords do not match!";return Promise.reject(new Error(k))}})],children:s.jsx(p.PasswordInput,{prefix:s.jsx(bt,{size:16}),placeholder:P?.resetForm?.confirmPasswordPlaceholder||"Confirm Password"})}),P?.resetForm?.showPasswordRequirements!==!1&&s.jsxs("div",{className:"bg-gray-50 p-4 rounded-md mb-6",children:[s.jsx(Ie,{type:"secondary",className:"block font-medium mb-2",children:P?.resetForm?.passwordRequirementsText||"Password Requirements:"}),s.jsxs(p.Space,{direction:"vertical",size:"small",children:[s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:u.length>=m.minLength?"text-green-500":"text-gray-300"}),"At least ",m.minLength," characters"]}),m.maxLength&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:u.length<=m.maxLength?"text-green-500":"text-gray-300"}),"At most ",m.maxLength," characters"]}),m.requireUppercase&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[A-Z]/.test(u)?"text-green-500":"text-gray-300"}),"One uppercase letter"]}),m.requireLowercase&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[a-z]/.test(u)?"text-green-500":"text-gray-300"}),"One lowercase letter"]}),m.requireNumbers&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/\d/.test(u)?"text-green-500":"text-gray-300"}),"One number"]}),m.requireSpecialChars&&s.jsxs(Ie,{type:"secondary",className:"flex items-center gap-2 text-sm",children:[s.jsx(Oe,{size:16,className:/[!@#$%^&*]/.test(u)?"text-green-500":"text-gray-300"}),"One special character (!@#$%^&*)"]})]})]}),s.jsx(p.FormItem,{children:s.jsx(p.Button,{variant:"primary",type:"submit",fullWidth:!0,disabled:d||r,children:P?.resetForm?.submitButtonText||"Reset Password"})})]},i)]})})},{Content:Ot}=p.Layout,hr=({logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a=!0,staticConfig:n=null,onAuthComplete:i,roleSelectionTitle:c,roleSelectionSubtitle:d,twoFactorTitle:l,twoFactorSubtitle:u,passwordResetTitle:h,passwordResetSubtitle:m,initialAuthState:w=null})=>{const{user:f,pendingAuth:x}=Ye(),{authConfig:y}=Be();ir(y),nr(y);const[P,A]=g.useState(()=>{if(w){if(w.roles&&w.roles.length>1)return"roleSelection";if(w.requires2FA)return"twoFactor";if(w.requiresPasswordReset)return"passwordReset"}return"login"}),[B,N]=g.useState(w?.token||null),[H,S]=g.useState(w?.twoFactorMethods||null),[v,C]=g.useState(w?.passwordResetReason||null),[F,D]=g.useState(w||null),k=async L=>{console.log("Login success result:",L);let T=L,M=null;L?.status===401&&L?.data?(T=L.data,M=L.data?.next_step):L?.next_step?(T=L,M=L.next_step):(T=L?.response?.data||L?.data||L,M=T?.next_step);const E=L?.loginUser;(L?.token||T?.token)&&N(L.token||T.token);let Z=L?.user||T?.user||E||{};if((typeof Z!="object"||Z===null)&&(Z={}),E&&typeof E=="object"&&(Z={...Z,email:Z.email||E.email,username:Z.username||E.username,phone:Z.phone||E.phone,name:Z.name||E.display}),M&&M.is_pending)switch(M.id){case"role_selection":let Q=[];Array.isArray(M.metadata.roles)?Q=M.metadata.roles:typeof M.metadata.roles=="object"&&(Q=Object.entries(M.metadata.roles).map(([J,V])=>({id:J,name:V,is_default:!1}))),D({...L,roles:Q,user:Z,nextStep:M,loginUser:E}),A("roleSelection");return;case"mfa_authenticate":N(L.token||T?.token);const z=M.metadata?.type?[M.metadata.type]:M.metadata?.methods||["email"];S(z),A("twoFactor");return;case"set_password":N(L.token||T?.token);const _=M.metadata?.password_policy;C(M.metadata?.reason||"Password update required"),D({...L,passwordPolicy:_,user:Z,loginUser:E}),A("passwordReset");return;case"password_expiry":N(L.token||T?.token),C("Your password has expired"),D({...L,passwordPolicy:M.metadata?.password_policy,user:Z,loginUser:E}),A("passwordReset");return;case"first_login":N(L.token||T?.token),C("Please set up your password for first login"),D({...L,passwordPolicy:M.metadata?.password_policy,user:Z,loginUser:E}),A("passwordReset");return;case"login_by_code":N(L.token||T?.token),console.log("OTP login flow required"),p.toast.info("OTP verification required"),i&&i({...L,user:Z,requiresOTP:!0});return}if(L.requires2FA){N(L.token),S(L.twoFactorMethods||["email"]),D({...L,user:Z,loginUser:E}),A("twoFactor");return}if(L.requiresPasswordReset){N(L.token),C(L.passwordResetReason||"Your password has expired"),D({...L,user:Z,loginUser:E}),A("passwordReset");return}i&&i({...L,user:Z})},U=async L=>{try{console.log("2FA verification result:",L);let T=L,M=null,E=!1,Z=null;if(L?.status===401&&L?.data?(T=L.data,M=L.data?.next_step,Z=L.status,E=L?.meta?.is_authenticated||!1):L?.response?(Z=L.response.status,T=L.response.data,M=T?.next_step,E=L.response.meta?.is_authenticated||!1):(T=L?.data||L,M=T?.next_step,E=L?.meta?.is_authenticated||T?.meta?.is_authenticated||!1,Z=L?.status||T?.status),Z===200&&E){console.log("Authentication completed successfully after 2FA"),p.toast.success("Two-factor authentication successful!"),i&&i({...L,token:B,user:F?.user,authenticated:!0});return}if(M&&M.is_pending)switch(M.id){case"set_password":const Q=M.metadata?.password_policy;C(M.metadata?.reason||"Password reset required"),D({...F,passwordPolicy:Q}),A("passwordReset");return;default:console.warn("Unknown next step after 2FA:",M.id);break}if(L.requiresPasswordReset){C(L.passwordResetReason||"Your password has expired"),A("passwordReset");return}p.toast.success("Two-factor authentication successful!"),i&&i({...L,token:B,user:F?.user,authenticated:!0})}catch(T){throw T}},I=async L=>{try{const T=await W.setPassword(L.password);console.log("Password reset result:",T);let M=T,E=null,Z=!1,Q=null;if(T?.status===401&&T?.data?(M=T.data,E=T.data?.next_step,Q=T.status,Z=T?.meta?.is_authenticated||!1):T?.response?(Q=T.response.status,M=T.response.data,E=M?.next_step,Z=T.response.meta?.is_authenticated||!1):(M=T?.data||T,E=M?.next_step,Z=T?.meta?.is_authenticated||M?.meta?.is_authenticated||!1,Q=T?.status||M?.status),Q===200&&Z){console.log("Authentication completed successfully after password reset"),p.toast.success("Password reset successful!"),i&&i({...T,token:B,user:F?.user,authenticated:!0});return}if(E&&E.is_pending)switch(E.id){case"mfa_authenticate":const z=E.metadata?.type?[E.metadata.type]:E.metadata?.methods||["email"];S(z),A("twoFactor");return;default:console.warn("Unknown next step after password reset:",E.id);break}p.toast.success("Password reset successful!"),i&&i({...T,token:B,user:F?.user,authenticated:!0})}catch(T){throw p.toast.error(T.message||"Failed to reset password"),T}};return(()=>{switch(P){case"login":return s.jsx(ol,{onLoginSuccess:k,logo:e,title:t,subtitle:r,apiConfig:o,useDynamicConfig:a,staticConfig:n,roleSelectionTitle:c,roleSelectionSubtitle:d});case"roleSelection":return F?.roles?s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx("div",{className:"w-full",children:s.jsx(So,{user:F?.user,roles:F?.roles||[],logo:e,onRoleSelect:async M=>{try{const E=await W.selectRole(M.id);console.log("Role selection result:",E);let Z=E,Q=null,z=!1,_=null;if(E?.status===401&&E?.data?(Z=E.data,Q=E.data?.next_step,_=E.status,z=E?.meta?.is_authenticated||!1):E?.response?(_=E.response.status,Z=E.response.data,Q=Z?.next_step,z=E.response.meta?.is_authenticated||!1):(Z=E?.data||E,Q=Z?.next_step,z=E?.meta?.is_authenticated||Z?.meta?.is_authenticated||!1,_=E?.status||Z?.status),_===200&&z){console.log("Authentication completed successfully after role selection"),p.toast.success("Role selected successfully!"),i&&i({...E,user:{...F.user,role:M},authenticated:!0});return}if(Q&&Q.is_pending)switch(Q.id){case"mfa_authenticate":const J=Q.metadata?.type?[Q.metadata.type]:Q.metadata?.methods||["email"];S(J),A("twoFactor");return;case"set_password":const V=Q.metadata?.password_policy;C(Q.metadata?.reason||"Password update required"),D({...F,passwordPolicy:V}),A("passwordReset");return;case"password_expiry":C("Your password has expired"),D({...F,passwordPolicy:Q.metadata?.password_policy}),A("passwordReset");return;case"first_login":C("Please set up your password for first login"),D({...F,passwordPolicy:Q.metadata?.password_policy}),A("passwordReset");return;case"login_by_code":console.log("OTP login flow required after role selection"),p.toast.info("OTP verification required"),i&&i({...E,user:{...F.user,role:M},requiresOTP:!0});return;default:console.warn("Unknown next step:",Q.id);break}p.toast.success("Role selected successfully!"),i&&i({...E,user:{...F.user,role:M}})}catch(E){throw p.toast.error(E.message||"Failed to select role"),E}},title:c||"Select Your Role",subtitle:d||"Choose a role to continue"})})})}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx("div",{className:"text-center py-16 px-5",children:s.jsx(p.Spin,{size:"large",tip:"Loading..."})})})});case"twoFactor":return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(il,{user:F?.user||x?.user||f,availableMethods:H,onVerify:U,title:l,subtitle:u})})});case"passwordReset":const L=F?.passwordPolicy,T=L?{minLength:L.min_length||8,maxLength:L.max_length,requireUppercase:L.require_uppercase||!1,requireLowercase:L.require_lowercase||!1,requireNumbers:L.require_numbers||!1,requireSpecialChars:L.require_special_chars||!1}:void 0;return s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(Ot,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx(dl,{reason:v,onReset:I,title:h,subtitle:m,passwordRules:T})})});default:return null}})()},{Content:ul}=p.Layout,hl=({logo:e,apiConfig:t,onAuthComplete:r,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,redirectPath:l="/"})=>{const[u,h]=g.useState(null),[m,w]=g.useState(!1),f=async P=>{P.requiresRoleSelection||P.requires2FA||P.requiresPasswordReset?(h(P),w(!0)):(P.token&&localStorage.setItem(t?.tokenKey||"authToken",P.token),r&&r(P))},x=P=>{console.error("OAuth callback error:",P)},y=P=>{const A={...u,...P,authMethod:"oauth",provider:u?.provider};r&&r(A)};return m&&u?s.jsx(hr,{logo:e,apiConfig:t,onAuthComplete:y,roleSelectionTitle:o,roleSelectionSubtitle:a,twoFactorTitle:n,twoFactorSubtitle:i,passwordResetTitle:c,passwordResetSubtitle:d,initialAuthState:{user:u.user,token:u.token,roles:u.roles,requires2FA:u.requires2FA,twoFactorMethods:u.twoFactorMethods,requiresPasswordReset:u.requiresPasswordReset,passwordResetReason:u.passwordResetReason}}):s.jsx(p.Layout,{className:"min-h-screen bg-gradient-to-br from-purple-600 to-purple-800",children:s.jsx(ul,{className:"flex justify-center items-center min-h-screen p-5",children:s.jsx($i,{onSuccess:f,onError:x,apiConfig:t,redirectPath:l})})})},ko=()=>Ye(),{Header:Sc,Content:Ao}=p.Layout,fr={},pr={},gr={"admin@example.com":{requires2FA:!0,requiresPasswordReset:!1,twoFactorMethods:["email","mobile"]},"+919876543210":{requires2FA:!0,requiresPasswordReset:!0,passwordResetReason:"Your password will expire in 7 days",twoFactorMethods:["mobile"]},"test@example.com":{requires2FA:!1,requiresPasswordReset:!0,passwordResetReason:"Password has expired"}},ht={"admin@example.com":[{id:1,name:"Super Admin",description:"Full system access with all administrative privileges",permissions:["system.manage","users.manage","roles.manage","settings.manage"],is_default:!1},{id:2,name:"Organization Admin",description:"Manage organization settings and users",permissions:["org.manage","users.manage","reports.view"],is_default:!0},{id:3,name:"Compliance Officer",description:"Monitor compliance and security settings",permissions:["compliance.view","audit.view","reports.generate"],is_default:!1}],"+919876543210":[{id:4,name:"Team Manager",description:"Manage team members and projects",permissions:["team.manage","projects.manage","reports.view"],is_default:!0},{id:5,name:"Employee",description:"Standard employee access",permissions:["profile.edit","tasks.manage","reports.view"],is_default:!1}],default:[{id:6,name:"User",description:"Standard user access",permissions:["profile.view","profile.edit"],is_default:!0}]},mr=e=>({loginEndpoint:"/api/auth/login",logoutEndpoint:"/api/auth/logout",verifyEndpoint:"/api/auth/verify",forgotPasswordEndpoint:"/api/auth/forgot-password",resetPasswordEndpoint:"/api/auth/reset-password",loginMethodsEndpoint:"/api/v1/login/?action=fetch_methods",otpRequestEndpoint:"/api/auth/otp/request",otpVerifyEndpoint:"/api/auth/otp/verify",apiClient:{post:async(t,r)=>{if(console.log("Mock API POST:",t,r),await new Promise(o=>setTimeout(o,1e3)),t.includes("login")){const o=r.email||r.phone||r.username;if(["admin@example.com","+919876543210","test@example.com","admin"].includes(o)&&r.password==="password"){const i=ht[o]||ht.default,c=gr[o]||{};return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o==="admin@example.com"?"John Admin":o.startsWith("+")?"Mobile User":"Test User"},token:"mock-jwt-token-12345",roles:i,...c}}throw new Error("Invalid credentials")}if(t.includes("otp/request")){const o=r.email_or_phone||r.email||r.phone||r.username,a=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return fr[o]=a,console.log(`📱 Mock OTP for ${o}: ${a}`),p.toast.info(`Mock OTP sent! Check console for OTP: ${a}`),{success:!0,message:"OTP sent successfully"}}if(t.includes("otp/verify")){const o=r.email_or_phone||r.email||r.phone||r.username;if(fr[o]===r.otp){delete fr[o];const n=ht[o]||ht.default;return{user:{id:1,username:o,email:o.includes("@")?o:"user@example.com",mobile:o.startsWith("+")?o:"+919876543210",name:o.includes("@")?"OTP User":"Mobile User"},token:"mock-jwt-token-otp-12345",roles:n}}throw new Error("Invalid OTP")}if(t.includes("forgot-password"))return{message:"Reset email sent successfully"};if(t.includes("reset-password"))return{message:"Password reset successfully"};if(t.includes("role/select"))return console.log("Role selected:",r),{success:!0,...gr["admin@example.com"]||{}};if(t.includes("2fa/send")){const o=Math.floor(Math.random()*9e5+1e5).toString().slice(0,6);return pr[r.method]=o,console.log(`📱 2FA OTP for ${r.method}: ${o}`),p.toast.info(`2FA OTP sent! Check console for OTP: ${o}`),{success:!0,message:"2FA code sent successfully"}}if(t.includes("2fa/verify")){if(pr[r.method]===r.otp){delete pr[r.method];const n=gr["admin@example.com"]||{};return{success:!0,requiresPasswordReset:n.requiresPasswordReset,passwordResetReason:n.passwordResetReason}}throw new Error("Invalid 2FA code")}if(t.includes("password/change"))return console.log("Password changed:",r),{success:!0,message:"Password changed successfully"};if(t.includes("oauth/callback")){console.log("OAuth callback:",r);const o=r.provider||"google",a={id:1,email:`user@${o}.com`,name:`${o.charAt(0).toUpperCase()+o.slice(1)} User`,username:`user@${o}.com`};return o==="google"?{user:a,token:"mock-oauth-token-12345",roles:ht["admin@example.com"],requires2FA:!0,twoFactorMethods:["email"]}:o==="microsoft"?{user:a,token:"mock-oauth-token-12345",requiresPasswordReset:!0,passwordResetReason:"first_login"}:{user:a,token:"mock-oauth-token-12345"}}return{success:!0}},get:async t=>{if(console.log("Mock API GET:",t),await new Promise(r=>setTimeout(r,500)),t.includes("fetch_methods")||t.includes("config"))return{success:!0,response:{auth_config:{login_methods:{password:{enabled:!0,forgot_password_enabled:!0,allowed_usernames:["email","phone"]},otp:{enabled:!0,allowed_methods:["email","sms"]},sso:{enabled:!1},oidc:{enabled:!1}},password_policy:{min_length:8,require_numbers:!0,require_lowercase:!0,require_uppercase:!0,require_special_chars:!0,password_expiry_days:90,password_history_count:3,allow_change:!0,reset:{enabled:!0,method:["email"],expiry_hours:2}},session_policy:{remember_me_enabled:!0,remember_me_duration_days:30},two_factor_auth:{required:!0,allowed_methods:[]}}}};if(t.includes("verify")){console.log("Inside verify");const r=localStorage.getItem("authToken");if(r&&r.startsWith("mock-jwt-token"))return{id:1,username:"admin",email:"admin@example.com"};throw new Error("Invalid token")}return{}}}}),fl=({basePath:e="/login",apiConfig:t={},onAuthComplete:r,logo:o,title:a="Welcome Back",subtitle:n="Please sign in to your account",roleSelectionTitle:i="Select Your Role",roleSelectionSubtitle:c="Choose a role to continue",twoFactorTitle:d="Two-Factor Authentication",twoFactorSubtitle:l="Please enter your verification code",passwordResetTitle:u="Reset Password",passwordResetSubtitle:h="Please enter your new password"})=>{const{authConfig:m}=Pe();G.useLocation(),G.useNavigate();const[w,f]=g.useState(null),{setBasePath:x}=Et();g.useEffect(()=>{x(e)},[e,x]),g.useEffect(()=>(m&&Oi(m),()=>{Mi()}),[m]);const y=g.useMemo(()=>{const S=m?.login||{},v=m?.logo||{};return{logo:v.url?s.jsx("img",{src:v.url,alt:v.alt||"Logo",style:{width:v.width||"auto",height:v.height||"auto",...v.style},className:v.className}):o,title:S.title||a,subtitle:S.subtitle||n,roleSelectionTitle:m?.roleSelection?.title||i,roleSelectionSubtitle:m?.roleSelection?.subtitle||c,twoFactorTitle:m?.twoFactor?.title||d,twoFactorSubtitle:m?.twoFactor?.subtitle||l,passwordResetTitle:m?.resetPassword?.resetForm?.title||u,passwordResetSubtitle:m?.resetPassword?.resetForm?.subtitle||h}},[m,o,a,n,i,c,d,l,u,h]),P=g.useMemo(()=>yo(m),[m]);console.log("basePath",e),console.log("apiConfig",t);const A=S=>{f(S),r&&r(S)},B=()=>{G.useNavigate();const S=async v=>{console.log("Authentication complete:",v),p.toast.success("Authentication complete!");try{const F=new URLSearchParams(window.location.search).get("next");let D="/app";F&&(D=decodeURIComponent(F),console.log("Redirecting to 'next' parameter:",D)),console.log("Final redirect URL:",D),window.location.href=D}catch(C){console.error("Error handling auth completion:",C),window.location.href="/app"}};return s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hr,{onAuthComplete:S,logo:y.logo,title:y.title,subtitle:y.subtitle,apiConfig:mr(),useDynamicConfig:!0,roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})},N=()=>{const{forgotPassword:S}=ko(),v=qe(m),C=async F=>{try{await S(F);const D=m?.resetPassword?.forgotPassword?.successMessage||"Reset email sent successfully!";p.toast.success(D)}catch(D){const k=m?.resetPassword?.forgotPassword?.errorMessage||D.message||"Failed to send reset email";p.toast.error(k)}};return s.jsx(p.Layout,{style:{...P,minHeight:"100vh"},children:s.jsx(Ao,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{...v,width:"100%"},children:s.jsx(qi,{onSubmit:C,authConfig:m})})})})},H=()=>{const{resetPassword:S}=ko(),v=qe(m),C=async F=>{await S(F);const D=m?.resetPassword?.resetForm?.successMessage||"Password reset successfully!";p.toast.success(D)};return s.jsx(p.Layout,{style:{...P,minHeight:"100vh"},children:s.jsx(Ao,{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:s.jsx("div",{style:{...v,width:"100%"},children:s.jsx(Ii,{onSubmit:C,token:"demo-reset-token",authConfig:m})})})})};return e.endsWith("/")&&e.slice(0,-1),s.jsx(Ei,{authConfig:m,children:s.jsx(Ji,{config:mr(),children:s.jsxs(G.Routes,{children:[s.jsx(G.Route,{path:"/",element:s.jsx(B,{})}),s.jsx(G.Route,{path:"forgot-password",element:s.jsx(N,{})}),s.jsx(G.Route,{path:"reset-password",element:s.jsx(H,{})}),s.jsx(G.Route,{path:"/oauth/callback",element:s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hl,{logo:y.logo,apiConfig:mr(),onAuthComplete:S=>{console.log("OAuth auth complete:",S),(async()=>{const C=S?.response?.data?.redirect_url;C&&(window.location.href=C)})()},roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})}),s.jsx(G.Route,{path:"/complete",element:s.jsx("div",{style:{...P,minHeight:"100vh"},children:s.jsx(hr,{authData:w,apiConfig:t,logo:y.logo,onComplete:A,roleSelectionTitle:y.roleSelectionTitle,roleSelectionSubtitle:y.roleSelectionSubtitle,twoFactorTitle:y.twoFactorTitle,twoFactorSubtitle:y.twoFactorSubtitle,passwordResetTitle:y.passwordResetTitle,passwordResetSubtitle:y.passwordResetSubtitle})})}),s.jsx(G.Route,{path:"*",element:s.jsx(G.Navigate,{to:"/404",replace:!0})})]})})})},wr=({basePath:e="/app"})=>{const t=at();return s.jsx("div",{className:"page-container",children:s.jsx(fl,{basePath:e,apiConfig:t})})},pl=async(e=[])=>{console.log("🚀 Creating dynamic page registry..."),console.log("📋 Requested page types:",e);const t=Ta(e);console.log("✅ Available page types:",t);const r={login:{component:wr,includeBasePath:!0,standalone:!0,propsBuilder:({matchedRoutePath:c})=>({basePath:c})},custom:{component:null,includeBasePath:!1,handler:({customPages:c,customPagePath:d,location:l})=>{const u=c[d];return u?g.createElement(u):g.createElement(ds,{componentName:d})}},404:{component:zt,standalone:!0,includeBasePath:!1,propsBuilder:()=>({})},default:{component:zt,includeBasePath:!1,standalone:!0,propsBuilder:({pageType:c})=>({message:`Unknown page type: ${c}`})}};for(const c of t){const d=Na(c);d?(r[c]={component:d,includeBasePath:!0,propsBuilder:({matchedRoutePath:l})=>({basePath:l})},console.log(`✅ Registered static page type: ${c}`)):console.warn(`⚠️ Failed to get component for page type: ${c}`)}const o=t.length,a=4,n=o+a;console.log(`📊 Registry created with ${n} page types:`),console.log(` • Dynamic framework pages (${o}): ${t.join(", ")||"none"}`),console.log(` • Static pages (${a}): login, custom, 404, default`);const i=e.filter(c=>!t.includes(c));return i.length>0&&console.warn(`⚠️ Unconfigured page types (not in PAGE_CONFIG): ${i.join(", ")}`),r},gl=e=>{const t=new Set;return e.forEach(r=>{r.page_type&&r.page_type!=="custom"&&r.page_type!=="login"&&t.add(r.page_type)}),Array.from(t)},ml=async e=>{const t=gl(e);return pl(t)},_o=g.createContext(void 0);let Re=!1;typeof window<"u"&&(Re=!1);const Pe=()=>{const e=g.useContext(_o);if(!e)throw new Error("useAppContext must be used within AppProvider");return e},Lo=({children:e,config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={}})=>{const c=G.useNavigate(),d=G.useLocation(),[l,u]=g.useState(null),[h,m]=g.useState(!0),[w,f]=g.useState(null),[x,y]=g.useState(null);g.useEffect(()=>{console.log("🔄 Loading state changed to:",h)},[h]);const[P,A]=g.useState(null),[B,N]=g.useState(!1),[H,S]=g.useState(null),v=()=>typeof window<"u"&&window.app_initializer_endpoint?window.app_initializer_endpoint:"/app/initializer",C=t,F=C.apiConfig||{};g.useEffect(()=>{const k={colors:{primary:"#5048ed",secondary:"#6d7280",success:"#10b981",warning:"#f59e0b",error:"#f04438",gray:"#6d7280",background:"#f9fafb",text:"#252b37"}},U="default-theme-variables";let I=document.getElementById(U);I||(I=document.createElement("style"),I.id=U,document.head.appendChild(I)),I.innerHTML=`:root { ${yt(k)} }`},[]),g.useEffect(()=>{const k=Ve.getCachedLogo();k&&y(k.base64Data||k.url)},[]),g.useEffect(()=>{let k=!1;return(async()=>{const I=window.location.pathname,j=I.startsWith("/app/login");if(console.log("🔍 AppContext useEffect triggered:",{currentPath:I,isLoginPage:j,fetchInProgress:Re}),Re){console.log("⚠️ Fetch already in progress, skipping...");return}Re=!0,console.log("🚀 Starting fetchAppInitData...");try{const L=await jr(),T=L.success?L.response:null;if(console.log("✅ fetchAppInitData completed:",{success:L.success,hasMenu:T?.menu?.length>0,menuCount:T?.menu?.length,userRole:T?.profile_info?.user_role}),!L.success)throw new Error(L.response?.message||"Failed to fetch app data");if(console.log("📦 Setting app data"),u(T),T?.theme){console.log("🎨 Applying theme");const M=document.getElementById("default-theme-variables");if(M)M.innerHTML=`:root { ${yt(T.theme)} }`;else{const E=document.createElement("style");E.id="default-theme-variables",E.innerHTML=`:root { ${yt(T.theme)} }`,document.head.appendChild(E)}T?.app_logo&&Ve.updateInBackground(T.app_logo,T.app_name,E=>{E.base64Data&&y(E.base64Data)})}}catch(L){console.error("❌ fetchAppInitData error:",L),f(L.message)}finally{console.log("🏁 Finally block executing:",{cancelled:k,loading:h}),console.log("✅ Setting loading to FALSE (ignoring cancelled state)"),m(!1),Re=!1,console.log("✅ fetchAppInitData finally block completed:",{fetchInProgress:Re,cancelled:k})}})(),()=>{k=!0,console.log("🧹 AppContext cleanup - useEffect unmounting")}},[]),g.useEffect(()=>{if(h||!l)return;const k=d.pathname,U=k==="/app/configuration-error";if(k==="/app/logout")return;const j=l.menu&&l.menu.length>0,L=l.routes&&l.routes.length>0,T=l.profile_info?.user_role,M=l.is_user_anonymous,E=!l.is_user_anonymous,Z=L&&l.routes.some(Q=>{const z=Q.path;return k===z||k.startsWith(z+"/")});if(console.log("🔍 Redirect logic check:",{currentPath:k,hasMenu:j,hasRoutes:L,userRole:T,isAnonymous:M,isAuthenticated:E,isConfigPage:U,isValidPath:Z}),E&&!j&&!U){console.log("🚀 Flow 1: Authenticated user without menu → configuration-error"),c("/app/configuration-error",{replace:!0});return}if(M&&!j){console.log("🚀 Flow 2: Anonymous user without menu → login"),c("/app/login",{replace:!0});return}if(j&&l.menu){const Q=l.menu[0]?.path||l.menu[0]?.uri;if(Q&&(k==="/app"||k==="/app/"||!Z&&!U)){console.log("🚀 Flow 3/4: Redirecting to first menu item:",Q,{reason:k==="/app"||k==="/app/"?"/app root":"invalid path"}),c(Q,{replace:!0});return}}},[h,l,d.pathname,c]),g.useEffect(()=>{let k=!1;return(async()=>{if(h){console.log("⏳ Still loading app data, skipping registry creation");return}if(!l){console.log("⏳ No app data yet, skipping registry creation");return}if(console.log("🚀 Starting registry creation...",{isAnonymous:l.is_user_anonymous,hasRoutes:!!l.routes,routesLength:l.routes?.length}),l.is_user_anonymous){console.log("✅ Anonymous user - creating minimal registry"),k||(A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1));return}if(!l.routes||l.routes.length===0){console.log("⚠️ No routes found - creating fallback registry"),k||(A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1));return}try{k||(N(!0),S(null)),console.log("🚀 Creating dynamic page registry from routes...");const I=await ml(l.routes);k||(A(I),N(!1),console.log("✅ Dynamic page registry created successfully"))}catch(I){console.error("❌ Failed to create dynamic page registry:",I),k||(S(I.message||"Failed to create page registry"),A({login:{component:null},custom:{component:null},404:{component:null},default:{component:null}}),N(!1))}})(),()=>{k=!0}},[l,h]);const D={appData:l,loading:h,error:w,config:C,apiConfig:F,menu:l?.menu||[],routes:l?.routes||[],profileInfo:l?.profile_info||{},appLogo:x||l?.app_logo||"",appName:l?.app_name||"Zango CRM",metadata:l?.metadata||{},theme:l?.theme||{},layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,pageTypeRegistry:P,registryLoading:B,registryError:H,initializerEndpoint:v()};return s.jsx(_o.Provider,{value:D,children:e})},To=()=>{const e=G.useNavigate(),{routes:t}=Pe(),r=g.useCallback(a=>{if(!a)return!1;const n=a.endsWith("/")&&a!=="/"?a.slice(0,-1):a;return t.some(i=>{const c=i.path,d=c.endsWith("/")&&c!=="/"?c.slice(0,-1):c;if(d===n)return!0;if(d.includes(":")){const l=d.split("/").map(h=>h.startsWith(":")?"[^/]+":h).join("/");return new RegExp(`^${l}(/.*)?$`).test(n)}return i.exact===!1?n.startsWith(d):!1})},[t]);return{navigateTo:g.useCallback((a,n={})=>{if(a){if(a.startsWith("http://")||a.startsWith("https://")){n.newTab?window.open(a,"_blank"):window.location.href=a;return}r(a)?e(a,n):n.newTab?window.open(a,"_blank"):window.location.href=a}},[e,r]),isInternalRoute:r}},Mt=({to:e,children:t,className:r,onClick:o,...a})=>{const{isInternalRoute:n}=To(),i=d=>{o&&o(d)};return!(e&&(e.startsWith("http://")||e.startsWith("https://")))&&n(e)?s.jsx(G.Link,{to:e,className:r,onClick:i,...a,children:t}):s.jsx("a",{href:e,className:r,onClick:i,...a,children:t})},Ut=(e,t)=>{if(!e)return;e.querySelectorAll("svg").forEach(o=>{o.getAttribute("fill")&&o.getAttribute("fill")!=="none"&&o.setAttribute("fill",t),o.getAttribute("stroke")&&o.getAttribute("stroke")!=="none"&&o.setAttribute("stroke",t),o.querySelectorAll("*").forEach(n=>{n.getAttribute("fill")&&n.getAttribute("fill")!=="none"&&n.setAttribute("fill",t),n.getAttribute("stroke")&&n.getAttribute("stroke")!=="none"&&n.setAttribute("stroke",t)})})},wl=({appLogo:e,appName:t,linkTo:r="/app",collapsed:o=!1})=>{if(o){const a=t?t.charAt(0).toUpperCase():"A";return s.jsx("div",{className:"navbar-logo-container frame-logo-container",style:{padding:"16px",justifyContent:"center"},children:s.jsx(Mt,{to:r,style:{textDecoration:"none"},children:s.jsx("div",{className:"collapsed-logo-initial",style:{width:"32px",height:"32px",backgroundColor:"var(--color-brand-500, #5048ED)",color:"white",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:"bold"},children:a})})})}return s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:s.jsx(Pr,{logoUrl:e,appName:t,height:"28px",linkTo:r})})},No=({menuItems:e=[],appLogo:t,theme:r={},config:o={}})=>{const a=G.useLocation(),[n,i]=g.useState({}),{appName:c}=Pe(),d=g.useRef(null);g.useEffect(()=>{if(!d.current)return;const k=d.current.querySelector("#wideSidebarMenu");if(!k)return;k.querySelectorAll("li").forEach(I=>{const j=I.classList.contains("active"),L="var(--color-gray-700, #414651)",T="var(--color-brand-500, #5048ED)";Ut(I,j?T:L);const M=()=>{I.classList.contains("active")||Ut(I,T)},E=()=>{I.classList.contains("active")||Ut(I,L)};return I.addEventListener("mouseenter",M),I.addEventListener("mouseleave",E),()=>{I.removeEventListener("mouseenter",M),I.removeEventListener("mouseleave",E)}})},[a.pathname,e]);const l=(k,U)=>{const I=k.url||k.uri,j=I?.endsWith("/")?I:`${I}/`,L=U.endsWith("/")?U:`${U}/`;return j===L?!0:k.children?.length?k.children.some(T=>{const M=T.url||T.uri;return(M?.endsWith("/")?M:`${M}/`)===L}):!1},u=k=>{i(U=>({...U,[k]:!U[k]}))};g.useEffect(()=>{const k={};e.forEach(U=>{U.children?.length&&l(U,a.pathname)&&(k[U.name]=!0)}),i(k)},[a.pathname,e]);const h=k=>k.icon?k.icon.includes("<svg")?s.jsx("span",{className:"navbar-icon",dangerouslySetInnerHTML:{__html:k.icon}}):/^[\u{1F300}-\u{1F9FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]|[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(k.icon)||k.icon.length<=4?s.jsx("span",{className:"navbar-icon navbar-icon-emoji",children:k.icon}):s.jsx("span",{className:"navbar-icon",children:s.jsx("img",{src:k.icon,alt:k.name,width:"16",height:"16"})}):s.jsx("span",{className:"navbar-icon",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M1.66675 8.00002C1.66675 5.1802 1.66675 3.77029 2.46539 2.83519C2.5788 2.70241 2.70247 2.57874 2.83525 2.46533C3.77035 1.66669 5.18026 1.66669 8.00008 1.66669C10.8199 1.66669 12.2298 1.66669 13.1649 2.46533C13.2977 2.57874 13.4213 2.70241 13.5347 2.83519C14.3334 3.77029 14.3334 5.1802 14.3334 8.00002C14.3334 10.8198 14.3334 12.2298 13.5347 13.1648C13.4213 13.2976 13.2977 13.4213 13.1649 13.5347C12.2298 14.3334 10.8199 14.3334 8.00008 14.3334C5.18026 14.3334 3.77035 14.3334 2.83525 13.5347C2.70247 13.4213 2.5788 13.2976 2.46539 13.1648C1.66675 12.2298 1.66675 10.8198 1.66675 8.00002Z",stroke:"currentColor",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.69235 4.83562C7.83568 4.61038 8.16448 4.61038 8.30782 4.83562L8.72255 5.48724C9.18115 6.20782 9.79228 6.81896 10.5129 7.27756L11.1645 7.69229C11.3897 7.83562 11.3897 8.16442 11.1645 8.30776L10.5129 8.72249C9.79228 9.18109 9.18115 9.79222 8.72255 10.5128L8.30782 11.1644C8.16448 11.3897 7.83568 11.3897 7.69235 11.1644L7.27762 10.5128C6.81902 9.79222 6.20788 9.18109 5.4873 8.72249L4.83568 8.30776C4.61044 8.16442 4.61044 7.83562 4.83568 7.69229L5.4873 7.27756C6.20788 6.81896 6.81902 6.20782 7.27762 5.48724L7.69235 4.83562Z",stroke:"currentColor",strokeLinejoin:"round"})]})}),{showLogo:m=!0,showMenu:w=!0,isCollapsed:f=!1,collapsible:x=!1,customLogo:y=null,customMenuContent:P=null,customBottomContent:A=null,customNavbar:B=null,customMenu:N=null,menuConfig:H={},className:S="",style:v={}}=o,[C,F]=g.useState(f),D=C?"80px":"244px";return s.jsxs("nav",{ref:d,className:`navbar ${C?"collapsed-sidebar":"wide-sidebar"} ${S}`,style:{width:D,...v,display:"flex",flexDirection:"column",transition:"width 0.3s ease"},children:[m&&(y?s.jsx("div",{className:"navbar-logo-container frame-logo-container",children:y}):s.jsx(wl,{appLogo:t,appName:c,collapsed:C})),x&&s.jsx("div",{className:"navbar-toggle-container",style:{padding:"8px 16px",borderBottom:"1px solid var(--color-gray-200, #e5e7eb)"},children:s.jsx("button",{onClick:()=>F(!C),className:"navbar-toggle-btn",style:{width:"100%",padding:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background-color 0.2s ease"},onMouseEnter:k=>k.target.style.backgroundColor="var(--color-gray-100, #f3f4f6)",onMouseLeave:k=>k.target.style.backgroundColor="transparent",title:C?"Expand navbar":"Collapse navbar",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:C?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"var(--color-gray-600, #4b5563)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),s.jsx("div",{className:"navbar-menu-container frame-menu-container complete-hidden-scroll-style",style:{flex:1,overflow:"auto"},children:w&&(N||s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"navbar-menu wide-sidebar-menu",id:"wideSidebarMenu",children:e.map(k=>{const U=k.url||k.uri,I=l(k,a.pathname),j=n[k.name]||!1,L=k.children&&k.children.length>0;return s.jsxs(g.Fragment,{children:[s.jsx("li",{className:`menu-list-item ${L?"menu-list-item-with-sub-menu":""} ${I?"active":""}`,children:L?s.jsxs("div",{className:"menu-item",onClick:()=>!C&&u(k.name),style:{justifyContent:C?"center":"flex-start",padding:C?"8px":void 0},title:C?k.name:void 0,children:[h(k),!C&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`menu-title ${I?"font-semibold":""}`,children:k.name}),s.jsx("div",{className:`flex justify-center items-center h-full transition-transform duration-300 ease-in-out ${I&&j?"rotate-180":""}`,children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:s.jsx("path",{d:"M9.74976 3.99963C9.81538 3.99963 9.88053 4.01263 9.94116 4.03772C10.0018 4.06282 10.0569 4.09977 10.1033 4.14612C10.1496 4.19249 10.1865 4.24766 10.2117 4.30823C10.2368 4.36885 10.2497 4.43402 10.2498 4.49963C10.2498 4.56531 10.2368 4.63036 10.2117 4.69104C10.1865 4.75173 10.1497 4.8067 10.1033 4.85315L6.35327 8.60315C6.30685 8.64961 6.25184 8.68639 6.19116 8.71155C6.13048 8.73669 6.06544 8.75061 5.99976 8.75061C5.93412 8.75058 5.86899 8.73668 5.80835 8.71155C5.77819 8.69902 5.74944 8.6837 5.72241 8.66565L5.64624 8.60315L1.89624 4.85315C1.80256 4.75936 1.74976 4.6322 1.74976 4.49963C1.74981 4.36705 1.80248 4.23988 1.89624 4.14612C1.99 4.05236 2.11717 3.99969 2.24976 3.99963C2.38232 3.99963 2.50948 4.05244 2.60327 4.14612L5.99976 7.5426L9.39624 4.14612C9.44265 4.09971 9.49773 4.06286 9.55835 4.03772C9.61897 4.01261 9.68414 3.99966 9.74976 3.99963Z",fill:"#414651",stroke:"#414651",strokeWidth:"0.25"})})})]})]}):s.jsxs(Mt,{to:U,className:"menu-item",style:{justifyContent:C?"center":"flex-start",padding:C?"8px":void 0},title:C?k.name:void 0,children:[h(k),!C&&s.jsx("span",{className:`menu-title ${I?"font-semibold":""}`,children:k.name})]})}),L&&!C&&s.jsx("ul",{className:`submenu-list ${j?"active":""}`,children:k.children.map(T=>{const M=T.url||T.uri,E=a.pathname===M||a.pathname===`${M}/`;return s.jsx("li",{className:"submenu-list-item",children:s.jsxs(Mt,{to:M,className:`submenu-item d-flex ${E?"selected-each-wide-submenu":""}`,children:[s.jsx("span",{className:"submenu-item-icon-container",children:E?s.jsx("svg",{className:"w-3.5 h-2.5 inline-block",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:s.jsx("path",{d:"M13.3538 6.85375L10.3538 9.85375C10.2599 9.94757 10.1327 10.0003 10 10.0003C9.86732 10.0003 9.74007 9.94757 9.64625 9.85375C9.55243 9.75993 9.49972 9.63268 9.49972 9.5C9.49972 9.36732 9.55243 9.24007 9.64625 9.14625L11.7931 7H7C5.27665 6.99818 3.62441 6.31278 2.40582 5.09418C1.18722 3.87559 0.50182 2.22335 0.5 0.5C0.5 0.367392 0.552678 0.240215 0.646447 0.146447C0.740215 0.0526785 0.867392 0 1 0C1.13261 0 1.25979 0.0526785 1.35355 0.146447C1.44732 0.240215 1.5 0.367392 1.5 0.5C1.50165 1.95818 2.08165 3.35617 3.11274 4.38726C4.14383 5.41835 5.54182 5.99835 7 6H11.7931L9.64625 3.85375C9.55243 3.75993 9.49972 3.63268 9.49972 3.5C9.49972 3.36732 9.55243 3.24007 9.64625 3.14625C9.74007 3.05243 9.86732 2.99972 10 2.99972C10.1327 2.99972 10.2599 3.05243 10.3538 3.14625L13.3538 6.14625C13.4002 6.19269 13.4371 6.24783 13.4623 6.30853C13.4874 6.36923 13.5004 6.43429 13.5004 6.5C13.5004 6.56571 13.4874 6.63077 13.4623 6.69147C13.4371 6.75217 13.4002 6.80731 13.3538 6.85375Z",fill:"var(--color-brand-500, #5048ED)"})}):s.jsx("span",{className:"hidden"})}),s.jsx("span",{className:`text-xs ${E?"text-[var(--color-brand-500,#5048ED)]":"text-[var(--color-gray-700,#414651)]"}`,children:T.name})]})},M)})})]},k.name)})}),P&&!C&&s.jsx("div",{className:"custom-menu-content",style:{paddingTop:"8px"},children:P})]}))}),A&&s.jsx("div",{className:"navbar-bottom-content",style:{marginTop:"auto",flexShrink:0},children:A})]})},yl=(e=!0)=>{const[t,r]=g.useState(null),[o,a]=g.useState(!1),[n,i]=g.useState(null),[c,d]=g.useState(!1),[l,u]=g.useState(!1),h=async()=>{if(!(!e||t&&!c)){a(!0),i(null);try{const w=await Dr();if(w.success&&w.response){const f=w.response.profile_data||w.response;w.response.password_policy&&!f.password_policy&&(f.password_policy=w.response.password_policy),u(w.response.should_set_password||!1),r(f),i(null)}else{const f=w.response?.message||"Failed to fetch profile data";i(f),console.error("Profile API Error:",w)}}catch(w){const f=w.message||"Network error while fetching profile";i(f),console.error("Profile fetch error:",w)}finally{a(!1),d(!0)}}},m=()=>{d(!1),h()};return g.useEffect(()=>{e&&!c&&h()},[e]),{profileData:t,loading:o,error:n,refetch:m,shouldSetPassword:l}},Ne=(e,t="/",r=null)=>{let o=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`;r&&(o+=` domain=${r};`),document.cookie=o,r||(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t}; domain=${window.location.hostname};`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t};`)},yr=e=>{const t=e+"=",r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},Eo=(e,t,r=null,o="/",a=null)=>{let n="";if(r){const c=new Date;c.setTime(c.getTime()+r*24*60*60*1e3),n="; expires="+c.toUTCString()}let i=`${e}=${t}${n}; path=${o}`;a&&(i+=`; domain=${a}`),document.cookie=i},Fo=()=>{const e=yr("zangocookie");return e!==null&&e!==""},Oo=Object.freeze({__proto__:null,deleteCookie:Ne,getCookie:yr,isAuthenticatedViaCookie:Fo,setCookie:Eo}),Mo=async(e={})=>{try{const t=await Kr();if(t.success||t.responseStatus===401){Ne("zangocookie","/"),Ne("zangocookie","/app"),Ne("zangocookie","/app/"),Ne("zangocookie");const r=window.location.hostname;if(Ne("zangocookie","/",r),Ne("zangocookie","/app",r),r.includes(".")){const a="."+r.split(".").slice(-2).join(".");Ne("zangocookie","/",a),Ne("zangocookie","/app",a)}localStorage.removeItem("authToken"),localStorage.clear(),sessionStorage.clear();const o=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=o},100)}else p.toast.error({title:"Logout Failed",description:t.response?.message||"Unable to logout. Please try again.",duration:5e3})}catch(t){console.error("Logout error:",t),p.toast.error({title:"Logout Error",description:"An error occurred while logging out. Please try again.",duration:5e3});const r=e.redirectUrl||e.theme?.login_url||"/app/login";setTimeout(()=>{window.location.href=r},100)}},Uo=e=>{const t=document.createElement("div");t.style.cssText=`
124
143
  position: fixed;
125
144
  top: 0;
126
145
  left: 0;
@@ -168,10 +187,10 @@ export default App;`,w=`mkdir -p ${c}`,m={container:{padding:"32px",maxWidth:"90
168
187
  transition: all 0.2s;
169
188
  ">Log Out</button>
170
189
  </div>
171
- `;const o=r.querySelector("#cancel-logout"),a=r.querySelector("#confirm-logout");o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#b91c1c"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="#dc2626"}),o.addEventListener("click",()=>{document.body.removeChild(t)}),a.addEventListener("click",()=>{document.body.removeChild(t),e()}),t.addEventListener("click",i=>{i.target===t&&document.body.removeChild(t)});const n=i=>{i.key==="Escape"&&(document.removeEventListener("keydown",n),document.body.contains(t)&&document.body.removeChild(t))};document.addEventListener("keydown",n),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>o.focus(),100)},_o=({isOpen:e,onClose:t})=>{const[r,o]=f.useState("account"),[a,n]=f.useState(!1),[i,c]=f.useState(!1),[d,l]=f.useState(null),[u,h]=f.useState(!1),[w,m]=f.useState([]),[g,A]=f.useState(!1),[C,b]=f.useState(null),[_,O]=f.useState([]),[F,W]=f.useState(null),{appData:q}=Se(),{profileData:P,loading:S,error:z,refetch:V,shouldSetPassword:N}=ol(e),[M,K]=f.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[x,E]=f.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[v,k]=f.useState({}),[U,Z]=f.useState({}),[Q,$]=f.useState(""),[L,D]=f.useState(!1),[R,ae]=f.useState(null),[se,Ne]=f.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),Ee=async()=>{A(!0),b(null);try{const T=await Br();if(T.success&&T.response){const J=T.response.data||T.response;m(J),b(null)}else{const J=T.response?.message||"Failed to fetch sessions";b(J),console.error("Sessions API Error:",T)}}catch(T){const J=T.message||"Network error while fetching sessions";b(J),console.error("Sessions fetch error:",T)}finally{A(!1)}};f.useEffect(()=>{if(P){let T=P.last_password_changed||"Never",J=null;if(P.last_password_changed&&P?.password_policy?.password_expiry_days){const re=new Date(P.last_password_changed),Je=new Date(re);Je.setDate(Je.getDate()+P.password_policy.password_expiry_days),Je>new Date?J=Je.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):J="Expired"}K({name:P.name||"",email:P.email||"",mobile:P.mobile||"",roles:P.roles||[],currentRole:q?.profile_info?.user_role||P.roles?.[0]?.name||"Admin",lastPasswordChange:T,nextPasswordDue:J}),h(P.auth_config?.two_factor_auth?.required||!1),P.profile_pic&&l(P.profile_pic);let X=null;P.auth_config?.password_policy?X=P.auth_config.password_policy:P.password_policy&&(X=P.password_policy),X?(console.log("Setting password policy from profileData.auth_config.password_policy:",X),W(X)):console.log("No password policy found in profileData:",{auth_config_password_policy:P.auth_config?.password_policy,password_policy:P.password_policy}),P.tokens&&O(P.tokens)}P&&P.tokens&&O(P.tokens),q?.sessions?.tokens&&O(q.sessions.tokens),q?.password_policy&&W(q.password_policy)},[P,q]);const lt=(T,J)=>{const X=T.user_agent||T.browser_agent||"Unknown Browser",re=T.ip||T.location||"Unknown Location",Je=T.created_at,Ge=T.last_seen_at,Sl=pe=>pe.includes("Chrome")?"Chrome":pe.includes("Firefox")?"Firefox":pe.includes("Safari")?"Safari":pe.includes("Edge")?"Edge":"Unknown Browser",kl=pe=>pe.includes("Mac")?"macOS":pe.includes("Windows")?"Windows":pe.includes("Linux")?"Linux":pe.includes("iPhone")||pe.includes("iOS")?"iOS":pe.includes("Android")?"Android":"Unknown OS",Uo=pe=>{if(!pe)return"Unknown";const pr=pe.replace(" IST",""),fr=new Date(pr),Ll=new Date().getTime()-fr.getTime(),Mt=Math.floor(Ll/1e3),Ut=Math.floor(Mt/60),Bt=Math.floor(Ut/60),gr=Math.floor(Bt/24);return gr>0?`${gr} day${gr>1?"s":""} ago`:Bt>0?`${Bt} hour${Bt>1?"s":""} ago`:Ut>0?`${Ut} minute${Ut>1?"s":""} ago`:Mt>0?`${Mt} second${Mt>1?"s":""} ago`:"Just now"},Al=Sl(X),Bo=kl(X),_l=()=>{if(T.is_current)return!0;if(!Ge)return!1;const pe=typeof Ge=="string"?Ge.replace(" IST",""):Ge,pr=new Date(pe),fr=new Date(Date.now()-3600*1e3);return pr>fr};return{...T,deviceName:`${Al} on ${Bo}`,os:Bo,location:re==="127.0.0.1"?"Local Device":re,sessionStartTime:Uo(Je),lastSeen:Uo(Ge),isActive:_l()}};f.useEffect(()=>{const{newPassword:T}=x;console.log("Password validation useEffect triggered:",{newPassword:T,passwordPolicy:F}),F?(console.log("Using password policy for validation:",F),Ne({minLength:T.length>=(F.min_length||8),hasUpperCase:F.require_uppercase?/[A-Z]/.test(T):!0,hasLowerCase:F.require_lowercase?/[a-z]/.test(T):!0,hasNumber:F.require_numbers?/[0-9]/.test(T):!0,hasSpecialChar:F.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(T):!0})):(console.log("No password policy found, using default validation"),Ne({minLength:T.length>=8,hasUpperCase:/[A-Z]/.test(T),hasLowerCase:/[a-z]/.test(T),hasNumber:/[0-9]/.test(T),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(T)}))},[x.newPassword,F]);const[Ke,hr]=f.useState(e);f.useEffect(()=>{e&&!Ke&&(V&&V(),Ee(),n(!1),c(!1),k({}),Z({}),$(""),E({currentPassword:"",newPassword:"",confirmPassword:""})),hr(e)},[e,Ke,V]),f.useEffect(()=>{r==="security"&&e&&Ee()},[r,e]);const Ot=T=>{const{name:J,value:X}=T.target;K(re=>({...re,[J]:X})),k(re=>({...re,[J]:""}))},Ce=T=>{const{name:J,value:X}=T.target;E(re=>({...re,[J]:X})),Z(re=>({...re,[J]:""}))},Ft=()=>{const T={};return M.name.trim()||(T.name="Name is required"),T},wl=async T=>{const J=T.target.files?.[0];if(J){const X=new FormData;X.append("profile_pic",J);try{const re=await dt(X);re.success?(l(re.response?.profile_pic||URL.createObjectURL(J)),$("Profile photo updated successfully!")):$(re.response?.message||"Failed to upload photo")}catch{$("Failed to upload photo")}}},Fo=async()=>{try{const T=!u,J={two_factor_auth:{required:T}},X=new FormData;X.append("auth_config",JSON.stringify(J));const re=await dt(X);re.success?(h(T),$(`Two-factor authentication ${T?"enabled":"disabled"}`),p.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${T?"enabled":"disabled"} successfully`,duration:3e3})):($(re.response?.message||"Failed to update two-factor authentication"),p.toast.error({title:"Update Failed",description:re.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{$("Failed to update two-factor authentication"),p.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},Mo=async T=>{try{const J=await Vr(T);J.success?(Ee(),$("Session logged out successfully")):$(J.response?.message||"Failed to logout session")}catch{$("Failed to logout session")}},yl=async()=>{try{const T=w.filter(X=>!X.is_current).map(X=>X.id),J=await $r(T);J.success?($("All other sessions logged out successfully"),Ee()):$(J.response?.message||"Failed to logout all sessions")}catch{$("Failed to logout all sessions")}},bl=()=>{const T={};return!N&&!x.currentPassword&&(T.currentPassword="Current password is required"),x.newPassword?Object.values(se).some(X=>!X)&&(T.newPassword="Password must meet all requirements"):T.newPassword=N?"Password is required":"New password is required",x.newPassword!==x.confirmPassword&&(T.confirmPassword="Passwords do not match"),T},Cl=async T=>{T.preventDefault();const J=Ft();if(Object.keys(J).length>0){k(J);return}D(!0),$("");try{const X=new FormData;X.append("name",M.name);const re=await dt(X);re.success?($("Name updated successfully!"),n(!1),setTimeout(()=>{$("")},3e3)):$(re.response?.message||"Failed to update name")}catch{$("An error occurred. Please try again.")}finally{D(!1)}},vl=async T=>{T.preventDefault();const J=bl();if(Object.keys(J).length>0){Z(J);return}D(!0),$("");try{const X={new_password:x.newPassword};N||(X.current_password=x.currentPassword);const re=await Ir(X);re.success?($(N?"Password set successfully!":"Password changed successfully!"),E({currentPassword:"",newPassword:"",confirmPassword:""}),c(!1),V&&V(),setTimeout(()=>{$("")},3e3)):$(re.response?.message||"Failed to change password")}catch{$("An error occurred. Please try again.")}finally{D(!1)}},xl=async T=>{ae(T);try{const J=await qr(T);J.success?(p.toast.success({title:"Role Switched",description:"Role switched successfully! Redirecting...",duration:2e3}),setTimeout(()=>{window.location.href="/app"},1e3)):(p.toast.error({title:"Role Switch Failed",description:J.response?.message||"Failed to switch role",duration:5e3}),ae(null))}catch{p.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),ae(null)}},Pl=()=>{Ao(()=>{ko({redirectUrl:"/app/login"})})};return s.jsxs("div",{className:`user-profile-drawer ${e?"open":""}`,children:[s.jsx("div",{className:"profile-header-gradient",children:s.jsx("button",{className:"profile-close-btn",onClick:t,children:s.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),S&&s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280"},children:"Loading profile..."})]}),L&&s.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:s.jsxs("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.1)"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280",fontSize:"16px"},children:"Updating password..."})]})}),z&&!S&&s.jsxs("div",{style:{margin:"1rem 1.5rem",padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s.jsx("svg",{style:{height:"20px",width:"20px",color:"#f87171",marginRight:"8px"},viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),s.jsx("span",{style:{color:"#b91c1c",fontWeight:"500"},children:"Failed to load profile"})]}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"4px",marginBottom:"8px"},children:z}),s.jsx("button",{onClick:V,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!S&&!z&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"profile-info-section",children:[s.jsx("div",{className:"profile-avatar-container",children:s.jsxs("div",{className:"profile-avatar-circle",children:[d?s.jsx("img",{src:d,alt:"Profile",className:"profile-avatar-img"}):M.name?s.jsx("span",{className:"profile-initials",children:M.name.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2)}):s.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M20 20C23.6819 20 26.6667 17.0152 26.6667 13.3333C26.6667 9.65143 23.6819 6.66667 20 6.66667C16.3181 6.66667 13.3333 9.65143 13.3333 13.3333C13.3333 17.0152 16.3181 20 20 20ZM20 20C13.3726 20 8 25.3726 8 32C8 33.1046 8.89543 34 10 34H30C31.1046 34 32 33.1046 32 32C32 25.3726 26.6274 20 20 20Z",stroke:"#6B7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),s.jsxs("label",{className:"profile-avatar-edit",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:wl,hidden:!0}),s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M2.52121 10.8728L2 14L5.12724 13.4788C5.67029 13.3883 6.1715 13.1304 6.56079 12.7411L13.6132 5.68859C14.1289 5.17281 14.1289 4.3366 13.6131 3.82084L12.1791 2.38682C11.6633 1.87105 10.8271 1.87106 10.3113 2.38685L3.25894 9.43933C2.86965 9.8286 2.61171 10.3298 2.52121 10.8728Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),s.jsxs("div",{className:"profile-name-section",children:[s.jsx("h2",{className:"profile-user-name",children:M.name||"Welcome!"}),s.jsxs("div",{className:"profile-user-role-badge",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M9.5 6.5V4.5C9.5 3.39543 8.60457 2.5 7.5 2.5H6.5C5.39543 2.5 4.5 3.39543 4.5 4.5V6.5M3 6.5H11C11.5523 6.5 12 6.94772 12 7.5V10.5C12 11.0523 11.5523 11.5 11 11.5H3C2.44772 11.5 2 11.0523 2 10.5V7.5C2 6.94772 2.44772 6.5 3 6.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"7",cy:"9",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{children:M.currentRole})]})]})]}),s.jsx("div",{className:"profile-main-content",children:s.jsxs("div",{className:"profile-content-wrapper",children:[s.jsxs("div",{className:"profile-tabs",children:[s.jsx("button",{className:`profile-tab ${r==="account"?"active":""}`,onClick:()=>{o("account"),n(!1),$("")},children:"Account"}),s.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{o("security"),c(!1),$("")},children:"Security"})]}),Q&&s.jsx("div",{className:`profile-alert ${Q.includes("successfully")?"success":"error"}`,children:s.jsx("span",{children:Q})}),v.general&&s.jsx("div",{className:"profile-alert error",children:s.jsx("span",{children:v.general})}),s.jsx("div",{className:"profile-tab-content",children:r==="account"?s.jsxs("div",{className:"account-section",children:[!M.name&&!M.email&&!M.mobile&&s.jsxs("div",{className:"welcome-banner",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"rgba(80, 72, 237, 0.1)"}),s.jsx("path",{d:"M24 16V20M24 28H24.01M34 24C34 29.5228 29.5228 34 24 34C18.4772 34 14 29.5228 14 24C14 18.4772 18.4772 14 24 14C29.5228 14 34 18.4772 34 24Z",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("h3",{children:"Complete Your Profile"}),s.jsx("p",{children:"Add your name and other details to personalize your account. Click the edit button next to each field to get started."})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsxs("div",{className:"profile-field-header",children:[s.jsx("label",{className:"profile-field-label",children:"Name"}),!a&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>n(!0),children:"Edit"})]}),a?s.jsxs("form",{onSubmit:Cl,className:"profile-inline-form",children:[s.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:M.name,onChange:Ot,placeholder:"Enter your full name",autoFocus:!0}),s.jsxs("div",{className:"profile-inline-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{n(!1),k({}),K(T=>({...T,name:P?.name||""}))},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-save-btn",disabled:L,children:L?"Saving...":"Save"})]}),v.name&&s.jsx("div",{className:"profile-form-error",children:v.name})]}):s.jsx("div",{className:"profile-field-value",children:M.name||s.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),M.email&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Email"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M2.66667 5.33333L7.2786 8.60289C7.67788 8.86886 8.32212 8.86886 8.7214 8.60289L13.3333 5.33333M4 12H12C12.7364 12 13.3333 11.4031 13.3333 10.6667V5.33333C13.3333 4.59695 12.7364 4 12 4H4C3.26362 4 2.66667 4.59695 2.66667 5.33333V10.6667C2.66667 11.4031 3.26362 12 4 12Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),M.email]})]}),M.mobile&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Mobile Number"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M5.33333 2.66667H10.6667C11.4031 2.66667 12 3.26362 12 4V12C12 12.7364 11.4031 13.3333 10.6667 13.3333H5.33333C4.59695 13.3333 4 12.7364 4 12V4C4 3.26362 4.59695 2.66667 5.33333 2.66667ZM5.33333 2.66667V3.33333C5.33333 3.70152 5.63181 4 6 4H10C10.3682 4 10.6667 3.70152 10.6667 3.33333V2.66667M8 11.3333H8.00667",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),M.mobile]})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Roles"}),s.jsx("div",{className:"roles-list",children:M.roles&&M.roles.length>0?M.roles.map((T,J)=>s.jsxs("div",{className:`role-item ${T.name===M.currentRole?"active":""}`,children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:T.name})]}),T.name===M.currentRole?s.jsx("span",{className:"role-badge",children:"Current"}):s.jsx("button",{className:"role-switch-btn",onClick:()=>xl(T.id),disabled:R!==null,children:R===T.id?"Switching...":"Switch"})]},T.id)):s.jsxs("div",{className:"role-item active",children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:M.currentRole||"Admin"})]}),s.jsx("span",{className:"role-badge",children:"Current"})]})})]}),s.jsx("div",{className:"profile-field-section logout-section",children:s.jsxs("button",{className:"logout-button",onClick:Pl,children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"currentColor",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{children:"Log Out"})]})})]}):s.jsxs("div",{className:"security-section",children:[s.jsxs("div",{className:"security-block",children:[s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"security-title",children:["Password",F&&!F.allow_change&&s.jsx("span",{className:"password-disabled-badge",children:"Disabled"})]}),!N&&s.jsxs("p",{className:"security-subtitle",children:["Last changed: ",M.lastPasswordChange,M.nextPasswordDue&&s.jsxs(s.Fragment,{children:[" • ",s.jsxs("span",{className:M.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",M.nextPasswordDue]})]})]}),N&&s.jsx("p",{className:"security-subtitle",children:"Set your password to secure your account"})]}),!i&&F?.allow_change!==!1&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>{c(!0),E({currentPassword:"",newPassword:"",confirmPassword:""}),Z({})},children:N?"Set Password":"Change Password"})]}),i&&s.jsxs("form",{onSubmit:vl,className:"password-form",children:[!N&&s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Current Password"}),s.jsx("input",{type:"password",name:"currentPassword",className:"profile-form-input",value:x.currentPassword,onChange:Ce,placeholder:"Enter current password",autoComplete:"new-password"}),U.currentPassword&&s.jsx("div",{className:"profile-form-error",children:U.currentPassword})]}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:N?"Password":"New Password"}),s.jsx("input",{type:"password",name:"newPassword",className:"profile-form-input",value:x.newPassword,onChange:Ce,placeholder:N?"Enter password":"Enter new password",autoComplete:"new-password"}),U.newPassword&&s.jsx("div",{className:"profile-form-error",children:U.newPassword})]}),s.jsx("div",{className:"password-requirements",children:F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`password-requirement ${se.minLength?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsxs("span",{children:["Minimum ",F.min_length," characters"]})]}),F.require_uppercase&&s.jsxs("div",{className:`password-requirement ${se.hasUpperCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One uppercase character"})]}),F.require_lowercase&&s.jsxs("div",{className:`password-requirement ${se.hasLowerCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One lowercase character"})]}),F.require_numbers&&s.jsxs("div",{className:`password-requirement ${se.hasNumber?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One number"})]}),F.require_special_chars&&s.jsxs("div",{className:`password-requirement ${se.hasSpecialChar?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One special character"})]})]})}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Confirm Password"}),s.jsx("input",{type:"password",name:"confirmPassword",className:"profile-form-input",value:x.confirmPassword,onChange:Ce,placeholder:N?"Confirm password":"Confirm new password",autoComplete:"new-password"}),U.confirmPassword&&s.jsx("div",{className:"profile-form-error",children:U.confirmPassword})]}),s.jsxs("div",{className:"profile-form-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{c(!1),Z({}),E({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:L,children:L?N?"Setting...":"Updating...":N?"Set Password":"Update Password"})]})]})]}),s.jsx("div",{className:"security-block",children:s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Two-Factor Authentication"}),s.jsxs("p",{className:"security-subtitle",children:[u?"Enabled":"Disabled"," ",u?"":" - Add an extra layer of security"]}),!u&&P?.auth_config?.two_factor_auth?.can_enable===!1&&P?.auth_config?.two_factor_auth?.issue&&s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"8px"},children:P.auth_config.two_factor_auth.issue})]}),!u&&P?.auth_config?.two_factor_auth?.can_enable===!0&&s.jsx("button",{className:"toggle-btn",onClick:Fo,children:"Enable"}),u&&P?.auth_config?.two_factor_auth?.can_disable===!0&&s.jsx("button",{className:"toggle-btn enabled",onClick:Fo,children:"Disable"})]})}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Where you're logged in"}),s.jsx("p",{className:"security-subtitle",children:"Manage your active sessions"})]})}),s.jsx("div",{className:"sessions-list",children:g?s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"small"}),s.jsx("span",{style:{marginLeft:"8px",color:"#6b7280"},children:"Loading sessions..."})]}):C?s.jsxs("div",{style:{padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",textAlign:"center"},children:[s.jsx("p",{style:{color:"#b91c1c",margin:"0 0 8px 0"},children:"Failed to load sessions"}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",margin:"0 0 8px 0"},children:C}),s.jsx("button",{onClick:Ee,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):w.length>0?w.map((T,J)=>{const X=lt(T);return s.jsxs("div",{className:"session-item",children:[s.jsx("div",{className:"session-info",children:s.jsxs("div",{className:"session-device",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.5 4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V12.5C17.5 13.4205 16.7538 14.1667 15.8333 14.1667H4.16667C3.24619 14.1667 2.5 13.4205 2.5 12.5V4.16667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.66667 17.5H13.3333",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 14.1667V17.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"session-device-header",children:[s.jsx("p",{className:"session-device-name",children:X.deviceName}),T.is_current?s.jsx("span",{className:"session-status-tag current",children:"Current"}):X.isActive?s.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>Mo(T.id),children:"Logout"}):s.jsx("button",{className:"logout-tag-btn",onClick:()=>Mo(T.id),children:"Logout"})]}),s.jsxs("p",{className:"session-details",children:[X.os," • ",X.location]})]})]})}),s.jsx("div",{className:"session-time",children:s.jsxs("div",{className:"session-time-info",children:[s.jsxs("p",{className:"session-start-time",children:["Started: ",X.sessionStartTime]}),s.jsx("p",{className:"session-last-active",children:X.isActive?"Active now":`Last seen: ${X.lastSeen}`})]})})]},T.id||J)}):s.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),w.length>1&&s.jsx("button",{className:"logout-all-btn",onClick:yl,children:"Sign me out of all other sessions"})]}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Authentication Tokens"}),s.jsx("p",{className:"security-subtitle",children:"Manage your bearer tokens for API authentication"})]})}),s.jsx("div",{className:"tokens-list",children:_&&_.length>0?_.map((T,J)=>s.jsx("div",{className:"token-item",children:s.jsx("div",{className:"token-info",children:s.jsxs("div",{className:"token-details",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M15 8.33333V6.66667C15 4.08934 12.9107 2 10.3333 2H9.66667C7.08934 2 5 4.08934 5 6.66667V8.33333M6.66667 8.33333H13.3333C14.2538 8.33333 15 9.07953 15 10V15C15 15.9205 14.2538 16.6667 13.3333 16.6667H6.66667C5.74619 16.6667 5 15.9205 5 15V10C5 9.07953 5.74619 8.33333 6.66667 8.33333Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"10",cy:"12.5",r:"1.25",fill:"currentColor"})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"token-name",children:[T.role," - Bearer Token"]}),s.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),s.jsxs("p",{className:"token-created",children:["Created: ",new Date(T.created).toLocaleDateString()]}),T.expiry?s.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(T.expiry).toLocaleDateString()]}):s.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},J)):s.jsxs("div",{className:"no-tokens",children:[s.jsx("p",{children:"No authentication tokens found"}),s.jsx("p",{className:"no-tokens-hint",children:"Bearer tokens will appear here for API authentication"})]})})]})]})})]})})]})]})},al=({onLogout:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-logout ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"#717680",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"#717680",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"Log Out"})]}),nl=({onViewProfile:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-view ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M8.00004 7.33329C9.47281 7.33329 10.6667 6.13948 10.6667 4.66663C10.6667 3.19377 9.47281 1.99996 8.00004 1.99996C6.52719 1.99996 5.33337 3.19377 5.33337 4.66663C5.33337 6.13948 6.52719 7.33329 8.00004 7.33329Z",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M4.00004 14V12.6666C4.00004 11.9594 4.28099 11.2811 4.78109 10.781C5.28119 10.2809 5.95947 9.99996 6.66671 9.99996H9.33337C10.0406 9.99996 10.7189 10.2809 11.219 10.781C11.7191 11.2811 12 11.9594 12 12.6666V14",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"View Profile"})]}),Lo=({profileInfo:e,theme:t={},config:r={}})=>{const[o,a]=f.useState(!1),[n,i]=f.useState(!1),[c,d]=f.useState(!1),[l,u]=f.useState(null),h=f.useRef(null);H.useNavigate(),f.useEffect(()=>{const v=k=>{h.current&&!h.current.contains(k.target)&&(a(!1),i(!1))};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const w=()=>{a(!o),o||i(!1)},m=()=>{Ao(()=>{ko({theme:t})})},g=v=>{window.location.href=v},A=e?.current_role||e?.user_role,C=e?.other_roles||[],{showProfile:b=!0,showLeftSection:_=!0,showRightSection:O=!0,customLeftContent:F=null,customRightContent:W=null,customProfileMenu:q=null,customViewProfile:P=null,profileMenuConfig:S={},className:z="",style:V={}}=r,{showViewProfile:N=!0,showLogout:M=!0,showRoleSwitch:K=!0,customMenuItems:x=[]}=S,E=()=>{d(!0),a(!1)};return s.jsxs("header",{className:`topbar header-container ${z}`,style:V,children:[s.jsxs("div",{className:"topbar-content",children:[_&&s.jsx("div",{className:"topbar-left",children:F||null}),O&&s.jsxs("div",{className:"topbar-right",children:[W,b&&s.jsxs("div",{className:"dropdown profile-dropdown-container",ref:h,children:[s.jsxs("div",{className:"profile-dropdown-menu-button",onClick:w,children:[s.jsxs("div",{className:"profile-info-wrapper",children:[s.jsx("img",{src:e?.profile_pic||`https://ui-avatars.com/api/?name=${encodeURIComponent(e?.name||"User")}&background=${Qr("brand",500).split("#")[1]}&color=fff`,alt:"Profile",className:"profile-avatar"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"profile-name",children:e?.name||"User"}),s.jsx("span",{className:"text-[12px] text-gray-600",children:A})]})]}),s.jsx("svg",{className:`dropdown-arrow ${o?"open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M13.3538 6.35354L8.35378 11.3535C8.30735 11.4 8.2522 11.4369 8.1915 11.4621C8.13081 11.4872 8.06574 11.5002 8.00003 11.5002C7.93433 11.5002 7.86926 11.4872 7.80856 11.4621C7.74786 11.4369 7.69272 11.4 7.64628 11.3535L2.64628 6.35354C2.55246 6.25972 2.49976 6.13247 2.49976 5.99979C2.49976 5.86711 2.55246 5.73986 2.64628 5.64604C2.7401 5.55222 2.86735 5.49951 3.00003 5.49951C3.13272 5.49951 3.25996 5.55222 3.35378 5.64604L8.00003 10.2929L12.6463 5.64604C12.6927 5.59958 12.7479 5.56273 12.8086 5.53759C12.8693 5.51245 12.9343 5.49951 13 5.49951C13.0657 5.49951 13.1308 5.51245 13.1915 5.53759C13.2522 5.56273 13.3073 5.59958 13.3538 5.64604C13.4002 5.69249 13.4371 5.74764 13.4622 5.80834C13.4874 5.86904 13.5003 5.93409 13.5003 5.99979C13.5003 6.06549 13.4874 6.13054 13.4622 6.19124C13.4371 6.25193 13.4002 6.30708 13.3538 6.35354Z",fill:"#414651"})})]}),s.jsxs("ul",{className:`profile-dropdown-menu ${o?"show":""}`,children:[C.length>0&&n&&s.jsx("li",{children:s.jsx("div",{className:"profile-roles complete-hidden-scroll-style",children:C.map((v,k)=>s.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>g(v.url),children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("g",{clipPath:"url(#clip0_1427_392)",children:s.jsx("path",{d:"M0.833374 7.99998C0.833374 4.04198 4.04204 0.833313 8.00004 0.833313C11.958 0.833313 15.1667 4.04198 15.1667 7.99998C15.1667 11.958 11.958 15.1666 8.00004 15.1666C4.04204 15.1666 0.833374 11.958 0.833374 7.99998ZM8.00004 1.83331C4.59404 1.83331 1.83337 4.59398 1.83337 7.99998C1.83337 9.58131 2.42804 11.0233 3.40671 12.1146L3.60604 11.7646C4.28871 10.5706 5.55871 9.83331 6.93471 9.83331H9.06604C10.4414 9.83331 11.7114 10.5706 12.394 11.7646L12.5934 12.114C13.572 11.0226 14.1667 9.58065 14.1667 7.99998C14.1667 4.59398 11.406 1.83331 8.00004 1.83331ZM11.8454 12.8206L11.5254 12.2606C11.0214 11.378 10.0827 10.8333 9.06604 10.8333H6.93471C5.91804 10.8333 4.97871 11.378 4.47471 12.2606L4.15471 12.8213C5.20871 13.6633 6.54537 14.1666 8.00004 14.1666C9.45471 14.1666 10.7914 13.6633 11.8454 12.8206ZM5.66671 6.33331C5.66671 5.04465 6.71137 3.99998 8.00004 3.99998C9.28871 3.99998 10.3334 5.04465 10.3334 6.33331C10.3334 7.62198 9.28871 8.66665 8.00004 8.66665C6.71137 8.66665 5.66671 7.62198 5.66671 6.33331ZM8.00004 4.99998C7.26337 4.99998 6.66671 5.59665 6.66671 6.33331C6.66671 7.06998 7.26337 7.66665 8.00004 7.66665C8.73671 7.66665 9.33337 7.06998 9.33337 6.33331C9.33337 5.59665 8.73671 4.99998 8.00004 4.99998Z",fill:"#717680"})}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_1427_392",children:s.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),s.jsx("span",{className:"label",children:v.label})]},k))})}),s.jsx("li",{children:s.jsx("hr",{className:"profile-dropdown-divider"})}),x.map((v,k)=>s.jsx("li",{children:v},k)),N&&s.jsx("li",{children:s.jsx(nl,{onViewProfile:E})}),M&&s.jsx("li",{children:s.jsx(al,{onLogout:m})})]})]})]})]}),P?P({user:e,isOpen:c,onClose:()=>d(!1)}):s.jsx(_o,{isOpen:c,onClose:()=>d(!1),profileData:l})]})},il={showTopbar:!0,showNavbar:!0,layoutType:"wide"},ll={showProfile:!0,showLeftSection:!0,showRightSection:!0,customLeftContent:null,customRightContent:null,customProfileMenu:null,customTopbar:null,customViewProfile:null,profileMenuConfig:{showViewProfile:!0,showLogout:!0,showRoleSwitch:!0,customMenuItems:[]},className:"",style:{}},cl={showLogo:!0,showMenu:!0,isCollapsed:!1,collapsible:!1,customLogo:null,customMenuContent:null,customBottomContent:null,customNavbar:null,customMenu:null,menuConfig:{showIcons:!0,showSubmenus:!0,expandOnHover:!1,customMenuItemRenderer:null},className:"",style:{}},Tt=(e={},t={})=>{const r={...t};return Object.keys(e).forEach(o=>{if(e[o]===void 0||e[o]===null)return;e[o]&&(e[o].$$typeof||typeof e[o]=="function")||typeof e[o]=="function"||Array.isArray(e[o])?r[o]=e[o]:typeof e[o]=="object"&&typeof t[o]=="object"&&!Array.isArray(t[o])?r[o]=Tt(e[o],t[o]):r[o]=e[o]}),r},No=()=>{const{loading:e,error:t,menu:r,profileInfo:o,appLogo:a,theme:n={},layoutConfig:i={},topbarConfig:c={},navbarConfig:d={},customComponents:l={}}=Se(),u=H.useLocation(),h=Tt(i,il),w=Tt(c,ll),m=Tt(d,cl),g=()=>{const q=document.getElementById("contentSpinner");q&&q.classList.add("active")},A=()=>{const q=document.getElementById("contentSpinner");q&&q.classList.remove("active")};if(f.useEffect(()=>{g();const q=300,P=Date.now(),S=setTimeout(()=>{const z=Date.now()-P;z>=q?A():setTimeout(A,q-z)},500);return()=>{clearTimeout(S)}},[u.pathname]),f.useEffect(()=>(window.addEventListener("beforeunload",g),()=>{window.removeEventListener("beforeunload",g)}),[]),e)return s.jsx("div",{className:"layout-loading",children:"Loading..."});if(t)return s.jsxs("div",{className:"layout-error",children:["Error: ",t]});const C=h.layoutType||n?.layout||"wide",b=h.showNavbar&&n?.menu_config?.display_sidebar!==!1,_=h.showTopbar,O=l?.Layout,F=l?.Topbar||w.customTopbar,W=l?.Navbar||m.customNavbar;return O?s.jsx(O,{menu:r,profileInfo:o,appLogo:a,theme:n,layoutConfig:h,topbarConfig:w,navbarConfig:m,children:s.jsx(H.Outlet,{})}):s.jsx("div",{className:`layout layout-${C}`,children:s.jsxs("main",{className:"layout-wrapper",children:[b&&(W?s.jsx(W,{menuItems:r,appLogo:a,theme:n,config:m}):s.jsx(vo,{menuItems:r,appLogo:a,theme:n,config:m})),s.jsxs("div",{className:"layout-main",style:{width:b?`calc(100vw - ${m.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[_&&(F?s.jsx(F,{profileInfo:o,theme:n,config:w}):s.jsx(Lo,{profileInfo:o,theme:n,config:w})),s.jsxs("div",{className:"layout-content",children:[s.jsx("div",{className:"content-spinner-container",id:"contentSpinner",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),s.jsx(H.Outlet,{})]})]})]})})},dl=(e,t,r)=>{const o=t[e]||t.default;if(o.handler)return o.handler(r);let a=o.propsBuilder?o.propsBuilder({...r,pageType:e}):{};o.includeBasePath!==!1&&r.matchedRoutePath&&(a={basePath:r.matchedRoutePath,...a});const i=o.component;return f.createElement(i,a)},it=({customPages:e={},forceRoute:t})=>{const r=H.useLocation(),{routes:o,pageTypeRegistry:a,registryLoading:n,registryError:i,initializerEndpoint:c}=Se(),d=Re(),[l,u]=f.useState({pageType:null,customPagePath:null,matchedRoutePath:null,loading:!0});if(f.useEffect(()=>{u(C=>({...C,loading:!0})),(()=>{const C=r.pathname;if(t){u({pageType:t.page_type,customPagePath:t.component||null,matchedRoutePath:t.path,loading:!1});return}if(r.state&&r.state.page_type&&(r.state.page_type!=="custom"||r.state.custom_page_path)){let b=C;if(o&&o.length>0){for(const _ of o)if(C===_.path||C.startsWith(_.path+"/")){b=_.path;break}}u({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:b,loading:!1});return}if(o&&o.length>0){const b=[...o].sort((_,O)=>{const F=_.path.split("/").filter(q=>q).length;return O.path.split("/").filter(q=>q).length-F});for(const _ of b){let O=H.matchPath({path:_.path,exact:!0},C);if(!O&&C.startsWith(_.path+"/")){const F=_.path.endsWith("/*")?_.path:`${_.path}/*`;O=H.matchPath({path:F,exact:!1},C)}if(O){u({pageType:_.page_type,customPagePath:_.component||null,matchedRoutePath:_.path,loading:!1});return}}}u({pageType:"404",customPagePath:null,matchedRoutePath:null,loading:!1})})()},[r,o,t]),l.loading||n)return s.jsx("div",{className:"content-spinner-container active",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})});if(i)return s.jsxs("div",{style:{padding:"24px",color:"#f04438"},children:["Failed to load page registry: ",i]});if(!a)return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",textAlign:"center",padding:"24px"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"32px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.05)",maxWidth:"500px",width:"100%",border:"1px solid #e1e3e6"},children:[s.jsx("h1",{style:{fontSize:"32px",margin:"0",color:"#f04438",fontWeight:"bold",lineHeight:"1"},children:"⚠️"}),s.jsx("h3",{style:{fontSize:"18px",margin:"12px 0",color:"#252b37",fontWeight:"600"},children:"Configuration Issue"}),s.jsx("p",{style:{fontSize:"14px",color:"#717680",marginBottom:"16px",lineHeight:"1.5"},children:"Unable to load page configuration from:"}),s.jsx("code",{style:{display:"block",backgroundColor:"#f9fafb",border:"1px solid #e1e3e6",borderRadius:"4px",padding:"8px 12px",fontSize:"12px",color:"#252b37",fontFamily:"Monaco, Menlo, monospace",marginBottom:"16px",wordBreak:"break-all"},children:c}),s.jsx("p",{style:{fontSize:"13px",color:"#8b909a",margin:"0"},children:"Please check your configuration or contact your administrator."})]})});const{pageType:h,customPagePath:w,matchedRoutePath:m}=l,g=`${h}-${w||"default"}-${m||"none"}`;return s.jsx("div",{className:"h-full",children:dl(h,a,{matchedRoutePath:m,customPagePath:w,customPages:e,location:r,apiConfig:d})},g)},Eo=()=>{const{metadata:e,appName:t,apiConfig:r,theme:o}=Se(),a=f.useRef(new Set),n=()=>{a.current.forEach(d=>{d.parentNode&&d.parentNode.removeChild(d)}),a.current.clear()},i=(d,l,u)=>{let h=document.querySelector(d);return h||(h=l(),document.head.appendChild(h),a.current.add(h)),u(h),h},c=(d,l="image")=>new Promise((u,h)=>{const w=document.createElement("link");w.rel="preload",w.as=l,w.href=d,w.onload=()=>u(),w.onerror=()=>h(new Error(`Failed to preload ${l}: ${d}`)),a.current.add(w),document.head.appendChild(w),setTimeout(()=>{w.parentNode&&(w.parentNode.removeChild(w),a.current.delete(w))},1e4)});return f.useEffect(()=>{if(!e)return;n();const d=(l,u)=>{if(!l)return u||null;if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("//"))return l;try{return ct(l,r)}catch(h){return console.warn(`Failed to build asset URL for ${l}:`,h),u||null}};if(e.title?document.title=e.title:t&&(document.title=t),e.description&&i('meta[name="description"]',()=>{const l=document.createElement("meta");return l.name="description",l},l=>{l.content=e.description}),e.keywords&&i('meta[name="keywords"]',()=>{const l=document.createElement("meta");return l.name="keywords",l},l=>{l.content=e.keywords}),i('meta[name="viewport"]',()=>{const l=document.createElement("meta");return l.name="viewport",l},l=>{l.content="width=device-width, initial-scale=1.0"}),o?.colors?.primary&&i('meta[name="theme-color"]',()=>{const l=document.createElement("meta");return l.name="theme-color",l},l=>{l.content=o.colors.primary}),e.favicon){const l=d(e.favicon,"/favicon.ico");l&&i('link[rel="icon"][type="image/x-icon"], link[rel="shortcut icon"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/x-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload favicon:",h.message))})}if(e.favicon_png){const l=d(e.favicon_png,"/favicon-32x32.png");l&&i('link[rel="icon"][type="image/png"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/png",u.sizes="32x32",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload PNG favicon:",h.message))})}if(e.apple_touch_icon){const l=d(e.apple_touch_icon,"/apple-touch-icon.png");l&&i('link[rel="apple-touch-icon"]',()=>{const u=document.createElement("link");return u.rel="apple-touch-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload Apple touch icon:",h.message))})}if(e.og_image){const l=d(e.og_image,"/og-image.png");l&&(c(l).catch(u=>console.warn("Failed to preload OG image:",u.message)),i('meta[property="og:image"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image"),u},u=>{u.content=l}),(e.og_image_alt||e.title)&&i('meta[property="og:image:alt"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image:alt"),u},u=>{u.content=e.og_image_alt||e.title||t||"Zango CRM"}))}if(i('meta[property="og:title"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:title"),l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[property="og:description"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:description"),l},l=>{l.content=e.description}),i('meta[property="og:type"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:type"),l},l=>{l.content="website"}),i('meta[property="og:url"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:url"),l},l=>{l.content=window.location.href}),i('meta[name="twitter:card"]',()=>{const l=document.createElement("meta");return l.name="twitter:card",l},l=>{l.content=e.og_image?"summary_large_image":"summary"}),i('meta[name="twitter:title"]',()=>{const l=document.createElement("meta");return l.name="twitter:title",l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[name="twitter:description"]',()=>{const l=document.createElement("meta");return l.name="twitter:description",l},l=>{l.content=e.description}),e.og_image){const l=d(e.og_image,"/og-image.png");l&&i('meta[name="twitter:image"]',()=>{const u=document.createElement("meta");return u.name="twitter:image",u},u=>{u.content=l})}if(i('link[rel="canonical"]',()=>{const l=document.createElement("link");return l.rel="canonical",l},l=>{l.href=window.location.href.split("?")[0]}),e.manifest||e.webmanifest){const l=d(e.manifest||e.webmanifest,"/manifest.json");l&&i('link[rel="manifest"]',()=>{const u=document.createElement("link");return u.rel="manifest",u},u=>{u.href=l})}return n},[e,t,o]),null},To=()=>{const e=H.useNavigate(),[t,r]=f.useState(null);return f.useEffect(()=>{(async()=>{try{const a=await Dr();a.success||a.responseStatus===401?setTimeout(()=>{e("/app/login")},1500):(r(a.response?.message||"An error occurred while logging out. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3))}catch(a){console.error("Logout error:",a),r("An error occurred. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3)}})()},[e]),s.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",backgroundColor:"#f5f5f5"},children:[s.jsx("div",{style:{backgroundColor:"white",padding:"40px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",textAlign:"center",maxWidth:"400px",width:"100%"},children:t?s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px",color:"#ef4444"},children:s.jsx("svg",{width:"50",height:"50",fill:"none",viewBox:"0 0 24 24",style:{margin:"0 auto"},children:s.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logout Error"}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:t})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px"},children:s.jsx("div",{style:{width:"50px",height:"50px",border:"3px solid #f3f3f3",borderTop:"3px solid var(--primary-color, #3b82f6)",borderRadius:"50%",margin:"0 auto",animation:"spin 1s linear infinite"}})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logging you out..."}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:"Please wait while we securely log you out."})]})}),s.jsx("style",{children:`
190
+ `;const o=r.querySelector("#cancel-logout"),a=r.querySelector("#confirm-logout");o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#b91c1c"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="#dc2626"}),o.addEventListener("click",()=>{document.body.removeChild(t)}),a.addEventListener("click",()=>{document.body.removeChild(t),e()}),t.addEventListener("click",i=>{i.target===t&&document.body.removeChild(t)});const n=i=>{i.key==="Escape"&&(document.removeEventListener("keydown",n),document.body.contains(t)&&document.body.removeChild(t))};document.addEventListener("keydown",n),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>o.focus(),100)},Bo=({isOpen:e,onClose:t})=>{const[r,o]=g.useState("account"),[a,n]=g.useState(!1),[i,c]=g.useState(!1),[d,l]=g.useState(null),[u,h]=g.useState(!1),[m,w]=g.useState([]),[f,x]=g.useState(!1),[y,P]=g.useState(null),[A,B]=g.useState([]),[N,H]=g.useState(null),{appData:S}=Pe(),{profileData:v,loading:C,error:F,refetch:D,shouldSetPassword:k}=yl(e),[U,I]=g.useState({name:"",email:"",mobile:"",roles:[],currentRole:"",lastPasswordChange:"Never",nextPasswordDue:null}),[j,L]=g.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[T,M]=g.useState({}),[E,Z]=g.useState({}),[Q,z]=g.useState(""),[_,J]=g.useState(!1),[V,K]=g.useState(null),[ee,ne]=g.useState({minLength:!1,hasUpperCase:!1,hasLowerCase:!1,hasNumber:!1,hasSpecialChar:!1}),ie=async()=>{x(!0),P(null);try{const O=await Hr();if(O.success&&O.response){const X=O.response.data||O.response;w(X),P(null)}else{const X=O.response?.message||"Failed to fetch sessions";P(X),console.error("Sessions API Error:",O)}}catch(O){const X=O.message||"Network error while fetching sessions";P(X),console.error("Sessions fetch error:",O)}finally{x(!1)}};g.useEffect(()=>{if(v){let O=v.last_password_changed||"Never",X=null;if(v.last_password_changed&&v?.password_policy?.password_expiry_days){const oe=new Date(v.last_password_changed),et=new Date(oe);et.setDate(et.getDate()+v.password_policy.password_expiry_days),et>new Date?X=et.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):X="Expired"}I({name:v.name||"",email:v.email||"",mobile:v.mobile||"",roles:v.roles||[],currentRole:S?.profile_info?.user_role||v.roles?.[0]?.name||"Admin",lastPasswordChange:O,nextPasswordDue:X}),h(v.auth_config?.two_factor_auth?.required||!1),v.profile_pic&&l(v.profile_pic);let R=null;v.auth_config?.password_policy?R=v.auth_config.password_policy:v.password_policy&&(R=v.password_policy),R?(console.log("Setting password policy from profileData.auth_config.password_policy:",R),H(R)):console.log("No password policy found in profileData:",{auth_config_password_policy:v.auth_config?.password_policy,password_policy:v.password_policy}),v.tokens&&B(v.tokens)}v&&v.tokens&&B(v.tokens),S?.sessions?.tokens&&B(S.sessions.tokens),S?.password_policy&&H(S.password_policy)},[v,S]);const me=(O,X)=>{const R=O.user_agent||O.browser_agent||"Unknown Browser",oe=O.ip||O.location||"Unknown Location",et=O.created_at,tt=O.last_seen_at,ql=we=>we.includes("Chrome")?"Chrome":we.includes("Firefox")?"Firefox":we.includes("Safari")?"Safari":we.includes("Edge")?"Edge":"Unknown Browser",Il=we=>we.includes("Mac")?"macOS":we.includes("Windows")?"Windows":we.includes("Linux")?"Linux":we.includes("iPhone")||we.includes("iOS")?"iOS":we.includes("Android")?"Android":"Unknown OS",zo=we=>{if(!we)return"Unknown";const Cr=we.replace(" IST",""),vr=new Date(Cr),jl=new Date().getTime()-vr.getTime(),qt=Math.floor(jl/1e3),It=Math.floor(qt/60),$t=Math.floor(It/60),xr=Math.floor($t/24);return xr>0?`${xr} day${xr>1?"s":""} ago`:$t>0?`${$t} hour${$t>1?"s":""} ago`:It>0?`${It} minute${It>1?"s":""} ago`:qt>0?`${qt} second${qt>1?"s":""} ago`:"Just now"},$l=ql(R),Wo=Il(R),Vl=()=>{if(O.is_current)return!0;if(!tt)return!1;const we=typeof tt=="string"?tt.replace(" IST",""):tt,Cr=new Date(we),vr=new Date(Date.now()-3600*1e3);return Cr>vr};return{...O,deviceName:`${$l} on ${Wo}`,os:Wo,location:oe==="127.0.0.1"?"Local Device":oe,sessionStartTime:zo(et),lastSeen:zo(tt),isActive:Vl()}};g.useEffect(()=>{const{newPassword:O}=j;console.log("Password validation useEffect triggered:",{newPassword:O,passwordPolicy:N}),N?(console.log("Using password policy for validation:",N),ne({minLength:O.length>=(N.min_length||8),hasUpperCase:N.require_uppercase?/[A-Z]/.test(O):!0,hasLowerCase:N.require_lowercase?/[a-z]/.test(O):!0,hasNumber:N.require_numbers?/[0-9]/.test(O):!0,hasSpecialChar:N.require_special_chars?/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(O):!0})):(console.log("No password policy found, using default validation"),ne({minLength:O.length>=8,hasUpperCase:/[A-Z]/.test(O),hasLowerCase:/[a-z]/.test(O),hasNumber:/[0-9]/.test(O),hasSpecialChar:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(O)}))},[j.newPassword,N]);const[Ze,$e]=g.useState(e);g.useEffect(()=>{e&&!Ze&&(D&&D(),ie(),n(!1),c(!1),M({}),Z({}),z(""),L({currentPassword:"",newPassword:"",confirmPassword:""})),$e(e)},[e,Ze,D]),g.useEffect(()=>{r==="security"&&e&&ie()},[r,e]);const Ge=O=>{const{name:X,value:R}=O.target;I(oe=>({...oe,[X]:R})),M(oe=>({...oe,[X]:""}))},le=O=>{const{name:X,value:R}=O.target;L(oe=>({...oe,[X]:R})),Z(oe=>({...oe,[X]:""}))},Ee=()=>{const O={};return U.name.trim()||(O.name="Name is required"),O},br=async O=>{const X=O.target.files?.[0];if(X){const R=new FormData;R.append("profile_pic",X);try{const oe=await gt(R);oe.success?(l(oe.response?.profile_pic||URL.createObjectURL(X)),z("Profile photo updated successfully!")):z(oe.response?.message||"Failed to upload photo")}catch{z("Failed to upload photo")}}},Do=async()=>{try{const O=!u,X={two_factor_auth:{required:O}},R=new FormData;R.append("auth_config",JSON.stringify(X));const oe=await gt(R);oe.success?(h(O),z(`Two-factor authentication ${O?"enabled":"disabled"}`),p.toast.success({title:"Two-Factor Authentication Updated",description:`Two-factor authentication ${O?"enabled":"disabled"} successfully`,duration:3e3})):(z(oe.response?.message||"Failed to update two-factor authentication"),p.toast.error({title:"Update Failed",description:oe.response?.message||"Failed to update two-factor authentication",duration:5e3}))}catch{z("Failed to update two-factor authentication"),p.toast.error({title:"Update Error",description:"An error occurred while updating two-factor authentication",duration:5e3})}},Ho=async O=>{try{const X=await Zr(O);X.success?(ie(),z("Session logged out successfully")):z(X.response?.message||"Failed to logout session")}catch{z("Failed to logout session")}},El=async()=>{try{const O=m.filter(R=>!R.is_current).map(R=>R.id),X=await Gr(O);X.success?(z("All other sessions logged out successfully"),ie()):z(X.response?.message||"Failed to logout all sessions")}catch{z("Failed to logout all sessions")}},Fl=()=>{const O={};return!k&&!j.currentPassword&&(O.currentPassword="Current password is required"),j.newPassword?Object.values(ee).some(R=>!R)&&(O.newPassword="Password must meet all requirements"):O.newPassword=k?"Password is required":"New password is required",j.newPassword!==j.confirmPassword&&(O.confirmPassword="Passwords do not match"),O},Ol=async O=>{O.preventDefault();const X=Ee();if(Object.keys(X).length>0){M(X);return}J(!0),z("");try{const R=new FormData;R.append("name",U.name);const oe=await gt(R);oe.success?(z("Name updated successfully!"),n(!1),setTimeout(()=>{z("")},3e3)):z(oe.response?.message||"Failed to update name")}catch{z("An error occurred. Please try again.")}finally{J(!1)}},Ml=async O=>{O.preventDefault();const X=Fl();if(Object.keys(X).length>0){Z(X);return}J(!0),z("");try{const R={new_password:j.newPassword};k||(R.current_password=j.currentPassword);const oe=await zr(R);oe.success?(z(k?"Password set successfully!":"Password changed successfully!"),L({currentPassword:"",newPassword:"",confirmPassword:""}),c(!1),D&&D(),setTimeout(()=>{z("")},3e3)):z(oe.response?.message||"Failed to change password")}catch{z("An error occurred. Please try again.")}finally{J(!1)}},Ul=async O=>{K(O);try{const X=await Wr(O);X.success?(p.toast.success({title:"Role Switched",description:"Role switched successfully! Redirecting...",duration:2e3}),setTimeout(()=>{window.location.href="/app"},1e3)):(p.toast.error({title:"Role Switch Failed",description:X.response?.message||"Failed to switch role",duration:5e3}),K(null))}catch{p.toast.error({title:"Role Switch Error",description:"An error occurred while switching role",duration:5e3}),K(null)}},Bl=()=>{Uo(()=>{Mo({redirectUrl:"/app/login"})})};return s.jsxs("div",{className:`user-profile-drawer ${e?"open":""}`,children:[s.jsx("div",{className:"profile-header-gradient",children:s.jsx("button",{className:"profile-close-btn",onClick:t,children:s.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),C&&s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280"},children:"Loading profile..."})]}),_&&s.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:s.jsxs("div",{style:{backgroundColor:"white",padding:"2rem",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.1)"},children:[s.jsx(p.Spin,{size:"large"}),s.jsx("span",{style:{marginLeft:"12px",color:"#6b7280",fontSize:"16px"},children:"Updating password..."})]})}),F&&!C&&s.jsxs("div",{style:{margin:"1rem 1.5rem",padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s.jsx("svg",{style:{height:"20px",width:"20px",color:"#f87171",marginRight:"8px"},viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),s.jsx("span",{style:{color:"#b91c1c",fontWeight:"500"},children:"Failed to load profile"})]}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"4px",marginBottom:"8px"},children:F}),s.jsx("button",{onClick:D,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}),!C&&!F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"profile-info-section",children:[s.jsx("div",{className:"profile-avatar-container",children:s.jsxs("div",{className:"profile-avatar-circle",children:[d?s.jsx("img",{src:d,alt:"Profile",className:"profile-avatar-img"}):U.name?s.jsx("span",{className:"profile-initials",children:U.name.split(" ").map(O=>O[0]).join("").toUpperCase().slice(0,2)}):s.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M20 20C23.6819 20 26.6667 17.0152 26.6667 13.3333C26.6667 9.65143 23.6819 6.66667 20 6.66667C16.3181 6.66667 13.3333 9.65143 13.3333 13.3333C13.3333 17.0152 16.3181 20 20 20ZM20 20C13.3726 20 8 25.3726 8 32C8 33.1046 8.89543 34 10 34H30C31.1046 34 32 33.1046 32 32C32 25.3726 26.6274 20 20 20Z",stroke:"#6B7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),s.jsxs("label",{className:"profile-avatar-edit",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:br,hidden:!0}),s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M2.52121 10.8728L2 14L5.12724 13.4788C5.67029 13.3883 6.1715 13.1304 6.56079 12.7411L13.6132 5.68859C14.1289 5.17281 14.1289 4.3366 13.6131 3.82084L12.1791 2.38682C11.6633 1.87105 10.8271 1.87106 10.3113 2.38685L3.25894 9.43933C2.86965 9.8286 2.61171 10.3298 2.52121 10.8728Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),s.jsxs("div",{className:"profile-name-section",children:[s.jsx("h2",{className:"profile-user-name",children:U.name||"Welcome!"}),s.jsxs("div",{className:"profile-user-role-badge",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M9.5 6.5V4.5C9.5 3.39543 8.60457 2.5 7.5 2.5H6.5C5.39543 2.5 4.5 3.39543 4.5 4.5V6.5M3 6.5H11C11.5523 6.5 12 6.94772 12 7.5V10.5C12 11.0523 11.5523 11.5 11 11.5H3C2.44772 11.5 2 11.0523 2 10.5V7.5C2 6.94772 2.44772 6.5 3 6.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"7",cy:"9",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{children:U.currentRole})]})]})]}),s.jsx("div",{className:"profile-main-content",children:s.jsxs("div",{className:"profile-content-wrapper",children:[s.jsxs("div",{className:"profile-tabs",children:[s.jsx("button",{className:`profile-tab ${r==="account"?"active":""}`,onClick:()=>{o("account"),n(!1),z("")},children:"Account"}),s.jsx("button",{className:`profile-tab ${r==="security"?"active":""}`,onClick:()=>{o("security"),c(!1),z("")},children:"Security"})]}),Q&&s.jsx("div",{className:`profile-alert ${Q.includes("successfully")?"success":"error"}`,children:s.jsx("span",{children:Q})}),T.general&&s.jsx("div",{className:"profile-alert error",children:s.jsx("span",{children:T.general})}),s.jsx("div",{className:"profile-tab-content",children:r==="account"?s.jsxs("div",{className:"account-section",children:[!U.name&&!U.email&&!U.mobile&&s.jsxs("div",{className:"welcome-banner",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"rgba(80, 72, 237, 0.1)"}),s.jsx("path",{d:"M24 16V20M24 28H24.01M34 24C34 29.5228 29.5228 34 24 34C18.4772 34 14 29.5228 14 24C14 18.4772 18.4772 14 24 14C29.5228 14 34 18.4772 34 24Z",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("h3",{children:"Complete Your Profile"}),s.jsx("p",{children:"Add your name and other details to personalize your account. Click the edit button next to each field to get started."})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsxs("div",{className:"profile-field-header",children:[s.jsx("label",{className:"profile-field-label",children:"Name"}),!a&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>n(!0),children:"Edit"})]}),a?s.jsxs("form",{onSubmit:Ol,className:"profile-inline-form",children:[s.jsx("input",{type:"text",name:"name",className:"profile-form-input",value:U.name,onChange:Ge,placeholder:"Enter your full name",autoFocus:!0}),s.jsxs("div",{className:"profile-inline-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{n(!1),M({}),I(O=>({...O,name:v?.name||""}))},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-save-btn",disabled:_,children:_?"Saving...":"Save"})]}),T.name&&s.jsx("div",{className:"profile-form-error",children:T.name})]}):s.jsx("div",{className:"profile-field-value",children:U.name||s.jsx("span",{className:"empty-value",children:"Click edit to add your name"})})]}),U.email&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Email"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M2.66667 5.33333L7.2786 8.60289C7.67788 8.86886 8.32212 8.86886 8.7214 8.60289L13.3333 5.33333M4 12H12C12.7364 12 13.3333 11.4031 13.3333 10.6667V5.33333C13.3333 4.59695 12.7364 4 12 4H4C3.26362 4 2.66667 4.59695 2.66667 5.33333V10.6667C2.66667 11.4031 3.26362 12 4 12Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),U.email]})]}),U.mobile&&s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Mobile Number"}),s.jsxs("div",{className:"profile-field-value readonly",children:[s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"field-icon",children:s.jsx("path",{d:"M5.33333 2.66667H10.6667C11.4031 2.66667 12 3.26362 12 4V12C12 12.7364 11.4031 13.3333 10.6667 13.3333H5.33333C4.59695 13.3333 4 12.7364 4 12V4C4 3.26362 4.59695 2.66667 5.33333 2.66667ZM5.33333 2.66667V3.33333C5.33333 3.70152 5.63181 4 6 4H10C10.3682 4 10.6667 3.70152 10.6667 3.33333V2.66667M8 11.3333H8.00667",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})}),U.mobile]})]}),s.jsxs("div",{className:"profile-field-section",children:[s.jsx("label",{className:"profile-field-label",children:"Roles"}),s.jsx("div",{className:"roles-list",children:U.roles&&U.roles.length>0?U.roles.map((O,X)=>s.jsxs("div",{className:`role-item ${O.name===U.currentRole?"active":""}`,children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:O.name})]}),O.name===U.currentRole?s.jsx("span",{className:"role-badge",children:"Current"}):s.jsx("button",{className:"role-switch-btn",onClick:()=>Ul(O.id),disabled:V!==null,children:V===O.id?"Switching...":"Switch"})]},O.id)):s.jsxs("div",{className:"role-item active",children:[s.jsxs("div",{className:"role-info",children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10.6667 7V5C10.6667 3.89543 9.77124 3 8.66667 3H7.33333C6.22876 3 5.33333 3.89543 5.33333 5V7M4 7H12C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13H4C3.44772 13 3 12.5523 3 12V8C3 7.44772 3.44772 7 4 7Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"8",cy:"10",r:"0.75",fill:"currentColor"})]}),s.jsx("span",{className:"role-name",children:U.currentRole||"Admin"})]}),s.jsx("span",{className:"role-badge",children:"Current"})]})})]}),s.jsx("div",{className:"profile-field-section logout-section",children:s.jsxs("button",{className:"logout-button",onClick:Bl,children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"currentColor",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{children:"Log Out"})]})})]}):s.jsxs("div",{className:"security-section",children:[s.jsxs("div",{className:"security-block",children:[s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"security-title",children:["Password",N&&!N.allow_change&&s.jsx("span",{className:"password-disabled-badge",children:"Disabled"})]}),!k&&s.jsxs("p",{className:"security-subtitle",children:["Last changed: ",U.lastPasswordChange,U.nextPasswordDue&&s.jsxs(s.Fragment,{children:[" • ",s.jsxs("span",{className:U.nextPasswordDue==="Expired"?"password-expired":"",children:["Next due: ",U.nextPasswordDue]})]})]}),k&&s.jsx("p",{className:"security-subtitle",children:"Set your password to secure your account"})]}),!i&&N?.allow_change!==!1&&s.jsx("button",{className:"profile-field-edit-btn",onClick:()=>{c(!0),L({currentPassword:"",newPassword:"",confirmPassword:""}),Z({})},children:k?"Set Password":"Change Password"})]}),i&&s.jsxs("form",{onSubmit:Ml,className:"password-form",children:[!k&&s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Current Password"}),s.jsx("input",{type:"password",name:"currentPassword",className:"profile-form-input",value:j.currentPassword,onChange:le,placeholder:"Enter current password",autoComplete:"new-password"}),E.currentPassword&&s.jsx("div",{className:"profile-form-error",children:E.currentPassword})]}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:k?"Password":"New Password"}),s.jsx("input",{type:"password",name:"newPassword",className:"profile-form-input",value:j.newPassword,onChange:le,placeholder:k?"Enter password":"Enter new password",autoComplete:"new-password"}),E.newPassword&&s.jsx("div",{className:"profile-form-error",children:E.newPassword})]}),s.jsx("div",{className:"password-requirements",children:N&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`password-requirement ${ee.minLength?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsxs("span",{children:["Minimum ",N.min_length," characters"]})]}),N.require_uppercase&&s.jsxs("div",{className:`password-requirement ${ee.hasUpperCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One uppercase character"})]}),N.require_lowercase&&s.jsxs("div",{className:`password-requirement ${ee.hasLowerCase?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One lowercase character"})]}),N.require_numbers&&s.jsxs("div",{className:`password-requirement ${ee.hasNumber?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One number"})]}),N.require_special_chars&&s.jsxs("div",{className:`password-requirement ${ee.hasSpecialChar?"met":""}`,children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 11.375C3.0315 11.375 0.625 8.9685 0.625 6C0.625 3.0315 3.0315 0.625 6 0.625C8.9685 0.625 11.375 3.0315 11.375 6C11.375 8.9685 8.9685 11.375 6 11.375ZM1.375 6C1.375 8.5545 3.4455 10.625 6 10.625C8.5545 10.625 10.625 8.5545 10.625 6C10.625 3.4455 8.5545 1.375 6 1.375C3.4455 1.375 1.375 3.4455 1.375 6ZM8.2765 4.7535L5.5265 7.7535C5.4575 7.829 5.3605 7.8725 5.258 7.875C5.156 7.877 5.057 7.8375 4.985 7.765L3.735 6.515C3.5885 6.3685 3.5885 6.1315 3.735 5.985C3.8815 5.8385 4.1185 5.8385 4.265 5.985L5.238 6.958L7.7235 4.2465C7.8635 4.094 8.1005 4.0835 8.2535 4.2235C8.406 4.3635 8.4165 4.6005 8.2765 4.7535Z",fill:"currentColor"})}),s.jsx("span",{children:"One special character"})]})]})}),s.jsxs("div",{className:"profile-form-group",children:[s.jsx("label",{className:"profile-form-label",children:"Confirm Password"}),s.jsx("input",{type:"password",name:"confirmPassword",className:"profile-form-input",value:j.confirmPassword,onChange:le,placeholder:k?"Confirm password":"Confirm new password",autoComplete:"new-password"}),E.confirmPassword&&s.jsx("div",{className:"profile-form-error",children:E.confirmPassword})]}),s.jsxs("div",{className:"profile-form-actions",children:[s.jsx("button",{type:"button",className:"profile-cancel-btn",onClick:()=>{c(!1),Z({}),L({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx("button",{type:"submit",className:"profile-submit-btn",disabled:_,children:_?k?"Setting...":"Updating...":k?"Set Password":"Update Password"})]})]})]}),s.jsx("div",{className:"security-block",children:s.jsxs("div",{className:"security-header",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Two-Factor Authentication"}),s.jsxs("p",{className:"security-subtitle",children:[u?"Enabled":"Disabled"," ",u?"":" - Add an extra layer of security"]}),!u&&v?.auth_config?.two_factor_auth?.can_enable===!1&&v?.auth_config?.two_factor_auth?.issue&&s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",marginTop:"8px"},children:v.auth_config.two_factor_auth.issue})]}),!u&&v?.auth_config?.two_factor_auth?.can_enable===!0&&s.jsx("button",{className:"toggle-btn",onClick:Do,children:"Enable"}),u&&v?.auth_config?.two_factor_auth?.can_disable===!0&&s.jsx("button",{className:"toggle-btn enabled",onClick:Do,children:"Disable"})]})}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Where you're logged in"}),s.jsx("p",{className:"security-subtitle",children:"Manage your active sessions"})]})}),s.jsx("div",{className:"sessions-list",children:f?s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"2rem"},children:[s.jsx(p.Spin,{size:"small"}),s.jsx("span",{style:{marginLeft:"8px",color:"#6b7280"},children:"Loading sessions..."})]}):y?s.jsxs("div",{style:{padding:"1rem",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",textAlign:"center"},children:[s.jsx("p",{style:{color:"#b91c1c",margin:"0 0 8px 0"},children:"Failed to load sessions"}),s.jsx("p",{style:{color:"#dc2626",fontSize:"14px",margin:"0 0 8px 0"},children:y}),s.jsx("button",{onClick:ie,style:{fontSize:"14px",color:"#dc2626",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]}):m.length>0?m.map((O,X)=>{const R=me(O);return s.jsxs("div",{className:"session-item",children:[s.jsx("div",{className:"session-info",children:s.jsxs("div",{className:"session-device",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.5 4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V12.5C17.5 13.4205 16.7538 14.1667 15.8333 14.1667H4.16667C3.24619 14.1667 2.5 13.4205 2.5 12.5V4.16667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.66667 17.5H13.3333",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 14.1667V17.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"session-device-header",children:[s.jsx("p",{className:"session-device-name",children:R.deviceName}),O.is_current?s.jsx("span",{className:"session-status-tag current",children:"Current"}):R.isActive?s.jsx("button",{className:"logout-tag-btn logout-tag-btn-ghost",onClick:()=>Ho(O.id),children:"Logout"}):s.jsx("button",{className:"logout-tag-btn",onClick:()=>Ho(O.id),children:"Logout"})]}),s.jsxs("p",{className:"session-details",children:[R.os," • ",R.location]})]})]})}),s.jsx("div",{className:"session-time",children:s.jsxs("div",{className:"session-time-info",children:[s.jsxs("p",{className:"session-start-time",children:["Started: ",R.sessionStartTime]}),s.jsx("p",{className:"session-last-active",children:R.isActive?"Active now":`Last seen: ${R.lastSeen}`})]})})]},O.id||X)}):s.jsx("p",{className:"no-sessions",children:"No active sessions found"})}),m.length>1&&s.jsx("button",{className:"logout-all-btn",onClick:El,children:"Sign me out of all other sessions"})]}),s.jsxs("div",{className:"security-block",children:[s.jsx("div",{className:"security-header",children:s.jsxs("div",{children:[s.jsx("h4",{className:"security-title",children:"Authentication Tokens"}),s.jsx("p",{className:"security-subtitle",children:"Manage your bearer tokens for API authentication"})]})}),s.jsx("div",{className:"tokens-list",children:A&&A.length>0?A.map((O,X)=>s.jsx("div",{className:"token-item",children:s.jsx("div",{className:"token-info",children:s.jsxs("div",{className:"token-details",children:[s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M15 8.33333V6.66667C15 4.08934 12.9107 2 10.3333 2H9.66667C7.08934 2 5 4.08934 5 6.66667V8.33333M6.66667 8.33333H13.3333C14.2538 8.33333 15 9.07953 15 10V15C15 15.9205 14.2538 16.6667 13.3333 16.6667H6.66667C5.74619 16.6667 5 15.9205 5 15V10C5 9.07953 5.74619 8.33333 6.66667 8.33333Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("circle",{cx:"10",cy:"12.5",r:"1.25",fill:"currentColor"})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"token-name",children:[O.role," - Bearer Token"]}),s.jsx("p",{className:"token-type",children:"Type: Bearer Authentication Token"}),s.jsxs("p",{className:"token-created",children:["Created: ",new Date(O.created).toLocaleDateString()]}),O.expiry?s.jsxs("p",{className:"token-expiry",children:["Expires: ",new Date(O.expiry).toLocaleDateString()]}):s.jsx("p",{className:"token-expiry",children:"Expires: Never"})]})]})})},X)):s.jsxs("div",{className:"no-tokens",children:[s.jsx("p",{children:"No authentication tokens found"}),s.jsx("p",{className:"no-tokens-hint",children:"Bearer tokens will appear here for API authentication"})]})})]})]})})]})})]})]})},bl=({onLogout:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-logout ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M10 11.75C9.95093 12.9846 8.92207 14.0329 7.54373 13.9992C7.22307 13.9913 6.82673 13.8796 6.03408 13.656C4.12641 13.1179 2.47037 12.2135 2.07304 10.1877C2 9.81533 2 9.39627 2 8.5582V7.4418C2 6.60374 2 6.1847 2.07304 5.81231C2.47037 3.78643 4.12641 2.8821 6.03408 2.34402C6.82673 2.12042 7.22307 2.00863 7.54373 2.00079C8.92207 1.96707 9.95093 3.01538 10 4.25",stroke:"#717680",strokeLinecap:"round"}),s.jsx("path",{d:"M14 7.99998H6.66663M14 7.99998C14 7.53318 12.6704 6.661 12.3333 6.33331M14 7.99998C14 8.46678 12.6704 9.33898 12.3333 9.66665",stroke:"#717680",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"Log Out"})]}),Cl=({onViewProfile:e,className:t=""})=>s.jsxs("a",{className:`dropdown-item profile-view ${t}`,href:"#",onClick:r=>{r.preventDefault(),e()},children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("path",{d:"M8.00004 7.33329C9.47281 7.33329 10.6667 6.13948 10.6667 4.66663C10.6667 3.19377 9.47281 1.99996 8.00004 1.99996C6.52719 1.99996 5.33337 3.19377 5.33337 4.66663C5.33337 6.13948 6.52719 7.33329 8.00004 7.33329Z",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M4.00004 14V12.6666C4.00004 11.9594 4.28099 11.2811 4.78109 10.781C5.28119 10.2809 5.95947 9.99996 6.66671 9.99996H9.33337C10.0406 9.99996 10.7189 10.2809 11.219 10.781C11.7191 11.2811 12 11.9594 12 12.6666V14",stroke:"#717680",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("span",{className:"profile-name",children:"View Profile"})]}),qo=({profileInfo:e,theme:t={},config:r={}})=>{const[o,a]=g.useState(!1),[n,i]=g.useState(!1),[c,d]=g.useState(!1),[l,u]=g.useState(null),h=g.useRef(null);G.useNavigate(),g.useEffect(()=>{const T=M=>{h.current&&!h.current.contains(M.target)&&(a(!1),i(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const m=()=>{a(!o),o||i(!1)},w=()=>{Uo(()=>{Mo({theme:t})})},f=T=>{window.location.href=T},x=e?.current_role||e?.user_role,y=e?.other_roles||[],{showProfile:P=!0,showLeftSection:A=!0,showRightSection:B=!0,customLeftContent:N=null,customRightContent:H=null,customProfileMenu:S=null,customViewProfile:v=null,profileMenuConfig:C={},className:F="",style:D={}}=r,{showViewProfile:k=!0,showLogout:U=!0,showRoleSwitch:I=!0,customMenuItems:j=[]}=C,L=()=>{d(!0),a(!1)};return s.jsxs("header",{className:`topbar header-container ${F}`,style:D,children:[s.jsxs("div",{className:"topbar-content",children:[A&&s.jsx("div",{className:"topbar-left",children:N||null}),B&&s.jsxs("div",{className:"topbar-right",children:[H,P&&s.jsxs("div",{className:"dropdown profile-dropdown-container",ref:h,children:[s.jsxs("div",{className:"profile-dropdown-menu-button",onClick:m,children:[s.jsxs("div",{className:"profile-info-wrapper",children:[s.jsx("img",{src:e?.profile_pic||`https://ui-avatars.com/api/?name=${encodeURIComponent(e?.name||"User")}&background=${as("brand",500).split("#")[1]}&color=fff`,alt:"Profile",className:"profile-avatar"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"profile-name",children:e?.name||"User"}),s.jsx("span",{className:"text-[12px] text-gray-600",children:x})]})]}),s.jsx("svg",{className:`dropdown-arrow ${o?"open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M13.3538 6.35354L8.35378 11.3535C8.30735 11.4 8.2522 11.4369 8.1915 11.4621C8.13081 11.4872 8.06574 11.5002 8.00003 11.5002C7.93433 11.5002 7.86926 11.4872 7.80856 11.4621C7.74786 11.4369 7.69272 11.4 7.64628 11.3535L2.64628 6.35354C2.55246 6.25972 2.49976 6.13247 2.49976 5.99979C2.49976 5.86711 2.55246 5.73986 2.64628 5.64604C2.7401 5.55222 2.86735 5.49951 3.00003 5.49951C3.13272 5.49951 3.25996 5.55222 3.35378 5.64604L8.00003 10.2929L12.6463 5.64604C12.6927 5.59958 12.7479 5.56273 12.8086 5.53759C12.8693 5.51245 12.9343 5.49951 13 5.49951C13.0657 5.49951 13.1308 5.51245 13.1915 5.53759C13.2522 5.56273 13.3073 5.59958 13.3538 5.64604C13.4002 5.69249 13.4371 5.74764 13.4622 5.80834C13.4874 5.86904 13.5003 5.93409 13.5003 5.99979C13.5003 6.06549 13.4874 6.13054 13.4622 6.19124C13.4371 6.25193 13.4002 6.30708 13.3538 6.35354Z",fill:"#414651"})})]}),s.jsxs("ul",{className:`profile-dropdown-menu ${o?"show":""}`,children:[y.length>0&&n&&s.jsx("li",{children:s.jsx("div",{className:"profile-roles complete-hidden-scroll-style",children:y.map((T,M)=>s.jsxs("div",{className:"dropdown-item profile-each-role",onClick:()=>f(T.url),children:[s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[s.jsx("g",{clipPath:"url(#clip0_1427_392)",children:s.jsx("path",{d:"M0.833374 7.99998C0.833374 4.04198 4.04204 0.833313 8.00004 0.833313C11.958 0.833313 15.1667 4.04198 15.1667 7.99998C15.1667 11.958 11.958 15.1666 8.00004 15.1666C4.04204 15.1666 0.833374 11.958 0.833374 7.99998ZM8.00004 1.83331C4.59404 1.83331 1.83337 4.59398 1.83337 7.99998C1.83337 9.58131 2.42804 11.0233 3.40671 12.1146L3.60604 11.7646C4.28871 10.5706 5.55871 9.83331 6.93471 9.83331H9.06604C10.4414 9.83331 11.7114 10.5706 12.394 11.7646L12.5934 12.114C13.572 11.0226 14.1667 9.58065 14.1667 7.99998C14.1667 4.59398 11.406 1.83331 8.00004 1.83331ZM11.8454 12.8206L11.5254 12.2606C11.0214 11.378 10.0827 10.8333 9.06604 10.8333H6.93471C5.91804 10.8333 4.97871 11.378 4.47471 12.2606L4.15471 12.8213C5.20871 13.6633 6.54537 14.1666 8.00004 14.1666C9.45471 14.1666 10.7914 13.6633 11.8454 12.8206ZM5.66671 6.33331C5.66671 5.04465 6.71137 3.99998 8.00004 3.99998C9.28871 3.99998 10.3334 5.04465 10.3334 6.33331C10.3334 7.62198 9.28871 8.66665 8.00004 8.66665C6.71137 8.66665 5.66671 7.62198 5.66671 6.33331ZM8.00004 4.99998C7.26337 4.99998 6.66671 5.59665 6.66671 6.33331C6.66671 7.06998 7.26337 7.66665 8.00004 7.66665C8.73671 7.66665 9.33337 7.06998 9.33337 6.33331C9.33337 5.59665 8.73671 4.99998 8.00004 4.99998Z",fill:"#717680"})}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_1427_392",children:s.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),s.jsx("span",{className:"label",children:T.label})]},M))})}),s.jsx("li",{children:s.jsx("hr",{className:"profile-dropdown-divider"})}),j.map((T,M)=>s.jsx("li",{children:T},M)),k&&s.jsx("li",{children:s.jsx(Cl,{onViewProfile:L})}),U&&s.jsx("li",{children:s.jsx(bl,{onLogout:w})})]})]})]})]}),v?v({user:e,isOpen:c,onClose:()=>d(!1)}):s.jsx(Bo,{isOpen:c,onClose:()=>d(!1),profileData:l})]})},vl={showTopbar:!0,showNavbar:!0,layoutType:"wide"},xl={showProfile:!0,showLeftSection:!0,showRightSection:!0,customLeftContent:null,customRightContent:null,customProfileMenu:null,customTopbar:null,customViewProfile:null,profileMenuConfig:{showViewProfile:!0,showLogout:!0,showRoleSwitch:!0,customMenuItems:[]},className:"",style:{}},Pl={showLogo:!0,showMenu:!0,isCollapsed:!1,collapsible:!1,customLogo:null,customMenuContent:null,customBottomContent:null,customNavbar:null,customMenu:null,menuConfig:{showIcons:!0,showSubmenus:!0,expandOnHover:!1,customMenuItemRenderer:null},className:"",style:{}},Bt=(e={},t={})=>{const r={...t};return Object.keys(e).forEach(o=>{if(e[o]===void 0||e[o]===null)return;e[o]&&(e[o].$$typeof||typeof e[o]=="function")||typeof e[o]=="function"||Array.isArray(e[o])?r[o]=e[o]:typeof e[o]=="object"&&typeof t[o]=="object"&&!Array.isArray(t[o])?r[o]=Bt(e[o],t[o]):r[o]=e[o]}),r},Io=()=>{const{loading:e,error:t,menu:r,profileInfo:o,appLogo:a,theme:n={},layoutConfig:i={},topbarConfig:c={},navbarConfig:d={},customComponents:l={}}=Pe(),u=G.useLocation(),h=Bt(i,vl),m=Bt(c,xl),w=Bt(d,Pl),f=()=>{const S=document.getElementById("contentSpinner");S&&S.classList.add("active")},x=()=>{const S=document.getElementById("contentSpinner");S&&S.classList.remove("active")};if(g.useEffect(()=>{f();const S=300,v=Date.now(),C=setTimeout(()=>{const F=Date.now()-v;F>=S?x():setTimeout(x,S-F)},500);return()=>{clearTimeout(C)}},[u.pathname]),g.useEffect(()=>(window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}),[]),e)return s.jsx("div",{className:"layout-loading",children:"Loading..."});if(t)return s.jsxs("div",{className:"layout-error",children:["Error: ",t]});const y=h.layoutType||n?.layout||"wide",P=h.showNavbar&&n?.menu_config?.display_sidebar!==!1,A=h.showTopbar,B=l?.Layout,N=l?.Topbar||m.customTopbar,H=l?.Navbar||w.customNavbar;return B?s.jsx(B,{menu:r,profileInfo:o,appLogo:a,theme:n,layoutConfig:h,topbarConfig:m,navbarConfig:w,children:s.jsx(G.Outlet,{})}):s.jsx("div",{className:`layout layout-${y}`,children:s.jsxs("main",{className:"layout-wrapper",children:[P&&(H?s.jsx(H,{menuItems:r,appLogo:a,theme:n,config:w}):s.jsx(No,{menuItems:r,appLogo:a,theme:n,config:w})),s.jsxs("div",{className:"layout-main",style:{width:P?`calc(100vw - ${w.isCollapsed?"80px":"244px"})`:"100vw",transition:"width 0.3s ease"},children:[A&&(N?s.jsx(N,{profileInfo:o,theme:n,config:m}):s.jsx(qo,{profileInfo:o,theme:n,config:m})),s.jsxs("div",{className:"layout-content",children:[s.jsx("div",{className:"content-spinner-container",id:"contentSpinner",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),s.jsx(G.Outlet,{})]})]})]})})},Sl=(e,t,r)=>{const o=t[e]||t.default;if(o.handler)return o.handler(r);let a=o.propsBuilder?o.propsBuilder({...r,pageType:e}):{};o.includeBasePath!==!1&&r.matchedRoutePath&&(a={basePath:r.matchedRoutePath,...a});const i=o.component;return g.createElement(i,a)},ft=({customPages:e={},forceRoute:t})=>{const r=G.useLocation(),{routes:o,pageTypeRegistry:a,registryLoading:n,registryError:i,initializerEndpoint:c}=Pe(),d=at(),[l,u]=g.useState({pageType:null,customPagePath:null,matchedRoutePath:null,loading:!0});if(g.useEffect(()=>{u(y=>({...y,loading:!0})),(()=>{const y=r.pathname;if(t){u({pageType:t.page_type,customPagePath:t.component||null,matchedRoutePath:t.path,loading:!1});return}if(r.state&&r.state.page_type&&(r.state.page_type!=="custom"||r.state.custom_page_path)){let P=y;if(o&&o.length>0){for(const A of o)if(y===A.path||y.startsWith(A.path+"/")){P=A.path;break}}u({pageType:r.state.page_type,customPagePath:r.state.custom_page_path||null,matchedRoutePath:P,loading:!1});return}if(o&&o.length>0){const P=[...o].sort((A,B)=>{const N=A.path.split("/").filter(S=>S).length;return B.path.split("/").filter(S=>S).length-N});for(const A of P){let B=G.matchPath({path:A.path,exact:!0},y);if(!B&&y.startsWith(A.path+"/")){const N=A.path.endsWith("/*")?A.path:`${A.path}/*`;B=G.matchPath({path:N,exact:!1},y)}if(B){u({pageType:A.page_type,customPagePath:A.component||null,matchedRoutePath:A.path,loading:!1});return}}}u({pageType:"404",customPagePath:null,matchedRoutePath:null,loading:!1})})()},[r,o,t]),l.loading||n)return s.jsx("div",{className:"content-spinner-container active",children:s.jsx("div",{className:"spinner",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{d:"M32 5.33331V16",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 20.7999L50.9335 13.0665",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M48 32H58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M43.2002 43.2L50.9335 50.9333",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M32 48V58.6667",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 50.9333L20.7997 43.2",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.33301 32H15.9997",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.0664 13.0665L20.7997 20.7999",stroke:"var(--color-brand-500, #5048ED)",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})})});if(i)return s.jsxs("div",{style:{padding:"24px",color:"#f04438"},children:["Failed to load page registry: ",i]});if(!a)return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",textAlign:"center",padding:"24px"},children:s.jsxs("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"32px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.05)",maxWidth:"500px",width:"100%",border:"1px solid #e1e3e6"},children:[s.jsx("h1",{style:{fontSize:"32px",margin:"0",color:"#f04438",fontWeight:"bold",lineHeight:"1"},children:"⚠️"}),s.jsx("h3",{style:{fontSize:"18px",margin:"12px 0",color:"#252b37",fontWeight:"600"},children:"Configuration Issue"}),s.jsx("p",{style:{fontSize:"14px",color:"#717680",marginBottom:"16px",lineHeight:"1.5"},children:"Unable to load page configuration from:"}),s.jsx("code",{style:{display:"block",backgroundColor:"#f9fafb",border:"1px solid #e1e3e6",borderRadius:"4px",padding:"8px 12px",fontSize:"12px",color:"#252b37",fontFamily:"Monaco, Menlo, monospace",marginBottom:"16px",wordBreak:"break-all"},children:c}),s.jsx("p",{style:{fontSize:"13px",color:"#8b909a",margin:"0"},children:"Please check your configuration or contact your administrator."})]})});const{pageType:h,customPagePath:m,matchedRoutePath:w}=l,f=`${h}-${m||"default"}-${w||"none"}`;return s.jsx("div",{className:"h-full",children:Sl(h,a,{matchedRoutePath:w,customPagePath:m,customPages:e,location:r,apiConfig:d})},f)},$o=()=>{const{metadata:e,appName:t,apiConfig:r,theme:o}=Pe(),a=g.useRef(new Set),n=()=>{a.current.forEach(d=>{d.parentNode&&d.parentNode.removeChild(d)}),a.current.clear()},i=(d,l,u)=>{let h=document.querySelector(d);return h||(h=l(),document.head.appendChild(h),a.current.add(h)),u(h),h},c=(d,l="image")=>new Promise((u,h)=>{const m=document.createElement("link");m.rel="preload",m.as=l,m.href=d,m.onload=()=>u(),m.onerror=()=>h(new Error(`Failed to preload ${l}: ${d}`)),a.current.add(m),document.head.appendChild(m),setTimeout(()=>{m.parentNode&&(m.parentNode.removeChild(m),a.current.delete(m))},1e4)});return g.useEffect(()=>{if(!e)return;n();const d=(l,u)=>{if(!l)return u||null;if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("//"))return l;try{return pt(l,r)}catch(h){return console.warn(`Failed to build asset URL for ${l}:`,h),u||null}};if(e.title?document.title=e.title:t&&(document.title=t),e.description&&i('meta[name="description"]',()=>{const l=document.createElement("meta");return l.name="description",l},l=>{l.content=e.description}),e.keywords&&i('meta[name="keywords"]',()=>{const l=document.createElement("meta");return l.name="keywords",l},l=>{l.content=e.keywords}),i('meta[name="viewport"]',()=>{const l=document.createElement("meta");return l.name="viewport",l},l=>{l.content="width=device-width, initial-scale=1.0"}),o?.colors?.primary&&i('meta[name="theme-color"]',()=>{const l=document.createElement("meta");return l.name="theme-color",l},l=>{l.content=o.colors.primary}),e.favicon){const l=d(e.favicon,"/favicon.ico");l&&i('link[rel="icon"][type="image/x-icon"], link[rel="shortcut icon"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/x-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload favicon:",h.message))})}if(e.favicon_png){const l=d(e.favicon_png,"/favicon-32x32.png");l&&i('link[rel="icon"][type="image/png"]',()=>{const u=document.createElement("link");return u.rel="icon",u.type="image/png",u.sizes="32x32",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload PNG favicon:",h.message))})}if(e.apple_touch_icon){const l=d(e.apple_touch_icon,"/apple-touch-icon.png");l&&i('link[rel="apple-touch-icon"]',()=>{const u=document.createElement("link");return u.rel="apple-touch-icon",u},u=>{u.href=l,c(l).catch(h=>console.warn("Failed to preload Apple touch icon:",h.message))})}if(e.og_image){const l=d(e.og_image,"/og-image.png");l&&(c(l).catch(u=>console.warn("Failed to preload OG image:",u.message)),i('meta[property="og:image"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image"),u},u=>{u.content=l}),(e.og_image_alt||e.title)&&i('meta[property="og:image:alt"]',()=>{const u=document.createElement("meta");return u.setAttribute("property","og:image:alt"),u},u=>{u.content=e.og_image_alt||e.title||t||"Zango CRM"}))}if(i('meta[property="og:title"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:title"),l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[property="og:description"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:description"),l},l=>{l.content=e.description}),i('meta[property="og:type"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:type"),l},l=>{l.content="website"}),i('meta[property="og:url"]',()=>{const l=document.createElement("meta");return l.setAttribute("property","og:url"),l},l=>{l.content=window.location.href}),i('meta[name="twitter:card"]',()=>{const l=document.createElement("meta");return l.name="twitter:card",l},l=>{l.content=e.og_image?"summary_large_image":"summary"}),i('meta[name="twitter:title"]',()=>{const l=document.createElement("meta");return l.name="twitter:title",l},l=>{l.content=e.title||t||"Zango CRM"}),e.description&&i('meta[name="twitter:description"]',()=>{const l=document.createElement("meta");return l.name="twitter:description",l},l=>{l.content=e.description}),e.og_image){const l=d(e.og_image,"/og-image.png");l&&i('meta[name="twitter:image"]',()=>{const u=document.createElement("meta");return u.name="twitter:image",u},u=>{u.content=l})}if(i('link[rel="canonical"]',()=>{const l=document.createElement("link");return l.rel="canonical",l},l=>{l.href=window.location.href.split("?")[0]}),e.manifest||e.webmanifest){const l=d(e.manifest||e.webmanifest,"/manifest.json");l&&i('link[rel="manifest"]',()=>{const u=document.createElement("link");return u.rel="manifest",u},u=>{u.href=l})}return n},[e,t,o]),null},Vo=()=>{const e=G.useNavigate(),[t,r]=g.useState(null);return g.useEffect(()=>{(async()=>{try{const a=await Jr();a.success||a.responseStatus===401?setTimeout(()=>{e("/app/login")},1500):(r(a.response?.message||"An error occurred while logging out. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3))}catch(a){console.error("Logout error:",a),r("An error occurred. Redirecting to login..."),setTimeout(()=>{e("/app/login")},2e3)}})()},[e]),s.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",backgroundColor:"#f5f5f5"},children:[s.jsx("div",{style:{backgroundColor:"white",padding:"40px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",textAlign:"center",maxWidth:"400px",width:"100%"},children:t?s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px",color:"#ef4444"},children:s.jsx("svg",{width:"50",height:"50",fill:"none",viewBox:"0 0 24 24",style:{margin:"0 auto"},children:s.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logout Error"}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:t})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{marginBottom:"20px"},children:s.jsx("div",{style:{width:"50px",height:"50px",border:"3px solid #f3f3f3",borderTop:"3px solid var(--primary-color, #3b82f6)",borderRadius:"50%",margin:"0 auto",animation:"spin 1s linear infinite"}})}),s.jsx("h2",{style:{fontSize:"24px",fontWeight:"600",marginBottom:"12px",color:"#333"},children:"Logging you out..."}),s.jsx("p",{style:{fontSize:"16px",color:"#666",margin:0},children:"Please wait while we securely log you out."})]})}),s.jsx("style",{children:`
172
191
  @keyframes spin {
173
192
  0% { transform: rotate(0deg); }
174
193
  100% { transform: rotate(360deg); }
175
194
  }
176
- `})]})},ul=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Se();return e.length===0&&t?.user_role&&t.user_role,s.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:s.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[s.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),s.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),s.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),s.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),s.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),s.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[s.jsx("li",{children:"Appbuilder package routes are configured correctly"}),s.jsx("li",{children:"Required policies are properly mapped"}),s.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),s.jsxs("div",{className:"flex gap-3 justify-center",children:[s.jsx(p.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),s.jsx(p.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},Oo=({customPages:e})=>{const t=H.useParams(),o=`${H.useLocation().pathname}-${Object.values(t).join("-")}`;return s.jsx(it,{customPages:e},o)},hl=({customPages:e})=>{const{routes:t,loading:r,menu:o,pageTypeRegistry:a,registryError:n}=Se(),i=o.length>0?o[0].uri:null;if(r)return s.jsx("div",{className:"zango-loading",children:"Loading..."});if(n)return s.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",n]});const c=[],d=[];return a&&t.forEach(l=>{const u=a[l.page_type];u&&u.standalone?c.push(l):d.push(l)}),s.jsxs(H.Routes,{children:[s.jsx(H.Route,{path:"app/login/*",element:s.jsx(dr,{basePath:"/app/login"})}),s.jsx(H.Route,{path:"app/logout",element:s.jsx(To,{})}),s.jsx(H.Route,{path:"app/configuration-error",element:s.jsx(ul,{})}),c.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(it,{customPages:e,forceRoute:l})}),s.jsx(H.Route,{path:u,element:s.jsx(it,{customPages:e,forceRoute:l})})]},l.path)}),s.jsxs(H.Route,{path:"/",element:s.jsx(No,{}),children:[s.jsx(H.Route,{index:!0,element:i?s.jsx(H.Navigate,{to:i}):s.jsx("div",{children:"No menu items available"})}),s.jsx(H.Route,{path:"app",element:s.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),d.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(Oo,{customPages:e})}),s.jsx(H.Route,{path:u,element:s.jsx(Oo,{customPages:e})})]},l.path)})]}),s.jsx(H.Route,{path:"*",element:s.jsx(it,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),s.jsx(H.Route,{path:"/404",element:s.jsx(it,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},pl=({customPages:e})=>s.jsxs(s.Fragment,{children:[s.jsx(Eo,{}),s.jsx(hl,{customPages:e})]}),fl=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>(i&&typeof window<"u"&&(console.log("app init endpoint here",i),window.app_initializer_endpoint=i),s.jsx(H.BrowserRouter,{children:s.jsx(bo,{config:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,children:s.jsx(pl,{customPages:t})})})),gl=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>s.jsxs(s.Fragment,{children:[s.jsx(fl,{config:t,customPages:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,appInitializerEndpoint:i}),s.jsx(p.Toaster,{position:"bottom-right"})]});class ml{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const o=encodeURIComponent(r),a=`${t}?next=${o}`;window.location.href=a}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...n)=>{try{const[i,c={}]=n,d=Date.now().toString(),l=new Headers(c.headers||{});l.set("X-Client-Timestamp",d),l.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),l.set("X-Client-Platform",navigator.platform);const u={...c,headers:l},h=await t(i,u),w=window.location.origin+"/login/";return h.url&&h.url===w&&r.handleRedirect("/app/login/"),h}catch(i){throw i}};const o=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(...n){return this._requestUrl=n[1],o.apply(this,n)},XMLHttpRequest.prototype.send=function(...n){const i=this,c=Date.now().toString();return this.setRequestHeader("X-Client-Timestamp",c),this.setRequestHeader("X-User-Agent",navigator.userAgent),this.setRequestHeader("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),this.setRequestHeader("X-Client-Platform",navigator.platform),this.addEventListener("load",function(){const d=i.responseURL||i._requestUrl,l=window.location.origin+"/login/";d&&d===l&&r.handleRedirect("/app/login/")}),a.apply(this,n)}}}new ml,B.AppProvider=bo,B.CachedLogo=mr,B.CrudPage=es,B.CustomPageFallback=rs,B.CustomPageLoader=ss,B.DocumentHead=Eo,B.Layout=No,B.LoginPage=dr,B.LogoutPage=To,B.Navbar=vo,B.NotFoundPage=jt,B.SmartLink=Nt,B.Topbar=Lo,B.UserProfileDrawer=_o,B.ZangoApp=gl,B.buildApiUrl=me,B.callApi=we,B.callDeleteApi=Cr,B.callGetApi=wr,B.callPatchApi=vr,B.callPostApi=yr,B.callPutApi=br,B.changePassword=Ar,B.changeRole=qr,B.deleteCookie=_e,B.fetchAppInitData=Mr,B.fetchUserProfile=Ur,B.fetchUserSessions=Br,B.generateCSSVariables=pt,B.generatePalette=Be,B.generateQueryString=zo,B.getApiConfig=ba,B.getApiTimeout=Do,B.getApiUrl=ct,B.getAppInitData=xr,B.getColor=Qr,B.getContrastColor=wa,B.getCookie=ur,B.getEndpoint=jo,B.getUserProfile=Pr,B.getUserSessions=Nr,B.isAuthenticatedViaCookie=Po,B.isLightColor=Yr,B.logoCache=Ue,B.logout=Or,B.logoutAllSessions=Tr,B.logoutSession=Er,B.performAppLogout=jr,B.performDirectLogout=Dr,B.performLogout=Fr,B.removeAllSessions=$r,B.removeSession=Vr,B.saveUserProfile=dt,B.setCookie=xo,B.setTwoFactor=Zo,B.switchRole=Lr,B.toggleTwoFactor=_r,B.updatePassword=Ir,B.updateSvgColors=Et,B.updateUserProfile=Sr,B.uploadPhoto=Wo,B.uploadProfilePhoto=kr,B.useApiConfig=Re,B.useAppContext=Se,B.useRouteConfig=ya,B.useSmartNavigation=Co}));
195
+ `})]})},kl=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Pe();return e.length===0&&t?.user_role&&t.user_role,s.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:s.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[s.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),s.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),s.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),s.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),s.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),s.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[s.jsx("li",{children:"Appbuilder package routes are configured correctly"}),s.jsx("li",{children:"Required policies are properly mapped"}),s.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),s.jsxs("div",{className:"flex gap-3 justify-center",children:[s.jsx(p.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),s.jsx(p.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},jo=({customPages:e})=>{const t=G.useParams(),o=`${G.useLocation().pathname}-${Object.values(t).join("-")}`;return s.jsx(ft,{customPages:e},o)},Al=({customPages:e})=>{const{routes:t,loading:r,menu:o,pageTypeRegistry:a,registryError:n}=Pe(),i=o.length>0?o[0].uri:null;if(r)return s.jsx("div",{className:"zango-loading",children:"Loading..."});if(n)return s.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",n]});const c=[],d=[];return a&&t.forEach(l=>{const u=a[l.page_type];u&&u.standalone?c.push(l):d.push(l)}),s.jsxs(G.Routes,{children:[s.jsx(G.Route,{path:"app/login/*",element:s.jsx(wr,{basePath:"/app/login"})}),s.jsx(G.Route,{path:"app/logout",element:s.jsx(Vo,{})}),s.jsx(G.Route,{path:"app/configuration-error",element:s.jsx(kl,{})}),c.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(g.Fragment,{children:[s.jsx(G.Route,{path:`${u}/*`,element:s.jsx(ft,{customPages:e,forceRoute:l})}),s.jsx(G.Route,{path:u,element:s.jsx(ft,{customPages:e,forceRoute:l})})]},l.path)}),s.jsxs(G.Route,{path:"/",element:s.jsx(Io,{}),children:[s.jsx(G.Route,{index:!0,element:i?s.jsx(G.Navigate,{to:i}):s.jsx("div",{children:"No menu items available"})}),s.jsx(G.Route,{path:"app",element:s.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),d.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(g.Fragment,{children:[s.jsx(G.Route,{path:`${u}/*`,element:s.jsx(jo,{customPages:e})}),s.jsx(G.Route,{path:u,element:s.jsx(jo,{customPages:e})})]},l.path)})]}),s.jsx(G.Route,{path:"*",element:s.jsx(ft,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),s.jsx(G.Route,{path:"/404",element:s.jsx(ft,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},_l=({customPages:e})=>s.jsxs(s.Fragment,{children:[s.jsx($o,{}),s.jsx(Al,{customPages:e})]}),Ll=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={},appInitializerEndpoint:c})=>(c&&typeof window<"u"&&(console.log("app init endpoint here",c),window.app_initializer_endpoint=c),s.jsx(G.BrowserRouter,{children:s.jsx(Lo,{config:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,children:s.jsx(_l,{customPages:t})})})),Tl=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},authConfig:i={},appInitializerEndpoint:c})=>s.jsxs(s.Fragment,{children:[s.jsx(Ll,{config:t,customPages:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,authConfig:i,appInitializerEndpoint:c}),s.jsx(p.Toaster,{position:"bottom-right"})]});class Nl{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const o=encodeURIComponent(r),a=`${t}?next=${o}`;window.location.href=a}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...n)=>{try{const[i,c={}]=n,d=typeof i=="string"?i:i.toString();if(d.startsWith("http")&&!d.startsWith(window.location.origin))return await t(i,c);const u=Date.now().toString(),h=new Headers(c.headers||{});h.set("X-Client-Timestamp",u),h.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),h.set("X-Client-Platform",navigator.platform);const m={...c,headers:h},w=await t(i,m),f=window.location.origin+"/login/";return w.url&&w.url===f&&r.handleRedirect("/app/login/"),w}catch(i){throw i}};const o=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(...n){return this._requestUrl=n[1],o.apply(this,n)},XMLHttpRequest.prototype.send=function(...n){const i=this,c=this._requestUrl||"";if(!(c.startsWith("http")&&!c.startsWith(window.location.origin))){const l=Date.now().toString();this.setRequestHeader("X-Client-Timestamp",l),this.setRequestHeader("X-User-Agent",navigator.userAgent),this.setRequestHeader("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),this.setRequestHeader("X-Client-Platform",navigator.platform)}return this.addEventListener("load",function(){const l=i.responseURL||i._requestUrl,u=window.location.origin+"/login/";l&&l===u&&r.handleRedirect("/app/login/")}),a.apply(this,n)}}}new Nl,q.AppProvider=Lo,q.CachedLogo=Pr,q.CrudPage=is,q.CustomPageFallback=cs,q.CustomPageLoader=ds,q.DocumentHead=$o,q.Layout=Io,q.LoginPage=wr,q.LogoutPage=Vo,q.Navbar=No,q.NotFoundPage=zt,q.SmartLink=Mt,q.Topbar=qo,q.UserProfileDrawer=Bo,q.ZangoApp=Tl,q.buildApiUrl=Ce,q.callApi=ve,q.callDeleteApi=_r,q.callGetApi=Sr,q.callPatchApi=Lr,q.callPostApi=kr,q.callPutApi=Ar,q.changePassword=Or,q.changeRole=Wr,q.deleteCookie=Ne,q.fetchAppInitData=jr,q.fetchUserProfile=Dr,q.fetchUserSessions=Hr,q.generateCSSVariables=yt,q.generatePalette=je,q.generateQueryString=Ro,q.getApiConfig=La,q.getApiTimeout=Qo,q.getApiUrl=pt,q.getAppInitData=Tr,q.getColor=as,q.getContrastColor=Aa,q.getCookie=yr,q.getEndpoint=Xo,q.getUserProfile=Nr,q.getUserSessions=Br,q.isAuthenticatedViaCookie=Fo,q.isLightColor=os,q.logoCache=Ve,q.logout=$r,q.logoutAllSessions=Ir,q.logoutSession=qr,q.performAppLogout=Kr,q.performDirectLogout=Jr,q.performLogout=Vr,q.removeAllSessions=Gr,q.removeSession=Zr,q.saveUserProfile=gt,q.setCookie=Eo,q.setTwoFactor=ta,q.switchRole=Ur,q.toggleTwoFactor=Mr,q.updatePassword=zr,q.updateSvgColors=Ut,q.updateUserProfile=Er,q.uploadPhoto=ea,q.uploadProfilePhoto=Fr,q.useApiConfig=at,q.useAppContext=Pe,q.useRouteConfig=_a,q.useSmartNavigation=To}));
177
196
  //# sourceMappingURL=zango-crm-framework.umd.cjs.map