@adonis-agora/authkit-server 0.83.0 → 0.85.0
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.
- package/build/host/views/login.edge +25 -5
- package/build/host/views/partials/styles.edge +1 -1
- package/build/src/commands/settings_commands.js +9 -0
- package/build/src/define_config.d.ts +11 -0
- package/build/src/define_config.js +1 -0
- package/build/src/host/config_locks.js +2 -0
- package/build/src/host/controllers/interaction_controller.js +13 -0
- package/build/src/host/controllers/registration_controller.js +3 -0
- package/build/src/host/controllers/social_controller.js +29 -14
- package/build/src/host/i18n.d.ts +2 -0
- package/build/src/host/i18n.js +3 -0
- package/build/src/host/last_login_method.d.ts +67 -0
- package/build/src/host/last_login_method.js +119 -0
- package/build/src/host/runtime_toggles.d.ts +26 -0
- package/build/src/host/runtime_toggles.js +31 -0
- package/build/src/host/ui-dist/assets/{index-DhQzXw2i.js → index-BV2WkBd5.js} +1 -1
- package/build/src/host/ui-dist/index.html +1 -1
- package/build/src/provider/interaction_actions.js +7 -0
- package/package.json +2 -2
|
@@ -19,7 +19,13 @@
|
|
|
19
19
|
@end
|
|
20
20
|
|
|
21
21
|
<div class="mt-6">
|
|
22
|
-
|
|
22
|
+
{{-- Selo "último usado": este dispositivo entrou por e-mail (senha, link, código ou passkey). --}}
|
|
23
|
+
<div class="mb-1 flex items-center justify-between">
|
|
24
|
+
<label for="email" class="block text-sm font-medium text-gray-700">{{ t('login.email_label') }}</label>
|
|
25
|
+
@if(['password', 'magic_link', 'otp', 'passkey'].includes(lastUsedLoginMethod))
|
|
26
|
+
<span class="rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">{{ t('login.last_used') }}</span>
|
|
27
|
+
@end
|
|
28
|
+
</div>
|
|
23
29
|
<input id="email" name="email" type="email" required autofocus
|
|
24
30
|
autocomplete="{{ authMethods && authMethods.passkeyAutofill ? 'username webauthn' : 'username' }}"
|
|
25
31
|
class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm outline-hidden transition focus:border-gray-900 focus:ring-2 focus:ring-gray-900" />
|
|
@@ -49,7 +55,7 @@
|
|
|
49
55
|
|
|
50
56
|
@each(provider in (authMethods && authMethods.social ? authMethods.social : []))
|
|
51
57
|
<a href="/auth/{{ provider }}/redirect/{{ uid }}"
|
|
52
|
-
class="flex w-full items-center justify-center gap-2 rounded-lg border border-gray-300 bg-white py-2.5 text-sm font-medium text-gray-700 transition hover:bg-gray-50 mb-2">
|
|
58
|
+
class="relative flex w-full items-center justify-center gap-2 rounded-lg border border-gray-300 bg-white py-2.5 text-sm font-medium text-gray-700 transition hover:bg-gray-50 mb-2">
|
|
53
59
|
@if(provider === 'google')
|
|
54
60
|
<svg class="h-4 w-4" viewBox="0 0 24 24" aria-hidden="true">
|
|
55
61
|
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.27-4.74 3.27-8.1Z"/>
|
|
@@ -61,6 +67,9 @@
|
|
|
61
67
|
@else
|
|
62
68
|
{{ t('login.social_provider', { provider: provider }) }}
|
|
63
69
|
@end
|
|
70
|
+
@if(lastUsedLoginMethod === 'social:' + provider)
|
|
71
|
+
<span class="pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">{{ t('login.last_used') }}</span>
|
|
72
|
+
@end
|
|
64
73
|
</a>
|
|
65
74
|
@end
|
|
66
75
|
@end
|
|
@@ -106,7 +115,12 @@
|
|
|
106
115
|
@end
|
|
107
116
|
|
|
108
117
|
<div class="mt-6">
|
|
109
|
-
<
|
|
118
|
+
<div class="mb-1 flex items-center justify-between">
|
|
119
|
+
<label for="password" class="block text-sm font-medium text-gray-700">{{ t('login.password_label') }}</label>
|
|
120
|
+
@if(lastUsedLoginMethod === 'password')
|
|
121
|
+
<span class="rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">{{ t('login.last_used') }}</span>
|
|
122
|
+
@end
|
|
123
|
+
</div>
|
|
110
124
|
<input id="password" name="password" type="password" required autofocus
|
|
111
125
|
class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm outline-hidden transition focus:border-gray-900 focus:ring-2 focus:ring-gray-900" />
|
|
112
126
|
</div>
|
|
@@ -189,8 +203,11 @@
|
|
|
189
203
|
<form method="POST" action="/auth/interaction/{{ uid }}/magic" class="mt-4">
|
|
190
204
|
<input type="hidden" name="_csrf" value="{{ csrfToken }}">
|
|
191
205
|
<button type="submit"
|
|
192
|
-
class="w-full rounded-lg border border-gray-300 py-2.5 text-sm font-semibold text-gray-700 transition hover:bg-gray-50">
|
|
206
|
+
class="relative w-full rounded-lg border border-gray-300 py-2.5 text-sm font-semibold text-gray-700 transition hover:bg-gray-50">
|
|
193
207
|
{{ t('login.magic_link_button') }}
|
|
208
|
+
@if(lastUsedLoginMethod === 'magic_link' || lastUsedLoginMethod === 'otp')
|
|
209
|
+
<span class="pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">{{ t('login.last_used') }}</span>
|
|
210
|
+
@end
|
|
194
211
|
</button>
|
|
195
212
|
</form>
|
|
196
213
|
@end
|
|
@@ -204,8 +221,11 @@
|
|
|
204
221
|
<input type="hidden" name="response" id="passkey-response">
|
|
205
222
|
</form>
|
|
206
223
|
<button type="button" id="passkey-button"
|
|
207
|
-
class="mt-4 w-full rounded-lg border border-gray-300 py-2.5 text-sm font-semibold text-gray-700 transition hover:bg-gray-50">
|
|
224
|
+
class="relative mt-4 w-full rounded-lg border border-gray-300 py-2.5 text-sm font-semibold text-gray-700 transition hover:bg-gray-50">
|
|
208
225
|
{{ t('login.passkey_button') }}
|
|
226
|
+
@if(lastUsedLoginMethod === 'passkey')
|
|
227
|
+
<span class="pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">{{ t('login.last_used') }}</span>
|
|
228
|
+
@end
|
|
209
229
|
</button>
|
|
210
230
|
<p id="passkey-error" class="mt-3 hidden text-sm text-red-600">{{ t('mfa_challenge.passkey_error') }}</p>
|
|
211
231
|
{{-- M12: script inline sem nonce é bloqueado por CSP `script-src 'self'` — extraído
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{{-- Gerado por scripts/build_host_css.mjs — não editar à mão. --}}
|
|
2
2
|
<style>/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
3
|
-
@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-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking: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}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-800:oklch(47.3% .137 46.201);--color-green-50:oklch(98.2% .018 155.826);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--tracking-widest:.1em;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}button:not(:disabled),[role=button]:not(:disabled){cursor:pointer}}@layer components;@layer utilities{.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.my-4{margin-block:calc(var(--spacing) * 4)}.my-6{margin-block:calc(var(--spacing) * 6)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.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}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-48{height:calc(var(--spacing) * 48)}.h-px{height:1px}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-48{width:calc(var(--spacing) * 48)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.flex-1{flex:1}.cursor-pointer{cursor:pointer}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-gray-100>:not(:last-child)){border-color:var(--color-gray-100)}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-blue-300{border-color:var(--color-blue-300)}.border-emerald-300{border-color:var(--color-emerald-300)}.border-gray-100{border-color:var(--color-gray-100)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-900{border-color:var(--color-gray-900)}.border-red-200{border-color:var(--color-red-200)}.border-red-300{border-color:var(--color-red-300)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-100{background-color:var(--color-emerald-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-50{background-color:var(--color-green-50)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-600{background-color:var(--color-red-600)}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.4em\]{--tw-tracking:.4em;letter-spacing:.4em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.text-amber-600{color:var(--color-amber-600)}.text-amber-800{color:var(--color-amber-800)}.text-blue-800{color:var(--color-blue-800)}.text-blue-900{color:var(--color-blue-900)}.text-emerald-600{color:var(--color-emerald-600)}.text-emerald-700{color:var(--color-emerald-700)}.text-emerald-800{color:var(--color-emerald-800)}.text-emerald-900{color:var(--color-emerald-900)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-700{color:var(--color-green-700)}.text-red-600{color:var(--color-red-600)}.text-red-700{color:var(--color-red-700)}.text-red-800{color:var(--color-red-800)}.text-red-900{color:var(--color-red-900)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-amber-200{--tw-ring-color:var(--color-amber-200)}.ring-black\/5{--tw-ring-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.ring-black\/5{--tw-ring-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.ring-blue-200{--tw-ring-color:var(--color-blue-200)}.ring-emerald-200{--tw-ring-color:var(--color-emerald-200)}.ring-gray-900{--tw-ring-color:var(--color-gray-900)}.ring-red-200{--tw-ring-color:var(--color-red-200)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.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,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}@media (hover:hover){.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-90:hover{opacity:.9}}.focus\:border-gray-900:focus{border-color:var(--color-gray-900)}.focus\:border-red-600:focus{border-color:var(--color-red-600)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-gray-900:focus{--tw-ring-color:var(--color-gray-900)}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{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}</style>
|
|
3
|
+
@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-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking: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}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-800:oklch(47.3% .137 46.201);--color-green-50:oklch(98.2% .018 155.826);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--tracking-widest:.1em;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}button:not(:disabled),[role=button]:not(:disabled){cursor:pointer}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.top-1\/2{top:50%}.right-2{right:calc(var(--spacing) * 2)}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.my-4{margin-block:calc(var(--spacing) * 4)}.my-6{margin-block:calc(var(--spacing) * 6)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.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}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-48{height:calc(var(--spacing) * 48)}.h-px{height:1px}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-48{width:calc(var(--spacing) * 48)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.flex-1{flex:1}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.cursor-pointer{cursor:pointer}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-gray-100>:not(:last-child)){border-color:var(--color-gray-100)}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-blue-300{border-color:var(--color-blue-300)}.border-emerald-300{border-color:var(--color-emerald-300)}.border-gray-100{border-color:var(--color-gray-100)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-900{border-color:var(--color-gray-900)}.border-red-200{border-color:var(--color-red-200)}.border-red-300{border-color:var(--color-red-300)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-100{background-color:var(--color-emerald-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-50{background-color:var(--color-green-50)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-600{background-color:var(--color-red-600)}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.4em\]{--tw-tracking:.4em;letter-spacing:.4em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.text-amber-600{color:var(--color-amber-600)}.text-amber-800{color:var(--color-amber-800)}.text-blue-800{color:var(--color-blue-800)}.text-blue-900{color:var(--color-blue-900)}.text-emerald-600{color:var(--color-emerald-600)}.text-emerald-700{color:var(--color-emerald-700)}.text-emerald-800{color:var(--color-emerald-800)}.text-emerald-900{color:var(--color-emerald-900)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-700{color:var(--color-green-700)}.text-red-600{color:var(--color-red-600)}.text-red-700{color:var(--color-red-700)}.text-red-800{color:var(--color-red-800)}.text-red-900{color:var(--color-red-900)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-amber-200{--tw-ring-color:var(--color-amber-200)}.ring-black\/5{--tw-ring-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.ring-black\/5{--tw-ring-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.ring-blue-200{--tw-ring-color:var(--color-blue-200)}.ring-emerald-200{--tw-ring-color:var(--color-emerald-200)}.ring-gray-900{--tw-ring-color:var(--color-gray-900)}.ring-red-200{--tw-ring-color:var(--color-red-200)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.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,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}@media (hover:hover){.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-90:hover{opacity:.9}}.focus\:border-gray-900:focus{border-color:var(--color-gray-900)}.focus\:border-red-600:focus{border-color:var(--color-red-600)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-gray-900:focus{--tw-ring-color:var(--color-gray-900)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{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}</style>
|
|
@@ -83,6 +83,15 @@ function validateKnownKey(key, value) {
|
|
|
83
83
|
}
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
|
+
case SETTING_KEYS.SOCIAL_SECOND_FACTOR: {
|
|
87
|
+
if ('policy' in obj && !['enrolled', 'required', 'never'].includes(obj.policy))
|
|
88
|
+
return "social_second_factor.policy must be 'enrolled', 'required' or 'never'";
|
|
89
|
+
if ('requiredRoles' in obj &&
|
|
90
|
+
(!Array.isArray(obj.requiredRoles) ||
|
|
91
|
+
obj.requiredRoles.some((r) => typeof r !== 'string')))
|
|
92
|
+
return 'social_second_factor.requiredRoles must be string[]';
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
86
95
|
case SETTING_KEYS.TRUSTED_DEVICES: {
|
|
87
96
|
if ('enabled' in obj && typeof obj.enabled !== 'boolean')
|
|
88
97
|
return 'trusted_devices.enabled must be boolean';
|
|
@@ -39,6 +39,9 @@ export interface AuthSocialConfig {
|
|
|
39
39
|
* 2º fator no login social. Aceita uma política fixa ou uma função por conta
|
|
40
40
|
* (ex.: `'required'` só para papéis administrativos). Default: `'enrolled'`.
|
|
41
41
|
*
|
|
42
|
+
* Omitido, a política vem da setting `social_second_factor` do console admin
|
|
43
|
+
* (política + papéis que sempre exigem o fator). Declarado, TRAVA essa setting.
|
|
44
|
+
*
|
|
42
45
|
* `roles` vem da MESMA fonte do claim de papéis: `resolveTokenRoles` quando o
|
|
43
46
|
* host o configura (ex.: `@adonis-agora/authz`), senão `account.globalRoles`.
|
|
44
47
|
* Só é resolvido quando a política é uma função.
|
|
@@ -586,10 +589,18 @@ export interface LoginConfigInput {
|
|
|
586
589
|
* idêntico ao de antes, e-mail idêntico). Ver `host/otp_login.ts`.
|
|
587
590
|
*/
|
|
588
591
|
otp?: OtpLoginConfigInput;
|
|
592
|
+
/**
|
|
593
|
+
* Selo "último usado" na tela de login: o método com que este dispositivo
|
|
594
|
+
* entrou da última vez (senha, link, código, passkey, social) fica num cookie
|
|
595
|
+
* sem identidade e a tela o destaca. Por dispositivo, nunca por conta — não
|
|
596
|
+
* vaza como uma conta entra. Default: **ligado**. Ver `host/last_login_method.ts`.
|
|
597
|
+
*/
|
|
598
|
+
lastUsedMethod?: boolean;
|
|
589
599
|
}
|
|
590
600
|
export interface ResolvedLoginConfig {
|
|
591
601
|
requireVerifiedEmail: boolean;
|
|
592
602
|
otp: ResolvedOtpLoginConfig;
|
|
603
|
+
lastUsedMethod: boolean;
|
|
593
604
|
}
|
|
594
605
|
export declare function resolveLogin(input?: LoginConfigInput): ResolvedLoginConfig;
|
|
595
606
|
/**
|
|
@@ -154,6 +154,7 @@ export function resolveLogin(input) {
|
|
|
154
154
|
return {
|
|
155
155
|
requireVerifiedEmail: input?.requireVerifiedEmail ?? false,
|
|
156
156
|
otp: resolveOtpLoginConfig(input?.otp),
|
|
157
|
+
lastUsedMethod: input?.lastUsedMethod ?? true,
|
|
157
158
|
};
|
|
158
159
|
}
|
|
159
160
|
export function resolveRegistration(input) {
|
|
@@ -41,6 +41,8 @@ export function deriveLockedSettingKeys(config) {
|
|
|
41
41
|
add(config.organizations !== undefined, SETTING_KEYS.ORGANIZATIONS_POLICY);
|
|
42
42
|
add(config.admin?.impersonation !== undefined, SETTING_KEYS.ADMIN_IMPERSONATION);
|
|
43
43
|
add(config.ttl !== undefined, SETTING_KEYS.TOKEN_TTL);
|
|
44
|
+
// `social.secondFactor` (política fixa ou função por conta) manda; o console não altera.
|
|
45
|
+
add(config.social?.secondFactor !== undefined, SETTING_KEYS.SOCIAL_SECOND_FACTOR);
|
|
44
46
|
return locked;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -10,6 +10,7 @@ import { beginCustomMfa, clearMfaFlow, customMfaViewProps, getMfaFlow, initializ
|
|
|
10
10
|
import { sendMagicLinkEmail, sendOtpUnlockEmail } from '../default_mailer.js';
|
|
11
11
|
import { normalizeEmailIdentifier } from '../email_identifier.js';
|
|
12
12
|
import { translate } from '../i18n.js';
|
|
13
|
+
import { readLastLoginMethod, rememberLastLoginMethod } from '../last_login_method.js';
|
|
13
14
|
import { assertLoginAllowed, attemptPasswordLogin, isEmailUnverifiedBlock, } from '../login_attempt.js';
|
|
14
15
|
import { magicChannelProp, normalizeLoginChannel } from '../login_channel.js';
|
|
15
16
|
import { notifyLoginSuccess } from '../login_notify.js';
|
|
@@ -125,6 +126,7 @@ export default class AuthInteractionController {
|
|
|
125
126
|
message: maintenance.message ?? translate(cfg.messages, 'maintenance.default_message'),
|
|
126
127
|
});
|
|
127
128
|
}
|
|
129
|
+
rememberLastLoginMethod(ctx, cfg, `custom:${input.method}`);
|
|
128
130
|
const gate = await this.secondFactorGate(ctx, cfg, account.id, details, input.method, input.factorId, input.remember, input.passwordless === true);
|
|
129
131
|
if (gate.kind === 'challenge') {
|
|
130
132
|
ctx.session.put(MFA_CUSTOM_PRIMARY_KEY, {
|
|
@@ -175,6 +177,8 @@ export default class AuthInteractionController {
|
|
|
175
177
|
authMethods,
|
|
176
178
|
magicLinkAvailable: authMethods.magicLink && magicLinkCapableConfig,
|
|
177
179
|
otpEnabled,
|
|
180
|
+
// Selo "último usado": método com que ESTE dispositivo entrou da última vez.
|
|
181
|
+
lastUsedLoginMethod: readLastLoginMethod(ctx, cfg),
|
|
178
182
|
};
|
|
179
183
|
}
|
|
180
184
|
/**
|
|
@@ -495,6 +499,7 @@ export default class AuthInteractionController {
|
|
|
495
499
|
// Gate do 2º fator — a MESMA regra dos três caminhos de login (ver
|
|
496
500
|
// `secondFactorGate`). Quando desafia, não finaliza a interaction: guarda o
|
|
497
501
|
// accountId pendente e devolve a tela.
|
|
502
|
+
rememberLastLoginMethod(ctx, cfg, 'password');
|
|
498
503
|
const gate = await this.secondFactorGate(ctx, cfg, acc.id, details, 'pwd');
|
|
499
504
|
if (gate.kind === 'challenge')
|
|
500
505
|
return gate.response;
|
|
@@ -1349,6 +1354,7 @@ export default class AuthInteractionController {
|
|
|
1349
1354
|
});
|
|
1350
1355
|
}
|
|
1351
1356
|
// Conta com segundo fator não termina o login só com o e-mail.
|
|
1357
|
+
rememberLastLoginMethod(ctx, cfg, 'magic_link');
|
|
1352
1358
|
const magicGate = await this.secondFactorGate(ctx, cfg, acc.id, await service.interactions.details(ctx), 'email');
|
|
1353
1359
|
if (magicGate.kind === 'challenge')
|
|
1354
1360
|
return magicGate.response;
|
|
@@ -1471,6 +1477,7 @@ export default class AuthInteractionController {
|
|
|
1471
1477
|
clientId,
|
|
1472
1478
|
});
|
|
1473
1479
|
// Conta com segundo fator não termina o login só com o código do e-mail.
|
|
1480
|
+
rememberLastLoginMethod(ctx, cfg, 'otp');
|
|
1474
1481
|
const otpGate = await this.secondFactorGate(ctx, cfg, result.account.id, await service.interactions.details(ctx), 'email');
|
|
1475
1482
|
if (otpGate.kind === 'challenge')
|
|
1476
1483
|
return otpGate.response;
|
|
@@ -1738,6 +1745,11 @@ export default class AuthInteractionController {
|
|
|
1738
1745
|
return ctx.response.redirect(`/auth/interaction/${ctx.request.param('uid')}`);
|
|
1739
1746
|
return this.finishVerifiedMfa(ctx, cfg, details, 'webauthn', 'webauthn');
|
|
1740
1747
|
}
|
|
1748
|
+
// Passkey como fator PRIMÁRIO (passkey-first/autofill). Como 2º fator ela não
|
|
1749
|
+
// é o método com que a pessoa se identificou — o selo fica com o primário.
|
|
1750
|
+
if (ctx.session.get(MFA_PENDING_KEY) !== accountId) {
|
|
1751
|
+
rememberLastLoginMethod(ctx, cfg, 'passkey');
|
|
1752
|
+
}
|
|
1741
1753
|
if (cfg.mfa) {
|
|
1742
1754
|
const gate = await this.secondFactorGate(ctx, cfg, accountId, details, 'webauthn');
|
|
1743
1755
|
if (gate.kind === 'challenge')
|
|
@@ -1845,6 +1857,7 @@ export default class AuthInteractionController {
|
|
|
1845
1857
|
// Senha trocada: limpa o step e finaliza o login.
|
|
1846
1858
|
ctx.session.forget(PASSWORD_EXPIRED_KEY);
|
|
1847
1859
|
// Verifica se precisa de MFA mesmo após a troca — mesma regra do resto.
|
|
1860
|
+
rememberLastLoginMethod(ctx, cfg, 'password');
|
|
1848
1861
|
const expiredGate = await this.secondFactorGate(ctx, cfg, accountId, details, 'pwd');
|
|
1849
1862
|
if (expiredGate.kind === 'challenge')
|
|
1850
1863
|
return expiredGate.response;
|
|
@@ -7,6 +7,7 @@ import { guardBotProtection, resolveEffectiveBotProtection } from '../bot_protec
|
|
|
7
7
|
import { brandFor } from '../branding.js';
|
|
8
8
|
import { sendEmailVerificationEmail, sendMagicLinkEmail, sendPasswordResetEmail, } from '../default_mailer.js';
|
|
9
9
|
import { translate } from '../i18n.js';
|
|
10
|
+
import { rememberLastLoginMethod } from '../last_login_method.js';
|
|
10
11
|
import { authkitOrigin } from '../origin.js';
|
|
11
12
|
import { RuntimeSettings, resolveRuntimeSettings } from '../runtime_settings.js';
|
|
12
13
|
import { resolveEffectiveAuthMethods, resolveEffectiveMaintenanceMode, resolveEffectiveRegistration, } from '../runtime_toggles.js';
|
|
@@ -165,6 +166,8 @@ export default class AuthRegistrationController {
|
|
|
165
166
|
ip: ctx.request.ip?.() ?? null,
|
|
166
167
|
clientId: details.params.client_id ?? null,
|
|
167
168
|
});
|
|
169
|
+
// Conta nova entra por senha: o selo "último usado" já nasce no método certo.
|
|
170
|
+
rememberLastLoginMethod(ctx, cfg, 'password');
|
|
168
171
|
// Finaliza a interaction como login (interactionFinished escreve o redirect 303 que
|
|
169
172
|
// retoma o authorize; o form nativo da tela segue esse redirect no sucesso).
|
|
170
173
|
const result = await service.interactions.login(ctx, {
|
|
@@ -3,9 +3,10 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { supportsLoginMethodsPreference, supportsMagicLink, supportsPasskeys, supportsProviderIdentity, } from '../../accounts/account_store.js';
|
|
4
4
|
import { resolveAccountRoles } from '../account_roles.js';
|
|
5
5
|
import { normalizeEmailIdentifier } from '../email_identifier.js';
|
|
6
|
+
import { rememberLastLoginMethod } from '../last_login_method.js';
|
|
6
7
|
import { assertLoginAllowed } from '../login_attempt.js';
|
|
7
8
|
import { resolveRuntimeSettingsOrNoop } from '../runtime_settings.js';
|
|
8
|
-
import { resolveEffectiveAuthMethods } from '../runtime_toggles.js';
|
|
9
|
+
import { resolveEffectiveAuthMethods, resolveEffectiveSocialSecondFactor, } from '../runtime_toggles.js';
|
|
9
10
|
import { SOCIAL_PENDING_KEY } from '../social_pending.js';
|
|
10
11
|
import { resolveEffectiveUserLoginMethods, } from '../user_login_methods.js';
|
|
11
12
|
const UID_SESSION_KEY = 'authkit_social_uid';
|
|
@@ -32,19 +33,32 @@ async function resolveGlobalAuthMethodsForUser(cfg, settings) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
|
-
* Política de 2º fator do login social para esta conta
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* Política de 2º fator do login social para esta conta.
|
|
37
|
+
*
|
|
38
|
+
* `social.secondFactor` no config manda (e trava a setting no console). Sem ele,
|
|
39
|
+
* vale a setting `social_second_factor` do console: a `policy` e, para quem tem
|
|
40
|
+
* um dos `requiredRoles`, `'required'`. Default `'enrolled'`. Os papéis vêm de
|
|
41
|
+
* `resolveAccountRoles` (o `resolveTokenRoles` do host, ex.: authz) e só são
|
|
42
|
+
* resolvidos quando há algo que dependa deles.
|
|
38
43
|
*/
|
|
39
|
-
async function resolveSecondFactorPolicy(cfg, account) {
|
|
40
|
-
const
|
|
41
|
-
if (typeof
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
async function resolveSecondFactorPolicy(cfg, account, settings) {
|
|
45
|
+
const fromConfig = cfg.social?.secondFactor;
|
|
46
|
+
if (typeof fromConfig === 'function') {
|
|
47
|
+
return await fromConfig({
|
|
48
|
+
id: account.id,
|
|
49
|
+
email: account.email,
|
|
50
|
+
roles: await resolveAccountRoles(cfg, account),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (fromConfig !== undefined)
|
|
54
|
+
return fromConfig;
|
|
55
|
+
const setting = await resolveEffectiveSocialSecondFactor(settings);
|
|
56
|
+
if (setting.policy !== 'required' && setting.requiredRoles.length > 0) {
|
|
57
|
+
const roles = await resolveAccountRoles(cfg, account);
|
|
58
|
+
if (roles.some((role) => setting.requiredRoles.includes(role)))
|
|
59
|
+
return 'required';
|
|
60
|
+
}
|
|
61
|
+
return setting.policy;
|
|
48
62
|
}
|
|
49
63
|
/** true se a conta tem TOTP confirmado ou ao menos uma passkey. */
|
|
50
64
|
async function hasEnrolledSecondFactor(store, accountId) {
|
|
@@ -196,11 +210,12 @@ export default class AuthSocialController {
|
|
|
196
210
|
}
|
|
197
211
|
}
|
|
198
212
|
ctx.session.forget(UID_SESSION_KEY);
|
|
213
|
+
rememberLastLoginMethod(ctx, cfg, `social:${provider}`);
|
|
199
214
|
// 2º fator: o provider provou a identidade, mas quem cadastrou TOTP/passkey
|
|
200
215
|
// aqui espera que o fator valha também neste caminho. O desafio mora no
|
|
201
216
|
// interaction controller (mesmo gate de senha/magic link/OTP), então este
|
|
202
217
|
// passo só registra o login pendente e manda o browser para lá.
|
|
203
|
-
const policy = await resolveSecondFactorPolicy(cfg, user);
|
|
218
|
+
const policy = await resolveSecondFactorPolicy(cfg, user, settings);
|
|
204
219
|
const needsGate = policy === 'required' ||
|
|
205
220
|
(policy === 'enrolled' && (!!cfg.mfa || (await hasEnrolledSecondFactor(store, user.id))));
|
|
206
221
|
if (needsGate) {
|
package/build/src/host/i18n.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare const DEFAULT_MESSAGES: {
|
|
|
50
50
|
'login.magic_link_sent': string;
|
|
51
51
|
'signup.magic_link_sent': string;
|
|
52
52
|
'login.passkey_button': string;
|
|
53
|
+
'login.last_used': string;
|
|
53
54
|
'login.otp_label': string;
|
|
54
55
|
'login.otp_placeholder': string;
|
|
55
56
|
'login.otp_submit': string;
|
|
@@ -809,6 +810,7 @@ export declare const PT_BR_MESSAGES: {
|
|
|
809
810
|
'login.magic_link_sent': string;
|
|
810
811
|
'signup.magic_link_sent': string;
|
|
811
812
|
'login.passkey_button': string;
|
|
813
|
+
'login.last_used': string;
|
|
812
814
|
'login.otp_label': string;
|
|
813
815
|
'login.otp_placeholder': string;
|
|
814
816
|
'login.otp_submit': string;
|
package/build/src/host/i18n.js
CHANGED
|
@@ -41,6 +41,8 @@ export const DEFAULT_MESSAGES = {
|
|
|
41
41
|
'login.magic_link_sent': 'If the account exists, we sent you a login link.',
|
|
42
42
|
'signup.magic_link_sent': 'Check your email — we sent you a link to finish creating your account.',
|
|
43
43
|
'login.passkey_button': 'Sign in with a passkey',
|
|
44
|
+
// Selo do método com que este dispositivo entrou da última vez.
|
|
45
|
+
'login.last_used': 'Last used',
|
|
44
46
|
// Login por OTP (código digitável).
|
|
45
47
|
'login.otp_label': 'Enter the login code from the email',
|
|
46
48
|
'login.otp_placeholder': '000000',
|
|
@@ -891,6 +893,7 @@ export const PT_BR_MESSAGES = {
|
|
|
891
893
|
'login.magic_link_sent': 'Se a conta existir, enviamos um link de login.',
|
|
892
894
|
'signup.magic_link_sent': 'Enviamos um link para o seu e-mail. Abra-o para concluir o cadastro.',
|
|
893
895
|
'login.passkey_button': 'Entrar com passkey',
|
|
896
|
+
'login.last_used': 'Último usado',
|
|
894
897
|
// Login por OTP (código digitável).
|
|
895
898
|
'login.otp_label': 'Digite o código de login do e-mail',
|
|
896
899
|
'login.otp_placeholder': '000000',
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
/**
|
|
3
|
+
* "Último método usado" no login (o selo "Last used" do Cloudflare, Vercel, Clerk…).
|
|
4
|
+
*
|
|
5
|
+
* O método fica num cookie DESTE DISPOSITIVO, não na conta. É de propósito:
|
|
6
|
+
* - o passo 1 (identifier) ainda não sabe quem é o usuário, e é exatamente ali
|
|
7
|
+
* que o selo mais ajuda ("da última vez você entrou com Google");
|
|
8
|
+
* - guardar por conta e mostrar no passo 2 diria a quem digita um e-mail qualquer
|
|
9
|
+
* como aquela conta entra — vazamento de enumeração. O cookie só conta ao
|
|
10
|
+
* próprio browser o que ele mesmo fez.
|
|
11
|
+
*
|
|
12
|
+
* O cookie não carrega identidade nenhuma (nem e-mail, nem accountId), só o método.
|
|
13
|
+
* É puramente de SUPERFÍCIE: a tela destaca um botão, mas nada no fluxo muda — os
|
|
14
|
+
* métodos oferecidos continuam vindo de `authMethods`, e um valor adulterado no
|
|
15
|
+
* cookie só destaca outro botão (ou nenhum, se não passar na validação).
|
|
16
|
+
*
|
|
17
|
+
* Gravado quando o fator PRIMÁRIO é aceito. Numa conta com 2º fator, isso acontece
|
|
18
|
+
* antes do desafio de MFA: o selo responde "como você se identificou", que é o
|
|
19
|
+
* botão que a pessoa procura na próxima vez.
|
|
20
|
+
*/
|
|
21
|
+
/** Nome do cookie do último método de login. */
|
|
22
|
+
export declare const LAST_LOGIN_METHOD_COOKIE = "authkit_last_login";
|
|
23
|
+
/**
|
|
24
|
+
* Método de login primário. `social:<provider>` e `custom:<id>` carregam o id do
|
|
25
|
+
* provedor/método para a tela destacar o botão certo entre vários.
|
|
26
|
+
*/
|
|
27
|
+
export type LastLoginMethod = 'password' | 'magic_link' | 'otp' | 'passkey' | `social:${string}` | `custom:${string}`;
|
|
28
|
+
/**
|
|
29
|
+
* Valida um valor lido do cookie. Só os métodos conhecidos passam; qualquer outra
|
|
30
|
+
* coisa (ausente, lixo, valor adulterado) vira `undefined` — sem selo.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeLastLoginMethod(raw: unknown): LastLoginMethod | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Lê o último método deste dispositivo para a tela de login. Fail-safe: feature
|
|
35
|
+
* desligada, ctx sem cookies ou qualquer erro → `undefined` (sem selo).
|
|
36
|
+
*/
|
|
37
|
+
export declare function readLastLoginMethod(ctx: HttpContext, cfg: {
|
|
38
|
+
login?: {
|
|
39
|
+
lastUsedMethod?: boolean;
|
|
40
|
+
};
|
|
41
|
+
}): LastLoginMethod | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Registra o método primário que acabou de ser aceito. Grava via resposta do
|
|
44
|
+
* Adonis; quando o login termina no `interactionFinished` (que encerra a resposta
|
|
45
|
+
* crua), o `completeLogin` repassa o cookie pendente — ver
|
|
46
|
+
* {@link relayPendingCookies}. Best-effort: nunca derruba o login.
|
|
47
|
+
*/
|
|
48
|
+
export declare function rememberLastLoginMethod(ctx: HttpContext, cfg: {
|
|
49
|
+
login?: {
|
|
50
|
+
lastUsedMethod?: boolean;
|
|
51
|
+
};
|
|
52
|
+
}, method: LastLoginMethod): void;
|
|
53
|
+
/**
|
|
54
|
+
* Repassa os `Set-Cookie` que o handler gravou na resposta do Adonis para a
|
|
55
|
+
* resposta crua do Node.
|
|
56
|
+
*
|
|
57
|
+
* O Adonis só escreve os headers no `finish()`, depois do handler. Mas o
|
|
58
|
+
* `interactionFinished` do oidc-provider escreve o 303 e dá `res.end()` direto na
|
|
59
|
+
* resposta crua — quando o Adonis chega no `finish()`, a resposta já saiu e todo
|
|
60
|
+
* cookie gravado via `ctx.response.cookie()` no mesmo request é descartado em
|
|
61
|
+
* silêncio. Chamado pelo `completeLogin` logo antes do `interactionFinished`.
|
|
62
|
+
*
|
|
63
|
+
* Os cookies saem do Adonis ao serem repassados, então não há como irem em dobro.
|
|
64
|
+
* O `Set-Cookie` que o próprio oidc-provider grava depois é ACRESCENTADO aos
|
|
65
|
+
* existentes (a lib `cookies` do Koa preserva o header), então nada se perde.
|
|
66
|
+
*/
|
|
67
|
+
export declare function relayPendingCookies(ctx: HttpContext): void;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Último método usado" no login (o selo "Last used" do Cloudflare, Vercel, Clerk…).
|
|
3
|
+
*
|
|
4
|
+
* O método fica num cookie DESTE DISPOSITIVO, não na conta. É de propósito:
|
|
5
|
+
* - o passo 1 (identifier) ainda não sabe quem é o usuário, e é exatamente ali
|
|
6
|
+
* que o selo mais ajuda ("da última vez você entrou com Google");
|
|
7
|
+
* - guardar por conta e mostrar no passo 2 diria a quem digita um e-mail qualquer
|
|
8
|
+
* como aquela conta entra — vazamento de enumeração. O cookie só conta ao
|
|
9
|
+
* próprio browser o que ele mesmo fez.
|
|
10
|
+
*
|
|
11
|
+
* O cookie não carrega identidade nenhuma (nem e-mail, nem accountId), só o método.
|
|
12
|
+
* É puramente de SUPERFÍCIE: a tela destaca um botão, mas nada no fluxo muda — os
|
|
13
|
+
* métodos oferecidos continuam vindo de `authMethods`, e um valor adulterado no
|
|
14
|
+
* cookie só destaca outro botão (ou nenhum, se não passar na validação).
|
|
15
|
+
*
|
|
16
|
+
* Gravado quando o fator PRIMÁRIO é aceito. Numa conta com 2º fator, isso acontece
|
|
17
|
+
* antes do desafio de MFA: o selo responde "como você se identificou", que é o
|
|
18
|
+
* botão que a pessoa procura na próxima vez.
|
|
19
|
+
*/
|
|
20
|
+
/** Nome do cookie do último método de login. */
|
|
21
|
+
export const LAST_LOGIN_METHOD_COOKIE = 'authkit_last_login';
|
|
22
|
+
/** Validade do cookie: 1 ano (renovado a cada login). */
|
|
23
|
+
const LAST_LOGIN_METHOD_MAX_AGE = 365 * 24 * 60 * 60;
|
|
24
|
+
const FIXED_METHODS = new Set(['password', 'magic_link', 'otp', 'passkey']);
|
|
25
|
+
/** Ids de provedor/método: mesmo formato curto que vai em rota/config. */
|
|
26
|
+
const QUALIFIED_METHOD = /^(social|custom):[a-z0-9][a-z0-9_-]{0,63}$/i;
|
|
27
|
+
/**
|
|
28
|
+
* Valida um valor lido do cookie. Só os métodos conhecidos passam; qualquer outra
|
|
29
|
+
* coisa (ausente, lixo, valor adulterado) vira `undefined` — sem selo.
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeLastLoginMethod(raw) {
|
|
32
|
+
if (typeof raw !== 'string')
|
|
33
|
+
return undefined;
|
|
34
|
+
if (FIXED_METHODS.has(raw) || QUALIFIED_METHOD.test(raw))
|
|
35
|
+
return raw;
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/** `false` desliga a feature (`login.lastUsedMethod: false`); ausente = ligada. */
|
|
39
|
+
function isEnabled(cfg) {
|
|
40
|
+
return cfg.login?.lastUsedMethod !== false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Lê o último método deste dispositivo para a tela de login. Fail-safe: feature
|
|
44
|
+
* desligada, ctx sem cookies ou qualquer erro → `undefined` (sem selo).
|
|
45
|
+
*/
|
|
46
|
+
export function readLastLoginMethod(ctx, cfg) {
|
|
47
|
+
if (!isEnabled(cfg))
|
|
48
|
+
return undefined;
|
|
49
|
+
try {
|
|
50
|
+
return normalizeLastLoginMethod(ctx.request.plainCookie?.(LAST_LOGIN_METHOD_COOKIE));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Registra o método primário que acabou de ser aceito. Grava via resposta do
|
|
58
|
+
* Adonis; quando o login termina no `interactionFinished` (que encerra a resposta
|
|
59
|
+
* crua), o `completeLogin` repassa o cookie pendente — ver
|
|
60
|
+
* {@link relayPendingCookies}. Best-effort: nunca derruba o login.
|
|
61
|
+
*/
|
|
62
|
+
export function rememberLastLoginMethod(ctx, cfg, method) {
|
|
63
|
+
if (!isEnabled(cfg))
|
|
64
|
+
return;
|
|
65
|
+
if (!normalizeLastLoginMethod(method))
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
ctx.response.plainCookie?.(LAST_LOGIN_METHOD_COOKIE, method, {
|
|
69
|
+
httpOnly: true,
|
|
70
|
+
sameSite: 'lax',
|
|
71
|
+
path: '/',
|
|
72
|
+
maxAge: LAST_LOGIN_METHOD_MAX_AGE,
|
|
73
|
+
secure: ctx.request.secure?.() ?? false,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Selo é cosmético: falha ao gravar não interfere no login.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Repassa os `Set-Cookie` que o handler gravou na resposta do Adonis para a
|
|
82
|
+
* resposta crua do Node.
|
|
83
|
+
*
|
|
84
|
+
* O Adonis só escreve os headers no `finish()`, depois do handler. Mas o
|
|
85
|
+
* `interactionFinished` do oidc-provider escreve o 303 e dá `res.end()` direto na
|
|
86
|
+
* resposta crua — quando o Adonis chega no `finish()`, a resposta já saiu e todo
|
|
87
|
+
* cookie gravado via `ctx.response.cookie()` no mesmo request é descartado em
|
|
88
|
+
* silêncio. Chamado pelo `completeLogin` logo antes do `interactionFinished`.
|
|
89
|
+
*
|
|
90
|
+
* Os cookies saem do Adonis ao serem repassados, então não há como irem em dobro.
|
|
91
|
+
* O `Set-Cookie` que o próprio oidc-provider grava depois é ACRESCENTADO aos
|
|
92
|
+
* existentes (a lib `cookies` do Koa preserva o header), então nada se perde.
|
|
93
|
+
*/
|
|
94
|
+
export function relayPendingCookies(ctx) {
|
|
95
|
+
try {
|
|
96
|
+
const response = ctx.response;
|
|
97
|
+
const raw = response?.response;
|
|
98
|
+
if (!raw || typeof raw.setHeader !== 'function' || raw.headersSent)
|
|
99
|
+
return;
|
|
100
|
+
const pending = response.getHeader?.('set-cookie');
|
|
101
|
+
if (pending === undefined || pending === null)
|
|
102
|
+
return;
|
|
103
|
+
const toList = (value) => value === undefined || value === null
|
|
104
|
+
? []
|
|
105
|
+
: Array.isArray(value)
|
|
106
|
+
? value.map(String)
|
|
107
|
+
: [String(value)];
|
|
108
|
+
// O `getHeader` do Adonis também enxerga o que já está na resposta crua, então
|
|
109
|
+
// a lista pendente pode repetir o que lá está — dedup preservando a ordem.
|
|
110
|
+
const cookies = [...new Set([...toList(raw.getHeader?.('set-cookie')), ...toList(pending)])];
|
|
111
|
+
// O `removeHeader` do Adonis apaga também da resposta crua — por isso vem
|
|
112
|
+
// ANTES do `setHeader`, que regrava a lista completa.
|
|
113
|
+
response.removeHeader?.('set-cookie');
|
|
114
|
+
raw.setHeader('set-cookie', cookies);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Repasse é best-effort: nunca derruba o login.
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -40,6 +40,7 @@ export declare const SETTING_KEYS: {
|
|
|
40
40
|
readonly SUDO_MODE: 'sudo_mode';
|
|
41
41
|
readonly ACCOUNT_EXPIRATION: 'account_expiration';
|
|
42
42
|
readonly KEY_ROTATION: 'key_rotation';
|
|
43
|
+
readonly SOCIAL_SECOND_FACTOR: 'social_second_factor';
|
|
43
44
|
};
|
|
44
45
|
export type SettingKey = (typeof SETTING_KEYS)[keyof typeof SETTING_KEYS];
|
|
45
46
|
/**
|
|
@@ -835,3 +836,28 @@ export interface ResolvedAccountExpiration {
|
|
|
835
836
|
* FAIL-SAFE: qualquer erro → `{ enabled: false, inactiveDays: 365, warnDays: 14 }`.
|
|
836
837
|
*/
|
|
837
838
|
export declare function resolveEffectiveAccountExpiration(settings: SettingsCapability): Promise<ResolvedAccountExpiration>;
|
|
839
|
+
/** Política do 2º fator no login social (ver `AuthSocialConfig.secondFactor`). */
|
|
840
|
+
export type SocialSecondFactorPolicyValue = 'enrolled' | 'required' | 'never';
|
|
841
|
+
/**
|
|
842
|
+
* Shape da setting `social_second_factor` em `auth_settings` — o equivalente,
|
|
843
|
+
* editável no console, de `social.secondFactor` do config. Declarar
|
|
844
|
+
* `social.secondFactor` no `defineConfig` TRAVA esta key (config locks).
|
|
845
|
+
*
|
|
846
|
+
* - `policy`: `'enrolled'` | `'required'` | `'never'` (ver `SocialSecondFactorPolicy`).
|
|
847
|
+
* - `requiredRoles`: papéis que SEMPRE exigem o fator, qualquer que seja a
|
|
848
|
+
* `policy` (ex.: `['ADMIN']`). Os papéis vêm de `resolveAccountRoles` — a
|
|
849
|
+
* mesma fonte do claim, então valem com `resolveTokenRoles`/authz.
|
|
850
|
+
*/
|
|
851
|
+
export interface SocialSecondFactorSetting {
|
|
852
|
+
policy?: SocialSecondFactorPolicyValue;
|
|
853
|
+
requiredRoles?: string[];
|
|
854
|
+
}
|
|
855
|
+
export interface ResolvedSocialSecondFactorSetting {
|
|
856
|
+
policy: SocialSecondFactorPolicyValue;
|
|
857
|
+
requiredRoles: string[];
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Resolve a política efetiva da setting. Ausente ou inválida → `'enrolled'` sem
|
|
861
|
+
* papéis exigidos (o default da lib). FAIL-SAFE: qualquer erro → default.
|
|
862
|
+
*/
|
|
863
|
+
export declare function resolveEffectiveSocialSecondFactor(settings: SettingsCapability): Promise<ResolvedSocialSecondFactorSetting>;
|
|
@@ -42,6 +42,7 @@ export const SETTING_KEYS = {
|
|
|
42
42
|
SUDO_MODE: 'sudo_mode',
|
|
43
43
|
ACCOUNT_EXPIRATION: 'account_expiration',
|
|
44
44
|
KEY_ROTATION: 'key_rotation',
|
|
45
|
+
SOCIAL_SECOND_FACTOR: 'social_second_factor',
|
|
45
46
|
};
|
|
46
47
|
/**
|
|
47
48
|
* Resolve o valor efetivo de "registration enabled" combinando a setting
|
|
@@ -857,3 +858,33 @@ export async function resolveEffectiveAccountExpiration(settings) {
|
|
|
857
858
|
return defaults;
|
|
858
859
|
}
|
|
859
860
|
}
|
|
861
|
+
const SOCIAL_SECOND_FACTOR_POLICIES = [
|
|
862
|
+
'enrolled',
|
|
863
|
+
'required',
|
|
864
|
+
'never',
|
|
865
|
+
];
|
|
866
|
+
/**
|
|
867
|
+
* Resolve a política efetiva da setting. Ausente ou inválida → `'enrolled'` sem
|
|
868
|
+
* papéis exigidos (o default da lib). FAIL-SAFE: qualquer erro → default.
|
|
869
|
+
*/
|
|
870
|
+
export async function resolveEffectiveSocialSecondFactor(settings) {
|
|
871
|
+
const defaults = { policy: 'enrolled', requiredRoles: [] };
|
|
872
|
+
try {
|
|
873
|
+
const raw = await settings.getSetting(SETTING_KEYS.SOCIAL_SECOND_FACTOR);
|
|
874
|
+
if (raw === null || raw === undefined)
|
|
875
|
+
return defaults;
|
|
876
|
+
if (typeof raw !== 'object' || Array.isArray(raw))
|
|
877
|
+
return defaults;
|
|
878
|
+
const s = raw;
|
|
879
|
+
const policy = SOCIAL_SECOND_FACTOR_POLICIES.includes(s.policy)
|
|
880
|
+
? s.policy
|
|
881
|
+
: defaults.policy;
|
|
882
|
+
const requiredRoles = Array.isArray(s.requiredRoles)
|
|
883
|
+
? s.requiredRoles.filter((r) => typeof r === 'string' && r.trim() !== '')
|
|
884
|
+
: [];
|
|
885
|
+
return { policy, requiredRoles: requiredRoles.map((r) => r.trim()) };
|
|
886
|
+
}
|
|
887
|
+
catch {
|
|
888
|
+
return defaults;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
@@ -64,4 +64,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
64
64
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lP(e,t){if(e){if(typeof e==`string`)return uP(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uP(e,t):void 0}}function uP(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dP(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function fP(e){if(Array.isArray(e))return e}var pP=(0,b.createContext)(void 0),mP=e=>{var t=e.children,n=sP((0,b.useState)(`${Yo(`recharts`)}-clip`),1)[0],r=UN();if(r==null)return null;var i=r.x,a=r.y,o=r.width,s=r.height;return b.createElement(pP.Provider,{value:n},b.createElement(`defs`,null,b.createElement(`clipPath`,{id:n},b.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)};function hP(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function gP(e,t,n){return rP({width:e.width+t.width,height:e.height+t.height},n)}function _P(e,t,n){var r=n===`width`,i=e.x,a=e.y,o=e.width,s=e.height;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function vP(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function yP(e,t){return hP(e,t+1)}function bP(e,t,n,r,i){for(var a=(r||[]).slice(),o=t.start,s=t.end,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:hP(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||vP(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function xP(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var o=t.start,s=t.end,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||vP(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),p===0||p!==1);m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function SP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CP(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SP(Object(n),!0).forEach(function(t){wP(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wP(e,t,n){return(t=TP(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TP(e){var t=EP(e,`string`);return typeof t==`symbol`?t:t+``}function EP(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function DP(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,s=t.start,c=t.end,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=CP(CP({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=CP(CP({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&vP(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=CP(CP({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function OP(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,c=t.start,l=t.end;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=CP(CP({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&vP(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=CP(CP({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=CP(CP({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=CP(CP({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&vP(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=CP(CP({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function kP(e,t,n){var r=e.tick,i=e.ticks,a=e.viewBox,o=e.minTickGap,s=e.orientation,c=e.interval,l=e.tickFormatter,u=e.unit,d=e.angle;if(!i||!i.length||!r)return[];if(U(c)||Mm.isSsr)return yP(i,U(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?EA(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?gP(EA(i,{fontSize:t,letterSpacing:n}),m,d):EA(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?Wo(_.coordinate-g.coordinate):1,y=_P(a,v,p);return c===`equidistantPreserveStart`?bP(v,y,h,i,o):c===`equidistantPreserveEnd`?xP(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?OP(v,y,h,i,o,c===`preserveStartEnd`):DP(v,y,h,i,o),f.filter(e=>e.isShow))}var AP=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>l&&(l=t.width)}});var u=n?n.getBoundingClientRect().width:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},jP=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.height>l&&(l=t.height)}});var u=n?n.getBoundingClientRect().height:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},MP=sd({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId,a=n.ticks;e[r][i]=q(a)},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId;delete e[r][i]}}}),NP=MP.actions,PP=NP.setRenderedTicks,FP=NP.removeRenderedTicks,IP=MP.reducer,LP=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function RP(e,t){return UP(e)||HP(e,t)||BP(e,t)||zP()}function zP(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
65
65
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BP(e,t){if(e){if(typeof e==`string`)return VP(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?VP(e,t):void 0}}function VP(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function HP(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function UP(e){if(Array.isArray(e))return e}function WP(e,t){if(e==null)return{};var n,r,i=GP(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function GP(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function KP(){return KP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KP.apply(null,arguments)}function qP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JP(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qP(Object(n),!0).forEach(function(t){YP(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YP(e,t,n){return(t=XP(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XP(e){var t=ZP(e,`string`);return typeof t==`symbol`?t:t+``}function ZP(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var QP={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:nv.axis};function $P(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=JP(JP(JP({},c),Ao(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=JP(JP({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=JP(JP({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return b.createElement(`line`,KP({},l,{className:wo(`recharts-cartesian-axis-line`,yn(s,`className`))}))}function eF(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=U(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function tF(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function nF(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function rF(e){var t=e.option,n=e.tickProps,r=e.value,i,a=wo(n.className,`recharts-cartesian-axis-tick-value`);if(b.isValidElement(t))i=b.cloneElement(t,JP(JP({},n),{},{className:a}));else if(typeof t==`function`)i=t(JP(JP({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=wo(o,mM(t))),i=b.createElement(Cj,KP({},n,{className:o}),r)}return i}function iF(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=jc(),a=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(r!=null&&n!=null){var e=t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),o=a.current;o!=null&&o.axisId===r&&o.axisType===n&&ln(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(PP({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,b.useEffect)(()=>r==null||n==null?rs:()=>{i(FP({axisId:r,axisType:n}))},[i,r,n]),null}var aF=(0,b.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,v=e.tickMargin,y=e.fontSize,x=e.letterSpacing,S=e.getTicksConfig,C=e.events,w=e.axisType,T=e.axisId,E=kP(JP(JP({},S),{},{ticks:r}),y,x),D=Ao(S),O=jo(i),k=fj(D.textAnchor)?D.textAnchor:tF(d,f),ee=nF(d,f),A={};typeof a==`object`&&(A=a);var te=JP(JP({},D),{},{fill:`none`},A),j=E.map(e=>JP({entry:e},eF(e,p,m,h,g,d,_,f,v))),ne=j.map(e=>{var t=e.entry,n=e.line;return b.createElement(Uo,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&b.createElement(`line`,KP({},te,n,{className:wo(`recharts-cartesian-axis-tick-line`,yn(a,`className`))})))}),re=j.map((e,t)=>{var n=e.entry,r=e.tick,a=JP(JP({},JP(JP(JP(JP({verticalAnchor:ee},D),{},{textAnchor:k,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:E.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??D.angle??0})),O);return b.createElement(Uo,KP({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},gc(C,n,t)),i&&b.createElement(rF,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return b.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${w}-ticks`},b.createElement(iF,{ticks:E,axisId:T,axisType:w}),re.length>0&&b.createElement(dk,{zIndex:nv.label},b.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${w}-tick-labels`,ref:t},re)),ne.length>0&&b.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${w}-tick-lines`},ne))}),oF=(0,b.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=WP(e,LP),d=RP((0,b.useState)(``),2),f=d[0],p=d[1],m=RP((0,b.useState)(``),2),h=m[0],g=m[1],_=(0,b.useRef)(null);(0,b.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>AP({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>jP({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var v=(0,b.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:b.createElement(dk,{zIndex:e.zIndex},b.createElement(Uo,{className:wo(`recharts-cartesian-axis`,a)},b.createElement($P,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Ao(e)}),b.createElement(aF,{ref:v,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),b.createElement(Fj,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},b.createElement(Yj,{label:e.label,labelRef:e.labelRef}),e.children)))}),sF=b.forwardRef((e,t)=>{var n=Sc(e,QP);return b.createElement(oF,KP({},n,{ref:t}))});sF.displayName=`CartesianAxis`;var cF=(0,b.createContext)({grid:{stroke:`#ccc`,fill:`none`}});cF.Provider;var lF=()=>(0,b.useContext)(cF),uF=[`x1`,`y1`,`x2`,`y2`,`key`],dF=[`offset`],fF=[`xAxisId`,`yAxisId`],pF=[`xAxisId`,`yAxisId`];function mF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function hF(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mF(Object(n),!0).forEach(function(t){gF(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gF(e,t,n){return(t=_F(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _F(e){var t=vF(e,`string`);return typeof t==`symbol`?t:t+``}function vF(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function yF(){return yF=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},yF.apply(null,arguments)}function bF(e,t){if(e==null)return{};var n,r,i=xF(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function xF(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var SF=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return b.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function CF(e){var t=e.option,n=e.lineItemProps,r;if(b.isValidElement(t))r=b.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=Ao(bF(n,uF))??{};l.offset;var u=bF(l,dF),d=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(`,`):u.strokeDasharray;r=b.createElement(`line`,yF({},u,{strokeDasharray:d,x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function wF(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0||r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=bF(e,fF),s=a.map((e,r)=>{var a=hF(hF({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return b.createElement(CF,{key:`line-${r}`,option:i,lineItemProps:a})});return b.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function TF(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0||r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=bF(e,pF),s=a.map((e,r)=>{var a=hF(hF({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return b.createElement(CF,{option:i,lineItemProps:a,key:`line-${r}`})});return b.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function EF(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return b.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function DF(e){var t=e.vertical,n=t===void 0||t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return b.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var OF=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return pf(kP(hF(hF(hF({},QP),n),{},{ticks:mf(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},kF=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return pf(kP(hF(hF(hF({},QP),n),{},{ticks:mf(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},AF={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:nv.grid};function jF(e){var t=jp(),n=Mp(),r=Ap(),i=hF(hF({},Sc(e,AF)),{},{x:U(e.x)?e.x:r.left,y:U(e.y)?e.y:r.top,width:U(e.width)?e.width:r.width,height:U(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=Yf(),h=W(e=>IE(e,`xAxis`,a,m)),g=W(e=>IE(e,`yAxis`,o,m)),_=lF(),v={stroke:i.stroke??_.grid.stroke,strokeWidth:i.strokeWidth??_.grid.strokeWidth,strokeOpacity:i.strokeOpacity??_.grid.strokeOpacity,strokeDasharray:i.strokeDasharray??_.grid.strokeDasharray};if(!rf(l)||!rf(u)||!U(s)||!U(c))return null;var y=i.verticalCoordinatesGenerator||OF,x=i.horizontalCoordinatesGenerator||kF,S=i.horizontalPoints,C=i.verticalPoints;if((!S||!S.length)&&typeof x==`function`){var w=f&&f.length,T=x({yAxis:g?hF(hF({},g),{},{ticks:w?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);Qf(Array.isArray(T),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(S=T)}if((!C||!C.length)&&typeof y==`function`){var E=p&&p.length,D=y({xAxis:h?hF(hF({},h),{},{ticks:E?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},E?!0:d);Qf(Array.isArray(D),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof D}]`),Array.isArray(D)&&(C=D)}return b.createElement(dk,{zIndex:i.zIndex},b.createElement(`g`,{className:`recharts-cartesian-grid`},b.createElement(SF,{fill:i.fill??_.grid.fill,fillOpacity:i.fillOpacity??_.grid.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),b.createElement(EF,yF({},i,{horizontalPoints:S})),b.createElement(DF,yF({},i,{verticalPoints:C})),b.createElement(wF,yF({},i,v,{offset:r,horizontalPoints:S,xAxis:h,yAxis:g})),b.createElement(TF,yF({},i,v,{offset:r,verticalPoints:C,xAxis:h,yAxis:g}))))}jF.displayName=`CartesianGrid`;var MF=sd({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),NF=MF.actions;NF.addErrorBar,NF.replaceErrorBar,NF.removeErrorBar;var PF=MF.reducer;function FF(e,t){var n=W(t=>Rw(t,e)),r=W(e=>Vw(e,t)),i=n?.allowDataOverflow??Iw.allowDataOverflow,a=r?.allowDataOverflow??zw.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function IF(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=UN(),a=FF(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=W(e=>dE(e,t,!1)),u=W(e=>fE(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,v=s&&u?Math.abs(u[1]-u[0]):m*2;return b.createElement(`clipPath`,{id:`clipPath-${r}`},b.createElement(`rect`,{x:h,y:g,width:_,height:v}))}function LF(e){var t=jo(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function RF(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function zF(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var BF=(e,t,n)=>zE(e,`xAxis`,RF(e,t),n),VF=(e,t,n)=>RE(e,`xAxis`,RF(e,t),n),HF=(e,t,n)=>zE(e,`yAxis`,zF(e,t),n),UF=(e,t,n)=>RE(e,`yAxis`,zF(e,t),n),WF=G([Np,BF,HF,VF,UF],(e,t,n,r,i)=>ff(e,`xAxis`)?wf(t,r,!1):wf(n,i,!1)),GF=G([Yw,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),KF=e=>ff(Np(e),`xAxis`)?`yAxis`:`xAxis`,qF=(e,t)=>KF(e)===`yAxis`?zF(e,t):RF(e,t),JF=(e,t,n)=>xT(e,KF(e),qF(e,t),n),YF=G([Np,BF,HF,VF,UF,G([GF,JF],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=Tv(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),b_,WF,GF,tv,G([GF,JF],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(ns)}})],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return OI({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),XF=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],ZF=[`id`,`baseLine`];function QF(){return QF=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QF.apply(null,arguments)}function $F(e,t){if(e==null)return{};var n,r,i=eI(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function eI(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function tI(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!Z(a)||!Z(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return U(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),U(c)?b.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function nI(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!Z(a)||!Z(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return U(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),U(c)?b.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function rI(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?b.createElement(nI,{alpha:t,points:r,baseLine:i,strokeWidth:a}):b.createElement(tI,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function iI(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=$F(e,XF),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=rN(),h=d.id,g=d.baseLine,_=Ao($F(d,ZF)),v=b.createElement(hh,QF({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),y=l!==`none`&&b.createElement(hh,QF({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&b.createElement(hh,QF({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?b.createElement(Uo,null,b.createElement(`defs`,null,b.createElement(`clipPath`,{id:m},b.createElement(rI,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),b.createElement(Uo,{clipPath:`url(#${m})`},v,y,x)):b.createElement(b.Fragment,null,v,y,x)}var aI=[`id`],oI=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function sI(){return sI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sI.apply(null,arguments)}function cI(e,t){if(e==null)return{};var n,r,i=lI(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lI(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function uI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function dI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?uI(Object(n),!0).forEach(function(t){fI(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fI(e,t,n){return(t=pI(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pI(e){var t=mI(e,`string`);return typeof t==`symbol`?t:t+``}function mI(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var hI={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:FM,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[dI(dI({},e.next),{},{x:Qo(e.prev.x,e.next.x,t),y:Qo(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:iI,xAxisId:0,yAxisId:0,zIndex:nv.area};function gI(e,t){return e&&e!==`none`?e:t}var _I=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:gI(r,i),value:Ef(n,t),payload:e}]},vI=b.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:rs,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Ef(o,t),hide:s,type:u,color:gI(r,a),unit:c,formatter:l,graphicalItemId:d}};return b.createElement(DM,{tooltipEntrySettings:f})});function yI(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Ao(r);return b.createElement(TN,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function bI(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return dI(dI({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return b.createElement(rM,{value:t?r:void 0},n)}function xI(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=cI(a,aI),_=dI(dI({},Mo(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return b.createElement(b.Fragment,null,t?.length>1&&b.createElement(Uo,{clipPath:r?`url(#clipPath-${i})`:void 0},b.createElement(EM,{option:m,DefaultShape:hI.shape,shapeProps:_})),b.createElement(yI,{points:t,props:g,clipPathId:i}))}function SI(e,t,n){return U(e)?Qo(U(t)?t:void 0,e,n):es(e)||Go(e)?Qo(U(t)?t:void 0,0,n):e}function CI(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,b.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=HM(m,a),g=Fp(),_=YM(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,x=_.handleAnimationEnd,S=h.startValue;if(g==null)return null;var C=Array.isArray(s)&&Array.isArray(S)?VM(S,s,f):Array.isArray(s)?VM(null,s,f):null;return b.createElement(XM,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:x,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(C,i,g):a?s:SI(s,S,i);return h.syncStepValue(c,i),b.createElement(bI,{showLabels:!v,points:o},r.children,b.createElement(xI,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),b.createElement(cM,{label:r.label}))})}function wI(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,b.useRef)(null),a=(0,b.useRef)();return b.createElement(CI,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var TI=class extends b.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=wo(`recharts-area`,i),g=f,_=LF(n),v=_.r,y=_.strokeWidth,x=hM(n),S=v*2+y,C=s?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return b.createElement(dk,{zIndex:m},b.createElement(Uo,{className:h},s&&b.createElement(`defs`,null,b.createElement(IF,{clipPathId:g,xAxisId:c,yAxisId:l}),!x&&b.createElement(`clipPath`,{id:`clipPath-dots-${g}`},b.createElement(`rect`,{x:o-S/2,y:a-S/2,width:u+S,height:d+S}))),b.createElement(wI,{needClip:s,clipPathId:g,props:this.props})),b.createElement(ZN,{points:r,mainColor:gI(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&b.createElement(ZN,{points:p,mainColor:gI(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}};function EI(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=cI(e,oI),g=Pp(),_=AO(),v=FF(p,m).needClip,y=Yf(),x=W(t=>YF(t,e.id,y))??{},S=x.points,C=x.isRange,w=x.baseLine,T=UN();if(g!==`horizontal`&&g!==`vertical`||T==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:b.createElement(TI,sI({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:v,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var DI=(e,t,n,r,i)=>{var a=n??t;if(U(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function OI(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=DI(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=uf(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=uf(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>uf(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:vf({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:vf({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function kI(e){var t=Sc(e,hI),n=Yf();return b.createElement(oN,{id:t.id,type:`area`},e=>b.createElement(b.Fragment,null,b.createElement(OM,{legendPayload:_I(t)}),b.createElement(vI,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),b.createElement(pN,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:_f(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),b.createElement(EI,sI({},t,{id:e}))))}var AI=b.memo(kI,lm);AI.displayName=`Area`;var jI=[`domain`,`range`],MI=[`domain`,`range`];function NI(e,t){if(e==null)return{};var n,r,i=PI(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PI(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function FI(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function II(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=NI(e,jI),a=t.domain,o=t.range,s=NI(t,MI);return!FI(n,a)||!FI(r,o)?!1:lm(i,s)}var LI=[`type`],RI=[`dangerouslySetInnerHTML`,`ticks`,`scale`],zI=[`id`,`scale`];function BI(){return BI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},BI.apply(null,arguments)}function VI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VI(Object(n),!0).forEach(function(t){UI(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UI(e,t,n){return(t=WI(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WI(e){var t=GI(e,`string`);return typeof t==`symbol`?t:t+``}function GI(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function KI(e,t){if(e==null)return{};var n,r,i=qI(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qI(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function JI(e){var t=jc(),n=(0,b.useRef)(null),r=Fp(),i=e.type,a=KI(e,LI),o=ov(r,`xAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return HI(HI({},a),{},{type:o})},[a,o]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(NN(s)):n.current!==s&&t(PN({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(FN(n.current)),null)},[t]),null}var YI=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=W(qf),c=Yf(),l=jc(),u=`xAxis`,d=W(e=>LE(e,u,t,c)),f=W(e=>EE(e,t)),p=W(e=>jE(e,t)),m=W(e=>Lw(e,t));if((0,b.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||Bj(i)||(0,b.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(BN({id:t,height:n}))}}},[d,f,l,i,t,r,m]),f==null||p==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=KI(e,RI);m.id,m.scale;var g=KI(m,zI);return b.createElement(sF,BI({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:wo(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},XI={allowDataOverflow:Iw.allowDataOverflow,allowDecimals:Iw.allowDecimals,allowDuplicatedCategory:Iw.allowDuplicatedCategory,angle:Iw.angle,axisLine:QP.axisLine,height:Iw.height,hide:!1,includeHidden:Iw.includeHidden,interval:Iw.interval,label:!1,minTickGap:Iw.minTickGap,mirror:Iw.mirror,orientation:Iw.orientation,padding:Iw.padding,reversed:Iw.reversed,scale:Iw.scale,tick:Iw.tick,tickCount:Iw.tickCount,tickLine:QP.tickLine,tickSize:QP.tickSize,type:Iw.type,niceTicks:Iw.niceTicks,xAxisId:0},ZI=b.memo(e=>{var t=Sc(e,XI);return b.createElement(b.Fragment,null,b.createElement(JI,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),b.createElement(YI,t))},II);ZI.displayName=`XAxis`;var QI=[`type`],$I=[`dangerouslySetInnerHTML`,`ticks`,`scale`],eL=[`id`,`scale`];function tL(){return tL=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},tL.apply(null,arguments)}function nL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nL(Object(n),!0).forEach(function(t){iL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function iL(e,t,n){return(t=aL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aL(e){var t=oL(e,`string`);return typeof t==`symbol`?t:t+``}function oL(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function sL(e,t){if(e==null)return{};var n,r,i=cL(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function cL(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function lL(e){var t=jc(),n=(0,b.useRef)(null),r=Fp(),i=e.type,a=sL(e,QI),o=ov(r,`yAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return rL(rL({},a),{},{type:o})},[o,a]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(IN(s)):n.current!==s&&t(LN({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(RN(n.current)),null)},[t]),null}function uL(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=W(qf),c=Yf(),l=jc(),u=`yAxis`,d=W(e=>NE(e,t)),f=W(e=>ME(e,t)),p=W(e=>LE(e,u,t,c)),m=W(e=>Bw(e,t));if((0,b.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||Bj(i)||(0,b.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(zN({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=sL(e,$I);m.id,m.scale;var g=sL(m,eL);return b.createElement(sF,tL({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:wo(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var dL={allowDataOverflow:zw.allowDataOverflow,allowDecimals:zw.allowDecimals,allowDuplicatedCategory:zw.allowDuplicatedCategory,angle:zw.angle,axisLine:QP.axisLine,hide:!1,includeHidden:zw.includeHidden,interval:zw.interval,label:!1,minTickGap:zw.minTickGap,mirror:zw.mirror,orientation:zw.orientation,padding:zw.padding,reversed:zw.reversed,scale:zw.scale,tick:zw.tick,tickCount:zw.tickCount,tickLine:QP.tickLine,tickSize:QP.tickSize,type:zw.type,niceTicks:zw.niceTicks,width:zw.width,yAxisId:0},fL=b.memo(e=>{var t=Sc(e,dL);return b.createElement(b.Fragment,null,b.createElement(lL,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),b.createElement(uL,t))},II);fL.displayName=`YAxis`;var pL=G([(e,t)=>t,Np,Sv,jv,$D,tO,PO,Gf],KO);function mL(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function hL(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(mL(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var gL=Hu(`mouseClick`),_L=qd();_L.startListening({actionCreator:gL,effect:(e,t)=>{var n=e.payload,r=pL(t.getState(),hL(n));r?.activeIndex!=null&&t.dispatch(iD({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var vL=Hu(`mouseMove`),yL=qd(),bL=null,xL=null,SL=null;yL.startListening({actionCreator:vL,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);bL!==null&&(cancelAnimationFrame(bL),bL=null),xL!==null&&(typeof i!=`number`||!o)&&(clearTimeout(xL),xL=null),SL=hL(n);var s=()=>{var e=t.getState(),n=WE(e,e.tooltip.settings.shared);if(!SL)bL=null,xL=null;else{if(n===`axis`){var r=pL(e,SL);r?.activeIndex==null?t.dispatch(nD()):t.dispatch(rD({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}bL=null,xL=null}};o?i===`raf`?bL=requestAnimationFrame(s):typeof i==`number`&&xL===null&&(xL=setTimeout(s,i)):s()}});function CL(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var wL={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},TL=sd({name:`rootProps`,initialState:wL,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??wL.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),EL=TL.reducer,DL=TL.actions.updateOptions,OL=sd({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}});OL.actions.updatePolarOptions;var kL=OL.reducer,AL=Hu(`keyDown`),jL=Hu(`focus`),ML=Hu(`blur`),NL=qd(),PL=null,FL=null,IL=null;NL.startListening({actionCreator:AL,effect:(e,t)=>{IL=e.payload,PL!==null&&(cancelAnimationFrame(PL),PL=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);FL!==null&&(typeof r!=`number`||!a)&&(clearTimeout(FL),FL=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=IL;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=yD(n,VD(e),vT(e),XD(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=tO(e),c=VD(e),l=WE(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=zO(e,l,`hover`,String(n.index));t.dispatch(oD({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=BE(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=vT(e),h=XD(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(yD(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(yD(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=zO(e,l,`hover`,String(p));t.dispatch(oD({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{PL=null,FL=null}};a?r===`raf`?PL=requestAnimationFrame(o):typeof r==`number`&&FL===null&&(o(),IL=null,FL=setTimeout(()=>{IL?o():(FL=null,PL=null)},r)):o()}}),NL.startListening({actionCreator:jL,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=zO(n,WE(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(oD({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),NL.startListening({actionCreator:ML,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(oD({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function LL(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var RL=Hu(`externalEvent`),zL=qd(),BL=new Map,VL=new Map,HL=new Map;zL.startListening({actionCreator:RL,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=LL(i);HL.set(a,{handler:r,reactEvent:o});var s=BL.get(a);s!==void 0&&(cancelAnimationFrame(s),BL.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=VL.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),VL.delete(a));var p=()=>{var e=HL.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:dO(i),activeDataKey:cO(i),activeIndex:oO(i),activeLabel:sO(i),activeTooltipIndex:oO(i),isTooltipActive:fO(i)};n&&n(o,r)}finally{BL.delete(a),VL.delete(a),HL.delete(a)}};if(!d)p();else if(l===`raf`){var m=requestAnimationFrame(p);BL.set(a,m)}else if(typeof l==`number`){if(!VL.has(a)){p();var h=setTimeout(p,l);VL.set(a,h)}}else p()}}});var UL=G([G([CD],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),WL=Hu(`touchMove`),GL=qd(),KL=null,qL=null,JL=null,YL=null;GL.startListening({actionCreator:WL,effect:(e,t)=>{var n=e.payload;if(n.touches!=null&&n.touches.length!==0){YL=LL(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);KL!==null&&(cancelAnimationFrame(KL),KL=null),qL!==null&&(typeof i!=`number`||!o)&&(clearTimeout(qL),qL=null),JL=Array.from(n.touches).map(e=>hL({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(YL!=null){var e=t.getState(),n=WE(e,e.tooltip.settings.shared);if(n===`axis`){var r=JL?.[0];if(r==null){KL=null,qL=null;return}var i=pL(e,r);i?.activeIndex!=null&&t.dispatch(rD({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=YL.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(Ff),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=LD(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=UL(e,s,c);t.dispatch(tD({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}KL=null,qL=null}};o?i===`raf`?KL=requestAnimationFrame(s):typeof i==`number`&&qL===null&&(s(),YL=null,qL=setTimeout(()=>{YL?s():(qL=null,KL=null)},i)):s()}}});var XL={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},ZL=sd({name:`eventSettings`,initialState:XL,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=q(t.payload.throttledEvents))}}}),QL=ZL.actions.setEventSettings,$L=ZL.reducer,eR=pl({brush:tP,cartesianAxis:VN,chartData:Ik,errorBars:PF,eventSettings:$L,graphicalItems:fN,layout:tf,legend:Wp,options:kk,polarAxis:pM,polarOptions:kL,referenceElements:oP,renderedTicks:IP,rootProps:EL,tooltip:sD,zIndex:lk}),tR=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Y({reducer:eR,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([_L.middleware,yL.middleware,NL.middleware,zL.middleware,GL.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(J({type:`raf`}))},devTools:Mm.devToolsEnabled&&{serialize:{replacer:CL},name:`recharts-${t}`}})};function nR(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=Yf(),a=(0,b.useRef)(null);if(i)return n;a.current??=tR(t,r);var o=Oc;return b.createElement(om,{context:o,store:a.current},n)}function rR(e){var t=e.layout,n=e.margin,r=jc(),i=Yf();return(0,b.useEffect)(()=>{i||(r(Qd(t)),r(Zd(n)))},[r,i,t,n]),null}var iR=(0,b.memo)(rR,lm);function aR(e){var t=jc();return(0,b.useEffect)(()=>{t(DL(e))},[t,e]),null}var oR=(0,b.memo)(e=>{var t=jc();return(0,b.useEffect)(()=>{t(QL(e))},[t,e]),null},lm);function sR(e){var t=e.zIndex,n=e.isPanorama,r=(0,b.useRef)(null),i=jc();return(0,b.useLayoutEffect)(()=>(r.current&&i(sk({zIndex:t,element:r.current,isPanorama:n})),()=>{i(ck({zIndex:t,isPanorama:n}))}),[i,t,n]),b.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function cR(e){var t=e.children,n=e.isPanorama,r=W(JO);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return b.createElement(b.Fragment,null,i.map(e=>b.createElement(sR,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>b.createElement(sR,{key:e,zIndex:e,isPanorama:n})))}var lR=[`children`];function uR(e,t){if(e==null)return{};var n,r,i=dR(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function dR(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function fR(){return fR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fR.apply(null,arguments)}var pR={width:`100%`,height:`100%`,display:`block`},mR=(0,b.forwardRef)((e,t)=>{var n=jp(),r=Mp(),i=eh();if(!rf(n)||!rf(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),b.createElement(Ro,fR({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:pR,ref:t}),a)}),hR=e=>{var t=e.children,n=W(Zf);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return b.createElement(Ro,{width:r,height:i,x:o,y:a},t)},gR=(0,b.forwardRef)((e,t)=>{var n=e.children,r=uR(e,lR);return Yf()?b.createElement(hR,null,b.createElement(cR,{isPanorama:!0},n)):b.createElement(mR,fR({ref:t},r),b.createElement(cR,{isPanorama:!1},n))});function _R(e,t){return SR(e)||xR(e,t)||yR(e,t)||vR()}function vR(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
66
66
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yR(e,t){if(e){if(typeof e==`string`)return bR(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bR(e,t):void 0}}function bR(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xR(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function SR(e){if(Array.isArray(e))return e}function CR(){var e=jc(),t=_R((0,b.useState)(null),2),n=t[0],r=t[1],i=W(jf);return(0,b.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;Z(t)&&t!==i&&e(ef(t))}},[n,e,i]),r}function wR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function TR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wR(Object(n),!0).forEach(function(t){ER(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ER(e,t,n){return(t=DR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DR(e){var t=OR(e,`string`);return typeof t==`symbol`?t:t+``}function OR(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function kR(){return kR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kR.apply(null,arguments)}function AR(e,t){return FR(e)||PR(e,t)||MR(e,t)||jR()}function jR(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
67
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MR(e,t){if(e){if(typeof e==`string`)return NR(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?NR(e,t):void 0}}function NR(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PR(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function FR(e){if(Array.isArray(e))return e}var IR=()=>(qk(),null);function LR(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var RR=(0,b.forwardRef)((e,t)=>{var n=(0,b.useRef)(null),r=AR((0,b.useState)({containerWidth:LR(e.style?.width),containerHeight:LR(e.style?.height)}),2),i=r[0],a=r[1],o=(0,b.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,b.useEffect)(()=>()=>{n.current?.disconnect()},[o]),b.createElement(b.Fragment,null,b.createElement(Rp,{width:i.containerWidth,height:i.containerHeight}),b.createElement(`div`,kR({ref:s},e)))}),zR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=AR((0,b.useState)({containerWidth:LR(n),containerHeight:LR(r)}),2),a=i[0],o=i[1],s=(0,b.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return b.createElement(b.Fragment,null,b.createElement(Rp,{width:a.containerWidth,height:a.containerHeight}),b.createElement(`div`,kR({ref:c},e)))}),BR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height;return b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(`div`,kR({ref:t},e)))}),VR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?b.createElement(zR,kR({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?b.createElement(BR,kR({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(`div`,kR({ref:t},e)))});function HR(e){return e?RR:VR}var UR=(0,b.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,x=y===void 0||y,S=(0,b.useRef)(null),C=jc(),w=AR((0,b.useState)(null),2),T=w[0],E=w[1],D=AR((0,b.useState)(null),2),O=D[0],k=D[1],ee=CR(),A=Tp(),te=A?.width>0?A.width:_,j=A?.height>0?A.height:i,ne=(0,b.useCallback)(e=>{ee(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[ee,t,E,k]),re=(0,b.useCallback)(e=>{C(gL(e)),C(RL({handler:a,reactEvent:e}))},[C,a]),ie=(0,b.useCallback)(e=>{C(vL(e)),C(RL({handler:l,reactEvent:e}))},[C,l]),ae=(0,b.useCallback)(e=>{C(nD()),C(RL({handler:u,reactEvent:e}))},[C,u]),oe=(0,b.useCallback)(e=>{C(vL(e)),C(RL({handler:d,reactEvent:e}))},[C,d]),se=(0,b.useCallback)(()=>{C(jL())},[C]),ce=(0,b.useCallback)(()=>{C(ML())},[C]),le=(0,b.useCallback)(e=>{C(AL(e.key))},[C]),ue=(0,b.useCallback)(e=>{C(RL({handler:o,reactEvent:e}))},[C,o]),de=(0,b.useCallback)(e=>{C(RL({handler:s,reactEvent:e}))},[C,s]),fe=(0,b.useCallback)(e=>{C(RL({handler:c,reactEvent:e}))},[C,c]),pe=(0,b.useCallback)(e=>{C(RL({handler:f,reactEvent:e}))},[C,f]),me=(0,b.useCallback)(e=>{C(RL({handler:h,reactEvent:e}))},[C,h]),he=(0,b.useCallback)(e=>{x&&C(WL(e)),C(RL({handler:m,reactEvent:e}))},[C,x,m]),ge=(0,b.useCallback)(e=>{C(RL({handler:p,reactEvent:e}))},[C,p]),M=HR(v);return b.createElement(xk.Provider,{value:T},b.createElement(ps.Provider,{value:O},b.createElement(M,{width:te??g?.width,height:j??g?.height,className:wo(`recharts-wrapper`,r),style:TR({position:`relative`,cursor:`default`,width:te,height:j},g),onClick:re,onContextMenu:ue,onDoubleClick:de,onFocus:se,onBlur:ce,onKeyDown:le,onMouseDown:fe,onMouseEnter:ie,onMouseLeave:ae,onMouseMove:oe,onMouseUp:pe,onTouchEnd:ge,onTouchMove:he,onTouchStart:me,ref:ne},b.createElement(IR,null),n)))}),WR=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function GR(e,t){if(e==null)return{};var n,r,i=KR(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function KR(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var qR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=Ao(GR(e,WR));return c?b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(gR,{otherAttributes:d,title:l,desc:u},a)):b.createElement(UR,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(gR,{otherAttributes:d,title:l,desc:u,ref:t},b.createElement(mP,null,a)))});function JR(){return JR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JR.apply(null,arguments)}function YR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YR(Object(n),!0).forEach(function(t){ZR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZR(e,t,n){return(t=QR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QR(e){var t=$R(e,`string`);return typeof t==`symbol`?t:t+``}function $R(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ez=XR({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},XL),tz=(0,b.forwardRef)(function(e,t){var n=Sc(e.categoricalChartProps,ez),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return b.createElement(nR,{preloadedState:{options:c},reduxStoreName:s.id??r},b.createElement(QN,{chartData:s.data}),b.createElement(iR,{layout:n.layout,margin:n.margin}),b.createElement(oR,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(aR,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(qR,JR({},n,{ref:t})))}),nz=[`axis`],rz=(0,b.forwardRef)((e,t)=>b.createElement(tz,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nz,tooltipPayloadSearcher:Dk,categoricalChartProps:e,ref:t})),iz=e=>{let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})};function az({data:e,color:t=`var(--accent)`,height:n=150,label:r=`events`}){if(!e||e.length===0)return(0,x.jsx)(`div`,{style:{height:n}});let i=`tc-${r.replace(/[^a-z0-9]/gi,``)}`;return(0,x.jsx)(Dp,{width:`100%`,height:n,children:(0,x.jsxs)(rz,{data:e,margin:{top:8,right:8,bottom:0,left:8},children:[(0,x.jsx)(`defs`,{children:(0,x.jsxs)(`linearGradient`,{id:i,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,x.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.32}),(0,x.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:.02})]})}),(0,x.jsx)(jF,{strokeDasharray:`3 3`,stroke:`var(--line)`,vertical:!1}),(0,x.jsx)(ZI,{dataKey:`date`,tickFormatter:iz,tick:{fontSize:10,fill:`var(--faint)`},axisLine:!1,tickLine:!1,minTickGap:42}),(0,x.jsx)(fL,{hide:!0,domain:[0,`auto`],allowDecimals:!1}),(0,x.jsx)(uA,{cursor:{stroke:`var(--line)`,strokeDasharray:`3 3`},content:({active:e,payload:n,label:i})=>e&&n?.length?(0,x.jsxs)(`div`,{className:`chart-tip`,children:[(0,x.jsx)(`div`,{className:`chart-tip-label`,children:iz(String(i))}),(0,x.jsxs)(`div`,{className:`chart-tip-row`,children:[(0,x.jsx)(`span`,{className:`chart-tip-dot`,style:{background:t}}),r,` `,(0,x.jsx)(`b`,{children:n[0].value})]})]}):null}),(0,x.jsx)(AI,{type:`monotone`,dataKey:`count`,stroke:t,strokeWidth:1.8,fill:`url(#${i})`,isAnimationActive:!1})]})})}function oz(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function sz(e){return e.includes(`login`)||e.includes(`signin`)?`badge-green`:e.includes(`fail`)||e.includes(`error`)||e.includes(`locked`)?`badge-red`:e.includes(`register`)||e.includes(`signup`)?`badge-accent`:e.includes(`settings`)||e.includes(`admin`)?`badge-amber`:`badge-muted`}function cz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(xa,{count:6,columns:3}),children:e&&(0,x.jsxs)(`div`,{className:`cards`,children:[(0,x.jsxs)(`div`,{className:`card c-accent`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Total Users`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.usersTotal.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`registered accounts`})]}),(0,x.jsxs)(`div`,{className:`card c-green`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Active Sessions`}),(0,x.jsx)(`div`,{className:`card-value`,children:(e.activeSessions??0).toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`currently logged in`})]}),(0,x.jsxs)(`div`,{className:`card c-amber`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`MAU`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.mau.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`monthly active users`})]}),(0,x.jsxs)(`div`,{className:`card`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Sign-ins`}),(0,x.jsx)(`div`,{className:`card-value`,style:{color:`var(--text)`},children:e.signInsTotal.toLocaleString()}),(0,x.jsxs)(`div`,{className:`card-hint`,children:[`last `,e.windowDays,` days`]})]}),(0,x.jsxs)(`div`,{className:`card c-blue`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Sign-ups`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.signUpsTotal.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`new registrations`})]}),(0,x.jsxs)(`div`,{className:`card`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`OAuth Clients`}),(0,x.jsx)(`div`,{className:`card-value`,style:{color:`var(--text)`},children:e.clientsCount.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`OIDC clients`})]})]})})}function lz({title:e}){return(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsx)(`div`,{className:`panel-head`,children:(0,x.jsx)(`h3`,{children:e})}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:4},children:(0,x.jsx)(z,{height:60,borderRadius:8})})]})}function uz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(lz,{title:`Sign-ins / day`}),children:e&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Sign-ins / day`}),(0,x.jsxs)(`span`,{className:`meta`,children:[`last `,e.windowDays,`d`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:`4px`},children:e.signInsPerDay.length>0?(0,x.jsx)(az,{data:e.signInsPerDay,color:`var(--accent)`,label:`sign-ins`}):(0,x.jsx)(`div`,{style:{height:60,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--faint)`,fontSize:12},children:`No data yet`})})]})})}function dz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(lz,{title:`Sign-ups / day`}),children:e&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Sign-ups / day`}),(0,x.jsxs)(`span`,{className:`meta`,children:[`last `,e.windowDays,`d`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:`4px`},children:e.signUpsPerDay.length>0?(0,x.jsx)(az,{data:e.signUpsPerDay,color:`var(--green)`,label:`sign-ups`}):(0,x.jsx)(`div`,{style:{height:60,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--faint)`,fontSize:12},children:`No data yet`})})]})})}function fz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(Ca,{rows:5,cols:4}),children:e?.auditSupported&&e.recentEvents.length>0&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Recent Events`}),(0,x.jsxs)(`span`,{className:`meta`,children:[e.auditTotal.toLocaleString(),` total`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{padding:0},children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Type`}),(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`IP`}),(0,x.jsx)(`th`,{children:`When`})]})}),(0,x.jsx)(`tbody`,{children:e.recentEvents.map(e=>(0,x.jsxs)(`tr`,{className:`static`,style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${sz(e.type)}`,children:e.type})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`11.5px`},children:e.email??e.accountId??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`code`,children:e.ip??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`11px`,color:`var(--faint)`},children:e.createdAt?oz(e.createdAt):`—`})})]},e.id))})]})})]})})}function pz(){return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Overview`}),(0,x.jsx)(`div`,{className:`page-sub`,children:`Identity provider metrics`})]}),(0,x.jsx)(cz,{}),(0,x.jsxs)(`div`,{className:`grid-2`,style:{marginTop:16},children:[(0,x.jsx)(uz,{}),(0,x.jsx)(dz,{})]}),(0,x.jsx)(`div`,{style:{marginTop:16},children:(0,x.jsx)(fz,{})})]})}var mz=20,hz={pact:`PACT`,poppy:`Poppy`};function gz(e){return!!e&&typeof e==`object`&&`status`in e&&e.status===404}function _z(){let e=Ra();return t=>{if(t?.code===`sudo_required`){let e=window.location.pathname+window.location.search;window.location.href=`${Bi().endpoints.confirm??`/account/confirm`}?return_to=${encodeURIComponent(e)}`}else e.error(t instanceof Error?t.message:String(t))}}function vz(){let e=C();return()=>e.invalidateQueries({queryKey:L.admin.personalAgents()})}function yz({agent:e}){let t=e.effective===`blocked`?(0,x.jsx)(`span`,{className:`badge badge-red`,children:`blocked`}):e.effective===`allowed`?(0,x.jsx)(`span`,{className:`badge badge-green`,children:`allowed`}):(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`not listed`}),n=[e.config&&`config: ${e.config}`,e.console&&`console: ${e.console.status}`].filter(Boolean);return(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3,alignItems:`flex-start`},children:[t,n.length>0&&(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},children:n.join(` · `)})]})}function bz(e){let t=[],{pact:n,poppy:r}=e.protocols;return n&&t.push(n.open?`PACT: open — any agent publishing a JWKS via OIDC discovery is accepted, except blocked ones.`:`PACT: only listed agents are accepted.`),r&&t.push(r.requireRegistration?`Poppy: registration required — only listed agents can start sessions.`:`Poppy: any agent with a valid client_id can start sessions, except blocked ones.`),(n?.hostResolver||r?.hostResolver)&&t.push(`Part of the list comes from a host function and is not shown here.`),t}function xz({onShowConnections:e}){let{data:t,isLoading:n,error:r,refetch:i}=P({...Vr(),retry:(e,t)=>!gz(t)&&e<1}),a=ut(Wr()),o=ut(Gr()),s=Ra(),c=_z(),l=vz(),[u,d]=(0,b.useState)(!1);if(gz(r))return(0,x.jsxs)(`div`,{className:`error-box`,children:[`Personal agents are not configured. Add `,(0,x.jsx)(`code`,{children:`personalAgents`}),` (PACT and/or`,` `,(0,x.jsx)(`code`,{children:`poppy`}),`) to `,(0,x.jsx)(`code`,{children:`defineConfig`}),`.`]});async function f(e){if(confirm(`Block ${e.name}? Every account connected to it is disconnected now (${e.connections}), and it cannot connect again until unblocked.`))try{let t=await a.mutateAsync({protocol:e.protocol,identifier:e.identifier,status:`blocked`,name:e.console?void 0:e.name,jwksUri:e.jwksUri??void 0});s.success(`Blocked — ${t.disconnected} connection(s) revoked`),l()}catch(e){c(e)}}async function p(e){if(e.protocol===`pact`&&!e.jwksUri)d(!0);else try{await a.mutateAsync({protocol:e.protocol,identifier:e.identifier,status:`allowed`,jwksUri:e.jwksUri??void 0}),s.success(`Agent allowed`),l()}catch(e){c(e)}}async function m(e){if(!e.console)return;let t=e.console.status===`blocked`?`Unblock`:`Remove from the allowlist`;if(confirm(`${t}: ${e.name}?`))try{await o.mutateAsync(e.console.id),s.success(e.console.status===`blocked`?`Unblocked`:`Removed`),l()}catch(e){c(e)}}let h=a.isPending||o.isPending;return(0,x.jsx)(_a,{isLoading:n,error:r,onRetry:i,skeleton:(0,x.jsx)(Ca,{rows:4,cols:5}),children:t&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:16},children:(0,x.jsxs)(`div`,{className:`panel-body`,style:{display:`flex`,gap:16,alignItems:`flex-start`},children:[(0,x.jsx)(`div`,{style:{flex:1,fontSize:12,color:`var(--muted)`,lineHeight:1.7},children:bz(t).map(e=>(0,x.jsx)(`div`,{children:e},e))}),(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,onClick:()=>d(!0),children:`Add agent`})]})}),(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:24},children:t.agents.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsx)(`h4`,{children:`No personal agents yet`}),(0,x.jsx)(`p`,{children:`Agents show up here once listed or once someone connects one.`})]}):(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Agent`}),(0,x.jsx)(`th`,{children:`Protocol`}),(0,x.jsx)(`th`,{children:`Status`}),(0,x.jsx)(`th`,{children:`Connections`}),(0,x.jsx)(`th`,{})]})}),(0,x.jsx)(`tbody`,{children:t.agents.map(t=>{let n=t.config===`blocked`,r=t.console?.status===`blocked`;return(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:t.name}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:`var(--faint)`},children:t.identifier})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge badge-muted`,children:hz[t.protocol]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(yz,{agent:t})}),(0,x.jsx)(`td`,{children:t.connections>0?(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>e(t),children:t.connections}):(0,x.jsx)(`span`,{style:{color:`var(--faint)`},children:`0`})}),(0,x.jsxs)(`td`,{style:{textAlign:`right`,whiteSpace:`nowrap`},children:[t.console&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:h,onClick:()=>m(t),children:r?`Unblock`:`Remove`}),t.effective===`unlisted`&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:h,onClick:()=>p(t),children:`Allow`}),!n&&!r&&(0,x.jsx)(`button`,{className:`btn btn-danger btn-sm`,disabled:h,onClick:()=>f(t),children:`Block`}),n&&(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},title:`Blocked in defineConfig — change it there.`,children:`locked by config`})]})]},`${t.protocol} ${t.identifier}`)})})]})})}),(0,x.jsx)(Sz,{open:u,onClose:()=>d(!1),protocols:[`pact`,`poppy`].filter(e=>t.protocols[e]!==null),allowHttp:!!t.protocols.poppy?.allowInsecureClientIds})]})})}function Sz({open:e,onClose:t,protocols:n,allowHttp:r}){let i=ut(Wr()),a=Ra(),o=_z(),s=vz(),[c,l]=(0,b.useState)(n[0]??`poppy`),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(``),[g,_]=(0,b.useState)(`allowed`);async function v(e){e.preventDefault();try{let e=await i.mutateAsync({protocol:c,identifier:u.trim(),status:g,name:f.trim()||void 0,jwksUri:c===`pact`&&m.trim()||void 0});a.success(g===`blocked`?`Blocked — ${e.disconnected} connection(s) revoked`:`Agent allowed`),s(),d(``),p(``),h(``),t()}catch(e){o(e)}}return(0,x.jsx)(ja,{open:e,onClose:t,title:`Add personal agent`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn btn-ghost`,onClick:t,children:`Cancel`}),(0,x.jsx)(`button`,{className:g===`blocked`?`btn btn-danger`:`btn btn-primary`,form:`add-agent-form`,type:`submit`,disabled:i.isPending||!u.trim(),children:i.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):g===`blocked`?`Block`:`Allow`})]}),children:(0,x.jsxs)(`form`,{id:`add-agent-form`,onSubmit:v,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Protocol`}),(0,x.jsx)(`select`,{className:`input`,value:c,onChange:e=>l(e.target.value),children:n.map(e=>(0,x.jsx)(`option`,{value:e,children:hz[e]},e))})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:c===`poppy`?`Client ID (metadata URL)`:`Issuer (iss)`}),(0,x.jsx)(`input`,{className:`input input-mono`,value:u,onChange:e=>d(e.target.value),placeholder:c===`poppy`?`${r?`http(s)`:`https`}://agent.example/poppy-agent/agent.json`:`https://agent.example`,required:!0})]}),c===`pact`&&(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsxs)(`label`,{children:[`JWKS URI `,g===`allowed`?`(required)`:`(optional)`]}),(0,x.jsx)(`input`,{className:`input input-mono`,value:m,onChange:e=>h(e.target.value),placeholder:`https://agent.example/.well-known/jwks.json`,required:g===`allowed`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Display name (optional)`}),(0,x.jsx)(`input`,{className:`input`,value:f,onChange:e=>p(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Status`}),(0,x.jsxs)(`select`,{className:`input`,value:g,onChange:e=>_(e.target.value===`blocked`?`blocked`:`allowed`),children:[(0,x.jsx)(`option`,{value:`allowed`,children:`Allowed`}),(0,x.jsx)(`option`,{value:`blocked`,children:`Blocked (disconnects every account now)`})]})]})]})})}function Cz({agent:e,onClearAgent:t,page:n,onPage:r}){let{data:i,isLoading:a,error:o,refetch:s}=P({...Hr({protocol:e?.protocol,clientId:e?.identifier,page:n,size:mz}),retry:(e,t)=>!gz(t)&&e<1}),c=ut(Ur()),l=Ra(),u=_z(),d=vz();if(gz(o))return null;async function f(e,t,n){if(confirm(`Disconnect ${n} from ${t}?`))try{await c.mutateAsync(e),l.success(`Connection revoked`),d()}catch(e){u(e)}}return(0,x.jsxs)(`div`,{className:`settings-section`,children:[(0,x.jsxs)(`div`,{className:`settings-section-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{children:[`Connections`,e?` — ${e.name}`:``]}),(0,x.jsx)(`p`,{style:{marginTop:2},children:`Accounts that signed in to a personal agent. Revoking cuts that agent off the account right away.`})]}),e&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:t,children:`Show all`})]}),(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(Ca,{rows:5,cols:5}),children:i&&i.data.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsx)(`h4`,{children:`No connections`}),(0,x.jsx)(`p`,{children:`No account is connected to a personal agent.`})]}):i&&(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`Agent`}),(0,x.jsx)(`th`,{children:`Scopes`}),(0,x.jsx)(`th`,{children:`Connected`}),(0,x.jsx)(`th`,{children:`Expires`}),(0,x.jsx)(`th`,{})]})}),(0,x.jsx)(`tbody`,{children:i.data.map(e=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[e.accountEmail&&(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:e.accountEmail}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:`var(--faint)`},children:e.accountId})]})}),(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{fontSize:12},children:e.agentName}),(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},children:hz[e.protocol]})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:e.scopes.map(e=>(0,x.jsx)(`span`,{className:`badge badge-muted`,children:e},e))})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`mono text-sm`,children:new Date(e.createdAt).toLocaleString()})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`mono text-sm`,children:new Date(e.expiresAt).toLocaleDateString()})}),(0,x.jsx)(`td`,{style:{textAlign:`right`},children:(0,x.jsx)(`button`,{className:`btn btn-danger btn-sm`,disabled:c.isPending,onClick:()=>f(e.id,e.accountEmail??e.accountId,e.agentName),children:`Revoke`})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:n,total:i.meta.total,size:mz,onPage:r})})]})})})]})}function wz(){let[e,t]=na(`page`,Ki.withDefault(1)),[n,r]=(0,b.useState)(null);return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Personal agents`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[`AI agents (PACT, Poppy) acting for your users: who is connected, and which agents may connect. Allow and block add to `,(0,x.jsx)(`code`,{children:`defineConfig`}),` and apply right away.`]})]}),(0,x.jsx)(xz,{onShowConnections:e=>{r(e),t(null)}}),(0,x.jsx)(Cz,{agent:n,onClearAgent:()=>{r(null),t(null)},page:e,onPage:e=>void t(e)})]})}var Tz=`ADMIN`;function Ez({onEdit:e,onDelete:t,onUnavailable:n}){let[r,i]=(0,b.useState)(!1),{data:a,isLoading:o,error:s,refetch:c}=P({...Sr(),retry:(e,t)=>t&&typeof t==`object`&&`status`in t&&t.status===404?(r||(i(!0),n()),!1):e<1}),l=a?.data??[];return(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:o,error:s&&!(typeof s==`object`&&`status`in s&&s.status===404)?s:void 0,onRetry:c,skeleton:(0,x.jsx)(Ca,{rows:4,cols:4}),children:l.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,x.jsx)(`path`,{d:`M2 20a10 10 0 0120 0`})]}),(0,x.jsx)(`h4`,{children:`No roles yet`}),(0,x.jsx)(`p`,{children:`Create roles to assign permissions to users`})]}):(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Name`}),(0,x.jsx)(`th`,{children:`Description`}),(0,x.jsx)(`th`,{children:`Type`}),(0,x.jsx)(`th`,{style:{width:80}})]})}),(0,x.jsx)(`tbody`,{children:l.map(n=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontWeight:600,color:n.name===Tz?`var(--accent)`:`var(--text)`},children:n.name})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{color:`var(--muted)`,fontSize:12},children:n.description??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${`builtin`in n&&n.builtin?`badge-accent`:`badge-muted`}`,children:`builtin`in n&&n.builtin?`built-in`:`custom`})}),(0,x.jsx)(`td`,{className:`no-click`,style:{textAlign:`right`},children:(0,x.jsxs)(`div`,{style:{display:`flex`,gap:6,justifyContent:`flex-end`},children:[(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>e(n),children:`Edit`}),n.name!==Tz&&(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:()=>t(n),children:(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:(0,x.jsx)(`path`,{d:`M2 4.5h12M5.5 4.5V3h5v1.5M10.5 4.5v8a1 1 0 01-1 1h-3a1 1 0 01-1-1v-8`,strokeLinecap:`round`})})})]})})]},n.name))})]})})})})}function Dz(){let e=Ra(),t=C(),n=F(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)({name:``,description:``}),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=ut(Cr());async function m(n){n.preventDefault(),u(!0);try{await p.mutateAsync({name:s.name.trim().toUpperCase(),description:s.description||void 0}),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role created`),i(!1),c({name:``,description:``})}catch(t){e.error(t instanceof Error?t.message:String(t))}finally{u(!1)}}async function h(r){if(r.preventDefault(),a){u(!0);try{await n.admin.roles.update(a.name,{description:s.description||void 0}),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role updated`),o(null)}catch(t){e.error(t instanceof Error?t.message:String(t))}finally{u(!1)}}}async function g(r){if(confirm(`Delete role ${r.name}?`))try{await n.admin.roles.remove(r.name),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role deleted`)}catch(t){e.error(t instanceof Error?t.message:String(t))}}return d?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,style:{marginBottom:8},children:`Roles`}),(0,x.jsxs)(`div`,{className:`error-box`,children:[`Role catalog requires the `,(0,x.jsx)(`code`,{children:`auth_settings`}),` table (runtime settings). Run the migration to enable this feature.`]})]}):(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Roles`}),(0,x.jsx)(`div`,{className:`page-sub`,children:`Global role catalog`})]}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>{c({name:``,description:``}),i(!0)},children:[(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M8 2v12M2 8h12`,strokeLinecap:`round`})}),`New Role`]})})]}),(0,x.jsx)(Ez,{onEdit:e=>{o(e),c({name:e.name,description:e.description??``})},onDelete:g,onUnavailable:()=>f(!0)}),(0,x.jsx)(ja,{open:r,onClose:()=>i(!1),title:`New Role`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>i(!1),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:m,disabled:l,children:l?(0,x.jsx)(`span`,{className:`spinner sm`}):`Create Role`})]}),children:(0,x.jsxs)(`form`,{onSubmit:m,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Name * (uppercase)`}),(0,x.jsx)(`input`,{className:`input input-mono`,required:!0,value:s.name,onChange:e=>c(t=>({...t,name:e.target.value.toUpperCase()})),placeholder:`EDITOR`}),(0,x.jsx)(`div`,{className:`hint`,children:`Letters, digits, underscore. E.g. ADMIN, CONTENT_MANAGER`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Description`}),(0,x.jsx)(`input`,{className:`input`,value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),placeholder:`Can edit content`})]})]})}),(0,x.jsx)(ja,{open:!!a,onClose:()=>o(null),title:`Edit Role — ${a?.name}`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>o(null),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:h,disabled:l,children:l?(0,x.jsx)(`span`,{className:`spinner sm`}):`Save`})]}),children:(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Description`}),(0,x.jsx)(`input`,{className:`input`,value:s.description,onChange:e=>c(t=>({...t,description:e.target.value}))})]})})]})}var Oz=20;function kz({page:e,onPage:t}){let{data:n,isLoading:r,error:i,refetch:a}=P(_r()),o=n?.sessions??[],s=o.length,c=o.slice((e-1)*Oz,e*Oz);return(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:r,error:i,onRetry:a,skeleton:(0,x.jsx)(Ca,{rows:8,cols:6}),children:c.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,x.jsx)(`h4`,{children:`No active sessions`}),(0,x.jsx)(`p`,{children:`No users are currently logged in`})]}):(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`Browser / OS`}),(0,x.jsx)(`th`,{children:`IP`}),(0,x.jsx)(`th`,{children:`Location`}),(0,x.jsx)(`th`,{children:`Login`}),(0,x.jsx)(`th`,{children:`Methods`})]})}),(0,x.jsx)(`tbody`,{children:c.map(e=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[e.email&&(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500,color:`var(--text)`},children:e.email}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:e.email?`var(--faint)`:void 0},children:e.accountId})]})}),(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{color:`var(--text)`,fontWeight:500,fontSize:12},children:e.browser??`—`}),(0,x.jsx)(`span`,{style:{color:`var(--faint)`,fontSize:11},children:e.os??``})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`code`,children:e.ip??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontSize:11.5,color:`var(--muted)`},children:e.location??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:11,color:`var(--faint)`},children:e.loginTs?new Date(e.loginTs).toLocaleString():`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:e.amr.length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`—`}):e.amr.map(e=>(0,x.jsx)(`span`,{className:`badge badge-muted`,children:e},e))})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:e,total:s,size:Oz,onPage:t})})]})})})}function Az(){let{data:e}=P(_r());return e?.sessions.length??0}function jz(){let e=Ra(),t=C(),[n,r]=na(`page`,Ki.withDefault(1)),i=Az(),a=ut(vr());async function o(){if(confirm(`Revoke ALL active sessions? All users will be logged out.`))try{let n=await a.mutateAsync();e.success(`Revoked ${n.revoked??0} sessions`),t.invalidateQueries({queryKey:L.admin.sessions()})}catch(t){e.error(t instanceof Error?t.message:String(t))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Sessions`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[i.toLocaleString(),` active sessions`]})]}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-danger`,onClick:o,disabled:a.isPending,children:[a.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:(0,x.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`,strokeLinecap:`round`})}),`Revoke All`]})})]}),(0,x.jsx)(kz,{page:n,onPage:r})]})}function Mz({rowCount:e=4}){return(0,x.jsx)(`div`,{style:{background:`var(--bg2)`,border:`1px solid var(--line)`,borderRadius:`var(--radius)`,overflow:`hidden`},children:Array.from({length:e}).map((t,n)=>(0,x.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`14px 16px`,borderBottom:n<e-1?`1px solid var(--line)`:void 0,gap:16},children:[(0,x.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,gap:6},children:[(0,x.jsx)(z,{width:`40%`,height:13}),(0,x.jsx)(z,{width:`70%`,height:11})]}),(0,x.jsx)(z,{width:44,height:24,borderRadius:12})]},n))})}function Nz(){return(0,x.jsxs)(`span`,{className:`settings-badge`,title:`Definido via defineConfig() — gerenciado no código, não editável aqui`,style:{background:`var(--accent-soft, rgba(99,102,241,0.12))`,color:`var(--accent, #6366f1)`,borderColor:`rgba(99,102,241,0.3)`,display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,"aria-hidden":!0,children:[(0,x.jsx)(`rect`,{x:`3`,y:`7`,width:`10`,height:`7`,rx:`1.5`}),(0,x.jsx)(`path`,{d:`M5 7V5a3 3 0 016 0v2`,strokeLinecap:`round`})]}),`definido via config`]})}function Pz({section:e,onUnavailable:t}){let n=Ra(),r=C(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),{data:f,isLoading:p,error:m,refetch:h}=P({...Fr(),retry:(e,n)=>n&&typeof n==`object`&&`status`in n&&n.status===404?(i||(a(!0),t()),!1):e<1}),g=f?.data??[],_=(f?.locked??[]).includes(e.settingKey),v=g.find(t=>t.key===e.settingKey),y=!v,S=v&&typeof v.value==`object`&&v.value!==null&&!Array.isArray(v.value)?v.value:{},w=o??S;(0,b.useEffect)(()=>{s(null),l(!1)},[f]);let T=ut(Ir()),E=ut(Lr());function D(e){return e.field in w?w[e.field]:e.defaultValue}function O(e,t){s(n=>({...n??S,[e.field]:t})),l(!0)}async function k(){d(!0);try{let t={...w};for(let n of e.fields)n.field in t||(t[n.field]=n.defaultValue);await T.mutateAsync({key:e.settingKey,value:t}),r.invalidateQueries({queryKey:L.admin.settings()}),l(!1),n.success(`Salvo: ${e.settingKey}`)}catch(e){n.error(e instanceof Error?e.message:String(e))}finally{d(!1)}}async function ee(){d(!0);try{await E.mutateAsync(e.settingKey),r.invalidateQueries({queryKey:L.admin.settings()}),s(null),l(!1),n.success(`Voltou ao default: ${e.settingKey}`)}catch(e){n.error(e instanceof Error?e.message:String(e))}finally{d(!1)}}let A=m&&typeof m==`object`&&`status`in m&&m.status===404,te=m&&!A?m:void 0;return(0,x.jsxs)(`div`,{className:`settings-section`,children:[(0,x.jsxs)(`div`,{className:`settings-section-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[e.title,_&&(0,x.jsx)(Nz,{}),!_&&!y&&(0,x.jsx)(`span`,{className:`settings-badge`,children:`custom`}),c&&!_&&(0,x.jsx)(`span`,{className:`settings-badge`,style:{background:`var(--amber-soft)`,color:`var(--amber)`,borderColor:`rgba(255,180,84,0.3)`},children:`unsaved`})]}),(0,x.jsx)(`p`,{style:{marginTop:2},children:e.description}),_&&(0,x.jsxs)(`p`,{style:{marginTop:4,color:`var(--accent, #6366f1)`,fontSize:12},children:[`Travado no `,(0,x.jsx)(`code`,{children:`defineConfig()`}),` — o config tem prioridade sobre o runtime. Remova de lá para editar por aqui.`]}),(0,x.jsx)(`div`,{style:{fontSize:10.5,color:`var(--faint)`,fontFamily:`var(--mono)`,marginTop:2},children:e.settingKey})]}),!_&&(0,x.jsxs)(`div`,{className:`settings-control`,style:{gap:8},children:[c&&(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,disabled:u,onClick:k,children:u?(0,x.jsx)(`span`,{className:`spinner sm`}):`Salvar`}),!y&&!c&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:u,onClick:ee,title:`Voltar ao default`,children:(0,x.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`path`,{d:`M2 8a6 6 0 016-6 6 6 0 014.24 1.76L14 5`,strokeLinecap:`round`}),(0,x.jsx)(`path`,{d:`M14 2v3h-3`,strokeLinecap:`round`})]})})]})]}),(0,x.jsx)(_a,{isLoading:p,error:te,onRetry:h,skeleton:(0,x.jsx)(Mz,{rowCount:e.fields.length}),children:(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(`div`,{className:`panel-body`,style:{padding:0},children:e.fields.map(e=>{let t=D(e);return(0,x.jsxs)(`div`,{className:`settings-row`,style:_?{opacity:.85}:void 0,children:[(0,x.jsxs)(`div`,{className:`settings-info`,children:[(0,x.jsx)(`div`,{className:`settings-key`,children:e.label}),(0,x.jsx)(`div`,{className:`settings-desc`,children:e.description})]}),(0,x.jsx)(`div`,{className:`settings-control`,children:e.type===`boolean`?(0,x.jsxs)(`label`,{className:`toggle`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:!!t,disabled:_,onChange:t=>O(e,t.target.checked)}),(0,x.jsx)(`div`,{className:`toggle-track`}),(0,x.jsx)(`div`,{className:`toggle-thumb`})]}):e.type===`number`?(0,x.jsx)(`input`,{className:`input input-mono`,type:`number`,style:{width:90,textAlign:`right`},value:String(t??e.defaultValue??0),disabled:_,onChange:t=>O(e,Number(t.target.value))}):(0,x.jsx)(`input`,{className:`input`,style:{width:220},value:String(t??e.defaultValue??``),disabled:_,onChange:t=>O(e,t.target.value)})})]},e.field)})})})})]})}var Fz=[{title:`Métodos de login`,description:`Quais métodos a tela de login oferece. Travável via defineConfig({ authMethods }).`,settingKey:`auth_methods`,fields:[{field:`password`,label:`Senha`,description:`Login por e-mail + senha`,type:`boolean`,defaultValue:!0},{field:`magicLink`,label:`Magic link`,description:`Login por link enviado no e-mail (requer mail + passwordless.magicLink)`,type:`boolean`,defaultValue:!1},{field:`passkey`,label:`Passkey`,description:`Entrar com passkey (WebAuthn) antes da senha`,type:`boolean`,defaultValue:!1},{field:`forgotPassword`,label:`Esqueci a senha`,description:`Link de reset (só aparece com senha ligada)`,type:`boolean`,defaultValue:!0},{field:`passkeyAutofill`,label:`Autofill de passkey`,description:`Sugestões de passkey no input de e-mail (conditional mediation)`,type:`boolean`,defaultValue:!0}]},{title:`Cadastro`,description:`Cadastro público (self-service).`,settingKey:`registration`,fields:[{field:`enabled`,label:`Permitir cadastro`,description:`Novos usuários podem se cadastrar sozinhos`,type:`boolean`,defaultValue:!0}]},{title:`Verificação de e-mail`,description:`Exigir e-mail verificado para logar.`,settingKey:`require_verified_email`,fields:[{field:`enabled`,label:`Exigir e-mail verificado`,description:`Bloqueia login de contas com e-mail não verificado`,type:`boolean`,defaultValue:!1},{field:`graceDays`,label:`Dias de graça`,description:`Permite login não-verificado por N dias após o cadastro (0 = sem graça)`,type:`number`,defaultValue:0}]},{title:`Manutenção`,description:`Modo manutenção — bloqueia login de contas comuns (admin segue entrando).`,settingKey:`maintenance_mode`,fields:[{field:`enabled`,label:`Modo manutenção`,description:`Telas de login/signup mostram página de manutenção`,type:`boolean`,defaultValue:!1},{field:`message`,label:`Mensagem`,description:`Texto exibido na página de manutenção (vazio = default)`,type:`string`,defaultValue:``}]},{title:`Bloqueio por falha (lockout)`,description:`Trava a conta após tentativas de login falhas.`,settingKey:`lockout`,fields:[{field:`enabled`,label:`Ligar lockout`,description:`Trava a conta após muitas falhas de senha`,type:`boolean`,defaultValue:!1},{field:`maxAttempts`,label:`Máx. tentativas`,description:`Falhas antes de travar`,type:`number`,defaultValue:5},{field:`windowSec`,label:`Janela (s)`,description:`Janela em que as falhas contam`,type:`number`,defaultValue:900},{field:`baseLockoutSec`,label:`Trava base (s)`,description:`Duração inicial da trava (backoff exponencial)`,type:`number`,defaultValue:60},{field:`maxLockoutSec`,label:`Trava máx. (s)`,description:`Teto da duração da trava`,type:`number`,defaultValue:3600}]},{title:`TTL dos tokens`,description:`Tempo de vida dos tokens OIDC (segundos).`,settingKey:`token_ttl`,fields:[{field:`accessTokenSec`,label:`Access token (s)`,description:`Validade do access token`,type:`number`,defaultValue:3600},{field:`idTokenSec`,label:`ID token (s)`,description:`Validade do ID token`,type:`number`,defaultValue:3600},{field:`refreshTokenSec`,label:`Refresh token (s)`,description:`Validade do refresh token`,type:`number`,defaultValue:2592e3}]}];function Iz(){let[e,t]=(0,b.useState)(!1);return e?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,style:{marginBottom:8},children:`Settings`}),(0,x.jsxs)(`div`,{className:`error-box`,children:[`Runtime settings exigem a tabela `,(0,x.jsx)(`code`,{children:`auth_settings`}),`. Rode a migration para habilitar.`]})]}):(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Settings`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[`Configuração de runtime — mudanças valem na hora. Settings definidas no`,` `,(0,x.jsx)(`code`,{children:`defineConfig()`}),` ficam travadas (config > runtime).`]})]}),Fz.map(e=>(0,x.jsx)(Pz,{section:e,onUnavailable:()=>t(!0)},e.settingKey))]})}var Lz=20;function Rz({search:e,page:t,onPage:n,onSelectUser:r}){let{data:i,isLoading:a,error:o,refetch:s}=P(sr({search:e,page:t,size:Lz})),c=i?.data??[],l=i?.meta.total??0;return(0,x.jsxs)(x.Fragment,{children:[!a&&!o&&(0,x.jsx)(`div`,{style:{marginBottom:4},children:(0,x.jsxs)(`span`,{className:`page-sub`,style:{fontSize:12,color:`var(--faint)`},children:[l.toLocaleString(),` accounts`]})}),(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(Ca,{rows:6,cols:3}),children:c.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,x.jsx)(`path`,{d:`M4 20c0-4.42 3.58-8 8-8s8 3.58 8 8`})]}),(0,x.jsx)(`h4`,{children:`No users found`}),(0,x.jsx)(`p`,{children:e?`Try a different search term`:`No accounts registered yet`})]}):(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`User`}),(0,x.jsx)(`th`,{children:`Roles`}),(0,x.jsx)(`th`,{children:`Status`})]})}),(0,x.jsx)(`tbody`,{children:c.map(e=>(0,x.jsxs)(`tr`,{onClick:()=>r(e.id),children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,x.jsx)(`div`,{className:`avatar`,style:{width:26,height:26,fontSize:10},children:e.email.slice(0,2).toUpperCase()}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500,fontSize:12.5},children:e.email}),e.name&&(0,x.jsx)(`div`,{style:{color:`var(--faint)`,fontSize:11},children:e.name})]})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:(e.roles??e.globalRoles).length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`no roles`}):(e.roles??e.globalRoles).map(e=>(0,x.jsx)(`span`,{className:`badge badge-accent`,children:e},e))})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${e.disabled?`badge-red`:`badge-green`}`,children:e.disabled?`disabled`:`active`})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:t,total:l,size:Lz,onPage:n})})]})})})]})}function zz({userId:e,onMutated:t,onClose:n}){let r=Ra(),i=C(),{data:a,isLoading:o,error:s,refetch:c}=P(cr(e)),l=ut(fr(e)),u=ut(pr(e)),d=ut(mr(e)),f=ut(hr(e)),p=ut(gr(e)),m=P({...Rr(e),enabled:!1}),[h,g]=(0,b.useState)(null);async function _(){if(a)try{a.disabled?(await u.mutateAsync(),r.success(`User enabled`)):(await l.mutateAsync(),r.success(`User disabled`)),i.invalidateQueries({queryKey:L.admin.user(e)}),t()}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function v(){try{await d.mutateAsync(),r.success(`Reset email sent`)}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function y(){if(a&&confirm(`Delete user ${a.email}? This cannot be undone.`))try{await f.mutateAsync(),r.success(`User deleted`),n(),t()}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function S(){if(a&&confirm(`Disconnect ${a.email} from all devices? Every active session and grant will be revoked.`))try{let t=await p.mutateAsync();r.success(`Disconnected from all devices${typeof t?.revoked==`number`?` (${t.revoked} sessions)`:``}`),i.invalidateQueries({queryKey:L.admin.userSessions(e)})}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function w(){let e=await m.refetch();e.error?r.error(e.error instanceof Error?e.error.message:`Impersonation not available`):e.data?g(e.data):r.error(`Impersonation not available`)}async function T(e,t){try{await navigator.clipboard.writeText(e),r.success(`${t} copied`)}catch{r.error(`Could not copy to the clipboard`)}}return(0,x.jsx)(_a,{isLoading:o,error:s,onRetry:c,skeleton:(0,x.jsx)(`div`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:16},children:[(0,x.jsx)(`div`,{style:{width:44,height:44,borderRadius:`50%`,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}}),(0,x.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,gap:6},children:[(0,x.jsx)(`div`,{style:{height:14,width:`60%`,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}}),(0,x.jsx)(`div`,{style:{height:11,width:`40%`,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}})]})]})}),children:a&&(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:16},children:[(0,x.jsx)(`div`,{className:`avatar`,style:{width:44,height:44,fontSize:15},children:a.email.slice(0,2).toUpperCase()}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{fontWeight:600,fontSize:14},children:a.email}),a.name&&(0,x.jsx)(`div`,{style:{color:`var(--faint)`,fontSize:12},children:a.name}),(0,x.jsx)(`div`,{style:{marginTop:4},children:(0,x.jsx)(`span`,{className:`badge ${a.disabled?`badge-red`:`badge-green`}`,children:a.disabled?`disabled`:`active`})})]})]}),(0,x.jsxs)(`div`,{className:`code`,style:{fontSize:11,padding:`6px 10px`},children:[`ID: `,a.id]}),(0,x.jsxs)(`div`,{style:{marginTop:16},children:[(0,x.jsx)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:`Actions`}),(0,x.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:[(0,x.jsx)(`button`,{className:`btn btn-sm ${a.disabled?``:`btn-danger`}`,onClick:_,disabled:l.isPending||u.isPending,children:a.disabled?`Enable account`:`Disable account`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:v,disabled:d.isPending,children:`Reset password`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:w,disabled:m.isFetching,children:`Impersonate`}),(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:S,disabled:p.isPending,children:`Disconnect all devices`}),(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:y,disabled:f.isPending,children:`Delete user`})]})]}),(0,x.jsx)(ja,{open:h!==null,onClose:()=>g(null),title:`Impersonate ${h?.targetEmail??``}`,large:!0,footer:(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>g(null),children:`Close`}),children:h&&(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,x.jsxs)(`p`,{style:{margin:0,fontSize:13,color:`var(--faint)`},children:[`Impersonation runs through the RFC 8693 token exchange. The exchange has to be signed with `,(0,x.jsx)(`strong`,{children:`your own admin access token`}),` as the`,` `,(0,x.jsx)(`code`,{children:`subject_token`}),`, which this console does not hold — so run the request below from wherever you already have that token. The issued `,(0,x.jsx)(`code`,{children:`id_token`}),` `,`carries `,(0,x.jsx)(`code`,{children:`act`}),` with your subject, and the exchange is audited.`]}),(0,x.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,x.jsx)(Bz,{label:`Token endpoint`,value:h.tokenEndpoint}),(0,x.jsx)(Bz,{label:`Client`,value:h.clientId}),(0,x.jsx)(Bz,{label:`Grant type`,value:h.grantType}),(0,x.jsx)(Bz,{label:`Subject token type`,value:h.subjectTokenType}),(0,x.jsx)(Bz,{label:`Requested subject`,value:h.requestedSubject})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:6},children:[(0,x.jsx)(`span`,{style:{fontSize:12,color:`var(--faint)`},children:`Request`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>T(h.curl,`Command`),children:`Copy`})]}),(0,x.jsx)(`pre`,{className:`code`,style:{fontSize:11,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:h.curl})]})]})})]})})}function Bz({label:e,value:t}){return(0,x.jsxs)(`div`,{style:{display:`flex`,gap:10,fontSize:12},children:[(0,x.jsx)(`span`,{style:{color:`var(--faint)`,minWidth:140},children:e}),(0,x.jsx)(`span`,{className:`code`,style:{fontSize:11,padding:`2px 6px`,wordBreak:`break-all`},children:t})]})}function Vz({userId:e,onMutated:t}){let n=Ra(),r=C(),{data:i,isLoading:a,error:o,refetch:s}=P(cr(e)),c=ut(dr(e)),[l,u]=(0,b.useState)([]),d=Bi().features?.rolesManagedExternally===!0;(0,b.useEffect)(()=>{i&&u(i.globalRoles)},[i]);let f=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};async function p(){try{await c.mutateAsync({globalRoles:l}),n.success(`Roles updated`),r.invalidateQueries({queryKey:L.admin.user(e)}),t()}catch(e){n.error(e instanceof Error?e.message:String(e))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:`Global Roles`}),(0,x.jsxs)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2].map(e=>(0,x.jsx)(`div`,{style:{height:20,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}},e))}),children:[i&&d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`,marginBottom:8},children:(i.roles??[]).length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`no roles`}):(i.roles??[]).map(e=>(0,x.jsx)(`span`,{className:`badge badge-accent`,children:e},e))}),(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`},children:`Roles come from the application (resolveTokenRoles) and are managed there.`})]}),i&&!d&&(0,x.jsxs)(x.Fragment,{children:[l.length===0&&(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`,marginBottom:8},children:`No roles assigned`}),i.globalRoles.map(e=>(0,x.jsxs)(`label`,{className:`checkbox-row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:l.includes(e),onChange:()=>f(e)}),(0,x.jsx)(`div`,{children:(0,x.jsx)(`div`,{className:`chk-label`,children:e})})]},e)),(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,style:{marginTop:10},onClick:p,disabled:c.isPending,children:c.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):`Save roles`})]})]})]})}function Hz({userId:e}){let{data:t,isLoading:n,error:r,refetch:i}=P(lr(e)),a=t?.sessions??[];return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:[`Sessions `,!n&&!r?`(${a.length})`:``]}),(0,x.jsx)(_a,{isLoading:n,error:r,onRetry:i,skeleton:(0,x.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2].map(e=>(0,x.jsx)(`div`,{style:{height:44,borderRadius:8,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}},e))}),children:a.length===0?(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`},children:`No active sessions`}):a.map(e=>(0,x.jsxs)(`div`,{className:`panel`,style:{marginBottom:8,padding:`10px 12px`},children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,x.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`none`,stroke:`var(--muted)`,strokeWidth:`1.6`,children:[(0,x.jsx)(`rect`,{x:`1.5`,y:`3.5`,width:`13`,height:`9`,rx:`1.5`}),(0,x.jsx)(`circle`,{cx:`8`,cy:`8.5`,r:`2`})]}),(0,x.jsx)(`span`,{style:{color:`var(--text)`,fontWeight:500},children:e.browser??`Unknown browser`}),(0,x.jsx)(`span`,{style:{color:`var(--faint)`},children:e.os}),(0,x.jsx)(`span`,{className:`code ml-auto`,children:e.ip??`—`})]}),e.location&&(0,x.jsx)(`div`,{style:{fontSize:11,color:`var(--faint)`,marginTop:4},children:e.location})]},e.id))})]})}function Uz({userId:e,onClose:t,onMutated:n}){let{data:r}=P(cr(e));return(0,x.jsx)(Ga,{open:!0,onClose:t,title:r?.email??`User detail`,children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,x.jsx)(zz,{userId:e,onMutated:n,onClose:t}),(0,x.jsx)(Vz,{userId:e,onMutated:n}),(0,x.jsx)(Hz,{userId:e})]})})}function Wz(){let e=Ra(),t=C(),[n,r]=na(`page`,Ki.withDefault(1)),[i,a]=na(`q`,Gi.withDefault(``)),[o,s]=na(`user`),c=Ka(i,300),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)({email:``,name:``,password:``,invite:!1}),p=ut(ur());async function m(n){n.preventDefault();try{await p.mutateAsync({email:d.email,name:d.name||void 0,password:d.password||void 0,invite:d.invite}),t.invalidateQueries({queryKey:L.admin.users()}),e.success(`User created`),u(!1),f({email:``,name:``,password:``,invite:!1})}catch(t){e.error(t instanceof Error?t.message:String(t))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsx)(`div`,{children:(0,x.jsx)(`div`,{className:`page-title`,children:`Users`})}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>u(!0),children:[(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M8 2v12M2 8h12`,strokeLinecap:`round`})}),`New User`]})})]}),(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:0},children:(0,x.jsx)(`div`,{className:`panel-head`,children:(0,x.jsxs)(`div`,{className:`search-input`,style:{flex:1,maxWidth:320},children:[(0,x.jsxs)(`svg`,{className:`search-ico`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,children:[(0,x.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,x.jsx)(`path`,{d:`M10 10l3 3`,strokeLinecap:`round`})]}),(0,x.jsx)(`input`,{className:`input`,placeholder:`Search by email or name…`,value:i,onChange:e=>{a(e.target.value),r(1)}})]})})}),(0,x.jsx)(Rz,{search:c,page:n,onPage:r,onSelectUser:s,onInvalidate:()=>t.invalidateQueries({queryKey:L.admin.users()})}),(0,x.jsx)(ja,{open:l,onClose:()=>u(!1),title:`Create User`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>u(!1),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:m,disabled:p.isPending,children:p.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):`Create User`})]}),children:(0,x.jsxs)(`form`,{onSubmit:m,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Email *`}),(0,x.jsx)(`input`,{className:`input`,type:`email`,required:!0,value:d.email,onChange:e=>f(t=>({...t,email:e.target.value})),placeholder:`user@example.com`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Name`}),(0,x.jsx)(`input`,{className:`input`,value:d.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:`Full name (optional)`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Password`}),(0,x.jsx)(`input`,{className:`input`,type:`password`,value:d.password,onChange:e=>f(t=>({...t,password:e.target.value})),placeholder:`Leave blank to send invite`})]}),(0,x.jsxs)(`label`,{className:`checkbox-row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:d.invite,onChange:e=>f(t=>({...t,invite:e.target.checked}))}),(0,x.jsx)(`span`,{className:`chk-label`,children:`Send invitation email`})]})]})}),o&&(0,x.jsx)(Uz,{userId:o,onClose:()=>s(null),onMutated:()=>t.invalidateQueries({queryKey:L.admin.users()})})]})}var Gz={overview:`Overview`,users:`Users`,sessions:`Sessions`,clients:`OAuth Clients`,roles:`Roles`,orgs:`Organizations`,audit:`Audit Log`,keys:`Signing Keys`,agents:`Personal Agents`,settings:`Settings`};function Kz(){let{route:e}=ia();switch(e){case`overview`:return(0,x.jsx)(pz,{});case`users`:return(0,x.jsx)(Wz,{});case`sessions`:return(0,x.jsx)(jz,{});case`clients`:return(0,x.jsx)(Ha,{});case`roles`:return(0,x.jsx)(Dz,{});case`orgs`:return(0,x.jsx)(So,{});case`audit`:return(0,x.jsx)(Aa,{});case`keys`:return(0,x.jsx)(Wa,{});case`agents`:return(0,x.jsx)(wz,{});case`settings`:return(0,x.jsx)(Iz,{});default:return(0,x.jsx)(pz,{})}}function qz(){let{route:e}=ia();return(0,x.jsxs)(`div`,{className:`app-shell`,children:[(0,x.jsx)(ca,{}),(0,x.jsxs)(`main`,{className:`main`,children:[(0,x.jsx)(la,{title:Gz[e]??`AuthKit Admin`}),(0,x.jsx)(`div`,{className:`content`,children:(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`loading-row`,children:(0,x.jsx)(`div`,{className:`spinner lg`})}),children:(0,x.jsx)(Kz,{})})})]})]})}var Jz=document.getElementById(`root`);if(!Jz)throw Error(`Root element not found`);var Yz=pt();(0,zi.createRoot)(Jz).render((0,x.jsx)(b.StrictMode,{children:(0,x.jsx)(w,{client:Yz,children:(0,x.jsx)(ft,{children:(0,x.jsx)(Ri,{children:(0,x.jsx)(oa,{children:(0,x.jsx)(La,{children:(0,x.jsx)(qz,{})})})})})})}));
|
|
67
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MR(e,t){if(e){if(typeof e==`string`)return NR(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?NR(e,t):void 0}}function NR(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PR(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function FR(e){if(Array.isArray(e))return e}var IR=()=>(qk(),null);function LR(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var RR=(0,b.forwardRef)((e,t)=>{var n=(0,b.useRef)(null),r=AR((0,b.useState)({containerWidth:LR(e.style?.width),containerHeight:LR(e.style?.height)}),2),i=r[0],a=r[1],o=(0,b.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,b.useEffect)(()=>()=>{n.current?.disconnect()},[o]),b.createElement(b.Fragment,null,b.createElement(Rp,{width:i.containerWidth,height:i.containerHeight}),b.createElement(`div`,kR({ref:s},e)))}),zR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=AR((0,b.useState)({containerWidth:LR(n),containerHeight:LR(r)}),2),a=i[0],o=i[1],s=(0,b.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return b.createElement(b.Fragment,null,b.createElement(Rp,{width:a.containerWidth,height:a.containerHeight}),b.createElement(`div`,kR({ref:c},e)))}),BR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height;return b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(`div`,kR({ref:t},e)))}),VR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?b.createElement(zR,kR({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?b.createElement(BR,kR({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(`div`,kR({ref:t},e)))});function HR(e){return e?RR:VR}var UR=(0,b.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,x=y===void 0||y,S=(0,b.useRef)(null),C=jc(),w=AR((0,b.useState)(null),2),T=w[0],E=w[1],D=AR((0,b.useState)(null),2),O=D[0],k=D[1],ee=CR(),A=Tp(),te=A?.width>0?A.width:_,j=A?.height>0?A.height:i,ne=(0,b.useCallback)(e=>{ee(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[ee,t,E,k]),re=(0,b.useCallback)(e=>{C(gL(e)),C(RL({handler:a,reactEvent:e}))},[C,a]),ie=(0,b.useCallback)(e=>{C(vL(e)),C(RL({handler:l,reactEvent:e}))},[C,l]),ae=(0,b.useCallback)(e=>{C(nD()),C(RL({handler:u,reactEvent:e}))},[C,u]),oe=(0,b.useCallback)(e=>{C(vL(e)),C(RL({handler:d,reactEvent:e}))},[C,d]),se=(0,b.useCallback)(()=>{C(jL())},[C]),ce=(0,b.useCallback)(()=>{C(ML())},[C]),le=(0,b.useCallback)(e=>{C(AL(e.key))},[C]),ue=(0,b.useCallback)(e=>{C(RL({handler:o,reactEvent:e}))},[C,o]),de=(0,b.useCallback)(e=>{C(RL({handler:s,reactEvent:e}))},[C,s]),fe=(0,b.useCallback)(e=>{C(RL({handler:c,reactEvent:e}))},[C,c]),pe=(0,b.useCallback)(e=>{C(RL({handler:f,reactEvent:e}))},[C,f]),me=(0,b.useCallback)(e=>{C(RL({handler:h,reactEvent:e}))},[C,h]),he=(0,b.useCallback)(e=>{x&&C(WL(e)),C(RL({handler:m,reactEvent:e}))},[C,x,m]),ge=(0,b.useCallback)(e=>{C(RL({handler:p,reactEvent:e}))},[C,p]),M=HR(v);return b.createElement(xk.Provider,{value:T},b.createElement(ps.Provider,{value:O},b.createElement(M,{width:te??g?.width,height:j??g?.height,className:wo(`recharts-wrapper`,r),style:TR({position:`relative`,cursor:`default`,width:te,height:j},g),onClick:re,onContextMenu:ue,onDoubleClick:de,onFocus:se,onBlur:ce,onKeyDown:le,onMouseDown:fe,onMouseEnter:ie,onMouseLeave:ae,onMouseMove:oe,onMouseUp:pe,onTouchEnd:ge,onTouchMove:he,onTouchStart:me,ref:ne},b.createElement(IR,null),n)))}),WR=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function GR(e,t){if(e==null)return{};var n,r,i=KR(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function KR(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var qR=(0,b.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=Ao(GR(e,WR));return c?b.createElement(b.Fragment,null,b.createElement(Rp,{width:n,height:r}),b.createElement(gR,{otherAttributes:d,title:l,desc:u},a)):b.createElement(UR,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(gR,{otherAttributes:d,title:l,desc:u,ref:t},b.createElement(mP,null,a)))});function JR(){return JR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JR.apply(null,arguments)}function YR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YR(Object(n),!0).forEach(function(t){ZR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZR(e,t,n){return(t=QR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QR(e){var t=$R(e,`string`);return typeof t==`symbol`?t:t+``}function $R(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ez=XR({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},XL),tz=(0,b.forwardRef)(function(e,t){var n=Sc(e.categoricalChartProps,ez),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return b.createElement(nR,{preloadedState:{options:c},reduxStoreName:s.id??r},b.createElement(QN,{chartData:s.data}),b.createElement(iR,{layout:n.layout,margin:n.margin}),b.createElement(oR,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(aR,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(qR,JR({},n,{ref:t})))}),nz=[`axis`],rz=(0,b.forwardRef)((e,t)=>b.createElement(tz,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nz,tooltipPayloadSearcher:Dk,categoricalChartProps:e,ref:t})),iz=e=>{let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})};function az({data:e,color:t=`var(--accent)`,height:n=150,label:r=`events`}){if(!e||e.length===0)return(0,x.jsx)(`div`,{style:{height:n}});let i=`tc-${r.replace(/[^a-z0-9]/gi,``)}`;return(0,x.jsx)(Dp,{width:`100%`,height:n,children:(0,x.jsxs)(rz,{data:e,margin:{top:8,right:8,bottom:0,left:8},children:[(0,x.jsx)(`defs`,{children:(0,x.jsxs)(`linearGradient`,{id:i,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,x.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.32}),(0,x.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:.02})]})}),(0,x.jsx)(jF,{strokeDasharray:`3 3`,stroke:`var(--line)`,vertical:!1}),(0,x.jsx)(ZI,{dataKey:`date`,tickFormatter:iz,tick:{fontSize:10,fill:`var(--faint)`},axisLine:!1,tickLine:!1,minTickGap:42}),(0,x.jsx)(fL,{hide:!0,domain:[0,`auto`],allowDecimals:!1}),(0,x.jsx)(uA,{cursor:{stroke:`var(--line)`,strokeDasharray:`3 3`},content:({active:e,payload:n,label:i})=>e&&n?.length?(0,x.jsxs)(`div`,{className:`chart-tip`,children:[(0,x.jsx)(`div`,{className:`chart-tip-label`,children:iz(String(i))}),(0,x.jsxs)(`div`,{className:`chart-tip-row`,children:[(0,x.jsx)(`span`,{className:`chart-tip-dot`,style:{background:t}}),r,` `,(0,x.jsx)(`b`,{children:n[0].value})]})]}):null}),(0,x.jsx)(AI,{type:`monotone`,dataKey:`count`,stroke:t,strokeWidth:1.8,fill:`url(#${i})`,isAnimationActive:!1})]})})}function oz(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function sz(e){return e.includes(`login`)||e.includes(`signin`)?`badge-green`:e.includes(`fail`)||e.includes(`error`)||e.includes(`locked`)?`badge-red`:e.includes(`register`)||e.includes(`signup`)?`badge-accent`:e.includes(`settings`)||e.includes(`admin`)?`badge-amber`:`badge-muted`}function cz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(xa,{count:6,columns:3}),children:e&&(0,x.jsxs)(`div`,{className:`cards`,children:[(0,x.jsxs)(`div`,{className:`card c-accent`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Total Users`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.usersTotal.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`registered accounts`})]}),(0,x.jsxs)(`div`,{className:`card c-green`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Active Sessions`}),(0,x.jsx)(`div`,{className:`card-value`,children:(e.activeSessions??0).toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`currently logged in`})]}),(0,x.jsxs)(`div`,{className:`card c-amber`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`MAU`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.mau.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`monthly active users`})]}),(0,x.jsxs)(`div`,{className:`card`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Sign-ins`}),(0,x.jsx)(`div`,{className:`card-value`,style:{color:`var(--text)`},children:e.signInsTotal.toLocaleString()}),(0,x.jsxs)(`div`,{className:`card-hint`,children:[`last `,e.windowDays,` days`]})]}),(0,x.jsxs)(`div`,{className:`card c-blue`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`Sign-ups`}),(0,x.jsx)(`div`,{className:`card-value`,children:e.signUpsTotal.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`new registrations`})]}),(0,x.jsxs)(`div`,{className:`card`,children:[(0,x.jsx)(`div`,{className:`card-label`,children:`OAuth Clients`}),(0,x.jsx)(`div`,{className:`card-value`,style:{color:`var(--text)`},children:e.clientsCount.toLocaleString()}),(0,x.jsx)(`div`,{className:`card-hint`,children:`OIDC clients`})]})]})})}function lz({title:e}){return(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsx)(`div`,{className:`panel-head`,children:(0,x.jsx)(`h3`,{children:e})}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:4},children:(0,x.jsx)(z,{height:60,borderRadius:8})})]})}function uz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(lz,{title:`Sign-ins / day`}),children:e&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Sign-ins / day`}),(0,x.jsxs)(`span`,{className:`meta`,children:[`last `,e.windowDays,`d`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:`4px`},children:e.signInsPerDay.length>0?(0,x.jsx)(az,{data:e.signInsPerDay,color:`var(--accent)`,label:`sign-ins`}):(0,x.jsx)(`div`,{style:{height:60,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--faint)`,fontSize:12},children:`No data yet`})})]})})}function dz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(lz,{title:`Sign-ups / day`}),children:e&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Sign-ups / day`}),(0,x.jsxs)(`span`,{className:`meta`,children:[`last `,e.windowDays,`d`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{paddingBottom:`4px`},children:e.signUpsPerDay.length>0?(0,x.jsx)(az,{data:e.signUpsPerDay,color:`var(--green)`,label:`sign-ups`}):(0,x.jsx)(`div`,{style:{height:60,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--faint)`,fontSize:12},children:`No data yet`})})]})})}function fz(){let{data:e,isLoading:t,error:n,refetch:r}=P(or());return(0,x.jsx)(_a,{isLoading:t,error:n,onRetry:r,skeleton:(0,x.jsx)(Ca,{rows:5,cols:4}),children:e?.auditSupported&&e.recentEvents.length>0&&(0,x.jsxs)(`div`,{className:`panel`,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{children:`Recent Events`}),(0,x.jsxs)(`span`,{className:`meta`,children:[e.auditTotal.toLocaleString(),` total`]})]}),(0,x.jsx)(`div`,{className:`panel-body`,style:{padding:0},children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Type`}),(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`IP`}),(0,x.jsx)(`th`,{children:`When`})]})}),(0,x.jsx)(`tbody`,{children:e.recentEvents.map(e=>(0,x.jsxs)(`tr`,{className:`static`,style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${sz(e.type)}`,children:e.type})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`11.5px`},children:e.email??e.accountId??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`code`,children:e.ip??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`11px`,color:`var(--faint)`},children:e.createdAt?oz(e.createdAt):`—`})})]},e.id))})]})})]})})}function pz(){return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Overview`}),(0,x.jsx)(`div`,{className:`page-sub`,children:`Identity provider metrics`})]}),(0,x.jsx)(cz,{}),(0,x.jsxs)(`div`,{className:`grid-2`,style:{marginTop:16},children:[(0,x.jsx)(uz,{}),(0,x.jsx)(dz,{})]}),(0,x.jsx)(`div`,{style:{marginTop:16},children:(0,x.jsx)(fz,{})})]})}var mz=20,hz={pact:`PACT`,poppy:`Poppy`};function gz(e){return!!e&&typeof e==`object`&&`status`in e&&e.status===404}function _z(){let e=Ra();return t=>{if(t?.code===`sudo_required`){let e=window.location.pathname+window.location.search;window.location.href=`${Bi().endpoints.confirm??`/account/confirm`}?return_to=${encodeURIComponent(e)}`}else e.error(t instanceof Error?t.message:String(t))}}function vz(){let e=C();return()=>e.invalidateQueries({queryKey:L.admin.personalAgents()})}function yz({agent:e}){let t=e.effective===`blocked`?(0,x.jsx)(`span`,{className:`badge badge-red`,children:`blocked`}):e.effective===`allowed`?(0,x.jsx)(`span`,{className:`badge badge-green`,children:`allowed`}):(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`not listed`}),n=[e.config&&`config: ${e.config}`,e.console&&`console: ${e.console.status}`].filter(Boolean);return(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3,alignItems:`flex-start`},children:[t,n.length>0&&(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},children:n.join(` · `)})]})}function bz(e){let t=[],{pact:n,poppy:r}=e.protocols;return n&&t.push(n.open?`PACT: open — any agent publishing a JWKS via OIDC discovery is accepted, except blocked ones.`:`PACT: only listed agents are accepted.`),r&&t.push(r.requireRegistration?`Poppy: registration required — only listed agents can start sessions.`:`Poppy: any agent with a valid client_id can start sessions, except blocked ones.`),(n?.hostResolver||r?.hostResolver)&&t.push(`Part of the list comes from a host function and is not shown here.`),t}function xz({onShowConnections:e}){let{data:t,isLoading:n,error:r,refetch:i}=P({...Vr(),retry:(e,t)=>!gz(t)&&e<1}),a=ut(Wr()),o=ut(Gr()),s=Ra(),c=_z(),l=vz(),[u,d]=(0,b.useState)(!1);if(gz(r))return(0,x.jsxs)(`div`,{className:`error-box`,children:[`Personal agents are not configured. Add `,(0,x.jsx)(`code`,{children:`personalAgents`}),` (PACT and/or`,` `,(0,x.jsx)(`code`,{children:`poppy`}),`) to `,(0,x.jsx)(`code`,{children:`defineConfig`}),`.`]});async function f(e){if(confirm(`Block ${e.name}? Every account connected to it is disconnected now (${e.connections}), and it cannot connect again until unblocked.`))try{let t=await a.mutateAsync({protocol:e.protocol,identifier:e.identifier,status:`blocked`,name:e.console?void 0:e.name,jwksUri:e.jwksUri??void 0});s.success(`Blocked — ${t.disconnected} connection(s) revoked`),l()}catch(e){c(e)}}async function p(e){if(e.protocol===`pact`&&!e.jwksUri)d(!0);else try{await a.mutateAsync({protocol:e.protocol,identifier:e.identifier,status:`allowed`,jwksUri:e.jwksUri??void 0}),s.success(`Agent allowed`),l()}catch(e){c(e)}}async function m(e){if(!e.console)return;let t=e.console.status===`blocked`?`Unblock`:`Remove from the allowlist`;if(confirm(`${t}: ${e.name}?`))try{await o.mutateAsync(e.console.id),s.success(e.console.status===`blocked`?`Unblocked`:`Removed`),l()}catch(e){c(e)}}let h=a.isPending||o.isPending;return(0,x.jsx)(_a,{isLoading:n,error:r,onRetry:i,skeleton:(0,x.jsx)(Ca,{rows:4,cols:5}),children:t&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:16},children:(0,x.jsxs)(`div`,{className:`panel-body`,style:{display:`flex`,gap:16,alignItems:`flex-start`},children:[(0,x.jsx)(`div`,{style:{flex:1,fontSize:12,color:`var(--muted)`,lineHeight:1.7},children:bz(t).map(e=>(0,x.jsx)(`div`,{children:e},e))}),(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,onClick:()=>d(!0),children:`Add agent`})]})}),(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:24},children:t.agents.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsx)(`h4`,{children:`No personal agents yet`}),(0,x.jsx)(`p`,{children:`Agents show up here once listed or once someone connects one.`})]}):(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Agent`}),(0,x.jsx)(`th`,{children:`Protocol`}),(0,x.jsx)(`th`,{children:`Status`}),(0,x.jsx)(`th`,{children:`Connections`}),(0,x.jsx)(`th`,{})]})}),(0,x.jsx)(`tbody`,{children:t.agents.map(t=>{let n=t.config===`blocked`,r=t.console?.status===`blocked`;return(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:t.name}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:`var(--faint)`},children:t.identifier})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge badge-muted`,children:hz[t.protocol]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(yz,{agent:t})}),(0,x.jsx)(`td`,{children:t.connections>0?(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:()=>e(t),children:t.connections}):(0,x.jsx)(`span`,{style:{color:`var(--faint)`},children:`0`})}),(0,x.jsxs)(`td`,{style:{textAlign:`right`,whiteSpace:`nowrap`},children:[t.console&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:h,onClick:()=>m(t),children:r?`Unblock`:`Remove`}),t.effective===`unlisted`&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:h,onClick:()=>p(t),children:`Allow`}),!n&&!r&&(0,x.jsx)(`button`,{className:`btn btn-danger btn-sm`,disabled:h,onClick:()=>f(t),children:`Block`}),n&&(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},title:`Blocked in defineConfig — change it there.`,children:`locked by config`})]})]},`${t.protocol} ${t.identifier}`)})})]})})}),(0,x.jsx)(Sz,{open:u,onClose:()=>d(!1),protocols:[`pact`,`poppy`].filter(e=>t.protocols[e]!==null),allowHttp:!!t.protocols.poppy?.allowInsecureClientIds})]})})}function Sz({open:e,onClose:t,protocols:n,allowHttp:r}){let i=ut(Wr()),a=Ra(),o=_z(),s=vz(),[c,l]=(0,b.useState)(n[0]??`poppy`),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(``),[g,_]=(0,b.useState)(`allowed`);async function v(e){e.preventDefault();try{let e=await i.mutateAsync({protocol:c,identifier:u.trim(),status:g,name:f.trim()||void 0,jwksUri:c===`pact`&&m.trim()||void 0});a.success(g===`blocked`?`Blocked — ${e.disconnected} connection(s) revoked`:`Agent allowed`),s(),d(``),p(``),h(``),t()}catch(e){o(e)}}return(0,x.jsx)(ja,{open:e,onClose:t,title:`Add personal agent`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn btn-ghost`,onClick:t,children:`Cancel`}),(0,x.jsx)(`button`,{className:g===`blocked`?`btn btn-danger`:`btn btn-primary`,form:`add-agent-form`,type:`submit`,disabled:i.isPending||!u.trim(),children:i.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):g===`blocked`?`Block`:`Allow`})]}),children:(0,x.jsxs)(`form`,{id:`add-agent-form`,onSubmit:v,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Protocol`}),(0,x.jsx)(`select`,{className:`input`,value:c,onChange:e=>l(e.target.value),children:n.map(e=>(0,x.jsx)(`option`,{value:e,children:hz[e]},e))})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:c===`poppy`?`Client ID (metadata URL)`:`Issuer (iss)`}),(0,x.jsx)(`input`,{className:`input input-mono`,value:u,onChange:e=>d(e.target.value),placeholder:c===`poppy`?`${r?`http(s)`:`https`}://agent.example/poppy-agent/agent.json`:`https://agent.example`,required:!0})]}),c===`pact`&&(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsxs)(`label`,{children:[`JWKS URI `,g===`allowed`?`(required)`:`(optional)`]}),(0,x.jsx)(`input`,{className:`input input-mono`,value:m,onChange:e=>h(e.target.value),placeholder:`https://agent.example/.well-known/jwks.json`,required:g===`allowed`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Display name (optional)`}),(0,x.jsx)(`input`,{className:`input`,value:f,onChange:e=>p(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Status`}),(0,x.jsxs)(`select`,{className:`input`,value:g,onChange:e=>_(e.target.value===`blocked`?`blocked`:`allowed`),children:[(0,x.jsx)(`option`,{value:`allowed`,children:`Allowed`}),(0,x.jsx)(`option`,{value:`blocked`,children:`Blocked (disconnects every account now)`})]})]})]})})}function Cz({agent:e,onClearAgent:t,page:n,onPage:r}){let{data:i,isLoading:a,error:o,refetch:s}=P({...Hr({protocol:e?.protocol,clientId:e?.identifier,page:n,size:mz}),retry:(e,t)=>!gz(t)&&e<1}),c=ut(Ur()),l=Ra(),u=_z(),d=vz();if(gz(o))return null;async function f(e,t,n){if(confirm(`Disconnect ${n} from ${t}?`))try{await c.mutateAsync(e),l.success(`Connection revoked`),d()}catch(e){u(e)}}return(0,x.jsxs)(`div`,{className:`settings-section`,children:[(0,x.jsxs)(`div`,{className:`settings-section-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{children:[`Connections`,e?` — ${e.name}`:``]}),(0,x.jsx)(`p`,{style:{marginTop:2},children:`Accounts that signed in to a personal agent. Revoking cuts that agent off the account right away.`})]}),e&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,onClick:t,children:`Show all`})]}),(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(Ca,{rows:5,cols:5}),children:i&&i.data.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsx)(`h4`,{children:`No connections`}),(0,x.jsx)(`p`,{children:`No account is connected to a personal agent.`})]}):i&&(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`Agent`}),(0,x.jsx)(`th`,{children:`Scopes`}),(0,x.jsx)(`th`,{children:`Connected`}),(0,x.jsx)(`th`,{children:`Expires`}),(0,x.jsx)(`th`,{})]})}),(0,x.jsx)(`tbody`,{children:i.data.map(e=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[e.accountEmail&&(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:e.accountEmail}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:`var(--faint)`},children:e.accountId})]})}),(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{fontSize:12},children:e.agentName}),(0,x.jsx)(`span`,{style:{fontSize:11,color:`var(--faint)`},children:hz[e.protocol]})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:e.scopes.map(e=>(0,x.jsx)(`span`,{className:`badge badge-muted`,children:e},e))})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`mono text-sm`,children:new Date(e.createdAt).toLocaleString()})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`mono text-sm`,children:new Date(e.expiresAt).toLocaleDateString()})}),(0,x.jsx)(`td`,{style:{textAlign:`right`},children:(0,x.jsx)(`button`,{className:`btn btn-danger btn-sm`,disabled:c.isPending,onClick:()=>f(e.id,e.accountEmail??e.accountId,e.agentName),children:`Revoke`})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:n,total:i.meta.total,size:mz,onPage:r})})]})})})]})}function wz(){let[e,t]=na(`page`,Ki.withDefault(1)),[n,r]=(0,b.useState)(null);return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Personal agents`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[`AI agents (PACT, Poppy) acting for your users: who is connected, and which agents may connect. Allow and block add to `,(0,x.jsx)(`code`,{children:`defineConfig`}),` and apply right away.`]})]}),(0,x.jsx)(xz,{onShowConnections:e=>{r(e),t(null)}}),(0,x.jsx)(Cz,{agent:n,onClearAgent:()=>{r(null),t(null)},page:e,onPage:e=>void t(e)})]})}var Tz=`ADMIN`;function Ez({onEdit:e,onDelete:t,onUnavailable:n}){let[r,i]=(0,b.useState)(!1),{data:a,isLoading:o,error:s,refetch:c}=P({...Sr(),retry:(e,t)=>t&&typeof t==`object`&&`status`in t&&t.status===404?(r||(i(!0),n()),!1):e<1}),l=a?.data??[];return(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:o,error:s&&!(typeof s==`object`&&`status`in s&&s.status===404)?s:void 0,onRetry:c,skeleton:(0,x.jsx)(Ca,{rows:4,cols:4}),children:l.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,x.jsx)(`path`,{d:`M2 20a10 10 0 0120 0`})]}),(0,x.jsx)(`h4`,{children:`No roles yet`}),(0,x.jsx)(`p`,{children:`Create roles to assign permissions to users`})]}):(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Name`}),(0,x.jsx)(`th`,{children:`Description`}),(0,x.jsx)(`th`,{children:`Type`}),(0,x.jsx)(`th`,{style:{width:80}})]})}),(0,x.jsx)(`tbody`,{children:l.map(n=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontWeight:600,color:n.name===Tz?`var(--accent)`:`var(--text)`},children:n.name})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{color:`var(--muted)`,fontSize:12},children:n.description??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${`builtin`in n&&n.builtin?`badge-accent`:`badge-muted`}`,children:`builtin`in n&&n.builtin?`built-in`:`custom`})}),(0,x.jsx)(`td`,{className:`no-click`,style:{textAlign:`right`},children:(0,x.jsxs)(`div`,{style:{display:`flex`,gap:6,justifyContent:`flex-end`},children:[(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>e(n),children:`Edit`}),n.name!==Tz&&(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:()=>t(n),children:(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:(0,x.jsx)(`path`,{d:`M2 4.5h12M5.5 4.5V3h5v1.5M10.5 4.5v8a1 1 0 01-1 1h-3a1 1 0 01-1-1v-8`,strokeLinecap:`round`})})})]})})]},n.name))})]})})})})}function Dz(){let e=Ra(),t=C(),n=F(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)({name:``,description:``}),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=ut(Cr());async function m(n){n.preventDefault(),u(!0);try{await p.mutateAsync({name:s.name.trim().toUpperCase(),description:s.description||void 0}),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role created`),i(!1),c({name:``,description:``})}catch(t){e.error(t instanceof Error?t.message:String(t))}finally{u(!1)}}async function h(r){if(r.preventDefault(),a){u(!0);try{await n.admin.roles.update(a.name,{description:s.description||void 0}),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role updated`),o(null)}catch(t){e.error(t instanceof Error?t.message:String(t))}finally{u(!1)}}}async function g(r){if(confirm(`Delete role ${r.name}?`))try{await n.admin.roles.remove(r.name),t.invalidateQueries({queryKey:L.admin.roles()}),e.success(`Role deleted`)}catch(t){e.error(t instanceof Error?t.message:String(t))}}return d?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,style:{marginBottom:8},children:`Roles`}),(0,x.jsxs)(`div`,{className:`error-box`,children:[`Role catalog requires the `,(0,x.jsx)(`code`,{children:`auth_settings`}),` table (runtime settings). Run the migration to enable this feature.`]})]}):(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Roles`}),(0,x.jsx)(`div`,{className:`page-sub`,children:`Global role catalog`})]}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>{c({name:``,description:``}),i(!0)},children:[(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M8 2v12M2 8h12`,strokeLinecap:`round`})}),`New Role`]})})]}),(0,x.jsx)(Ez,{onEdit:e=>{o(e),c({name:e.name,description:e.description??``})},onDelete:g,onUnavailable:()=>f(!0)}),(0,x.jsx)(ja,{open:r,onClose:()=>i(!1),title:`New Role`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>i(!1),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:m,disabled:l,children:l?(0,x.jsx)(`span`,{className:`spinner sm`}):`Create Role`})]}),children:(0,x.jsxs)(`form`,{onSubmit:m,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Name * (uppercase)`}),(0,x.jsx)(`input`,{className:`input input-mono`,required:!0,value:s.name,onChange:e=>c(t=>({...t,name:e.target.value.toUpperCase()})),placeholder:`EDITOR`}),(0,x.jsx)(`div`,{className:`hint`,children:`Letters, digits, underscore. E.g. ADMIN, CONTENT_MANAGER`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Description`}),(0,x.jsx)(`input`,{className:`input`,value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),placeholder:`Can edit content`})]})]})}),(0,x.jsx)(ja,{open:!!a,onClose:()=>o(null),title:`Edit Role — ${a?.name}`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>o(null),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:h,disabled:l,children:l?(0,x.jsx)(`span`,{className:`spinner sm`}):`Save`})]}),children:(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Description`}),(0,x.jsx)(`input`,{className:`input`,value:s.description,onChange:e=>c(t=>({...t,description:e.target.value}))})]})})]})}var Oz=20;function kz({page:e,onPage:t}){let{data:n,isLoading:r,error:i,refetch:a}=P(_r()),o=n?.sessions??[],s=o.length,c=o.slice((e-1)*Oz,e*Oz);return(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:r,error:i,onRetry:a,skeleton:(0,x.jsx)(Ca,{rows:8,cols:6}),children:c.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,x.jsx)(`h4`,{children:`No active sessions`}),(0,x.jsx)(`p`,{children:`No users are currently logged in`})]}):(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Account`}),(0,x.jsx)(`th`,{children:`Browser / OS`}),(0,x.jsx)(`th`,{children:`IP`}),(0,x.jsx)(`th`,{children:`Location`}),(0,x.jsx)(`th`,{children:`Login`}),(0,x.jsx)(`th`,{children:`Methods`})]})}),(0,x.jsx)(`tbody`,{children:c.map(e=>(0,x.jsxs)(`tr`,{style:{cursor:`default`},children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[e.email&&(0,x.jsx)(`span`,{style:{fontSize:12,fontWeight:500,color:`var(--text)`},children:e.email}),(0,x.jsx)(`span`,{className:`mono text-sm`,style:{color:e.email?`var(--faint)`:void 0},children:e.accountId})]})}),(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,x.jsx)(`span`,{style:{color:`var(--text)`,fontWeight:500,fontSize:12},children:e.browser??`—`}),(0,x.jsx)(`span`,{style:{color:`var(--faint)`,fontSize:11},children:e.os??``})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`code`,children:e.ip??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontSize:11.5,color:`var(--muted)`},children:e.location??`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:11,color:`var(--faint)`},children:e.loginTs?new Date(e.loginTs).toLocaleString():`—`})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:e.amr.length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`—`}):e.amr.map(e=>(0,x.jsx)(`span`,{className:`badge badge-muted`,children:e},e))})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:e,total:s,size:Oz,onPage:t})})]})})})}function Az(){let{data:e}=P(_r());return e?.sessions.length??0}function jz(){let e=Ra(),t=C(),[n,r]=na(`page`,Ki.withDefault(1)),i=Az(),a=ut(vr());async function o(){if(confirm(`Revoke ALL active sessions? All users will be logged out.`))try{let n=await a.mutateAsync();e.success(`Revoked ${n.revoked??0} sessions`),t.invalidateQueries({queryKey:L.admin.sessions()})}catch(t){e.error(t instanceof Error?t.message:String(t))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Sessions`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[i.toLocaleString(),` active sessions`]})]}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-danger`,onClick:o,disabled:a.isPending,children:[a.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:(0,x.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`,strokeLinecap:`round`})}),`Revoke All`]})})]}),(0,x.jsx)(kz,{page:n,onPage:r})]})}function Mz({rowCount:e=4}){return(0,x.jsx)(`div`,{style:{background:`var(--bg2)`,border:`1px solid var(--line)`,borderRadius:`var(--radius)`,overflow:`hidden`},children:Array.from({length:e}).map((t,n)=>(0,x.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`14px 16px`,borderBottom:n<e-1?`1px solid var(--line)`:void 0,gap:16},children:[(0,x.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,gap:6},children:[(0,x.jsx)(z,{width:`40%`,height:13}),(0,x.jsx)(z,{width:`70%`,height:11})]}),(0,x.jsx)(z,{width:44,height:24,borderRadius:12})]},n))})}function Nz(){return(0,x.jsxs)(`span`,{className:`settings-badge`,title:`Definido via defineConfig() — gerenciado no código, não editável aqui`,style:{background:`var(--accent-soft, rgba(99,102,241,0.12))`,color:`var(--accent, #6366f1)`,borderColor:`rgba(99,102,241,0.3)`,display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,"aria-hidden":!0,children:[(0,x.jsx)(`rect`,{x:`3`,y:`7`,width:`10`,height:`7`,rx:`1.5`}),(0,x.jsx)(`path`,{d:`M5 7V5a3 3 0 016 0v2`,strokeLinecap:`round`})]}),`definido via config`]})}function Pz({section:e,onUnavailable:t}){let n=Ra(),r=C(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),{data:f,isLoading:p,error:m,refetch:h}=P({...Fr(),retry:(e,n)=>n&&typeof n==`object`&&`status`in n&&n.status===404?(i||(a(!0),t()),!1):e<1}),g=f?.data??[],_=(f?.locked??[]).includes(e.settingKey),v=g.find(t=>t.key===e.settingKey),y=!v,S=v&&typeof v.value==`object`&&v.value!==null&&!Array.isArray(v.value)?v.value:{},w=o??S;(0,b.useEffect)(()=>{s(null),l(!1)},[f]);let T=ut(Ir()),E=ut(Lr());function D(e){return e.field in w?w[e.field]:e.defaultValue}function O(e,t){s(n=>({...n??S,[e.field]:t})),l(!0)}async function k(){d(!0);try{let t={...w};for(let n of e.fields)n.field in t||(t[n.field]=n.defaultValue);await T.mutateAsync({key:e.settingKey,value:t}),r.invalidateQueries({queryKey:L.admin.settings()}),l(!1),n.success(`Salvo: ${e.settingKey}`)}catch(e){n.error(e instanceof Error?e.message:String(e))}finally{d(!1)}}async function ee(){d(!0);try{await E.mutateAsync(e.settingKey),r.invalidateQueries({queryKey:L.admin.settings()}),s(null),l(!1),n.success(`Voltou ao default: ${e.settingKey}`)}catch(e){n.error(e instanceof Error?e.message:String(e))}finally{d(!1)}}let A=m&&typeof m==`object`&&`status`in m&&m.status===404,te=m&&!A?m:void 0;return(0,x.jsxs)(`div`,{className:`settings-section`,children:[(0,x.jsxs)(`div`,{className:`settings-section-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[e.title,_&&(0,x.jsx)(Nz,{}),!_&&!y&&(0,x.jsx)(`span`,{className:`settings-badge`,children:`custom`}),c&&!_&&(0,x.jsx)(`span`,{className:`settings-badge`,style:{background:`var(--amber-soft)`,color:`var(--amber)`,borderColor:`rgba(255,180,84,0.3)`},children:`unsaved`})]}),(0,x.jsx)(`p`,{style:{marginTop:2},children:e.description}),_&&(0,x.jsxs)(`p`,{style:{marginTop:4,color:`var(--accent, #6366f1)`,fontSize:12},children:[`Travado no `,(0,x.jsx)(`code`,{children:`defineConfig()`}),` — o config tem prioridade sobre o runtime. Remova de lá para editar por aqui.`]}),(0,x.jsx)(`div`,{style:{fontSize:10.5,color:`var(--faint)`,fontFamily:`var(--mono)`,marginTop:2},children:e.settingKey})]}),!_&&(0,x.jsxs)(`div`,{className:`settings-control`,style:{gap:8},children:[c&&(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,disabled:u,onClick:k,children:u?(0,x.jsx)(`span`,{className:`spinner sm`}):`Salvar`}),!y&&!c&&(0,x.jsx)(`button`,{className:`btn btn-ghost btn-sm`,disabled:u,onClick:ee,title:`Voltar ao default`,children:(0,x.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`path`,{d:`M2 8a6 6 0 016-6 6 6 0 014.24 1.76L14 5`,strokeLinecap:`round`}),(0,x.jsx)(`path`,{d:`M14 2v3h-3`,strokeLinecap:`round`})]})})]})]}),(0,x.jsx)(_a,{isLoading:p,error:te,onRetry:h,skeleton:(0,x.jsx)(Mz,{rowCount:e.fields.length}),children:(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(`div`,{className:`panel-body`,style:{padding:0},children:e.fields.map(e=>{let t=D(e);return(0,x.jsxs)(`div`,{className:`settings-row`,style:_?{opacity:.85}:void 0,children:[(0,x.jsxs)(`div`,{className:`settings-info`,children:[(0,x.jsx)(`div`,{className:`settings-key`,children:e.label}),(0,x.jsx)(`div`,{className:`settings-desc`,children:e.description})]}),(0,x.jsx)(`div`,{className:`settings-control`,children:e.type===`boolean`?(0,x.jsxs)(`label`,{className:`toggle`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:!!t,disabled:_,onChange:t=>O(e,t.target.checked)}),(0,x.jsx)(`div`,{className:`toggle-track`}),(0,x.jsx)(`div`,{className:`toggle-thumb`})]}):e.type===`select`?(0,x.jsx)(`select`,{className:`input`,style:{width:220},value:String(t??e.defaultValue??``),disabled:_,onChange:t=>O(e,t.target.value),children:(e.options??[]).map(e=>(0,x.jsx)(`option`,{value:e.value,children:e.label},e.value))}):e.type===`list`?(0,x.jsx)(`input`,{className:`input input-mono`,style:{width:220},placeholder:`ADMIN, COORDINATOR`,value:(Array.isArray(t)?t:[]).join(`, `),disabled:_,onChange:t=>O(e,t.target.value.split(`,`).map(e=>e.trim()).filter(Boolean))}):e.type===`number`?(0,x.jsx)(`input`,{className:`input input-mono`,type:`number`,style:{width:90,textAlign:`right`},value:String(t??e.defaultValue??0),disabled:_,onChange:t=>O(e,Number(t.target.value))}):(0,x.jsx)(`input`,{className:`input`,style:{width:220},value:String(t??e.defaultValue??``),disabled:_,onChange:t=>O(e,t.target.value)})})]},e.field)})})})})]})}var Fz=[{title:`Métodos de login`,description:`Quais métodos a tela de login oferece. Travável via defineConfig({ authMethods }).`,settingKey:`auth_methods`,fields:[{field:`password`,label:`Senha`,description:`Login por e-mail + senha`,type:`boolean`,defaultValue:!0},{field:`magicLink`,label:`Magic link`,description:`Login por link enviado no e-mail (requer mail + passwordless.magicLink)`,type:`boolean`,defaultValue:!1},{field:`passkey`,label:`Passkey`,description:`Entrar com passkey (WebAuthn) antes da senha`,type:`boolean`,defaultValue:!1},{field:`forgotPassword`,label:`Esqueci a senha`,description:`Link de reset (só aparece com senha ligada)`,type:`boolean`,defaultValue:!0},{field:`passkeyAutofill`,label:`Autofill de passkey`,description:`Sugestões de passkey no input de e-mail (conditional mediation)`,type:`boolean`,defaultValue:!0}]},{title:`Cadastro`,description:`Cadastro público (self-service).`,settingKey:`registration`,fields:[{field:`enabled`,label:`Permitir cadastro`,description:`Novos usuários podem se cadastrar sozinhos`,type:`boolean`,defaultValue:!0}]},{title:`Verificação de e-mail`,description:`Exigir e-mail verificado para logar.`,settingKey:`require_verified_email`,fields:[{field:`enabled`,label:`Exigir e-mail verificado`,description:`Bloqueia login de contas com e-mail não verificado`,type:`boolean`,defaultValue:!1},{field:`graceDays`,label:`Dias de graça`,description:`Permite login não-verificado por N dias após o cadastro (0 = sem graça)`,type:`number`,defaultValue:0}]},{title:`Manutenção`,description:`Modo manutenção — bloqueia login de contas comuns (admin segue entrando).`,settingKey:`maintenance_mode`,fields:[{field:`enabled`,label:`Modo manutenção`,description:`Telas de login/signup mostram página de manutenção`,type:`boolean`,defaultValue:!1},{field:`message`,label:`Mensagem`,description:`Texto exibido na página de manutenção (vazio = default)`,type:`string`,defaultValue:``}]},{title:`Bloqueio por falha (lockout)`,description:`Trava a conta após tentativas de login falhas.`,settingKey:`lockout`,fields:[{field:`enabled`,label:`Ligar lockout`,description:`Trava a conta após muitas falhas de senha`,type:`boolean`,defaultValue:!1},{field:`maxAttempts`,label:`Máx. tentativas`,description:`Falhas antes de travar`,type:`number`,defaultValue:5},{field:`windowSec`,label:`Janela (s)`,description:`Janela em que as falhas contam`,type:`number`,defaultValue:900},{field:`baseLockoutSec`,label:`Trava base (s)`,description:`Duração inicial da trava (backoff exponencial)`,type:`number`,defaultValue:60},{field:`maxLockoutSec`,label:`Trava máx. (s)`,description:`Teto da duração da trava`,type:`number`,defaultValue:3600}]},{title:`Login social: 2º fator`,description:`Quando o "Continuar com Google" pede o 2º fator da conta. Travável via defineConfig({ social: { secondFactor } }).`,settingKey:`social_second_factor`,fields:[{field:`policy`,label:`Política`,description:`Para quem não tem um dos papéis abaixo`,type:`select`,options:[{value:`enrolled`,label:`Pedir se a conta tem fator cadastrado`},{value:`required`,label:`Sempre exigir`},{value:`never`,label:`Confiar só no provider`}],defaultValue:`enrolled`},{field:`requiredRoles`,label:`Papéis que sempre exigem`,description:`Separados por vírgula. Conta sem fator cadastrado com esses papéis precisa cadastrar antes de entrar pelo Google.`,type:`list`,defaultValue:[]}]},{title:`TTL dos tokens`,description:`Tempo de vida dos tokens OIDC (segundos).`,settingKey:`token_ttl`,fields:[{field:`accessTokenSec`,label:`Access token (s)`,description:`Validade do access token`,type:`number`,defaultValue:3600},{field:`idTokenSec`,label:`ID token (s)`,description:`Validade do ID token`,type:`number`,defaultValue:3600},{field:`refreshTokenSec`,label:`Refresh token (s)`,description:`Validade do refresh token`,type:`number`,defaultValue:2592e3}]}];function Iz(){let[e,t]=(0,b.useState)(!1);return e?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`page-title`,style:{marginBottom:8},children:`Settings`}),(0,x.jsxs)(`div`,{className:`error-box`,children:[`Runtime settings exigem a tabela `,(0,x.jsx)(`code`,{children:`auth_settings`}),`. Rode a migration para habilitar.`]})]}):(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header`,children:[(0,x.jsx)(`div`,{className:`page-title`,children:`Settings`}),(0,x.jsxs)(`div`,{className:`page-sub`,children:[`Configuração de runtime — mudanças valem na hora. Settings definidas no`,` `,(0,x.jsx)(`code`,{children:`defineConfig()`}),` ficam travadas (config > runtime).`]})]}),Fz.map(e=>(0,x.jsx)(Pz,{section:e,onUnavailable:()=>t(!0)},e.settingKey))]})}var Lz=20;function Rz({search:e,page:t,onPage:n,onSelectUser:r}){let{data:i,isLoading:a,error:o,refetch:s}=P(sr({search:e,page:t,size:Lz})),c=i?.data??[],l=i?.meta.total??0;return(0,x.jsxs)(x.Fragment,{children:[!a&&!o&&(0,x.jsx)(`div`,{style:{marginBottom:4},children:(0,x.jsxs)(`span`,{className:`page-sub`,style:{fontSize:12,color:`var(--faint)`},children:[l.toLocaleString(),` accounts`]})}),(0,x.jsx)(`div`,{className:`panel`,children:(0,x.jsx)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(Ca,{rows:6,cols:3}),children:c.length===0?(0,x.jsxs)(`div`,{className:`empty-state`,children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,x.jsx)(`path`,{d:`M4 20c0-4.42 3.58-8 8-8s8 3.58 8 8`})]}),(0,x.jsx)(`h4`,{children:`No users found`}),(0,x.jsx)(`p`,{children:e?`Try a different search term`:`No accounts registered yet`})]}):(0,x.jsxs)(`div`,{className:`tbl-wrap`,children:[(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`User`}),(0,x.jsx)(`th`,{children:`Roles`}),(0,x.jsx)(`th`,{children:`Status`})]})}),(0,x.jsx)(`tbody`,{children:c.map(e=>(0,x.jsxs)(`tr`,{onClick:()=>r(e.id),children:[(0,x.jsx)(`td`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,x.jsx)(`div`,{className:`avatar`,style:{width:26,height:26,fontSize:10},children:e.email.slice(0,2).toUpperCase()}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500,fontSize:12.5},children:e.email}),e.name&&(0,x.jsx)(`div`,{style:{color:`var(--faint)`,fontSize:11},children:e.name})]})]})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`},children:(e.roles??e.globalRoles).length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`no roles`}):(e.roles??e.globalRoles).map(e=>(0,x.jsx)(`span`,{className:`badge badge-accent`,children:e},e))})}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`span`,{className:`badge ${e.disabled?`badge-red`:`badge-green`}`,children:e.disabled?`disabled`:`active`})})]},e.id))})]}),(0,x.jsx)(`div`,{style:{padding:`0 16px 12px`},children:(0,x.jsx)(ua,{page:t,total:l,size:Lz,onPage:n})})]})})})]})}function zz({userId:e,onMutated:t,onClose:n}){let r=Ra(),i=C(),{data:a,isLoading:o,error:s,refetch:c}=P(cr(e)),l=ut(fr(e)),u=ut(pr(e)),d=ut(mr(e)),f=ut(hr(e)),p=ut(gr(e)),m=P({...Rr(e),enabled:!1}),[h,g]=(0,b.useState)(null);async function _(){if(a)try{a.disabled?(await u.mutateAsync(),r.success(`User enabled`)):(await l.mutateAsync(),r.success(`User disabled`)),i.invalidateQueries({queryKey:L.admin.user(e)}),t()}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function v(){try{await d.mutateAsync(),r.success(`Reset email sent`)}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function y(){if(a&&confirm(`Delete user ${a.email}? This cannot be undone.`))try{await f.mutateAsync(),r.success(`User deleted`),n(),t()}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function S(){if(a&&confirm(`Disconnect ${a.email} from all devices? Every active session and grant will be revoked.`))try{let t=await p.mutateAsync();r.success(`Disconnected from all devices${typeof t?.revoked==`number`?` (${t.revoked} sessions)`:``}`),i.invalidateQueries({queryKey:L.admin.userSessions(e)})}catch(e){r.error(e instanceof Error?e.message:String(e))}}async function w(){let e=await m.refetch();e.error?r.error(e.error instanceof Error?e.error.message:`Impersonation not available`):e.data?g(e.data):r.error(`Impersonation not available`)}async function T(e,t){try{await navigator.clipboard.writeText(e),r.success(`${t} copied`)}catch{r.error(`Could not copy to the clipboard`)}}return(0,x.jsx)(_a,{isLoading:o,error:s,onRetry:c,skeleton:(0,x.jsx)(`div`,{children:(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:16},children:[(0,x.jsx)(`div`,{style:{width:44,height:44,borderRadius:`50%`,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}}),(0,x.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,gap:6},children:[(0,x.jsx)(`div`,{style:{height:14,width:`60%`,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}}),(0,x.jsx)(`div`,{style:{height:11,width:`40%`,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}})]})]})}),children:a&&(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:16},children:[(0,x.jsx)(`div`,{className:`avatar`,style:{width:44,height:44,fontSize:15},children:a.email.slice(0,2).toUpperCase()}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{fontWeight:600,fontSize:14},children:a.email}),a.name&&(0,x.jsx)(`div`,{style:{color:`var(--faint)`,fontSize:12},children:a.name}),(0,x.jsx)(`div`,{style:{marginTop:4},children:(0,x.jsx)(`span`,{className:`badge ${a.disabled?`badge-red`:`badge-green`}`,children:a.disabled?`disabled`:`active`})})]})]}),(0,x.jsxs)(`div`,{className:`code`,style:{fontSize:11,padding:`6px 10px`},children:[`ID: `,a.id]}),(0,x.jsxs)(`div`,{style:{marginTop:16},children:[(0,x.jsx)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:`Actions`}),(0,x.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:[(0,x.jsx)(`button`,{className:`btn btn-sm ${a.disabled?``:`btn-danger`}`,onClick:_,disabled:l.isPending||u.isPending,children:a.disabled?`Enable account`:`Disable account`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:v,disabled:d.isPending,children:`Reset password`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:w,disabled:m.isFetching,children:`Impersonate`}),(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:S,disabled:p.isPending,children:`Disconnect all devices`}),(0,x.jsx)(`button`,{className:`btn btn-sm btn-danger`,onClick:y,disabled:f.isPending,children:`Delete user`})]})]}),(0,x.jsx)(ja,{open:h!==null,onClose:()=>g(null),title:`Impersonate ${h?.targetEmail??``}`,large:!0,footer:(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>g(null),children:`Close`}),children:h&&(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,x.jsxs)(`p`,{style:{margin:0,fontSize:13,color:`var(--faint)`},children:[`Impersonation runs through the RFC 8693 token exchange. The exchange has to be signed with `,(0,x.jsx)(`strong`,{children:`your own admin access token`}),` as the`,` `,(0,x.jsx)(`code`,{children:`subject_token`}),`, which this console does not hold — so run the request below from wherever you already have that token. The issued `,(0,x.jsx)(`code`,{children:`id_token`}),` `,`carries `,(0,x.jsx)(`code`,{children:`act`}),` with your subject, and the exchange is audited.`]}),(0,x.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,x.jsx)(Bz,{label:`Token endpoint`,value:h.tokenEndpoint}),(0,x.jsx)(Bz,{label:`Client`,value:h.clientId}),(0,x.jsx)(Bz,{label:`Grant type`,value:h.grantType}),(0,x.jsx)(Bz,{label:`Subject token type`,value:h.subjectTokenType}),(0,x.jsx)(Bz,{label:`Requested subject`,value:h.requestedSubject})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:6},children:[(0,x.jsx)(`span`,{style:{fontSize:12,color:`var(--faint)`},children:`Request`}),(0,x.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>T(h.curl,`Command`),children:`Copy`})]}),(0,x.jsx)(`pre`,{className:`code`,style:{fontSize:11,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:h.curl})]})]})})]})})}function Bz({label:e,value:t}){return(0,x.jsxs)(`div`,{style:{display:`flex`,gap:10,fontSize:12},children:[(0,x.jsx)(`span`,{style:{color:`var(--faint)`,minWidth:140},children:e}),(0,x.jsx)(`span`,{className:`code`,style:{fontSize:11,padding:`2px 6px`,wordBreak:`break-all`},children:t})]})}function Vz({userId:e,onMutated:t}){let n=Ra(),r=C(),{data:i,isLoading:a,error:o,refetch:s}=P(cr(e)),c=ut(dr(e)),[l,u]=(0,b.useState)([]),d=Bi().features?.rolesManagedExternally===!0;(0,b.useEffect)(()=>{i&&u(i.globalRoles)},[i]);let f=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};async function p(){try{await c.mutateAsync({globalRoles:l}),n.success(`Roles updated`),r.invalidateQueries({queryKey:L.admin.user(e)}),t()}catch(e){n.error(e instanceof Error?e.message:String(e))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:`Global Roles`}),(0,x.jsxs)(_a,{isLoading:a,error:o,onRetry:s,skeleton:(0,x.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2].map(e=>(0,x.jsx)(`div`,{style:{height:20,borderRadius:6,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}},e))}),children:[i&&d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`,marginBottom:8},children:(i.roles??[]).length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`no roles`}):(i.roles??[]).map(e=>(0,x.jsx)(`span`,{className:`badge badge-accent`,children:e},e))}),(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`},children:`Roles come from the application (resolveTokenRoles) and are managed there.`})]}),i&&!d&&(0,x.jsxs)(x.Fragment,{children:[l.length===0&&(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`,marginBottom:8},children:`No roles assigned`}),i.globalRoles.map(e=>(0,x.jsxs)(`label`,{className:`checkbox-row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:l.includes(e),onChange:()=>f(e)}),(0,x.jsx)(`div`,{children:(0,x.jsx)(`div`,{className:`chk-label`,children:e})})]},e)),(0,x.jsx)(`button`,{className:`btn btn-primary btn-sm`,style:{marginTop:10},onClick:p,disabled:c.isPending,children:c.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):`Save roles`})]})]})]})}function Hz({userId:e}){let{data:t,isLoading:n,error:r,refetch:i}=P(lr(e)),a=t?.sessions??[];return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{style:{fontSize:10.5,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`var(--faint)`,fontWeight:600,marginBottom:8},children:[`Sessions `,!n&&!r?`(${a.length})`:``]}),(0,x.jsx)(_a,{isLoading:n,error:r,onRetry:i,skeleton:(0,x.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[1,2].map(e=>(0,x.jsx)(`div`,{style:{height:44,borderRadius:8,background:`var(--bg3)`,backgroundImage:`linear-gradient(90deg, var(--bg3) 0%, var(--bg2) 40%, var(--bg3) 100%)`,backgroundSize:`200% 100%`,animation:`sk-shimmer 1.6s ease-in-out infinite`}},e))}),children:a.length===0?(0,x.jsx)(`div`,{style:{fontSize:12,color:`var(--faint)`},children:`No active sessions`}):a.map(e=>(0,x.jsxs)(`div`,{className:`panel`,style:{marginBottom:8,padding:`10px 12px`},children:[(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,x.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`none`,stroke:`var(--muted)`,strokeWidth:`1.6`,children:[(0,x.jsx)(`rect`,{x:`1.5`,y:`3.5`,width:`13`,height:`9`,rx:`1.5`}),(0,x.jsx)(`circle`,{cx:`8`,cy:`8.5`,r:`2`})]}),(0,x.jsx)(`span`,{style:{color:`var(--text)`,fontWeight:500},children:e.browser??`Unknown browser`}),(0,x.jsx)(`span`,{style:{color:`var(--faint)`},children:e.os}),(0,x.jsx)(`span`,{className:`code ml-auto`,children:e.ip??`—`})]}),e.location&&(0,x.jsx)(`div`,{style:{fontSize:11,color:`var(--faint)`,marginTop:4},children:e.location})]},e.id))})]})}function Uz({userId:e,onClose:t,onMutated:n}){let{data:r}=P(cr(e));return(0,x.jsx)(Ga,{open:!0,onClose:t,title:r?.email??`User detail`,children:(0,x.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,x.jsx)(zz,{userId:e,onMutated:n,onClose:t}),(0,x.jsx)(Vz,{userId:e,onMutated:n}),(0,x.jsx)(Hz,{userId:e})]})})}function Wz(){let e=Ra(),t=C(),[n,r]=na(`page`,Ki.withDefault(1)),[i,a]=na(`q`,Gi.withDefault(``)),[o,s]=na(`user`),c=Ka(i,300),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)({email:``,name:``,password:``,invite:!1}),p=ut(ur());async function m(n){n.preventDefault();try{await p.mutateAsync({email:d.email,name:d.name||void 0,password:d.password||void 0,invite:d.invite}),t.invalidateQueries({queryKey:L.admin.users()}),e.success(`User created`),u(!1),f({email:``,name:``,password:``,invite:!1})}catch(t){e.error(t instanceof Error?t.message:String(t))}}return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`page-header-row`,children:[(0,x.jsx)(`div`,{children:(0,x.jsx)(`div`,{className:`page-title`,children:`Users`})}),(0,x.jsx)(`div`,{className:`page-actions`,children:(0,x.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>u(!0),children:[(0,x.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M8 2v12M2 8h12`,strokeLinecap:`round`})}),`New User`]})})]}),(0,x.jsx)(`div`,{className:`panel`,style:{marginBottom:0},children:(0,x.jsx)(`div`,{className:`panel-head`,children:(0,x.jsxs)(`div`,{className:`search-input`,style:{flex:1,maxWidth:320},children:[(0,x.jsxs)(`svg`,{className:`search-ico`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,children:[(0,x.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,x.jsx)(`path`,{d:`M10 10l3 3`,strokeLinecap:`round`})]}),(0,x.jsx)(`input`,{className:`input`,placeholder:`Search by email or name…`,value:i,onChange:e=>{a(e.target.value),r(1)}})]})})}),(0,x.jsx)(Rz,{search:c,page:n,onPage:r,onSelectUser:s,onInvalidate:()=>t.invalidateQueries({queryKey:L.admin.users()})}),(0,x.jsx)(ja,{open:l,onClose:()=>u(!1),title:`Create User`,footer:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{className:`btn`,onClick:()=>u(!1),children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn btn-primary`,onClick:m,disabled:p.isPending,children:p.isPending?(0,x.jsx)(`span`,{className:`spinner sm`}):`Create User`})]}),children:(0,x.jsxs)(`form`,{onSubmit:m,children:[(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Email *`}),(0,x.jsx)(`input`,{className:`input`,type:`email`,required:!0,value:d.email,onChange:e=>f(t=>({...t,email:e.target.value})),placeholder:`user@example.com`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Name`}),(0,x.jsx)(`input`,{className:`input`,value:d.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:`Full name (optional)`})]}),(0,x.jsxs)(`div`,{className:`field`,children:[(0,x.jsx)(`label`,{children:`Password`}),(0,x.jsx)(`input`,{className:`input`,type:`password`,value:d.password,onChange:e=>f(t=>({...t,password:e.target.value})),placeholder:`Leave blank to send invite`})]}),(0,x.jsxs)(`label`,{className:`checkbox-row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:d.invite,onChange:e=>f(t=>({...t,invite:e.target.checked}))}),(0,x.jsx)(`span`,{className:`chk-label`,children:`Send invitation email`})]})]})}),o&&(0,x.jsx)(Uz,{userId:o,onClose:()=>s(null),onMutated:()=>t.invalidateQueries({queryKey:L.admin.users()})})]})}var Gz={overview:`Overview`,users:`Users`,sessions:`Sessions`,clients:`OAuth Clients`,roles:`Roles`,orgs:`Organizations`,audit:`Audit Log`,keys:`Signing Keys`,agents:`Personal Agents`,settings:`Settings`};function Kz(){let{route:e}=ia();switch(e){case`overview`:return(0,x.jsx)(pz,{});case`users`:return(0,x.jsx)(Wz,{});case`sessions`:return(0,x.jsx)(jz,{});case`clients`:return(0,x.jsx)(Ha,{});case`roles`:return(0,x.jsx)(Dz,{});case`orgs`:return(0,x.jsx)(So,{});case`audit`:return(0,x.jsx)(Aa,{});case`keys`:return(0,x.jsx)(Wa,{});case`agents`:return(0,x.jsx)(wz,{});case`settings`:return(0,x.jsx)(Iz,{});default:return(0,x.jsx)(pz,{})}}function qz(){let{route:e}=ia();return(0,x.jsxs)(`div`,{className:`app-shell`,children:[(0,x.jsx)(ca,{}),(0,x.jsxs)(`main`,{className:`main`,children:[(0,x.jsx)(la,{title:Gz[e]??`AuthKit Admin`}),(0,x.jsx)(`div`,{className:`content`,children:(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`loading-row`,children:(0,x.jsx)(`div`,{className:`spinner lg`})}),children:(0,x.jsx)(Kz,{})})})]})]})}var Jz=document.getElementById(`root`);if(!Jz)throw Error(`Root element not found`);var Yz=pt();(0,zi.createRoot)(Jz).render((0,x.jsx)(b.StrictMode,{children:(0,x.jsx)(w,{client:Yz,children:(0,x.jsx)(ft,{children:(0,x.jsx)(Ri,{children:(0,x.jsx)(oa,{children:(0,x.jsx)(La,{children:(0,x.jsx)(qz,{})})})})})})}));
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;1,400&display=swap" rel="stylesheet">
|
|
11
|
-
<script type="module" crossorigin src="/__AUTHKIT_BASE__/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/__AUTHKIT_BASE__/assets/index-BV2WkBd5.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/__AUTHKIT_BASE__/assets/index-DTSmD4RU.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readActiveOrgFromHostCtx } from '../host/active_org_cookie.js';
|
|
2
2
|
import { InteractionSessionLostException, isInteractionSessionLost, } from '../host/interaction_recovery.js';
|
|
3
|
+
import { relayPendingCookies } from '../host/last_login_method.js';
|
|
3
4
|
/**
|
|
4
5
|
* Choke point ÚNICO de `interactionDetails`: converte o `SessionNotFound` do
|
|
5
6
|
* `oidc-provider` (sessão de interaction perdida — caso NORMAL) na exceção
|
|
@@ -31,6 +32,7 @@ export function createInteractionActions(provider, deps) {
|
|
|
31
32
|
const account = await deps.verifyCredentials(email, password);
|
|
32
33
|
if (!account)
|
|
33
34
|
return { ok: false };
|
|
35
|
+
relayPendingCookies(ctx);
|
|
34
36
|
await provider.interactionFinished(ctx.request.request, ctx.response.response, { login: { accountId: account.id } }, { mergeWithLastSubmission: false });
|
|
35
37
|
return { ok: true };
|
|
36
38
|
},
|
|
@@ -47,6 +49,10 @@ export function createInteractionActions(provider, deps) {
|
|
|
47
49
|
// O campo `remember` é nativo do oidc-provider v9 — veja resume.js.
|
|
48
50
|
if (extra?.remember === false)
|
|
49
51
|
login.remember = false;
|
|
52
|
+
// O `interactionFinished` encerra a resposta crua: os cookies que o handler
|
|
53
|
+
// gravou no Adonis (último método de login, dispositivo confiável) só saem
|
|
54
|
+
// se forem repassados antes.
|
|
55
|
+
relayPendingCookies(ctx);
|
|
50
56
|
await provider.interactionFinished(ctx.request.request, ctx.response.response, { login }, { mergeWithLastSubmission: false });
|
|
51
57
|
return { ok: true };
|
|
52
58
|
},
|
|
@@ -75,6 +81,7 @@ export function createInteractionActions(provider, deps) {
|
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
const grantId = await grant.save();
|
|
84
|
+
relayPendingCookies(ctx);
|
|
78
85
|
return provider.interactionFinished(ctx.request.request, ctx.response.response, { consent: { grantId } }, { mergeWithLastSubmission: true });
|
|
79
86
|
},
|
|
80
87
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "AdonisJS OIDC/OAuth2 provider (Identity Provider) toolkit: ejectable auth server with sessions, rate-limiting, MFA/TOTP, audit log, federated logout and OpenTelemetry metrics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"qrcode": "1.5.4"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@adonis-agora/authkit-react": "0.
|
|
119
|
+
"@adonis-agora/authkit-react": "0.26.0",
|
|
120
120
|
"@adonis-agora/durable": "0.53.0",
|
|
121
121
|
"@adonis-agora/telescope": "0.23.0",
|
|
122
122
|
"@adonisjs/ally": "6.3.2",
|