@adonis-agora/authkit-server 0.82.3 → 0.84.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.
Files changed (34) hide show
  1. package/build/host/views/login.edge +25 -5
  2. package/build/host/views/partials/styles.edge +1 -1
  3. package/build/src/define_config.d.ts +44 -4
  4. package/build/src/define_config.js +1 -0
  5. package/build/src/host/account_roles.d.ts +14 -3
  6. package/build/src/host/account_roles.js +15 -4
  7. package/build/src/host/admin_api/api_users_controller.d.ts +3 -0
  8. package/build/src/host/admin_api/api_users_controller.js +9 -5
  9. package/build/src/host/admin_api/dto.d.ts +24 -0
  10. package/build/src/host/admin_api/dto.js +14 -0
  11. package/build/src/host/admin_api/token_verify_service.js +7 -2
  12. package/build/src/host/admin_console/admin_shell_controller.js +3 -1
  13. package/build/src/host/admin_console/console_users_controller.d.ts +4 -0
  14. package/build/src/host/admin_console/console_users_controller.js +12 -6
  15. package/build/src/host/controllers/interaction_controller.d.ts +8 -0
  16. package/build/src/host/controllers/interaction_controller.js +59 -12
  17. package/build/src/host/controllers/pat_introspection_controller.d.ts +1 -1
  18. package/build/src/host/controllers/pat_introspection_controller.js +2 -1
  19. package/build/src/host/controllers/registration_controller.d.ts +10 -0
  20. package/build/src/host/controllers/registration_controller.js +97 -30
  21. package/build/src/host/controllers/social_controller.js +64 -1
  22. package/build/src/host/i18n.d.ts +2 -0
  23. package/build/src/host/i18n.js +3 -0
  24. package/build/src/host/last_login_method.d.ts +67 -0
  25. package/build/src/host/last_login_method.js +119 -0
  26. package/build/src/host/register_auth_host.js +4 -0
  27. package/build/src/host/signup_token.d.ts +9 -0
  28. package/build/src/host/signup_token.js +31 -0
  29. package/build/src/host/social_pending.d.ts +17 -0
  30. package/build/src/host/social_pending.js +11 -0
  31. package/build/src/host/ui-dist/assets/{index-C1eSfG8B.js → index-DhQzXw2i.js} +1 -1
  32. package/build/src/host/ui-dist/index.html +1 -1
  33. package/build/src/provider/interaction_actions.js +7 -0
  34. package/package.json +2 -2
@@ -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.globalRoles.length===0?(0,x.jsx)(`span`,{className:`badge badge-muted`,children:`no 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)([]);(0,b.useEffect)(()=>{i&&u(i.globalRoles)},[i]);let d=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};async function f(){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.jsx)(_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&&(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:()=>d(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:f,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===`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,{})})})})})})}));
@@ -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-C1eSfG8B.js"></script>
11
+ <script type="module" crossorigin src="/__AUTHKIT_BASE__/assets/index-DhQzXw2i.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.82.3",
3
+ "version": "0.84.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.25.1",
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",