@nest-my-admin/ui 0.5.0 → 0.6.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./rich-text-input-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./rich-text-input-D_ViXscs.js","./rich-text-input-CmZdYwUT.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function te(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function P(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ne=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function re(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ne)}catch(e){ne(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ie(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else re(ie.bind(null,e))}var ae={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ae,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ie,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:P}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=re,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),m=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),ae=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),F=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ne:return`Suspense`;case re:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case te:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case P:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case ae:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var L=ye(null),Se=ye(null),Ce=ye(null),we=ye(null);function Te(e,t){switch(xe(Ce,t),xe(Se,e),xe(L,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?_p(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=_p(t),e=vp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(L),xe(L,e)}function Ee(){be(L),be(Se),be(Ce)}function De(e){var t=e.memoizedState;t!==null&&(mh._currentValue=t.memoizedState,xe(we,e)),t=L.current;var n=vp(t,e.type);t!==n&&(xe(Se,e),xe(L,n))}function Oe(e){Se.current===e&&(be(L),be(Se)),we.current===e&&(be(we),mh._currentValue=ge)}var ke,Ae;function je(e){if(ke===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||``,Ae=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ke+e+Ae}var Me=!1;function Ne(e,t){if(!e||Me)return``;Me=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -50,8 +50,8 @@ Error generating stack: `+e.message+`
|
|
|
50
50
|
`},ld=0,ud=[];function dd(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),i=y.useState(ld++)[0],a=y.useState(Nu)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=lu([e.lockRef.current],(e.shards||[]).map(od),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=y.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=id(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Zu(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Zu(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return rd(h,t,e,h===`h`?s:c,!0)},[]),c=y.useCallback(function(e){var n=e;if(ud.length&&ud[ud.length-1]===a){var r=`deltaY`in n?ad(n):id(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&sd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(od).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=y.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:fd(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=y.useCallback(function(e){n.current=id(e),r.current=void 0},[]),d=y.useCallback(function(t){l(t.type,ad(t),t.target,s(t,e.lockRef.current))},[]),f=y.useCallback(function(t){l(t.type,id(t),t.target,s(t,e.lockRef.current))},[]);y.useEffect(function(){return ud.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ku),document.addEventListener(`touchmove`,c,Ku),document.addEventListener(`touchstart`,u,Ku),function(){ud=ud.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ku),document.removeEventListener(`touchmove`,c,Ku),document.removeEventListener(`touchstart`,u,Ku)}},[]);var p=e.removeScrollBar,m=e.inert;return y.createElement(y.Fragment,null,m?y.createElement(a,{styles:cd(i)}):null,p?y.createElement(Uu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fd(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var pd=Cu(wu,dd),md=y.forwardRef(function(e,t){return y.createElement(Eu,su({},e,{ref:t,sideCar:pd}))});md.classNames=Eu.classNames;var hd=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},gd=new WeakMap,_d=new WeakMap,vd={},yd=0,bd=function(e){return e&&(e.host||bd(e.parentNode))},xd=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=bd(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Sd=function(e,t,n,r){var i=xd(t,Array.isArray(e)?e:[e]);vd[n]||(vd[n]=new WeakMap);var a=vd[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(gd.get(e)||0)+1,l=(a.get(e)||0)+1;gd.set(e,c),a.set(e,l),o.push(e),c===1&&i&&_d.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),yd++,function(){o.forEach(function(e){var t=gd.get(e)-1,i=a.get(e)-1;gd.set(e,t),a.set(e,i),t||(_d.has(e)||e.removeAttribute(r),_d.delete(e)),i||e.removeAttribute(n)}),yd--,yd||(gd=new WeakMap,gd=new WeakMap,_d=new WeakMap,vd={})}},Cd=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||hd(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Sd(r,i,n,`aria-hidden`)):function(){return null}},wd=Object.defineProperty,Td=(e,t)=>wd(e,`name`,{value:t,configurable:!0}),Ed=`Dialog`,[Dd,Od]=Pc(Ed),[kd,Ad]=Dd(Ed),jd=Td(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=y.useRef(null),c=y.useRef(null),[l,u]=$c({prop:r,defaultProp:i??!1,onChange:a,caller:Ed}),[d,f]=y.useState(0),[p,m]=y.useState(0);return(0,b.jsx)(kd,{scope:t,triggerRef:s,contentRef:c,contentId:_l(),titleId:_l(),descriptionId:_l(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:y.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Md=`DialogTrigger`,Nd=y.forwardRef(Td(function(e,t){let{__scopeDialog:n,...r}=e,i=Ad(Md,n),a=lc(t,i.triggerRef);return(0,b.jsx)(kc.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Zd(i.open),...r,ref:a,onClick:zc(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Pd=`DialogPortal`,[Fd,Id]=Dd(Pd,{forceMount:void 0}),Ld=Td(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ad(Pd,t);return(0,b.jsx)(Fd,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,b.jsx)(sl,{present:n||a.open,children:(0,b.jsx)($l,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Rd=`DialogOverlay`,zd=y.forwardRef(Td(function(e,t){let n=Id(Rd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ad(Rd,e.__scopeDialog);return a.modal?(0,b.jsx)(sl,{present:r||a.open,children:(0,b.jsx)(Vd,{...i,ref:t})}):null},`DialogOverlay`)),Bd=fc(`DialogOverlay.RemoveScroll`),Vd=y.forwardRef(Td(function(e,t){let{__scopeDialog:n,...r}=e,i=Ad(Rd,n),a=lc(t,kl());return(0,b.jsx)(md,{as:Bd,allowPinchZoom:!0,shards:[i.contentRef],children:(0,b.jsx)(kc.div,{"data-state":Zd(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Hd=`DialogContent`,Ud=y.forwardRef(Td(function(e,t){let n=Id(Hd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ad(Hd,e.__scopeDialog);return(0,b.jsx)(sl,{present:r||a.open,children:a.modal?(0,b.jsx)(Wd,{...i,ref:t}):(0,b.jsx)(Gd,{...i,ref:t})})},`DialogContent`)),Wd=y.forwardRef(Td(function(e,t){let n=Ad(Hd,e.__scopeDialog),r=y.useRef(null),i=lc(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return Cd(e)},[]),(0,b.jsx)(Kd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:zc(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:zc(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:zc(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Gd=y.forwardRef(Td(function(e,t){let n=Ad(Hd,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,b.jsx)(Kd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Kd=y.forwardRef(Td(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Ad(Hd,n);return au(),(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(Bl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,b.jsx)(Ol,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Zd(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),qd=`DialogTitle`,Jd=y.forwardRef(Td(function(e,t){let{__scopeDialog:n,...r}=e,i=Ad(qd,n),{setTitleCount:a}=i;return Wc(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(kc.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Yd=`DialogClose`,Xd=y.forwardRef(Td(function(e,t){let{__scopeDialog:n,...r}=e,i=Ad(Yd,n);return(0,b.jsx)(kc.button,{type:`button`,...r,ref:t,onClick:zc(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Zd(e){return e?`open`:`closed`}Td(Zd,`getState`);var Qd=Object.defineProperty,$d=(e,t)=>Qd(e,`name`,{value:t,configurable:!0});function ef(e){let[t,n]=y.useState(void 0);return Wc(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}$d(ef,`useSize`);var tf=Object.defineProperty,nf=(e,t)=>tf(e,`name`,{value:t,configurable:!0}),rf=`Checkbox`,[af,of]=Pc(rf),[sf,cf]=af(rf);function lf(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=$c({prop:n,defaultProp:i??!1,onChange:c,caller:rf}),[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useRef(!1),[x,S]=y.useReducer(e=>e+1,0),C=!m||!!o||!!m.closest(`form`),w={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:x,onUserInteraction:S,required:l,defaultChecked:!vf(i)&&i,isFormControl:C,bubbleInput:g,setBubbleInput:_};return(0,b.jsx)(sf,{scope:t,...w,children:_f(d)?d(w):r})}nf(lf,`CheckboxProvider`);var uf=`CheckboxTrigger`,df=y.forwardRef(nf(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=cf(uf,e),g=lc(i,u),_=y.useRef(c);return y.useEffect(()=>{let e=a?.form;if(e){let t=nf(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,b.jsx)(kc.button,{type:`button`,role:`checkbox`,"aria-checked":vf(c)?`mixed`:c,"aria-required":l,"data-state":yf(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:zc(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:zc(n,e=>{p(),d(e=>vf(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),ff=y.forwardRef(nf(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,b.jsx)(lf,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(df,{...d,ref:t,__scopeCheckbox:n}),e&&(0,b.jsx)(gf,{__scopeCheckbox:n})]})})},`Checkbox`)),pf=`CheckboxIndicator`,mf=y.forwardRef(nf(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=cf(pf,n);return(0,b.jsx)(sl,{present:r||vf(a.checked)||a.checked===!0,children:(0,b.jsx)(kc.span,{"data-state":yf(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),hf=`CheckboxBubbleInput`,gf=y.forwardRef(nf(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=cf(hf,e),g=lc(r,h),_=ef(i),v=y.useRef(!1),x=y.useRef(s),S=y.useRef(o);y.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==S.current;S.current=o;let i=x.current!==s;x.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=vf(s),n.call(e,!vf(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let C=y.useRef(!vf(s)&&s);return(0,b.jsx)(kc.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??C.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:zc(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function _f(e){return typeof e==`function`}nf(_f,`isFunction`);function vf(e){return e===`indeterminate`}nf(vf,`isIndeterminate`);function yf(e){return vf(e)?`indeterminate`:e?`checked`:`unchecked`}nf(yf,`getState`);var bf=[`top`,`right`,`bottom`,`left`],xf=Math.min,Sf=Math.max,Cf=Math.round,wf=Math.floor,Tf=e=>({x:e,y:e}),Ef={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Df(e,t,n){return Sf(e,xf(t,n))}function Of(e,t){return typeof e==`function`?e(t):e}function kf(e){return e.split(`-`)[0]}function Af(e){return e.split(`-`)[1]}function jf(e){return e===`x`?`y`:`x`}function Mf(e){return e===`y`?`height`:`width`}function Nf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Pf(e){return jf(Nf(e))}function Ff(e,t,n){n===void 0&&(n=!1);let r=Af(e),i=Pf(e),a=Mf(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Wf(o)),[o,Wf(o)]}function If(e){let t=Wf(e);return[Lf(e),t,Lf(t)]}function Lf(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Rf=[`left`,`right`],zf=[`right`,`left`],Bf=[`top`,`bottom`],Vf=[`bottom`,`top`];function Hf(e,t,n){switch(e){case`top`:case`bottom`:return n?t?zf:Rf:t?Rf:zf;case`left`:case`right`:return t?Bf:Vf;default:return[]}}function Uf(e,t,n,r){let i=Af(e),a=Hf(kf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Lf)))),a}function Wf(e){let t=kf(e);return Ef[t]+e.slice(t.length)}function Gf(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Kf(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Gf(e)}function qf(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function K(e,t,n){let{reference:r,floating:i}=e,a=Nf(t),o=Pf(t),s=Mf(o),c=kf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Af(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Jf(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Of(t,e),p=Kf(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=qf(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=qf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Yf=50,Xf=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Jf},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=K(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Yf&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=K(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Zf=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Of(e,t)||{};if(l==null)return{};let d=Kf(u),f={x:n,y:r},p=Pf(i),m=Mf(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=xf(d[_],T),D=xf(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Df(E,k,O),j=!c.arrow&&Af(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Qf=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Of(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=kf(r),_=Nf(o),v=kf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Wf(o)]:If(o)),x=p!==`none`;!d&&x&&b.push(...Uf(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Ff(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Nf(t)||T.every(e=>Nf(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Nf(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function $f(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ep(e){return bf.some(t=>e[t]>=0)}var tp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Of(e,t);switch(i){case`referenceHidden`:{let e=$f(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ep(e)}}}case`escaped`:{let e=$f(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ep(e)}}}default:return{}}}}},np=new Set([`left`,`top`]);async function rp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=kf(n),s=Af(n),c=Nf(n)===`y`,l=np.has(o)?-1:1,u=a&&c?-1:1,d=Of(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ip=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await rp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ap=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Of(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Nf(i),p=jf(f),m=u[p],h=u[f],g=(e,t)=>Df(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},op=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Of(e,t),u={x:n,y:r},d=Nf(i),f=jf(d),p=u[f],m=u[d],h=Of(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=np.has(kf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},sp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Of(e,t),c=await i.detectOverflow(t,s),l=kf(n),u=Af(n),d=Nf(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=xf(p-c[m],g),y=xf(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Sf(c.left,c.right):S=p-2*Sf(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function cp(){return typeof window<`u`}function lp(e){return fp(e)?(e.nodeName||``).toLowerCase():`#document`}function up(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function dp(e){return((fp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function fp(e){return cp()?e instanceof Node||e instanceof up(e).Node:!1}function pp(e){return cp()?e instanceof Element||e instanceof up(e).Element:!1}function mp(e){return cp()?e instanceof HTMLElement||e instanceof up(e).HTMLElement:!1}function hp(e){return!cp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof up(e).ShadowRoot}function gp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Dp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function _p(e){return/^(table|td|th)$/.test(lp(e))}function vp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var yp=/transform|translate|scale|rotate|perspective|filter/,bp=/paint|layout|strict|content/,xp=e=>!!e&&e!==`none`,Sp;function Cp(e){let t=pp(e)?Dp(e):e;return xp(t.transform)||xp(t.translate)||xp(t.scale)||xp(t.rotate)||xp(t.perspective)||!Tp()&&(xp(t.backdropFilter)||xp(t.filter))||yp.test(t.willChange||``)||bp.test(t.contain||``)}function wp(e){let t=kp(e);for(;mp(t)&&!Ep(t);){if(Cp(t))return t;if(vp(t))return null;t=kp(t)}return null}function Tp(){return Sp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Sp}function Ep(e){return/^(html|body|#document)$/.test(lp(e))}function Dp(e){return up(e).getComputedStyle(e)}function Op(e){return pp(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kp(e){if(lp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||hp(e)&&e.host||dp(e);return hp(t)?t.host:t}function Ap(e){let t=kp(e);return Ep(t)?(e.ownerDocument||e).body:mp(t)&&gp(t)?t:Ap(t)}function jp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ap(e),i=r===e.ownerDocument?.body,a=up(r);if(i){let e=Mp(a);return t.concat(a,a.visualViewport||[],gp(r)?r:[],e&&n?jp(e):[])}return t.concat(r,jp(r,[],n))}function Mp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Np(e){let t=Dp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=mp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Cf(n)!==a||Cf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Pp(e){return pp(e)?e:e.contextElement}function Fp(e){let t=Pp(e);if(!mp(t))return Tf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Np(t),o=(a?Cf(n.width):n.width)/r,s=(a?Cf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ip=Tf(0);function Lp(e){let t=up(e);return!Tp()||!t.visualViewport?Ip:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rp(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===up(e)}function zp(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Pp(e),o=Tf(1);t&&(r?pp(r)&&(o=Fp(r)):o=Fp(e));let s=Rp(a,n,r)?Lp(a):Tf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=up(a),t=pp(r)?up(r):r,n=e,i=Mp(n);for(;i&&t!==n;){let e=Fp(i),t=i.getBoundingClientRect(),r=Dp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=up(i),i=Mp(n)}}return qf({width:u,height:d,x:c,y:l})}function Bp(e,t){let n=Op(e).scrollLeft;return t?t.left+n:zp(dp(e)).left+n}function Vp(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Bp(e,n),y:n.top+t.scrollTop}}function Hp(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=dp(r),s=t?vp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Tf(1),u=Tf(0),d=mp(r);if((d||!a)&&((lp(r)!==`body`||gp(o))&&(c=Op(r)),d)){let e=zp(r);l=Fp(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Vp(o,c):Tf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Up(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Wp(e){let t=Op(e),n=e.ownerDocument.body,r=Sf(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Sf(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Bp(e),o=-t.scrollTop;return Dp(n).direction===`rtl`&&(a+=Sf(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Gp=25;function Kp(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=up(e),a=dp(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Tp()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Bp(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Gp&&(s-=o)}return{width:s,height:c,x:l,y:u}}function qp(e,t){let n=zp(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Fp(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Jp(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Kp(e,n,t);else if(t===`document`)r=Wp(dp(e));else if(pp(t))r=qp(t,n);else{let n=Lp(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return qf(r)}function Yp(e,t){let n=t.get(e);if(n)return n;let r=jp(e,[],!1).filter(e=>pp(e)&&lp(e)!==`body`),i=null,a=Dp(e).position===`fixed`,o=a?kp(e):e;for(;pp(o)&&!Ep(o);){let e=Dp(o),t=Cp(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=kp(o)}return t.set(e,r),r}function Xp(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?vp(t)?[]:Yp(t,this._c):[].concat(n),r],o=Jp(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Jp(t,a[e],i);s=Sf(n.top,s),c=xf(n.right,c),l=xf(n.bottom,l),u=Sf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Zp(e){let{width:t,height:n}=Np(e);return{width:t,height:n}}function Qp(e,t,n){let r=mp(t),i=dp(t),a=n===`fixed`,o=zp(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Tf(0);if((r||!a)&&((lp(t)!==`body`||gp(i))&&(s=Op(t)),r)){let e=zp(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Bp(i));let l=i&&!r&&!a?Vp(i,s):Tf(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function $p(e){return Dp(e).position===`static`}function em(e,t){if(!mp(e)||Dp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return dp(e)===n&&(n=n.ownerDocument.body),n}function tm(e,t){let n=up(e);if(vp(e))return n;if(!mp(e)){let t=kp(e);for(;t&&!Ep(t);){if(pp(t)&&!$p(t))return t;t=kp(t)}return n}let r=em(e,t);for(;r&&_p(r)&&$p(r);)r=em(r,t);return r&&Ep(r)&&$p(r)&&!Cp(r)?n:r||wp(e)||n}var nm=async function(e){let t=this.getOffsetParent||tm,n=this.getDimensions,r=await n(e.floating);return{reference:Qp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function rm(e){return Dp(e).direction===`rtl`}var im={convertOffsetParentRelativeRectToViewportRelativeRect:Hp,getDocumentElement:dp,getClippingRect:Xp,getOffsetParent:tm,getElementRects:nm,getClientRects:Up,getDimensions:Zp,getScale:Fp,isElement:pp,isRTL:rm};function am(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function om(e,t,n){let r=null,i,a=dp(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=wf(d),h=wf(a.clientWidth-(u+f)),g=wf(a.clientHeight-(d+p)),_=wf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Sf(0,xf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!am(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=up(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function sm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Pp(e),u=i||a?[...l?jp(l):[],...t?jp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?om(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?zp(e):null;c&&g();function g(){let t=zp(e);h&&!am(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var cm=ip,lm=ap,um=Qf,dm=sp,fm=tp,pm=Zf,mm=op,hm=(e,t,n)=>{let r=new Map,i=n??{},a={...im,...i.platform,_c:r};return Xf(e,t,{...i,platform:a})},gm=typeof document<`u`?y.useLayoutEffect:function(){};function _m(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!_m(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!_m(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function vm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ym(e,t){let n=vm(e);return Math.round(t*n)/n}function bm(e){let t=y.useRef(e);return gm(()=>{t.current=e}),t}function xm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);_m(f,r)||p(r);let[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=y.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=y.useRef(null),w=y.useRef(null),T=y.useRef(u),E=c!=null,D=bm(c),O=bm(i),k=bm(l),A=y.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),hm(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!_m(T.current,t)&&(T.current=t,Ec.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);gm(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=y.useRef(!1);gm(()=>(j.current=!0,()=>{j.current=!1}),[]),gm(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=y.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:b}),[v,b]),N=y.useMemo(()=>({reference:x,floating:S}),[x,S]),ee=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=ym(N.floating,u.x),r=ym(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...vm(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:ee}),[u,A,M,N,ee])}var Sm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:pm({element:r.current,padding:i}).fn(n):r?pm({element:r,padding:i}).fn(n):{}}}},Cm=(e,t)=>{let n=cm(e);return{name:n.name,fn:n.fn,options:[e,t]}},wm=(e,t)=>{let n=lm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tm=(e,t)=>({fn:mm(e).fn,options:[e,t]}),Em=(e,t)=>{let n=um(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dm=(e,t)=>{let n=dm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Om=(e,t)=>{let n=fm(e);return{name:n.name,fn:n.fn,options:[e,t]}},km=(e,t)=>{let n=Sm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Am=Object.defineProperty,jm=(e,t)=>Am(e,`name`,{value:t,configurable:!0}),Mm=`Popper`,[Nm,Pm]=Pc(Mm),[Fm,Im]=Nm(Mm),Lm=jm(e=>{let{__scopePopper:t,children:n}=e,[r,i]=y.useState(null),[a,o]=y.useState(void 0);return(0,b.jsx)(Fm,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Rm=`PopperAnchor`,zm=y.forwardRef(jm(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Im(Rm,n),o=y.useRef(null),s=a.onAnchorChange,c=lc(t,y.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=y.useRef(null);y.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Km(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,b.jsx)(kc.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Bm=`PopperContent`,[Vm,Hm]=Nm(Bm),Um=y.forwardRef(jm(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=Im(Bm,n),[_,v]=y.useState(null),x=lc(t,v),[S,C]=y.useState(null),w=ef(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(Wm),altBoundary:A},{refs:M,floatingStyles:N,placement:ee,isPositioned:te,middlewareData:P}=xm({strategy:`fixed`,placement:D,whileElementsMounted:jm((...e)=>sm(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Cm({mainAxis:i+E,alignmentAxis:o}),c&&wm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Tm():void 0,...j}),c&&Em({...j}),Dm({...j,apply:jm(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&km({element:S,padding:s}),Gm({arrowWidth:T,arrowHeight:E}),f&&Om({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ne=g.setPlacementState;Wc(()=>(ne(ee),()=>{ne(void 0)}),[ee,ne]);let[re,ie]=Km(ee),ae=bl(m);Wc(()=>{te&&ae?.()},[te,ae]);let oe=P.arrow?.x,se=P.arrow?.y,ce=P.arrow?.centerOffset!==0,[le,F]=y.useState();return Wc(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]),(0,b.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...N,transform:te?N.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:le,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,b.jsx)(Vm,{scope:n,placedSide:re,placedAlign:ie,onArrowChange:C,arrowX:oe,arrowY:se,shouldHideArrow:ce,children:(0,b.jsx)(kc.div,{"data-side":re,"data-align":ie,...h,ref:x,style:{...h.style,animation:te?h.style?.animation:`none`}})})})},`PopperContent`));function Wm(e){return e!==null}jm(Wm,`isNotNull`);var Gm=jm(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Km(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Km(e){let[t,n=`center`]=e.split(`-`);return[t,n]}jm(Km,`getSideAndAlignFromPlacement`);var qm=Lm,Jm=zm,Ym=Um,Xm=Object.defineProperty,Zm=y.forwardRef(((e,t)=>Xm(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,b.jsx)(kc.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),Qm=Object.defineProperty,$m=(e,t)=>Qm(e,`name`,{value:t,configurable:!0}),eh=`Popover`,[th,nh]=Pc(eh,[Pm]),rh=Pm(),[ih,ah]=th(eh),oh=$m(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=rh(t),c=y.useRef(null),[l,u]=y.useState(!1),[d,f]=$c({prop:r,defaultProp:i??!1,onChange:a,caller:eh});return(0,b.jsx)(qm,{...s,children:(0,b.jsx)(ih,{scope:t,contentId:_l(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:y.useCallback(()=>u(!0),[]),onCustomAnchorRemove:y.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),sh=`PopoverTrigger`,ch=y.forwardRef($m(function(e,t){let{__scopePopover:n,...r}=e,i=ah(sh,n),a=rh(n),o=lc(t,i.triggerRef),s=(0,b.jsx)(kc.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":xh(i.open),...r,ref:o,onClick:zc(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,b.jsx)(Jm,{asChild:!0,...a,children:s})},`PopoverTrigger`)),lh=`PopoverPortal`,[uh,dh]=th(lh,{forceMount:void 0}),fh=$m(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ah(lh,t);return(0,b.jsx)(uh,{scope:t,forceMount:n,children:(0,b.jsx)(sl,{present:n||a.open,children:(0,b.jsx)($l,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),ph=`PopoverContent`,mh=y.forwardRef($m(function(e,t){let n=dh(ph,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=ah(ph,e.__scopePopover);return(0,b.jsx)(sl,{present:r||a.open,children:a.modal?(0,b.jsx)(gh,{...i,ref:t}):(0,b.jsx)(_h,{...i,ref:t})})},`PopoverContent`)),hh=fc(`PopoverContent.RemoveScroll`),gh=y.forwardRef($m(function(e,t){let n=ah(ph,e.__scopePopover),r=y.useRef(null),i=lc(t,r),a=y.useRef(!1);return y.useEffect(()=>{let e=r.current;if(e)return Cd(e)},[]),(0,b.jsx)(md,{as:hh,allowPinchZoom:!0,children:(0,b.jsx)(vh,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zc(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:zc(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:zc(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),_h=y.forwardRef($m(function(e,t){let n=ah(ph,e.__scopePopover),r=y.useRef(!1),i=y.useRef(!1);return(0,b.jsx)(vh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),vh=y.forwardRef($m(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=ah(ph,n),p=rh(n);return au(),(0,b.jsx)(Bl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,b.jsx)(Ol,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,b.jsx)(Ym,{"data-state":xh(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`)),yh=`PopoverClose`,bh=y.forwardRef($m(function(e,t){let{__scopePopover:n,...r}=e,i=ah(yh,n);return(0,b.jsx)(kc.button,{type:`button`,...r,ref:t,onClick:zc(e.onClick,()=>i.onOpenChange(!1))})},`PopoverClose`));function xh(e){return e?`open`:`closed`}$m(xh,`getState`);var Sh=oh,Ch=ch,wh=fh,Th=mh,Eh=bh,Dh=ic(`group/button inline-flex shrink-0 items-center justify-center rounded-control border border-transparent bg-clip-padding text-[13px] font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer`,{variants:{variant:{default:`border-primary bg-primary text-primary-foreground hover:opacity-92`,outline:`border-input bg-card hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`border-input bg-card text-bad hover:bg-muted focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 gap-1.5 px-3.5 has-data-[icon=inline-end]:pe-3 has-data-[icon=inline-start]:ps-3`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 px-2.5 text-[12.5px] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2`,icon:`size-9`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8 in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function q({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?pc:`button`;return(0,b.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:W(Dh({variant:t,size:n,className:e})),...i})}function Oh({className:e,type:t,...n}){return(0,b.jsx)(`input`,{type:t,"data-slot":`input`,className:W(`h-9 w-full min-w-0 rounded-control border border-input bg-card px-3 py-1 text-[13px] transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function kh({className:e,...t}){return(0,b.jsx)(Zm,{"data-slot":`label`,className:W(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Ah=`۰۱۲۳۴۵۶۷۸۹`,jh=`٠١٢٣٤٥٦٧٨٩`;function Mh(e){return e.replace(/[۰-۹٠-٩]/g,e=>String(Math.max(Ah.indexOf(e),jh.indexOf(e))))}function Nh(e){return Mh(e).replace(/٫/g,`.`).replace(/٬/g,`,`)}function Ph(e){return e.replace(/[0-9]/g,e=>Ah[Number(e)])}function Fh(e){return Ph(e).replace(/\./g,`٫`).replace(/,/g,`٬`)}var Ih=`nma.calendar`,Lh=`nma.digits`;function Rh(e){try{return localStorage.getItem(e)}catch{return null}}function zh(e){let t=Rh(Ih),n=Rh(Lh);return{calendar:t===`gregorian`||t===`persian`?t:e.split(`-`)[0]===`fa`?`persian`:`gregorian`,digits:n===`latn`||n===`arabext`?n:e.split(`-`)[0]===`fa`?`arabext`:`latn`}}function Bh(e){try{e.calendar&&localStorage.setItem(Ih,e.calendar),e.digits&&localStorage.setItem(Lh,e.digits)}catch{}}var Vh={"common.loading":`Loading…`,"common.yes":`Yes`,"common.no":`No`,"common.empty":`—`,"common.all":`All`,"common.cancel":`Cancel`,"common.pageNotFound":`Page not found.`,"common.requestFailed":`Request failed ({status})`,"common.reference":`{message} (reference: {id})`,"shell.adminPanel":`Admin panel`,"palette.move":`Move`,"palette.openItem":`Open`,"palette.close":`Close`,"shell.menu":`Menu`,"shell.closeMenu":`Close menu`,"shell.resources":`Resources`,"shell.filterResources":`Filter resources`,"shell.pinned":`Pinned`,"shell.recent":`Recent`,"shell.pin":`Pin {name}`,"shell.unpin":`Unpin {name}`,"shell.collapseGroup":`Collapse {name}`,"shell.expandGroup":`Expand {name}`,"shell.collapseSidebar":`Collapse sidebar`,"shell.expandSidebar":`Expand sidebar`,"shell.breadcrumbs":`Breadcrumbs`,"shell.home":`Home`,"shell.dashboard":`Dashboard`,"shell.noMatches":`No resources match.`,"shell.theme":`Theme`,"shell.themeLight":`Light`,"shell.themeDark":`Dark`,"shell.themeSystem":`System`,"shell.language":`Language`,"shell.noResources":`No admin resources are registered yet. Decorate a provider with @AdminResource.`,"shell.records":`{count} records`,"shell.aboutRecords":`about {count} records`,"list.select":`Select`,"list.done":`Done`,"list.loadMore":`Load more`,"list.showing":`{shown} shown`,"list.showingOf":`{shown} of {total}`,"list.new":`New`,"list.trash":`Trash`,"list.trashNote":`Records in the trash. Restore one to edit it again.`,"list.restore":`Restore`,"list.restoreRecord":`Restore {name}`,"list.actions":`Actions`,"list.noMatches":`No records match.`,"list.noRecords":`No records yet.`,"list.total":`{count} total`,"list.about":`about {count}`,"list.page":`Page {page}`,"list.pageOf":`Page {page} of {pages}`,"list.range":`Showing {from} to {to} of {total}`,"list.rowsPerPage":`Rows per page`,"list.toggleRow":`{column}: {name}`,"list.previousPage":`Previous page`,"list.nextPage":`Next page`,"list.columns":`Columns`,"list.density":`Density`,"list.comfortable":`Comfortable`,"list.compact":`Compact`,"list.moveUp":`Move {name} up`,"list.moveDown":`Move {name} down`,"list.resetColumns":`Reset columns`,"list.resize":`Resize {name}`,"list.retry":`Try again`,"list.loadFailed":`The list could not be loaded.`,"list.selectPage":`Select all on this page`,"list.selectRow":`Select {name}`,"print.open":`Print {name}`,"list.export":`Export to Excel`,"list.exporting":`Exporting…`,"list.exportTruncated":`Only the first {count} rows were exported.`,"list.exportDone":`{file} downloaded.`,"list.selected":`{count} selected`,"list.deleteSelected":`Delete selected`,"list.confirmDeleteSelected":`Delete {count}`,"list.clearSelection":`Clear selection`,"list.bulkDeleted":`{count} deleted`,"list.bulkFailed":`{count} failed`,"list.quickView":`Quick view: {name}`,"list.edit":`Edit`,"list.close":`Close`,"list.editCell":`Edit {name}: {value}`,"action.running":`Running…`,"action.confirm":`Run “{action}”?`,"action.confirmRecord":`Run “{action}” on {name}?`,"action.confirmSelected":`Run “{action}” on {count} records?`,"action.eachNote":`Each of the {count} records is handled on its own: one that fails does not stop the others.`,"action.atomicNote":`All or nothing: if one of the {count} records fails, none is changed.`,"action.done":`“{action}” done.`,"action.doneGone":`“{action}” done. The record is no longer in your view.`,"action.bulkDone":`{action}: {count} done`,"action.saveFirst":`Save or discard your changes first.`,"action.more":`More actions`,"toast.region":`Notifications`,"toast.dismiss":`Dismiss`,"settings.viewOnly":`You can view these settings but not change them.`,"settings.discard":`Discard changes`,"secret.set":`Set`,"secret.notSet":`Not set`,"secret.replace":`Replace`,"secret.replaceName":`Replace {name}`,"secret.clear":`Clear`,"secret.clearName":`Clear {name}`,"secret.keep":`Keep the current value`,"secret.willClear":`Will be cleared when you save.`,"secret.undo":`Undo`,"filters.search":`Search`,"filters.searchIn":`Search {fields}`,"filters.filtersAndSort":`Filters and sort`,"filters.showResults":`Show results`,"filters.sortBy":`Sort by`,"filters.ascending":`{name}, ascending`,"filters.descending":`{name}, descending`,"filters.filters":`Filters`,"filters.clear":`Clear filters`,"filters.from":`From`,"filters.to":`To`,"filters.contains":`{field} contains`,"filters.empty":`empty`,"filters.notEmpty":`not empty`,"filters.not":`not `,"filters.removeChip":`Remove filter {label}`,"filters.active":`Active filters`,"filters.any":`Any`,"filters.onlyEmpty":`Empty`,"filters.hideEmpty":`Not empty`,"filters.emptyValues":`{field}: empty values`,"filters.selected":`{count} selected`,"date.placeholder":`yyyy/mm/dd`,"date.openCalendar":`Choose {name} from a calendar`,"date.calendar":`{name} calendar`,"date.previous":`Previous`,"date.next":`Next`,"date.chooseMonth":`Choose a month`,"date.chooseYear":`Choose a year`,"date.today":`Today`,"date.clear":`Clear`,"date.time":`{name} time`,"auth.title":`Sign in`,"auth.username":`Username`,"auth.password":`Password`,"auth.signIn":`Sign in`,"auth.signingIn":`Signing in…`,"auth.required":`Enter your username and password.`,"auth.failed":`Signing in failed. Try again.`,"auth.userMenu":`Account menu for {name}`,"auth.account":`Account`,"auth.signOut":`Sign out`,"auth.changePassword":`Change password`,"auth.currentPassword":`Current password`,"auth.newPassword":`New password`,"auth.confirmPassword":`New password again`,"auth.mismatch":`does not match the new password`,"auth.passwordChanged":`Password changed. Your other sessions were signed out.`,"auth.sessions":`Signed-in devices`,"auth.signOutOthers":`Sign out everywhere else`,"auth.thisDevice":`This device`,"auth.unknownDevice":`Unknown device`,"auth.lastSeen":`Last active {when}`,"auth.revoke":`Sign out`,"auth.revokeSession":`Sign out {name}`,"rbac.administration":`Administration`,"rbac.users":`Users`,"rbac.groups":`Groups`,"rbac.roles":`Roles`,"rbac.user":`User`,"rbac.group":`Group`,"rbac.role":`Role`,"rbac.newUser":`New user`,"rbac.newGroup":`New group`,"rbac.newRole":`New role`,"rbac.createUser":`Create user`,"rbac.export":`Export`,"rbac.import":`Import`,"rbac.importFile":`Roles file to import`,"rbac.imported":`{count} roles imported.`,"rbac.notJson":`That file is not JSON.`,"rbac.permissionCount":`{count} permissions`,"rbac.system":`System`,"rbac.systemNote":`This role is defined in code: change it there.`,"rbac.name":`Name`,"rbac.labelIn":`Label ({language})`,"rbac.matrix":`Permissions`,"rbac.resource":`Resource`,"rbac.op.view":`View`,"rbac.op.create":`Create`,"rbac.op.update":`Change`,"rbac.op.delete":`Delete`,"rbac.op.purge":`Purge`,"rbac.grant":`{operation} {resource}`,"rbac.details":`Fields and scopes of {resource}`,"rbac.fields":`Fields`,"rbac.restricted":`restricted`,"rbac.fieldRule":`Access to {field}`,"rbac.rule.default":`As the permissions allow`,"rbac.rule.defaultHidden":`Hidden (restricted)`,"rbac.rule.hidden":`Hidden`,"rbac.rule.readonly":`Read-only`,"rbac.rule.edit":`Editable`,"rbac.scopes":`Rows`,"rbac.allRows":`all rows`,"rbac.custom":`Other permissions`,"rbac.global":`General permissions`,"rbac.actions":`Actions`,"rbac.actionNote":`Actions on records also need Change.`,"rbac.pages":`Settings pages`,"rbac.page":`Page`,"rbac.viewImplied":`Whoever may change a page may view it.`,"rbac.noGroups":`No groups yet.`,"rbac.groupSummary":`{roles} roles · {members} members`,"rbac.members":`Members`,"rbac.noMembers":`No members yet.`,"rbac.addMember":`Add a member`,"rbac.searchUsers":`Search users`,"rbac.searchResults":`Matching users`,"rbac.usersFromMemberships":`Your sign-in adapter cannot list users: these are the users that have roles or groups here.`,"rbac.superuser":`Superuser`,"rbac.superuserNote":`Only superusers can change a superuser.`,"rbac.inactive":`Inactive`,"rbac.active":`Active`,"rbac.displayName":`Display name`,"rbac.email":`Email`,"rbac.saved":`Saved.`,"rbac.setPassword":`Set password`,"rbac.setPasswordNote":`The user is signed out everywhere.`,"rbac.passwordSet":`Password set; the user was signed out everywhere.`,"auth.otpTitle":`Two-step verification`,"auth.otp":`Code`,"auth.otpHelp":`Enter the 6-digit code from your authenticator app, or one of your recovery codes.`,"auth.verify":`Verify`,"auth.otpRequired":`Enter the code.`,"auth.startOver":`Use another account`,"twoFactor.title":`Two-factor sign-in`,"twoFactor.on":`On`,"twoFactor.off":`Off`,"twoFactor.intro":`Ask for a code from an authenticator app after the password.`,"twoFactor.setUp":`Set up`,"twoFactor.scan":`Scan the code with your authenticator app, or type the key into it. Then enter the code the app shows.`,"twoFactor.qr":`QR code for your authenticator app`,"twoFactor.key":`Key`,"twoFactor.code":`Code from the app`,"twoFactor.turnOn":`Turn on`,"twoFactor.recoveryTitle":`Recovery codes`,"twoFactor.recoveryIntro":`Keep these somewhere safe. Each one signs you in once if you lose your device. They are not shown again.`,"twoFactor.copy":`Copy codes`,"twoFactor.copied":`Copied`,"twoFactor.done":`I saved them`,"twoFactor.left":`{count} unused recovery codes.`,"twoFactor.newCodes":`New recovery codes`,"twoFactor.turnOff":`Turn off`,"twoFactor.password":`Your password`,"twoFactor.enabledNote":`Two-factor sign-in is on. Your other sessions were signed out.`,"twoFactor.disabledNote":`Two-factor sign-in is off.`,"viewAs.start":`View as this user`,"viewAs.banner":`Viewing as {name}. Read-only.`,"viewAs.stop":`Stop viewing`,"rbac.twoFactor":`2FA`,"rbac.resetTwoFactor":`Reset two-factor sign-in`,"rbac.resetTwoFactorNote":`Turns off their second factor (a lost phone) and signs them out everywhere.`,"rbac.twoFactorReset":`Two-factor sign-in is off for this user.`,"debugger.title":`Permission debugger`,"debugger.intro":`Why a user can or cannot see and change things.`,"debugger.user":`User`,"debugger.resource":`Resource`,"debugger.record":`Record id (optional)`,"debugger.explain":`Explain`,"debugger.pick":`Choose a user and a resource.`,"debugger.roles":`Roles`,"debugger.noRoles":`No roles: nothing is allowed.`,"debugger.superuser":`A superuser may do everything.`,"debugger.source.direct":`assigned directly`,"debugger.source.group":`through group {group}`,"debugger.source.resolveRoles":`from resolveRoles`,"debugger.source.adapter":`from the sign-in adapter`,"debugger.unknownRole":`not a role, grants nothing`,"debugger.operations":`Operations`,"debugger.allowed":`Allowed`,"debugger.denied":`Denied`,"debugger.noGrant":`No role grants it`,"debugger.viaUpdate":`{pattern} in {role} (changing implies viewing)`,"debugger.grant":`{pattern} in {role}`,"debugger.fields":`Fields`,"debugger.field":`Field`,"debugger.result":`Result`,"debugger.byRole":`Per role`,"debugger.forced":`Always shown: keys and the version`,"debugger.scopes":`Rows`,"debugger.allRows":`All rows`,"debugger.noRows":`No rows`,"debugger.someRows":`Rows of {scopes}`,"debugger.globalScopes":`Also limited by {scopes}`,"debugger.recordTitle":`Record {id}`,"debugger.reason.permission":`no permission`,"debugger.reason.scope":`outside their rows`,"debugger.reason.rule":`a rule on this record says no`,"debugger.reason.missing":`no such record`,"debugger.actions":`Actions`,"debugger.needsUpdate":`actions on records also need Change`,"debugger.noRecordActions":`none on this record`,"debugger.pages":`Settings pages`,"audit.title":`Audit log`,"audit.history":`History`,"audit.details":`Details`,"audit.recordTabs":`Record and its history`,"audit.entries":`Recorded changes`,"audit.notAllowed":`You may not read the audit log`,"audit.off":`The audit log is not enabled in this admin`,"audit.empty":`Nothing has been recorded yet.`,"audit.noMatches":`No entries match.`,"audit.noActor":`Nobody signed in`,"audit.viewAsBy":`while user {id} was viewing as them`,"audit.filterByActor":`Show only what {name} did`,"audit.changedFields":`Changed fields`,"audit.before":`Before`,"audit.after":`After`,"audit.becomes":`became`,"audit.field.changed":`changed`,"audit.field.hidden":`hidden`,"audit.field.dropped":`too large to keep`,"audit.field.truncated":`cut short`,"audit.showMore":`Show more`,"audit.showLess":`Show less`,"audit.input":`Input`,"audit.inputTruncated":`The input was too large to keep.`,"audit.restrictedRecord":`A record you cannot see: its details are withheld.`,"audit.restrictedChanges":`You may not see what was changed.`,"audit.suppressedNote":`They came in the same minute and were not recorded one by one.`,"audit.limitedNote":`Further failures in this minute are only counted.`,"audit.actionDeleted":`The action deleted the record.`,"audit.filter.actor":`Actor (user id)`,"audit.filter.event":`Event`,"audit.filter.eventHint":`order.updated or auth.*`,"audit.filter.resource":`Resource`,"audit.filter.record":`Record id`,"audit.filter.recordHint":`Choose a resource first`,"audit.event.unseen":`A change you cannot see`,"audit.event.created":`Created`,"audit.event.updated":`Changed`,"audit.event.deleted":`Deleted`,"audit.event.trashed":`Moved to trash`,"audit.event.restored":`Restored`,"audit.event.purged":`Deleted for good`,"audit.event.action":`Ran “{action}”`,"audit.event.page":`Changed {page}`,"audit.event.login":`Signed in`,"audit.event.logout":`Signed out`,"audit.event.loginFailed":`Failed sign-in`,"audit.event.loginFailedCode":`Failed sign-in: wrong two-factor code`,"audit.event.loginFailedLimited":`Failed sign-in: too many attempts`,"audit.event.loginFailedMore":`{count} more failed sign-ins`,"audit.event.viewAs":`Viewed the admin as a user`,"audit.event.roleChanged":`Role changed`,"audit.event.groupChanged":`Group changed`,"audit.event.userRolesChanged":`Roles and groups of a user changed`,"audit.event.userCreated":`User created`,"audit.event.userChanged":`User changed`,"audit.event.passwordChanged":`Password changed`,"audit.event.passwordReset":`Password set by an administrator`,"audit.event.twoFactorEnabled":`Two-factor sign-in turned on`,"audit.event.twoFactorDisabled":`Two-factor sign-in turned off`,"audit.event.twoFactorReset":`Two-factor sign-in reset`,"audit.event.recoveryCodes":`New recovery codes`,"audit.event.sessions":`Sessions signed out`,"audit.event.sessionsOthers":`Signed out everywhere else`,"audit.event.sessionsOne":`Signed out one device`,"display.title":`Display settings`,"display.calendar":`Calendar`,"display.gregorian":`Gregorian`,"display.jalali":`Jalali`,"display.digits":`Digits`,"display.accent":`Accent colour`,"display.customAccent":`Another colour`,"display.defaultAccent":`Default`,"display.accentForEveryone":`Use for everyone`,"display.resetForEveryone":`Reset for everyone`,"display.latinDigits":`Latin 123`,"display.persianDigits":`Persian ۱۲۳`,"inline.row":`{name} row {index}`,"inline.newRow":`New {name} {index}`,"inline.moveUp":`Move {name} up`,"inline.moveDown":`Move {name} down`,"inline.remove":`Remove {name}`,"inline.rowActions":`Row actions`,"inline.empty":`None yet.`,"inline.limitsMax":`{count} · at most {max}`,"inline.limitsBetween":`{count} · {min} to {max}`,"inline.countMin":`Needs at least {min} (has {count}).`,"inline.countMax":`Can have at most {max} (has {count}).`,"inline.truncated":`{count} more are not shown here, so these cannot be edited in this form.`,"inline.openList":`Open the list`,"inline.duplicateNote":`Duplicate copies this record only, not its {names}.`,"form.new":`New {name}`,"form.back":`Back`,"form.edit":`Edit`,"dashboard.title":`Dashboard`,"dashboard.subtitle":`Your shop over the chosen period`,"dashboard.period":`Period`,"dashboard.day":`Today`,"dashboard.week":`Week`,"dashboard.month":`Month`,"dashboard.year":`Year`,"dashboard.range":`Choose dates`,"dashboard.apply":`Show`,"dashboard.failed":`This widget could not load.`,"dashboard.retry":`Try again`,"dashboard.viewAll":`View all`,"dashboard.thisPeriod":`This period`,"dashboard.previousPeriod":`Previous period`,"stepper.since":`since {time}`,"form.viewProfile":`View`,"form.viewOnly":`You can view this record but not change it.`,"form.save":`Save`,"form.saving":`Saving…`,"form.delete":`Delete`,"form.confirmDelete":`Confirm delete`,"form.moveToTrash":`Move to trash`,"form.confirmMoveToTrash":`Confirm move to trash`,"form.deleting":`Deleting…`,"form.keep":`Keep`,"form.related":`Related`,"form.add":`Add {name}`,"form.remove":`Remove {name} {index}`,"form.conflictTitle":`Someone else saved this record while you were editing it.`,"form.conflictNone":`None of the fields on this form changed.`,"form.keepMine":`Keep my changes`,"form.loadTheirs":`Load theirs`,"form.saveAndNew":`Save & new`,"form.duplicate":`Duplicate`,"form.savedName":`“{name}” saved.`,"form.leaveTitle":`Leave without saving? Your changes will be lost.`,"form.stay":`Stay`,"form.leave":`Leave`,"form.unsaved":`Unsaved changes`,"form.formatJson":`Format`,"form.tabHasErrors":`(has errors)`,"form.readOnly":`Read-only`,"form.externalLink":`{name} (opens in a new tab)`,"form.colorCode":`{name} colour code`,"upload.choose":`Choose a file`,"upload.chooseMany":`Choose files`,"upload.chooseImage":`Choose an image`,"upload.chooseImages":`Choose images`,"upload.replace":`Replace`,"upload.drop":`or drop it here`,"upload.dropMany":`or drop them here`,"upload.limit":`Up to {max}`,"upload.uploading":`Uploading {name}`,"upload.cancel":`Cancel uploading {name}`,"upload.remove":`Remove {name}`,"upload.open":`Open {name}`,"upload.more":`+{count}`,"upload.failed":`{name}: {message}`,"upload.busy":`Wait for the uploads to finish, then save.`,"upload.tooLarge":`The file is too large.`,"upload.tooLargeMax":`The file is too large (at most {max}).`,"upload.typeRefused":`This type of file is not accepted here.`,"upload.empty":`The file is empty.`,"upload.network":`The upload failed. Check your connection and try again.`,"upload.bytes":`{value} B`,"upload.kilobytes":`{value} KB`,"upload.megabytes":`{value} MB`,"upload.gigabytes":`{value} GB`,"upload.terabytes":`{value} TB`,"editor.loading":`Loading the editor…`,"editor.toolbar":`{name} formatting`,"editor.paragraph":`Paragraph`,"editor.heading":`Heading {level}`,"editor.bold":`Bold`,"editor.italic":`Italic`,"editor.strike":`Strikethrough`,"editor.bulletList":`Bulleted list`,"editor.orderedList":`Numbered list`,"editor.blockquote":`Quote`,"editor.rule":`Horizontal line`,"editor.link":`Link`,"editor.linkAddress":`Link address`,"editor.linkApply":`Apply`,"editor.unlink":`Remove link`,"editor.image":`Insert image`,"editor.imageNoAddress":`the server gave no address to show the image from`,"editor.table":`Insert table`,"editor.addRow":`Add row`,"editor.addColumn":`Add column`,"editor.deleteRow":`Delete row`,"editor.deleteColumn":`Delete column`,"editor.deleteTable":`Delete table`,"editor.undo":`Undo`,"editor.redo":`Redo`,"palette.open":`Search and go to`,"palette.placeholder":`Go to, create, or find records…`,"palette.results":`Results`,"palette.goTo":`Go to`,"palette.actions":`Actions`,"palette.toggleTheme":`Toggle theme`,"palette.records":`Records`,"palette.new":`New {name}`,"palette.searching":`Searching…`,"palette.noResults":`Nothing found`,"picker.typeToSearch":`Type to search…`,"picker.typeToAdd":`Type to add…`,"picker.searching":`Searching…`,"picker.noMatches":`No matches`,"picker.remove":`Remove {name}`,"picker.clear":`Clear {name}`,"picker.selected":`Selected {name}`,"validation.required":`is required`,"validation.number":`must be a number`,"validation.json":`must be valid JSON`,"validation.date":`must be a valid date`,"validation.datetime":`must be a valid date and time`,"validation.minLength":`must be at least {min} characters`,"validation.maxLength":`must be at most {max} characters`,"validation.pattern":`is not in the expected format`,"validation.email":`must be an email address`,"validation.url":`must be a URL`,"validation.uuid":`must be a UUID`,"validation.oneOf":`must be one of: {values}`,"validation.integer":`must be an integer`,"validation.min":`must be at least {min}`,"validation.max":`must be at most {max}`},Hh={en:Vh,fa:{"common.loading":`در حال بارگذاری…`,"common.yes":`بله`,"common.no":`خیر`,"common.empty":`—`,"common.all":`همه`,"common.cancel":`انصراف`,"common.pageNotFound":`صفحه پیدا نشد.`,"common.requestFailed":`درخواست ناموفق بود ({status})`,"common.reference":`{message} (کد پیگیری: {id})`,"shell.adminPanel":`پنل مدیریت`,"palette.move":`جابهجایی`,"palette.openItem":`باز کردن`,"palette.close":`بستن`,"shell.menu":`منو`,"shell.closeMenu":`بستن منو`,"shell.resources":`بخشها`,"shell.filterResources":`جستوجوی بخشها`,"shell.pinned":`سنجاقشده`,"shell.recent":`اخیر`,"shell.pin":`سنجاق کردن {name}`,"shell.unpin":`برداشتن سنجاق {name}`,"shell.collapseGroup":`بستن {name}`,"shell.expandGroup":`باز کردن {name}`,"shell.collapseSidebar":`جمع کردن نوار کناری`,"shell.expandSidebar":`باز کردن نوار کناری`,"shell.breadcrumbs":`مسیر صفحه`,"shell.home":`خانه`,"shell.dashboard":`داشبورد`,"shell.noMatches":`بخشی پیدا نشد.`,"shell.theme":`پوسته`,"shell.themeLight":`روشن`,"shell.themeDark":`تیره`,"shell.themeSystem":`سیستم`,"shell.language":`زبان`,"shell.noResources":`هنوز بخشی ثبت نشده است. یک provider را با @AdminResource علامت بزنید.`,"shell.records":`{count} رکورد`,"shell.aboutRecords":`حدود {count} رکورد`,"list.select":`انتخاب`,"list.done":`تمام`,"list.loadMore":`بیشتر`,"list.showing":`{shown} مورد`,"list.showingOf":`{shown} از {total}`,"list.new":`جدید`,"list.trash":`سطل زباله`,"list.trashNote":`رکوردهای سطل زباله. برای ویرایش دوباره، آن را بازگردانید.`,"list.restore":`بازگردانی`,"list.restoreRecord":`بازگردانی {name}`,"list.actions":`عملیات`,"list.noMatches":`رکوردی با این شرایط نیست.`,"list.noRecords":`هنوز رکوردی نیست.`,"list.total":`{count} مورد`,"list.about":`حدود {count}`,"list.page":`صفحه {page}`,"list.pageOf":`صفحه {page} از {pages}`,"list.range":`نمایش {from} تا {to} از {total}`,"list.rowsPerPage":`ردیف در صفحه`,"list.toggleRow":`{column}: {name}`,"list.previousPage":`صفحه قبل`,"list.nextPage":`صفحه بعد`,"list.columns":`ستونها`,"list.density":`تراکم`,"list.comfortable":`راحت`,"list.compact":`فشرده`,"list.moveUp":`جابهجایی {name} به بالا`,"list.moveDown":`جابهجایی {name} به پایین`,"list.resetColumns":`بازنشانی ستونها`,"list.resize":`تغییر اندازهی {name}`,"list.retry":`تلاش دوباره`,"list.loadFailed":`فهرست بارگذاری نشد.`,"list.selectPage":`انتخاب همهی این صفحه`,"list.selectRow":`انتخاب {name}`,"print.open":`چاپ {name}`,"list.export":`خروجی Excel`,"list.exporting":`در حال ساخت فایل…`,"list.exportTruncated":`فقط {count} ردیف اول در فایل آمد.`,"list.exportDone":`{file} دانلود شد.`,"list.selected":`{count} مورد انتخاب شده`,"list.deleteSelected":`حذف انتخابشدهها`,"list.confirmDeleteSelected":`حذف {count} مورد`,"list.clearSelection":`لغو انتخاب`,"list.bulkDeleted":`{count} مورد حذف شد`,"list.bulkFailed":`{count} مورد ناموفق`,"list.quickView":`نمای سریع: {name}`,"list.edit":`ویرایش`,"list.close":`بستن`,"list.editCell":`ویرایش {name}: {value}`,"action.running":`در حال اجرا…`,"action.confirm":`«{action}» اجرا شود؟`,"action.confirmRecord":`«{action}» روی {name} اجرا شود؟`,"action.confirmSelected":`«{action}» روی {count} رکورد اجرا شود؟`,"action.eachNote":`هر یک از {count} رکورد جداگانه انجام میشود: خطای یکی بقیه را متوقف نمیکند.`,"action.atomicNote":`همه یا هیچ: اگر یکی از {count} رکورد خطا بدهد، هیچکدام تغییر نمیکند.`,"action.done":`«{action}» انجام شد.`,"action.doneGone":`«{action}» انجام شد. این رکورد دیگر در دسترس شما نیست.`,"action.bulkDone":`{action}: {count} مورد انجام شد`,"action.saveFirst":`ابتدا تغییرات را ذخیره یا لغو کنید.`,"action.more":`کارهای بیشتر`,"toast.region":`اعلانها`,"toast.dismiss":`بستن`,"settings.viewOnly":`میتوانید این تنظیمات را ببینید ولی نمیتوانید تغییرشان دهید.`,"settings.discard":`لغو تغییرات`,"secret.set":`تنظیم شده`,"secret.notSet":`تنظیم نشده`,"secret.replace":`جایگزینی`,"secret.replaceName":`جایگزینی {name}`,"secret.clear":`پاک کردن`,"secret.clearName":`پاک کردن {name}`,"secret.keep":`نگه داشتن مقدار فعلی`,"secret.willClear":`هنگام ذخیره پاک میشود.`,"secret.undo":`بازگردانی`,"filters.search":`جستوجو`,"filters.searchIn":`جستوجو در {fields}`,"filters.filtersAndSort":`فیلتر و مرتبسازی`,"filters.showResults":`نمایش نتایج`,"filters.sortBy":`مرتبسازی بر اساس`,"filters.ascending":`{name}، صعودی`,"filters.descending":`{name}، نزولی`,"filters.filters":`فیلترها`,"filters.clear":`پاک کردن فیلترها`,"filters.from":`از`,"filters.to":`تا`,"filters.contains":`{field} شامل`,"filters.empty":`خالی`,"filters.notEmpty":`غیرخالی`,"filters.not":`بهجز `,"filters.removeChip":`حذف فیلتر {label}`,"filters.active":`فیلترهای فعال`,"filters.any":`همه`,"filters.onlyEmpty":`خالی`,"filters.hideEmpty":`غیرخالی`,"filters.emptyValues":`{field}: مقدارهای خالی`,"filters.selected":`{count} مورد`,"date.placeholder":`yyyy/mm/dd`,"date.openCalendar":`انتخاب {name} از تقویم`,"date.calendar":`تقویم {name}`,"date.previous":`قبلی`,"date.next":`بعدی`,"date.chooseMonth":`انتخاب ماه`,"date.chooseYear":`انتخاب سال`,"date.today":`امروز`,"date.clear":`پاک کردن`,"date.time":`ساعت {name}`,"auth.title":`ورود`,"auth.username":`نام کاربری`,"auth.password":`گذرواژه`,"auth.signIn":`ورود`,"auth.signingIn":`در حال ورود…`,"auth.required":`نام کاربری و گذرواژه را وارد کنید.`,"auth.failed":`ورود انجام نشد. دوباره تلاش کنید.`,"auth.userMenu":`منوی حساب {name}`,"auth.account":`حساب کاربری`,"auth.signOut":`خروج`,"auth.changePassword":`تغییر گذرواژه`,"auth.currentPassword":`گذرواژهی فعلی`,"auth.newPassword":`گذرواژهی جدید`,"auth.confirmPassword":`تکرار گذرواژهی جدید`,"auth.mismatch":`با گذرواژهی جدید یکسان نیست`,"auth.passwordChanged":`گذرواژه تغییر کرد. نشستهای دیگر شما بسته شدند.`,"auth.sessions":`دستگاههای واردشده`,"auth.signOutOthers":`خروج از همهی دستگاههای دیگر`,"auth.thisDevice":`همین دستگاه`,"auth.unknownDevice":`دستگاه ناشناخته`,"auth.lastSeen":`آخرین فعالیت {when}`,"auth.revoke":`خروج`,"auth.revokeSession":`خروج {name}`,"rbac.administration":`مدیریت`,"rbac.users":`کاربران`,"rbac.groups":`گروهها`,"rbac.roles":`نقشها`,"rbac.user":`کاربر`,"rbac.group":`گروه`,"rbac.role":`نقش`,"rbac.newUser":`کاربر جدید`,"rbac.newGroup":`گروه جدید`,"rbac.newRole":`نقش جدید`,"rbac.createUser":`ساختن کاربر`,"rbac.export":`خروجی`,"rbac.import":`ورود`,"rbac.importFile":`پروندهی نقشها برای ورود`,"rbac.imported":`{count} نقش وارد شد.`,"rbac.notJson":`این پرونده JSON نیست.`,"rbac.permissionCount":`{count} مجوز`,"rbac.system":`سیستمی`,"rbac.systemNote":`این نقش در کد تعریف شده است؛ آن را همانجا تغییر دهید.`,"rbac.name":`نام`,"rbac.labelIn":`عنوان ({language})`,"rbac.matrix":`مجوزها`,"rbac.resource":`بخش`,"rbac.op.view":`دیدن`,"rbac.op.create":`ساختن`,"rbac.op.update":`تغییر`,"rbac.op.delete":`حذف`,"rbac.op.purge":`حذف دائمی`,"rbac.grant":`{operation} {resource}`,"rbac.details":`فیلدها و ردیفهای {resource}`,"rbac.fields":`فیلدها`,"rbac.restricted":`محدود`,"rbac.fieldRule":`دسترسی به {field}`,"rbac.rule.default":`مطابق مجوزها`,"rbac.rule.defaultHidden":`پنهان (محدود)`,"rbac.rule.hidden":`پنهان`,"rbac.rule.readonly":`فقط خواندنی`,"rbac.rule.edit":`قابل ویرایش`,"rbac.scopes":`ردیفها`,"rbac.allRows":`همهی ردیفها`,"rbac.custom":`مجوزهای دیگر`,"rbac.global":`مجوزهای عمومی`,"rbac.actions":`عملیات`,"rbac.actionNote":`عملیات روی رکوردها به مجوز تغییر هم نیاز دارد.`,"rbac.pages":`صفحههای تنظیمات`,"rbac.page":`صفحه`,"rbac.viewImplied":`هر کس بتواند صفحهای را تغییر دهد، میتواند آن را ببیند.`,"rbac.noGroups":`هنوز گروهی نیست.`,"rbac.groupSummary":`{roles} نقش · {members} عضو`,"rbac.members":`اعضا`,"rbac.noMembers":`هنوز عضوی نیست.`,"rbac.addMember":`افزودن عضو`,"rbac.searchUsers":`جستوجوی کاربران`,"rbac.searchResults":`کاربران یافتهشده`,"rbac.usersFromMemberships":`سامانهی ورود شما نمیتواند کاربران را فهرست کند: اینها کاربرانی هستند که اینجا نقش یا گروه دارند.`,"rbac.superuser":`ابرکاربر`,"rbac.superuserNote":`فقط ابرکاربرها میتوانند ابرکاربر را تغییر دهند.`,"rbac.inactive":`غیرفعال`,"rbac.active":`فعال`,"rbac.displayName":`نام نمایشی`,"rbac.email":`ایمیل`,"rbac.saved":`ذخیره شد.`,"rbac.setPassword":`تعیین گذرواژه`,"rbac.setPasswordNote":`کاربر از همهجا خارج میشود.`,"rbac.passwordSet":`گذرواژه تعیین شد؛ کاربر از همهجا خارج شد.`,"auth.otpTitle":`تأیید دومرحلهای`,"auth.otp":`کد`,"auth.otpHelp":`کد ۶ رقمی برنامهٔ احراز هویت یا یکی از کدهای بازیابی را وارد کنید.`,"auth.verify":`تأیید`,"auth.otpRequired":`کد را وارد کنید.`,"auth.startOver":`ورود با حساب دیگر`,"twoFactor.title":`ورود دومرحلهای`,"twoFactor.on":`روشن`,"twoFactor.off":`خاموش`,"twoFactor.intro":`پس از گذرواژه، کدی از برنامهٔ احراز هویت خواسته شود.`,"twoFactor.setUp":`راهاندازی`,"twoFactor.scan":`کد را با برنامهٔ احراز هویت اسکن کنید یا کلید را در آن وارد کنید. سپس کدی را که برنامه نشان میدهد بنویسید.`,"twoFactor.qr":`کد QR برای برنامهٔ احراز هویت`,"twoFactor.key":`کلید`,"twoFactor.code":`کد برنامه`,"twoFactor.turnOn":`روشن کردن`,"twoFactor.recoveryTitle":`کدهای بازیابی`,"twoFactor.recoveryIntro":`این کدها را جای امنی نگه دارید. اگر دستگاهتان را گم کنید، هر کد یک بار شما را وارد میکند. دوباره نشان داده نمیشوند.`,"twoFactor.copy":`کپی کدها`,"twoFactor.copied":`کپی شد`,"twoFactor.done":`ذخیرهشان کردم`,"twoFactor.left":`{count} کد بازیابی استفادهنشده.`,"twoFactor.newCodes":`کدهای بازیابی تازه`,"twoFactor.turnOff":`خاموش کردن`,"twoFactor.password":`گذرواژهٔ شما`,"twoFactor.enabledNote":`ورود دومرحلهای روشن شد. نشستهای دیگر شما بسته شدند.`,"twoFactor.disabledNote":`ورود دومرحلهای خاموش است.`,"viewAs.start":`دیدن از نگاه این کاربر`,"viewAs.banner":`از نگاه {name}. فقط خواندنی.`,"viewAs.stop":`پایان`,"rbac.twoFactor":`ورود دومرحلهای`,"rbac.resetTwoFactor":`بازنشانی ورود دومرحلهای`,"rbac.resetTwoFactorNote":`عامل دوم کاربر را (مثلاً گوشی گمشده) خاموش میکند و او را از همهجا خارج میکند.`,"rbac.twoFactorReset":`ورود دومرحلهای این کاربر خاموش شد.`,"debugger.title":`اشکالیاب دسترسی`,"debugger.intro":`چرا کاربری چیزی را میبیند یا نمیبیند، تغییر میدهد یا نمیدهد.`,"debugger.user":`کاربر`,"debugger.resource":`منبع`,"debugger.record":`شناسهٔ رکورد (اختیاری)`,"debugger.explain":`توضیح بده`,"debugger.pick":`یک کاربر و یک منبع انتخاب کنید.`,"debugger.roles":`نقشها`,"debugger.noRoles":`بدون نقش: هیچ کاری مجاز نیست.`,"debugger.superuser":`ابرکاربر همهکاری میتواند بکند.`,"debugger.source.direct":`مستقیم داده شده`,"debugger.source.group":`از گروه {group}`,"debugger.source.resolveRoles":`از resolveRoles`,"debugger.source.adapter":`از سامانهٔ ورود`,"debugger.unknownRole":`نقشی با این نام نیست؛ چیزی نمیدهد`,"debugger.operations":`عملیات`,"debugger.allowed":`مجاز`,"debugger.denied":`غیرمجاز`,"debugger.noGrant":`هیچ نقشی آن را نمیدهد`,"debugger.viaUpdate":`{pattern} در {role} (تغییر، دیدن را هم میدهد)`,"debugger.grant":`{pattern} در {role}`,"debugger.fields":`فیلدها`,"debugger.field":`فیلد`,"debugger.result":`نتیجه`,"debugger.byRole":`به تفکیک نقش`,"debugger.forced":`همیشه دیده میشود: کلیدها و نسخه`,"debugger.scopes":`ردیفها`,"debugger.allRows":`همهٔ ردیفها`,"debugger.noRows":`هیچ ردیفی`,"debugger.someRows":`ردیفهای {scopes}`,"debugger.globalScopes":`محدود به {scopes} نیز`,"debugger.recordTitle":`رکورد {id}`,"debugger.reason.permission":`بدون مجوز`,"debugger.reason.scope":`بیرون از ردیفهایش`,"debugger.reason.rule":`قاعدهٔ این رکورد اجازه نمیدهد`,"debugger.reason.missing":`چنین رکوردی نیست`,"debugger.actions":`عملیات`,"debugger.needsUpdate":`عملیات روی رکوردها به مجوز تغییر هم نیاز دارد`,"debugger.noRecordActions":`هیچکدام روی این رکورد`,"debugger.pages":`صفحههای تنظیمات`,"audit.title":`گزارش تغییرات`,"audit.history":`تاریخچه`,"audit.details":`جزئیات`,"audit.recordTabs":`رکورد و تاریخچهی آن`,"audit.entries":`تغییرهای ثبتشده`,"audit.notAllowed":`اجازهی خواندن گزارش تغییرات را ندارید`,"audit.off":`گزارش تغییرات در این پنل فعال نیست`,"audit.empty":`هنوز چیزی ثبت نشده است.`,"audit.noMatches":`موردی پیدا نشد.`,"audit.noActor":`بدون ورود`,"audit.viewAsBy":`هنگامی که کاربر {id} از دید او نگاه میکرد`,"audit.filterByActor":`فقط کارهای {name} را نشان بده`,"audit.changedFields":`فیلدهای تغییرکرده`,"audit.before":`قبل`,"audit.after":`بعد`,"audit.becomes":`شد`,"audit.field.changed":`تغییر کرد`,"audit.field.hidden":`پنهان`,"audit.field.dropped":`بزرگتر از آن بود که نگه داشته شود`,"audit.field.truncated":`کوتاهشده`,"audit.showMore":`بیشتر`,"audit.showLess":`کمتر`,"audit.input":`ورودی`,"audit.inputTruncated":`ورودی بزرگتر از آن بود که نگه داشته شود.`,"audit.restrictedRecord":`رکوردی که نمیتوانید ببینید: جزئیات آن نشان داده نمیشود.`,"audit.restrictedChanges":`اجازهی دیدن تغییرها را ندارید.`,"audit.suppressedNote":`در همان دقیقه رخ دادند و تکتک ثبت نشدند.`,"audit.limitedNote":`ورودهای ناموفق بعدی در این دقیقه فقط شمرده میشوند.`,"audit.actionDeleted":`این عملیات رکورد را حذف کرد.`,"audit.filter.actor":`انجامدهنده (شناسهی کاربر)`,"audit.filter.event":`رویداد`,"audit.filter.eventHint":`order.updated یا auth.*`,"audit.filter.resource":`بخش`,"audit.filter.record":`شناسهی رکورد`,"audit.filter.recordHint":`نخست یک بخش انتخاب کنید`,"audit.event.unseen":`تغییری که نمیتوانید ببینید`,"audit.event.created":`ایجاد شد`,"audit.event.updated":`تغییر کرد`,"audit.event.deleted":`حذف شد`,"audit.event.trashed":`به سطل زباله رفت`,"audit.event.restored":`بازیابی شد`,"audit.event.purged":`برای همیشه حذف شد`,"audit.event.action":`«{action}» اجرا شد`,"audit.event.page":`{page} تغییر کرد`,"audit.event.login":`وارد شد`,"audit.event.logout":`خارج شد`,"audit.event.loginFailed":`ورود ناموفق`,"audit.event.loginFailedCode":`ورود ناموفق: کد دومرحلهای نادرست`,"audit.event.loginFailedLimited":`ورود ناموفق: تلاشهای بیش از حد`,"audit.event.loginFailedMore":`{count} ورود ناموفق دیگر`,"audit.event.viewAs":`پنل را از دید یک کاربر دید`,"audit.event.roleChanged":`نقش تغییر کرد`,"audit.event.groupChanged":`گروه تغییر کرد`,"audit.event.userRolesChanged":`نقشها و گروههای یک کاربر تغییر کرد`,"audit.event.userCreated":`کاربر ایجاد شد`,"audit.event.userChanged":`کاربر تغییر کرد`,"audit.event.passwordChanged":`رمز عبور تغییر کرد`,"audit.event.passwordReset":`مدیر رمز عبور را تعیین کرد`,"audit.event.twoFactorEnabled":`ورود دومرحلهای روشن شد`,"audit.event.twoFactorDisabled":`ورود دومرحلهای خاموش شد`,"audit.event.twoFactorReset":`ورود دومرحلهای بازنشانی شد`,"audit.event.recoveryCodes":`کدهای بازیابی تازه`,"audit.event.sessions":`نشستها بسته شدند`,"audit.event.sessionsOthers":`از همهی دستگاههای دیگر خارج شد`,"audit.event.sessionsOne":`از یک دستگاه خارج شد`,"display.title":`تنظیمات نمایش`,"display.calendar":`تقویم`,"display.gregorian":`میلادی`,"display.jalali":`شمسی`,"display.digits":`ارقام`,"display.accent":`رنگ اصلی`,"display.customAccent":`رنگ دیگر`,"display.defaultAccent":`پیشفرض`,"display.accentForEveryone":`برای همه`,"display.resetForEveryone":`بازگشت برای همه`,"display.latinDigits":`لاتین 123`,"display.persianDigits":`فارسی ۱۲۳`,"inline.row":`{name} ردیف {index}`,"inline.newRow":`{name} جدید {index}`,"inline.moveUp":`بردن {name} به بالا`,"inline.moveDown":`بردن {name} به پایین`,"inline.remove":`حذف {name}`,"inline.rowActions":`کارهای ردیف`,"inline.empty":`هنوز چیزی نیست.`,"inline.limitsMax":`{count} · حداکثر {max}`,"inline.limitsBetween":`{count} · از {min} تا {max}`,"inline.countMin":`دستکم {min} لازم است ({count} هست).`,"inline.countMax":`حداکثر {max} میتواند باشد ({count} هست).`,"inline.truncated":`{count} مورد دیگر اینجا نشان داده نمیشود، پس اینها در این فرم ویرایش نمیشوند.`,"inline.openList":`باز کردن فهرست`,"inline.duplicateNote":`تکثیر فقط همین رکورد را کپی میکند، نه {names} آن را.`,"form.new":`{name} جدید`,"form.back":`بازگشت`,"form.edit":`ویرایش`,"dashboard.title":`داشبورد`,"dashboard.subtitle":`وضعیت فروشگاه در بازه انتخابشده`,"dashboard.period":`بازه زمانی`,"dashboard.day":`امروز`,"dashboard.week":`هفته`,"dashboard.month":`ماه`,"dashboard.year":`سال`,"dashboard.range":`انتخاب بازه تاریخ`,"dashboard.apply":`نمایش`,"dashboard.failed":`این ویجت بارگذاری نشد.`,"dashboard.retry":`تلاش دوباره`,"dashboard.viewAll":`مشاهده همه`,"dashboard.thisPeriod":`این دوره`,"dashboard.previousPeriod":`دوره قبل`,"stepper.since":`از {time}`,"form.viewProfile":`مشاهده پروفایل`,"form.viewOnly":`میتوانید این رکورد را ببینید اما نمیتوانید آن را تغییر دهید.`,"form.save":`ذخیره`,"form.saving":`در حال ذخیره…`,"form.delete":`حذف`,"form.confirmDelete":`تأیید حذف`,"form.moveToTrash":`انتقال به سطل زباله`,"form.confirmMoveToTrash":`تأیید انتقال به سطل زباله`,"form.deleting":`در حال حذف…`,"form.keep":`نگهداشتن`,"form.related":`مرتبط`,"form.add":`افزودن {name}`,"form.remove":`حذف {name} {index}`,"form.conflictTitle":`در حین ویرایش شما، شخص دیگری این رکورد را ذخیره کرد.`,"form.conflictNone":`هیچیک از فیلدهای این فرم تغییر نکرده است.`,"form.keepMine":`تغییرات من بماند`,"form.loadTheirs":`نسخهی آنها را بارگذاری کن`,"form.saveAndNew":`ذخیره و مورد جدید`,"form.duplicate":`تکثیر`,"form.savedName":`«{name}» ذخیره شد.`,"form.leaveTitle":`بدون ذخیره خارج میشوید؟ تغییرات از دست میرود.`,"form.stay":`بمان`,"form.leave":`خروج`,"form.unsaved":`تغییرات ذخیره نشده`,"form.formatJson":`مرتبسازی`,"form.tabHasErrors":`(دارای خطا)`,"form.readOnly":`فقط خواندنی`,"form.externalLink":`{name} (در زبانهی جدید باز میشود)`,"form.colorCode":`کد رنگ {name}`,"upload.choose":`انتخاب فایل`,"upload.chooseMany":`انتخاب فایلها`,"upload.chooseImage":`انتخاب تصویر`,"upload.chooseImages":`انتخاب تصویرها`,"upload.replace":`جایگزینی`,"upload.drop":`یا آن را اینجا رها کنید`,"upload.dropMany":`یا آنها را اینجا رها کنید`,"upload.limit":`حداکثر {max}`,"upload.uploading":`در حال بارگذاری {name}`,"upload.cancel":`لغو بارگذاری {name}`,"upload.remove":`حذف {name}`,"upload.open":`باز کردن {name}`,"upload.more":`+{count}`,"upload.failed":`{name}: {message}`,"upload.busy":`تا پایان بارگذاریها صبر کنید، سپس ذخیره کنید.`,"upload.tooLarge":`فایل بیش از حد بزرگ است.`,"upload.tooLargeMax":`فایل بیش از حد بزرگ است (حداکثر {max}).`,"upload.typeRefused":`این نوع فایل اینجا پذیرفته نمیشود.`,"upload.empty":`فایل خالی است.`,"upload.network":`بارگذاری ناموفق بود. اتصال خود را بررسی کنید و دوباره تلاش کنید.`,"upload.bytes":`{value} بایت`,"upload.kilobytes":`{value} کیلوبایت`,"upload.megabytes":`{value} مگابایت`,"upload.gigabytes":`{value} گیگابایت`,"upload.terabytes":`{value} ترابایت`,"editor.loading":`در حال بارگذاری ویرایشگر…`,"editor.toolbar":`قالببندی {name}`,"editor.paragraph":`پاراگراف`,"editor.heading":`عنوان {level}`,"editor.bold":`پررنگ`,"editor.italic":`کج`,"editor.strike":`خطخورده`,"editor.bulletList":`فهرست نشانهدار`,"editor.orderedList":`فهرست شمارهدار`,"editor.blockquote":`نقلقول`,"editor.rule":`خط افقی`,"editor.link":`پیوند`,"editor.linkAddress":`نشانی پیوند`,"editor.linkApply":`اعمال`,"editor.unlink":`حذف پیوند`,"editor.image":`درج تصویر`,"editor.imageNoAddress":`سرور نشانیای برای نمایش تصویر نداد`,"editor.table":`درج جدول`,"editor.addRow":`افزودن سطر`,"editor.addColumn":`افزودن ستون`,"editor.deleteRow":`حذف سطر`,"editor.deleteColumn":`حذف ستون`,"editor.deleteTable":`حذف جدول`,"editor.undo":`واگرد`,"editor.redo":`ازنو`,"palette.open":`جستوجو و رفتن به`,"palette.placeholder":`رفتن به، ساختن، یا یافتن رکورد…`,"palette.results":`نتایج`,"palette.goTo":`رفتن به`,"palette.actions":`کارها`,"palette.toggleTheme":`تغییر تم`,"palette.records":`رکوردها`,"palette.new":`{name} جدید`,"palette.searching":`در حال جستوجو…`,"palette.noResults":`چیزی پیدا نشد`,"picker.typeToSearch":`برای جستوجو تایپ کنید…`,"picker.typeToAdd":`برای افزودن تایپ کنید…`,"picker.searching":`در حال جستوجو…`,"picker.noMatches":`موردی پیدا نشد`,"picker.remove":`حذف {name}`,"picker.clear":`پاک کردن {name}`,"picker.selected":`{name} انتخابشده`,"validation.required":`الزامی است`,"validation.number":`باید عدد باشد`,"validation.json":`باید JSON معتبر باشد`,"validation.date":`باید تاریخ معتبری باشد`,"validation.datetime":`باید تاریخ و زمان معتبر باشد`,"validation.minLength":`باید دستکم {min} نویسه باشد`,"validation.maxLength":`باید حداکثر {max} نویسه باشد`,"validation.pattern":`قالب آن درست نیست`,"validation.email":`باید نشانی ایمیل باشد`,"validation.url":`باید نشانی اینترنتی باشد`,"validation.uuid":`باید UUID باشد`,"validation.oneOf":`باید یکی از اینها باشد: {values}`,"validation.integer":`باید عدد صحیح باشد`,"validation.min":`باید دستکم {min} باشد`,"validation.max":`باید حداکثر {max} باشد`}},Uh=new Set([`fa`,`ar`,`he`,`ur`]),Wh=`nma.locale`,Gh=`en`,Kh={calendar:`gregorian`,digits:`latn`};function qh(){return Kh}function Jh(e){Kh=e}function Yh(){return Gh}function J(e,t={},n=Gh){return((Hh[n]??Vh)[e]??Vh[e]).replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function Xh(e){return Uh.has(e.split(`-`)[0])}var Zh=e=>`-u-ca-${e.calendar===`persian`?`persian`:`gregory`}-nu-${e.digits}`;function Qh(e,t=Gh){return new Intl.NumberFormat(`${t}-u-nu-${Kh.digits}`).format(e)}function $h(e){return Kh.digits===`arabext`?Fh(e):e}function eg(e,t=Gh){return new Intl.DateTimeFormat(`${t}${Zh(Kh)}`,{dateStyle:`medium`,timeStyle:`short`}).format(e)}function tg(e,t=Gh){return new Intl.DateTimeFormat(`${t}${Zh(Kh)}`,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).format(e)}function ng(e,t=Gh){let n=Date.parse(`${e}T00:00:00Z`);return!/^\d{4}-\d{2}-\d{2}$/.test(e)||Number.isNaN(n)?e:new Intl.DateTimeFormat(`${t}${Zh(Kh)}`,{dateStyle:`medium`,timeZone:`UTC`}).format(n)}function rg(e,t=new Date,n=Gh){let r=Math.min(0,Math.round((e.getTime()-t.getTime())/1e3)),i=new Intl.RelativeTimeFormat(`${n}-u-nu-${Kh.digits}`,{numeric:`auto`});for(let[e,t]of[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]])if(Math.abs(r)>=t)return i.format(Math.trunc(r/t),e);return i.format(Math.abs(r)<10?0:r,`second`)}function ig(e){Gh=e,typeof document<`u`&&(document.documentElement.lang=e,document.documentElement.dir=Xh(e)?`rtl`:`ltr`)}function ag(e,t){try{let t=localStorage.getItem(Wh);if(t&&e.includes(t))return t}catch{}return t}var og=(0,y.createContext)(void 0);function sg({locales:e,fallback:t,children:n}){let[r,i]=(0,y.useState)(()=>{let n=ag(e,t);return ig(n),n}),[a,o]=(0,y.useState)(()=>{let e=zh(r);return Jh(e),e});return(0,b.jsx)(og.Provider,{value:{locale:r,locales:e,setLocale:e=>{ig(e);try{localStorage.setItem(Wh,e)}catch{}let t=zh(e);Jh(t),o(t),i(e)},t:(e,t)=>J(e,t,r),calendar:a.calendar,digits:a.digits,setDisplay:e=>{Bh(e);let t={...a,...e};Jh(t),o(t)}},children:n})}function Y(){let e=(0,y.useContext)(og);if(!e)throw Error(`useLocale() outside LocaleProvider`);return e}function X(){return Y().t}function cg(){let e=document.getElementById(`nma-config`)?.textContent;if(e)return JSON.parse(e);throw Error(`nest-my-admin: runtime config missing`)}var lg=cg(),ug=class extends Error{status;body;constructor(e,t){super(t.code===`INTERNAL`&&t.correlationId?J(`common.reference`,{message:t.message,id:t.correlationId}):t.message),this.status=e,this.body=t,this.name=`ApiError`}get fields(){return this.body.fields??{}}};function dg(e){if(!(e instanceof ug))return e.message;let t=Object.entries(e.fields).map(([e,t])=>`${e}: ${t.join(`, `)}`);return[e.message,...t].join(` — `)}var fg,pg;function mg(e){fg=e}function hg(){return fg}function gg(e){pg=e}function _g(){fg=void 0,pg?.()}function vg(e,t){let n=t.replace(/\/+$/,``);return n===``||e!==n&&!e.startsWith(`${n}/`)?e:e.slice(n.length)||`/`}function yg(e,t=``){if(!e||!e.startsWith(`/`)||e.startsWith(`//`)||e.startsWith(`/\\`))return`/`;let n=vg(e,t);return n.startsWith(`/login`)?`/`:n}var bg=`nma-view-as`;function xg(){try{return sessionStorage.getItem(bg)??void 0}catch{return}}function Sg(e){try{e===void 0?sessionStorage.removeItem(bg):sessionStorage.setItem(bg,e)}catch{}}var Cg=class extends Error{constructor(){super(`Upload aborted`),this.name=`UploadAbortedError`}},wg=`application/octet-stream`;function Tg(e){return typeof e==`object`&&!!e&&`code`in e&&`message`in e}function Eg(e){return typeof e==`object`&&!!e&&typeof e.token==`string`}function Dg(e,t,n,r){let i=n.createXhr?n.createXhr():new XMLHttpRequest,a=!1;return{promise:new Promise((o,s)=>{let c=e=>{a||(a=!0,e())};i.open(`POST`,`${n.apiBase}/uploads?${new URLSearchParams({resource:t.resource,field:t.field})}`),i.setRequestHeader(`Accept`,`application/json`),i.setRequestHeader(`Accept-Language`,n.locale),i.setRequestHeader(`Content-Type`,wg),i.setRequestHeader(`X-File-Name`,encodeURIComponent(e.name)),n.csrfToken&&i.setRequestHeader(`X-CSRF-Token`,n.csrfToken),n.viewAs&&i.setRequestHeader(`X-View-As`,n.viewAs),i.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&r?.(e.loaded/e.total)},i.onload=()=>{let e;try{e=i.responseText?JSON.parse(i.responseText):void 0}catch{e=void 0}let t=i.status>=200&&i.status<300&&Eg(e);i.status===401&&n.onSignedOut?.(),c(()=>{t?(r?.(1),o(e)):Tg(e)?s(new ug(i.status,e)):i.status===413?s(new ug(413,{code:`BAD_REQUEST`,message:J(`upload.tooLarge`,{},n.locale),correlationId:``})):s(new ug(i.status,{code:`INTERNAL`,message:J(`common.requestFailed`,{status:i.status},n.locale),correlationId:``}))})},i.onerror=()=>c(()=>s(Error(J(`upload.network`,{},n.locale)))),i.onabort=()=>c(()=>s(new Cg)),i.send(e)}),abort:()=>{a||i.abort()}}}function Og(e){if(e instanceof ug){let t=Object.values(e.fields).flat();if(t.length>0)return t.join(` `)}return e instanceof Error?e.message:String(e)}function kg(e,t){if(t.length===0)return!0;let n=e.toLowerCase();return t.some(e=>{let t=e.trim().toLowerCase();return t===`*`||t===`*/*`?!0:t.endsWith(`/*`)?n.startsWith(t.slice(0,-1)):n===t})}function Ag(e,t,n){if(e.size===0)return J(`upload.empty`,{},n);if(e.size>t.maxBytes)return J(`upload.tooLargeMax`,{max:Mg(t.maxBytes,n)},n);if(e.type!==``&&!kg(e.type.split(`;`)[0].trim(),t.accept))return J(`upload.typeRefused`,{},n)}var jg=[`upload.bytes`,`upload.kilobytes`,`upload.megabytes`,`upload.gigabytes`,`upload.terabytes`];function Mg(e,t){let n=e,r=0;for(;n>=1024&&r<jg.length-1;)n/=1024,r+=1;let i=new Intl.NumberFormat(t??`${Yh()}-u-nu-${qh().digits}`,{maximumFractionDigits:r===0?0:1}).format(n);return J(jg[r],{value:i},t)}function Ng(e,t,n){let r=[...e];if(t<0||t>=r.length||n<0||n>=r.length||t===n)return r;let[i]=r.splice(t,1);return r.splice(n,0,i),r}function Pg(e){return{...e,creatable:!1,actions:[],prints:[],permissions:{create:!1,update:!1,delete:!1,purge:!1},list:{...e.list,editable:[]},form:{...e.form,create:[],update:[],requiredOnCreate:[],readonly:[...new Set([...e.form.readonly,...e.form.update,...e.form.create])]},...e.inlines?{inlines:Object.fromEntries(Object.entries(e.inlines).map(([e,t])=>[e,Pg(t)]))}:{}}}function Fg(e){return e.schema.readonly?e:{...e,schema:{...e.schema,readonly:!0}}}function Ig(e){return e.viewAs?{...e,rbac:{...e.rbac,manage:!1}}:e}function Lg(e){return typeof e==`object`&&!!e&&`code`in e&&`message`in e}async function Z(e,t={}){let n=t.method??`GET`,r=hg(),i=e===`/session`&&n===`POST`?void 0:xg(),a=await fetch(`${lg.apiBase}${e}`,{...t,credentials:`same-origin`,headers:{Accept:`application/json`,"Accept-Language":Yh(),...t.body?{"Content-Type":`application/json`}:{},...n!==`GET`&&r?{"X-CSRF-Token":r}:{},...i?{"X-View-As":i}:{},...t.headers}});a.status===401&&!e.startsWith(`/session`)&&_g();let o=await a.text(),s;try{s=o?JSON.parse(o):void 0}catch{s=void 0}if(!a.ok)throw new ug(a.status,Lg(s)?s:{code:`INTERNAL`,message:J(`common.requestFailed`,{status:a.status}),correlationId:``});return s}var Rg=encodeURIComponent,zg=e=>typeof e==`number`||typeof e==`string`?{"If-Match":`"${e}"`}:{};function Bg(e,t,n){let r=new URLSearchParams([...n.map(e=>[`id`,e]),[`lang`,Yh()]]);return`${lg.apiBase}/resources/${encodeURIComponent(e)}/print/${encodeURIComponent(t)}?${r}`}async function Vg(e,t){let n=new URLSearchParams(t);n.set(`offset`,String(-new Date().getTimezoneOffset()));let r=xg(),i=await fetch(`${lg.apiBase}/resources/${encodeURIComponent(e)}/export?${n}`,{credentials:`same-origin`,headers:{"Accept-Language":Yh(),...r?{"X-View-As":r}:{}}});if(i.status===401&&_g(),!i.ok){let e=await i.json().catch(()=>void 0);throw new ug(i.status,Lg(e)?e:{code:`INTERNAL`,message:J(`common.requestFailed`,{status:i.status}),correlationId:``})}let a=/filename="([^"]+)"/.exec(i.headers.get(`Content-Disposition`)??``)?.[1]??`${e}.xlsx`,o=i.headers.get(`X-Export-Truncated`);return{blob:await i.blob(),filename:a,...o?{truncated:Number(o)}:{}}}var Q={exportList:Vg,session:async()=>Ig(await Z(`/session`)),login:(e,t,n)=>Z(`/session`,{method:`POST`,body:JSON.stringify({username:e,password:t,...n?{otp:n}:{}})}),logout:()=>Z(`/session`,{method:`DELETE`}),sessions:()=>Z(`/account/sessions`),revokeSession:e=>Z(`/account/sessions/${Rg(e)}`,{method:`DELETE`}),revokeOtherSessions:()=>Z(`/account/sessions`,{method:`DELETE`}),changePassword:(e,t)=>Z(`/account/password`,{method:`POST`,body:JSON.stringify({current:e,next:t})}),twoFactor:{status:()=>Z(`/account/2fa`),setup:()=>Z(`/account/2fa/setup`,{method:`POST`,body:`{}`}),confirm:e=>Z(`/account/2fa/confirm`,{method:`POST`,body:JSON.stringify({code:e})}),disable:e=>Z(`/account/2fa/disable`,{method:`POST`,body:JSON.stringify({password:e})}),recoveryCodes:e=>Z(`/account/2fa/recovery-codes`,{method:`POST`,body:JSON.stringify({password:e})})},meta:()=>Z(`/meta`),menuBadges:()=>Z(`/menu/badges`),dashboard:()=>Z(`/dashboard`),setAppearance:e=>Z(`/appearance`,{method:`PUT`,body:JSON.stringify({accent:e})}),widget:(e,t)=>Z(`/dashboard/${encodeURIComponent(e)}?${new URLSearchParams({...t})}`),tabCounts:e=>Z(`/resources/${encodeURIComponent(e)}/tab-counts`),rbac:{catalog:()=>Z(`/rbac/catalog`),roles:()=>Z(`/rbac/roles`),role:e=>Z(`/rbac/roles/${Rg(e)}`),createRole:e=>Z(`/rbac/roles`,{method:`POST`,body:JSON.stringify(e)}),updateRole:(e,t)=>Z(`/rbac/roles/${Rg(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),deleteRole:e=>Z(`/rbac/roles/${Rg(e)}`,{method:`DELETE`}),exportRoles:()=>Z(`/rbac/roles/export`),importRoles:e=>Z(`/rbac/roles/import`,{method:`POST`,body:JSON.stringify(e)}),groups:()=>Z(`/rbac/groups`),group:e=>Z(`/rbac/groups/${e}`),saveGroup:(e,t)=>Z(t===void 0?`/rbac/groups`:`/rbac/groups/${t}`,{method:t===void 0?`POST`:`PATCH`,body:JSON.stringify(e)}),deleteGroup:e=>Z(`/rbac/groups/${e}`,{method:`DELETE`}),users:e=>Z(`/rbac/users?${new URLSearchParams(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``).map(([e,t])=>[e,String(t)]))}`),user:e=>Z(`/rbac/users/${Rg(e)}`),createUser:e=>Z(`/rbac/users`,{method:`POST`,body:JSON.stringify(e)}),updateUser:(e,t)=>Z(`/rbac/users/${Rg(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),setPassword:(e,t)=>Z(`/rbac/users/${Rg(e)}/password`,{method:`POST`,body:JSON.stringify({password:t})}),resetTwoFactor:e=>Z(`/rbac/users/${Rg(e)}/2fa/reset`,{method:`POST`,body:`{}`}),explain:e=>Z(`/rbac/explain?${new URLSearchParams(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``))}`)},upload:(e,t,n)=>Dg(e,t,{apiBase:lg.apiBase,csrfToken:hg(),viewAs:xg(),locale:Yh(),onSignedOut:_g},n),search:e=>Z(`/search?${new URLSearchParams({q:e})}`),schema:async e=>{let t=await Z(`/meta/resources/${Rg(e)}`);return xg()?Pg(t):t},list:(e,t)=>Z(`/resources/${Rg(e)}?${t}`),remove:(e,t,n)=>Z(`/resources/${Rg(e)}/${Rg(t)}`,{method:`DELETE`,headers:zg(n)}),options:(e,t,n)=>{let r=new URLSearchParams;return n.ids?r.set(`ids`,n.ids.join(`,`)):n.search&&r.set(`search`,n.search),n.values&&r.set(`values`,n.values),n.parent&&n.values&&r.set(`parent`,n.parent),Z(`/resources/${Rg(e)}/fields/${Rg(t)}/options${r.size?`?${r}`:``}`)},bulkDelete:(e,t)=>Z(`/resources/${Rg(e)}/bulk-delete`,{method:`POST`,body:JSON.stringify({ids:t})}),runAction:(e,t,n)=>Z(`/resources/${Rg(e)}/actions/${Rg(t)}`,{method:`POST`,body:JSON.stringify(n)}),page:async e=>{let t=await Z(`/pages/${Rg(e)}`);return xg()?Fg(t):t},savePage:(e,t)=>Z(`/pages/${Rg(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),history:(e,t,n)=>Z(`/resources/${Rg(e)}/${Rg(t)}/history${n?`?${new URLSearchParams({before:n})}`:``}`),audit:(e,t)=>{let n=new URLSearchParams(e);return t&&n.set(`before`,t),Z(`/audit${n.size?`?${n}`:``}`)},restore:(e,t)=>Z(`/resources/${Rg(e)}/${Rg(t)}/restore`,{method:`POST`,body:`{}`}),get:(e,t)=>Z(`/resources/${Rg(e)}/${Rg(t)}`),create:(e,t)=>Z(`/resources/${Rg(e)}`,{method:`POST`,body:JSON.stringify(t)}),update:(e,t,n,r)=>Z(`/resources/${Rg(e)}/${Rg(t)}`,{method:`PATCH`,body:JSON.stringify(n),headers:zg(r)})},Hg=()=>ft({queryKey:[`session`],queryFn:async()=>{let e=await Q.session();return mg(e.csrfToken),e},retry:!1,staleTime:3e5}),Ug=()=>{let{locale:e}=Y();return ft({queryKey:[`meta`,e],queryFn:Q.meta})},Wg=(e,t=!0)=>{let{locale:n}=Y();return ft({queryKey:[`schema`,e,n],queryFn:()=>Q.schema(e),enabled:t})},Gg=e=>ft({queryKey:[`menu-badges`],queryFn:Q.menuBadges,enabled:e,refetchInterval:6e4,refetchOnWindowFocus:!0}),Kg=e=>{let{locale:t}=Y();return ft({queryKey:[`page`,e,t],queryFn:()=>Q.page(e)})},qg=(e,t,n=!0)=>ft({queryKey:[`list`,e,t],queryFn:()=>Q.list(e,new URLSearchParams(t)),placeholderData:ue,enabled:n}),Jg=(e,t)=>ft({queryKey:[`record`,e,t],queryFn:()=>Q.get(e,t),enabled:t!==void 0}),Yg=(e,t,n,r,i,a)=>ft({queryKey:[`options`,e,t,n,i??``,a??``],queryFn:()=>Q.options(e,t,{search:n,values:i,parent:a}),enabled:r,placeholderData:ue}),Xg=(e,t,n)=>ft({queryKey:[`options`,e,t,`ids`,n],queryFn:()=>Q.options(e,t,{ids:n}),enabled:n.length>0}),Zg=function(e,t){let n=e,r=$g[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=t_.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=t_.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=t_.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=t_.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=t_.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=t_.getErrorCorrectPolynomial(l),d=r_(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=i_.getRSBlocks(e,t),i=a_();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),t_.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=o_(e);break;case`Alphanumeric`:n=s_(e);break;case`Byte`:n=c_(e);break;case`Kanji`:n=l_(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=i_.getRSBlocks(e,r),n=a_();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),t_.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return m_(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`<`;break;case`>`:t+=`>`;break;case`&`:t+=`&`;break;case`"`:t+=`"`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
|
|
51
51
|
`}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
|
|
52
52
|
`}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};Zg.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},Zg.createStringToBytes=function(e,t){let n=function(){let n=f_(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var Qg={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},$g={L:1,M:0,Q:3,H:2},e_={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},t_=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case e_.PATTERN000:return function(e,t){return(e+t)%2==0};case e_.PATTERN001:return function(e,t){return e%2==0};case e_.PATTERN010:return function(e,t){return t%3==0};case e_.PATTERN011:return function(e,t){return(e+t)%3==0};case e_.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case e_.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case e_.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case e_.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=r_([1],0);for(let n=0;n<e;n+=1)t=t.multiply(r_([1,n_.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case Qg.MODE_NUMBER:return 10;case Qg.MODE_ALPHA_NUM:return 9;case Qg.MODE_8BIT_BYTE:return 8;case Qg.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case Qg.MODE_NUMBER:return 12;case Qg.MODE_ALPHA_NUM:return 11;case Qg.MODE_8BIT_BYTE:return 16;case Qg.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case Qg.MODE_NUMBER:return 14;case Qg.MODE_ALPHA_NUM:return 13;case Qg.MODE_8BIT_BYTE:return 16;case Qg.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),n_=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),r_=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=n_.gexp(n_.glog(r.getAt(n))+n_.glog(e.getAt(i)));return r_(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=n_.glog(r.getAt(0))-n_.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=n_.gexp(n_.glog(e.getAt(r))+t);return r_(n,0).mod(e)},r},i_=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case $g.L:return e[(t-1)*4+0];case $g.M:return e[(t-1)*4+1];case $g.Q:return e[(t-1)*4+2];case $g.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),a_=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},o_=function(e){let t=Qg.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},s_=function(e){let t=Qg.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},c_=function(e){let t=Qg.MODE_8BIT_BYTE,n=Zg.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},l_=function(e){let t=Qg.MODE_KANJI,n=Zg.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},u_=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},d_=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},f_=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},p_=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=u_(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},m_=function(e,t,n){let r=p_(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=u_();r.write(i);let a=d_(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};Zg.stringToBytes;function h_({text:e,label:t}){let{size:n,path:r}=(0,y.useMemo)(()=>{let t=Zg(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i} ${e}h1v1h-1z`);return{size:n,path:r}},[e]);return(0,b.jsx)(`svg`,{viewBox:`-3 -3 ${n+6} ${n+6}`,role:`img`,"aria-label":t,className:`size-44 rounded-md bg-white`,shapeRendering:`crispEdges`,children:(0,b.jsx)(`path`,{d:r,fill:`#000`})})}function g_(){let{t:e}=Y(),t=Hg();if(t.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(!t.data)return null;if(t.data.viewAs)return(0,b.jsx)(Da,{to:`/`,replace:!0});let{user:n,auth:r}=t.data;return(0,b.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-8`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:e(`auth.account`)}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n.displayName,n.username?` · ${n.username}`:``]})]}),r.password&&(0,b.jsx)(__,{}),r.twoFactor&&(0,b.jsx)(v_,{}),r.sessions&&(0,b.jsx)(b_,{revokeOthers:r.revokeOthers})]})}function __(){let{t:e}=Y(),t=S(),[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)({}),[u,d]=(0,y.useState)(!1),f=pt({mutationFn:()=>Q.changePassword(n,i),onSuccess:async()=>{r(``),a(``),s(``),l({}),d(!0),await t.invalidateQueries({queryKey:[`account-sessions`]})},onError:e=>l(e instanceof ug&&Object.keys(e.fields).length>0?e.fields:{form:[dg(e)]})});function p(t){t.preventDefault(),d(!1);let r={};n||(r.current=[e(`validation.required`)]),i?i!==o&&(r.confirm=[e(`auth.mismatch`)]):r.next=[e(`validation.required`)],l(r),Object.keys(r).length===0&&f.mutate()}let m=(e,t,n,r,i)=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`password-${e}`,children:t}),(0,b.jsx)(Oh,{id:`password-${e}`,type:`password`,autoComplete:i,value:n,onChange:e=>r(e.target.value),"aria-invalid":c[e]?!0:void 0,"aria-describedby":c[e]?`password-${e}-error`:void 0}),c[e]&&(0,b.jsx)(`p`,{id:`password-${e}-error`,className:`text-sm text-destructive`,children:c[e].join(` `)})]});return(0,b.jsxs)(`section`,{"aria-labelledby":`password-title`,className:`flex flex-col gap-4 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsx)(`h2`,{id:`password-title`,className:`font-medium`,children:e(`auth.changePassword`)}),(0,b.jsxs)(`form`,{onSubmit:p,noValidate:!0,className:`flex flex-col gap-4`,children:[c.form&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c.form.join(` `)}),u&&(0,b.jsx)(`p`,{role:`status`,className:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:e(`auth.passwordChanged`)}),m(`current`,e(`auth.currentPassword`),n,r,`current-password`),m(`next`,e(`auth.newPassword`),i,a,`new-password`),m(`confirm`,e(`auth.confirmPassword`),o,s,`new-password`),(0,b.jsx)(`div`,{children:(0,b.jsx)(q,{type:`submit`,disabled:f.isPending,children:e(`auth.changePassword`)})})]})]})}function v_(){let{t:e}=Y(),t=S(),n=ft({queryKey:[`account-2fa`],queryFn:Q.twoFactor.status}),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),h=e=>m(e instanceof ug&&Object.keys(e.fields).length>0?Object.values(e.fields).flat().join(` `):dg(e)),g=async()=>{await t.invalidateQueries({queryKey:[`account-2fa`]}),await t.invalidateQueries({queryKey:[`account-sessions`]})},_=pt({mutationFn:Q.twoFactor.setup,onMutate:()=>m(null),onError:h}),v=pt({mutationFn:()=>Q.twoFactor.confirm(r.trim()),onMutate:()=>m(null),onSuccess:async t=>{c(t.recoveryCodes),i(``),_.reset(),f(e(`twoFactor.enabledNote`)),await g()},onError:h}),x=pt({mutationFn:()=>Q.twoFactor.recoveryCodes(a),onMutate:()=>m(null),onSuccess:async e=>{c(e.recoveryCodes),o(``),await g()},onError:h}),C=pt({mutationFn:()=>Q.twoFactor.disable(a),onMutate:()=>m(null),onSuccess:async()=>{o(``),c(null),f(e(`twoFactor.disabledNote`)),await g()},onError:h}),w=n.data?.enabled===!0,T=_.data;return(0,b.jsxs)(`section`,{"aria-labelledby":`two-factor-title`,className:`flex flex-col gap-3 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h2`,{id:`two-factor-title`,className:`font-medium`,children:e(`twoFactor.title`)}),n.data&&(0,b.jsx)(`span`,{className:w?`rounded-full bg-green-500/15 px-2 py-0.5 text-xs text-green-800 dark:text-green-300`:`rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:e(w?`twoFactor.on`:`twoFactor.off`)})]}),p&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p}),d&&!p&&(0,b.jsx)(`p`,{role:`status`,className:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:d}),s&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border bg-muted/40 p-3`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium`,children:e(`twoFactor.recoveryTitle`)}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.recoveryIntro`)}),(0,b.jsx)(`ul`,{"aria-label":e(`twoFactor.recoveryTitle`),dir:`ltr`,className:`grid grid-cols-2 gap-1 font-mono text-sm`,children:s.map(e=>(0,b.jsx)(`li`,{children:e},e))}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard?.writeText(s.join(`
|
|
53
|
-
`)).then(()=>u(!0),()=>void 0)},children:e(l?`twoFactor.copied`:`twoFactor.copy`)}),(0,b.jsx)(q,{type:`button`,size:`sm`,onClick:()=>{c(null),u(!1)},children:e(`twoFactor.done`)})]})]}),n.data&&!w&&!T&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.intro`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:_.isPending,onClick:()=>_.mutate(),children:e(`twoFactor.setUp`)})]}),!w&&T&&(0,b.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),r.trim()&&v.mutate()},children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.scan`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,b.jsx)(h_,{text:T.otpauthUrl,label:e(`twoFactor.qr`)}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`twoFactor.key`)}),(0,b.jsx)(`code`,{dir:`ltr`,"data-testid":`two-factor-key`,className:`break-all font-mono`,children:T.secret.match(/.{1,4}/g).join(` `)})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`two-factor-code`,children:e(`twoFactor.code`)}),(0,b.jsx)(Oh,{id:`two-factor-code`,autoComplete:`one-time-code`,inputMode:`numeric`,dir:`ltr`,maxLength:10,value:r,onChange:e=>i(e.target.value)})]}),(0,b.jsx)(q,{type:`submit`,disabled:v.isPending||!r.trim(),children:e(`twoFactor.turnOn`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,onClick:()=>_.reset(),children:e(`common.cancel`)})]})]}),w&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.left`,{count:n.data.recoveryCodesLeft})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`two-factor-password`,children:e(`twoFactor.password`)}),(0,b.jsx)(Oh,{id:`two-factor-password`,type:`password`,autoComplete:`current-password`,value:a,onChange:e=>o(e.target.value)})]}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:!a||x.isPending,onClick:()=>x.mutate(),children:e(`twoFactor.newCodes`)}),(0,b.jsx)(q,{type:`button`,variant:`destructive`,disabled:!a||C.isPending,onClick:()=>C.mutate(),children:e(`twoFactor.turnOff`)})]})]})]})}function y_(e,t){return e?[/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:void 0,/Android/.test(e)?`Android`:/iPhone|iPad/.test(e)?`iOS`:/Mac OS X/.test(e)?`macOS`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:void 0].filter(Boolean).join(` · `)||e.slice(0,40):t}function b_({revokeOthers:e}){let{t}=Y(),n=S(),r=ft({queryKey:[`account-sessions`],queryFn:Q.sessions}),i=()=>n.invalidateQueries({queryKey:[`account-sessions`]}),a=pt({mutationFn:e=>Q.revokeSession(e),onSuccess:i}),o=pt({mutationFn:()=>Q.revokeOtherSessions(),onSuccess:i}),s=r.data?.items??[],c=a.error??o.error??r.error;return(0,b.jsxs)(`section`,{"aria-labelledby":`sessions-title`,className:`flex flex-col gap-3 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h2`,{id:`sessions-title`,className:`font-medium`,children:t(`auth.sessions`)}),e&&s.length>1&&(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(),children:t(`auth.signOutOthers`)})]}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:dg(c)}),(0,b.jsx)(`ul`,{"aria-label":t(`auth.sessions`),className:`flex flex-col divide-y`,children:s.map(e=>(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 py-2 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,title:e.userAgent,children:[y_(e.userAgent,t(`auth.unknownDevice`)),e.current&&(0,b.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary`,children:t(`auth.thisDevice`)})]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`auth.lastSeen`,{when:eg(new Date(e.lastSeenAt))}),e.ip?` · ${e.ip}`:``]})]}),!e.current&&(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(e.id),"aria-label":t(`auth.revokeSession`,{name:y_(e.userAgent,t(`auth.unknownDevice`))}),children:t(`auth.revoke`)})]},e.id))})]})}function x_(e,t){return e==null?``:typeof e==`string`?e:e[t]??e[lg.locale]??Object.values(e)[0]??``}function S_(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),n=Object.keys(t);if(n.length!==0)return lg.locales.length===1?t[n[0]]:t}function C_(e){let t=Object.fromEntries(lg.locales.map(e=>[e,``]));return typeof e==`string`?t[lg.locale]=e:e&&Object.assign(t,e),t}function w_({children:e,actions:t}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:e}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]})}function T_({children:e,tone:t=`error`}){return(0,b.jsx)(`p`,{role:t===`error`?`alert`:`status`,className:t===`error`?`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:e})}var E_=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function D_(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:E_(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var O_=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},k_=e=>{let t=O_(e);return t.charAt(0).toUpperCase()+t.slice(1)},A_=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),j_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function M_(e){return e!=null}function N_(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??j_.width,a=e.size??e.height??j_.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?A_(...c):A_(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??j_[`stroke-width`])*Number(e.size??e.width??j_.width)/Number(t.size??t.width??j_.width):t.strokeWidth??j_[`stroke-width`];return[`svg`,{...Object.entries(j_).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&M_(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&M_(t.width)&&{[r(`width`)]:t.width},...`height`in t&&M_(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function P_(e,t={}){return N_(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var F_=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},I_=(0,y.createContext)({}),L_=()=>(0,y.useContext)(I_),R_=(0,y.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=L_()??{},b=!!c||F_(d),[x,S,C=[]]=P_(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:A_(v,s),hasA11yProp:b,attributes:d});return(0,y.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function $(e,t=[],n=[]){let r=typeof e==`string`?D_(e,t,n):e,i=(0,y.forwardRef)(({className:e,...t},n)=>(0,y.createElement)(R_,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=k_(r.name)),i}var z_={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};z_.node;var B_=$(z_),V_={name:`arrow-down-up`,size:24,node:[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]};V_.node;var H_=$(V_),U_={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};U_.node;var W_=$(U_),G_={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};G_.node;var K_=$(G_),q_={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};q_.node;var J_=$(q_),Y_={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Y_.node;var X_=$(Y_),Z_={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Z_.node;var Q_=$(Z_),$_={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};$_.node;var ev=$($_),tv={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};tv.node;var nv=$(tv),rv={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};rv.node;var iv=$(rv),av={name:`briefcase`,size:24,node:[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]};av.node;var ov=$(av),sv={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};sv.node;var cv=$(sv),lv={name:`calendar-days`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M12 13h.01`,key:`y0uutt`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M8 17h.01`,key:`p3bg7i`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M16 17h.01`,key:`ql8jdd`}]]};lv.node;var uv=$(lv),dv={name:`calendar-range`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M17 13h-6`,key:`1qbiup`}],[`path`,{d:`M13 17H7`,key:`1x38vv`}],[`path`,{d:`M7 13h.01`,key:`1vezk1`}],[`path`,{d:`M17 17h.01`,key:`1sd3ek`}]]};dv.node;var fv=$(dv),pv={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};pv.node;var mv=$(pv),hv={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};hv.node;var gv=$(hv),_v={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};_v.node;var vv=$(_v),yv={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};yv.node;var bv=$(yv),xv={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};xv.node;var Sv=$(xv),Cv={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Cv.node;var wv=$(Cv),Tv={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Tv.node;var Ev=$(Tv),Dv={name:`circle-plus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-circle`]};Dv.node;var Ov=$(Dv),kv={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};kv.node;var Av=$(kv),jv={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};jv.node;var Mv=$(jv),Nv={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Nv.node;var Pv=$(Nv),Fv={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};Fv.node;var Iv=$(Fv),Lv={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Lv.node;var Rv=$(Lv),zv={name:`dollar-sign`,size:24,node:[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]};zv.node;var Bv=$(zv),Vv={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Vv.node;var Hv=$(Vv),Uv={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Uv.node;var Wv=$(Uv),Gv={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Gv.node;var Kv=$(Gv),qv={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};qv.node;var Jv=$(qv),Yv={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Yv.node;var Xv=$(Yv),Zv={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Zv.node;var Qv=$(Zv),$v={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};$v.node;var ey=$($v),ty={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};ty.node;var ny=$(ty),ry={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};ry.node;var iy=$(ry),ay={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ay.node;var oy=$(ay),sy={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};sy.node;var cy=$(sy),ly={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};ly.node;var uy=$(ly),dy={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};dy.node;var fy=$(dy),py={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};py.node;var my=$(py),hy={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};hy.node;var gy=$(hy),_y={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};_y.node;var vy=$(_y),yy={name:`key`,size:24,node:[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]};yy.node;var by=$(yy),xy={name:`languages`,size:24,node:[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]};xy.node;var Sy=$(xy),Cy={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Cy.node;var wy=$(Cy),Ty={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};Ty.node;var Ey=$(Ty),Dy={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Dy.node;var Oy=$(Dy),ky={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};ky.node;var Ay=$(ky),jy={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};jy.node;var My=$(jy),Ny={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Ny.node;var Py=$(Ny),Fy={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Fy.node;var Iy=$(Fy),Ly={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Ly.node;var Ry=$(Ly),zy={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};zy.node;var By=$(zy),Vy={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};Vy.node;var Hy=$(Vy),Uy={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Uy.node;var Wy=$(Uy),Gy={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};Gy.node;var Ky=$(Gy),qy={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};qy.node;var Jy=$(qy),Yy={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Yy.node;var Xy=$(Yy),Zy={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Zy.node;var Qy=$(Zy),$y={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};$y.node;var eb=$($y),tb={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};tb.node;var nb=$(tb),rb={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};rb.node;var ib=$(rb),ab={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};ab.node;var ob=$(ab),sb={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};sb.node;var cb=$(sb),lb={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};lb.node;var ub=$(lb),db={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};db.node;var fb=$(db),pb={name:`printer`,size:24,node:[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]};pb.node;var mb=$(pb),hb={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};hb.node;var gb=$(hb),_b={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};_b.node;var vb=$(_b),yb={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};yb.node;var bb=$(yb),xb={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};xb.node;var Sb=$(xb),Cb={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Cb.node;var wb=$(Cb),Tb={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};Tb.node;var Eb=$(Tb),Db={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Db.node;var Ob=$(Db),kb={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};kb.node;var Ab=$(kb),jb={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};jb.node;var Mb=$(jb),Nb={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};Nb.node;var Pb=$(Nb),Fb={name:`shopping-bag`,size:24,node:[[`path`,{d:`M16 10a4 4 0 0 1-8 0`,key:`1ltviw`}],[`path`,{d:`M3.103 6.034h17.794`,key:`awc11p`}],[`path`,{d:`M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z`,key:`o988cm`}]]};Fb.node;var Ib=$(Fb),Lb={name:`shopping-cart`,size:24,node:[[`path`,{d:`m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18`,key:`uebgi3`}],[`path`,{d:`M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25`,key:`1j7c9p`}],[`circle`,{cx:`18`,cy:`20`,r:`2`,key:`t9985n`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};Lb.node;var Rb=$(Lb),zb={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};zb.node;var Bb=$(zb),Vb={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};Vb.node;var Hb=$(Vb),Ub={name:`store`,size:24,node:[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]};Ub.node;var Wb=$(Ub),Gb={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Gb.node;var Kb=$(Gb),qb={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};qb.node;var Jb=$(qb),Yb={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Yb.node;var Xb=$(Yb),Zb={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Zb.node;var Qb=$(Zb),$b={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};$b.node;var ex=$($b),tx={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};tx.node;var nx=$(tx),rx={name:`truck`,size:24,node:[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]};rx.node;var ix=$(rx),ax={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};ax.node;var ox=$(ax),sx={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};sx.node;var cx=$(sx),lx={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};lx.node;var ux=$(lx),dx={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};dx.node;var fx=$(dx),px={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};px.node;var mx=$(px),hx={name:`wallet`,size:24,node:[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]};hx.node;var gx=$(hx),_x={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};_x.node;var vx=$(_x),yx={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};yx.node;var bx=$(yx),xx={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};xx.node;var Sx=$(xx),Cx=/^(-?)(\d+)(?:\.(\d*))?$/,wx=/^-?\d{1,3}(,\d{3})+(\.\d*)?$/;function Tx(e,t){let n=Nh(e).trim(),r=Cx.exec(wx.test(n)?n.replace(/,/g,``):n);if(!r)return e;let[,i,a,o]=r,s=a.replace(/^0+(?=\d)/,``).replace(/\B(?=(\d{3})+$)/g,`,`),c=t===void 0?o??``:(o??``).padEnd(t,`0`);return`${i}${s}${c?`.${c}`:``}`}var Ex;function Dx(e){Ex=e}function Ox(){if(!Ex)return;let{unit:e,position:t}=Ex,n=Yh(),r=typeof e==`string`?e:e[n]??e[n.split(`-`)[0]]??Object.values(e)[0];return r?{unit:r,position:t}:void 0}function kx(e,t={}){let n=t.currency??Ox(),r=e=>$h(Tx(e,t.scale));return{main:r(e),...n?{unit:n.unit,position:n.position}:{},...t.previous===void 0?{}:{previous:r(t.previous)}}}function Ax(e){return e.unit?e.position===`before`?`${e.unit} ${e.main}`:`${e.main} ${e.unit}`:e.main}function jx(e,t){if(e==null)return`—`;if(t.type===`relation`){let t=Array.isArray(e)?e:[e];return t.length===0?`—`:t.map(e=>String(e.title)).join(`, `)}if(t.file)return(Array.isArray(e)?e:[e]).map(e=>String(e).split(`/`).pop()).join(`, `)||`—`;if(t.widget===`richtext`)return Nx(String(e))||`—`;if(t.type===`boolean`)return J(e?`common.yes`:`common.no`);if(t.type===`enum`)return t.enumLabels?.[String(e)]??String(e);if(t.widget===`money`)return Ax(kx(String(e),{currency:t.currency,scale:t.scale}));if(t.type===`number`||t.type===`decimal`||t.type===`bigint`)return $h(String(e));if(t.type===`date`)return ng(String(e));if(t.type===`json`||t.type===`object`)return JSON.stringify(e);if(t.type===`datetime`){let t=new Date(String(e));return Number.isNaN(t.getTime())?String(e):eg(t)}return String(e)}var Mx={amp:`&`,lt:`<`,gt:`>`,quot:`"`,"#39":`'`,nbsp:` `};function Nx(e,t=120){let n=e.replace(/<[^>]*>/g,` `).replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(e,t)=>Mx[t]).replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t).trimEnd()}…`:n}function Px(e,t){let n=e?.groups??[];return{resource:e=>t(e)?.label??n.flatMap(e=>e.resources).find(t=>t.name===e)?.label,page:e=>n.flatMap(e=>e.pages).find(t=>t.name===e)?.label,action:(e,n)=>t(e)?.actions?.find(e=>e.name===n)?.label,softDelete:e=>t(e)?.softDelete}}var Fx={created:`audit.event.created`,updated:`audit.event.updated`,deleted:`audit.event.deleted`,restored:`audit.event.restored`,purged:`audit.event.purged`},Ix={"auth.login":`audit.event.login`,"auth.logout":`audit.event.logout`,"auth.view_as":`audit.event.viewAs`,"auth.password_changed":`audit.event.passwordChanged`,"auth.two_factor_enabled":`audit.event.twoFactorEnabled`,"auth.two_factor_disabled":`audit.event.twoFactorDisabled`,"auth.recovery_codes_regenerated":`audit.event.recoveryCodes`,"rbac.role.changed":`audit.event.roleChanged`,"rbac.group.changed":`audit.event.groupChanged`,"rbac.user_roles.changed":`audit.event.userRolesChanged`,"rbac.user.created":`audit.event.userCreated`,"rbac.user.changed":`audit.event.userChanged`,"rbac.user.password_reset":`audit.event.passwordReset`,"rbac.user.two_factor_reset":`audit.event.twoFactorReset`},Lx={WRONG_CODE:`audit.event.loginFailedCode`,RATE_LIMITED:`audit.event.loginFailedLimited`};function Rx(e){return e.event.startsWith(`*.`)||e.event.startsWith(`page.*.`)}function zx(e){return e.resource!==void 0&&e.event.startsWith(`${e.resource}.`)?e.event.slice(e.resource.length+1):void 0}var Bx=/^page\.(.+)\.updated$/;function Vx(e,t={}){if(Rx(e))return J(`audit.event.unseen`);let n=zx(e);if(n!==void 0){if(n.startsWith(`action.`)&&n.length>7){let r=n.slice(7);return J(`audit.event.action`,{action:t.action?.(e.resource,r)??r})}if(n===`deleted`&&t.softDelete?.(e.resource))return J(`audit.event.trashed`);let r=Fx[n];return r?J(r):e.event}let r=Bx.exec(e.event)?.[1];if(r!==void 0)return J(`audit.event.page`,{page:t.page?.(r)??r});if(e.event===`auth.login_failed`){let t=e.meta?.reason;return t===`SUPPRESSED`?J(`audit.event.loginFailedMore`,{count:e.meta?.suppressed??0}):J(t&&Lx[t]||`audit.event.loginFailed`)}if(e.event===`auth.sessions_revoked`){let t=e.meta?.sessions;return J(t===`others`?`audit.event.sessionsOthers`:t===`one`?`audit.event.sessionsOne`:`audit.event.sessions`)}let i=Ix[e.event];return i?J(i):e.event}function Hx(e){if(e.event===`auth.login_failed`){if(e.meta?.reason===`SUPPRESSED`)return J(`audit.suppressedNote`);if(e.meta?.limited)return J(`audit.limitedNote`)}if(e.meta?.action!==void 0&&e.meta.deleted)return J(`audit.actionDeleted`)}function Ux(e,t={}){if(!Rx(e)){if(e.resource!==void 0){let n=t.resource?.(e.resource)??e.resource;return e.recordId===void 0?n:e.recordTitle!==void 0&&e.recordTitle!==``?`${n}: ${e.recordTitle}`:`${n} #${e.recordId}`}if(e.recordTitle!==void 0&&e.recordTitle!==``)return e.recordTitle;if(e.recordId!==void 0)return e.recordId;if(e.event===`auth.login_failed`&&e.meta?.username)return e.meta.username}}function Wx(e){if(e.restricted&&!Rx(e))return J(e.resource===void 0?`audit.restrictedChanges`:`audit.restrictedRecord`)}function Gx(e,t,n){let r={field:e.field,label:t?.label??e.field};if(`hidden`in e&&e.hidden)return{...r,state:`hidden`,truncated:!1};if(`changed`in e&&e.changed)return{...r,state:`changed`,truncated:!1};let i=e,a=i.truncated===!0;return a&&!(`before`in i)&&!(`after`in i)?{...r,state:`dropped`,truncated:a}:{...r,state:`values`,before:`before`in i&&i.before!==void 0?Yx(i.before,t,n):void 0,after:`after`in i&&i.after!==void 0?Yx(i.after,t,n):void 0,truncated:a}}var Kx=`—`,qx=1e5;function Jx(e){return e==null||e===``?Kx:typeof e==`boolean`?J(e?`common.yes`:`common.no`):typeof e==`string`?e:Array.isArray(e)?e.length===0?Kx:e.every(e=>typeof e!=`object`||!e)?e.map(String).join(`, `):JSON.stringify(e):typeof e==`object`?JSON.stringify(e):String(e)}function Yx(e,t,n){if(e==null||e===``)return Kx;if(!t)return Jx(e);if(t.type===`relation`){let t=Array.isArray(e)?e:[e],r=e=>typeof e==`object`&&e?e.id:e;if(t.some(e=>![`string`,`number`,`bigint`].includes(typeof r(e))))return Jx(e);let i=t.map(e=>String(r(e)));return i.length===0?Kx:i.map(e=>{let t=n?.(e);return t!==void 0&&t!==``&&t!==`#${e}`?`${t} (#${e})`:`#${e}`}).join(`, `)}return t.file?typeof e==`string`||Array.isArray(e)?jx(e,t):Jx(e):t.type===`json`||t.type===`object`?typeof e==`string`?e:JSON.stringify(e):typeof e==`object`?Jx(e):t.widget===`richtext`?Nx(String(e),qx)||Kx:jx(e,t)}var Xx=[`actor`,`event`,`resource`,`record`,`from`,`to`],Zx=/^(\d{4})-(\d{2})-(\d{2})$/;function Qx(e,t){let n=Zx.exec(e);if(!n)return e;let[r,i,a]=[Number(n[1]),Number(n[2]),Number(n[3])],o=t?new Date(r,i-1,a,23,59,59,999):new Date(r,i-1,a,0,0,0,0);return o.getFullYear()===r&&o.getMonth()===i-1&&o.getDate()===a?o.toISOString():e}function $x(e){let t=new URLSearchParams;for(let n of Xx){let r=e.get(n);r!==null&&r!==``&&(n!==`record`||e.get(`resource`))&&t.set(n,n===`from`?Qx(r,!1):n===`to`?Qx(r,!0):r)}return t.sort(),t.toString()}function eS(e){return $x(e)!==``}function tS(e,t){let n=t.trim();return e===`resource`?{resource:n||null,record:null}:{[e]:n||null}}function nS(){return Object.fromEntries(Xx.map(e=>[e,null]))}function rS({entries:e,now:t,names:n,schemaOf:r,pageFieldsOf:i,titleOf:a,onActor:o,showSubject:s=!1}){let{t:c}=Y();return(0,b.jsx)(`ol`,{"aria-label":c(`audit.entries`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:e.map(e=>(0,b.jsx)(aS,{entry:e,now:t,names:n,schema:e.resource===void 0?void 0:r(e.resource),pageFields:e.resource===void 0&&e.meta?.page!==void 0?i?.(e.meta.page):void 0,titleOf:a,onActor:o,showSubject:s},e.id))})}var iS=/\.(deleted|purged)$/;function aS({entry:e,now:t,names:n,schema:r,pageFields:i,titleOf:a,onActor:o,showSubject:s}){let c=r?.fields??i,{t:l}=Y(),u=new Date(e.at),d=!Number.isNaN(u.getTime()),f=s?Ux(e,n):void 0,p=s&&e.resource!==void 0&&e.recordId!==void 0&&!iS.test(e.event)&&!e.meta?.deleted,m=Wx(e),h=Hx(e),g=e.actor?e.actor.name??`#${e.actor.id}`:l(`audit.noActor`),_=e.meta?.input?Object.entries(e.meta.input):[],v=e.meta?.action===void 0?void 0:r?.actions?.find(t=>t.name===oS(e))?.input?.fields,y=[e.meta?.ip,e.meta?.userAgent].filter(Boolean).join(` · `);return(0,b.jsxs)(`li`,{className:`flex flex-col gap-2 px-4 py-3 text-sm`,"data-event":e.event,"data-actor":e.actor?.id??``,"data-anonymous":Rx(e)||void 0,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:Vx(e,n)}),f!==void 0&&(p?(0,b.jsx)(bo,{to:`/${e.resource}/${encodeURIComponent(e.recordId)}`,className:`text-primary hover:underline`,children:f}):(0,b.jsx)(`span`,{children:f}))]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[e.actor&&o?(0,b.jsx)(`button`,{type:`button`,className:`font-medium text-foreground hover:underline`,"aria-label":l(`audit.filterByActor`,{name:g}),onClick:()=>o(e.actor.id),children:g}):(0,b.jsx)(`span`,{className:`font-medium text-foreground`,children:g}),e.viewAsBy!==void 0&&(0,b.jsx)(`span`,{children:l(`audit.viewAsBy`,{id:e.viewAsBy})}),d?(0,b.jsxs)(`time`,{dateTime:e.at,children:[rg(u,t),` · `,eg(u)]}):(0,b.jsx)(`span`,{children:e.at})]}),h!==void 0&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:h}),m!==void 0&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:m}),e.changes!==void 0&&e.changes.length>0&&(0,b.jsx)(`dl`,{"aria-label":l(`audit.changedFields`),className:`grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-[minmax(6rem,auto)_1fr]`,children:e.changes.map(e=>{let t=c?.find(t=>t.name===e.field);return(0,b.jsx)(sS,{row:Gx(e,t,a?t=>a(e.field,t):void 0)},e.field)})}),_.length>0&&(0,b.jsx)(`dl`,{"aria-label":l(`audit.input`),className:`grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-[minmax(6rem,auto)_1fr]`,children:_.map(([e,t])=>{let n=v?.find(t=>t.name===e);return(0,b.jsxs)(`div`,{className:`contents`,"data-input":e,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:n?.label??e}),(0,b.jsx)(`dd`,{className:`min-w-0`,children:(0,b.jsx)(lS,{text:Yx(t,n)})})]},e)})}),e.meta?.inputTruncated&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:l(`audit.inputTruncated`)}),y!==``&&(0,b.jsx)(`p`,{className:`text-xs break-all text-muted-foreground`,dir:`ltr`,"data-client":!0,children:y})]})}function oS(e){let t=`${e.resource}.action.`;return e.event.startsWith(t)?e.event.slice(t.length):void 0}function sS({row:e}){let{t}=Y();return(0,b.jsxs)(`div`,{className:`contents`,"data-change":e.field,"data-state":e.state,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:e.state===`values`?(0,b.jsxs)(b.Fragment,{children:[e.before!==void 0&&(0,b.jsxs)(`span`,{className:`min-w-0 text-muted-foreground line-through decoration-muted-foreground/50`,"data-before":!0,children:[(0,b.jsxs)(`span`,{className:`sr-only`,children:[t(`audit.before`),`: `]}),(0,b.jsx)(lS,{text:e.before})]}),e.before!==void 0&&e.after!==void 0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(K_,{className:`size-3.5 shrink-0 self-center text-muted-foreground rtl:-scale-x-100`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`sr-only`,children:t(`audit.becomes`)})]}),e.after!==void 0&&(0,b.jsxs)(`span`,{className:`min-w-0`,"data-after":!0,children:[e.before===void 0&&(0,b.jsxs)(`span`,{className:`sr-only`,children:[t(`audit.after`),`: `]}),(0,b.jsx)(lS,{text:e.after})]}),e.truncated&&(0,b.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t(`audit.field.truncated`),`)`]})]}):(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:t(`audit.field.${e.state}`)})})]})}var cS=160;function lS({text:e}){let{t}=Y(),[n,r]=(0,y.useState)(!1);return e.length<=cS?(0,b.jsx)(`span`,{dir:`auto`,className:`break-words whitespace-pre-wrap`,children:e}):(0,b.jsxs)(`span`,{dir:`auto`,className:`break-words whitespace-pre-wrap`,children:[n?e:`${e.slice(0,cS).trimEnd()}…`,` `,(0,b.jsx)(q,{type:`button`,variant:`link`,size:`sm`,className:`h-auto p-0 text-xs`,"aria-expanded":n,onClick:()=>r(e=>!e),children:t(n?`audit.showLess`:`audit.showMore`)})]})}var uS=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],dS=(e,t)=>Math.trunc(e/t),fS=(e,t)=>e-Math.trunc(e/t)*t;function pS(e){let t=e+621,n=-14,r=uS[0];if(e<r||e>=uS[uS.length-1])throw RangeError(`Jalali year ${e} is out of range`);let i=0;for(let t=1;t<uS.length;t++){let a=uS[t];if(i=a-r,e<a)break;n+=dS(i,33)*8+dS(fS(i,33),4),r=a}let a=e-r;n+=dS(a,33)*8+dS(fS(a,33)+3,4),fS(i,33)===4&&i-a===4&&(n+=1);let o=dS(t,4)-dS((dS(t,100)+1)*3,4)-150,s=20+n-o;i-a<6&&(a=a-i+dS(i+4,33)*33);let c=fS(fS(a+1,33)-1,4);return c===-1&&(c=4),{leap:c,gy:t,march:s}}function mS(e,t,n){return dS((e+dS(t-8,6)+100100)*1461,4)+dS(153*fS(t+9,12)+2,5)+n-34840408-dS(dS(e+100100+dS(t-8,6),100)*3,4)+752}function hS(e){let t=4*e+139361631;t=t+dS(dS(4*e+183187720,146097)*3,4)*4-3908;let n=dS(fS(t,1461),4)*5+308,r=dS(fS(n,153),5)+1,i=fS(dS(n,153),12)+1;return{gy:dS(t,1461)-100100+dS(8-i,6),gm:i,gd:r}}function gS(e,t,n){let{gy:r,march:i}=pS(e);return mS(r,3,i)+(t-1)*31-dS(t,7)*(t-7)+n-1}function _S(e){let{gy:t}=hS(e),n=t-621,r=pS(n),i=e-mS(t,3,r.march);if(i>=0){if(i<=185)return{jy:n,jm:1+dS(i,31),jd:fS(i,31)+1};i-=186}else--n,i+=179,r.leap===1&&(i+=1);return{jy:n,jm:7+dS(i,30),jd:fS(i,30)+1}}var vS=(e,t=2)=>String(e).padStart(t,`0`),yS=/^(\d{4})-(\d{2})-(\d{2})$/;function bS(e){return pS(e).leap===0}function xS(e,t){return t<=6?31:t<=11||bS(e)?30:29}function SS(e){let t=yS.exec(e);if(!t)throw RangeError(`not an ISO date: ${e}`);return _S(mS(Number(t[1]),Number(t[2]),Number(t[3])))}function CS(e,t,n){let{gy:r,gm:i,gd:a}=hS(gS(e,t,n));return`${vS(r,4)}-${vS(i)}-${vS(a)}`}function wS(e,t,n){return Number.isInteger(e)&&e>=1&&e<3178&&t>=1&&t<=12&&n>=1&&n<=xS(e,t)}function TS(e){let{jy:t,jm:n,jd:r}=SS(e);return`${t}/${vS(n)}/${vS(r)}`}function ES(e){let t=/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/.exec(Mh(e.trim()));if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return wS(n,r,i)?CS(n,r,i):void 0}function DS(e,t){let{jy:n,jm:r,jd:i}=SS(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a%12+1;return CS(o,s,Math.min(i,xS(o,s)))}function OS(e,t){return new Date(Date.parse(`${e}T00:00:00Z`)+t*864e5).toISOString().slice(0,10)}function kS(){let e=new Date;return`${vS(e.getFullYear(),4)}-${vS(e.getMonth()+1)}-${vS(e.getDate())}`}var AS=(e,t=2)=>String(e).padStart(t,`0`),jS=(e,t)=>new Date(Date.UTC(e,t,0)).getUTCDate(),MS={intl:`persian`,parts:e=>{let{jy:t,jm:n,jd:r}=SS(e);return{year:t,month:n,day:r}},fromParts:CS,monthLength:xS,addMonths:DS,format:TS,parse:ES,weekStart:6},NS={intl:`gregory`,parts:e=>({year:Number(e.slice(0,4)),month:Number(e.slice(5,7)),day:Number(e.slice(8,10))}),fromParts:(e,t,n)=>`${AS(e,4)}-${AS(t)}-${AS(n)}`,monthLength:jS,addMonths:(e,t)=>{let{year:n,month:r,day:i}=NS.parts(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a%12+1;return NS.fromParts(o,s,Math.min(i,jS(o,s)))},format:e=>e,parse:e=>{let t=/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/.exec(Mh(e.trim()));if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return n>=1&&r>=1&&r<=12&&i>=1&&i<=jS(n,r)?NS.fromParts(n,r,i):void 0},weekStart:1},PS=e=>e===`persian`?MS:NS,FS=/^\d{4}-\d{2}-\d{2}$/;function IS(e){let{calendar:t}=Y();return(0,b.jsx)(LS,{...e,system:PS(t)})}function LS({id:e,value:t,onChange:n,label:r,live:i,className:a,system:o,...s}){let{t:c,digits:l}=Y(),u=e=>FS.test(e)?$h(o.format(e)):e,[d,f]=(0,y.useState)(()=>u(t)),[p,m]=(0,y.useState)(!1),h=(0,y.useRef)(t);(0,y.useEffect)(()=>{t!==h.current&&(h.current=t,f(u(t)))},[t,l,o]);function g(e){h.current=e,n(e)}function _(){let e=d.trim();if(e===``)return t!==``&&g(``);let n=o.parse(e);n?(f(u(n)),n!==t&&g(n)):i&&g(Mh(e))}function v(e){f(u(e)),m(!1),g(e)}return(0,b.jsxs)(`div`,{className:W(`flex items-center gap-1`,a),children:[(0,b.jsx)(Oh,{id:e,dir:`ltr`,inputMode:`numeric`,placeholder:c(`date.placeholder`),value:d,...s,onChange:e=>{if(f(e.target.value),!i)return;let t=e.target.value.trim();g((t===``?``:o.parse(t))??Mh(t))},onBlur:()=>{_(),s.onBlur?.()},onKeyDown:e=>{e.key===`Enter`&&(_(),i||e.preventDefault()),s.onKeyDown?.(e)}}),(0,b.jsxs)(Sh,{open:p,onOpenChange:m,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":c(`date.openCalendar`,{name:r}),children:(0,b.jsx)(uv,{})})}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`end`,sideOffset:4,className:`z-50 rounded-lg border bg-popover p-3 text-popover-foreground shadow-md`,"aria-label":c(`date.calendar`,{name:r}),children:(0,b.jsx)(RS,{system:o,value:FS.test(t)?t:void 0,onPick:v,onClear:()=>v(``)})})})]})]})}function RS({system:e,value:t,onPick:n,onClear:r}){let{t:i,locale:a}=Y(),o=kS(),[s,c]=(0,y.useState)(t??o),[l,u]=(0,y.useState)(`days`),d=(0,y.useRef)(null),f=(0,y.useRef)(!1),{year:p,month:m}=e.parts(s),h=Xh(a);(0,y.useEffect)(()=>{f.current&&(f.current=!1,d.current?.querySelector(`[data-iso="${s}"]`)?.focus())},[s]);let g=t=>new Intl.DateTimeFormat(`${a}-u-ca-${e.intl}`,{month:`long`,timeZone:`UTC`}).format(Date.parse(`${e.fromParts(p,t,1)}T00:00:00Z`)),_=e=>$h(String(e)),v=OS(`2024-01-07`,e.weekStart),x=Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(a,{weekday:`narrow`,timeZone:`UTC`}).format(Date.parse(`${OS(v,t)}T00:00:00Z`))),S=e.fromParts(p,m,1),C=(new Date(`${S}T00:00:00Z`).getUTCDay()-e.weekStart+7)%7,w=e.monthLength(p,m),T=[...Array.from({length:C},()=>null),...Array.from({length:w},(e,t)=>OS(S,t))];function E(t){let n={ArrowRight:h?-1:1,ArrowLeft:h?1:-1,ArrowDown:7,ArrowUp:-7},r;t.key in n?r=OS(s,n[t.key]):t.key===`PageDown`?r=e.addMonths(s,t.shiftKey?12:1):t.key===`PageUp`&&(r=e.addMonths(s,t.shiftKey?-12:-1)),r&&(t.preventDefault(),f.current=!0,c(r))}let D=(e,t,n,r)=>(0,b.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i(`date.previous`),onClick:()=>n(-1),children:(0,b.jsx)(Sv,{className:`rtl:rotate-180`})}),t?(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":r,onClick:t,children:e}):(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:e}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i(`date.next`),onClick:()=>n(1),children:(0,b.jsx)(wv,{className:`rtl:rotate-180`})})]}),O;if(l===`years`){let t=p-p%12;O=(0,b.jsxs)(b.Fragment,{children:[D(`${_(t)}–${_(t+11)}`,void 0,t=>c(e.addMonths(s,t*144)),``),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Array.from({length:12},(e,n)=>t+n).map(t=>(0,b.jsx)(q,{type:`button`,variant:t===p?`secondary`:`ghost`,size:`sm`,onClick:()=>{c(e.fromParts(t,m,Math.min(e.parts(s).day,e.monthLength(t,m)))),u(`months`)},children:_(t)},t))})]})}else O=l===`months`?(0,b.jsxs)(b.Fragment,{children:[D(_(p),()=>u(`years`),t=>c(e.addMonths(s,t*12)),i(`date.chooseYear`)),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Array.from({length:12},(e,t)=>t+1).map(t=>(0,b.jsx)(q,{type:`button`,variant:t===m?`secondary`:`ghost`,size:`sm`,onClick:()=>{c(e.fromParts(p,t,Math.min(e.parts(s).day,e.monthLength(p,t)))),u(`days`)},children:g(t)},t))})]}):(0,b.jsxs)(b.Fragment,{children:[D(`${g(m)} ${_(p)}`,()=>u(`months`),t=>c(e.addMonths(s,t)),i(`date.chooseMonth`)),(0,b.jsxs)(`div`,{ref:d,role:`grid`,"aria-label":`${g(m)} ${_(p)}`,onKeyDown:E,className:`grid grid-cols-7 gap-0.5 text-center`,children:[(0,b.jsx)(`div`,{role:`row`,className:`contents`,children:x.map((e,t)=>(0,b.jsx)(`div`,{role:`columnheader`,className:`py-1 text-xs text-muted-foreground`,children:e},t))}),Array.from({length:Math.ceil(T.length/7)},(r,i)=>(0,b.jsx)(`div`,{role:`row`,className:`contents`,children:T.slice(i*7,i*7+7).map((r,a)=>r?(0,b.jsx)(`div`,{role:`gridcell`,"aria-selected":r===t,children:(0,b.jsx)(`button`,{type:`button`,"data-iso":r,tabIndex:r===s?0:-1,"aria-label":ng(r),"aria-current":r===o?`date`:void 0,onClick:()=>n(r),className:W(`size-8 rounded-md text-sm hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,r===o&&`font-semibold text-primary`,r===t&&`bg-primary text-primary-foreground hover:bg-primary/90`),children:_(e.parts(r).day)})},r):(0,b.jsx)(`div`,{role:`gridcell`},`empty-${i}-${a}`))},i))]})]});return(0,b.jsxs)(`div`,{className:`flex w-64 flex-col`,children:[O,(0,b.jsxs)(`div`,{className:`mt-2 flex justify-between gap-2 border-t pt-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(o),children:i(`date.today`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:i(`date.clear`)})]})]})}function zS({id:e,value:t,onChange:n,label:r,...i}){let{t:a}=Y(),[o=``,s=``]=t.split(`T`),c=(e,t)=>n(e===``?``:`${e}T${t||`00:00`}`);return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(IS,{id:e,live:!0,value:o,label:r,onChange:e=>c(e,s),className:`min-w-44 flex-1`,...i}),(0,b.jsx)(Oh,{type:`time`,dir:`ltr`,"aria-label":a(`date.time`,{name:r}),className:`w-28`,value:s,onChange:e=>c(o,e.target.value)})]})}function BS(e,t){let[n,r]=(0,y.useState)(e);return(0,y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var VS=(e,t)=>String(e.id)===String(t.id);function HS({id:e,resource:t,field:n,value:r,onChange:i,clearable:a,values:o,parent:s,invalid:c,describedBy:l}){let u=X(),d=n.relation?.kind===`to-many`,f=d&&Array.isArray(r)?r:[],p=!d&&r&&!Array.isArray(r)?r:null,[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(!1),[v,x]=(0,y.useState)(0),S=BS(m.trim(),250),C=Yg(t,n.name,S,g,o,s),w=(C.data?.items??[]).filter(e=>!f.some(t=>VS(t,e))),T=`${e}-options`,E=t=>`${e}-option-${t}`;(0,y.useEffect)(()=>{x(0)},[S,C.data]);function D(e){h(``),_(!1),i(d?[...f,e]:e)}function O(e){e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),g?x(t=>Math.max(0,Math.min(w.length-1,t+(e.key===`ArrowDown`?1:-1)))):_(!0)):e.key===`Enter`&&g?(e.preventDefault(),w[v]&&D(w[v])):e.key===`Escape`&&g?(e.preventDefault(),_(!1),h(``)):e.key===`Backspace`&&d&&m===``&&f.length>0&&i(f.slice(0,-1))}return(0,b.jsxs)(`div`,{className:`relative flex flex-col gap-1.5`,children:[d&&f.length>0&&(0,b.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":u(`picker.selected`,{name:n.label}),children:f.map(e=>(0,b.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md bg-muted py-0.5 ps-2 pe-1 text-sm`,children:[e.title,(0,b.jsx)(`button`,{type:`button`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,"aria-label":u(`picker.remove`,{name:e.title}),onClick:()=>i(f.filter(t=>!VS(t,e))),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},String(e.id)))}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(Oh,{id:e,role:`combobox`,autoComplete:`off`,"aria-autocomplete":`list`,"aria-expanded":g,"aria-controls":T,"aria-activedescendant":g&&w[v]?E(v):void 0,"aria-invalid":c||void 0,"aria-describedby":l,className:W(p&&a&&`pe-8`),placeholder:p?p.title:u(d?`picker.typeToAdd`:`picker.typeToSearch`),value:g||m?m:p?.title??``,onChange:e=>{h(e.target.value),_(!0)},onFocus:()=>_(!0),onBlur:()=>{_(!1),h(``)},onKeyDown:O}),p&&a&&(0,b.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 end-0 flex items-center px-2 text-muted-foreground hover:text-foreground`,"aria-label":u(`picker.clear`,{name:n.label}),onClick:()=>i(null),children:(0,b.jsx)(bx,{className:`size-4`})})]}),g&&(0,b.jsxs)(`div`,{className:`absolute inset-x-0 top-full z-20 mt-1 max-h-60 overflow-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:[(0,b.jsx)(`ul`,{id:T,role:`listbox`,"aria-label":n.label,children:w.map((e,t)=>(0,b.jsx)(`li`,{id:E(t),role:`option`,"aria-selected":t===v,className:W(`cursor-pointer rounded-md px-2 py-1.5 text-sm`,t===v&&`bg-accent text-accent-foreground`),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>x(t),onClick:()=>D(e),children:e.title},String(e.id)))}),w.length===0&&(0,b.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:C.isError?dg(C.error):u(C.isFetching||C.isPending?`picker.searching`:`picker.noMatches`)})]})]})}var US=new Set([`page`,`pageSize`,`sort`,`search`,`trashed`,`after`,`tab`]),WS=e=>US.has(e)||e.startsWith(`filter[`);function GS(e){let t=new URLSearchParams;for(let[n,r]of e)r!==``&&WS(n)&&t.append(n,r);return t.sort(),t.toString()}function KS(e,t){return`filter[${e}][${t}]`}function qS(e){return[...e.keys()].some(e=>e===`search`||e.startsWith(`filter[`))}function JS(e){let t={};for(let n of e.keys())(n===`search`||n.startsWith(`filter[`))&&(t[n]=null);return t}function YS(e,t){let n=new URLSearchParams(e);Object.keys(t).some(e=>e!==`page`&&e!==`after`)&&(n.delete(`page`),n.delete(`after`));for(let[e,r]of Object.entries(t))r===null?n.delete(e):n.set(e,r);return n}function XS(e,t){if(!e)return{summary:``,label:J(`list.page`,{page:t}),hasNext:!1};if(e.total===null)return{summary:``,label:J(`list.page`,{page:t}),hasNext:e.hasMore===!0};let n=Math.max(1,Math.ceil(e.total/e.pageSize)),r=Qh(e.total);return{summary:J(e.estimated?`list.about`:`list.total`,{count:r}),label:e.estimated?J(`list.page`,{page:t}):J(`list.pageOf`,{page:t,pages:n}),hasNext:t<n}}function ZS(e,t,n){if(!e||e.total===null||e.total===0)return``;if(e.estimated)return J(`list.about`,{count:Qh(e.total)});let r=(t-1)*e.pageSize+1;return J(`list.range`,{from:Qh(r),to:Qh(r+Math.max(n,1)-1),total:Qh(e.total)})}function QS(e){return[...new Set([10,20,50,100,e])].filter(e=>e<=100).sort((e,t)=>e-t)}function $S(e){let t=new Set;for(let[n,r]of e){let e=/^filter\[([^\][]+)\]/.exec(n);e&&r!==``&&t.add(e[1])}return t.size}function eC(e,t){let n=e=>e===`search`||e===`sort`||e.startsWith(`filter[`),r={};for(let i of new Set([...e.keys(),...t.keys()]))n(i)&&e.get(i)!==t.get(i)&&(r[i]=t.get(i));return Object.fromEntries(Object.entries(r).sort(([e],[t])=>e.localeCompare(t)))}function tC(e){return new Map([...e].filter(([e,t])=>e.startsWith(`filter[`)&&t!==``))}function nC(e,t){let n=tC(t),r=t.get(`tab`);return e?.find(e=>{if((e.where?e.key:null)!==r)return!1;let t=Object.entries(e.filter);return t.length===n.size&&t.every(([e,t])=>n.get(e)===t)})}function rC(e,t){let n={};for(let e of tC(t).keys())n[e]=null;return t.has(`tab`)&&(n.tab=null),Object.assign(n,e.filter),e.where?n.tab=e.key:t.has(`tab`)&&(n.tab=null),n}var iC=/^filter\[([^\][]+)\]\[([^\][]+)\]$/;function aC(e,t){if(e.type===`boolean`)return J(t===`true`?`common.yes`:`common.no`);if(e.type===`enum`)return e.enumLabels?.[t]??t;if(e.type===`date`)return ng(t);if(e.type===`number`||e.type===`decimal`||e.type===`bigint`)return $h(t);if(e.type===`datetime`){let e=new Date(t);return Number.isNaN(e.getTime())?t:eg(e)}return t}function oC(e,t){let n=[],r=t.get(`search`);r&&n.push({key:`search`,label:J(`filters.search`),value:`“${r}”`,remove:[`search`]});let i=sC(e,t),a=new Map;for(let[e,n]of t){if(i[e]===n)continue;let t=iC.exec(e);if(!t||n===``)continue;let[,r,o]=t;a.set(r,[...a.get(r)??[],{operator:o,raw:n,key:e}])}for(let[t,r]of a){let i=e.fields.find(e=>e.name===t);if(!i)continue;let a=[],o,s=r.find(e=>e.operator===`gte`||e.operator===`gt`),c=r.find(e=>e.operator===`lte`||e.operator===`lt`);s&&c&&a.push(`${aC(i,s.raw)} – ${aC(i,c.raw)}`);for(let{operator:e,raw:n}of r){if((e===`gte`||e===`gt`||e===`lte`||e===`lt`)&&s&&c)continue;let r=n.split(`,`).map(e=>aC(i,e));if(i.type===`relation`&&[`eq`,`ne`,`in`,`nin`].includes(e)){let r=e===`ne`||e===`nin`?J(`filters.not`):``;o={field:t,ids:n.split(`,`),prefix:r},a.push(`${r}${n.split(`,`).map(e=>`#${e}`).join(`, `)}`);continue}switch(e){case`isNull`:a.push(J(n===`true`?`filters.empty`:`filters.notEmpty`));break;case`ne`:case`nin`:a.push(`${J(`filters.not`)}${r.join(`, `)}`);break;case`gte`:case`gt`:a.push(`≥ ${r[0]}`);break;case`lte`:case`lt`:a.push(`≤ ${r[0]}`);break;case`between`:a.push(r.join(` – `));break;case`contains`:a.push(`“${n}”`);break;case`startsWith`:a.push(`${n}…`);break;default:a.push(r.join(`, `))}}n.push({key:`filter:${t}`,label:i.label,value:a.join(`; `),...o?{ref:o}:{},remove:r.map(e=>e.key)})}return n}function sC(e,t){return nC(e.list?.tabs,t)?.filter??{}}var cC=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},lC=e=>Array.isArray(e)?e:[];function uC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`title`in e}function dC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`name`in e&&`size`in e&&(`key`in e||`token`in e)}function fC(e){return(Array.isArray(e)?e:[e]).filter(dC)}function pC(e,t){let n=e?._files?.[t];return n==null?[]:Array.isArray(n)?n:[n]}var mC=e=>e.token===void 0?`key:${e.key}`:`token:${e.token}`,hC=e=>e.token===void 0?{key:e.key}:{token:e.token},gC=(e,t)=>{let n=new Set(e.map(e=>String(e.id)));return e.length===t.length&&t.every(e=>n.has(String(e.id)))},_C=/<img\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;function vC(e){return e.replace(_C,``)}var yC=e=>String(e).padStart(2,`0`);function bC(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${yC(t.getMonth()+1)}-${yC(t.getDate())}T${yC(t.getHours())}:${yC(t.getMinutes())}`}function xC(e,t){let n={};for(let r of e){let e=t?.[r.name];if(r.file){let e=pC(t,r.name).map(({key:e,name:t,size:n,contentType:r,url:i})=>({key:e,name:t,size:n,contentType:r,url:i}));n[r.name]=r.file.many?e:e[0]??null}else if(r.type===`object`){let t=r.fields??[];n[r.name]=r.many?(Array.isArray(e)?e:[]).map(e=>xC(t,e)):xC(t,e??void 0)}else r.relation?.kind===`to-many`?n[r.name]=Array.isArray(e)?e.filter(uC):[]:r.type===`relation`?n[r.name]=uC(e)?e:null:r.type===`boolean`?n[r.name]=e===!0:e==null?n[r.name]=``:r.type===`json`?n[r.name]=JSON.stringify(e,null,2):r.type===`datetime`?n[r.name]=bC(String(e)):r.widget===`money`?n[r.name]=Tx(String(e),r.scale):n[r.name]=String(e)}return n}function SC(e,t){let n=/^-?\d{1,3}(,\d{3})+(\.\d+)?$/.test(e)?e.replace(/,/g,``):e;if((t?/^-?\d+$/:/^-?\d+(\.\d+)?$/).test(n))return n}function CC(e,t,n,r=``){let i={},a={};for(let o of e){let e=t[o.name];if(n&&e===n[o.name])continue;let s=`${r}${o.name}`;if(o.type===`object`){let t=o.fields??[];if(o.many){let r=lC(e).map((e,n)=>CC(t,e,void 0,`${s}.${n}.`));for(let e of r)Object.assign(a,e.errors);let c=r.map(e=>e.payload),l=n?lC(n[o.name]).map(e=>CC(t,e).payload):void 0;(l?JSON.stringify(l)!==JSON.stringify(c):c.length>0)&&(i[o.name]=c);continue}let r=CC(t,cC(e),n?cC(n[o.name]):void 0,`${s}.`);Object.assign(a,r.errors),(Object.keys(r.payload).length>0||!n&&!o.nullable)&&(i[o.name]=r.payload);continue}if(o.file){let t=fC(e),r=n?fC(n[o.name]):void 0;if(r&&t.map(mC).join(`
|
|
53
|
+
`)).then(()=>u(!0),()=>void 0)},children:e(l?`twoFactor.copied`:`twoFactor.copy`)}),(0,b.jsx)(q,{type:`button`,size:`sm`,onClick:()=>{c(null),u(!1)},children:e(`twoFactor.done`)})]})]}),n.data&&!w&&!T&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.intro`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:_.isPending,onClick:()=>_.mutate(),children:e(`twoFactor.setUp`)})]}),!w&&T&&(0,b.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),r.trim()&&v.mutate()},children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.scan`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,b.jsx)(h_,{text:T.otpauthUrl,label:e(`twoFactor.qr`)}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`twoFactor.key`)}),(0,b.jsx)(`code`,{dir:`ltr`,"data-testid":`two-factor-key`,className:`break-all font-mono`,children:T.secret.match(/.{1,4}/g).join(` `)})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`two-factor-code`,children:e(`twoFactor.code`)}),(0,b.jsx)(Oh,{id:`two-factor-code`,autoComplete:`one-time-code`,inputMode:`numeric`,dir:`ltr`,maxLength:10,value:r,onChange:e=>i(e.target.value)})]}),(0,b.jsx)(q,{type:`submit`,disabled:v.isPending||!r.trim(),children:e(`twoFactor.turnOn`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,onClick:()=>_.reset(),children:e(`common.cancel`)})]})]}),w&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`twoFactor.left`,{count:n.data.recoveryCodesLeft})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`two-factor-password`,children:e(`twoFactor.password`)}),(0,b.jsx)(Oh,{id:`two-factor-password`,type:`password`,autoComplete:`current-password`,value:a,onChange:e=>o(e.target.value)})]}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:!a||x.isPending,onClick:()=>x.mutate(),children:e(`twoFactor.newCodes`)}),(0,b.jsx)(q,{type:`button`,variant:`destructive`,disabled:!a||C.isPending,onClick:()=>C.mutate(),children:e(`twoFactor.turnOff`)})]})]})]})}function y_(e,t){return e?[/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:void 0,/Android/.test(e)?`Android`:/iPhone|iPad/.test(e)?`iOS`:/Mac OS X/.test(e)?`macOS`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:void 0].filter(Boolean).join(` · `)||e.slice(0,40):t}function b_({revokeOthers:e}){let{t}=Y(),n=S(),r=ft({queryKey:[`account-sessions`],queryFn:Q.sessions}),i=()=>n.invalidateQueries({queryKey:[`account-sessions`]}),a=pt({mutationFn:e=>Q.revokeSession(e),onSuccess:i}),o=pt({mutationFn:()=>Q.revokeOtherSessions(),onSuccess:i}),s=r.data?.items??[],c=a.error??o.error??r.error;return(0,b.jsxs)(`section`,{"aria-labelledby":`sessions-title`,className:`flex flex-col gap-3 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h2`,{id:`sessions-title`,className:`font-medium`,children:t(`auth.sessions`)}),e&&s.length>1&&(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(),children:t(`auth.signOutOthers`)})]}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:dg(c)}),(0,b.jsx)(`ul`,{"aria-label":t(`auth.sessions`),className:`flex flex-col divide-y`,children:s.map(e=>(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 py-2 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,title:e.userAgent,children:[y_(e.userAgent,t(`auth.unknownDevice`)),e.current&&(0,b.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary`,children:t(`auth.thisDevice`)})]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`auth.lastSeen`,{when:eg(new Date(e.lastSeenAt))}),e.ip?` · ${e.ip}`:``]})]}),!e.current&&(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(e.id),"aria-label":t(`auth.revokeSession`,{name:y_(e.userAgent,t(`auth.unknownDevice`))}),children:t(`auth.revoke`)})]},e.id))})]})}function x_(e,t){return e==null?``:typeof e==`string`?e:e[t]??e[lg.locale]??Object.values(e)[0]??``}function S_(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.trim()!==``).map(([e,t])=>[e,t.trim()])),n=Object.keys(t);if(n.length!==0)return lg.locales.length===1?t[n[0]]:t}function C_(e){let t=Object.fromEntries(lg.locales.map(e=>[e,``]));return typeof e==`string`?t[lg.locale]=e:e&&Object.assign(t,e),t}function w_({children:e,actions:t}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:e}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]})}function T_({children:e,tone:t=`error`}){return(0,b.jsx)(`p`,{role:t===`error`?`alert`:`status`,className:t===`error`?`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:e})}var E_=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function D_(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:E_(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var O_=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},k_=e=>{let t=O_(e);return t.charAt(0).toUpperCase()+t.slice(1)},A_=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),j_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function M_(e){return e!=null}function N_(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??j_.width,a=e.size??e.height??j_.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?A_(...c):A_(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??j_[`stroke-width`])*Number(e.size??e.width??j_.width)/Number(t.size??t.width??j_.width):t.strokeWidth??j_[`stroke-width`];return[`svg`,{...Object.entries(j_).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&M_(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&M_(t.width)&&{[r(`width`)]:t.width},...`height`in t&&M_(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function P_(e,t={}){return N_(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var F_=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},I_=(0,y.createContext)({}),L_=()=>(0,y.useContext)(I_),R_=(0,y.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=L_()??{},b=!!c||F_(d),[x,S,C=[]]=P_(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:A_(v,s),hasA11yProp:b,attributes:d});return(0,y.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function $(e,t=[],n=[]){let r=typeof e==`string`?D_(e,t,n):e,i=(0,y.forwardRef)(({className:e,...t},n)=>(0,y.createElement)(R_,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=k_(r.name)),i}var z_={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};z_.node;var B_=$(z_),V_={name:`arrow-down-up`,size:24,node:[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]};V_.node;var H_=$(V_),U_={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};U_.node;var W_=$(U_),G_={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};G_.node;var K_=$(G_),q_={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};q_.node;var J_=$(q_),Y_={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Y_.node;var X_=$(Y_),Z_={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Z_.node;var Q_=$(Z_),$_={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};$_.node;var ev=$($_),tv={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};tv.node;var nv=$(tv),rv={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};rv.node;var iv=$(rv),av={name:`briefcase`,size:24,node:[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]};av.node;var ov=$(av),sv={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};sv.node;var cv=$(sv),lv={name:`calendar-days`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M12 13h.01`,key:`y0uutt`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M8 17h.01`,key:`p3bg7i`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M16 17h.01`,key:`ql8jdd`}]]};lv.node;var uv=$(lv),dv={name:`calendar-range`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M17 13h-6`,key:`1qbiup`}],[`path`,{d:`M13 17H7`,key:`1x38vv`}],[`path`,{d:`M7 13h.01`,key:`1vezk1`}],[`path`,{d:`M17 17h.01`,key:`1sd3ek`}]]};dv.node;var fv=$(dv),pv={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};pv.node;var mv=$(pv),hv={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};hv.node;var gv=$(hv),_v={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};_v.node;var vv=$(_v),yv={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};yv.node;var bv=$(yv),xv={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};xv.node;var Sv=$(xv),Cv={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Cv.node;var wv=$(Cv),Tv={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Tv.node;var Ev=$(Tv),Dv={name:`circle-plus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-circle`]};Dv.node;var Ov=$(Dv),kv={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};kv.node;var Av=$(kv),jv={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};jv.node;var Mv=$(jv),Nv={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Nv.node;var Pv=$(Nv),Fv={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};Fv.node;var Iv=$(Fv),Lv={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Lv.node;var Rv=$(Lv),zv={name:`dollar-sign`,size:24,node:[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]};zv.node;var Bv=$(zv),Vv={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Vv.node;var Hv=$(Vv),Uv={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Uv.node;var Wv=$(Uv),Gv={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Gv.node;var Kv=$(Gv),qv={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};qv.node;var Jv=$(qv),Yv={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Yv.node;var Xv=$(Yv),Zv={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Zv.node;var Qv=$(Zv),$v={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};$v.node;var ey=$($v),ty={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};ty.node;var ny=$(ty),ry={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};ry.node;var iy=$(ry),ay={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ay.node;var oy=$(ay),sy={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};sy.node;var cy=$(sy),ly={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};ly.node;var uy=$(ly),dy={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};dy.node;var fy=$(dy),py={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};py.node;var my=$(py),hy={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};hy.node;var gy=$(hy),_y={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};_y.node;var vy=$(_y),yy={name:`key`,size:24,node:[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]};yy.node;var by=$(yy),xy={name:`languages`,size:24,node:[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]};xy.node;var Sy=$(xy),Cy={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Cy.node;var wy=$(Cy),Ty={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};Ty.node;var Ey=$(Ty),Dy={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Dy.node;var Oy=$(Dy),ky={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};ky.node;var Ay=$(ky),jy={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};jy.node;var My=$(jy),Ny={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Ny.node;var Py=$(Ny),Fy={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Fy.node;var Iy=$(Fy),Ly={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Ly.node;var Ry=$(Ly),zy={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};zy.node;var By=$(zy),Vy={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};Vy.node;var Hy=$(Vy),Uy={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Uy.node;var Wy=$(Uy),Gy={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};Gy.node;var Ky=$(Gy),qy={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};qy.node;var Jy=$(qy),Yy={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Yy.node;var Xy=$(Yy),Zy={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Zy.node;var Qy=$(Zy),$y={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};$y.node;var eb=$($y),tb={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};tb.node;var nb=$(tb),rb={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};rb.node;var ib=$(rb),ab={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};ab.node;var ob=$(ab),sb={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};sb.node;var cb=$(sb),lb={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};lb.node;var ub=$(lb),db={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};db.node;var fb=$(db),pb={name:`printer`,size:24,node:[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]};pb.node;var mb=$(pb),hb={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};hb.node;var gb=$(hb),_b={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};_b.node;var vb=$(_b),yb={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};yb.node;var bb=$(yb),xb={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};xb.node;var Sb=$(xb),Cb={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Cb.node;var wb=$(Cb),Tb={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};Tb.node;var Eb=$(Tb),Db={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Db.node;var Ob=$(Db),kb={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};kb.node;var Ab=$(kb),jb={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};jb.node;var Mb=$(jb),Nb={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};Nb.node;var Pb=$(Nb),Fb={name:`shopping-bag`,size:24,node:[[`path`,{d:`M16 10a4 4 0 0 1-8 0`,key:`1ltviw`}],[`path`,{d:`M3.103 6.034h17.794`,key:`awc11p`}],[`path`,{d:`M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z`,key:`o988cm`}]]};Fb.node;var Ib=$(Fb),Lb={name:`shopping-cart`,size:24,node:[[`path`,{d:`m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18`,key:`uebgi3`}],[`path`,{d:`M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25`,key:`1j7c9p`}],[`circle`,{cx:`18`,cy:`20`,r:`2`,key:`t9985n`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};Lb.node;var Rb=$(Lb),zb={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};zb.node;var Bb=$(zb),Vb={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};Vb.node;var Hb=$(Vb),Ub={name:`store`,size:24,node:[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]};Ub.node;var Wb=$(Ub),Gb={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Gb.node;var Kb=$(Gb),qb={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};qb.node;var Jb=$(qb),Yb={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Yb.node;var Xb=$(Yb),Zb={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Zb.node;var Qb=$(Zb),$b={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};$b.node;var ex=$($b),tx={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};tx.node;var nx=$(tx),rx={name:`truck`,size:24,node:[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]};rx.node;var ix=$(rx),ax={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};ax.node;var ox=$(ax),sx={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};sx.node;var cx=$(sx),lx={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};lx.node;var ux=$(lx),dx={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};dx.node;var fx=$(dx),px={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};px.node;var mx=$(px),hx={name:`wallet`,size:24,node:[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]};hx.node;var gx=$(hx),_x={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};_x.node;var vx=$(_x),yx={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};yx.node;var bx=$(yx),xx={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};xx.node;var Sx=$(xx),Cx=/^(-?)(\d+)(?:\.(\d*))?$/,wx=/^-?\d{1,3}(,\d{3})+(\.\d*)?$/;function Tx(e,t){let n=Nh(e).trim(),r=Cx.exec(wx.test(n)?n.replace(/,/g,``):n);if(!r)return e;let[,i,a,o]=r,s=a.replace(/^0+(?=\d)/,``).replace(/\B(?=(\d{3})+$)/g,`,`),c=t===void 0?o??``:(o??``).padEnd(t,`0`);return`${i}${s}${c?`.${c}`:``}`}var Ex;function Dx(e){Ex=e}function Ox(){if(!Ex)return;let{unit:e,position:t}=Ex,n=Yh(),r=typeof e==`string`?e:e[n]??e[n.split(`-`)[0]]??Object.values(e)[0];return r?{unit:r,position:t}:void 0}function kx(e,t={}){let n=t.currency??Ox(),r=e=>$h(Tx(e,t.scale));return{main:r(e),...n?{unit:n.unit,position:n.position}:{},...t.previous===void 0?{}:{previous:r(t.previous)}}}function Ax(e){return e.unit?e.position===`before`?`${e.unit} ${e.main}`:`${e.main} ${e.unit}`:e.main}function jx(e,t){if(e==null)return`—`;if(t.type===`relation`){let t=Array.isArray(e)?e:[e];return t.length===0?`—`:t.map(e=>String(e.title)).join(`, `)}if(t.file)return(Array.isArray(e)?e:[e]).map(e=>String(e).split(`/`).pop()).join(`, `)||`—`;if(t.widget===`richtext`)return Nx(String(e))||`—`;if(t.type===`boolean`)return J(e?`common.yes`:`common.no`);if(t.type===`enum`)return t.enumLabels?.[String(e)]??String(e);if(t.widget===`money`)return Ax(kx(String(e),{currency:t.currency,scale:t.scale}));if(t.type===`number`||t.type===`decimal`||t.type===`bigint`)return $h(String(e));if(t.type===`date`)return ng(String(e));if(t.type===`json`||t.type===`object`)return JSON.stringify(e);if(t.type===`datetime`){let t=new Date(String(e));return Number.isNaN(t.getTime())?String(e):eg(t)}return String(e)}var Mx={amp:`&`,lt:`<`,gt:`>`,quot:`"`,"#39":`'`,nbsp:` `};function Nx(e,t=120){let n=e.replace(/<[^>]*>/g,` `).replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(e,t)=>Mx[t]).replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t).trimEnd()}…`:n}function Px(e,t){let n=e?.groups??[];return{resource:e=>t(e)?.label??n.flatMap(e=>e.resources).find(t=>t.name===e)?.label,page:e=>n.flatMap(e=>e.pages).find(t=>t.name===e)?.label,action:(e,n)=>t(e)?.actions?.find(e=>e.name===n)?.label,softDelete:e=>t(e)?.softDelete}}var Fx={created:`audit.event.created`,updated:`audit.event.updated`,deleted:`audit.event.deleted`,restored:`audit.event.restored`,purged:`audit.event.purged`},Ix={"auth.login":`audit.event.login`,"auth.logout":`audit.event.logout`,"auth.view_as":`audit.event.viewAs`,"auth.password_changed":`audit.event.passwordChanged`,"auth.two_factor_enabled":`audit.event.twoFactorEnabled`,"auth.two_factor_disabled":`audit.event.twoFactorDisabled`,"auth.recovery_codes_regenerated":`audit.event.recoveryCodes`,"rbac.role.changed":`audit.event.roleChanged`,"rbac.group.changed":`audit.event.groupChanged`,"rbac.user_roles.changed":`audit.event.userRolesChanged`,"rbac.user.created":`audit.event.userCreated`,"rbac.user.changed":`audit.event.userChanged`,"rbac.user.password_reset":`audit.event.passwordReset`,"rbac.user.two_factor_reset":`audit.event.twoFactorReset`},Lx={WRONG_CODE:`audit.event.loginFailedCode`,RATE_LIMITED:`audit.event.loginFailedLimited`};function Rx(e){return e.event.startsWith(`*.`)||e.event.startsWith(`page.*.`)}function zx(e){return e.resource!==void 0&&e.event.startsWith(`${e.resource}.`)?e.event.slice(e.resource.length+1):void 0}var Bx=/^page\.(.+)\.updated$/;function Vx(e,t={}){if(Rx(e))return J(`audit.event.unseen`);let n=zx(e);if(n!==void 0){if(n.startsWith(`action.`)&&n.length>7){let r=n.slice(7);return J(`audit.event.action`,{action:t.action?.(e.resource,r)??r})}if(n===`deleted`&&t.softDelete?.(e.resource))return J(`audit.event.trashed`);let r=Fx[n];return r?J(r):e.event}let r=Bx.exec(e.event)?.[1];if(r!==void 0)return J(`audit.event.page`,{page:t.page?.(r)??r});if(e.event===`auth.login_failed`){let t=e.meta?.reason;return t===`SUPPRESSED`?J(`audit.event.loginFailedMore`,{count:e.meta?.suppressed??0}):J(t&&Lx[t]||`audit.event.loginFailed`)}if(e.event===`auth.sessions_revoked`){let t=e.meta?.sessions;return J(t===`others`?`audit.event.sessionsOthers`:t===`one`?`audit.event.sessionsOne`:`audit.event.sessions`)}let i=Ix[e.event];return i?J(i):e.event}function Hx(e){if(e.event===`auth.login_failed`){if(e.meta?.reason===`SUPPRESSED`)return J(`audit.suppressedNote`);if(e.meta?.limited)return J(`audit.limitedNote`)}if(e.meta?.action!==void 0&&e.meta.deleted)return J(`audit.actionDeleted`)}function Ux(e,t={}){if(!Rx(e)){if(e.resource!==void 0){let n=t.resource?.(e.resource)??e.resource;return e.recordId===void 0?n:e.recordTitle!==void 0&&e.recordTitle!==``?`${n}: ${e.recordTitle}`:`${n} #${e.recordId}`}if(e.recordTitle!==void 0&&e.recordTitle!==``)return e.recordTitle;if(e.recordId!==void 0)return e.recordId;if(e.event===`auth.login_failed`&&e.meta?.username)return e.meta.username}}function Wx(e){if(e.restricted&&!Rx(e))return J(e.resource===void 0?`audit.restrictedChanges`:`audit.restrictedRecord`)}function Gx(e,t,n){let r={field:e.field,label:t?.label??e.field};if(`hidden`in e&&e.hidden)return{...r,state:`hidden`,truncated:!1};if(`changed`in e&&e.changed)return{...r,state:`changed`,truncated:!1};let i=e,a=i.truncated===!0;return a&&!(`before`in i)&&!(`after`in i)?{...r,state:`dropped`,truncated:a}:{...r,state:`values`,before:`before`in i&&i.before!==void 0?Yx(i.before,t,n):void 0,after:`after`in i&&i.after!==void 0?Yx(i.after,t,n):void 0,truncated:a}}var Kx=`—`,qx=1e5;function Jx(e){return e==null||e===``?Kx:typeof e==`boolean`?J(e?`common.yes`:`common.no`):typeof e==`string`?e:Array.isArray(e)?e.length===0?Kx:e.every(e=>typeof e!=`object`||!e)?e.map(String).join(`, `):JSON.stringify(e):typeof e==`object`?JSON.stringify(e):String(e)}function Yx(e,t,n){if(e==null||e===``)return Kx;if(!t)return Jx(e);if(t.type===`relation`){let t=Array.isArray(e)?e:[e],r=e=>typeof e==`object`&&e?e.id:e;if(t.some(e=>![`string`,`number`,`bigint`].includes(typeof r(e))))return Jx(e);let i=t.map(e=>String(r(e)));return i.length===0?Kx:i.map(e=>{let t=n?.(e);return t!==void 0&&t!==``&&t!==`#${e}`?`${t} (#${e})`:`#${e}`}).join(`, `)}return t.file?typeof e==`string`||Array.isArray(e)?jx(e,t):Jx(e):t.type===`json`||t.type===`object`?typeof e==`string`?e:JSON.stringify(e):typeof e==`object`?Jx(e):t.widget===`richtext`?Nx(String(e),qx)||Kx:jx(e,t)}var Xx=[`actor`,`event`,`resource`,`record`,`from`,`to`],Zx=/^(\d{4})-(\d{2})-(\d{2})$/;function Qx(e,t){let n=Zx.exec(e);if(!n)return e;let[r,i,a]=[Number(n[1]),Number(n[2]),Number(n[3])],o=t?new Date(r,i-1,a,23,59,59,999):new Date(r,i-1,a,0,0,0,0);return o.getFullYear()===r&&o.getMonth()===i-1&&o.getDate()===a?o.toISOString():e}function $x(e){let t=new URLSearchParams;for(let n of Xx){let r=e.get(n);r!==null&&r!==``&&(n!==`record`||e.get(`resource`))&&t.set(n,n===`from`?Qx(r,!1):n===`to`?Qx(r,!0):r)}return t.sort(),t.toString()}function eS(e){return $x(e)!==``}function tS(e,t){let n=t.trim();return e===`resource`?{resource:n||null,record:null}:{[e]:n||null}}function nS(){return Object.fromEntries(Xx.map(e=>[e,null]))}function rS({entries:e,now:t,names:n,schemaOf:r,pageFieldsOf:i,titleOf:a,onActor:o,showSubject:s=!1}){let{t:c}=Y();return(0,b.jsx)(`ol`,{"aria-label":c(`audit.entries`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:e.map(e=>(0,b.jsx)(aS,{entry:e,now:t,names:n,schema:e.resource===void 0?void 0:r(e.resource),pageFields:e.resource===void 0&&e.meta?.page!==void 0?i?.(e.meta.page):void 0,titleOf:a,onActor:o,showSubject:s},e.id))})}var iS=/\.(deleted|purged)$/;function aS({entry:e,now:t,names:n,schema:r,pageFields:i,titleOf:a,onActor:o,showSubject:s}){let c=r?.fields??i,{t:l}=Y(),u=new Date(e.at),d=!Number.isNaN(u.getTime()),f=s?Ux(e,n):void 0,p=s&&e.resource!==void 0&&e.recordId!==void 0&&!iS.test(e.event)&&!e.meta?.deleted,m=Wx(e),h=Hx(e),g=e.actor?e.actor.name??`#${e.actor.id}`:l(`audit.noActor`),_=e.meta?.input?Object.entries(e.meta.input):[],v=e.meta?.action===void 0?void 0:r?.actions?.find(t=>t.name===oS(e))?.input?.fields,y=[e.meta?.ip,e.meta?.userAgent].filter(Boolean).join(` · `);return(0,b.jsxs)(`li`,{className:`flex flex-col gap-2 px-4 py-3 text-sm`,"data-event":e.event,"data-actor":e.actor?.id??``,"data-anonymous":Rx(e)||void 0,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:Vx(e,n)}),f!==void 0&&(p?(0,b.jsx)(bo,{to:`/${e.resource}/${encodeURIComponent(e.recordId)}`,className:`text-primary hover:underline`,children:f}):(0,b.jsx)(`span`,{children:f}))]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[e.actor&&o?(0,b.jsx)(`button`,{type:`button`,className:`font-medium text-foreground hover:underline`,"aria-label":l(`audit.filterByActor`,{name:g}),onClick:()=>o(e.actor.id),children:g}):(0,b.jsx)(`span`,{className:`font-medium text-foreground`,children:g}),e.viewAsBy!==void 0&&(0,b.jsx)(`span`,{children:l(`audit.viewAsBy`,{id:e.viewAsBy})}),d?(0,b.jsxs)(`time`,{dateTime:e.at,children:[rg(u,t),` · `,eg(u)]}):(0,b.jsx)(`span`,{children:e.at})]}),h!==void 0&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:h}),m!==void 0&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:m}),e.changes!==void 0&&e.changes.length>0&&(0,b.jsx)(`dl`,{"aria-label":l(`audit.changedFields`),className:`grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-[minmax(6rem,auto)_1fr]`,children:e.changes.map(e=>{let t=c?.find(t=>t.name===e.field);return(0,b.jsx)(sS,{row:Gx(e,t,a?t=>a(e.field,t):void 0)},e.field)})}),_.length>0&&(0,b.jsx)(`dl`,{"aria-label":l(`audit.input`),className:`grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-[minmax(6rem,auto)_1fr]`,children:_.map(([e,t])=>{let n=v?.find(t=>t.name===e);return(0,b.jsxs)(`div`,{className:`contents`,"data-input":e,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:n?.label??e}),(0,b.jsx)(`dd`,{className:`min-w-0`,children:(0,b.jsx)(lS,{text:Yx(t,n)})})]},e)})}),e.meta?.inputTruncated&&(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:l(`audit.inputTruncated`)}),y!==``&&(0,b.jsx)(`p`,{className:`text-xs break-all text-muted-foreground`,dir:`ltr`,"data-client":!0,children:y})]})}function oS(e){let t=`${e.resource}.action.`;return e.event.startsWith(t)?e.event.slice(t.length):void 0}function sS({row:e}){let{t}=Y();return(0,b.jsxs)(`div`,{className:`contents`,"data-change":e.field,"data-state":e.state,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:e.state===`values`?(0,b.jsxs)(b.Fragment,{children:[e.before!==void 0&&(0,b.jsxs)(`span`,{className:`min-w-0 text-muted-foreground line-through decoration-muted-foreground/50`,"data-before":!0,children:[(0,b.jsxs)(`span`,{className:`sr-only`,children:[t(`audit.before`),`: `]}),(0,b.jsx)(lS,{text:e.before})]}),e.before!==void 0&&e.after!==void 0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(K_,{className:`size-3.5 shrink-0 self-center text-muted-foreground rtl:-scale-x-100`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`sr-only`,children:t(`audit.becomes`)})]}),e.after!==void 0&&(0,b.jsxs)(`span`,{className:`min-w-0`,"data-after":!0,children:[e.before===void 0&&(0,b.jsxs)(`span`,{className:`sr-only`,children:[t(`audit.after`),`: `]}),(0,b.jsx)(lS,{text:e.after})]}),e.truncated&&(0,b.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t(`audit.field.truncated`),`)`]})]}):(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:t(`audit.field.${e.state}`)})})]})}var cS=160;function lS({text:e}){let{t}=Y(),[n,r]=(0,y.useState)(!1);return e.length<=cS?(0,b.jsx)(`span`,{dir:`auto`,className:`break-words whitespace-pre-wrap`,children:e}):(0,b.jsxs)(`span`,{dir:`auto`,className:`break-words whitespace-pre-wrap`,children:[n?e:`${e.slice(0,cS).trimEnd()}…`,` `,(0,b.jsx)(q,{type:`button`,variant:`link`,size:`sm`,className:`h-auto p-0 text-xs`,"aria-expanded":n,onClick:()=>r(e=>!e),children:t(n?`audit.showLess`:`audit.showMore`)})]})}var uS=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],dS=(e,t)=>Math.trunc(e/t),fS=(e,t)=>e-Math.trunc(e/t)*t;function pS(e){let t=e+621,n=-14,r=uS[0];if(e<r||e>=uS[uS.length-1])throw RangeError(`Jalali year ${e} is out of range`);let i=0;for(let t=1;t<uS.length;t++){let a=uS[t];if(i=a-r,e<a)break;n+=dS(i,33)*8+dS(fS(i,33),4),r=a}let a=e-r;n+=dS(a,33)*8+dS(fS(a,33)+3,4),fS(i,33)===4&&i-a===4&&(n+=1);let o=dS(t,4)-dS((dS(t,100)+1)*3,4)-150,s=20+n-o;i-a<6&&(a=a-i+dS(i+4,33)*33);let c=fS(fS(a+1,33)-1,4);return c===-1&&(c=4),{leap:c,gy:t,march:s}}function mS(e,t,n){return dS((e+dS(t-8,6)+100100)*1461,4)+dS(153*fS(t+9,12)+2,5)+n-34840408-dS(dS(e+100100+dS(t-8,6),100)*3,4)+752}function hS(e){let t=4*e+139361631;t=t+dS(dS(4*e+183187720,146097)*3,4)*4-3908;let n=dS(fS(t,1461),4)*5+308,r=dS(fS(n,153),5)+1,i=fS(dS(n,153),12)+1;return{gy:dS(t,1461)-100100+dS(8-i,6),gm:i,gd:r}}function gS(e,t,n){let{gy:r,march:i}=pS(e);return mS(r,3,i)+(t-1)*31-dS(t,7)*(t-7)+n-1}function _S(e){let{gy:t}=hS(e),n=t-621,r=pS(n),i=e-mS(t,3,r.march);if(i>=0){if(i<=185)return{jy:n,jm:1+dS(i,31),jd:fS(i,31)+1};i-=186}else--n,i+=179,r.leap===1&&(i+=1);return{jy:n,jm:7+dS(i,30),jd:fS(i,30)+1}}var vS=(e,t=2)=>String(e).padStart(t,`0`),yS=/^(\d{4})-(\d{2})-(\d{2})$/;function bS(e){return pS(e).leap===0}function xS(e,t){return t<=6?31:t<=11||bS(e)?30:29}function SS(e){let t=yS.exec(e);if(!t)throw RangeError(`not an ISO date: ${e}`);return _S(mS(Number(t[1]),Number(t[2]),Number(t[3])))}function CS(e,t,n){let{gy:r,gm:i,gd:a}=hS(gS(e,t,n));return`${vS(r,4)}-${vS(i)}-${vS(a)}`}function wS(e,t,n){return Number.isInteger(e)&&e>=1&&e<3178&&t>=1&&t<=12&&n>=1&&n<=xS(e,t)}function TS(e){let{jy:t,jm:n,jd:r}=SS(e);return`${t}/${vS(n)}/${vS(r)}`}function ES(e){let t=/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/.exec(Mh(e.trim()));if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return wS(n,r,i)?CS(n,r,i):void 0}function DS(e,t){let{jy:n,jm:r,jd:i}=SS(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a%12+1;return CS(o,s,Math.min(i,xS(o,s)))}function OS(e,t){return new Date(Date.parse(`${e}T00:00:00Z`)+t*864e5).toISOString().slice(0,10)}function kS(){let e=new Date;return`${vS(e.getFullYear(),4)}-${vS(e.getMonth()+1)}-${vS(e.getDate())}`}var AS=(e,t=2)=>String(e).padStart(t,`0`),jS=(e,t)=>new Date(Date.UTC(e,t,0)).getUTCDate(),MS={intl:`persian`,parts:e=>{let{jy:t,jm:n,jd:r}=SS(e);return{year:t,month:n,day:r}},fromParts:CS,monthLength:xS,addMonths:DS,format:TS,parse:ES,weekStart:6},NS={intl:`gregory`,parts:e=>({year:Number(e.slice(0,4)),month:Number(e.slice(5,7)),day:Number(e.slice(8,10))}),fromParts:(e,t,n)=>`${AS(e,4)}-${AS(t)}-${AS(n)}`,monthLength:jS,addMonths:(e,t)=>{let{year:n,month:r,day:i}=NS.parts(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a%12+1;return NS.fromParts(o,s,Math.min(i,jS(o,s)))},format:e=>e,parse:e=>{let t=/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/.exec(Mh(e.trim()));if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return n>=1&&r>=1&&r<=12&&i>=1&&i<=jS(n,r)?NS.fromParts(n,r,i):void 0},weekStart:1},PS=e=>e===`persian`?MS:NS,FS=/^\d{4}-\d{2}-\d{2}$/;function IS(e){let{calendar:t}=Y();return(0,b.jsx)(LS,{...e,system:PS(t)})}function LS({id:e,value:t,onChange:n,label:r,live:i,className:a,system:o,...s}){let{t:c,digits:l}=Y(),u=e=>FS.test(e)?$h(o.format(e)):e,[d,f]=(0,y.useState)(()=>u(t)),[p,m]=(0,y.useState)(!1),h=(0,y.useRef)(t);(0,y.useEffect)(()=>{t!==h.current&&(h.current=t,f(u(t)))},[t,l,o]);function g(e){h.current=e,n(e)}function _(){let e=d.trim();if(e===``)return t!==``&&g(``);let n=o.parse(e);n?(f(u(n)),n!==t&&g(n)):i&&g(Mh(e))}function v(e){f(u(e)),m(!1),g(e)}return(0,b.jsxs)(`div`,{className:W(`flex items-center gap-1`,a),children:[(0,b.jsx)(Oh,{id:e,dir:`ltr`,inputMode:`numeric`,placeholder:c(`date.placeholder`),value:d,...s,onChange:e=>{if(f(e.target.value),!i)return;let t=e.target.value.trim();g((t===``?``:o.parse(t))??Mh(t))},onBlur:()=>{_(),s.onBlur?.()},onKeyDown:e=>{e.key===`Enter`&&(_(),i||e.preventDefault()),s.onKeyDown?.(e)}}),(0,b.jsxs)(Sh,{open:p,onOpenChange:m,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":c(`date.openCalendar`,{name:r}),children:(0,b.jsx)(uv,{})})}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`end`,sideOffset:4,className:`z-50 rounded-lg border bg-popover p-3 text-popover-foreground shadow-md`,"aria-label":c(`date.calendar`,{name:r}),children:(0,b.jsx)(RS,{system:o,value:FS.test(t)?t:void 0,onPick:v,onClear:()=>v(``)})})})]})]})}function RS({system:e,value:t,onPick:n,onClear:r}){let{t:i,locale:a}=Y(),o=kS(),[s,c]=(0,y.useState)(t??o),[l,u]=(0,y.useState)(`days`),d=(0,y.useRef)(null),f=(0,y.useRef)(!1),{year:p,month:m}=e.parts(s),h=Xh(a);(0,y.useEffect)(()=>{f.current&&(f.current=!1,d.current?.querySelector(`[data-iso="${s}"]`)?.focus())},[s]);let g=t=>new Intl.DateTimeFormat(`${a}-u-ca-${e.intl}`,{month:`long`,timeZone:`UTC`}).format(Date.parse(`${e.fromParts(p,t,1)}T00:00:00Z`)),_=e=>$h(String(e)),v=OS(`2024-01-07`,e.weekStart),x=Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(a,{weekday:`narrow`,timeZone:`UTC`}).format(Date.parse(`${OS(v,t)}T00:00:00Z`))),S=e.fromParts(p,m,1),C=(new Date(`${S}T00:00:00Z`).getUTCDay()-e.weekStart+7)%7,w=e.monthLength(p,m),T=[...Array.from({length:C},()=>null),...Array.from({length:w},(e,t)=>OS(S,t))];function E(t){let n={ArrowRight:h?-1:1,ArrowLeft:h?1:-1,ArrowDown:7,ArrowUp:-7},r;t.key in n?r=OS(s,n[t.key]):t.key===`PageDown`?r=e.addMonths(s,t.shiftKey?12:1):t.key===`PageUp`&&(r=e.addMonths(s,t.shiftKey?-12:-1)),r&&(t.preventDefault(),f.current=!0,c(r))}let D=(e,t,n,r)=>(0,b.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i(`date.previous`),onClick:()=>n(-1),children:(0,b.jsx)(Sv,{className:`rtl:rotate-180`})}),t?(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":r,onClick:t,children:e}):(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:e}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":i(`date.next`),onClick:()=>n(1),children:(0,b.jsx)(wv,{className:`rtl:rotate-180`})})]}),O;if(l===`years`){let t=p-p%12;O=(0,b.jsxs)(b.Fragment,{children:[D(`${_(t)}–${_(t+11)}`,void 0,t=>c(e.addMonths(s,t*144)),``),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Array.from({length:12},(e,n)=>t+n).map(t=>(0,b.jsx)(q,{type:`button`,variant:t===p?`secondary`:`ghost`,size:`sm`,onClick:()=>{c(e.fromParts(t,m,Math.min(e.parts(s).day,e.monthLength(t,m)))),u(`months`)},children:_(t)},t))})]})}else O=l===`months`?(0,b.jsxs)(b.Fragment,{children:[D(_(p),()=>u(`years`),t=>c(e.addMonths(s,t*12)),i(`date.chooseYear`)),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Array.from({length:12},(e,t)=>t+1).map(t=>(0,b.jsx)(q,{type:`button`,variant:t===m?`secondary`:`ghost`,size:`sm`,onClick:()=>{c(e.fromParts(p,t,Math.min(e.parts(s).day,e.monthLength(p,t)))),u(`days`)},children:g(t)},t))})]}):(0,b.jsxs)(b.Fragment,{children:[D(`${g(m)} ${_(p)}`,()=>u(`months`),t=>c(e.addMonths(s,t)),i(`date.chooseMonth`)),(0,b.jsxs)(`div`,{ref:d,role:`grid`,"aria-label":`${g(m)} ${_(p)}`,onKeyDown:E,className:`grid grid-cols-7 gap-0.5 text-center`,children:[(0,b.jsx)(`div`,{role:`row`,className:`contents`,children:x.map((e,t)=>(0,b.jsx)(`div`,{role:`columnheader`,className:`py-1 text-xs text-muted-foreground`,children:e},t))}),Array.from({length:Math.ceil(T.length/7)},(r,i)=>(0,b.jsx)(`div`,{role:`row`,className:`contents`,children:T.slice(i*7,i*7+7).map((r,a)=>r?(0,b.jsx)(`div`,{role:`gridcell`,"aria-selected":r===t,children:(0,b.jsx)(`button`,{type:`button`,"data-iso":r,tabIndex:r===s?0:-1,"aria-label":ng(r),"aria-current":r===o?`date`:void 0,onClick:()=>n(r),className:W(`size-8 rounded-md text-sm hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,r===o&&`font-semibold text-primary`,r===t&&`bg-primary text-primary-foreground hover:bg-primary/90`),children:_(e.parts(r).day)})},r):(0,b.jsx)(`div`,{role:`gridcell`},`empty-${i}-${a}`))},i))]})]});return(0,b.jsxs)(`div`,{className:`flex w-64 flex-col`,children:[O,(0,b.jsxs)(`div`,{className:`mt-2 flex justify-between gap-2 border-t pt-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(o),children:i(`date.today`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:i(`date.clear`)})]})]})}function zS({id:e,value:t,onChange:n,label:r,...i}){let{t:a}=Y(),[o=``,s=``]=t.split(`T`),c=(e,t)=>n(e===``?``:`${e}T${t||`00:00`}`);return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(IS,{id:e,live:!0,value:o,label:r,onChange:e=>c(e,s),className:`min-w-44 flex-1`,...i}),(0,b.jsx)(Oh,{type:`time`,dir:`ltr`,"aria-label":a(`date.time`,{name:r}),className:`w-28`,value:s,onChange:e=>c(o,e.target.value)})]})}function BS(e,t){let[n,r]=(0,y.useState)(e);return(0,y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var VS=(e,t)=>String(e.id)===String(t.id);function HS({id:e,resource:t,field:n,value:r,onChange:i,clearable:a,values:o,parent:s,invalid:c,describedBy:l}){let u=X(),d=n.relation?.kind===`to-many`,f=d&&Array.isArray(r)?r:[],p=!d&&r&&!Array.isArray(r)?r:null,[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(!1),[v,x]=(0,y.useState)(0),S=BS(m.trim(),250),C=Yg(t,n.optionsField??n.name,S,g,o,s),w=(C.data?.items??[]).filter(e=>!f.some(t=>VS(t,e))),T=`${e}-options`,E=t=>`${e}-option-${t}`;(0,y.useEffect)(()=>{x(0)},[S,C.data]);function D(e){h(``),_(!1),i(d?[...f,e]:e)}function O(e){e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),g?x(t=>Math.max(0,Math.min(w.length-1,t+(e.key===`ArrowDown`?1:-1)))):_(!0)):e.key===`Enter`&&g?(e.preventDefault(),w[v]&&D(w[v])):e.key===`Escape`&&g?(e.preventDefault(),_(!1),h(``)):e.key===`Backspace`&&d&&m===``&&f.length>0&&i(f.slice(0,-1))}return(0,b.jsxs)(`div`,{className:`relative flex flex-col gap-1.5`,children:[d&&f.length>0&&(0,b.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":u(`picker.selected`,{name:n.label}),children:f.map(e=>(0,b.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md bg-muted py-0.5 ps-2 pe-1 text-sm`,children:[e.title,(0,b.jsx)(`button`,{type:`button`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,"aria-label":u(`picker.remove`,{name:e.title}),onClick:()=>i(f.filter(t=>!VS(t,e))),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},String(e.id)))}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(Oh,{id:e,role:`combobox`,autoComplete:`off`,"aria-autocomplete":`list`,"aria-expanded":g,"aria-controls":T,"aria-activedescendant":g&&w[v]?E(v):void 0,"aria-invalid":c||void 0,"aria-describedby":l,className:W(p&&a&&`pe-8`),placeholder:p?p.title:u(d?`picker.typeToAdd`:`picker.typeToSearch`),value:g||m?m:p?.title??``,onChange:e=>{h(e.target.value),_(!0)},onFocus:()=>_(!0),onBlur:()=>{_(!1),h(``)},onKeyDown:O}),p&&a&&(0,b.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 end-0 flex items-center px-2 text-muted-foreground hover:text-foreground`,"aria-label":u(`picker.clear`,{name:n.label}),onClick:()=>i(null),children:(0,b.jsx)(bx,{className:`size-4`})})]}),g&&(0,b.jsxs)(`div`,{className:`absolute inset-x-0 top-full z-20 mt-1 max-h-60 overflow-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:[(0,b.jsx)(`ul`,{id:T,role:`listbox`,"aria-label":n.label,children:w.map((e,t)=>(0,b.jsx)(`li`,{id:E(t),role:`option`,"aria-selected":t===v,className:W(`cursor-pointer rounded-md px-2 py-1.5 text-sm`,t===v&&`bg-accent text-accent-foreground`),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>x(t),onClick:()=>D(e),children:e.title},String(e.id)))}),w.length===0&&(0,b.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:C.isError?dg(C.error):u(C.isFetching||C.isPending?`picker.searching`:`picker.noMatches`)})]})]})}var US=new Set([`page`,`pageSize`,`sort`,`search`,`trashed`,`after`,`tab`]),WS=e=>US.has(e)||e.startsWith(`filter[`);function GS(e){let t=new URLSearchParams;for(let[n,r]of e)r!==``&&WS(n)&&t.append(n,r);return t.sort(),t.toString()}function KS(e,t){return`filter[${e}][${t}]`}function qS(e){return[...e.keys()].some(e=>e===`search`||e.startsWith(`filter[`))}function JS(e){let t={};for(let n of e.keys())(n===`search`||n.startsWith(`filter[`))&&(t[n]=null);return t}function YS(e,t){let n=new URLSearchParams(e);Object.keys(t).some(e=>e!==`page`&&e!==`after`)&&(n.delete(`page`),n.delete(`after`));for(let[e,r]of Object.entries(t))r===null?n.delete(e):n.set(e,r);return n}function XS(e,t){if(!e)return{summary:``,label:J(`list.page`,{page:t}),hasNext:!1};if(e.total===null)return{summary:``,label:J(`list.page`,{page:t}),hasNext:e.hasMore===!0};let n=Math.max(1,Math.ceil(e.total/e.pageSize)),r=Qh(e.total);return{summary:J(e.estimated?`list.about`:`list.total`,{count:r}),label:e.estimated?J(`list.page`,{page:t}):J(`list.pageOf`,{page:t,pages:n}),hasNext:t<n}}function ZS(e,t,n){if(!e||e.total===null||e.total===0)return``;if(e.estimated)return J(`list.about`,{count:Qh(e.total)});let r=(t-1)*e.pageSize+1;return J(`list.range`,{from:Qh(r),to:Qh(r+Math.max(n,1)-1),total:Qh(e.total)})}function QS(e){return[...new Set([10,20,50,100,e])].filter(e=>e<=100).sort((e,t)=>e-t)}function $S(e){let t=new Set;for(let[n,r]of e){let e=/^filter\[([^\][]+)\]/.exec(n);e&&r!==``&&t.add(e[1])}return t.size}function eC(e,t){let n=e=>e===`search`||e===`sort`||e.startsWith(`filter[`),r={};for(let i of new Set([...e.keys(),...t.keys()]))n(i)&&e.get(i)!==t.get(i)&&(r[i]=t.get(i));return Object.fromEntries(Object.entries(r).sort(([e],[t])=>e.localeCompare(t)))}function tC(e){return new Map([...e].filter(([e,t])=>e.startsWith(`filter[`)&&t!==``))}function nC(e,t){let n=tC(t),r=t.get(`tab`);return e?.find(e=>{if((e.where?e.key:null)!==r)return!1;let t=Object.entries(e.filter);return t.length===n.size&&t.every(([e,t])=>n.get(e)===t)})}function rC(e,t){let n={};for(let e of tC(t).keys())n[e]=null;return t.has(`tab`)&&(n.tab=null),Object.assign(n,e.filter),e.where?n.tab=e.key:t.has(`tab`)&&(n.tab=null),n}var iC=/^filter\[([^\][]+)\]\[([^\][]+)\]$/;function aC(e,t){if(e.type===`boolean`)return J(t===`true`?`common.yes`:`common.no`);if(e.type===`enum`)return e.enumLabels?.[t]??t;if(e.type===`date`)return ng(t);if(e.type===`number`||e.type===`decimal`||e.type===`bigint`)return $h(t);if(e.type===`datetime`){let e=new Date(t);return Number.isNaN(e.getTime())?t:eg(e)}return t}function oC(e,t){let n=[],r=t.get(`search`);r&&n.push({key:`search`,label:J(`filters.search`),value:`“${r}”`,remove:[`search`]});let i=sC(e,t),a=new Map;for(let[e,n]of t){if(i[e]===n)continue;let t=iC.exec(e);if(!t||n===``)continue;let[,r,o]=t;a.set(r,[...a.get(r)??[],{operator:o,raw:n,key:e}])}for(let[t,r]of a){let i=e.fields.find(e=>e.name===t);if(!i)continue;let a=[],o,s=r.find(e=>e.operator===`gte`||e.operator===`gt`),c=r.find(e=>e.operator===`lte`||e.operator===`lt`);s&&c&&a.push(`${aC(i,s.raw)} – ${aC(i,c.raw)}`);for(let{operator:e,raw:n}of r){if((e===`gte`||e===`gt`||e===`lte`||e===`lt`)&&s&&c)continue;let r=n.split(`,`).map(e=>aC(i,e));if(i.type===`relation`&&[`eq`,`ne`,`in`,`nin`].includes(e)){let r=e===`ne`||e===`nin`?J(`filters.not`):``;o={field:t,ids:n.split(`,`),prefix:r},a.push(`${r}${n.split(`,`).map(e=>`#${e}`).join(`, `)}`);continue}switch(e){case`isNull`:a.push(J(n===`true`?`filters.empty`:`filters.notEmpty`));break;case`ne`:case`nin`:a.push(`${J(`filters.not`)}${r.join(`, `)}`);break;case`gte`:case`gt`:a.push(`≥ ${r[0]}`);break;case`lte`:case`lt`:a.push(`≤ ${r[0]}`);break;case`between`:a.push(r.join(` – `));break;case`contains`:a.push(`“${n}”`);break;case`startsWith`:a.push(`${n}…`);break;default:a.push(r.join(`, `))}}n.push({key:`filter:${t}`,label:i.label,value:a.join(`; `),...o?{ref:o}:{},remove:r.map(e=>e.key)})}return n}function sC(e,t){return nC(e.list?.tabs,t)?.filter??{}}var cC=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},lC=e=>Array.isArray(e)?e:[];function uC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`title`in e}function dC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`name`in e&&`size`in e&&(`key`in e||`token`in e)}function fC(e){return(Array.isArray(e)?e:[e]).filter(dC)}function pC(e,t){let n=e?._files?.[t];return n==null?[]:Array.isArray(n)?n:[n]}var mC=e=>e.token===void 0?`key:${e.key}`:`token:${e.token}`,hC=e=>e.token===void 0?{key:e.key}:{token:e.token},gC=(e,t)=>{let n=new Set(e.map(e=>String(e.id)));return e.length===t.length&&t.every(e=>n.has(String(e.id)))},_C=/<img\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;function vC(e){return e.replace(_C,``)}var yC=e=>String(e).padStart(2,`0`);function bC(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${yC(t.getMonth()+1)}-${yC(t.getDate())}T${yC(t.getHours())}:${yC(t.getMinutes())}`}function xC(e,t){let n={};for(let r of e){let e=t?.[r.name];if(r.file){let e=pC(t,r.name).map(({key:e,name:t,size:n,contentType:r,url:i})=>({key:e,name:t,size:n,contentType:r,url:i}));n[r.name]=r.file.many?e:e[0]??null}else if(r.type===`object`){let t=r.fields??[];n[r.name]=r.many?(Array.isArray(e)?e:[]).map(e=>xC(t,e)):xC(t,e??void 0)}else r.relation?.kind===`to-many`?n[r.name]=Array.isArray(e)?e.filter(uC):[]:r.type===`relation`?n[r.name]=uC(e)?e:null:r.type===`boolean`?n[r.name]=e===!0:e==null?n[r.name]=``:r.type===`json`?n[r.name]=JSON.stringify(e,null,2):r.type===`datetime`?n[r.name]=bC(String(e)):r.widget===`money`?n[r.name]=Tx(String(e),r.scale):n[r.name]=String(e)}return n}function SC(e,t){let n=/^-?\d{1,3}(,\d{3})+(\.\d+)?$/.test(e)?e.replace(/,/g,``):e;if((t?/^-?\d+$/:/^-?\d+(\.\d+)?$/).test(n))return n}function CC(e,t,n,r=``){let i={},a={};for(let o of e){let e=t[o.name];if(n&&e===n[o.name])continue;let s=`${r}${o.name}`;if(o.type===`object`){let t=o.fields??[];if(o.many){let r=lC(e).map((e,n)=>CC(t,e,void 0,`${s}.${n}.`));for(let e of r)Object.assign(a,e.errors);let c=r.map(e=>e.payload),l=n?lC(n[o.name]).map(e=>CC(t,e).payload):void 0;(l?JSON.stringify(l)!==JSON.stringify(c):c.length>0)&&(i[o.name]=c);continue}let r=CC(t,cC(e),n?cC(n[o.name]):void 0,`${s}.`);Object.assign(a,r.errors),(Object.keys(r.payload).length>0||!n&&!o.nullable)&&(i[o.name]=r.payload);continue}if(o.file){let t=fC(e),r=n?fC(n[o.name]):void 0;if(r&&t.map(mC).join(`
|
|
54
54
|
`)===r.map(mC).join(`
|
|
55
|
-
`))continue;o.file.many?(r||t.length>0)&&(i[o.name]=t.map(hC)):t[0]?i[o.name]=hC(t[0]):(o.nullable||n)&&(i[o.name]=null);continue}if(o.relation?.kind===`to-many`){let t=Array.isArray(e)?e.filter(uC):[],r=n?.[o.name];(n?!gC(t,Array.isArray(r)?r.filter(uC):[]):t.length>0)&&(i[o.name]=t.map(e=>e.id));continue}if(o.type===`relation`){let t=uC(e)?e:null,r=n?.[o.name];if(n&&String(t?.id)===String(uC(r)?r.id:void 0))continue;t?i[o.name]=t.id:(o.nullable||n)&&(i[o.name]=null);continue}if(o.type===`boolean`){i[o.name]=e===!0;continue}let c=typeof e==`string`?e:``,l=c.trim();if(l===``){(o.nullable||n)&&(i[o.name]=null);continue}switch(o.type){case`number`:case`decimal`:case`bigint`:{let e=SC(Nh(l),o.type===`bigint`);e===void 0?a[s]=[J(`validation.number`)]:i[o.name]=o.type===`number`?Number(e):e;break}case`json`:try{i[o.name]=JSON.parse(l)}catch{a[s]=[J(`validation.json`)]}break;case`date`:{let e=Mh(l);!/^\d{4}-\d{2}-\d{2}$/.test(e)||Number.isNaN(Date.parse(`${e}T00:00:00Z`))||new Date(`${e}T00:00:00Z`).toISOString().slice(0,10)!==e?a[s]=[J(`validation.date`)]:i[o.name]=e;break}case`datetime`:{let e=new Date(Mh(l));Number.isNaN(e.getTime())?a[s]=[J(`validation.datetime`)]:i[o.name]=e.toISOString();break}default:i[o.name]=c}}return{payload:i,errors:a}}function wC(e,t){let{payload:n}=CC(e,t),r=e=>Array.isArray(e)?e.every(e=>typeof e==`string`||typeof e==`number`):typeof e==`string`?e.length<=100:typeof e!=`object`||!e,i=Object.fromEntries(Object.entries(n).filter(([,e])=>r(e))),a=JSON.stringify(i);return a.length<=4e3?a:void 0}var TC=`(max-width: 767px)`;function EC(e){let t=window.matchMedia(TC);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function DC(){return(0,y.useSyncExternalStore)(EC,()=>window.matchMedia(TC).matches,()=>!1)}function OC(e,t){if(e.widget===`stepper`)return`select`;if(e.widget)return e.widget;switch(e.type){case`boolean`:return`checkbox`;case`enum`:return`select`;case`text`:return`textarea`;case`json`:case`object`:return`json`;case`number`:case`decimal`:case`bigint`:return`number`;case`date`:return`date`;case`datetime`:return`datetime`;default:return t?.format===`email`?`email`:t?.format===`url`?`url`:`text`}}function kC(e,t){return e.enumLabels?.[t]??t}var AC=`h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,jC=new Set([`number`,`decimal`,`bigint`,`date`,`datetime`]);function MC({schema:e,params:t,onChange:n,trailing:r}){let i=X(),a=DC(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(),u=t.get(`search`)??``,[d,f]=(0,y.useState)(u);(0,y.useEffect)(()=>{f(u)},[u]);let p=e.list.filters.map(t=>({operators:t.operators,field:e.fields.find(e=>e.name===t.field)})).filter(e=>e.field!==void 0),m=e.list.search.length>0,h=a&&(p.length>0||e.list.sortable.length>0);if(p.length===0&&!m&&!h&&!r)return null;let g=e.list.search.map(t=>e.fields.find(e=>e.name===t)?.label??t);if(!a){let a=new Map(oC(e,t).map(e=>[e.key,e]));return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m&&(0,b.jsx)(WC,{label:i(`filters.search`),placeholder:i(`filters.searchIn`,{fields:g.join(`, `)}),value:d,onChange:f,onSubmit:()=>n({search:d.trim()||null})}),p.length>0&&(0,b.jsx)(`ul`,{"aria-label":i(`filters.filters`),className:`contents`,children:p.map(({field:r,operators:i})=>(0,b.jsx)(`li`,{className:`contents`,children:(0,b.jsx)(GC,{resource:e.name,field:r,operators:i,params:t,onChange:n,chip:a.get(`filter:${r.name}`)})},r.name))}),qS(t)&&(0,b.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(JS(t)),children:[i(`filters.clear`),(0,b.jsx)(bx,{className:`size-3.5`})]}),r&&(0,b.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:r})]})}let _=$S(t),v=oC(e,t).length>0,x=NC(e,t,i),S=()=>{l(new URLSearchParams(t)),s(!0)};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[m&&(0,b.jsx)(WC,{className:`flex-1`,label:i(`filters.search`),placeholder:i(`filters.searchIn`,{fields:g.join(`, `)}),value:d,onChange:f,onSubmit:()=>n({search:d.trim()||null})}),h&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,"aria-haspopup":`dialog`,onClick:S,children:[(0,b.jsx)(Bb,{}),i(`filters.filters`),_>0&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs text-primary-foreground`,children:Qh(_)})]})]}),(v||h&&x)&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v&&(0,b.jsx)(BC,{schema:e,params:t,onChange:n}),h&&x&&(0,b.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 items-center gap-1.5 rounded-full border border-input bg-card px-3 text-[13px]`,"aria-haspopup":`dialog`,onClick:S,children:[(0,b.jsx)(H_,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),x]})]}),h&&(0,b.jsx)(jd,{open:o,onOpenChange:s,children:(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/40`}),(0,b.jsxs)(Ud,{"aria-describedby":void 0,className:`fixed inset-x-0 bottom-0 z-50 flex max-h-[85dvh] flex-col rounded-t-[18px] bg-card shadow-xl outline-none`,children:[(0,b.jsx)(`div`,{className:`flex justify-center pt-2`,"aria-hidden":!0,children:(0,b.jsx)(`span`,{className:`h-1.5 w-10 rounded-full bg-input`})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 ps-4 pe-2 pt-1.5 pb-2`,children:[(0,b.jsx)(Jd,{className:`flex-1 text-[17px] font-bold`,children:i(`filters.filtersAndSort`)}),qS(t)&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,className:`text-primary`,onClick:()=>n(JS(t)),children:i(`filters.clear`)})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-5 overflow-y-auto px-4 py-1`,children:[p.map(({field:r,operators:i})=>(0,b.jsx)(FC,{resource:e.name,field:r,operators:i,params:t,onChange:n,touch:!0},r.name)),e.list.sortable.length>0&&(0,b.jsx)(PC,{schema:e,params:t,onChange:n})]}),(0,b.jsxs)(`div`,{className:`flex gap-2.5 border-t px-4 pt-3 pb-5`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>{c&&n(eC(t,c)),s(!1)},children:i(`common.cancel`)}),(0,b.jsx)(Xd,{asChild:!0,children:(0,b.jsx)(q,{className:`flex-1`,children:i(`filters.showResults`)})})]})]})]})})]})}function NC(e,t,n){if(e.list.sortable.length===0)return``;let{field:r,direction:i}=e.list.defaultSort,a=t.get(`sort`)??(i===`desc`?`-${r}`:r),o=a.replace(/^-/,``),s=e.fields.find(e=>e.name===o)?.label??o;return n(a.startsWith(`-`)?`filters.descending`:`filters.ascending`,{name:s})}function PC({schema:e,params:t,onChange:n}){let r=X(),{field:i,direction:a}=e.list.defaultSort,o=t.get(`sort`)??(a===`desc`?`-${i}`:i),s=t=>e.fields.find(e=>e.name===t)?.label??t;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`list-sort`,children:r(`filters.sortBy`)}),(0,b.jsx)(`select`,{id:`list-sort`,className:AC,value:o,onChange:e=>n({sort:e.target.value,page:null,after:null}),children:e.list.sortable.flatMap(e=>[(0,b.jsx)(`option`,{value:e,children:r(`filters.ascending`,{name:s(e)})},e),(0,b.jsx)(`option`,{value:`-${e}`,children:r(`filters.descending`,{name:s(e)})},`-${e}`)])})]})}function FC(e){let t=(0,b.jsx)(zC,{...e}),{field:n,operators:r,params:i,onChange:a}=e;return!n.nullable||!r.includes(`isNull`)||n.type===`relation`?t:(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t,(0,b.jsx)(IC,{field:n,params:i,onChange:a})]})}function IC({field:e,params:t,onChange:n}){let r=X(),i=KS(e.name,`isNull`);return(0,b.jsxs)(`select`,{"aria-label":r(`filters.emptyValues`,{field:e.label}),className:W(AC,`h-7 text-xs text-muted-foreground`),value:t.get(i)??``,onChange:e=>n({[i]:e.target.value||null}),children:[(0,b.jsx)(`option`,{value:``,children:r(`filters.any`)}),(0,b.jsx)(`option`,{value:`true`,children:r(`filters.onlyEmpty`)}),(0,b.jsx)(`option`,{value:`false`,children:r(`filters.hideEmpty`)})]})}function LC({id:e,inline:t,field:n,params:r,onChange:i}){let a=X(),o=KS(n.name,`in`),s=(r.get(o)??``).split(`,`).filter(Boolean),c=e=>{let t=s.includes(e)?s.filter(t=>t!==e):[...s,e];i({[o]:t.length>0?t.join(`,`):null})};return t?(0,b.jsx)(RC,{field:n,selected:s,onToggle:c}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:e,children:n.label}),(0,b.jsxs)(Sh,{children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(q,{id:e,type:`button`,variant:`outline`,className:`justify-between font-normal`,children:[(0,b.jsx)(`span`,{className:`truncate`,children:s.length===0?a(`common.all`):s.length<=2?s.map(e=>kC(n,e)).join(`, `):a(`filters.selected`,{count:s.length})}),(0,b.jsx)(bv,{className:`size-4 opacity-60`,"aria-hidden":!0})]})}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`start`,sideOffset:4,className:`z-50 min-w-48 rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:(0,b.jsx)(RC,{field:n,selected:s,onToggle:c})})})]})]})}function RC({field:e,selected:t,onToggle:n}){return(0,b.jsx)(`ul`,{"aria-label":e.label,children:(e.enumValues??[]).map(r=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,b.jsx)(ff,{checked:t.includes(r),onCheckedChange:()=>n(r),className:`flex size-4 items-center justify-center rounded border border-input data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground`,children:(0,b.jsx)(mf,{children:(0,b.jsx)(vv,{className:`size-3`})})}),kC(e,r)]})},r))})}function zC({inline:e,touch:t,resource:n,field:r,operators:i,params:a,onChange:o}){let{t:s,calendar:c}=Y(),l=`filter-${r.name}`;if(t&&r.type===`enum`&&i.includes(`in`))return(0,b.jsx)(qC,{field:r,params:a,onChange:o});if(r.type===`enum`&&i.includes(`in`))return(0,b.jsx)(LC,{id:l,inline:e,field:r,params:a,onChange:o});if(r.type===`relation`){let e=r.relation?.kind===`to-many`?`in`:`eq`;return i.includes(e)?(0,b.jsx)(HC,{id:l,resource:n,field:r,operator:e,params:a,onChange:o}):null}if((r.type===`enum`||r.type===`boolean`)&&i.includes(`eq`)){let e=KS(r.name,`eq`),n=r.type===`boolean`?[[`true`,s(`common.yes`)],[`false`,s(`common.no`)]]:(r.enumValues??[]).map(e=>[e,kC(r,e)]);return t&&n.length<=3?(0,b.jsx)(JC,{label:r.label,options:[[``,s(`common.all`)],...n],value:a.get(e)??``,onChange:t=>o({[e]:t||null})}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:l,children:r.label}),(0,b.jsxs)(`select`,{id:l,className:AC,value:a.get(e)??``,onChange:t=>o({[e]:t.target.value||null}),children:[(0,b.jsx)(`option`,{value:``,children:s(`common.all`)}),n.map(([e,t])=>(0,b.jsx)(`option`,{value:e,children:t},e))]})]})}if((r.type===`date`||r.type===`datetime`)&&i.includes(`gte`)&&i.includes(`lte`)){let e=(e,t)=>r.type===`date`||!t?t:new Date(`${t}T${e===`gte`?`00:00:00.000`:`23:59:59.999`}`).toISOString(),t=e=>e&&r.type===`datetime`?bC(e).slice(0,10):e??``;return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:r.label}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`gte`,`lte`].map(n=>{let i=KS(r.name,n),c=`${l}-${n}`,u=s(n===`gte`?`filters.from`:`filters.to`);return(0,b.jsxs)(`div`,{className:`flex min-w-36 flex-1 flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:c,className:`text-xs text-muted-foreground`,children:u}),(0,b.jsx)(IS,{id:c,label:`${r.label} ${u}`,value:t(a.get(i)),onChange:t=>o({[i]:e(n,t)||null})})]},n)})})]})}if(jC.has(r.type)&&i.includes(`gte`)&&i.includes(`lte`)){let e=r.type===`date`?`date`:r.type===`datetime`?`datetime-local`:`text`,t=e=>r.type===`datetime`&&e?new Date(e).toISOString():Nh(e.trim()).replace(/,/g,``),n=e=>e&&r.type===`datetime`?bC(e):e??``;return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:r.label}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:[`gte`,`lte`].map(i=>{let c=KS(r.name,i),u=`${l}-${i}`;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:u,className:`text-xs text-muted-foreground`,children:s(i===`gte`?`filters.from`:`filters.to`)}),(0,b.jsx)(UC,{id:u,type:e,inputMode:e===`text`?`decimal`:void 0,value:n(a.get(c)),onCommit:e=>o({[c]:t(e)||null})})]},i)})})]})}let u=i.includes(`contains`)?`contains`:i.includes(`eq`)?`eq`:void 0;if(!u)return null;let d=KS(r.name,u);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:l,children:u===`contains`?s(`filters.contains`,{field:r.label}):r.label}),(0,b.jsx)(UC,{id:l,value:a.get(d)??``,onCommit:e=>o({[d]:e.trim()||null})})]})}function BC({schema:e,params:t,onChange:n}){let r=X(),i=oC(e,t);return(0,b.jsx)(`ul`,{"aria-label":r(`filters.active`),className:`flex flex-wrap gap-2`,children:i.map(t=>(0,b.jsxs)(`li`,{className:`inline-flex h-9 items-center gap-1 rounded-full border border-primary bg-primary-soft ps-3 pe-1.5 text-[13px] font-semibold text-primary`,children:[(0,b.jsxs)(`span`,{className:`font-medium`,children:[t.label,`:`]}),t.ref?(0,b.jsx)(VC,{resource:e.name,chip:t}):(0,b.jsx)(`span`,{children:t.value}),(0,b.jsx)(`button`,{type:`button`,className:`rounded-full p-1 hover:bg-primary-soft`,"aria-label":r(`filters.removeChip`,{label:t.label}),onClick:()=>n(Object.fromEntries(t.remove.map(e=>[e,null]))),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},t.key))})}function VC({resource:e,chip:t}){let n=Xg(e,t.ref.field,t.ref.ids);if(!n.data)return(0,b.jsx)(`span`,{children:t.value});let r=new Map(n.data.items.map(e=>[String(e.id),e.title]));return(0,b.jsx)(`span`,{children:t.ref.prefix+t.ref.ids.map(e=>r.get(e)??`#${e}`).join(`, `)})}function HC({id:e,resource:t,field:n,operator:r,params:i,onChange:a}){let o=KS(n.name,r),s=(i.get(o)??``).split(`,`).filter(Boolean),c=Xg(t,n.name,s),l=new Map((c.data?.items??[]).map(e=>[String(e.id),e])),u=s.map(e=>l.get(e)??{id:e,title:`#${e}`});return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:e,children:n.label}),(0,b.jsx)(HS,{id:e,resource:t,field:n,clearable:!0,value:r===`in`?u:u[0]??null,onChange:e=>{let t=Array.isArray(e)?e:e?[e]:[];a({[o]:t.length>0?t.map(e=>e.id).join(`,`):null})}})]})}function UC({id:e,value:t,type:n=`text`,inputMode:r,onCommit:i}){let[a,o]=(0,y.useState)(t);(0,y.useEffect)(()=>{o(t)},[t]);let s=()=>{a!==t&&i(a)};return(0,b.jsx)(Oh,{id:e,type:n,inputMode:r,value:a,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())}})}function WC({label:e,placeholder:t,value:n,className:r,onChange:i,onSubmit:a}){return(0,b.jsxs)(`form`,{role:`search`,className:W(`relative w-[300px] max-w-full`,r),onSubmit:e=>{e.preventDefault(),a()},children:[(0,b.jsx)(wb,{className:`pointer-events-none absolute start-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(Oh,{"aria-label":e,placeholder:t,value:n,className:`ps-8`,onChange:e=>i(e.target.value)})]})}function GC({chip:e,...t}){let n=X(),{field:r,onChange:i}=t,a=e&&(()=>i(Object.fromEntries(e.remove.map(e=>[e,null]))));return(0,b.jsxs)(Sh,{children:[(0,b.jsxs)(`span`,{className:W(`inline-flex h-8 items-center rounded-lg border border-dashed border-input`,e&&`border-solid bg-card`),children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,className:`inline-flex h-full items-center gap-1.5 rounded-lg px-2.5 text-[12.5px] font-medium outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50`,children:[e?(0,b.jsx)(My,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}):(0,b.jsx)(Ov,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),r.label,e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`:`}),(0,b.jsx)(`span`,{className:`h-4 w-px bg-border`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`max-w-48 truncate rounded-[5px] bg-muted px-1.5 text-xs font-medium`,children:e.ref?(0,b.jsx)(VC,{resource:t.resource,chip:e}):e.value})]})]})}),a&&(0,b.jsx)(`button`,{type:`button`,className:`-ms-1 me-1 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":n(`filters.removeChip`,{label:r.label}),onClick:a,children:(0,b.jsx)(bx,{className:`size-3.5`})})]}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`start`,sideOffset:6,onOpenAutoFocus:r.type===`relation`?e=>e.preventDefault():void 0,className:`z-50 flex w-72 flex-col gap-3 rounded-[10px] border bg-popover p-3 text-popover-foreground shadow-lg outline-none`,children:(0,b.jsx)(FC,{...t,inline:!0})})})]})}var KC=`inline-flex h-9 items-center gap-1.5 rounded-full border border-input bg-card px-3 text-[13px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50 data-[state=checked]:border-primary data-[state=checked]:bg-primary-soft data-[state=checked]:font-semibold data-[state=checked]:text-primary`;function qC({field:e,params:t,onChange:n}){let r=KS(e.name,`in`),i=(t.get(r)??``).split(`,`).filter(Boolean),a=e=>{let t=i.includes(e)?i.filter(t=>t!==e):[...i,e];n({[r]:t.length>0?t.join(`,`):null})};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,"aria-hidden":!0,children:e.label}),(0,b.jsx)(`ul`,{"aria-label":e.label,className:`flex flex-wrap gap-2`,children:(e.enumValues??[]).map(t=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(ff,{checked:i.includes(t),onCheckedChange:()=>a(t),className:KC,children:[(0,b.jsx)(mf,{children:(0,b.jsx)(vv,{className:`size-3.5`})}),kC(e,t)]})},t))})]})}function JC({label:e,options:t,value:n,onChange:r}){return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,"aria-hidden":!0,children:e}),(0,b.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`grid auto-cols-fr grid-flow-col gap-0.5 rounded-[10px] bg-muted p-[3px]`,children:t.map(([e,t])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e,className:W(`h-9 rounded-lg text-[13px] text-muted-foreground`,n===e&&`bg-card font-semibold text-foreground shadow-sm`),onClick:()=>r(e),children:t},e))})]})}var YC=[`auth.*`,`auth.login`,`auth.login_failed`,`auth.view_as`,`rbac.*`,`rbac.role.changed`,`rbac.user_roles.changed`,`page.*`],XC=[`*`,`created`,`updated`,`deleted`,`restored`,`purged`,`action.*`];function ZC(){let{t:e,locale:t}=Y(),[n,r]=wo(),i=Ug(),a=Hg(),o=a.data?.audit.view===!0,s=$x(n),c=mt({queryKey:[`audit`,s],initialPageParam:void 0,queryFn:({pageParam:e})=>Q.audit(s,e),getNextPageParam:e=>e.next,staleTime:0,enabled:o,retry:!1}),l=c.data?.pages.flatMap(e=>e.entries)??[],u=new Set((i.data?.groups??[]).flatMap(e=>e.resources.map(e=>e.name))),d=[...new Set(l.map(e=>e.resource).filter(e=>e!==void 0&&u.has(e)))].sort(),f=ut({queries:d.map(e=>({queryKey:[`schema`,e,t],queryFn:()=>Q.schema(e),retry:!1}))}),p=e=>f[d.indexOf(e)]?.data,m=new Set((i.data?.groups??[]).flatMap(e=>e.pages.map(e=>e.name))),h=[...new Set(l.map(e=>e.meta?.page).filter(e=>e!==void 0&&m.has(e)))].sort(),g=ut({queries:h.map(e=>({queryKey:[`page`,e,t],queryFn:()=>Q.page(e),retry:!1}))}),_=e=>g[h.indexOf(e)]?.data?.schema.fields,v=(e,t)=>r(n=>YS(n,tS(e,t))),y=c.error instanceof ug&&(c.error.status===403||c.error.status===404);if(a.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(!o||y)return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{children:e(`audit.title`)}),(0,b.jsx)(G,{tone:`error`,children:y?dg(c.error):e(a.data?.audit.enabled?`audit.notAllowed`:`audit.off`)})]});let x=(i.data?.groups??[]).flatMap(e=>e.resources),S=n.get(`resource`)??``;return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{children:e(`audit.title`)}),(0,b.jsxs)(`fieldset`,{className:`grid gap-3 rounded-card border bg-card shadow-card p-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:e(`filters.filters`)}),(0,b.jsx)(QC,{label:e(`audit.filter.actor`),value:n.get(`actor`)??``,onCommit:e=>v(`actor`,e)}),(0,b.jsx)(QC,{label:e(`audit.filter.event`),placeholder:e(`audit.filter.eventHint`),value:n.get(`event`)??``,onCommit:e=>v(`event`,e),hints:[...S?XC.map(e=>`${S}.${e}`):[],...YC]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`audit-resource`,children:e(`audit.filter.resource`)}),(0,b.jsxs)(`select`,{id:`audit-resource`,className:AC,value:S,onChange:e=>v(`resource`,e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:e(`common.all`)}),S&&!x.some(e=>e.name===S)&&(0,b.jsx)(`option`,{value:S,children:S}),x.map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]}),(0,b.jsx)(QC,{label:e(`audit.filter.record`),placeholder:S?void 0:e(`audit.filter.recordHint`),value:S?n.get(`record`)??``:``,disabled:!S,onCommit:e=>v(`record`,e)}),[`from`,`to`].map(t=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`audit-${t}`,children:e(`filters.${t}`)}),(0,b.jsx)(IS,{id:`audit-${t}`,label:e(`filters.${t}`),value:n.get(t)??``,onChange:e=>v(t,e)})]},t)),eS(n)&&(0,b.jsx)(`div`,{className:`flex items-end sm:col-span-2 lg:col-span-3`,children:(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(e=>YS(e,nS())),children:e(`filters.clear`)})})]}),c.isError&&(0,b.jsx)(T_,{children:dg(c.error)}),c.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):l.length===0?!c.isError&&(0,b.jsx)(G,{children:e(eS(n)?`audit.noMatches`:`audit.empty`)}):(0,b.jsx)(rS,{entries:l,now:new Date(c.dataUpdatedAt),names:Px(i.data,p),schemaOf:p,pageFieldsOf:_,onActor:e=>v(`actor`,e),showSubject:!0}),c.hasNextPage&&(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`self-center`,disabled:c.isFetchingNextPage,onClick:()=>void c.fetchNextPage(),children:e(c.isFetchingNextPage?`common.loading`:`list.loadMore`)})]})}function QC({label:e,value:t,onCommit:n,placeholder:r,disabled:i,hints:a}){let o=(0,y.useId)(),[s,c]=(0,y.useState)(t);(0,y.useEffect)(()=>c(t),[t]);let l=()=>{s.trim()!==t&&n(s)};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:o,children:e}),(0,b.jsx)(Oh,{id:o,type:`text`,dir:`auto`,value:s,placeholder:r,disabled:i,list:a?`${o}-hints`:void 0,autoComplete:`off`,spellCheck:!1,onChange:e=>c(e.target.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())}}),a&&(0,b.jsx)(`datalist`,{id:`${o}-hints`,children:a.map(e=>(0,b.jsx)(`option`,{value:e},e))})]})}var $C={hidden:`rbac.rule.hidden`,view:`rbac.rule.readonly`,edit:`rbac.rule.edit`};function ew(){let{t:e}=Y(),[t,n]=wo(),r=t.get(`user`)??``,i=t.get(`resource`)??``,a=t.get(`record`)??``,o=ft({queryKey:[`rbac`,`catalog`],queryFn:Q.rbac.catalog}),s=ft({queryKey:[`rbac`,`user`,r],queryFn:()=>Q.rbac.user(r),enabled:r!==``}),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(i),[f,p]=(0,y.useState)(a),[m,h]=(0,y.useState)(r),g=ft({queryKey:[`rbac`,`users`,c,1],queryFn:()=>Q.rbac.users({search:c}),enabled:c.trim().length>0}),_=ft({queryKey:[`rbac`,`explain`,r,i,a],queryFn:()=>Q.rbac.explain({user:r,resource:i,record:a||void 0}),enabled:r!==``&&i!==``});function v(e){e.preventDefault();let t={};m&&(t.user=m),u&&(t.resource=u),f.trim()&&(t.record=f.trim()),n(t)}let x=m===r?s.data?.displayName:void 0;return(0,b.jsxs)(`div`,{className:`flex max-w-5xl flex-col gap-5`,children:[(0,b.jsx)(w_,{children:e(`debugger.title`)}),(0,b.jsx)(`p`,{className:`-mt-3 text-sm text-muted-foreground`,children:e(`debugger.intro`)}),(0,b.jsxs)(`form`,{onSubmit:v,className:`grid gap-4 rounded-card border bg-card shadow-card p-4 md:grid-cols-3`,"aria-label":e(`debugger.title`),children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-user`,children:e(`debugger.user`)}),(0,b.jsx)(Oh,{id:`debug-user`,placeholder:e(`rbac.searchUsers`),value:c,onChange:e=>l(e.target.value),autoComplete:`off`}),c.trim()&&(0,b.jsx)(`ul`,{"aria-label":e(`rbac.searchResults`),className:`flex flex-col rounded-md border text-sm`,children:(g.data?.items??[]).slice(0,6).map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,className:`w-full px-2 py-1.5 text-start hover:bg-accent`,onClick:()=>{h(e.id),l(``)},children:[e.displayName,e.username&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.username]})]})},e.id))}),m&&(0,b.jsx)(`p`,{className:`text-sm`,"data-testid":`debug-chosen-user`,children:x??m})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-resource`,children:e(`debugger.resource`)}),(0,b.jsxs)(`select`,{id:`debug-resource`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:u,onChange:e=>d(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`—`}),(o.data?.resources??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-record`,children:e(`debugger.record`)}),(0,b.jsx)(Oh,{id:`debug-record`,dir:`ltr`,value:f,onChange:e=>p(e.target.value)})]}),(0,b.jsx)(`div`,{className:`md:col-span-3`,children:(0,b.jsx)(q,{type:`submit`,disabled:!m||!u,children:e(`debugger.explain`)})})]}),!r||!i?(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`debugger.pick`)}):_.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):_.isError?(0,b.jsx)(G,{tone:`error`,children:dg(_.error)}):(0,b.jsx)(nw,{data:_.data})]})}function tw({allowed:e}){let{t}=Y();return(0,b.jsx)(`span`,{className:W(`rounded-full px-2 py-0.5 text-xs font-medium`,e?`bg-green-500/15 text-green-800 dark:text-green-300`:`bg-destructive/10 text-destructive`),children:t(e?`debugger.allowed`:`debugger.denied`)})}function nw({data:e}){let{t,locale:n}=Y(),r=e=>e.kind===`group`?t(`debugger.source.group`,{group:e.group??``}):t(`debugger.source.${e.kind}`),i=e=>e===`all`?t(`debugger.allRows`):e.length===0?t(`debugger.noRows`):t(`debugger.someRows`,{scopes:e.join(`, `)});return(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,"data-testid":`explanation`,children:[(0,b.jsxs)(`section`,{"aria-labelledby":`debug-roles`,className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`h2`,{id:`debug-roles`,className:`font-medium`,children:[t(`debugger.roles`),` · `,e.user.displayName]}),e.superuser?(0,b.jsx)(`p`,{className:`text-sm`,children:t(`debugger.superuser`)}):e.roles.length===0?(0,b.jsx)(`p`,{className:`text-sm`,children:t(`debugger.noRoles`)}):(0,b.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.roles.map(e=>(0,b.jsxs)(`li`,{children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(e.label,n)||e.name}),` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.sources.map(r).join(`, `),`)`]}),!e.known&&(0,b.jsx)(`span`,{className:`ms-2 text-destructive`,children:t(`debugger.unknownRole`)})]},e.name))})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-operations`,className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`h2`,{id:`debug-operations`,className:`font-medium`,children:[t(`debugger.operations`),` · `,e.resource.label]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsx)(`table`,{className:`w-full text-sm`,children:(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.operations.map(n=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{scope:`row`,className:`w-32 px-3 py-2 text-start font-medium`,children:t(`rbac.op.${n.operation}`)}),(0,b.jsx)(`td`,{className:`w-24 px-3 py-2`,children:(0,b.jsx)(tw,{allowed:n.allowed})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>t(e.via?`debugger.viaUpdate`:`debugger.grant`,{pattern:e.pattern,role:e.role})).join(` · `)})]},n.operation))})})})]}),e.actions.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-actions`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-actions`,className:`font-medium`,children:t(`debugger.actions`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsx)(`table`,{className:`w-full text-sm`,children:(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.actions.map(n=>(0,b.jsxs)(`tr`,{"data-action":n.name,children:[(0,b.jsx)(`th`,{scope:`row`,className:`w-32 px-3 py-2 text-start font-medium`,children:n.label}),(0,b.jsx)(`td`,{className:`w-24 px-3 py-2`,children:(0,b.jsx)(tw,{allowed:n.allowed})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:[n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>t(`debugger.grant`,{pattern:e.pattern,role:e.role})).join(` · `),...n.needsUpdate?[t(`debugger.needsUpdate`)]:[]].join(` — `)})]},n.name))})})})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-fields`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-fields`,className:`font-medium`,children:t(`debugger.fields`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/40 text-xs text-muted-foreground`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.field`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.result`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.byRole`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.fields.map(e=>(0,b.jsxs)(`tr`,{"data-field":e.name,children:[(0,b.jsxs)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-medium`,children:[e.label,e.restricted&&(0,b.jsx)(`span`,{className:`ms-2 rounded-full border px-1.5 text-xs font-normal text-muted-foreground`,children:t(`rbac.restricted`)})]}),(0,b.jsxs)(`td`,{className:`px-3 py-2`,children:[t($C[e.level]),e.forced&&(0,b.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t(`debugger.forced`)})]}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.byRole.map(e=>`${e.role}: ${t($C[e.level])}${e.rule?` (${e.rule})`:``}${e.code?` (${e.code})`:``}`).join(` · `)})]},e.name))})]})})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-scopes`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-scopes`,className:`font-medium`,children:t(`debugger.scopes`)}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.scopes.map(e=>(0,b.jsxs)(`li`,{children:[(0,b.jsxs)(`span`,{className:`font-medium`,children:[t(`rbac.op.${e.operation}`),`:`]}),` `,i(e.result),e.byRole.length>0&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.byRole.map(e=>`${e.role}: ${i(e.scopes)}`).join(` · `),`)`]}),e.global.length>0&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,t(`debugger.globalScopes`,{scopes:e.global.join(`, `)})]})]},e.operation))})]}),e.record&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-record-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-record-title`,className:`font-medium`,children:t(`debugger.recordTitle`,{id:e.record.id})}),(0,b.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[[`view`,`update`,`delete`].map(n=>(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,"data-operation":n,children:[(0,b.jsx)(`span`,{className:`w-24 font-medium`,children:t(`rbac.op.${n}`)}),(0,b.jsx)(tw,{allowed:e.record[n]}),e.record.reasons[n]&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:t(`debugger.reason.${e.record.reasons[n]}`)})]},n)),e.record.actions&&(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,"data-operation":`actions`,children:[(0,b.jsx)(`span`,{className:`w-24 font-medium`,children:t(`debugger.actions`)}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.record.actions.length===0?t(`debugger.noRecordActions`):e.record.actions.map(t=>e.actions.find(e=>e.name===t)?.label??t).join(`, `)})]})]})]}),e.pages.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-pages`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-pages`,className:`font-medium`,children:t(`debugger.pages`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/40 text-xs text-muted-foreground`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.page`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.op.view`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.op.update`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.byRole`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.pages.map(n=>(0,b.jsxs)(`tr`,{"data-page":n.name,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-medium`,children:n.label}),(0,b.jsx)(`td`,{className:`px-3 py-2`,"data-operation":`view`,children:(0,b.jsx)(tw,{allowed:n.view})}),(0,b.jsx)(`td`,{className:`px-3 py-2`,"data-operation":`update`,children:(0,b.jsx)(tw,{allowed:n.update})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>`${t(`debugger.grant`,{pattern:e.pattern,role:e.role})} (${e.code})`).join(` · `)})]},n.name))})]})})]})]})}function rw(){let{t:e,locale:t}=Y(),n=Hg(),r=ft({queryKey:[`rbac`,`groups`],queryFn:Q.rbac.groups});return r.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:n.data?.rbac.manage&&(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/groups/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newGroup`)]})}),children:e(`rbac.groups`)}),r.data.items.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`rbac.noGroups`)}),(0,b.jsx)(`ul`,{"aria-label":e(`rbac.groups`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card empty:hidden`,children:r.data.items.map(n=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/groups/${n.id}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(n.label,t)||n.name}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`rbac.groupSummary`,{roles:n.roles.length,members:n.members.length})})]})},n.id))})]})}function iw(){let{t:e}=Y(),{id:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),i=ft({queryKey:[`rbac`,`group`,t],queryFn:()=>Q.rbac.group(Number(t)),enabled:!n});return r.isPending||!n&&i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):!n&&i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsx)(aw,{roles:r.data.items,group:n?void 0:i.data},t??`new`)}function aw({roles:e,group:t}){let{t:n,locale:r}=Y(),i=Yi(),a=S(),o=Hg().data?.rbac.manage!==!0,[s,c]=(0,y.useState)(t?.name??``),[l,u]=(0,y.useState)(C_(t?.label)),[d,f]=(0,y.useState)(t?.roles??[]),[p,m]=(0,y.useState)(t?.members??[]),[h,g]=(0,y.useState)(``),_=ft({queryKey:[`rbac`,`users`,h],queryFn:()=>Q.rbac.users({search:h}),enabled:h.trim().length>0}),v=ft({queryKey:[`rbac`,`users`,``,1],queryFn:()=>Q.rbac.users({})}),[x,C]=(0,y.useState)({}),w=e=>x[e]??v.data?.items.find(t=>t.id===e)?.displayName??e,[T,E]=(0,y.useState)(null),D=pt({mutationFn:()=>Q.rbac.saveGroup({name:s.trim(),label:S_(l)??null,roles:d,members:p},t?.id),onSuccess:async e=>{await a.invalidateQueries({queryKey:[`rbac`]}),await a.invalidateQueries({queryKey:[`session`]}),i(`/-/groups/${e.id}`,{replace:!0}),E(null)},onError:e=>E(dg(e))}),O=pt({mutationFn:()=>Q.rbac.deleteGroup(t.id),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`rbac`]}),i(`/-/groups`)},onError:e=>E(dg(e))});function k(e){e.preventDefault(),o||D.mutate()}return(0,b.jsxs)(`form`,{onSubmit:k,className:`flex max-w-3xl flex-col gap-5`,"aria-label":n(`rbac.group`),children:[(0,b.jsx)(w_,{children:t?x_(t.label,r)||t.name:n(`rbac.newGroup`)}),T&&(0,b.jsx)(T_,{children:T}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`group-name`,children:n(`rbac.name`)}),(0,b.jsx)(Oh,{id:`group-name`,dir:`ltr`,value:s,disabled:o,onChange:e=>c(e.target.value)})]}),lg.locales.map(e=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`group-label-${e}`,children:n(`rbac.labelIn`,{language:e})}),(0,b.jsx)(Oh,{id:`group-label-${e}`,value:l[e]??``,disabled:o,onChange:t=>u({...l,[e]:t.target.value})})]},e))]}),(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:n(`rbac.roles`)}),e.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:d.includes(e.name),disabled:o,onChange:t=>f(t.target.checked?[...d,e.name]:d.filter(t=>t!==e.name))}),x_(e.label,r)||e.name]},e.name))]}),(0,b.jsxs)(`section`,{"aria-labelledby":`members-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`members-title`,className:`font-medium`,children:n(`rbac.members`)}),(0,b.jsxs)(`ul`,{"aria-label":n(`rbac.members`),className:`flex flex-wrap gap-2`,children:[p.map(e=>(0,b.jsxs)(`li`,{className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-sm`,children:[w(e),!o&&(0,b.jsx)(`button`,{type:`button`,"aria-label":n(`picker.remove`,{name:w(e)}),onClick:()=>m(p.filter(t=>t!==e)),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},e)),p.length===0&&(0,b.jsx)(`li`,{className:`text-sm text-muted-foreground`,children:n(`rbac.noMembers`)})]}),!o&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`member-search`,children:n(`rbac.addMember`)}),(0,b.jsx)(Oh,{id:`member-search`,value:h,placeholder:n(`rbac.searchUsers`),onChange:e=>g(e.target.value)}),(0,b.jsx)(`ul`,{"aria-label":n(`rbac.searchResults`),className:`flex flex-wrap gap-2`,children:(_.data?.items??[]).filter(e=>!p.includes(e.id)).map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{C({...x,[e.id]:e.displayName}),m([...p,e.id])},children:[(0,b.jsx)(fb,{}),e.displayName,e.username?` (${e.username})`:``]})},e.id))})]})]}),!o&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:D.isPending||!s.trim(),children:n(D.isPending?`form.saving`:`form.save`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>i(`/-/groups`),children:n(`common.cancel`)}),t&&(0,b.jsx)(q,{type:`button`,variant:`outline`,className:`ms-auto`,disabled:O.isPending,onClick:()=>O.mutate(),children:n(`form.delete`)})]})]})}var ow=[`view`,`create`,`update`,`delete`,`purge`,`field`,`action`];function sw(e,t){let n=e.split(`.`),r=t.split(`.`),i=r[0]===`page`&&!ow.includes(r[1]??``)&&(r.length===2||r.length===3&&r[2]===`update`);if(n[0]===`*`&&n.length>1&&i)return!1;for(let e=0;e<n.length;e++){let t=n[e];if(t===`*`&&e===n.length-1)return r.length>e;if(e>=r.length||t!==`*`&&t!==r[e])return!1}return n.length===r.length}function cw(e){let t=[...e.global];for(let n of e.resources){for(let r of e.operations)t.push(`${n.name}.${r}`);for(let e of n.custom)t.push(`${n.name}.${e}`);for(let e of n.actions)t.push(`${n.name}.action.${e.name}`)}for(let n of e.pages)t.push(`page.${n.name}`,`page.${n.name}.update`);return t}function lw(e,t){return e.some(e=>sw(e,t))}function uw(e,t,n,r){if(n)return lw(e,t)?e:[...e,t];let i=[];for(let n of e)if(n!==t){if(n.includes(`*`)&&sw(n,t)){for(let e of r)e!==t&&sw(n,e)&&!i.includes(e)&&i.push(e);continue}i.push(n)}return i.filter(e=>e===t||!sw(e,t))}var dw=[`view`,`update`,`delete`];function fw(){let{t:e}=Y(),{name:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`catalog`],queryFn:Q.rbac.catalog}),i=ft({queryKey:[`rbac`,`role`,t],queryFn:()=>Q.rbac.role(t),enabled:!n});return r.isPending||!n&&i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):!n&&i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsx)(pw,{catalog:r.data,role:n?void 0:i.data},t??`new`)}function pw({catalog:e,role:t}){let{t:n,locale:r}=Y(),i=Yi(),a=S(),o=Hg(),s=t?.system===!0||o.data?.rbac.manage!==!0,c=cw(e),[l,u]=(0,y.useState)(t?.name??``),[d,f]=(0,y.useState)(C_(t?.label)),[p,m]=(0,y.useState)(t?.permissions??[]),[h,g]=(0,y.useState)(t?.fields??{}),[_,v]=(0,y.useState)(t?.scopes??{}),[x,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(null),E=pt({mutationFn:()=>{let e={label:S_(d),permissions:p,fields:mw(h),scopes:mw(_)};return t?Q.rbac.updateRole(t.name,e):Q.rbac.createRole({name:l.trim(),...e})},onSuccess:async e=>{await a.invalidateQueries({queryKey:[`rbac`]}),await a.invalidateQueries({queryKey:[`session`]}),i(`/-/roles/${encodeURIComponent(e.name)}`,{replace:!0}),T(null)},onError:e=>T(e instanceof ug?[e.message,...Object.values(e.fields).flat()].join(` — `):dg(e))}),D=pt({mutationFn:()=>Q.rbac.deleteRole(t.name),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`rbac`]}),i(`/-/roles`)},onError:e=>T(dg(e))}),O=(e,t)=>m(n=>uw(n,e,t,c)),k=(e,t,n)=>g(r=>{let i={...r,[e]:{...r[e]}};return n===``?delete i[e][t]:i[e][t]=n,i}),A=(e,t,n,r)=>v(i=>{let a=i[e]?.[t],o=new Set(Array.isArray(a)?a:a?[a]:[]);return r?o.add(n):o.delete(n),{...i,[e]:{...i[e],[t]:[...o]}}});function j(e){e.preventDefault(),s||E.mutate()}let M=[...new Set(e.resources.map(e=>e.group))];return(0,b.jsxs)(`form`,{onSubmit:j,className:`flex max-w-5xl flex-col gap-5`,"aria-label":n(`rbac.role`),children:[(0,b.jsx)(w_,{children:t?x_(t.label,r)||t.name:n(`rbac.newRole`)}),t?.system&&(0,b.jsx)(T_,{tone:`success`,children:n(`rbac.systemNote`)}),w&&(0,b.jsx)(T_,{children:w}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`role-name`,children:n(`rbac.name`)}),(0,b.jsx)(Oh,{id:`role-name`,dir:`ltr`,value:l,disabled:!!t,onChange:e=>u(e.target.value)})]}),lg.locales.map(e=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`role-label-${e}`,children:n(`rbac.labelIn`,{language:e})}),(0,b.jsx)(Oh,{id:`role-label-${e}`,value:d[e]??``,disabled:s,onChange:t=>f({...d,[e]:t.target.value})})]},e))]}),(0,b.jsxs)(`section`,{"aria-labelledby":`matrix-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`matrix-title`,className:`font-medium`,children:n(`rbac.matrix`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b bg-muted/40`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:n(`rbac.resource`)}),e.operations.map(e=>(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.${e}`)},e)),(0,b.jsx)(`th`,{className:`w-0`})]})}),(0,b.jsx)(`tbody`,{children:M.map(t=>(0,b.jsx)(y.Fragment,{children:e.resources.filter(e=>e.group===t).map(t=>{let r=x===t.name,i=`role-details-${t.name}`;return(0,b.jsxs)(y.Fragment,{children:[(0,b.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-normal`,children:t.label}),e.operations.map(e=>{let r=`${t.name}.${e}`;return(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.${e}`),resource:t.label}),checked:lw(p,r),disabled:s,onChange:e=>O(r,e.target.checked)})},e)}),(0,b.jsx)(`td`,{className:`px-2`,children:(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-expanded":r,"aria-controls":i,"aria-label":n(`rbac.details`,{resource:t.label}),onClick:()=>C(r?null:t.name),children:(0,b.jsx)(bv,{className:W(`transition-transform`,r&&`rotate-180`)})})})]}),r&&(0,b.jsx)(`tr`,{id:i,className:`border-b bg-muted/20`,children:(0,b.jsx)(`td`,{colSpan:e.operations.length+2,className:`px-3 py-3`,children:(0,b.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.fields`)}),t.fields.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsxs)(`span`,{children:[e.label,e.restricted&&(0,b.jsx)(`span`,{className:`ms-2 rounded-full bg-amber-500/15 px-2 py-0.5 text-xs text-amber-800 dark:text-amber-300`,children:n(`rbac.restricted`)})]}),(0,b.jsxs)(`select`,{className:`h-8 rounded-lg border border-input bg-transparent px-2 text-sm`,value:h[t.name]?.[e.name]??``,disabled:s,"aria-label":n(`rbac.fieldRule`,{field:e.label}),onChange:n=>k(t.name,e.name,n.target.value),children:[(0,b.jsx)(`option`,{value:``,children:n(e.restricted?`rbac.rule.defaultHidden`:`rbac.rule.default`)}),(0,b.jsx)(`option`,{value:`hidden`,children:n(`rbac.rule.hidden`)}),(0,b.jsx)(`option`,{value:`readonly`,children:n(`rbac.rule.readonly`)}),(0,b.jsx)(`option`,{value:`edit`,children:n(`rbac.rule.edit`)})]})]},e.name))]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.scopes.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.scopes`)}),dw.map(e=>{let r=_[t.name]?.[e],i=Array.isArray(r)?r:r?[r]:[];return(0,b.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,b.jsxs)(`legend`,{className:`me-2 text-sm`,children:[n(`rbac.op.${e}`),`:`]}),t.scopes.map(n=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:i.includes(n),disabled:s,onChange:r=>A(t.name,e,n,r.target.checked)}),n]},n)),i.length===0&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`rbac.allRows`)})]},e)})]}),t.actions.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,"data-actions":t.name,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.actions`)}),t.actions.map(e=>{let n=`${t.name}.action.${e.name}`;return(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,n),disabled:s,onChange:e=>O(n,e.target.checked)}),e.label,(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:n})]},e.name)}),t.actions.some(e=>e.target===`record`)&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`rbac.actionNote`)})]}),t.custom.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.custom`)}),t.custom.map(e=>{let n=`${t.name}.${e}`;return(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,n),disabled:s,onChange:e=>O(n,e.target.checked)}),(0,b.jsx)(`code`,{className:`text-xs`,children:n})]},e)})]})]})]})})})]},t.name)})},t))})]})})]}),e.pages.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`pages-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`pages-title`,className:`font-medium`,children:n(`rbac.pages`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b bg-muted/40`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:n(`rbac.page`)}),(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.view`)}),(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.update`)})]})}),(0,b.jsx)(`tbody`,{children:e.pages.map(e=>{let t=`page.${e.name}`,r=`${t}.update`,i=lw(p,r)&&!lw(p,t);return(0,b.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-normal`,children:e.label}),(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.view`),resource:e.label}),title:i?n(`rbac.viewImplied`):void 0,checked:i||lw(p,t),disabled:s||i,onChange:e=>O(t,e.target.checked)})}),(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.update`),resource:e.label}),checked:lw(p,r),disabled:s,onChange:e=>O(r,e.target.checked)})})]},e.name)})})]})})]}),e.global.length>0&&(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:n(`rbac.global`)}),e.global.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,e),disabled:s,onChange:t=>O(e,t.target.checked)}),(0,b.jsx)(`code`,{className:`text-xs`,children:e})]},e))]}),!s&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:E.isPending||!t&&!l.trim(),children:n(E.isPending?`form.saving`:`form.save`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>i(`/-/roles`),children:n(`common.cancel`)}),t&&(0,b.jsx)(q,{type:`button`,variant:`outline`,className:`ms-auto`,disabled:D.isPending,onClick:()=>D.mutate(),children:n(`form.delete`)})]})]})}function mw(e){let t=Object.entries(e).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0&&!(Array.isArray(e)&&e.length===0)))]).filter(([,e])=>Object.keys(e).length>0);return t.length>0?Object.fromEntries(t):void 0}function hw(){let{t:e,locale:t}=Y(),n=Hg(),r=S(),i=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(null),c=n.data?.rbac.manage===!0,l=pt({mutationFn:async e=>Q.rbac.importRoles(JSON.parse(await e.text())),onSuccess:async t=>{s(e(`rbac.imported`,{count:t.imported.length})),await r.invalidateQueries({queryKey:[`rbac`]})}});async function u(){let e=await Q.rbac.exportRoles(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`roles.json`,n.click(),URL.revokeObjectURL(t)}return i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(q,{variant:`outline`,onClick:()=>void u(),children:[(0,b.jsx)(Hv,{}),e(`rbac.export`)]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`input`,{ref:a,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":e(`rbac.importFile`),onChange:e=>{let t=e.target.files?.[0];t&&l.mutate(t),e.target.value=``}}),(0,b.jsxs)(q,{variant:`outline`,onClick:()=>a.current?.click(),children:[(0,b.jsx)(ox,{}),e(`rbac.import`)]}),(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/roles/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newRole`)]})})]})]}),children:e(`rbac.roles`)}),o&&(0,b.jsx)(T_,{tone:`success`,children:o}),l.isError&&(0,b.jsx)(T_,{children:l.error instanceof SyntaxError?e(`rbac.notJson`):dg(l.error)}),(0,b.jsx)(`ul`,{"aria-label":e(`rbac.roles`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:i.data.items.map(n=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/roles/${encodeURIComponent(n.name)}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsxs)(`span`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(n.label,t)||n.name}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.name})]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e(`rbac.permissionCount`,{count:n.permissions.length}),n.system&&(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5`,children:e(`rbac.system`)})]})]})},n.name))})]})}function gw(){let{t:e}=Y(),t=Hg(),[n,r]=wo(),i=n.get(`search`)??``,a=Math.max(1,Number(n.get(`page`))||1),[o,s]=(0,y.useState)(i),c=ft({queryKey:[`rbac`,`users`,i,a],queryFn:()=>Q.rbac.users({search:i,page:a})});if(c.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(c.isError)return(0,b.jsx)(G,{tone:`error`,children:dg(c.error)});let{items:l,total:u,pageSize:d,capabilities:f}=c.data;return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:t.data?.rbac.manage&&f.create&&(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/users/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newUser`)]})}),children:e(`rbac.users`)}),!f.list&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`rbac.usersFromMemberships`)}),(0,b.jsxs)(`form`,{role:`search`,className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),r(o.trim()?{search:o.trim()}:{})},children:[(0,b.jsx)(Oh,{"aria-label":e(`rbac.searchUsers`),placeholder:e(`rbac.searchUsers`),value:o,onChange:e=>s(e.target.value)}),(0,b.jsx)(q,{type:`submit`,variant:`outline`,children:e(`filters.search`)})]}),(0,b.jsxs)(`ul`,{"aria-label":e(`rbac.users`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:[l.map(t=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/users/${encodeURIComponent(t.id)}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsxs)(`span`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:t.displayName}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[t.username,t.email].filter(Boolean).join(` · `)})]}),(0,b.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[t.isSuperuser&&(0,b.jsx)(`span`,{className:`rounded-full bg-purple-500/15 px-2 py-0.5 text-purple-800 dark:text-purple-300`,children:e(`rbac.superuser`)}),t.isActive===!1&&(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-muted-foreground`,children:e(`rbac.inactive`)}),t.twoFactor&&(0,b.jsx)(`span`,{className:`rounded-full bg-green-500/15 px-2 py-0.5 text-green-800 dark:text-green-300`,children:e(`rbac.twoFactor`)}),t.roles.map(e=>(0,b.jsx)(`span`,{className:`rounded-full border px-2 py-0.5`,children:e},e))]})]})},t.id)),l.length===0&&(0,b.jsx)(`li`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:e(`list.noMatches`)})]}),u>d&&(0,b.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-sm`,children:[(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a<=1,onClick:()=>r({...i?{search:i}:{},page:String(a-1)}),children:e(`list.previousPage`)}),(0,b.jsx)(`span`,{children:e(`list.pageOf`,{page:a,pages:Math.ceil(u/d)})}),(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a*d>=u,onClick:()=>r({...i?{search:i}:{},page:String(a+1)}),children:e(`list.nextPage`)})]})]})}function _w(){let{t:e}=Y(),{id:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),i=ft({queryKey:[`rbac`,`groups`],queryFn:Q.rbac.groups}),a=ft({queryKey:[`rbac`,`user`,t],queryFn:()=>Q.rbac.user(t),enabled:!n}),o=ft({queryKey:[`rbac`,`users`,``,1],queryFn:()=>Q.rbac.users({})});if(r.isPending||i.isPending||o.isPending||!n&&a.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});let s=r.error??i.error??o.error??(n?null:a.error);return s?(0,b.jsx)(G,{tone:`error`,children:dg(s)}):(0,b.jsx)(vw,{user:n?void 0:a.data,roles:r.data.items,groups:i.data.items,capabilities:o.data.capabilities},t??`new`)}function vw({user:e,roles:t,groups:n,capabilities:r}){let{t:i,locale:a}=Y(),o=Yi(),s=S(),c=Hg(),l=c.data?.rbac.manage===!0,u=c.data?.user.isSuperuser===!0,[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(e?.displayName??``),[h,g]=(0,y.useState)(e?.email??``),[_,v]=(0,y.useState)(e?.isActive!==!1),[x,C]=(0,y.useState)(e?.isSuperuser===!0),[w,T]=(0,y.useState)(e?.roles??[]),[E,D]=(0,y.useState)(e?.groups??[]),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)({}),[M,N]=(0,y.useState)(null),[ee,te]=(0,y.useState)(null),P=l&&(!e?.isSuperuser||u),ne=e=>{e instanceof ug&&Object.keys(e.fields).length>0?(j(e.fields),N(e.message)):(j({}),N(dg(e)))},re=pt({mutationFn:()=>{let t=r.update||!e?{displayName:p,email:h||null,isActive:_,...u?{isSuperuser:x}:{}}:{};return e?Q.rbac.updateUser(e.id,{...t,roles:w,groups:E}):Q.rbac.createUser({username:d,displayName:p,email:h||null,password:O,...u?{isSuperuser:x}:{},roles:w,groups:E})},onSuccess:async e=>{await s.invalidateQueries({queryKey:[`rbac`]}),j({}),N(null),te(i(`rbac.saved`)),o(`/-/users/${encodeURIComponent(e.id)}`,{replace:!0})},onError:ne}),ie=pt({mutationFn:()=>Q.rbac.resetTwoFactor(e.id),onSuccess:async()=>{await s.invalidateQueries({queryKey:[`rbac`]}),N(null),te(i(`rbac.twoFactorReset`))},onError:ne}),ae=!!e&&u&&!c.data?.viewAs&&e.id!==c.data?.user.id&&e.isActive!==!1,oe=pt({mutationFn:()=>Q.rbac.setPassword(e.id,O),onSuccess:()=>{k(``),j({}),N(null),te(i(`rbac.passwordSet`))},onError:ne});function se(e){e.preventDefault(),te(null),P&&re.mutate()}let ce=(t,n,i,a,o={})=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:t,children:n}),(0,b.jsx)(Oh,{id:t,value:i,disabled:!P||!!e&&!r.update,onChange:e=>a(e.target.value),"aria-invalid":A[t.replace(`user-`,``)]?!0:void 0,...o}),A[t.replace(`user-`,``)]&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:A[t.replace(`user-`,``)].join(` `)})]});return(0,b.jsxs)(`form`,{onSubmit:se,className:`flex max-w-3xl flex-col gap-5`,"aria-label":i(`rbac.user`),children:[(0,b.jsx)(w_,{actions:ae&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,onClick:()=>{Sg(e.id),s.clear(),o(`/`)},children:[(0,b.jsx)(Xv,{}),i(`viewAs.start`)]}),children:e?e.displayName:i(`rbac.newUser`)}),M&&(0,b.jsx)(T_,{children:M}),ee&&(0,b.jsx)(T_,{tone:`success`,children:ee}),e?.isSuperuser&&!u&&(0,b.jsx)(T_,{tone:`success`,children:i(`rbac.superuserNote`)}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[!e&&ce(`user-username`,i(`auth.username`),d,f,{dir:`ltr`,autoComplete:`off`}),ce(`user-displayName`,i(`rbac.displayName`),p,m),ce(`user-email`,i(`rbac.email`),h,g,{type:`email`,dir:`ltr`}),!e&&ce(`user-password`,i(`auth.password`),O,k,{type:`password`,autoComplete:`new-password`})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-6 text-sm`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:_,disabled:!P||!!e&&!r.update,onChange:e=>v(e.target.checked)}),i(`rbac.active`)]}),u&&(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:x,disabled:!P,onChange:e=>C(e.target.checked)}),i(`rbac.superuser`)]})]}),(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:i(`rbac.roles`)}),t.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:w.includes(e.name),disabled:!P,onChange:t=>T(t.target.checked?[...w,e.name]:w.filter(t=>t!==e.name))}),x_(e.label,a)||e.name]},e.name))]}),n.length>0&&(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:i(`rbac.groups`)}),n.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:E.includes(e.id),disabled:!P,onChange:t=>D(t.target.checked?[...E,e.id]:E.filter(t=>t!==e.id))}),x_(e.label,a)||e.name]},e.id))]}),P&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:re.isPending,children:i(re.isPending?`form.saving`:e?`form.save`:`rbac.createUser`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>o(`/-/users`),children:i(`common.cancel`)})]}),e&&P&&r.password&&(0,b.jsxs)(`section`,{"aria-labelledby":`set-password`,className:`flex flex-col gap-2 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsx)(`h2`,{id:`set-password`,className:`font-medium`,children:i(`rbac.setPassword`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`user-new-password`,children:i(`auth.newPassword`)}),(0,b.jsx)(Oh,{id:`user-new-password`,type:`password`,autoComplete:`new-password`,value:O,onChange:e=>k(e.target.value)})]}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:!O||oe.isPending,onClick:()=>oe.mutate(),children:i(`rbac.setPassword`)})]}),A.password&&e&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:A.password.join(` `)}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`rbac.setPasswordNote`)})]}),e?.twoFactor&&P&&r.resetTwoFactor&&(0,b.jsxs)(`section`,{"aria-labelledby":`reset-two-factor`,className:`flex flex-col gap-2 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsx)(`h2`,{id:`reset-two-factor`,className:`font-medium`,children:i(`rbac.resetTwoFactor`)}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`rbac.resetTwoFactorNote`)}),(0,b.jsx)(`div`,{children:(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:ie.isPending,onClick:()=>ie.mutate(),children:i(`rbac.resetTwoFactor`)})})]})]})}function yw(e){if(!e.menu)return e.groups.map(e=>({...e,items:[...e.resources.map(e=>({kind:`resource`,name:e.name,label:e.label,...e.icon?{icon:e.icon}:{}})),...e.pages.map(e=>({kind:`page`,name:e.name,label:e.label,...e.icon?{icon:e.icon}:{}}))]}));let{sections:t,advanced:n}=e.menu;return[...t,...n.items.length>0?[n]:[]].map(e=>{let t=[],r=[],i=e.items.map(n=>n.kind===`resource`?(t.push({name:n.resource,label:n.label,...n.icon?{icon:n.icon}:{},creatable:n.creatable,searchable:n.searchable}),{kind:`resource`,name:n.resource,label:n.label,...n.icon?{icon:n.icon}:{},...n.badge?{badge:`${e.key}.${n.resource}`}:{}}):n.kind===`page`?(r.push({name:n.page,label:n.label,...n.icon?{icon:n.icon}:{}}),{kind:`page`,name:n.page,label:n.label,...n.icon?{icon:n.icon}:{}}):n);return{key:e.key,label:e.label,...e.icon?{icon:e.icon}:{},resources:t,pages:r,items:i,...e===n?{advanced:!0}:{}}})}function bw(e,t){let n=e.flatMap(e=>e.kind===`resource`&&e.badge&&t?.[e.badge]?[t[e.badge]]:[]);if(n.length!==0)return{count:n.reduce((e,t)=>e+t.count,0),estimate:n.some(e=>e.estimate)}}function xw({menu:e,current:t}){return e&&!t}function Sw(e){return Mh(e).toLocaleLowerCase().replace(/[يى]/g,`ی`).replace(/ك/g,`ک`).replace(//g,` `)}function Cw(e,t){let n=Sw(e);return Sw(t).split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function ww(e,t,n,r=[]){let i=[],a=[],o=yw(e),s=t.trim()!==``;for(let r of o){o.length>1&&Cw(r.label,t)&&i.push({id:`group:${r.key}`,section:`go`,label:r.label,to:`/g/${r.key}`,...r.icon?{icon:r.icon}:{}});for(let o of r.resources){let c=o.icon??r.icon;Cw(`${o.label} ${r.label}`,t)&&i.push({id:`go:${o.name}`,section:`go`,label:o.label,detail:r.label,to:`/${o.name}`,...c?{icon:c}:{}});let l=n(o.label),u=s||e.menu!==void 0&&!r.advanced&&a.length<3;o.creatable&&u&&Cw(l,t)&&a.push({id:`new:${o.name}`,section:`actions`,label:l,to:`/${o.name}/new`})}for(let e of r.pages){let n=e.icon??r.icon;Cw(`${e.label} ${r.label}`,t)&&i.push({id:`page:${e.name}`,section:`go`,label:e.label,detail:r.label,to:`/p/${e.name}`,...n?{icon:n}:{}})}}let c=r.filter(e=>Cw(e.label,t)).map(e=>({id:e.id,section:`actions`,label:e.label}));return[...i,...a,...c]}var Tw=`nma.theme`,Ew=`oklch(0.145 0 0)`,Dw=`oklch(0.985 0 0)`;function Ow(){try{let e=localStorage.getItem(Tw);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}function kw(e,t){return e===`system`?t?`dark`:`light`:e}var Aw=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches;function jw(e){let t=kw(e,Aw());document.documentElement.classList.toggle(`dark`,t===`dark`),document.documentElement.style.colorScheme=t}var Mw=`nma-theme`;function Nw(e){try{localStorage.setItem(Tw,e)}catch{}jw(e),typeof window<`u`&&window.dispatchEvent(new Event(Mw))}function Pw(){Nw(kw(Ow(),Aw())===`dark`?`light`:`dark`)}function Fw(e){if(typeof matchMedia!=`function`)return()=>void 0;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>{e()===`system`&&jw(`system`)};return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}function Iw(e){let t,n=/^#([0-9a-f]{3,8})$/i.exec(e.trim())?.[1];if(n){let e=n.length<=4?[...n.slice(0,3)].map(e=>e+e).join(``):n.slice(0,6);t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(e.trim());n&&(t=n.slice(1,4).map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function Lw(e){let t={};if(e.primaryColor){let n=Iw(e.primaryColor),r=e.primaryForeground??(n!==void 0&&n>.45?Ew:Dw);Object.assign(t,{"--primary":e.primaryColor,"--primary-foreground":r,"--ring":e.primaryColor,"--sidebar-primary":e.primaryColor,"--sidebar-primary-foreground":r})}return e.radius&&Object.assign(t,{"--nma-radius-control":e.radius,"--nma-radius-card":`calc(${e.radius} * 1.5)`}),t}function Rw(e){for(let[t,n]of Object.entries(Lw(e)))document.documentElement.style.setProperty(t,n)}var zw=`nma.accent`,Bw=`nma-accent`,Vw=/^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([0-9.,%\s/+-]+(deg|turn|rad)?[0-9.,%\s/+-]*\))$/i;function Hw(e){return(e.personal&&Vw.test(e.personal.trim())?e.personal:null)??e.admin??e.branding??void 0}function Uw(){try{return localStorage.getItem(zw)}catch{return null}}function Ww(e){try{e===null?localStorage.removeItem(zw):localStorage.setItem(zw,e)}catch{}}var Gw=null,Kw;function qw(e={}){`admin`in e&&(Gw=e.admin??null),`branding`in e&&(Kw=e.branding);let t=Hw({personal:Uw(),admin:Gw,branding:Kw}),n=[`--primary`,`--primary-foreground`,`--ring`,`--sidebar-primary`,`--sidebar-primary-foreground`];if(t)for(let[e,n]of Object.entries(Lw({primaryColor:t})))document.documentElement.style.setProperty(e,n);else for(let e of n)document.documentElement.style.removeProperty(e);typeof window<`u`&&window.dispatchEvent(new Event(Bw))}var Jw={archive:B_,ban:X_,bell:Q_,book:ev,box:nv,boxes:iv,briefcase:ov,building:cv,calendar:mv,chart:gv,check:vv,clock:Av,"credit-card":Iv,database:Rv,dollar:Bv,file:ny,"file-text":ey,folder:iy,globe:oy,heart:uy,history:bb,home:fy,image:gy,inbox:vy,key:by,layers:wy,link:Oy,list:Py,lock:Iy,mail:By,map:Wy,"map-pin":Hy,message:Jy,package:eb,phone:ob,printer:mb,receipt:gb,refresh:vb,send:Eb,server:Ob,settings:Ab,shield:Pb,"shopping-bag":Ib,cart:Rb,"shopping-cart":Rb,star:Hb,store:Wb,tag:Jb,tags:Xb,ticket:Qb,truck:ix,user:ux,users:fx,video:mx,wallet:gx,wrench:vx,x:bx,zap:Sx};Object.keys(Jw);function Yw(e,t){return Xw(e)??(t===`group`?iy:t===`page`?Ab:ey)}function Xw(e){return e&&Object.hasOwn(Jw,e)?Jw[e]:void 0}function Zw(e,t){let[n,r]=(0,y.useState)(e);return(0,y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function Qw(){let{t:e}=Y(),t=Yi(),n=Ug(),r=Hg(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(0),u=(0,y.useId)(),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),a(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let f=Zw(o.trim(),250),p=f.length>=2&&(n.data?.groups.some(e=>e.resources.some(e=>e.searchable))??!1),m=ft({queryKey:[`search`,f],queryFn:()=>Q.search(f),enabled:i&&p,staleTime:1e4}),h=e=>{let t=n.data?yw(n.data).find(t=>t.resources.some(t=>t.name===e)):void 0;return t?.resources.find(t=>t.name===e)?.icon??t?.icon},g=n.data?ww(n.data,o,t=>e(`palette.new`,{name:t}),[{id:`theme`,label:e(`palette.toggleTheme`)}]):[],_=[...p&&o.trim()===f?(m.data?.groups??[]).flatMap(e=>e.items.map(t=>({id:`record:${e.resource}:${t._id}`,section:`records`,...h(e.resource)?{icon:h(e.resource)}:{},label:t._title,detail:e.label,to:`/${e.resource}/${encodeURIComponent(t._id)}`}))):[],...g.filter(e=>e.section===`actions`),...g.filter(e=>e.section===`go`),...r.data?.audit.view&&Cw(e(`audit.title`),o)?[{id:`audit`,section:`go`,label:e(`audit.title`),to:`/-/audit`}]:[]],v=Math.min(c,Math.max(0,_.length-1));(0,y.useEffect)(()=>l(0),[o,m.data]),(0,y.useEffect)(()=>{d.current?.querySelector(`[data-index="${v}"]`)?.scrollIntoView({block:`nearest`})},[v]);function x(e){e&&(a(!1),e.to?t(e.to):e.id===`theme`&&Pw())}function S(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),_.length===0)return;l((v+(e.key===`ArrowDown`?1:-1)+_.length)%_.length)}else e.key===`Enter`&&(e.preventDefault(),x(_[v]))}let C=[[`records`,e(`palette.records`)],[`actions`,e(`palette.actions`)],[`go`,e(`palette.goTo`)]],w=e=>`${u}-${e}`,T=p&&(m.isFetching||o.trim()!==f)?e(`palette.searching`):_.length===0?e(`palette.noResults`):``;return(0,b.jsxs)(jd,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,b.jsx)(Nd,{asChild:!0,children:(0,b.jsxs)(q,{variant:`outline`,className:`w-9 justify-start px-0 font-normal text-muted-foreground max-sm:justify-center sm:w-[260px] sm:px-3.5`,"aria-keyshortcuts":`Control+K Meta+K`,"aria-label":e(`palette.open`),children:[(0,b.jsx)(wb,{}),(0,b.jsx)(`span`,{className:`hidden min-w-0 flex-1 truncate text-start sm:inline`,children:e(`palette.placeholder`)}),(0,b.jsx)(`kbd`,{className:`hidden shrink-0 rounded-[5px] border border-border bg-muted px-[5px] py-px font-mono text-[11px] text-muted-foreground sm:inline`,dir:`ltr`,children:`⌘K`})]})}),(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/30`}),(0,b.jsxs)(Ud,{"aria-describedby":void 0,className:`fixed inset-x-3 top-[12vh] z-50 mx-auto flex max-h-[70vh] max-w-[540px] flex-col overflow-hidden rounded-card border border-border bg-card text-card-foreground shadow-[0_24px_48px_rgba(0,0,0,.18)] outline-none`,children:[(0,b.jsx)(Jd,{className:`sr-only`,children:e(`palette.open`)}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-border px-4`,children:[(0,b.jsx)(wb,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`input`,{role:`combobox`,"aria-expanded":!0,"aria-controls":u,"aria-autocomplete":`list`,"aria-activedescendant":_.length>0?w(v):void 0,"aria-label":e(`palette.open`),placeholder:e(`palette.placeholder`),className:`h-[52px] flex-1 bg-transparent text-sm outline-none`,value:o,onChange:e=>s(e.target.value),onKeyDown:S}),(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] py-px font-mono text-[11px] text-muted-foreground`,dir:`ltr`,children:`Esc`})]}),(0,b.jsx)(`ul`,{ref:d,id:u,role:`listbox`,"aria-label":e(`palette.results`),className:`flex-1 overflow-y-auto p-1.5`,children:C.map(([e,t])=>{let n=_.map((e,t)=>({item:e,index:t})).filter(({item:t})=>t.section===e);return n.length===0?null:(0,b.jsxs)(`li`,{role:`presentation`,children:[(0,b.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground`,"aria-hidden":!0,children:t}),(0,b.jsx)(`ul`,{role:`group`,"aria-label":t,children:n.map(({item:e,index:t})=>(0,b.jsxs)(`li`,{id:w(t),role:`option`,"aria-selected":t===v,"data-index":t,className:W(`flex h-10 cursor-pointer items-center gap-3 rounded-control px-2.5 text-[13.5px]`,t===v&&`bg-muted`),onMouseMove:()=>l(t),onClick:()=>x(e),children:[(0,b.jsx)($w,{item:e}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.section===`go`&&e.detail?`${e.detail} › ${e.label}`:e.label}),e.section===`records`&&e.detail&&(0,b.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.detail})]},e.id))})]},e)})}),(0,b.jsx)(`p`,{role:`status`,className:W(`px-4 text-sm text-muted-foreground`,T&&`border-t border-border py-2`),children:T}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 border-t border-border px-4 py-2.5 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,children:`↑↓`}),e(`palette.move`)]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,children:`↵`}),e(`palette.openItem`)]}),(0,b.jsxs)(`span`,{className:`ms-auto flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,dir:`ltr`,children:`⌘K`}),e(`palette.close`)]})]})]})]})]})}function $w({item:e}){let t=e.id.startsWith(`new:`)?fb:e.id===`theme`?Qy:Yw(e.icon,e.section===`records`?`resource`:`group`);return(0,b.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})}var eT={en:`English`,fa:`فارسی`};function tT(){let{t:e}=Y(),[t,n]=(0,y.useState)(Ow),r=[[`light`,e(`shell.themeLight`),Kb],[`dark`,e(`shell.themeDark`),Qy],[`system`,e(`shell.themeSystem`),Xy]];return(0,b.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`shell.theme`),className:`flex items-center rounded-control border border-border p-0.5`,children:r.map(([e,r,i])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,"aria-label":r,title:r,className:W(`rounded-md p-1.5 text-muted-foreground hover:text-foreground`,t===e&&`bg-muted text-foreground`),onClick:()=>{Nw(e),n(e)},children:(0,b.jsx)(i,{className:`size-4`})},e))})}function nT(){let{t:e,locale:t,locales:n,setLocale:r}=Y();return n.length<2?null:(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,b.jsx)(Sy,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`shell.language`)}),(0,b.jsx)(`select`,{className:`h-8 flex-1 rounded-control border border-input bg-card px-2 text-[13px]`,value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,b.jsx)(`option`,{value:e,lang:e,children:eT[e]??e},e))})]})}function rT(){let{t:e,calendar:t,digits:n,setDisplay:r}=Y(),i=(e,t,n,r)=>(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,b.jsx)(`div`,{className:`flex rounded-control border border-border p-0.5`,children:n.map(([e,n])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,className:W(`flex-1 cursor-pointer rounded-md px-2 py-1 text-[13px] text-muted-foreground hover:text-foreground`,t===e&&`bg-muted text-foreground`),onClick:()=>r(e),children:n},e))})]});return(0,b.jsxs)(b.Fragment,{children:[i(e(`display.calendar`),t,[[`gregorian`,e(`display.gregorian`)],[`persian`,e(`display.jalali`)]],e=>r({calendar:e})),i(e(`display.digits`),n,[[`latn`,e(`display.latinDigits`)],[`arabext`,e(`display.persianDigits`)]],e=>r({digits:e}))]})}function iT(){let{t:e}=Y(),[t,n]=(0,y.useState)(Ow);(0,y.useEffect)(()=>{let e=()=>n(Ow());return window.addEventListener(Mw,e),()=>window.removeEventListener(Mw,e)},[]);let r=t===`dark`||t===`system`&&typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,b.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":e(`shell.theme`),title:e(`shell.theme`),onClick:Pw,children:r?(0,b.jsx)(Kb,{}):(0,b.jsx)(Qy,{})})}var aT=[`#5B5BD6`,`#2563EB`,`#0E7490`,`#0F766E`,`#9333EA`,`#DB2777`,`#EA580C`];function oT(){let{t:e}=Y(),t=Hg(),n=S(),[r,i]=(0,y.useState)(Uw);(0,y.useEffect)(()=>{let e=()=>i(Uw());return window.addEventListener(Bw,e),()=>window.removeEventListener(Bw,e)},[]);let a=t.data?.appearance,o=pt({mutationFn:e=>Q.setAppearance(e),onSuccess:async({accent:e})=>{Ww(null),qw({admin:e}),await n.invalidateQueries({queryKey:[`session`]})}}),s=e=>{Ww(e),qw()},c=r??a?.accent??null;return(0,b.jsxs)(`div`,{role:`group`,"aria-label":e(`display.accent`),className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e(`display.accent`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[aT.map(e=>(0,b.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":c?.toLowerCase()===e.toLowerCase(),className:W(`size-6 cursor-pointer rounded-full border-2 border-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring`,c?.toLowerCase()===e.toLowerCase()&&`border-foreground`),style:{background:e},onClick:()=>s(e)},e)),(0,b.jsx)(`button`,{type:`button`,className:`size-6 cursor-pointer overflow-hidden rounded-full border border-border bg-[conic-gradient(red,yellow,lime,aqua,blue,magenta,red)]`,"aria-label":e(`display.customAccent`),title:e(`display.customAccent`),onClick:()=>cT(c)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,"aria-pressed":r===null,onClick:()=>s(null),children:e(`display.defaultAccent`)})]}),a?.manage&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:o.isPending||!r||r===a.accent,onClick:()=>o.mutate(r),children:e(`display.accentForEveryone`)}),a.accent&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:o.isPending,onClick:()=>o.mutate(null),children:e(`display.resetForEveryone`)})]}),o.isError&&(0,b.jsx)(`p`,{className:`text-xs text-destructive`,children:dg(o.error)})]})}var sT=null;function cT(e){sT&&(e&&/^#[0-9a-f]{6}$/i.test(e)&&(sT.value=e),sT.click())}function lT(){return(0,b.jsx)(`input`,{ref:e=>{sT=e},type:`color`,tabIndex:-1,"aria-hidden":!0,className:`pointer-events-none fixed bottom-0 start-0 size-px opacity-0`,onInput:e=>{Ww(e.currentTarget.value),qw()}})}var uT=`nma.nav`,dT={pinned:[],recent:[],collapsedGroups:[],expandedGroups:[],railCollapsed:!1};function fT(e){let t=dT;try{let n=e?.getItem(uT);n&&(t={...dT,...JSON.parse(n)})}catch{t=dT}let n=new Set,r=r=>{t=r;try{e?.setItem(uT,JSON.stringify(r))}catch{}for(let e of n)e()},i=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t];return{get:()=>t,subscribe(e){return n.add(e),()=>n.delete(e)},togglePin:e=>r({...t,pinned:i(t.pinned,e)}),visit:e=>{t.recent[0]!==e&&r({...t,recent:[e,...t.recent.filter(t=>t!==e)].slice(0,5)})},toggleGroup:(e,n=!1)=>{let i=_T(t,e,n),a=t=>t.filter(t=>t!==e);r({...t,collapsedGroups:i?a(t.collapsedGroups):[...a(t.collapsedGroups),e],expandedGroups:i?[...a(t.expandedGroups),e]:a(t.expandedGroups)})},toggleRail:()=>r({...t,railCollapsed:!t.railCollapsed})}}function pT(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var mT=fT(pT());function hT(){return(0,y.useSyncExternalStore)(mT.subscribe,mT.get)}function gT(e,t){return e.filter(e=>t.has(e))}function _T(e,t,n){return e.collapsedGroups.includes(t)?!0:!e.expandedGroups.includes(t)&&n}function vT(e){let{t}=Y(),[n,r,i]=qi().pathname.split(`/`).filter(Boolean).map(e=>decodeURIComponent(e)),a=n&&n!==`g`&&n!==`p`&&n!==`-`&&r&&r!==`new`?r:void 0,o=Jg(n??``,a),s=!!n&&![`g`,`p`,`-`,`account`].includes(n),c=Wg(n??``,s&&e!==void 0&&!yw(e).some(e=>e.resources.some(e=>e.name===n))),l=[{label:t(e?.dashboard?`shell.dashboard`:`shell.home`),to:`/`}];if(n===`account`&&!r)return[...l,{label:t(`auth.account`)}];if(n===`-`&&(r===`users`||r===`groups`||r===`roles`||r===`debugger`||r===`audit`)){let e={users:t(`rbac.users`),groups:t(`rbac.groups`),roles:t(`rbac.roles`),debugger:t(`debugger.title`),audit:t(`audit.title`)}[r];return l.push({label:t(`rbac.administration`)},{label:e,to:`/-/${r}`}),i&&l.push({label:i===`new`?t(`list.new`):i}),l}if(!n||!e)return l;let u=yw(e);if(n===`g`){let e=u.find(e=>e.key===r);return e&&l.push({label:e.label}),l}if(n===`p`){let e=u.find(e=>e.pages.some(e=>e.name===r)),t=e?.pages.find(e=>e.name===r);return e&&t&&l.push({label:e.label,to:`/g/${e.key}`},{label:t.label}),l}let d=u.find(e=>e.resources.some(e=>e.name===n)),f=d?.resources.find(e=>e.name===n);return!d||!f?c.data?(l.push({label:c.data.label,to:`/${n}`}),a&&l.push({label:typeof o.data?._title==`string`?o.data._title:`#${a}`}),l):l:(l.push({label:d.label,to:`/g/${d.key}`},{label:f.label,to:`/${f.name}`}),r===`new`?l.push({label:t(`form.new`,{name:f.label})}):a&&l.push({label:typeof o.data?._title==`string`?o.data._title:`#${a}`}),l)}function yT({meta:e,onOpenMenu:t}){let{t:n}=Y(),r=hT(),i=vT(e),a=i.length-1;return(0,b.jsxs)(`header`,{className:`flex h-14 items-center gap-2 border-b border-border bg-card px-5`,children:[(0,b.jsx)(q,{variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":n(`shell.menu`),onClick:t,"data-sidebar-toggle":``,children:(0,b.jsx)(Ky,{})}),(0,b.jsx)(q,{variant:`ghost`,size:`icon`,className:`hidden md:inline-flex`,"aria-label":n(r.railCollapsed?`shell.expandSidebar`:`shell.collapseSidebar`),"aria-pressed":r.railCollapsed,onClick:()=>mT.toggleRail(),"data-sidebar-toggle":``,children:(0,b.jsx)(nb,{className:`ltr:-scale-x-100`})}),(0,b.jsx)(`div`,{className:`hidden h-5 w-px bg-border md:block`,"aria-hidden":!0}),(0,b.jsx)(`nav`,{"aria-label":n(`shell.breadcrumbs`),className:`min-w-0 flex-1 ps-1`,children:(0,b.jsx)(`ol`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted-foreground`,children:i.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(Sv,{className:`size-3.5 shrink-0 ltr:rotate-180`,"aria-hidden":!0}),(0,b.jsx)(`li`,{className:t===a?`truncate font-medium text-foreground`:`hidden truncate sm:block`,children:e.to&&t!==a?(0,b.jsx)(bo,{to:e.to,className:`hover:text-foreground`,children:e.label}):(0,b.jsx)(`span`,{"aria-current":t===a?`page`:void 0,children:e.label})})]},`${t}:${e.label}`))})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(Qw,{}),(0,b.jsx)(iT,{})]})]})}function bT({rail:e=!1}){let{t}=Y(),n=Hg(),r=Yi(),i=S(),a=n.data;if(!a)return null;let{user:o,auth:s}=a,c=o.displayName.split(/\s+/).filter(Boolean).slice(0,2).map(e=>[...e][0].toUpperCase()).join(``);async function l(){try{await Q.logout()}finally{mg(void 0),Sg(void 0),i.clear(),r(`/login`,{replace:!0})}}return(0,b.jsxs)(Sh,{children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,"aria-label":t(`auth.userMenu`,{name:o.displayName}),"data-user-block":``,className:W(`flex cursor-pointer items-center gap-2.5 rounded-control text-start hover:bg-muted`,e?`size-10 justify-center`:`px-2.5 py-2`),children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-[13px] font-semibold`,children:c||(0,b.jsx)(cx,{className:`size-4`})}),!e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`min-w-0 flex-1 leading-[1.35]`,children:[(0,b.jsx)(`span`,{className:`block truncate text-[13px] font-medium`,children:o.displayName}),(o.username||o.email)&&(0,b.jsx)(`span`,{className:`block truncate text-[11.5px] text-muted-foreground`,children:o.email??o.username})]}),(0,b.jsx)(Wv,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{side:`top`,align:`start`,sideOffset:6,className:`z-50 flex w-64 flex-col gap-1 rounded-[10px] border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:[(s.password||s.sessions||s.twoFactor)&&!a.viewAs&&(0,b.jsx)(Eh,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/account`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-[13px] hover:bg-muted`,children:[(0,b.jsx)(cx,{className:`size-4`}),t(`auth.account`)]})}),a.audit.view&&(0,b.jsx)(Eh,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/audit`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-[13px] hover:bg-muted`,children:[(0,b.jsx)(bb,{className:`size-4`}),t(`audit.title`)]})}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 border-y border-border px-2 py-2`,children:[(0,b.jsx)(nT,{}),(0,b.jsx)(rT,{}),(0,b.jsx)(tT,{}),(0,b.jsx)(oT,{})]}),s.logout&&!a.open&&(0,b.jsxs)(`button`,{type:`button`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-start text-[13px] hover:bg-muted`,onClick:()=>void l(),children:[(0,b.jsx)(Ry,{className:`size-4 rtl:-scale-x-100`}),t(`auth.signOut`)]})]})})]})}var xT=`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-control px-2.5 text-start text-[13.5px] text-sidebar-foreground hover:bg-muted`,ST=({isActive:e})=>W(`flex h-8 items-center rounded-[7px] px-2.5 text-[13px] text-muted-foreground hover:bg-muted hover:text-foreground`,e&&`bg-primary-soft font-semibold text-primary-text hover:bg-primary-soft hover:text-primary-text`);function CT(e){return e.kind===`resource`?{key:e.name,to:`/${e.name}`,label:e.label,pin:e.name,...e.badge?{badge:e.badge}:{}}:e.kind===`page`?{key:`page:${e.name}`,to:`/p/${e.name}`,label:e.label}:{key:`link:${e.href}`,to:e.href,label:e.label,external:/^https?:\/\//i.test(e.href)}}var wT=(e,t)=>!t.external&&(e===t.to||e.startsWith(`${t.to}/`));function TT(e,t,n,r,i){let a=e.map(e=>{let r=e.items.map(CT);return{key:e.key,label:e.label,icon:Yw(e.icon,`group`),entries:r,collapsedByDefault:xw({menu:t,current:r.some(e=>wT(n,e))}),asLink:t&&!e.advanced&&r.length===1}});return r.length>0?[{key:`~pinned`,label:i,icon:ub,entries:r},...a]:a}function ET({title:e,logo:t,groups:n,menu:r,rail:i=!1,onClose:a}){let{t:o}=Y(),s=hT(),{pathname:c}=qi(),l=Gg(r).data,u=new Map(n.flatMap(e=>e.items.flatMap(e=>e.kind===`resource`?[[e.name,CT(e)]]:[]))),d=TT(n,r,c,gT(s.pinned,new Set(u.keys())).map(e=>u.get(e)),o(`shell.pinned`)),f=d.find(e=>n.some(t=>t.advanced&&t.key===e.key)),p=d.filter(e=>e!==f),m=NT(),h=(e,t=!1)=>i?(0,b.jsx)(jT,{section:e,muted:t},e.key):(0,b.jsx)(AT,{section:e,collapsed:_T(s,e.key,e.collapsedByDefault??!1),badges:l,muted:t,large:!!a},e.key);return(0,b.jsxs)(`nav`,{"aria-label":o(`shell.resources`),className:`flex h-full flex-col`,children:[(0,b.jsx)(kT,{title:e,logo:t,rail:i,onClose:a}),(0,b.jsxs)(`div`,{className:W(`flex flex-1 flex-col gap-0.5 overflow-y-auto`,i?`items-center px-0 py-2.5`:`p-2.5`),children:[r&&(0,b.jsx)(DT,{to:`/`,label:o(`shell.dashboard`),icon:Ey,rail:i,large:!!a,end:!0}),p.map(e=>h(e))]}),(0,b.jsxs)(`div`,{className:W(`flex flex-col gap-1 border-t border-sidebar-border`,i?`items-center px-0 py-2.5`:`p-2.5`),children:[f&&h(f,!0),m&&h(m,!0),(0,b.jsx)(bT,{rail:i})]})]})}function DT({to:e,label:t,icon:n,rail:r,large:i,end:a,external:o,count:s}){let c=({isActive:e})=>r?W(`flex size-10 items-center justify-center rounded-control hover:bg-muted`,e&&`bg-primary-soft text-primary-text hover:bg-primary-soft`):W(xT,i&&`h-11 text-[15px]`,e&&`bg-primary-soft font-semibold text-primary-text hover:bg-primary-soft`),l=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),!r&&(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:t}),!r&&s&&(0,b.jsx)(OT,{count:s})]});return o?(0,b.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,"aria-label":r?t:void 0,title:r?t:void 0,className:c({isActive:!1}),children:l}):(0,b.jsx)(xo,{to:e,end:a,"aria-label":r?t:void 0,title:r?t:void 0,className:c,children:l})}function OT({count:e,strong:t}){return(0,b.jsxs)(`span`,{className:W(`inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full px-1.5 text-[11px]`,t?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`),children:[e.estimate?`~`:``,Qh(e.count)]})}function kT({title:e,logo:t,rail:n,onClose:r}){let{t:i}=Y(),a=t?(0,b.jsx)(`img`,{src:t,alt:``,className:`size-[30px] shrink-0 rounded-control object-contain`}):(0,b.jsx)(`span`,{"aria-hidden":!0,className:`flex size-[30px] shrink-0 items-center justify-center rounded-control bg-primary font-bold text-primary-foreground`,children:[...e.trim()][0]??``});return(0,b.jsxs)(`div`,{className:W(`flex h-14 shrink-0 items-center gap-2.5 border-b border-sidebar-border`,n?`justify-center`:`px-4`),children:[a,!n&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`min-w-0 flex-1 leading-[1.3]`,children:[(0,b.jsx)(`div`,{className:W(`truncate font-semibold`,r?`text-[15px]`:`text-sm`),children:e}),!r&&(0,b.jsx)(`div`,{className:`text-[11.5px] text-muted-foreground`,children:i(`shell.adminPanel`)})]}),r?(0,b.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":i(`shell.closeMenu`),onClick:r,children:(0,b.jsx)(bx,{})}):(0,b.jsx)(Ev,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})}function AT({section:e,collapsed:t,badges:n,muted:r,large:i}){let{t:a}=Y(),o=e.icon,s=`nav-group-${e.key}`,c=bw(e.entries.flatMap(e=>e.badge?[{kind:`resource`,name:e.key,label:e.label,badge:e.badge}]:[]),n);if(e.asLink){let[t]=e.entries;return(0,b.jsx)(DT,{to:t.to,label:e.label,icon:o,rail:!1,large:i,external:t.external,count:t.badge?n?.[t.badge]:void 0})}return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`button`,{type:`button`,className:W(xT,i&&`h-11 text-[15px]`,r&&`text-muted-foreground`),"aria-expanded":!t,"aria-controls":s,"aria-label":a(t?`shell.expandGroup`:`shell.collapseGroup`,{name:e.label}),onClick:()=>mT.toggleGroup(e.key,e.collapsedByDefault??!1),children:[(0,b.jsx)(o,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),t&&c&&(0,b.jsx)(OT,{count:c}),(0,b.jsx)(bv,{className:W(`size-4 shrink-0 text-muted-foreground transition-transform`,t&&`rotate-90 rtl:rotate-90 ltr:-rotate-90`),"aria-hidden":!0})]}),!t&&(0,b.jsx)(`ul`,{id:s,"aria-label":e.label,className:`ms-[18px] mt-0.5 mb-1 flex flex-col gap-px border-s border-sidebar-border ps-2.5`,children:e.entries.map(e=>(0,b.jsxs)(`li`,{className:`group/item flex items-center`,children:[e.external?(0,b.jsx)(`a`,{href:e.to,target:`_blank`,rel:`noopener noreferrer`,className:W(ST({isActive:!1}),`min-w-0 flex-1`),children:(0,b.jsx)(`span`,{className:`truncate`,children:e.label})}):(0,b.jsxs)(xo,{to:e.to,className:e=>W(ST(e),`min-w-0 flex-1 gap-2`),children:[(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.badge&&n?.[e.badge]&&(0,b.jsx)(OT,{count:n[e.badge]})]}),e.pin&&(0,b.jsx)(MT,{name:e.pin,label:e.label})]},e.key))})]})}function jT({section:e,muted:t}){let[n,r]=(0,y.useState)(!1),{pathname:i}=qi(),a=e.icon,o=e.entries.some(e=>wT(i,e));return(0,b.jsxs)(Sh,{open:n,onOpenChange:r,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,onMouseEnter:()=>r(!0),"data-nav-section":``,className:W(`flex size-10 cursor-pointer items-center justify-center rounded-control hover:bg-muted`,t&&`text-muted-foreground`,o&&`bg-primary-soft text-primary-text hover:bg-primary-soft`),children:(0,b.jsx)(a,{className:`size-4`,"aria-hidden":!0})})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{side:`right`,align:`start`,sideOffset:8,onMouseLeave:()=>r(!1),className:`z-50 flex flex-col items-start gap-1.5`,children:[(0,b.jsx)(`span`,{className:`rounded-control bg-foreground px-3 py-1.5 text-[13px] font-medium text-background`,children:e.label}),(0,b.jsx)(`div`,{className:`flex min-w-40 flex-col gap-px rounded-[10px] border border-border bg-card p-1.5 shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:e.entries.map(e=>e.external?(0,b.jsx)(`a`,{href:e.to,target:`_blank`,rel:`noopener noreferrer`,className:ST({isActive:!1}),onClick:()=>r(!1),children:e.label},e.key):(0,b.jsx)(xo,{to:e.to,className:ST,onClick:()=>r(!1),children:e.label},e.key))})]})})]})}function MT({name:e,label:t}){let{t:n}=Y(),r=hT().pinned.includes(e);return(0,b.jsx)(`button`,{type:`button`,className:W(`cursor-pointer rounded-md p-1 text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/item:opacity-100`,r&&`opacity-100`),"aria-label":n(r?`shell.unpin`:`shell.pin`,{name:t}),"aria-pressed":r,onClick:()=>mT.togglePin(e),children:r?(0,b.jsx)(cb,{className:`size-3.5`}):(0,b.jsx)(ub,{className:`size-3.5`})})}function NT(){let{t:e}=Y();if(Hg().data?.rbac.view)return{key:`~administration`,label:e(`rbac.administration`),icon:Mb,entries:[{key:`users`,to:`/-/users`,label:e(`rbac.users`)},{key:`groups`,to:`/-/groups`,label:e(`rbac.groups`)},{key:`roles`,to:`/-/roles`,label:e(`rbac.roles`)},{key:`debugger`,to:`/-/debugger`,label:e(`debugger.title`)}]}}var PT={success:5e3,error:1e4},FT=4;function IT(e=globalThis){let t=[],n=1,r=new Map,i=new Set,a=e=>{t=e;for(let e of i)e()},o=n=>{let i=r.get(n);i!==void 0&&e.clearTimeout(i),r.delete(n),t.some(e=>e.id===n)&&a(t.filter(e=>e.id!==n))};return{get:()=>t,subscribe(e){return i.add(e),()=>i.delete(e)},show(i,s=`success`){let c=n++,l=[...t,{id:c,message:i,tone:s}];for(let e of l.slice(0,Math.max(0,l.length-FT)))o(e.id);return a([...t,{id:c,message:i,tone:s}]),r.set(c,e.setTimeout(()=>o(c),PT[s])),c},dismiss:o}}var LT=IT(),RT=(e,t=`success`)=>LT.show(e,t);function zT(){return(0,y.useSyncExternalStore)(LT.subscribe,LT.get)}function BT(){let e=X(),t=zT();return(0,b.jsx)(`div`,{role:`region`,"aria-label":e(`toast.region`),className:`pointer-events-none fixed inset-x-4 bottom-4 z-[60] flex flex-col items-end gap-2 sm:start-auto sm:w-96`,children:t.map(t=>(0,b.jsxs)(`div`,{role:t.tone===`error`?`alert`:`status`,className:W(`pointer-events-auto flex w-full items-start gap-2 rounded-lg border bg-popover px-3 py-2 text-sm text-popover-foreground shadow-lg`,t.tone===`error`?`border-destructive/50`:`border-green-600/40`),children:[(0,b.jsx)(`span`,{className:W(`min-w-0 flex-1 break-words`,t.tone===`error`&&`text-destructive`),children:t.message}),(0,b.jsx)(`button`,{type:`button`,className:`rounded-md p-0.5 text-muted-foreground hover:text-foreground`,"aria-label":e(`toast.dismiss`),onClick:()=>LT.dismiss(t.id),children:(0,b.jsx)(bx,{className:`size-4`,"aria-hidden":!0})})]},t.id))})}function VT(e,t){return e===void 0||typeof e==`string`?e:e[t]??e[lg.locale]??Object.values(e)[0]}function HT(){let{t:e}=Y(),t=Hg(),n=qi(),r=S(),i=t.isError&&xg()!==void 0&&t.error instanceof ug&&(t.error.status===403||t.error.status===404);return(0,y.useEffect)(()=>{i&&(Sg(void 0),r.clear())},[i,r]),t.isPending||i?(0,b.jsx)(G,{children:e(`common.loading`)}):t.isError?t.error instanceof ug&&t.error.status===401?(0,b.jsx)(Da,{to:`/login?${new URLSearchParams({next:n.pathname+n.search})}`,replace:!0}):(0,b.jsxs)(G,{tone:`error`,children:[dg(t.error),` `,(0,b.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:e(`list.retry`)})]}):(0,b.jsx)(WT,{})}function UT(){let{t:e}=Y(),t=Hg(),n=S(),r=Yi(),i=t.data;return i?.viewAs?(0,b.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center justify-center gap-3 bg-amber-400 px-4 py-2 text-sm font-medium text-amber-950`,children:[(0,b.jsx)(Xv,{className:`size-4`,"aria-hidden":!0}),(0,b.jsx)(`span`,{children:e(`viewAs.banner`,{name:i.user.displayName})}),(0,b.jsx)(q,{size:`sm`,variant:`outline`,className:`h-7 border-amber-950/30 bg-amber-50 text-amber-950 hover:bg-amber-100`,onClick:()=>{let e=i.user.id;Sg(void 0),n.clear(),r(`/-/users/${encodeURIComponent(e)}`)},children:e(`viewAs.stop`)})]}):null}function WT(){let e=Ug(),{t,locale:n}=Y(),r=hT(),i=qi(),[a,o]=(0,y.useState)(!1),s=(0,y.useRef)(null),c=Hg().data?.appearance?.accent;(0,y.useEffect)(()=>{c!==void 0&&qw({admin:c})},[c]);let l=(0,y.useMemo)(()=>e.data?yw(e.data):[],[e.data]),u=e.data?.menu!==void 0,d=VT(lg.branding.name,n)??e.data?.title??lg.title,f=lg.branding.logo;return(0,y.useEffect)(()=>{o(!1);let e=decodeURIComponent(i.pathname.split(`/`).filter(Boolean)[0]??``);l.some(t=>t.resources.some(t=>t.name===e))&&mT.visit(e)},[i.pathname,l]),(0,y.useEffect)(()=>{e.data&&(document.title=e.data.title)},[e.data]),(0,y.useEffect)(()=>{if(!a)return;s.current?.querySelector(`a, button, input`)?.focus();let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),(0,b.jsxs)(`div`,{className:`flex min-h-svh bg-background text-foreground`,children:[(0,b.jsx)(lT,{}),(0,b.jsx)(`aside`,{className:W(`sticky top-0 hidden h-svh shrink-0 border-e border-sidebar-border bg-sidebar text-sidebar-foreground md:block`,r.railCollapsed?`w-16`:`w-64`),children:(0,b.jsx)(ET,{title:d,logo:f,groups:l,menu:u,rail:r.railCollapsed})}),a&&(0,b.jsxs)(`div`,{className:`fixed inset-0 z-40 md:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shell.menu`),ref:s,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,"aria-hidden":!0,onClick:()=>o(!1)}),(0,b.jsx)(`aside`,{className:`absolute inset-y-0 start-0 flex w-[300px] max-w-[85vw] flex-col border-e border-sidebar-border bg-sidebar text-sidebar-foreground shadow-xl`,onClick:e=>{e.target.closest(`a`)&&o(!1)},children:(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,b.jsx)(ET,{title:d,logo:f,groups:l,menu:u,onClose:()=>o(!1)})})})]}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,inert:a||void 0,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-30 bg-background`,children:[(0,b.jsx)(UT,{}),(0,b.jsx)(yT,{meta:e.data,onOpenMenu:()=>o(!0)})]}),(0,b.jsx)(`main`,{className:`flex-1 p-4 md:p-7`,children:(0,b.jsx)(`div`,{className:`mx-auto w-full max-w-[1400px]`,children:(0,b.jsx)(Oa,{})})})]}),(0,b.jsx)(BT,{})]})}function GT(e){let t=lg.branding.name;return t===void 0?lg.title:typeof t==`string`?t:t[e]??t[lg.locale]??Object.values(t)[0]??lg.title}function KT(){let{t:e,locale:t}=Y(),n=Yi(),r=S(),[i]=wo(),a=yg(i.get(`next`),lg.basePath),o=Hg(),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(`password`),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1);if(o.isSuccess)return(0,b.jsx)(Da,{to:a,replace:!0});async function x(t){if(t.preventDefault(),!s.trim()||!l){g(e(`auth.required`));return}if(d===`otp`&&!p.trim()){g(e(`auth.otpRequired`));return}v(!0),g(null);try{let e=await Q.login(s.trim(),l,d===`otp`?p.trim():void 0);mg(e.csrfToken),Sg(void 0),r.clear(),r.setQueryData([`session`],e),n(a,{replace:!0})}catch(t){if(t instanceof ug&&t.body.code===`TWO_FACTOR_REQUIRED`){g(d===`otp`?t.message:null),f(`otp`),m(``);return}f(`password`),m(``),u(``),g(t instanceof ug&&(t.status===401||t.status===429||t.status===404)?t.message:e(`auth.failed`))}finally{v(!1)}}let C=lg.branding.logo;return(0,b.jsxs)(`main`,{className:`flex min-h-dvh flex-col bg-muted/30`,children:[(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 p-4`,children:[(0,b.jsx)(nT,{}),(0,b.jsx)(tT,{})]}),(0,b.jsx)(`div`,{className:`flex flex-1 items-start justify-center px-4 pt-[10vh]`,children:(0,b.jsxs)(`form`,{onSubmit:x,noValidate:!0,className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border bg-background p-6 shadow-sm`,"aria-labelledby":`login-title`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[C&&(0,b.jsx)(`img`,{src:C,alt:``,className:`size-10 rounded-md object-contain`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:GT(t)}),(0,b.jsx)(`h1`,{id:`login-title`,className:`text-[22px] font-bold`,children:e(d===`otp`?`auth.otpTitle`:`auth.title`)})]}),h&&(0,b.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}),d===`otp`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-otp`,children:e(`auth.otp`)}),(0,b.jsx)(Oh,{id:`login-otp`,autoComplete:`one-time-code`,inputMode:`text`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,dir:`ltr`,maxLength:40,value:p,onChange:e=>m(e.target.value),"aria-describedby":`login-otp-help`}),(0,b.jsx)(`p`,{id:`login-otp-help`,className:`text-sm text-muted-foreground`,children:e(`auth.otpHelp`)})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-username`,children:e(`auth.username`)}),(0,b.jsx)(Oh,{id:`login-username`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-password`,children:e(`auth.password`)}),(0,b.jsx)(Oh,{id:`login-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>u(e.target.value)})]})]}),(0,b.jsx)(q,{type:`submit`,disabled:_,children:e(_?`auth.signingIn`:d===`otp`?`auth.verify`:`auth.signIn`)}),d===`otp`&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,onClick:()=>{f(`password`),m(``),u(``),g(null)},children:e(`auth.startOver`)})]})})]})}var qT=3;function JT({field:e,files:t,detailed:n=!1,plain:r=!1}){let i=X();if(t.length===0)return(0,b.jsx)(b.Fragment,{children:`—`});let a=t=>e.widget===`image`&&t.contentType.startsWith(`image/`),o=n?t:t.slice(0,qT);return(0,b.jsxs)(`span`,{className:W(`inline-flex flex-wrap items-center`,n?`gap-2`:`gap-1 align-middle`),children:[o.map(e=>{let t=a(e)?(0,b.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,className:W(`rounded-md border bg-muted object-cover`,n?`size-24`:`size-8`)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ny,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`bdi`,{className:`max-w-48 truncate`,children:e.name}),n&&(0,b.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:Mg(e.size)})]});return r?(0,b.jsx)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:t},e.key):(0,b.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":i(`upload.open`,{name:e.name}),title:e.name,className:`inline-flex min-w-0 items-center gap-1 hover:underline`,onClick:e=>e.stopPropagation(),children:t},e.key)}),t.length>o.length&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`upload.more`,{count:t.length-o.length})})]})}var YT={ok:`bg-ok-bg text-ok`,warn:`bg-warn-bg text-warn`,bad:`bg-bad-bg text-bad`,info:`bg-info-bg text-info`,neutral:`bg-muted text-muted-foreground`,primary:`bg-primary-soft text-primary-text`};function XT({tone:e=`neutral`,className:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`badge`,"data-tone":e,className:W(`inline-flex h-[22px] items-center gap-1 rounded-full px-2 text-xs leading-none font-medium whitespace-nowrap`,YT[e],t),...n})}var ZT={gray:`neutral`,red:`bad`,amber:`warn`,green:`ok`,blue:`info`,purple:`primary`,pink:`bad`};function QT(e){return ZT[e]??`neutral`}function $T({value:e,field:t,className:n}){if(e==null)return(0,b.jsx)(b.Fragment,{children:jx(e,t)});let r=t.colors?.[String(e)]??`gray`;return(0,b.jsx)(XT,{"data-color":r,tone:QT(r),className:n,children:jx(e,t)})}function eE({value:e,field:t,record:n,detailed:r,plain:i}){return t.file&&n?(0,b.jsx)(JT,{field:t,files:pC(n,t.name),detailed:r,plain:i}):t.widget===`badge`?(0,b.jsx)($T,{value:e,field:t}):(0,b.jsx)(b.Fragment,{children:jx(e,t)})}function tE({title:e,subtitle:t,icon:n,actions:r,footer:i,className:a,bodyClassName:o,children:s,...c}){let l=(0,y.useId)(),u=e!==void 0&&c[`aria-labelledby`]===void 0?{"aria-labelledby":l}:{};return(0,b.jsxs)(`section`,{"data-slot":`card`,className:W(`rounded-card border border-border bg-card text-card-foreground shadow-card`,a),...u,...c,children:[e!==void 0&&(0,b.jsxs)(`header`,{className:`flex min-h-14 items-center gap-2 border-b border-border px-5 py-3`,children:[n&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&_svg]:size-4`,children:n}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`h2`,{id:l,className:`text-[15px] font-semibold`,children:e}),t&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]}),r&&(0,b.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]}),(0,b.jsx)(`div`,{className:W(e!==void 0&&`p-5`,o),children:s}),i&&(0,b.jsx)(`footer`,{className:`border-t border-border px-5 py-3`,children:i})]})}function nE({card:e,values:t,schema:n}){let r=X(),i=Wg(e.relation?.resource??``,e.relation!==void 0);if(!t)return null;let a=e.relation?i.data?.fields:n.fields;if(!a)return null;let o=Xw(e.icon),s=e.fields.flatMap(e=>{let t=a.find(t=>t.name===e);return t?[t]:[]}),c=e.relation?.link&&typeof t._id==`string`?`/${e.relation.resource}/${encodeURIComponent(t._id)}`:void 0;return(0,b.jsx)(tE,{title:e.title,icon:o?(0,b.jsx)(o,{}):void 0,actions:c&&(0,b.jsx)(bo,{to:c,className:`text-[13px] font-medium text-primary hover:underline`,children:r(`form.viewProfile`)}),children:(0,b.jsxs)(`dl`,{className:`flex flex-col gap-2.5 text-[13px]`,children:[e.relation&&typeof t._title==`string`&&(0,b.jsx)(`dt`,{className:`text-[14px] font-semibold`,children:t._title}),s.map(e=>(0,b.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`min-w-0 text-end break-words`,children:(0,b.jsx)(eE,{value:t[e.name],field:e,record:t})})]},e.name))]})})}function rE(e,t,n){let r=e.steps?.values??e.enumValues??[],i=typeof t==`string`?r.indexOf(t):-1;return r.map((t,r)=>{let a=n?.[t],o=a?tg(new Date(a)):null,s=i===-1?`future`:r<i?`done`:r===i?`current`:`future`;return{key:t,label:e.enumLabels?.[t]??t,state:s,at:s===`future`?null:o,caption:s===`current`&&o?J(`stepper.since`,{time:o}):null}})}function iE({field:e,value:t,reached:n}){let r=rE(e,t,n);return(0,b.jsx)(tE,{"aria-label":e.label,bodyClassName:`overflow-x-auto px-5 py-4`,children:(0,b.jsx)(`ol`,{className:`flex min-w-max`,children:r.map((e,t)=>(0,b.jsxs)(`li`,{"aria-current":e.state===`current`?`step`:void 0,className:`relative flex min-w-28 flex-1 flex-col items-center gap-1.5 text-center`,children:[t<r.length-1&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:W(`absolute start-1/2 top-3.5 h-0.5 w-full`,e.state===`done`?`bg-primary`:`bg-border`)}),(0,b.jsx)(`span`,{className:W(`relative z-10 flex size-7 items-center justify-center rounded-full border-2 bg-card text-xs font-semibold`,e.state===`done`&&`border-primary bg-primary text-primary-foreground`,e.state===`current`&&`border-primary text-primary`,e.state===`future`&&`border-border text-muted-foreground`),children:e.state===`done`?(0,b.jsx)(vv,{className:`size-3.5`,"aria-hidden":!0}):Qh(t+1)}),(0,b.jsx)(`span`,{className:W(`text-[13px]`,e.state===`current`?`font-semibold text-primary`:e.state===`done`?`font-semibold`:`text-muted-foreground`),children:e.label}),(0,b.jsx)(`span`,{className:`text-[11.5px] text-muted-foreground`,children:e.caption??e.at??`—`})]},e.key))})})}var aE=class{options;pending=[];problems=[];uploads=new Map;nextId=0;disposed=!1;constructor(e){this.options=e}get busy(){return this.pending.length>0}start(e,t){if(!(this.disposed||e.length===0)){this.problems=[];for(let n of e){let e=this.options.check(n);if(e){this.problems=[...this.problems,this.options.describe(n.name,e)];continue}let r=++this.nextId,i=this.options.preview?.(n),a=this.options.send(n,e=>{this.disposed||(this.pending=this.pending.map(t=>t.id===r?{...t,progress:e}:t),this.options.onChange())});this.uploads.set(r,a),this.pending=[...this.pending,{id:r,name:n.name,progress:0,preview:i}],a.promise.then(e=>{this.disposed||(this.finish(r),t(e,n,i))},e=>{this.disposed||(i&&this.options.revoke?.(i),e instanceof Cg||(this.problems=[...this.problems,this.options.describe(n.name,Og(e))]),this.finish(r))})}this.options.onChange()}}report(e,t){this.problems=[...this.problems,this.options.describe(e,t)],this.options.onChange()}cancel(e){this.uploads.get(e)?.abort()}cancelAll(){for(let e of[...this.uploads.values()])e.abort()}dispose(){this.disposed=!0;for(let e of this.pending)e.preview&&this.options.revoke?.(e.preview);this.cancelAll(),this.uploads.clear(),this.pending=[]}finish(e){this.uploads.delete(e),this.pending=this.pending.filter(t=>t.id!==e),this.options.onChange()}};function oE({resource:e,field:t,rules:n,onBusy:r}){let i=X(),[,a]=(0,y.useReducer)(e=>e+1,0),o=(0,y.useRef)({resource:e,field:t,rules:n,t:i});o.current={resource:e,field:t,rules:n,t:i};let s=(0,y.useRef)(null),c=()=>new aE({send:(e,t)=>Q.upload(e,{resource:o.current.resource,field:o.current.field.name},t),check:e=>Ag(e,o.current.rules),describe:(e,t)=>o.current.t(`upload.failed`,{name:e,message:t}),preview:e=>e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,revoke:e=>URL.revokeObjectURL(e),onChange:a});s.current??=c();let l=s.current.busy;return(0,y.useEffect)(()=>{r?.(l)},[l]),(0,y.useEffect)(()=>(s.current||(s.current=c(),a()),()=>{s.current?.dispose(),s.current=null,r?.(!1)}),[]),s.current}function sE({resource:e,field:t,value:n,onChange:r,onBusy:i}){let a=t.file?.many===!0,o=fC(n),s=(0,y.useRef)(o);s.current=o;let c=oE({resource:e,field:t,rules:t.file??{accept:[],maxBytes:1/0},onBusy:i}),l=(0,y.useRef)(new Map);(0,y.useEffect)(()=>()=>{for(let e of l.current.values())URL.revokeObjectURL(e);l.current.clear()},[]);function u(e){let t=new Set(e.map(e=>e.token));for(let[e,n]of l.current)t.has(e)||(URL.revokeObjectURL(n),l.current.delete(e));s.current=e,r(a?e:e[0]??null)}function d(e){let t=a?e:e.slice(0,1);t.length!==0&&(a||c.cancelAll(),c.start(t,(e,t,n)=>{n&&l.current.set(e.token,n);let r={token:e.token,name:e.name,size:e.size,contentType:e.contentType,...e.url?{url:e.url}:{}};u(a?[...s.current,r]:[r])}))}return{many:a,files:o,pending:c.pending,problems:c.problems,add:d,remove:e=>u(o.filter((t,n)=>n!==e)),move:(e,t)=>u(Ng(o,e,t)),cancel:e=>c.cancel(e),previewOf:e=>e.url??(e.token?l.current.get(e.token):void 0)}}function cE(e){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(null),a=()=>{n(null),i(null)};return{dragging:t,over:r,item:r=>({draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(r)),n(r)},onDragOver:e=>{t!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,i(r))},onDrop:n=>{t!==null&&(n.preventDefault(),e(t,r),a())},onDragEnd:a})}}function lE({id:e,field:t,label:n,compact:r,onFiles:i,aria:a}){let o=X(),s=(0,y.useRef)(null),[c,l]=(0,y.useState)(!1),u=t.file?.many===!0,d=t.file?.accept??[],f=d.length===0||d.some(e=>e===`*`||e===`*/*`),p=e=>e.dataTransfer.types.includes(`Files`);return(0,b.jsxs)(`div`,{"data-dropzone":t.name,onDragOver:e=>{p(e)&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:e=>{p(e)&&(e.preventDefault(),l(!1),i([...e.dataTransfer.files]))},className:W(`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg text-sm has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/50`,!r&&`border border-dashed border-input px-3 py-3`,c&&`border-primary bg-muted/50`),children:[(0,b.jsx)(`input`,{ref:s,id:e,type:`file`,className:`sr-only`,multiple:u,accept:f?void 0:d.join(`,`),onChange:e=>{i([...e.target.files??[]]),e.target.value=``},...a}),(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,tabIndex:-1,"aria-hidden":!0,onClick:()=>s.current?.click(),children:[(0,b.jsx)(ox,{}),n]}),!r&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[o(u?`upload.dropMany`:`upload.drop`),t.file&&` · ${o(`upload.limit`,{max:Mg(t.file.maxBytes)})}`]})]})}function uE({upload:e,onCancel:t,className:n}){let r=X(),i=Math.round(e.progress*100);return(0,b.jsxs)(`div`,{className:W(`flex items-center gap-2`,n),children:[(0,b.jsx)(`div`,{role:`progressbar`,"aria-label":r(`upload.uploading`,{name:e.name}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${i}%`}})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":r(`upload.cancel`,{name:e.name}),onClick:t,children:(0,b.jsx)(bx,{})})]})}function dE({problems:e}){return e.length===0?null:(0,b.jsx)(`ul`,{role:`alert`,className:`flex flex-col gap-0.5 text-sm text-destructive`,children:e.map((e,t)=>(0,b.jsx)(`li`,{children:e},t))})}function fE(e){let t=X(),{id:n,field:r,aria:i}=e,{many:a,files:o,pending:s,problems:c,add:l,remove:u,move:d,cancel:f}=sE(e),p=cE(d);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(o.length>0||s.length>0)&&(0,b.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[o.map((e,n)=>(0,b.jsxs)(`li`,{"data-file":e.name,...a&&o.length>1?p.item(n):{},className:W(`flex items-center gap-2 rounded-lg border px-2 py-1.5 text-sm`,p.dragging===n&&`opacity-50`,p.over===n&&p.dragging!==n&&`border-primary`),children:[a&&o.length>1?(0,b.jsx)(cy,{className:`size-4 shrink-0 cursor-grab text-muted-foreground`,"aria-hidden":!0}):(0,b.jsx)(ny,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),e.url?(0,b.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 truncate hover:underline`,"aria-label":t(`upload.open`,{name:e.name}),children:(0,b.jsx)(`bdi`,{children:e.name})}):(0,b.jsx)(`bdi`,{className:`min-w-0 truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:Mg(e.size)}),a&&o.length>1&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,disabled:n===0,"aria-label":t(`list.moveUp`,{name:e.name}),onClick:()=>d(n,n-1),children:(0,b.jsx)(J_,{})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,disabled:n===o.length-1,"aria-label":t(`list.moveDown`,{name:e.name}),onClick:()=>d(n,n+1),children:(0,b.jsx)(W_,{})})]}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":t(`upload.remove`,{name:e.name}),onClick:()=>u(n),children:(0,b.jsx)(bx,{})})]},e.token??e.key)),s.map(e=>(0,b.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-dashed px-2 py-1.5 text-sm`,children:[(0,b.jsx)(`bdi`,{className:`truncate text-muted-foreground`,children:e.name}),(0,b.jsx)(uE,{upload:e,onCancel:()=>f(e.id)})]},`pending-${e.id}`))]}),(0,b.jsx)(lE,{id:n,field:r,label:t(a?`upload.chooseMany`:o.length>0?`upload.replace`:`upload.choose`),compact:!a&&o.length>0,onFiles:l,aria:i}),(0,b.jsx)(dE,{problems:c})]})}function pE(e){let t=X(),{id:n,field:r,aria:i}=e,{many:a,files:o,pending:s,problems:c,add:l,remove:u,move:d,cancel:f,previewOf:p}=sE(e),m=cE(d),h=a&&o.length>1;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(o.length>0||s.length>0)&&(0,b.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,children:[o.map((e,n)=>{let r=p(e);return(0,b.jsxs)(`li`,{"data-file":e.name,...h?m.item(n):{},className:W(`group relative size-28 overflow-hidden rounded-lg border bg-muted`,h&&`cursor-grab`,m.dragging===n&&`opacity-50`,m.over===n&&m.dragging!==n&&`border-primary ring-2 ring-primary/40`),children:[r?(0,b.jsx)(`img`,{src:r,alt:e.name,draggable:!1,className:`size-full object-cover`}):(0,b.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1 p-1 text-center text-xs text-muted-foreground`,children:[(0,b.jsx)(my,{className:`size-5`,"aria-hidden":!0}),(0,b.jsx)(`bdi`,{className:`w-full truncate`,children:e.name})]}),(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`absolute end-1 top-1 shadow`,"aria-label":t(`upload.remove`,{name:e.name}),onClick:()=>u(n),children:(0,b.jsx)(bx,{})}),h&&(0,b.jsxs)(`div`,{className:`absolute inset-x-1 bottom-1 flex justify-between`,children:[(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`shadow`,disabled:n===0,"aria-label":t(`list.moveUp`,{name:e.name}),onClick:()=>d(n,n-1),children:(0,b.jsx)(Sv,{className:`rtl:rotate-180`})}),(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`shadow`,disabled:n===o.length-1,"aria-label":t(`list.moveDown`,{name:e.name}),onClick:()=>d(n,n+1),children:(0,b.jsx)(wv,{className:`rtl:rotate-180`})})]})]},e.token??e.key)}),s.map(e=>(0,b.jsxs)(`li`,{className:`relative size-28 overflow-hidden rounded-lg border border-dashed bg-muted`,children:[e.preview&&(0,b.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover opacity-40`}),(0,b.jsx)(uE,{upload:e,onCancel:()=>f(e.id),className:`absolute inset-x-1 bottom-1 rounded-md bg-background/80 ps-1.5`})]},`pending-${e.id}`))]}),(0,b.jsx)(lE,{id:n,field:r,label:t(a?`upload.chooseImages`:o.length>0?`upload.replace`:`upload.chooseImage`),compact:!a&&o.length>0,onFiles:l,aria:i}),(0,b.jsx)(dE,{problems:c})]})}function mE({className:e,...t}){return(0,b.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function hE({id:e,field:t,value:n,onChange:r,aria:i}){let{unit:a,position:o}=kx(`0`,{currency:t.currency}),s=a&&(0,b.jsx)(`span`,{className:`shrink-0 text-[13px] text-muted-foreground`,children:a});return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o===`before`&&s,(0,b.jsx)(Oh,{id:e,type:`text`,inputMode:`decimal`,dir:`ltr`,className:`text-end`,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),onBlur:()=>r(Tx(n,t.scale)),...i}),o!==`before`&&s]})}function gE({id:e,checked:t,onChange:n,aria:r}){return(0,b.jsx)(`button`,{id:e,type:`button`,role:`switch`,"aria-checked":t,onClick:()=>n(!t),className:W(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,t?`bg-primary`:`bg-input`),...r,children:(0,b.jsx)(`span`,{className:W(`block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-4 rtl:-translate-x-4`:`translate-x-0`)})})}function _E({id:e,field:t,value:n,onChange:r,aria:i,label:a,required:o}){let s=X(),c=(t.enumValues??[]).map(e=>[e,kC(t,e)]);return t.nullable&&!o&&c.unshift([``,s(`common.empty`)]),(0,b.jsxs)(`fieldset`,{id:e,className:`flex flex-col gap-1.5`,...i,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:a}),(0,b.jsx)(`div`,{role:`radiogroup`,className:`flex flex-wrap gap-x-4 gap-y-1.5`,children:c.map(([t,i])=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`radio`,name:e,value:t,checked:n===t,onChange:()=>r(t),className:`size-4 accent-primary`}),i]},t))})]})}var vE=/^#[0-9a-f]{6}$/i;function yE({id:e,field:t,value:n,onChange:r,aria:i}){let a=X();return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`color`,"aria-hidden":!0,tabIndex:-1,className:`h-8 w-10 shrink-0 cursor-pointer rounded-md border border-input bg-transparent p-0.5`,value:vE.test(n)?n.toLowerCase():`#000000`,onChange:e=>r(e.target.value)}),(0,b.jsx)(Oh,{id:e,dir:`ltr`,value:n,placeholder:t.placeholder??`#000000`,"aria-label":a(`form.colorCode`,{name:t.label}),onChange:e=>r(e.target.value),...i})]})}function bE({id:e,field:t,value:n,onChange:r,aria:i}){let a=X(),[o,s]=(0,y.useState)(null),c=`${e}-json`;function l(){if(n.trim()!==``)try{r(JSON.stringify(JSON.parse(n),null,2)),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}}let u=[i[`aria-describedby`],o?c:void 0].filter(Boolean).join(` `)||void 0;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(mE,{id:e,dir:`ltr`,rows:6,className:`font-mono`,spellCheck:!1,value:n,placeholder:t.placeholder,onChange:e=>{s(null),r(e.target.value)},...i,"aria-invalid":i[`aria-invalid`]??(o?!0:void 0),"aria-describedby":u}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:l,children:a(`form.formatJson`)}),o&&(0,b.jsx)(`p`,{id:c,className:`text-sm text-destructive`,children:o})]})]})}function xE({id:e,field:t,value:n,onChange:r,aria:i}){return(0,b.jsx)(mE,{id:e,rows:4,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),...i})}function SE({id:e,field:t,value:n,onChange:r,aria:i,...a}){return(0,b.jsx)(Oh,{id:e,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),...a,...i})}var CE=(0,y.lazy)(()=>Xa(()=>import(`./rich-text-input-LLJwDwdI.js`),__vite__mapDeps([0,1]),import.meta.url));function wE(e){let t=X();return(0,b.jsx)(y.Suspense,{fallback:(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`editor.loading`)}),children:(0,b.jsx)(CE,{...e})})}var TE=`h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive`;function EE({resource:e,field:t,value:n,required:r,errors:i,constraints:a,formValues:o,onChange:s,onBusy:c,idPrefix:l=`field`,parent:u,hideLabel:d}){let f=`${l}-${t.name}`,p=`${f}-error`,m=`${f}-help`,h=(i?.length??0)>0,g=[t.help?m:void 0,h?p:void 0].filter(Boolean).join(` `)||void 0,_={"aria-invalid":h?!0:void 0,"aria-describedby":g},v=typeof n==`string`?n:``,y=t.type===`relation`?void 0:OC(t,a),x=(0,b.jsxs)(b.Fragment,{children:[t.label,r&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-destructive`,children:`*`})]}),S=(0,b.jsx)(kh,{htmlFor:f,className:d?`sr-only`:void 0,children:x}),C=t.help?(0,b.jsx)(`p`,{id:m,className:`text-sm text-muted-foreground`,children:t.help}):null,w={id:f,field:t,value:v,onChange:e=>s(e),aria:_};if(t.type===`boolean`){let e=n===!0;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y===`switch`?(0,b.jsx)(gE,{id:f,checked:e,onChange:s,aria:_}):(0,b.jsx)(`input`,{id:f,type:`checkbox`,className:`size-4 accent-primary`,checked:e,onChange:e=>s(e.target.checked),..._}),S]}),C,(0,b.jsx)(OE,{id:p,errors:i})]})}if(t.type===`enum`&&y===`radio`)return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(_E,{...w,label:x,required:r}),C,(0,b.jsx)(OE,{id:p,errors:i})]});let T;if(t.type===`relation`)T=(0,b.jsx)(HS,{id:f,resource:e,field:t,value:n??null,onChange:s,clearable:t.nullable,values:o,parent:u,invalid:h,describedBy:g});else if(t.type===`enum`)T=(0,b.jsxs)(`select`,{id:f,className:TE,value:v,onChange:e=>s(e.target.value),..._,children:[(0,b.jsx)(`option`,{value:``,children:t.placeholder??`—`}),t.enumValues?.map(e=>(0,b.jsx)(`option`,{value:e,children:kC(t,e)},e))]});else switch(y){case`file`:T=(0,b.jsx)(fE,{id:f,resource:e,field:t,value:n,onChange:s,onBusy:c,aria:_});break;case`image`:T=(0,b.jsx)(pE,{id:f,resource:e,field:t,value:n,onChange:s,onBusy:c,aria:_});break;case`richtext`:T=(0,b.jsx)(wE,{id:f,resource:e,field:t,value:v,onChange:s,onBusy:c,invalid:h,describedBy:g});break;case`money`:T=(0,b.jsx)(hE,{...w});break;case`date`:T=(0,b.jsx)(IS,{id:f,live:!0,value:v,label:t.label,onChange:e=>s(e),..._});break;case`datetime`:T=(0,b.jsx)(zS,{id:f,value:v,label:t.label,onChange:e=>s(e),..._});break;case`json`:T=(0,b.jsx)(bE,{...w});break;case`textarea`:T=(0,b.jsx)(xE,{...w});break;case`color`:T=(0,b.jsx)(yE,{...w});break;case`password`:T=(0,b.jsx)(SE,{...w,type:`password`,autoComplete:`new-password`});break;case`slug`:T=(0,b.jsx)(SE,{...w,dir:`ltr`,autoCapitalize:`none`,spellCheck:!1});break;default:T=(0,b.jsx)(SE,{...w,...DE(t,y)})}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,T,C,(0,b.jsx)(OE,{id:p,errors:i})]})}function DE(e,t){if(t===`email`||t===`url`)return{type:t};switch(e.type){case`number`:case`decimal`:return{type:`text`,inputMode:`decimal`};case`bigint`:return{type:`text`,inputMode:`numeric`};case`date`:return{type:`date`};case`datetime`:return{type:`datetime-local`};default:return{type:`text`}}}function OE({id:e,errors:t}){return t?.length?(0,b.jsx)(`p`,{id:e,className:`text-sm text-destructive`,children:t.join(` `)}):null}var kE={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 lg:grid-cols-3`};function AE({layout:e,names:t,render:n,errors:r,renderInline:i,renderSummary:a,plain:o}){let s=e&&(i?e:PE(e)),c=new Set((s??[]).flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>ME(e)||NE(e)?[]:e.fields)),l=t.filter(e=>!c.has(e)),u=(s??[]).filter(e=>`tab`in e),d=(s??[]).findIndex(e=>`tab`in e),f=d===-1?(s??[]).filter(e=>!(`tab`in e)):(s??[]).slice(0,d).filter(e=>!(`tab`in e)),p=d===-1?[]:(s??[]).slice(d).filter(e=>!(`tab`in e)),m=(e,t)=>ME(e)?(0,b.jsx)(y.Fragment,{children:i?.(e)},t):NE(e)?(0,b.jsx)(y.Fragment,{children:a?.(e)},t):(0,b.jsx)(jE,{section:e,render:n,plain:o},t);return(0,b.jsxs)(b.Fragment,{children:[f.map((e,t)=>m(e,`b${t}`)),u.length>0&&(0,b.jsx)(FE,{tabs:u,render:n,errors:r,block:m}),p.map((e,t)=>m(e,`a${t}`)),l.length>0&&(0,b.jsx)(jE,{section:{fields:l,columns:1},render:n,plain:o})]})}function jE({section:e,render:t,plain:n}){let r=(0,y.useId)(),i=e.fields.map(e=>[e,t(e)]).filter(([,e])=>e!==null);if(i.length===0)return null;let a=(0,b.jsx)(`div`,{className:W(`grid gap-5`,kE[e.columns]),children:i.map(([e,t])=>(0,b.jsx)(`div`,{className:`min-w-0`,children:t},e))});return n?e.title?(0,b.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-3`,children:[(0,b.jsx)(`h3`,{id:r,className:`text-[13px] font-semibold text-muted-foreground`,children:e.title}),a]}):a:e.title?(0,b.jsx)(tE,{"aria-labelledby":r,title:(0,b.jsx)(`span`,{id:r,children:e.title}),children:a}):(0,b.jsx)(tE,{bodyClassName:`p-5`,children:a})}var ME=e=>`inline`in e,NE=e=>`summary`in e;function PE(e){return e.filter(e=>!ME(e)&&!NE(e)).map(e=>`tab`in e?{...e,sections:e.sections.filter(e=>!ME(e)&&!NE(e))}:e)}function FE({tabs:e,render:t,errors:n,block:r}){let i=X(),{locale:a}=Y(),o=(0,y.useId)(),[s,c]=(0,y.useState)(0),l=(0,y.useRef)([]),u=e=>e.sections.some(e=>(ME(e)?[`_inlines.${e.inline}`]:NE(e)?[]:e.fields).some(e=>Object.keys(n).some(t=>t===e||t.startsWith(`${e}.`))));(0,y.useEffect)(()=>{if(u(e[s]))return;let t=e.findIndex(u);t!==-1&&c(t)},[n]);function d(t){let n=Xh(a)?`ArrowLeft`:`ArrowRight`,r=Xh(a)?`ArrowRight`:`ArrowLeft`,i;t.key===n?i=(s+1)%e.length:t.key===r?i=(s-1+e.length)%e.length:t.key===`Home`?i=0:t.key===`End`&&(i=e.length-1),i!==void 0&&(t.preventDefault(),c(i),l.current[i]?.focus())}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`div`,{role:`tablist`,className:`flex gap-0.5 overflow-x-auto border-b`,onKeyDown:d,children:e.map((e,t)=>(0,b.jsxs)(`button`,{ref:e=>{l.current[t]=e},id:`${o}-tab-${t}`,type:`button`,role:`tab`,"aria-selected":t===s,"aria-controls":`${o}-panel-${t}`,tabIndex:t===s?0:-1,onClick:()=>c(t),className:W(`-mb-px flex h-[38px] items-center gap-1.5 border-b-2 px-3 text-[13px] whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,t===s?`border-foreground font-semibold`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.tab,u(e)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-destructive`}),(0,b.jsx)(`span`,{className:`sr-only`,children:i(`form.tabHasErrors`)})]})]},t))}),e.map((e,t)=>(0,b.jsx)(`div`,{id:`${o}-panel-${t}`,role:`tabpanel`,"aria-labelledby":`${o}-tab-${t}`,hidden:t!==s,className:W(`flex-col gap-5`,t===s?`flex`:`hidden`),children:e.sections.map((e,t)=>r(e,String(t)))},t))]})}var IE=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{};function LE({resource:e,field:t,path:n,pattern:r,value:i,constraints:a,markRequired:o,errors:s,onChange:c,idPrefix:l}){let u=X(),d=s[n];if(t.many){let f=Array.isArray(i)?i:[];return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:t.label}),f.map((i,d)=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-dashed p-3`,children:[(0,b.jsx)(RE,{resource:e,field:t,path:`${n}.${d}`,pattern:`${r}.*`,value:i,constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:e=>c(f.map((t,n)=>n===d?e:t))}),(0,b.jsx)(`div`,{children:(0,b.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>c(f.filter((e,t)=>t!==d)),children:[(0,b.jsx)(ex,{}),u(`form.remove`,{name:t.label,index:d+1})]})})]},d)),(0,b.jsx)(`div`,{children:(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>c([...f,xC(t.fields??[])]),children:[(0,b.jsx)(fb,{}),u(`form.add`,{name:t.label})]})}),d&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:d.join(` `)})]})}return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:t.label}),(0,b.jsx)(RE,{resource:e,field:t,path:n,pattern:r,value:IE(i),constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:c}),d&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:d.join(` `)})]})}function RE({resource:e,field:t,path:n,pattern:r,value:i,constraints:a,markRequired:o,errors:s,onChange:c,idPrefix:l}){return(0,b.jsx)(b.Fragment,{children:(t.fields??[]).filter(e=>!e.readonly).map(t=>{let u=`${n}.${t.name}`,d=`${r}.${t.name}`,f=e=>c({...i,[t.name]:e});return t.type===`object`?(0,b.jsx)(LE,{resource:e,field:t,path:u,pattern:d,value:i[t.name],constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:f},t.name):(0,b.jsx)(EE,{resource:e,field:{...t,name:u},value:i[t.name],required:o&&a[d]?.required===!0,errors:s[u],constraints:a[d],idPrefix:l,onChange:f},t.name)})})}function zE(e,t){let n=t?._perm?.actions;return e.actions.filter(e=>e.target===`record`&&(n===void 0||typeof n[e.name]==`string`)).map(e=>n?.[e.name]?{...e,label:n[e.name]}:e)}function BE(e,t){let n=zE(e,t),r=n.find(e=>e.primary),i=n.filter(e=>e!==r);return{...r?{primary:r}:{},buttons:i.slice(0,3),overflow:i.slice(3)}}function VE(e,t){let n=e.actions.filter(e=>e.target===`record`&&e.bulk);return t.length===0?n:n.filter(n=>t.some(t=>zE(e,t).some(e=>e.name===n.name)))}function HE(e){return e.actions.filter(e=>e.target===`resource`)}function UE(e,t=0){return e.confirm!==void 0||e.variant===`destructive`||t>1}function WE(e,t=0){return!e.input&&!UE(e,t)}function GE(e,t,n,r){if(UE(e,t))return typeof e.confirm==`string`?e.confirm:t>1?r(`action.confirmSelected`,{action:e.label,count:t}):n===void 0?r(`action.confirm`,{action:e.label}):r(`action.confirmRecord`,{action:e.label,name:n})}function KE(e){let t=e.message===void 0?{}:{message:e.message};return`record`in e?{kind:`record`,record:e.record,...t}:`ok`in e&&`failed`in e?{kind:`bulk`,result:{ok:e.ok,failed:e.failed},...t}:{kind:`resource`,...t}}function qE(e,t){return e.kind===`bulk`?e.result:{ok:t,failed:[]}}function JE(e,t){if(!(e instanceof ug))return{fields:{},form:e.message};let n=Object.entries(e.fields),r=e=>t.includes(e.split(`.`)[0]),i=Object.fromEntries(n.filter(([e])=>r(e))),a=n.filter(([e])=>!r(e)).map(([e,t])=>`${e}: ${t.join(`, `)}`);return{fields:i,form:Object.keys(i).length>0&&a.length===0?null:[e.message,...a].join(` — `)}}function YE(e,t){let n=uC(e)?String(e.id):e;return t===null?n==null||n===``:typeof t==`boolean`?n===t||n===String(t):typeof n!=`string`||n.trim()===``?!1:typeof t==`number`?Number(Nh(n).trim().replace(/,/g,``))===t:n===t}function XE(e,t){return!e.showIf||Object.entries(e.showIf).every(([e,n])=>(Array.isArray(n)?n:[n]).some(n=>YE(t[e],n)))}var ZE=/^.+@[^\s@]+\.[^\s@]+$/,QE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $E(e){if(/\s/.test(e))return!1;try{let{hostname:t}=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:`http://${e}`);return t.includes(`.`)||t.startsWith(`[`)}catch{return!1}}function eD(e,t){try{return new RegExp(t.source,t.flags).test(e)}catch{return!0}}function tD(e){let t=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)??[],n=e.match(/[^\uFE0F\uFE0E][\uFE0F\uFE0E]/g)??[];return e.length-t.length-n.length}function nD(e,t){let n=[];if(typeof e==`string`){let r=tD(e);t.minLength!==void 0&&r<t.minLength&&n.push(J(`validation.minLength`,{min:t.minLength})),t.maxLength!==void 0&&r>t.maxLength&&n.push(J(`validation.maxLength`,{max:t.maxLength})),t.pattern&&!eD(e,t.pattern)&&n.push(t.pattern.message??J(`validation.pattern`)),t.format===`email`&&!ZE.test(e)&&n.push(J(`validation.email`)),t.format===`url`&&!$E(e)&&n.push(J(`validation.url`)),t.format===`uuid`&&!QE.test(e)&&n.push(J(`validation.uuid`)),t.oneOf&&!t.oneOf.includes(e)&&n.push(J(`validation.oneOf`,{values:t.oneOf.join(`, `)}))}return typeof e==`number`&&(t.integer&&!Number.isInteger(e)&&n.push(J(`validation.integer`)),t.min!==void 0&&e<t.min&&n.push(J(`validation.min`,{min:t.min})),t.max!==void 0&&e>t.max&&n.push(J(`validation.max`,{max:t.max}))),n}function rD(e,t,n){let r={};for(let[i,a]of Object.entries(t))for(let{path:t,value:o,sent:s,parentSent:c}of iD(e,i.split(`.`))){if(o==null||o===``){a.required&&c&&(n===`create`||s)&&(r[t]=[J(`validation.required`)]);continue}let e=nD(o,a);e.length>0&&(r[t]=e)}return r}function iD(e,t,n=``,r=!0){let[i,...a]=t,o=typeof e==`object`&&e?e:void 0;if(i===`*`)return(Array.isArray(e)?e:[]).flatMap((e,t)=>iD(e,a,`${n}${t}.`,!0));let s=o!==void 0&&Object.hasOwn(o,i),c=o?.[i],l=`${n}${i}`;return a.length===0?[{path:l,value:c,sent:s,parentSent:r}]:iD(c,a,`${l}.`,r&&s)}function aD({resource:e,action:t,count:n,subject:r,running:i,error:a,onRun:o,onClose:s}){let c=X(),l=t.input?.fields??[],[u,d]=(0,y.useState)(()=>xC(l)),[f,p]=(0,y.useState)({}),[m,h]=(0,y.useState)(!1),g=l.filter(e=>XE(e,u)),_=a&&!m?JE(a,l.map(e=>e.name)):{fields:{},form:null},v={..._.fields,...f};function x(e){if(e.preventDefault(),e.stopPropagation(),!t.input)return o(void 0);let{payload:n,errors:r}=CC(g,u),i={...rD(n,Object.fromEntries(Object.entries(t.input.constraints).filter(([e])=>g.some(t=>t.name===e.split(`.`)[0]))),`create`),...r};p(i),h(Object.keys(i).length>0),Object.keys(i).length===0&&o(n)}let S=GE(t,n,r,c);function C(n){let r=g.find(e=>e.name===n);if(!r||!t.input)return null;let i=e=>d(t=>({...t,[n]:e}));return r.type===`object`?(0,b.jsx)(LE,{resource:e,field:r,path:n,pattern:n,value:u[n],constraints:t.input.constraints,markRequired:!0,errors:v,idPrefix:`action`,onChange:i}):(0,b.jsx)(EE,{resource:e,field:r,value:u[n],required:t.input.required.includes(n),errors:v[n],constraints:t.input.constraints[n],idPrefix:`action`,onChange:i})}return(0,b.jsx)(jd,{open:!0,onOpenChange:e=>!e&&!i&&s(),children:(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/30`}),(0,b.jsx)(Ud,{"aria-describedby":S?`action-question`:void 0,className:`fixed inset-x-3 top-[12vh] z-50 mx-auto flex max-h-[76vh] max-w-lg flex-col overflow-hidden rounded-xl border bg-background shadow-xl outline-none`,children:(0,b.jsxs)(`form`,{onSubmit:x,noValidate:!0,className:`flex min-h-0 flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto p-4`,children:[(0,b.jsx)(Jd,{className:`text-lg font-semibold`,children:t.label}),S&&(0,b.jsx)(`p`,{id:`action-question`,className:`text-sm`,children:S}),n>1&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(t.atomic?`action.atomicNote`:`action.eachNote`,{count:n})}),_.form&&(0,b.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:_.form}),t.input&&(0,b.jsx)(AE,{layout:void 0,names:l.map(e=>e.name),errors:v,render:C})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t p-4`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:i,onClick:s,children:c(`common.cancel`)}),(0,b.jsx)(q,{type:`submit`,variant:t.variant===`destructive`?`destructive`:`default`,disabled:i,children:i?c(`action.running`):t.label})]})]})})]})})}function oD({resource:e,action:t,ids:n,subject:r,size:i=`default`,className:a,primary:o=!1,menuItem:s=!1,blocked:c=!1,describedBy:l,onDone:u}){let d=X(),f=S(),[p,m]=(0,y.useState)(!1),h=WE(t,n?.length??0),g=pt({mutationFn:r=>Q.runAction(e,t.name,{...n?{ids:n}:{},...r?{input:r}:{}}),onSuccess:r=>{let i=KE(r);m(!1),i.kind===`bulk`?i.message&&RT(i.message):RT(i.message??d(i.kind===`record`&&i.record===null?`action.doneGone`:`action.done`,{action:t.label})),u(i,n??[]);for(let t of[`list`,`count`,`record`,`history`])f.invalidateQueries({queryKey:[t,e]})},onError:e=>{h&&RT(dg(e),`error`)}}),_=Xw(t.icon);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(q,{type:`button`,size:i,variant:t.variant===`destructive`?`destructive`:o?`default`:s?`ghost`:`outline`,className:W(s&&`w-full justify-start font-normal`,a),disabled:c||g.isPending,"aria-describedby":l,"data-action":t.name,onClick:()=>{g.reset(),h?g.mutate(void 0):m(!0)},children:[_&&(0,b.jsx)(_,{"aria-hidden":!0}),t.label,o&&(0,b.jsx)(Sv,{className:`ltr:rotate-180`,"aria-hidden":!0})]}),p&&(0,b.jsx)(aD,{resource:e,action:t,count:n?.length??0,subject:r,running:g.isPending,error:g.error,onRun:e=>g.mutate(e),onClose:()=>m(!1)})]})}function sD({schema:e,record:t,id:n,dirty:r,onGone:i,onChanged:a}){let o=X(),s=S(),[c,l]=(0,y.useState)(!1),{primary:u,buttons:d,overflow:f}=BE(e,t);if(!u&&d.length===0)return null;let p=`record-actions-note`,m=(o,c={})=>(0,b.jsx)(oD,{resource:e.name,action:o,ids:[n],subject:typeof t._title==`string`?t._title:`#${n}`,blocked:r,describedBy:r?p:void 0,...c,onDone:t=>{l(!1);let r=t.kind===`record`?t.record:void 0;if(r===null){i(),s.removeQueries({queryKey:[`record`,e.name,n]});return}r&&s.setQueryData([`record`,e.name,n],r),a()}},o.name);return(0,b.jsxs)(`div`,{role:`group`,"aria-label":o(`list.actions`),className:`ms-auto flex flex-wrap items-center gap-2`,children:[r&&(0,b.jsx)(`span`,{id:p,className:`text-xs text-muted-foreground`,children:o(`action.saveFirst`)}),d.map(e=>m(e)),f.length>0&&(0,b.jsxs)(Sh,{open:c,onOpenChange:l,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`icon`,"aria-label":o(`action.more`),children:(0,b.jsx)(Kv,{})})}),(0,b.jsx)(wh,{forceMount:!0,children:(0,b.jsx)(Th,{forceMount:!0,align:`end`,sideOffset:6,className:`z-50 flex min-w-48 flex-col gap-0.5 rounded-[10px] border bg-popover p-1.5 shadow-lg data-[state=closed]:hidden`,onClick:()=>l(!1),children:f.map(e=>m(e,{menuItem:!0}))})})]}),u&&m(u,{primary:!0})]})}function cD({schema:e,ids:t,bulkOnly:n=!1,size:r=`default`}){let i=X(),a=(e.prints??[]).filter(e=>!n||e.bulk);return t.length===0||a.length===0?null:(0,b.jsx)(b.Fragment,{children:a.map(n=>{let a=Xw(n.icon)??mb;return(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:r,"aria-label":i(`print.open`,{name:n.label}),onClick:()=>window.open(Bg(e.name,n.name,t),`_blank`,`noopener`),children:[(0,b.jsx)(a,{}),n.label]},n.name)})})}function lD({schema:e,query:t,iconOnly:n=!1}){let r=X(),[i,a]=(0,y.useState)(!1);if(!e.list.export)return null;async function o(){a(!0);try{let{blob:n,filename:i,truncated:a}=await Q.exportList(e.name,t),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=i,s.click(),setTimeout(()=>URL.revokeObjectURL(o),1e4),RT(a?r(`list.exportTruncated`,{count:a}):r(`list.exportDone`,{file:i}),a?`error`:`success`)}catch(e){RT(dg(e),`error`)}finally{a(!1)}}return(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:n?`icon`:`default`,disabled:i,"aria-label":n?r(`list.export`):void 0,onClick:()=>void o(),children:[(0,b.jsx)(Qv,{}),!n&&r(i?`list.exporting`:`list.export`)]})}function uD(e){let t=(0,y.useRef)(!1),n=ha(({currentLocation:n,nextLocation:r})=>e&&!t.current&&(n.pathname!==r.pathname||n.search!==r.search));return(0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e]),{blocker:n,release:()=>{t.current=!0}}}function dD({blocker:e}){let t=X();return e.state===`blocked`?(0,b.jsxs)(`div`,{role:`alertdialog`,"aria-labelledby":`leave-title`,className:`sticky top-16 z-10 flex flex-wrap items-center gap-2 rounded-md border border-amber-500/50 bg-background p-3 shadow-sm`,children:[(0,b.jsx)(`p`,{id:`leave-title`,className:`flex-1 text-sm font-medium`,children:t(`form.leaveTitle`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,autoFocus:!0,onClick:()=>e.reset(),children:t(`form.stay`)}),(0,b.jsx)(q,{type:`button`,variant:`destructive`,onClick:()=>e.proceed(),children:t(`form.leave`)})]}):null}function fD(e,t){let n=(0,y.useRef)(t);n.current=t,(0,y.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey)||t.altKey||t.shiftKey||t.key.toLowerCase()!==`s`)return;t.preventDefault();let r=document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`);(!r||r.contains(e.current))&&(n.current?.(),e.current?.requestSubmit())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function pD(e){let[t,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(e);return a.current=e,(0,y.useEffect)(()=>{t.length>0||!r||(i(!1),a.current())},[t.length,r]),{busy:t.length>0,setBusy:(e,t)=>n(n=>t===n.includes(e)?n:t?[...n,e]:n.filter(t=>t!==e)),refuse:()=>i(!0)}}function mD({dirty:e,children:t}){let n=X();return(0,b.jsxs)(`div`,{className:`sticky bottom-3 z-10 flex flex-wrap items-center gap-2 rounded-card border bg-card px-4 py-2.5 shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:[e&&(0,b.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[13px] font-semibold`,children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full bg-amber-500`}),n(`form.unsaved`)]}),(0,b.jsx)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:t})]})}function hD(){let e=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);return(0,b.jsx)(`kbd`,{"aria-hidden":!0,className:`rounded border border-current/30 px-1 font-sans text-[10.5px] opacity-80`,children:e?`⌘S`:`Ctrl S`})}var gD=`—`,_D=e=>e==null||e===``;function vD(e,t){let n=t?.value;switch(e.kind){case`image`:return typeof n==`string`&&n!==``?{kind:`image`,src:n}:{kind:`image`};case`toggle`:return{kind:`toggle`,on:n===!0};case`money`:{if(_D(n))return{kind:`money`,text:gD};let e=kx(String(n),_D(t?.previous)?{}:{previous:String(t.previous)});return{kind:`money`,text:e.main,...e.unit?{unit:e.unit,unitPosition:e.position}:{},...e.previous===void 0?{}:{previous:e.previous}}}case`badge`:return{kind:`badge`,text:t?.label??(_D(n)?gD:String(n)),...t?.tone?{tone:t.tone}:{}};case`count`:return{kind:`count`,text:typeof n==`number`?Qh(n):_D(n)?gD:$h(String(n))};case`title`:return{kind:`title`,text:_D(n)?gD:String(n),..._D(t?.subline)?{}:{subline:String(t.subline)}}}}function yD({schema:e,name:t,column:n,item:r,compact:i=!1}){let a=r._computed?.[t],o=vD(n,a);switch(o.kind){case`image`:return(0,b.jsx)(`span`,{className:W(`flex shrink-0 items-center justify-center overflow-hidden rounded-control border bg-muted text-muted-foreground`,i?`size-14`:`size-10`),children:o.src?(0,b.jsx)(`img`,{src:o.src,alt:``,className:`size-full object-cover`,loading:`lazy`}):(0,b.jsx)(gy,{className:`size-[18px]`,"aria-hidden":!0})});case`title`:return(0,b.jsxs)(`span`,{className:`flex min-w-0 flex-col leading-[1.45]`,children:[(0,b.jsx)(`span`,{className:W(`truncate font-semibold`,i?`text-[14.5px]`:`text-[13.5px]`),children:o.text}),o.subline&&(0,b.jsx)(`span`,{className:`truncate text-start font-mono text-[11.5px] text-muted-foreground`,children:(0,b.jsx)(`bdi`,{dir:`ltr`,children:o.subline})})]});case`money`:return(0,b.jsxs)(`span`,{className:`flex flex-col leading-[1.4]`,children:[(0,b.jsxs)(`span`,{className:`font-semibold whitespace-nowrap`,children:[o.unit&&o.unitPosition===`before`&&(0,b.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[o.unit,` `]}),o.text,o.unit&&o.unitPosition!==`before`&&(0,b.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[` `,o.unit]})]}),o.previous&&(0,b.jsx)(`s`,{className:`text-xs text-muted-foreground`,children:o.previous})]});case`badge`:return(0,b.jsx)(XT,{tone:o.tone,children:o.text});case`count`:return(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:o.text});case`toggle`:return(0,b.jsx)(bD,{schema:e,column:n,item:r,on:o.on===!0})}}function bD({schema:e,column:t,item:n,on:r}){let i=X(),a=S(),[o,s]=(0,y.useState)(r),c=t.toggle,l=c!==void 0&&n._perm?.update!==!1&&!(Array.isArray(n._readonly)&&n._readonly.includes(c.field)),u=pt({mutationFn:t=>Q.update(e.name,String(n._id),{[c.field]:t?c.on:c.off},e.version?n[e.version]:void 0),onSuccess:()=>a.invalidateQueries({queryKey:[`list`,e.name]}),onError:e=>{s(r),RT(dg(e),`error`)}}),d=typeof n._title==`string`?n._title:String(n._id);return(0,b.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":i(`list.toggleRow`,{column:t.label,name:d}),disabled:!l||u.isPending,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(!o),u.mutate(!o)},className:W(`relative inline-block h-5 w-9 shrink-0 cursor-pointer rounded-full bg-input transition-colors disabled:cursor-default disabled:opacity-60`,o&&`bg-primary`,`after:absolute after:top-0.5 after:size-4 after:rounded-full after:bg-white after:shadow-sm after:transition-[inset-inline-start] after:content-[''] after:start-0.5`,o&&`after:start-[18px]`)})}function xD(e){let t=e.form.layout;return t?t.flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>`fields`in e&&!(`inline`in e)?e.fields:[]):[...new Set([...e.form.update,...e.form.readonly])]}function SD(e){let t=(e.form.layout??[]).flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>`summary`in e?e.summary.flatMap(e=>`field`in e.value?[e.value.field]:[]):[]),n=(e.form.aside??[]).flatMap(e=>e.relation?[e.relation.field]:e.fields),r=[...e.form.header?.badges??[],...(e.form.header?.subtitle??[]).flatMap(e=>`field`in e?[e.field]:[])],i=new Set(e.form.update);return new Set([...t,...n,...r].filter(e=>!i.has(e)))}function CD(e,t,n){let r=e.form.mode===`view`&&t!==void 0&&!n,i=new Set(xD(e)),a=r?[]:e.form.update.filter(t=>i.has(t)||!e.form.layout),o=e.form.header,s=t=>e.fields.find(e=>e.name===t),c=e=>e!==void 0&&t?.[e.name]!==void 0&&t?.[e.name]!==null,l=(o?.badges?o.badges.map(s):e.fields.filter(e=>e.widget===`badge`)).filter(c),u=o?.stepper?s(o.stepper):void 0;u&&c(u)&&u.steps?.exclude.includes(String(t[u.name]))&&!l.includes(u)&&l.push(u);let d=t?._computed??{};return{editable:a,header:{badges:l,subtitle:(o?.subtitle??[]).flatMap(n=>{if(`field`in n){let e=s(n.field);return e&&c(e)?[jx(t[e.name],e)]:[]}let r=e.list.computed?.[n.computed];if(!r||!d[n.computed])return[];let i=vD(r,d[n.computed]);return i.text?[r.kind===`count`?`${i.text} ${r.label}`:i.text]:[]}),...u?{stepper:u}:{}},aside:e.form.aside??[]}}function wD(e,t,n){return e.relation?n?._aside?.[String(t)]:n}function TD(e,t,n){let r=n?._computed??{};return e.summary.flatMap(e=>{if(`field`in e.value){let r=t.fields.find(t=>t.name===e.value.field),i=n?.[e.value.field];return r&&i!=null?[{label:e.label,text:jx(i,r)}]:[]}let i=t.list.computed?.[e.value.computed],a=r[e.value.computed];if(!i||!a)return[];let o=vD(i,a),s=o.unit?o.unitPosition===`before`?`${o.unit} ${o.text}`:`${o.text} ${o.unit}`:o.text;return s?[{label:e.label,text:s}]:[]})}function ED(e,t){let n={};for(let r of e){if(!r.warnIf||!(r.name in t))continue;let e=t[r.name];(e==null||typeof e==`string`&&e.trim()===``)&&(n[r.name]=r.warnIf.message)}return n}function DD(e,t){return e.fields.filter(t=>t!==e.order).flatMap(e=>t.fields.filter(t=>t.name===e))}function OD(e,t,n){let r=n?._inlines?.[e.inline],i=DD(e,t);return(r?.rows??[]).map(e=>({key:String(e._id),id:String(e._id),record:e,values:xC(i,e)}))}function kD(e,t,n){return{key:n,values:xC(DD(e,t))}}function AD(e,t){if(!e.record)return new Set;let n=e.record._perm;if(t.permissions?.update===!1||n?.update===!1)return new Set(t.fields.map(e=>e.name));let r=Array.isArray(e.record._readonly)?e.record._readonly:[];return new Set([...t.form.readonly,...r])}function jD(e,t,n,r){let i=DD(e,t),a={},o=[],s=[],c=new Map(n.map(e=>[e.key,e]));for(let e of r){let n=c.get(e.key);if(n?.id!==void 0){let r=AD(e,t),{payload:o,errors:c}=CC(i.filter(e=>!r.has(e.name)),e.values,n.values),l={...rD(o,t.form.constraints.update,`update`),...c};if(Object.keys(l).length>0&&(a[e.key]=l),Object.keys(o).length===0)continue;let u=t.version?n.record?.[t.version]:void 0;s.push({_id:n.id,...o,...typeof u==`number`?{_version:u}:{}})}else{let{payload:n,errors:r}=CC(i,e.values),s={...rD(n,t.form.constraints.create,`create`),...r};Object.keys(s).length>0&&(a[e.key]=s),o.push({_key:e.key,...n})}}let l=new Set(r.map(e=>e.key)),u=n.filter(e=>e.id!==void 0&&!l.has(e.key)).map(e=>e.id),d=e.order!==void 0&&t.form.update.includes(e.order),f=r.map(e=>e.key),p=d&&f.join(`
|
|
55
|
+
`))continue;o.file.many?(r||t.length>0)&&(i[o.name]=t.map(hC)):t[0]?i[o.name]=hC(t[0]):(o.nullable||n)&&(i[o.name]=null);continue}if(o.relation?.kind===`to-many`){let t=Array.isArray(e)?e.filter(uC):[],r=n?.[o.name];(n?!gC(t,Array.isArray(r)?r.filter(uC):[]):t.length>0)&&(i[o.name]=t.map(e=>e.id));continue}if(o.type===`relation`){let t=uC(e)?e:null,r=n?.[o.name];if(n&&String(t?.id)===String(uC(r)?r.id:void 0))continue;t?i[o.name]=t.id:(o.nullable||n)&&(i[o.name]=null);continue}if(o.type===`boolean`){i[o.name]=e===!0;continue}let c=typeof e==`string`?e:``,l=c.trim();if(l===``){(o.nullable||n)&&(i[o.name]=null);continue}switch(o.type){case`number`:case`decimal`:case`bigint`:{let e=SC(Nh(l),o.type===`bigint`);e===void 0?a[s]=[J(`validation.number`)]:i[o.name]=o.type===`number`?Number(e):e;break}case`json`:try{i[o.name]=JSON.parse(l)}catch{a[s]=[J(`validation.json`)]}break;case`date`:{let e=Mh(l);!/^\d{4}-\d{2}-\d{2}$/.test(e)||Number.isNaN(Date.parse(`${e}T00:00:00Z`))||new Date(`${e}T00:00:00Z`).toISOString().slice(0,10)!==e?a[s]=[J(`validation.date`)]:i[o.name]=e;break}case`datetime`:{let e=new Date(Mh(l));Number.isNaN(e.getTime())?a[s]=[J(`validation.datetime`)]:i[o.name]=e.toISOString();break}default:i[o.name]=c}}return{payload:i,errors:a}}function wC(e,t){let{payload:n}=CC(e,t),r=e=>Array.isArray(e)?e.every(e=>typeof e==`string`||typeof e==`number`):typeof e==`string`?e.length<=100:typeof e!=`object`||!e,i=Object.fromEntries(Object.entries(n).filter(([,e])=>r(e))),a=JSON.stringify(i);return a.length<=4e3?a:void 0}var TC=`(max-width: 767px)`;function EC(e){let t=window.matchMedia(TC);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function DC(){return(0,y.useSyncExternalStore)(EC,()=>window.matchMedia(TC).matches,()=>!1)}function OC(e,t){if(e.widget===`stepper`)return`select`;if(e.widget)return e.widget;switch(e.type){case`boolean`:return`checkbox`;case`enum`:return`select`;case`text`:return`textarea`;case`json`:case`object`:return`json`;case`number`:case`decimal`:case`bigint`:return`number`;case`date`:return`date`;case`datetime`:return`datetime`;default:return t?.format===`email`?`email`:t?.format===`url`?`url`:`text`}}function kC(e,t){return e.enumLabels?.[t]??t}var AC=`h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,jC=new Set([`number`,`decimal`,`bigint`,`date`,`datetime`]);function MC({schema:e,params:t,onChange:n,trailing:r}){let i=X(),a=DC(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(),u=t.get(`search`)??``,[d,f]=(0,y.useState)(u);(0,y.useEffect)(()=>{f(u)},[u]);let p=e.list.filters.map(t=>({operators:t.operators,field:e.fields.find(e=>e.name===t.field)})).filter(e=>e.field!==void 0),m=e.list.search.length>0,h=a&&(p.length>0||e.list.sortable.length>0);if(p.length===0&&!m&&!h&&!r)return null;let g=e.list.search.map(t=>e.fields.find(e=>e.name===t)?.label??t);if(!a){let a=new Map(oC(e,t).map(e=>[e.key,e]));return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m&&(0,b.jsx)(WC,{label:i(`filters.search`),placeholder:i(`filters.searchIn`,{fields:g.join(`, `)}),value:d,onChange:f,onSubmit:()=>n({search:d.trim()||null})}),p.length>0&&(0,b.jsx)(`ul`,{"aria-label":i(`filters.filters`),className:`contents`,children:p.map(({field:r,operators:i})=>(0,b.jsx)(`li`,{className:`contents`,children:(0,b.jsx)(GC,{resource:e.name,field:r,operators:i,params:t,onChange:n,chip:a.get(`filter:${r.name}`)})},r.name))}),qS(t)&&(0,b.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(JS(t)),children:[i(`filters.clear`),(0,b.jsx)(bx,{className:`size-3.5`})]}),r&&(0,b.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:r})]})}let _=$S(t),v=oC(e,t).length>0,x=NC(e,t,i),S=()=>{l(new URLSearchParams(t)),s(!0)};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[m&&(0,b.jsx)(WC,{className:`flex-1`,label:i(`filters.search`),placeholder:i(`filters.searchIn`,{fields:g.join(`, `)}),value:d,onChange:f,onSubmit:()=>n({search:d.trim()||null})}),h&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,"aria-haspopup":`dialog`,onClick:S,children:[(0,b.jsx)(Bb,{}),i(`filters.filters`),_>0&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs text-primary-foreground`,children:Qh(_)})]})]}),(v||h&&x)&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v&&(0,b.jsx)(BC,{schema:e,params:t,onChange:n}),h&&x&&(0,b.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 items-center gap-1.5 rounded-full border border-input bg-card px-3 text-[13px]`,"aria-haspopup":`dialog`,onClick:S,children:[(0,b.jsx)(H_,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),x]})]}),h&&(0,b.jsx)(jd,{open:o,onOpenChange:s,children:(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/40`}),(0,b.jsxs)(Ud,{"aria-describedby":void 0,className:`fixed inset-x-0 bottom-0 z-50 flex max-h-[85dvh] flex-col rounded-t-[18px] bg-card shadow-xl outline-none`,children:[(0,b.jsx)(`div`,{className:`flex justify-center pt-2`,"aria-hidden":!0,children:(0,b.jsx)(`span`,{className:`h-1.5 w-10 rounded-full bg-input`})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 ps-4 pe-2 pt-1.5 pb-2`,children:[(0,b.jsx)(Jd,{className:`flex-1 text-[17px] font-bold`,children:i(`filters.filtersAndSort`)}),qS(t)&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,className:`text-primary`,onClick:()=>n(JS(t)),children:i(`filters.clear`)})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-5 overflow-y-auto px-4 py-1`,children:[p.map(({field:r,operators:i})=>(0,b.jsx)(FC,{resource:e.name,field:r,operators:i,params:t,onChange:n,touch:!0},r.name)),e.list.sortable.length>0&&(0,b.jsx)(PC,{schema:e,params:t,onChange:n})]}),(0,b.jsxs)(`div`,{className:`flex gap-2.5 border-t px-4 pt-3 pb-5`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>{c&&n(eC(t,c)),s(!1)},children:i(`common.cancel`)}),(0,b.jsx)(Xd,{asChild:!0,children:(0,b.jsx)(q,{className:`flex-1`,children:i(`filters.showResults`)})})]})]})]})})]})}function NC(e,t,n){if(e.list.sortable.length===0)return``;let{field:r,direction:i}=e.list.defaultSort,a=t.get(`sort`)??(i===`desc`?`-${r}`:r),o=a.replace(/^-/,``),s=e.fields.find(e=>e.name===o)?.label??o;return n(a.startsWith(`-`)?`filters.descending`:`filters.ascending`,{name:s})}function PC({schema:e,params:t,onChange:n}){let r=X(),{field:i,direction:a}=e.list.defaultSort,o=t.get(`sort`)??(a===`desc`?`-${i}`:i),s=t=>e.fields.find(e=>e.name===t)?.label??t;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`list-sort`,children:r(`filters.sortBy`)}),(0,b.jsx)(`select`,{id:`list-sort`,className:AC,value:o,onChange:e=>n({sort:e.target.value,page:null,after:null}),children:e.list.sortable.flatMap(e=>[(0,b.jsx)(`option`,{value:e,children:r(`filters.ascending`,{name:s(e)})},e),(0,b.jsx)(`option`,{value:`-${e}`,children:r(`filters.descending`,{name:s(e)})},`-${e}`)])})]})}function FC(e){let t=(0,b.jsx)(zC,{...e}),{field:n,operators:r,params:i,onChange:a}=e;return!n.nullable||!r.includes(`isNull`)||n.type===`relation`?t:(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t,(0,b.jsx)(IC,{field:n,params:i,onChange:a})]})}function IC({field:e,params:t,onChange:n}){let r=X(),i=KS(e.name,`isNull`);return(0,b.jsxs)(`select`,{"aria-label":r(`filters.emptyValues`,{field:e.label}),className:W(AC,`h-7 text-xs text-muted-foreground`),value:t.get(i)??``,onChange:e=>n({[i]:e.target.value||null}),children:[(0,b.jsx)(`option`,{value:``,children:r(`filters.any`)}),(0,b.jsx)(`option`,{value:`true`,children:r(`filters.onlyEmpty`)}),(0,b.jsx)(`option`,{value:`false`,children:r(`filters.hideEmpty`)})]})}function LC({id:e,inline:t,field:n,params:r,onChange:i}){let a=X(),o=KS(n.name,`in`),s=(r.get(o)??``).split(`,`).filter(Boolean),c=e=>{let t=s.includes(e)?s.filter(t=>t!==e):[...s,e];i({[o]:t.length>0?t.join(`,`):null})};return t?(0,b.jsx)(RC,{field:n,selected:s,onToggle:c}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:e,children:n.label}),(0,b.jsxs)(Sh,{children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(q,{id:e,type:`button`,variant:`outline`,className:`justify-between font-normal`,children:[(0,b.jsx)(`span`,{className:`truncate`,children:s.length===0?a(`common.all`):s.length<=2?s.map(e=>kC(n,e)).join(`, `):a(`filters.selected`,{count:s.length})}),(0,b.jsx)(bv,{className:`size-4 opacity-60`,"aria-hidden":!0})]})}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`start`,sideOffset:4,className:`z-50 min-w-48 rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:(0,b.jsx)(RC,{field:n,selected:s,onToggle:c})})})]})]})}function RC({field:e,selected:t,onToggle:n}){return(0,b.jsx)(`ul`,{"aria-label":e.label,children:(e.enumValues??[]).map(r=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,b.jsx)(ff,{checked:t.includes(r),onCheckedChange:()=>n(r),className:`flex size-4 items-center justify-center rounded border border-input data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground`,children:(0,b.jsx)(mf,{children:(0,b.jsx)(vv,{className:`size-3`})})}),kC(e,r)]})},r))})}function zC({inline:e,touch:t,resource:n,field:r,operators:i,params:a,onChange:o}){let{t:s,calendar:c}=Y(),l=`filter-${r.name}`;if(t&&r.type===`enum`&&i.includes(`in`))return(0,b.jsx)(qC,{field:r,params:a,onChange:o});if(r.type===`enum`&&i.includes(`in`))return(0,b.jsx)(LC,{id:l,inline:e,field:r,params:a,onChange:o});if(r.type===`relation`){let e=r.relation?.kind===`to-many`?`in`:`eq`;return i.includes(e)?(0,b.jsx)(HC,{id:l,resource:n,field:r,operator:e,params:a,onChange:o}):null}if((r.type===`enum`||r.type===`boolean`)&&i.includes(`eq`)){let e=KS(r.name,`eq`),n=r.type===`boolean`?[[`true`,s(`common.yes`)],[`false`,s(`common.no`)]]:(r.enumValues??[]).map(e=>[e,kC(r,e)]);return t&&n.length<=3?(0,b.jsx)(JC,{label:r.label,options:[[``,s(`common.all`)],...n],value:a.get(e)??``,onChange:t=>o({[e]:t||null})}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:l,children:r.label}),(0,b.jsxs)(`select`,{id:l,className:AC,value:a.get(e)??``,onChange:t=>o({[e]:t.target.value||null}),children:[(0,b.jsx)(`option`,{value:``,children:s(`common.all`)}),n.map(([e,t])=>(0,b.jsx)(`option`,{value:e,children:t},e))]})]})}if((r.type===`date`||r.type===`datetime`)&&i.includes(`gte`)&&i.includes(`lte`)){let e=(e,t)=>r.type===`date`||!t?t:new Date(`${t}T${e===`gte`?`00:00:00.000`:`23:59:59.999`}`).toISOString(),t=e=>e&&r.type===`datetime`?bC(e).slice(0,10):e??``;return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:r.label}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`gte`,`lte`].map(n=>{let i=KS(r.name,n),c=`${l}-${n}`,u=s(n===`gte`?`filters.from`:`filters.to`);return(0,b.jsxs)(`div`,{className:`flex min-w-36 flex-1 flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:c,className:`text-xs text-muted-foreground`,children:u}),(0,b.jsx)(IS,{id:c,label:`${r.label} ${u}`,value:t(a.get(i)),onChange:t=>o({[i]:e(n,t)||null})})]},n)})})]})}if(jC.has(r.type)&&i.includes(`gte`)&&i.includes(`lte`)){let e=r.type===`date`?`date`:r.type===`datetime`?`datetime-local`:`text`,t=e=>r.type===`datetime`&&e?new Date(e).toISOString():Nh(e.trim()).replace(/,/g,``),n=e=>e&&r.type===`datetime`?bC(e):e??``;return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:r.label}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:[`gte`,`lte`].map(i=>{let c=KS(r.name,i),u=`${l}-${i}`;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:u,className:`text-xs text-muted-foreground`,children:s(i===`gte`?`filters.from`:`filters.to`)}),(0,b.jsx)(UC,{id:u,type:e,inputMode:e===`text`?`decimal`:void 0,value:n(a.get(c)),onCommit:e=>o({[c]:t(e)||null})})]},i)})})]})}let u=i.includes(`contains`)?`contains`:i.includes(`eq`)?`eq`:void 0;if(!u)return null;let d=KS(r.name,u);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:l,children:u===`contains`?s(`filters.contains`,{field:r.label}):r.label}),(0,b.jsx)(UC,{id:l,value:a.get(d)??``,onCommit:e=>o({[d]:e.trim()||null})})]})}function BC({schema:e,params:t,onChange:n}){let r=X(),i=oC(e,t);return(0,b.jsx)(`ul`,{"aria-label":r(`filters.active`),className:`flex flex-wrap gap-2`,children:i.map(t=>(0,b.jsxs)(`li`,{className:`inline-flex h-9 items-center gap-1 rounded-full border border-primary bg-primary-soft ps-3 pe-1.5 text-[13px] font-semibold text-primary`,children:[(0,b.jsxs)(`span`,{className:`font-medium`,children:[t.label,`:`]}),t.ref?(0,b.jsx)(VC,{resource:e.name,chip:t}):(0,b.jsx)(`span`,{children:t.value}),(0,b.jsx)(`button`,{type:`button`,className:`rounded-full p-1 hover:bg-primary-soft`,"aria-label":r(`filters.removeChip`,{label:t.label}),onClick:()=>n(Object.fromEntries(t.remove.map(e=>[e,null]))),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},t.key))})}function VC({resource:e,chip:t}){let n=Xg(e,t.ref.field,t.ref.ids);if(!n.data)return(0,b.jsx)(`span`,{children:t.value});let r=new Map(n.data.items.map(e=>[String(e.id),e.title]));return(0,b.jsx)(`span`,{children:t.ref.prefix+t.ref.ids.map(e=>r.get(e)??`#${e}`).join(`, `)})}function HC({id:e,resource:t,field:n,operator:r,params:i,onChange:a}){let o=KS(n.name,r),s=(i.get(o)??``).split(`,`).filter(Boolean),c=Xg(t,n.name,s),l=new Map((c.data?.items??[]).map(e=>[String(e.id),e])),u=s.map(e=>l.get(e)??{id:e,title:`#${e}`});return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:e,children:n.label}),(0,b.jsx)(HS,{id:e,resource:t,field:n,clearable:!0,value:r===`in`?u:u[0]??null,onChange:e=>{let t=Array.isArray(e)?e:e?[e]:[];a({[o]:t.length>0?t.map(e=>e.id).join(`,`):null})}})]})}function UC({id:e,value:t,type:n=`text`,inputMode:r,onCommit:i}){let[a,o]=(0,y.useState)(t);(0,y.useEffect)(()=>{o(t)},[t]);let s=()=>{a!==t&&i(a)};return(0,b.jsx)(Oh,{id:e,type:n,inputMode:r,value:a,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())}})}function WC({label:e,placeholder:t,value:n,className:r,onChange:i,onSubmit:a}){return(0,b.jsxs)(`form`,{role:`search`,className:W(`relative w-[300px] max-w-full`,r),onSubmit:e=>{e.preventDefault(),a()},children:[(0,b.jsx)(wb,{className:`pointer-events-none absolute start-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(Oh,{"aria-label":e,placeholder:t,value:n,className:`ps-8`,onChange:e=>i(e.target.value)})]})}function GC({chip:e,...t}){let n=X(),{field:r,onChange:i}=t,a=e&&(()=>i(Object.fromEntries(e.remove.map(e=>[e,null]))));return(0,b.jsxs)(Sh,{children:[(0,b.jsxs)(`span`,{className:W(`inline-flex h-8 items-center rounded-lg border border-dashed border-input`,e&&`border-solid bg-card`),children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,className:`inline-flex h-full items-center gap-1.5 rounded-lg px-2.5 text-[12.5px] font-medium outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50`,children:[e?(0,b.jsx)(My,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}):(0,b.jsx)(Ov,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),r.label,e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`:`}),(0,b.jsx)(`span`,{className:`h-4 w-px bg-border`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`max-w-48 truncate rounded-[5px] bg-muted px-1.5 text-xs font-medium`,children:e.ref?(0,b.jsx)(VC,{resource:t.resource,chip:e}):e.value})]})]})}),a&&(0,b.jsx)(`button`,{type:`button`,className:`-ms-1 me-1 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":n(`filters.removeChip`,{label:r.label}),onClick:a,children:(0,b.jsx)(bx,{className:`size-3.5`})})]}),(0,b.jsx)(wh,{children:(0,b.jsx)(Th,{align:`start`,sideOffset:6,onOpenAutoFocus:r.type===`relation`?e=>e.preventDefault():void 0,className:`z-50 flex w-72 flex-col gap-3 rounded-[10px] border bg-popover p-3 text-popover-foreground shadow-lg outline-none`,children:(0,b.jsx)(FC,{...t,inline:!0})})})]})}var KC=`inline-flex h-9 items-center gap-1.5 rounded-full border border-input bg-card px-3 text-[13px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50 data-[state=checked]:border-primary data-[state=checked]:bg-primary-soft data-[state=checked]:font-semibold data-[state=checked]:text-primary`;function qC({field:e,params:t,onChange:n}){let r=KS(e.name,`in`),i=(t.get(r)??``).split(`,`).filter(Boolean),a=e=>{let t=i.includes(e)?i.filter(t=>t!==e):[...i,e];n({[r]:t.length>0?t.join(`,`):null})};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,"aria-hidden":!0,children:e.label}),(0,b.jsx)(`ul`,{"aria-label":e.label,className:`flex flex-wrap gap-2`,children:(e.enumValues??[]).map(t=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(ff,{checked:i.includes(t),onCheckedChange:()=>a(t),className:KC,children:[(0,b.jsx)(mf,{children:(0,b.jsx)(vv,{className:`size-3.5`})}),kC(e,t)]})},t))})]})}function JC({label:e,options:t,value:n,onChange:r}){return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,"aria-hidden":!0,children:e}),(0,b.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`grid auto-cols-fr grid-flow-col gap-0.5 rounded-[10px] bg-muted p-[3px]`,children:t.map(([e,t])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e,className:W(`h-9 rounded-lg text-[13px] text-muted-foreground`,n===e&&`bg-card font-semibold text-foreground shadow-sm`),onClick:()=>r(e),children:t},e))})]})}var YC=[`auth.*`,`auth.login`,`auth.login_failed`,`auth.view_as`,`rbac.*`,`rbac.role.changed`,`rbac.user_roles.changed`,`page.*`],XC=[`*`,`created`,`updated`,`deleted`,`restored`,`purged`,`action.*`];function ZC(){let{t:e,locale:t}=Y(),[n,r]=wo(),i=Ug(),a=Hg(),o=a.data?.audit.view===!0,s=$x(n),c=mt({queryKey:[`audit`,s],initialPageParam:void 0,queryFn:({pageParam:e})=>Q.audit(s,e),getNextPageParam:e=>e.next,staleTime:0,enabled:o,retry:!1}),l=c.data?.pages.flatMap(e=>e.entries)??[],u=new Set((i.data?.groups??[]).flatMap(e=>e.resources.map(e=>e.name))),d=[...new Set(l.map(e=>e.resource).filter(e=>e!==void 0&&u.has(e)))].sort(),f=ut({queries:d.map(e=>({queryKey:[`schema`,e,t],queryFn:()=>Q.schema(e),retry:!1}))}),p=e=>f[d.indexOf(e)]?.data,m=new Set((i.data?.groups??[]).flatMap(e=>e.pages.map(e=>e.name))),h=[...new Set(l.map(e=>e.meta?.page).filter(e=>e!==void 0&&m.has(e)))].sort(),g=ut({queries:h.map(e=>({queryKey:[`page`,e,t],queryFn:()=>Q.page(e),retry:!1}))}),_=e=>g[h.indexOf(e)]?.data?.schema.fields,v=(e,t)=>r(n=>YS(n,tS(e,t))),y=c.error instanceof ug&&(c.error.status===403||c.error.status===404);if(a.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(!o||y)return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{children:e(`audit.title`)}),(0,b.jsx)(G,{tone:`error`,children:y?dg(c.error):e(a.data?.audit.enabled?`audit.notAllowed`:`audit.off`)})]});let x=(i.data?.groups??[]).flatMap(e=>e.resources),S=n.get(`resource`)??``;return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{children:e(`audit.title`)}),(0,b.jsxs)(`fieldset`,{className:`grid gap-3 rounded-card border bg-card shadow-card p-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:e(`filters.filters`)}),(0,b.jsx)(QC,{label:e(`audit.filter.actor`),value:n.get(`actor`)??``,onCommit:e=>v(`actor`,e)}),(0,b.jsx)(QC,{label:e(`audit.filter.event`),placeholder:e(`audit.filter.eventHint`),value:n.get(`event`)??``,onCommit:e=>v(`event`,e),hints:[...S?XC.map(e=>`${S}.${e}`):[],...YC]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`audit-resource`,children:e(`audit.filter.resource`)}),(0,b.jsxs)(`select`,{id:`audit-resource`,className:AC,value:S,onChange:e=>v(`resource`,e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:e(`common.all`)}),S&&!x.some(e=>e.name===S)&&(0,b.jsx)(`option`,{value:S,children:S}),x.map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]}),(0,b.jsx)(QC,{label:e(`audit.filter.record`),placeholder:S?void 0:e(`audit.filter.recordHint`),value:S?n.get(`record`)??``:``,disabled:!S,onCommit:e=>v(`record`,e)}),[`from`,`to`].map(t=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`audit-${t}`,children:e(`filters.${t}`)}),(0,b.jsx)(IS,{id:`audit-${t}`,label:e(`filters.${t}`),value:n.get(t)??``,onChange:e=>v(t,e)})]},t)),eS(n)&&(0,b.jsx)(`div`,{className:`flex items-end sm:col-span-2 lg:col-span-3`,children:(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(e=>YS(e,nS())),children:e(`filters.clear`)})})]}),c.isError&&(0,b.jsx)(T_,{children:dg(c.error)}),c.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):l.length===0?!c.isError&&(0,b.jsx)(G,{children:e(eS(n)?`audit.noMatches`:`audit.empty`)}):(0,b.jsx)(rS,{entries:l,now:new Date(c.dataUpdatedAt),names:Px(i.data,p),schemaOf:p,pageFieldsOf:_,onActor:e=>v(`actor`,e),showSubject:!0}),c.hasNextPage&&(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`self-center`,disabled:c.isFetchingNextPage,onClick:()=>void c.fetchNextPage(),children:e(c.isFetchingNextPage?`common.loading`:`list.loadMore`)})]})}function QC({label:e,value:t,onCommit:n,placeholder:r,disabled:i,hints:a}){let o=(0,y.useId)(),[s,c]=(0,y.useState)(t);(0,y.useEffect)(()=>c(t),[t]);let l=()=>{s.trim()!==t&&n(s)};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:o,children:e}),(0,b.jsx)(Oh,{id:o,type:`text`,dir:`auto`,value:s,placeholder:r,disabled:i,list:a?`${o}-hints`:void 0,autoComplete:`off`,spellCheck:!1,onChange:e=>c(e.target.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())}}),a&&(0,b.jsx)(`datalist`,{id:`${o}-hints`,children:a.map(e=>(0,b.jsx)(`option`,{value:e},e))})]})}var $C={hidden:`rbac.rule.hidden`,view:`rbac.rule.readonly`,edit:`rbac.rule.edit`};function ew(){let{t:e}=Y(),[t,n]=wo(),r=t.get(`user`)??``,i=t.get(`resource`)??``,a=t.get(`record`)??``,o=ft({queryKey:[`rbac`,`catalog`],queryFn:Q.rbac.catalog}),s=ft({queryKey:[`rbac`,`user`,r],queryFn:()=>Q.rbac.user(r),enabled:r!==``}),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(i),[f,p]=(0,y.useState)(a),[m,h]=(0,y.useState)(r),g=ft({queryKey:[`rbac`,`users`,c,1],queryFn:()=>Q.rbac.users({search:c}),enabled:c.trim().length>0}),_=ft({queryKey:[`rbac`,`explain`,r,i,a],queryFn:()=>Q.rbac.explain({user:r,resource:i,record:a||void 0}),enabled:r!==``&&i!==``});function v(e){e.preventDefault();let t={};m&&(t.user=m),u&&(t.resource=u),f.trim()&&(t.record=f.trim()),n(t)}let x=m===r?s.data?.displayName:void 0;return(0,b.jsxs)(`div`,{className:`flex max-w-5xl flex-col gap-5`,children:[(0,b.jsx)(w_,{children:e(`debugger.title`)}),(0,b.jsx)(`p`,{className:`-mt-3 text-sm text-muted-foreground`,children:e(`debugger.intro`)}),(0,b.jsxs)(`form`,{onSubmit:v,className:`grid gap-4 rounded-card border bg-card shadow-card p-4 md:grid-cols-3`,"aria-label":e(`debugger.title`),children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-user`,children:e(`debugger.user`)}),(0,b.jsx)(Oh,{id:`debug-user`,placeholder:e(`rbac.searchUsers`),value:c,onChange:e=>l(e.target.value),autoComplete:`off`}),c.trim()&&(0,b.jsx)(`ul`,{"aria-label":e(`rbac.searchResults`),className:`flex flex-col rounded-md border text-sm`,children:(g.data?.items??[]).slice(0,6).map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,className:`w-full px-2 py-1.5 text-start hover:bg-accent`,onClick:()=>{h(e.id),l(``)},children:[e.displayName,e.username&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.username]})]})},e.id))}),m&&(0,b.jsx)(`p`,{className:`text-sm`,"data-testid":`debug-chosen-user`,children:x??m})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-resource`,children:e(`debugger.resource`)}),(0,b.jsxs)(`select`,{id:`debug-resource`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:u,onChange:e=>d(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`—`}),(o.data?.resources??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`debug-record`,children:e(`debugger.record`)}),(0,b.jsx)(Oh,{id:`debug-record`,dir:`ltr`,value:f,onChange:e=>p(e.target.value)})]}),(0,b.jsx)(`div`,{className:`md:col-span-3`,children:(0,b.jsx)(q,{type:`submit`,disabled:!m||!u,children:e(`debugger.explain`)})})]}),!r||!i?(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`debugger.pick`)}):_.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):_.isError?(0,b.jsx)(G,{tone:`error`,children:dg(_.error)}):(0,b.jsx)(nw,{data:_.data})]})}function tw({allowed:e}){let{t}=Y();return(0,b.jsx)(`span`,{className:W(`rounded-full px-2 py-0.5 text-xs font-medium`,e?`bg-green-500/15 text-green-800 dark:text-green-300`:`bg-destructive/10 text-destructive`),children:t(e?`debugger.allowed`:`debugger.denied`)})}function nw({data:e}){let{t,locale:n}=Y(),r=e=>e.kind===`group`?t(`debugger.source.group`,{group:e.group??``}):t(`debugger.source.${e.kind}`),i=e=>e===`all`?t(`debugger.allRows`):e.length===0?t(`debugger.noRows`):t(`debugger.someRows`,{scopes:e.join(`, `)});return(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,"data-testid":`explanation`,children:[(0,b.jsxs)(`section`,{"aria-labelledby":`debug-roles`,className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`h2`,{id:`debug-roles`,className:`font-medium`,children:[t(`debugger.roles`),` · `,e.user.displayName]}),e.superuser?(0,b.jsx)(`p`,{className:`text-sm`,children:t(`debugger.superuser`)}):e.roles.length===0?(0,b.jsx)(`p`,{className:`text-sm`,children:t(`debugger.noRoles`)}):(0,b.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.roles.map(e=>(0,b.jsxs)(`li`,{children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(e.label,n)||e.name}),` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.sources.map(r).join(`, `),`)`]}),!e.known&&(0,b.jsx)(`span`,{className:`ms-2 text-destructive`,children:t(`debugger.unknownRole`)})]},e.name))})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-operations`,className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`h2`,{id:`debug-operations`,className:`font-medium`,children:[t(`debugger.operations`),` · `,e.resource.label]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsx)(`table`,{className:`w-full text-sm`,children:(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.operations.map(n=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{scope:`row`,className:`w-32 px-3 py-2 text-start font-medium`,children:t(`rbac.op.${n.operation}`)}),(0,b.jsx)(`td`,{className:`w-24 px-3 py-2`,children:(0,b.jsx)(tw,{allowed:n.allowed})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>t(e.via?`debugger.viaUpdate`:`debugger.grant`,{pattern:e.pattern,role:e.role})).join(` · `)})]},n.operation))})})})]}),e.actions.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-actions`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-actions`,className:`font-medium`,children:t(`debugger.actions`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsx)(`table`,{className:`w-full text-sm`,children:(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.actions.map(n=>(0,b.jsxs)(`tr`,{"data-action":n.name,children:[(0,b.jsx)(`th`,{scope:`row`,className:`w-32 px-3 py-2 text-start font-medium`,children:n.label}),(0,b.jsx)(`td`,{className:`w-24 px-3 py-2`,children:(0,b.jsx)(tw,{allowed:n.allowed})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:[n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>t(`debugger.grant`,{pattern:e.pattern,role:e.role})).join(` · `),...n.needsUpdate?[t(`debugger.needsUpdate`)]:[]].join(` — `)})]},n.name))})})})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-fields`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-fields`,className:`font-medium`,children:t(`debugger.fields`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/40 text-xs text-muted-foreground`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.field`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.result`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.byRole`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.fields.map(e=>(0,b.jsxs)(`tr`,{"data-field":e.name,children:[(0,b.jsxs)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-medium`,children:[e.label,e.restricted&&(0,b.jsx)(`span`,{className:`ms-2 rounded-full border px-1.5 text-xs font-normal text-muted-foreground`,children:t(`rbac.restricted`)})]}),(0,b.jsxs)(`td`,{className:`px-3 py-2`,children:[t($C[e.level]),e.forced&&(0,b.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t(`debugger.forced`)})]}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.byRole.map(e=>`${e.role}: ${t($C[e.level])}${e.rule?` (${e.rule})`:``}${e.code?` (${e.code})`:``}`).join(` · `)})]},e.name))})]})})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`debug-scopes`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-scopes`,className:`font-medium`,children:t(`debugger.scopes`)}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.scopes.map(e=>(0,b.jsxs)(`li`,{children:[(0,b.jsxs)(`span`,{className:`font-medium`,children:[t(`rbac.op.${e.operation}`),`:`]}),` `,i(e.result),e.byRole.length>0&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.byRole.map(e=>`${e.role}: ${i(e.scopes)}`).join(` · `),`)`]}),e.global.length>0&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,t(`debugger.globalScopes`,{scopes:e.global.join(`, `)})]})]},e.operation))})]}),e.record&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-record-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-record-title`,className:`font-medium`,children:t(`debugger.recordTitle`,{id:e.record.id})}),(0,b.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[[`view`,`update`,`delete`].map(n=>(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,"data-operation":n,children:[(0,b.jsx)(`span`,{className:`w-24 font-medium`,children:t(`rbac.op.${n}`)}),(0,b.jsx)(tw,{allowed:e.record[n]}),e.record.reasons[n]&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:t(`debugger.reason.${e.record.reasons[n]}`)})]},n)),e.record.actions&&(0,b.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,"data-operation":`actions`,children:[(0,b.jsx)(`span`,{className:`w-24 font-medium`,children:t(`debugger.actions`)}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.record.actions.length===0?t(`debugger.noRecordActions`):e.record.actions.map(t=>e.actions.find(e=>e.name===t)?.label??t).join(`, `)})]})]})]}),e.pages.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`debug-pages`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`debug-pages`,className:`font-medium`,children:t(`debugger.pages`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/40 text-xs text-muted-foreground`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.page`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.op.view`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`rbac.op.update`)}),(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:t(`debugger.byRole`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y`,children:e.pages.map(n=>(0,b.jsxs)(`tr`,{"data-page":n.name,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-medium`,children:n.label}),(0,b.jsx)(`td`,{className:`px-3 py-2`,"data-operation":`view`,children:(0,b.jsx)(tw,{allowed:n.view})}),(0,b.jsx)(`td`,{className:`px-3 py-2`,"data-operation":`update`,children:(0,b.jsx)(tw,{allowed:n.update})}),(0,b.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.superuser?``:n.grantedBy.length===0?t(`debugger.noGrant`):n.grantedBy.map(e=>`${t(`debugger.grant`,{pattern:e.pattern,role:e.role})} (${e.code})`).join(` · `)})]},n.name))})]})})]})]})}function rw(){let{t:e,locale:t}=Y(),n=Hg(),r=ft({queryKey:[`rbac`,`groups`],queryFn:Q.rbac.groups});return r.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:n.data?.rbac.manage&&(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/groups/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newGroup`)]})}),children:e(`rbac.groups`)}),r.data.items.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`rbac.noGroups`)}),(0,b.jsx)(`ul`,{"aria-label":e(`rbac.groups`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card empty:hidden`,children:r.data.items.map(n=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/groups/${n.id}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(n.label,t)||n.name}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`rbac.groupSummary`,{roles:n.roles.length,members:n.members.length})})]})},n.id))})]})}function iw(){let{t:e}=Y(),{id:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),i=ft({queryKey:[`rbac`,`group`,t],queryFn:()=>Q.rbac.group(Number(t)),enabled:!n});return r.isPending||!n&&i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):!n&&i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsx)(aw,{roles:r.data.items,group:n?void 0:i.data},t??`new`)}function aw({roles:e,group:t}){let{t:n,locale:r}=Y(),i=Yi(),a=S(),o=Hg().data?.rbac.manage!==!0,[s,c]=(0,y.useState)(t?.name??``),[l,u]=(0,y.useState)(C_(t?.label)),[d,f]=(0,y.useState)(t?.roles??[]),[p,m]=(0,y.useState)(t?.members??[]),[h,g]=(0,y.useState)(``),_=ft({queryKey:[`rbac`,`users`,h],queryFn:()=>Q.rbac.users({search:h}),enabled:h.trim().length>0}),v=ft({queryKey:[`rbac`,`users`,``,1],queryFn:()=>Q.rbac.users({})}),[x,C]=(0,y.useState)({}),w=e=>x[e]??v.data?.items.find(t=>t.id===e)?.displayName??e,[T,E]=(0,y.useState)(null),D=pt({mutationFn:()=>Q.rbac.saveGroup({name:s.trim(),label:S_(l)??null,roles:d,members:p},t?.id),onSuccess:async e=>{await a.invalidateQueries({queryKey:[`rbac`]}),await a.invalidateQueries({queryKey:[`session`]}),i(`/-/groups/${e.id}`,{replace:!0}),E(null)},onError:e=>E(dg(e))}),O=pt({mutationFn:()=>Q.rbac.deleteGroup(t.id),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`rbac`]}),i(`/-/groups`)},onError:e=>E(dg(e))});function k(e){e.preventDefault(),o||D.mutate()}return(0,b.jsxs)(`form`,{onSubmit:k,className:`flex max-w-3xl flex-col gap-5`,"aria-label":n(`rbac.group`),children:[(0,b.jsx)(w_,{children:t?x_(t.label,r)||t.name:n(`rbac.newGroup`)}),T&&(0,b.jsx)(T_,{children:T}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`group-name`,children:n(`rbac.name`)}),(0,b.jsx)(Oh,{id:`group-name`,dir:`ltr`,value:s,disabled:o,onChange:e=>c(e.target.value)})]}),lg.locales.map(e=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`group-label-${e}`,children:n(`rbac.labelIn`,{language:e})}),(0,b.jsx)(Oh,{id:`group-label-${e}`,value:l[e]??``,disabled:o,onChange:t=>u({...l,[e]:t.target.value})})]},e))]}),(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:n(`rbac.roles`)}),e.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:d.includes(e.name),disabled:o,onChange:t=>f(t.target.checked?[...d,e.name]:d.filter(t=>t!==e.name))}),x_(e.label,r)||e.name]},e.name))]}),(0,b.jsxs)(`section`,{"aria-labelledby":`members-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`members-title`,className:`font-medium`,children:n(`rbac.members`)}),(0,b.jsxs)(`ul`,{"aria-label":n(`rbac.members`),className:`flex flex-wrap gap-2`,children:[p.map(e=>(0,b.jsxs)(`li`,{className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-sm`,children:[w(e),!o&&(0,b.jsx)(`button`,{type:`button`,"aria-label":n(`picker.remove`,{name:w(e)}),onClick:()=>m(p.filter(t=>t!==e)),children:(0,b.jsx)(bx,{className:`size-3.5`})})]},e)),p.length===0&&(0,b.jsx)(`li`,{className:`text-sm text-muted-foreground`,children:n(`rbac.noMembers`)})]}),!o&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`member-search`,children:n(`rbac.addMember`)}),(0,b.jsx)(Oh,{id:`member-search`,value:h,placeholder:n(`rbac.searchUsers`),onChange:e=>g(e.target.value)}),(0,b.jsx)(`ul`,{"aria-label":n(`rbac.searchResults`),className:`flex flex-wrap gap-2`,children:(_.data?.items??[]).filter(e=>!p.includes(e.id)).map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{C({...x,[e.id]:e.displayName}),m([...p,e.id])},children:[(0,b.jsx)(fb,{}),e.displayName,e.username?` (${e.username})`:``]})},e.id))})]})]}),!o&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:D.isPending||!s.trim(),children:n(D.isPending?`form.saving`:`form.save`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>i(`/-/groups`),children:n(`common.cancel`)}),t&&(0,b.jsx)(q,{type:`button`,variant:`outline`,className:`ms-auto`,disabled:O.isPending,onClick:()=>O.mutate(),children:n(`form.delete`)})]})]})}var ow=[`view`,`create`,`update`,`delete`,`purge`,`field`,`action`];function sw(e,t){let n=e.split(`.`),r=t.split(`.`),i=r[0]===`page`&&!ow.includes(r[1]??``)&&(r.length===2||r.length===3&&r[2]===`update`);if(n[0]===`*`&&n.length>1&&i)return!1;for(let e=0;e<n.length;e++){let t=n[e];if(t===`*`&&e===n.length-1)return r.length>e;if(e>=r.length||t!==`*`&&t!==r[e])return!1}return n.length===r.length}function cw(e){let t=[...e.global];for(let n of e.resources){for(let r of e.operations)t.push(`${n.name}.${r}`);for(let e of n.custom)t.push(`${n.name}.${e}`);for(let e of n.actions)t.push(`${n.name}.action.${e.name}`)}for(let n of e.pages)t.push(`page.${n.name}`,`page.${n.name}.update`);return t}function lw(e,t){return e.some(e=>sw(e,t))}function uw(e,t,n,r){if(n)return lw(e,t)?e:[...e,t];let i=[];for(let n of e)if(n!==t){if(n.includes(`*`)&&sw(n,t)){for(let e of r)e!==t&&sw(n,e)&&!i.includes(e)&&i.push(e);continue}i.push(n)}return i.filter(e=>e===t||!sw(e,t))}var dw=[`view`,`update`,`delete`];function fw(){let{t:e}=Y(),{name:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`catalog`],queryFn:Q.rbac.catalog}),i=ft({queryKey:[`rbac`,`role`,t],queryFn:()=>Q.rbac.role(t),enabled:!n});return r.isPending||!n&&i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):r.isError?(0,b.jsx)(G,{tone:`error`,children:dg(r.error)}):!n&&i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsx)(pw,{catalog:r.data,role:n?void 0:i.data},t??`new`)}function pw({catalog:e,role:t}){let{t:n,locale:r}=Y(),i=Yi(),a=S(),o=Hg(),s=t?.system===!0||o.data?.rbac.manage!==!0,c=cw(e),[l,u]=(0,y.useState)(t?.name??``),[d,f]=(0,y.useState)(C_(t?.label)),[p,m]=(0,y.useState)(t?.permissions??[]),[h,g]=(0,y.useState)(t?.fields??{}),[_,v]=(0,y.useState)(t?.scopes??{}),[x,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(null),E=pt({mutationFn:()=>{let e={label:S_(d),permissions:p,fields:mw(h),scopes:mw(_)};return t?Q.rbac.updateRole(t.name,e):Q.rbac.createRole({name:l.trim(),...e})},onSuccess:async e=>{await a.invalidateQueries({queryKey:[`rbac`]}),await a.invalidateQueries({queryKey:[`session`]}),i(`/-/roles/${encodeURIComponent(e.name)}`,{replace:!0}),T(null)},onError:e=>T(e instanceof ug?[e.message,...Object.values(e.fields).flat()].join(` — `):dg(e))}),D=pt({mutationFn:()=>Q.rbac.deleteRole(t.name),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`rbac`]}),i(`/-/roles`)},onError:e=>T(dg(e))}),O=(e,t)=>m(n=>uw(n,e,t,c)),k=(e,t,n)=>g(r=>{let i={...r,[e]:{...r[e]}};return n===``?delete i[e][t]:i[e][t]=n,i}),A=(e,t,n,r)=>v(i=>{let a=i[e]?.[t],o=new Set(Array.isArray(a)?a:a?[a]:[]);return r?o.add(n):o.delete(n),{...i,[e]:{...i[e],[t]:[...o]}}});function j(e){e.preventDefault(),s||E.mutate()}let M=[...new Set(e.resources.map(e=>e.group))];return(0,b.jsxs)(`form`,{onSubmit:j,className:`flex max-w-5xl flex-col gap-5`,"aria-label":n(`rbac.role`),children:[(0,b.jsx)(w_,{children:t?x_(t.label,r)||t.name:n(`rbac.newRole`)}),t?.system&&(0,b.jsx)(T_,{tone:`success`,children:n(`rbac.systemNote`)}),w&&(0,b.jsx)(T_,{children:w}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`role-name`,children:n(`rbac.name`)}),(0,b.jsx)(Oh,{id:`role-name`,dir:`ltr`,value:l,disabled:!!t,onChange:e=>u(e.target.value)})]}),lg.locales.map(e=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`role-label-${e}`,children:n(`rbac.labelIn`,{language:e})}),(0,b.jsx)(Oh,{id:`role-label-${e}`,value:d[e]??``,disabled:s,onChange:t=>f({...d,[e]:t.target.value})})]},e))]}),(0,b.jsxs)(`section`,{"aria-labelledby":`matrix-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`matrix-title`,className:`font-medium`,children:n(`rbac.matrix`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b bg-muted/40`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:n(`rbac.resource`)}),e.operations.map(e=>(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.${e}`)},e)),(0,b.jsx)(`th`,{className:`w-0`})]})}),(0,b.jsx)(`tbody`,{children:M.map(t=>(0,b.jsx)(y.Fragment,{children:e.resources.filter(e=>e.group===t).map(t=>{let r=x===t.name,i=`role-details-${t.name}`;return(0,b.jsxs)(y.Fragment,{children:[(0,b.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-normal`,children:t.label}),e.operations.map(e=>{let r=`${t.name}.${e}`;return(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.${e}`),resource:t.label}),checked:lw(p,r),disabled:s,onChange:e=>O(r,e.target.checked)})},e)}),(0,b.jsx)(`td`,{className:`px-2`,children:(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-expanded":r,"aria-controls":i,"aria-label":n(`rbac.details`,{resource:t.label}),onClick:()=>C(r?null:t.name),children:(0,b.jsx)(bv,{className:W(`transition-transform`,r&&`rotate-180`)})})})]}),r&&(0,b.jsx)(`tr`,{id:i,className:`border-b bg-muted/20`,children:(0,b.jsx)(`td`,{colSpan:e.operations.length+2,className:`px-3 py-3`,children:(0,b.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.fields`)}),t.fields.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsxs)(`span`,{children:[e.label,e.restricted&&(0,b.jsx)(`span`,{className:`ms-2 rounded-full bg-amber-500/15 px-2 py-0.5 text-xs text-amber-800 dark:text-amber-300`,children:n(`rbac.restricted`)})]}),(0,b.jsxs)(`select`,{className:`h-8 rounded-lg border border-input bg-transparent px-2 text-sm`,value:h[t.name]?.[e.name]??``,disabled:s,"aria-label":n(`rbac.fieldRule`,{field:e.label}),onChange:n=>k(t.name,e.name,n.target.value),children:[(0,b.jsx)(`option`,{value:``,children:n(e.restricted?`rbac.rule.defaultHidden`:`rbac.rule.default`)}),(0,b.jsx)(`option`,{value:`hidden`,children:n(`rbac.rule.hidden`)}),(0,b.jsx)(`option`,{value:`readonly`,children:n(`rbac.rule.readonly`)}),(0,b.jsx)(`option`,{value:`edit`,children:n(`rbac.rule.edit`)})]})]},e.name))]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.scopes.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.scopes`)}),dw.map(e=>{let r=_[t.name]?.[e],i=Array.isArray(r)?r:r?[r]:[];return(0,b.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,b.jsxs)(`legend`,{className:`me-2 text-sm`,children:[n(`rbac.op.${e}`),`:`]}),t.scopes.map(n=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:i.includes(n),disabled:s,onChange:r=>A(t.name,e,n,r.target.checked)}),n]},n)),i.length===0&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`rbac.allRows`)})]},e)})]}),t.actions.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,"data-actions":t.name,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.actions`)}),t.actions.map(e=>{let n=`${t.name}.action.${e.name}`;return(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,n),disabled:s,onChange:e=>O(n,e.target.checked)}),e.label,(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:n})]},e.name)}),t.actions.some(e=>e.target===`record`)&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`rbac.actionNote`)})]}),t.custom.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:n(`rbac.custom`)}),t.custom.map(e=>{let n=`${t.name}.${e}`;return(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,n),disabled:s,onChange:e=>O(n,e.target.checked)}),(0,b.jsx)(`code`,{className:`text-xs`,children:n})]},e)})]})]})]})})})]},t.name)})},t))})]})})]}),e.pages.length>0&&(0,b.jsxs)(`section`,{"aria-labelledby":`pages-title`,className:`flex flex-col gap-2`,children:[(0,b.jsx)(`h2`,{id:`pages-title`,className:`font-medium`,children:n(`rbac.pages`)}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-card border bg-card shadow-card`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b bg-muted/40`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-start font-medium`,children:n(`rbac.page`)}),(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.view`)}),(0,b.jsx)(`th`,{className:`px-2 py-2 text-center font-medium`,children:n(`rbac.op.update`)})]})}),(0,b.jsx)(`tbody`,{children:e.pages.map(e=>{let t=`page.${e.name}`,r=`${t}.update`,i=lw(p,r)&&!lw(p,t);return(0,b.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,b.jsx)(`th`,{scope:`row`,className:`px-3 py-2 text-start font-normal`,children:e.label}),(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.view`),resource:e.label}),title:i?n(`rbac.viewImplied`):void 0,checked:i||lw(p,t),disabled:s||i,onChange:e=>O(t,e.target.checked)})}),(0,b.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":n(`rbac.grant`,{operation:n(`rbac.op.update`),resource:e.label}),checked:lw(p,r),disabled:s,onChange:e=>O(r,e.target.checked)})})]},e.name)})})]})})]}),e.global.length>0&&(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:n(`rbac.global`)}),e.global.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:lw(p,e),disabled:s,onChange:t=>O(e,t.target.checked)}),(0,b.jsx)(`code`,{className:`text-xs`,children:e})]},e))]}),!s&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:E.isPending||!t&&!l.trim(),children:n(E.isPending?`form.saving`:`form.save`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>i(`/-/roles`),children:n(`common.cancel`)}),t&&(0,b.jsx)(q,{type:`button`,variant:`outline`,className:`ms-auto`,disabled:D.isPending,onClick:()=>D.mutate(),children:n(`form.delete`)})]})]})}function mw(e){let t=Object.entries(e).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0&&!(Array.isArray(e)&&e.length===0)))]).filter(([,e])=>Object.keys(e).length>0);return t.length>0?Object.fromEntries(t):void 0}function hw(){let{t:e,locale:t}=Y(),n=Hg(),r=S(),i=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(null),c=n.data?.rbac.manage===!0,l=pt({mutationFn:async e=>Q.rbac.importRoles(JSON.parse(await e.text())),onSuccess:async t=>{s(e(`rbac.imported`,{count:t.imported.length})),await r.invalidateQueries({queryKey:[`rbac`]})}});async function u(){let e=await Q.rbac.exportRoles(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`roles.json`,n.click(),URL.revokeObjectURL(t)}return i.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):i.isError?(0,b.jsx)(G,{tone:`error`,children:dg(i.error)}):(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(q,{variant:`outline`,onClick:()=>void u(),children:[(0,b.jsx)(Hv,{}),e(`rbac.export`)]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`input`,{ref:a,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":e(`rbac.importFile`),onChange:e=>{let t=e.target.files?.[0];t&&l.mutate(t),e.target.value=``}}),(0,b.jsxs)(q,{variant:`outline`,onClick:()=>a.current?.click(),children:[(0,b.jsx)(ox,{}),e(`rbac.import`)]}),(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/roles/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newRole`)]})})]})]}),children:e(`rbac.roles`)}),o&&(0,b.jsx)(T_,{tone:`success`,children:o}),l.isError&&(0,b.jsx)(T_,{children:l.error instanceof SyntaxError?e(`rbac.notJson`):dg(l.error)}),(0,b.jsx)(`ul`,{"aria-label":e(`rbac.roles`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:i.data.items.map(n=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/roles/${encodeURIComponent(n.name)}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsxs)(`span`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:x_(n.label,t)||n.name}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.name})]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e(`rbac.permissionCount`,{count:n.permissions.length}),n.system&&(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5`,children:e(`rbac.system`)})]})]})},n.name))})]})}function gw(){let{t:e}=Y(),t=Hg(),[n,r]=wo(),i=n.get(`search`)??``,a=Math.max(1,Number(n.get(`page`))||1),[o,s]=(0,y.useState)(i),c=ft({queryKey:[`rbac`,`users`,i,a],queryFn:()=>Q.rbac.users({search:i,page:a})});if(c.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(c.isError)return(0,b.jsx)(G,{tone:`error`,children:dg(c.error)});let{items:l,total:u,pageSize:d,capabilities:f}=c.data;return(0,b.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-4`,children:[(0,b.jsx)(w_,{actions:t.data?.rbac.manage&&f.create&&(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/users/new`,children:[(0,b.jsx)(fb,{}),e(`rbac.newUser`)]})}),children:e(`rbac.users`)}),!f.list&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`rbac.usersFromMemberships`)}),(0,b.jsxs)(`form`,{role:`search`,className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),r(o.trim()?{search:o.trim()}:{})},children:[(0,b.jsx)(Oh,{"aria-label":e(`rbac.searchUsers`),placeholder:e(`rbac.searchUsers`),value:o,onChange:e=>s(e.target.value)}),(0,b.jsx)(q,{type:`submit`,variant:`outline`,children:e(`filters.search`)})]}),(0,b.jsxs)(`ul`,{"aria-label":e(`rbac.users`),className:`flex flex-col divide-y rounded-card border bg-card shadow-card`,children:[l.map(t=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/-/users/${encodeURIComponent(t.id)}`,className:`flex flex-wrap items-center justify-between gap-2 px-4 py-3 hover:bg-muted/50`,children:[(0,b.jsxs)(`span`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:t.displayName}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[t.username,t.email].filter(Boolean).join(` · `)})]}),(0,b.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[t.isSuperuser&&(0,b.jsx)(`span`,{className:`rounded-full bg-purple-500/15 px-2 py-0.5 text-purple-800 dark:text-purple-300`,children:e(`rbac.superuser`)}),t.isActive===!1&&(0,b.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-muted-foreground`,children:e(`rbac.inactive`)}),t.twoFactor&&(0,b.jsx)(`span`,{className:`rounded-full bg-green-500/15 px-2 py-0.5 text-green-800 dark:text-green-300`,children:e(`rbac.twoFactor`)}),t.roles.map(e=>(0,b.jsx)(`span`,{className:`rounded-full border px-2 py-0.5`,children:e},e))]})]})},t.id)),l.length===0&&(0,b.jsx)(`li`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:e(`list.noMatches`)})]}),u>d&&(0,b.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-sm`,children:[(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a<=1,onClick:()=>r({...i?{search:i}:{},page:String(a-1)}),children:e(`list.previousPage`)}),(0,b.jsx)(`span`,{children:e(`list.pageOf`,{page:a,pages:Math.ceil(u/d)})}),(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:a*d>=u,onClick:()=>r({...i?{search:i}:{},page:String(a+1)}),children:e(`list.nextPage`)})]})]})}function _w(){let{t:e}=Y(),{id:t}=$i(),n=t===void 0,r=ft({queryKey:[`rbac`,`roles`],queryFn:Q.rbac.roles}),i=ft({queryKey:[`rbac`,`groups`],queryFn:Q.rbac.groups}),a=ft({queryKey:[`rbac`,`user`,t],queryFn:()=>Q.rbac.user(t),enabled:!n}),o=ft({queryKey:[`rbac`,`users`,``,1],queryFn:()=>Q.rbac.users({})});if(r.isPending||i.isPending||o.isPending||!n&&a.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});let s=r.error??i.error??o.error??(n?null:a.error);return s?(0,b.jsx)(G,{tone:`error`,children:dg(s)}):(0,b.jsx)(vw,{user:n?void 0:a.data,roles:r.data.items,groups:i.data.items,capabilities:o.data.capabilities},t??`new`)}function vw({user:e,roles:t,groups:n,capabilities:r}){let{t:i,locale:a}=Y(),o=Yi(),s=S(),c=Hg(),l=c.data?.rbac.manage===!0,u=c.data?.user.isSuperuser===!0,[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(e?.displayName??``),[h,g]=(0,y.useState)(e?.email??``),[_,v]=(0,y.useState)(e?.isActive!==!1),[x,C]=(0,y.useState)(e?.isSuperuser===!0),[w,T]=(0,y.useState)(e?.roles??[]),[E,D]=(0,y.useState)(e?.groups??[]),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)({}),[M,N]=(0,y.useState)(null),[ee,te]=(0,y.useState)(null),P=l&&(!e?.isSuperuser||u),ne=e=>{e instanceof ug&&Object.keys(e.fields).length>0?(j(e.fields),N(e.message)):(j({}),N(dg(e)))},re=pt({mutationFn:()=>{let t=r.update||!e?{displayName:p,email:h||null,isActive:_,...u?{isSuperuser:x}:{}}:{};return e?Q.rbac.updateUser(e.id,{...t,roles:w,groups:E}):Q.rbac.createUser({username:d,displayName:p,email:h||null,password:O,...u?{isSuperuser:x}:{},roles:w,groups:E})},onSuccess:async e=>{await s.invalidateQueries({queryKey:[`rbac`]}),j({}),N(null),te(i(`rbac.saved`)),o(`/-/users/${encodeURIComponent(e.id)}`,{replace:!0})},onError:ne}),ie=pt({mutationFn:()=>Q.rbac.resetTwoFactor(e.id),onSuccess:async()=>{await s.invalidateQueries({queryKey:[`rbac`]}),N(null),te(i(`rbac.twoFactorReset`))},onError:ne}),ae=!!e&&u&&!c.data?.viewAs&&e.id!==c.data?.user.id&&e.isActive!==!1,oe=pt({mutationFn:()=>Q.rbac.setPassword(e.id,O),onSuccess:()=>{k(``),j({}),N(null),te(i(`rbac.passwordSet`))},onError:ne});function se(e){e.preventDefault(),te(null),P&&re.mutate()}let ce=(t,n,i,a,o={})=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:t,children:n}),(0,b.jsx)(Oh,{id:t,value:i,disabled:!P||!!e&&!r.update,onChange:e=>a(e.target.value),"aria-invalid":A[t.replace(`user-`,``)]?!0:void 0,...o}),A[t.replace(`user-`,``)]&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:A[t.replace(`user-`,``)].join(` `)})]});return(0,b.jsxs)(`form`,{onSubmit:se,className:`flex max-w-3xl flex-col gap-5`,"aria-label":i(`rbac.user`),children:[(0,b.jsx)(w_,{actions:ae&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,onClick:()=>{Sg(e.id),s.clear(),o(`/`)},children:[(0,b.jsx)(Xv,{}),i(`viewAs.start`)]}),children:e?e.displayName:i(`rbac.newUser`)}),M&&(0,b.jsx)(T_,{children:M}),ee&&(0,b.jsx)(T_,{tone:`success`,children:ee}),e?.isSuperuser&&!u&&(0,b.jsx)(T_,{tone:`success`,children:i(`rbac.superuserNote`)}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[!e&&ce(`user-username`,i(`auth.username`),d,f,{dir:`ltr`,autoComplete:`off`}),ce(`user-displayName`,i(`rbac.displayName`),p,m),ce(`user-email`,i(`rbac.email`),h,g,{type:`email`,dir:`ltr`}),!e&&ce(`user-password`,i(`auth.password`),O,k,{type:`password`,autoComplete:`new-password`})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-6 text-sm`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:_,disabled:!P||!!e&&!r.update,onChange:e=>v(e.target.checked)}),i(`rbac.active`)]}),u&&(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:x,disabled:!P,onChange:e=>C(e.target.checked)}),i(`rbac.superuser`)]})]}),(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:i(`rbac.roles`)}),t.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:w.includes(e.name),disabled:!P,onChange:t=>T(t.target.checked?[...w,e.name]:w.filter(t=>t!==e.name))}),x_(e.label,a)||e.name]},e.name))]}),n.length>0&&(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`legend`,{className:`mb-1 font-medium`,children:i(`rbac.groups`)}),n.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:E.includes(e.id),disabled:!P,onChange:t=>D(t.target.checked?[...E,e.id]:E.filter(t=>t!==e.id))}),x_(e.label,a)||e.name]},e.id))]}),P&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`submit`,disabled:re.isPending,children:i(re.isPending?`form.saving`:e?`form.save`:`rbac.createUser`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>o(`/-/users`),children:i(`common.cancel`)})]}),e&&P&&r.password&&(0,b.jsxs)(`section`,{"aria-labelledby":`set-password`,className:`flex flex-col gap-2 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsx)(`h2`,{id:`set-password`,className:`font-medium`,children:i(`rbac.setPassword`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`user-new-password`,children:i(`auth.newPassword`)}),(0,b.jsx)(Oh,{id:`user-new-password`,type:`password`,autoComplete:`new-password`,value:O,onChange:e=>k(e.target.value)})]}),(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:!O||oe.isPending,onClick:()=>oe.mutate(),children:i(`rbac.setPassword`)})]}),A.password&&e&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:A.password.join(` `)}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`rbac.setPasswordNote`)})]}),e?.twoFactor&&P&&r.resetTwoFactor&&(0,b.jsxs)(`section`,{"aria-labelledby":`reset-two-factor`,className:`flex flex-col gap-2 rounded-card border bg-card shadow-card p-4`,children:[(0,b.jsx)(`h2`,{id:`reset-two-factor`,className:`font-medium`,children:i(`rbac.resetTwoFactor`)}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`rbac.resetTwoFactorNote`)}),(0,b.jsx)(`div`,{children:(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:ie.isPending,onClick:()=>ie.mutate(),children:i(`rbac.resetTwoFactor`)})})]})]})}function yw(e){if(!e.menu)return e.groups.map(e=>({...e,items:[...e.resources.map(e=>({kind:`resource`,name:e.name,label:e.label,...e.icon?{icon:e.icon}:{}})),...e.pages.map(e=>({kind:`page`,name:e.name,label:e.label,...e.icon?{icon:e.icon}:{}}))]}));let{sections:t,advanced:n}=e.menu;return[...t,...n.items.length>0?[n]:[]].map(e=>{let t=[],r=[],i=e.items.map(n=>n.kind===`resource`?(t.push({name:n.resource,label:n.label,...n.icon?{icon:n.icon}:{},creatable:n.creatable,searchable:n.searchable}),{kind:`resource`,name:n.resource,label:n.label,...n.icon?{icon:n.icon}:{},...n.badge?{badge:`${e.key}.${n.resource}`}:{}}):n.kind===`page`?(r.push({name:n.page,label:n.label,...n.icon?{icon:n.icon}:{}}),{kind:`page`,name:n.page,label:n.label,...n.icon?{icon:n.icon}:{}}):n);return{key:e.key,label:e.label,...e.icon?{icon:e.icon}:{},resources:t,pages:r,items:i,...e===n?{advanced:!0}:{}}})}function bw(e,t){let n=e.flatMap(e=>e.kind===`resource`&&e.badge&&t?.[e.badge]?[t[e.badge]]:[]);if(n.length!==0)return{count:n.reduce((e,t)=>e+t.count,0),estimate:n.some(e=>e.estimate)}}function xw({menu:e,current:t}){return e&&!t}function Sw(e){return Mh(e).toLocaleLowerCase().replace(/[يى]/g,`ی`).replace(/ك/g,`ک`).replace(//g,` `)}function Cw(e,t){let n=Sw(e);return Sw(t).split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function ww(e,t,n,r=[]){let i=[],a=[],o=yw(e),s=t.trim()!==``;for(let r of o){o.length>1&&Cw(r.label,t)&&i.push({id:`group:${r.key}`,section:`go`,label:r.label,to:`/g/${r.key}`,...r.icon?{icon:r.icon}:{}});for(let o of r.resources){let c=o.icon??r.icon;Cw(`${o.label} ${r.label}`,t)&&i.push({id:`go:${o.name}`,section:`go`,label:o.label,detail:r.label,to:`/${o.name}`,...c?{icon:c}:{}});let l=n(o.label),u=s||e.menu!==void 0&&!r.advanced&&a.length<3;o.creatable&&u&&Cw(l,t)&&a.push({id:`new:${o.name}`,section:`actions`,label:l,to:`/${o.name}/new`})}for(let e of r.pages){let n=e.icon??r.icon;Cw(`${e.label} ${r.label}`,t)&&i.push({id:`page:${e.name}`,section:`go`,label:e.label,detail:r.label,to:`/p/${e.name}`,...n?{icon:n}:{}})}}let c=r.filter(e=>Cw(e.label,t)).map(e=>({id:e.id,section:`actions`,label:e.label}));return[...i,...a,...c]}var Tw=`nma.theme`,Ew=`oklch(0.145 0 0)`,Dw=`oklch(0.985 0 0)`;function Ow(){try{let e=localStorage.getItem(Tw);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}function kw(e,t){return e===`system`?t?`dark`:`light`:e}var Aw=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches;function jw(e){let t=kw(e,Aw());document.documentElement.classList.toggle(`dark`,t===`dark`),document.documentElement.style.colorScheme=t}var Mw=`nma-theme`;function Nw(e){try{localStorage.setItem(Tw,e)}catch{}jw(e),typeof window<`u`&&window.dispatchEvent(new Event(Mw))}function Pw(){Nw(kw(Ow(),Aw())===`dark`?`light`:`dark`)}function Fw(e){if(typeof matchMedia!=`function`)return()=>void 0;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>{e()===`system`&&jw(`system`)};return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}function Iw(e){let t,n=/^#([0-9a-f]{3,8})$/i.exec(e.trim())?.[1];if(n){let e=n.length<=4?[...n.slice(0,3)].map(e=>e+e).join(``):n.slice(0,6);t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(e.trim());n&&(t=n.slice(1,4).map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function Lw(e){let t={};if(e.primaryColor){let n=Iw(e.primaryColor),r=e.primaryForeground??(n!==void 0&&n>.45?Ew:Dw);Object.assign(t,{"--primary":e.primaryColor,"--primary-foreground":r,"--ring":e.primaryColor,"--sidebar-primary":e.primaryColor,"--sidebar-primary-foreground":r})}return e.radius&&Object.assign(t,{"--nma-radius-control":e.radius,"--nma-radius-card":`calc(${e.radius} * 1.5)`}),t}function Rw(e){for(let[t,n]of Object.entries(Lw(e)))document.documentElement.style.setProperty(t,n)}var zw=`nma.accent`,Bw=`nma-accent`,Vw=/^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([0-9.,%\s/+-]+(deg|turn|rad)?[0-9.,%\s/+-]*\))$/i;function Hw(e){return(e.personal&&Vw.test(e.personal.trim())?e.personal:null)??e.admin??e.branding??void 0}function Uw(){try{return localStorage.getItem(zw)}catch{return null}}function Ww(e){try{e===null?localStorage.removeItem(zw):localStorage.setItem(zw,e)}catch{}}var Gw=null,Kw;function qw(e={}){`admin`in e&&(Gw=e.admin??null),`branding`in e&&(Kw=e.branding);let t=Hw({personal:Uw(),admin:Gw,branding:Kw}),n=[`--primary`,`--primary-foreground`,`--ring`,`--sidebar-primary`,`--sidebar-primary-foreground`];if(t)for(let[e,n]of Object.entries(Lw({primaryColor:t})))document.documentElement.style.setProperty(e,n);else for(let e of n)document.documentElement.style.removeProperty(e);typeof window<`u`&&window.dispatchEvent(new Event(Bw))}var Jw={archive:B_,ban:X_,bell:Q_,book:ev,box:nv,boxes:iv,briefcase:ov,building:cv,calendar:mv,chart:gv,check:vv,clock:Av,"credit-card":Iv,database:Rv,dollar:Bv,file:ny,"file-text":ey,folder:iy,globe:oy,heart:uy,history:bb,home:fy,image:gy,inbox:vy,key:by,layers:wy,link:Oy,list:Py,lock:Iy,mail:By,map:Wy,"map-pin":Hy,message:Jy,package:eb,phone:ob,printer:mb,receipt:gb,refresh:vb,send:Eb,server:Ob,settings:Ab,shield:Pb,"shopping-bag":Ib,cart:Rb,"shopping-cart":Rb,star:Hb,store:Wb,tag:Jb,tags:Xb,ticket:Qb,truck:ix,user:ux,users:fx,video:mx,wallet:gx,wrench:vx,x:bx,zap:Sx};Object.keys(Jw);function Yw(e,t){return Xw(e)??(t===`group`?iy:t===`page`?Ab:ey)}function Xw(e){return e&&Object.hasOwn(Jw,e)?Jw[e]:void 0}function Zw(e,t){let[n,r]=(0,y.useState)(e);return(0,y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function Qw(){let{t:e}=Y(),t=Yi(),n=Ug(),r=Hg(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(0),u=(0,y.useId)(),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),a(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let f=Zw(o.trim(),250),p=f.length>=2&&(n.data?.groups.some(e=>e.resources.some(e=>e.searchable))??!1),m=ft({queryKey:[`search`,f],queryFn:()=>Q.search(f),enabled:i&&p,staleTime:1e4}),h=e=>{let t=n.data?yw(n.data).find(t=>t.resources.some(t=>t.name===e)):void 0;return t?.resources.find(t=>t.name===e)?.icon??t?.icon},g=n.data?ww(n.data,o,t=>e(`palette.new`,{name:t}),[{id:`theme`,label:e(`palette.toggleTheme`)}]):[],_=[...p&&o.trim()===f?(m.data?.groups??[]).flatMap(e=>e.items.map(t=>({id:`record:${e.resource}:${t._id}`,section:`records`,...h(e.resource)?{icon:h(e.resource)}:{},label:t._title,detail:e.label,to:`/${e.resource}/${encodeURIComponent(t._id)}`}))):[],...g.filter(e=>e.section===`actions`),...g.filter(e=>e.section===`go`),...r.data?.audit.view&&Cw(e(`audit.title`),o)?[{id:`audit`,section:`go`,label:e(`audit.title`),to:`/-/audit`}]:[]],v=Math.min(c,Math.max(0,_.length-1));(0,y.useEffect)(()=>l(0),[o,m.data]),(0,y.useEffect)(()=>{d.current?.querySelector(`[data-index="${v}"]`)?.scrollIntoView({block:`nearest`})},[v]);function x(e){e&&(a(!1),e.to?t(e.to):e.id===`theme`&&Pw())}function S(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),_.length===0)return;l((v+(e.key===`ArrowDown`?1:-1)+_.length)%_.length)}else e.key===`Enter`&&(e.preventDefault(),x(_[v]))}let C=[[`records`,e(`palette.records`)],[`actions`,e(`palette.actions`)],[`go`,e(`palette.goTo`)]],w=e=>`${u}-${e}`,T=p&&(m.isFetching||o.trim()!==f)?e(`palette.searching`):_.length===0?e(`palette.noResults`):``;return(0,b.jsxs)(jd,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,b.jsx)(Nd,{asChild:!0,children:(0,b.jsxs)(q,{variant:`outline`,className:`w-9 justify-start px-0 font-normal text-muted-foreground max-sm:justify-center sm:w-[260px] sm:px-3.5`,"aria-keyshortcuts":`Control+K Meta+K`,"aria-label":e(`palette.open`),children:[(0,b.jsx)(wb,{}),(0,b.jsx)(`span`,{className:`hidden min-w-0 flex-1 truncate text-start sm:inline`,children:e(`palette.placeholder`)}),(0,b.jsx)(`kbd`,{className:`hidden shrink-0 rounded-[5px] border border-border bg-muted px-[5px] py-px font-mono text-[11px] text-muted-foreground sm:inline`,dir:`ltr`,children:`⌘K`})]})}),(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/30`}),(0,b.jsxs)(Ud,{"aria-describedby":void 0,className:`fixed inset-x-3 top-[12vh] z-50 mx-auto flex max-h-[70vh] max-w-[540px] flex-col overflow-hidden rounded-card border border-border bg-card text-card-foreground shadow-[0_24px_48px_rgba(0,0,0,.18)] outline-none`,children:[(0,b.jsx)(Jd,{className:`sr-only`,children:e(`palette.open`)}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-border px-4`,children:[(0,b.jsx)(wb,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`input`,{role:`combobox`,"aria-expanded":!0,"aria-controls":u,"aria-autocomplete":`list`,"aria-activedescendant":_.length>0?w(v):void 0,"aria-label":e(`palette.open`),placeholder:e(`palette.placeholder`),className:`h-[52px] flex-1 bg-transparent text-sm outline-none`,value:o,onChange:e=>s(e.target.value),onKeyDown:S}),(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] py-px font-mono text-[11px] text-muted-foreground`,dir:`ltr`,children:`Esc`})]}),(0,b.jsx)(`ul`,{ref:d,id:u,role:`listbox`,"aria-label":e(`palette.results`),className:`flex-1 overflow-y-auto p-1.5`,children:C.map(([e,t])=>{let n=_.map((e,t)=>({item:e,index:t})).filter(({item:t})=>t.section===e);return n.length===0?null:(0,b.jsxs)(`li`,{role:`presentation`,children:[(0,b.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground`,"aria-hidden":!0,children:t}),(0,b.jsx)(`ul`,{role:`group`,"aria-label":t,children:n.map(({item:e,index:t})=>(0,b.jsxs)(`li`,{id:w(t),role:`option`,"aria-selected":t===v,"data-index":t,className:W(`flex h-10 cursor-pointer items-center gap-3 rounded-control px-2.5 text-[13.5px]`,t===v&&`bg-muted`),onMouseMove:()=>l(t),onClick:()=>x(e),children:[(0,b.jsx)($w,{item:e}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.section===`go`&&e.detail?`${e.detail} › ${e.label}`:e.label}),e.section===`records`&&e.detail&&(0,b.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.detail})]},e.id))})]},e)})}),(0,b.jsx)(`p`,{role:`status`,className:W(`px-4 text-sm text-muted-foreground`,T&&`border-t border-border py-2`),children:T}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 border-t border-border px-4 py-2.5 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,children:`↑↓`}),e(`palette.move`)]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,children:`↵`}),e(`palette.openItem`)]}),(0,b.jsxs)(`span`,{className:`ms-auto flex items-center gap-1.5`,children:[(0,b.jsx)(`kbd`,{className:`rounded-[5px] border border-border bg-muted px-[5px] font-mono text-[11px]`,dir:`ltr`,children:`⌘K`}),e(`palette.close`)]})]})]})]})]})}function $w({item:e}){let t=e.id.startsWith(`new:`)?fb:e.id===`theme`?Qy:Yw(e.icon,e.section===`records`?`resource`:`group`);return(0,b.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})}var eT={en:`English`,fa:`فارسی`};function tT(){let{t:e}=Y(),[t,n]=(0,y.useState)(Ow),r=[[`light`,e(`shell.themeLight`),Kb],[`dark`,e(`shell.themeDark`),Qy],[`system`,e(`shell.themeSystem`),Xy]];return(0,b.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`shell.theme`),className:`flex items-center rounded-control border border-border p-0.5`,children:r.map(([e,r,i])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,"aria-label":r,title:r,className:W(`rounded-md p-1.5 text-muted-foreground hover:text-foreground`,t===e&&`bg-muted text-foreground`),onClick:()=>{Nw(e),n(e)},children:(0,b.jsx)(i,{className:`size-4`})},e))})}function nT(){let{t:e,locale:t,locales:n,setLocale:r}=Y();return n.length<2?null:(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,b.jsx)(Sy,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`shell.language`)}),(0,b.jsx)(`select`,{className:`h-8 flex-1 rounded-control border border-input bg-card px-2 text-[13px]`,value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,b.jsx)(`option`,{value:e,lang:e,children:eT[e]??e},e))})]})}function rT(){let{t:e,calendar:t,digits:n,setDisplay:r}=Y(),i=(e,t,n,r)=>(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,b.jsx)(`div`,{className:`flex rounded-control border border-border p-0.5`,children:n.map(([e,n])=>(0,b.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,className:W(`flex-1 cursor-pointer rounded-md px-2 py-1 text-[13px] text-muted-foreground hover:text-foreground`,t===e&&`bg-muted text-foreground`),onClick:()=>r(e),children:n},e))})]});return(0,b.jsxs)(b.Fragment,{children:[i(e(`display.calendar`),t,[[`gregorian`,e(`display.gregorian`)],[`persian`,e(`display.jalali`)]],e=>r({calendar:e})),i(e(`display.digits`),n,[[`latn`,e(`display.latinDigits`)],[`arabext`,e(`display.persianDigits`)]],e=>r({digits:e}))]})}function iT(){let{t:e}=Y(),[t,n]=(0,y.useState)(Ow);(0,y.useEffect)(()=>{let e=()=>n(Ow());return window.addEventListener(Mw,e),()=>window.removeEventListener(Mw,e)},[]);let r=t===`dark`||t===`system`&&typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,b.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":e(`shell.theme`),title:e(`shell.theme`),onClick:Pw,children:r?(0,b.jsx)(Kb,{}):(0,b.jsx)(Qy,{})})}var aT=[`#5B5BD6`,`#2563EB`,`#0E7490`,`#0F766E`,`#9333EA`,`#DB2777`,`#EA580C`];function oT(){let{t:e}=Y(),t=Hg(),n=S(),[r,i]=(0,y.useState)(Uw);(0,y.useEffect)(()=>{let e=()=>i(Uw());return window.addEventListener(Bw,e),()=>window.removeEventListener(Bw,e)},[]);let a=t.data?.appearance,o=pt({mutationFn:e=>Q.setAppearance(e),onSuccess:async({accent:e})=>{Ww(null),qw({admin:e}),await n.invalidateQueries({queryKey:[`session`]})}}),s=e=>{Ww(e),qw()},c=r??a?.accent??null;return(0,b.jsxs)(`div`,{role:`group`,"aria-label":e(`display.accent`),className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e(`display.accent`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[aT.map(e=>(0,b.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":c?.toLowerCase()===e.toLowerCase(),className:W(`size-6 cursor-pointer rounded-full border-2 border-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring`,c?.toLowerCase()===e.toLowerCase()&&`border-foreground`),style:{background:e},onClick:()=>s(e)},e)),(0,b.jsx)(`button`,{type:`button`,className:`size-6 cursor-pointer overflow-hidden rounded-full border border-border bg-[conic-gradient(red,yellow,lime,aqua,blue,magenta,red)]`,"aria-label":e(`display.customAccent`),title:e(`display.customAccent`),onClick:()=>cT(c)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,"aria-pressed":r===null,onClick:()=>s(null),children:e(`display.defaultAccent`)})]}),a?.manage&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:o.isPending||!r||r===a.accent,onClick:()=>o.mutate(r),children:e(`display.accentForEveryone`)}),a.accent&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:o.isPending,onClick:()=>o.mutate(null),children:e(`display.resetForEveryone`)})]}),o.isError&&(0,b.jsx)(`p`,{className:`text-xs text-destructive`,children:dg(o.error)})]})}var sT=null;function cT(e){sT&&(e&&/^#[0-9a-f]{6}$/i.test(e)&&(sT.value=e),sT.click())}function lT(){return(0,b.jsx)(`input`,{ref:e=>{sT=e},type:`color`,tabIndex:-1,"aria-hidden":!0,className:`pointer-events-none fixed bottom-0 start-0 size-px opacity-0`,onInput:e=>{Ww(e.currentTarget.value),qw()}})}var uT=`nma.nav`,dT={pinned:[],recent:[],collapsedGroups:[],expandedGroups:[],railCollapsed:!1};function fT(e){let t=dT;try{let n=e?.getItem(uT);n&&(t={...dT,...JSON.parse(n)})}catch{t=dT}let n=new Set,r=r=>{t=r;try{e?.setItem(uT,JSON.stringify(r))}catch{}for(let e of n)e()},i=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t];return{get:()=>t,subscribe(e){return n.add(e),()=>n.delete(e)},togglePin:e=>r({...t,pinned:i(t.pinned,e)}),visit:e=>{t.recent[0]!==e&&r({...t,recent:[e,...t.recent.filter(t=>t!==e)].slice(0,5)})},toggleGroup:(e,n=!1)=>{let i=_T(t,e,n),a=t=>t.filter(t=>t!==e);r({...t,collapsedGroups:i?a(t.collapsedGroups):[...a(t.collapsedGroups),e],expandedGroups:i?[...a(t.expandedGroups),e]:a(t.expandedGroups)})},toggleRail:()=>r({...t,railCollapsed:!t.railCollapsed})}}function pT(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var mT=fT(pT());function hT(){return(0,y.useSyncExternalStore)(mT.subscribe,mT.get)}function gT(e,t){return e.filter(e=>t.has(e))}function _T(e,t,n){return e.collapsedGroups.includes(t)?!0:!e.expandedGroups.includes(t)&&n}function vT(e){let{t}=Y(),[n,r,i]=qi().pathname.split(`/`).filter(Boolean).map(e=>decodeURIComponent(e)),a=n&&n!==`g`&&n!==`p`&&n!==`-`&&r&&r!==`new`?r:void 0,o=Jg(n??``,a),s=!!n&&![`g`,`p`,`-`,`account`].includes(n),c=Wg(n??``,s&&e!==void 0&&!yw(e).some(e=>e.resources.some(e=>e.name===n))),l=[{label:t(e?.dashboard?`shell.dashboard`:`shell.home`),to:`/`}];if(n===`account`&&!r)return[...l,{label:t(`auth.account`)}];if(n===`-`&&(r===`users`||r===`groups`||r===`roles`||r===`debugger`||r===`audit`)){let e={users:t(`rbac.users`),groups:t(`rbac.groups`),roles:t(`rbac.roles`),debugger:t(`debugger.title`),audit:t(`audit.title`)}[r];return l.push({label:t(`rbac.administration`)},{label:e,to:`/-/${r}`}),i&&l.push({label:i===`new`?t(`list.new`):i}),l}if(!n||!e)return l;let u=yw(e);if(n===`g`){let e=u.find(e=>e.key===r);return e&&l.push({label:e.label}),l}if(n===`p`){let e=u.find(e=>e.pages.some(e=>e.name===r)),t=e?.pages.find(e=>e.name===r);return e&&t&&l.push({label:e.label,to:`/g/${e.key}`},{label:t.label}),l}let d=u.find(e=>e.resources.some(e=>e.name===n)),f=d?.resources.find(e=>e.name===n);return!d||!f?c.data?(l.push({label:c.data.label,to:`/${n}`}),a&&l.push({label:typeof o.data?._title==`string`?o.data._title:`#${a}`}),l):l:(l.push({label:d.label,to:`/g/${d.key}`},{label:f.label,to:`/${f.name}`}),r===`new`?l.push({label:t(`form.new`,{name:f.label})}):a&&l.push({label:typeof o.data?._title==`string`?o.data._title:`#${a}`}),l)}function yT({meta:e,onOpenMenu:t}){let{t:n}=Y(),r=hT(),i=vT(e),a=i.length-1;return(0,b.jsxs)(`header`,{className:`flex h-14 items-center gap-2 border-b border-border bg-card px-5`,children:[(0,b.jsx)(q,{variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":n(`shell.menu`),onClick:t,"data-sidebar-toggle":``,children:(0,b.jsx)(Ky,{})}),(0,b.jsx)(q,{variant:`ghost`,size:`icon`,className:`hidden md:inline-flex`,"aria-label":n(r.railCollapsed?`shell.expandSidebar`:`shell.collapseSidebar`),"aria-pressed":r.railCollapsed,onClick:()=>mT.toggleRail(),"data-sidebar-toggle":``,children:(0,b.jsx)(nb,{className:`ltr:-scale-x-100`})}),(0,b.jsx)(`div`,{className:`hidden h-5 w-px bg-border md:block`,"aria-hidden":!0}),(0,b.jsx)(`nav`,{"aria-label":n(`shell.breadcrumbs`),className:`min-w-0 flex-1 ps-1`,children:(0,b.jsx)(`ol`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted-foreground`,children:i.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(Sv,{className:`size-3.5 shrink-0 ltr:rotate-180`,"aria-hidden":!0}),(0,b.jsx)(`li`,{className:t===a?`truncate font-medium text-foreground`:`hidden truncate sm:block`,children:e.to&&t!==a?(0,b.jsx)(bo,{to:e.to,className:`hover:text-foreground`,children:e.label}):(0,b.jsx)(`span`,{"aria-current":t===a?`page`:void 0,children:e.label})})]},`${t}:${e.label}`))})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(Qw,{}),(0,b.jsx)(iT,{})]})]})}function bT({rail:e=!1}){let{t}=Y(),n=Hg(),r=Yi(),i=S(),a=n.data;if(!a)return null;let{user:o,auth:s}=a,c=o.displayName.split(/\s+/).filter(Boolean).slice(0,2).map(e=>[...e][0].toUpperCase()).join(``);async function l(){try{await Q.logout()}finally{mg(void 0),Sg(void 0),i.clear(),r(`/login`,{replace:!0})}}return(0,b.jsxs)(Sh,{children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,"aria-label":t(`auth.userMenu`,{name:o.displayName}),"data-user-block":``,className:W(`flex cursor-pointer items-center gap-2.5 rounded-control text-start hover:bg-muted`,e?`size-10 justify-center`:`px-2.5 py-2`),children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-[13px] font-semibold`,children:c||(0,b.jsx)(cx,{className:`size-4`})}),!e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`min-w-0 flex-1 leading-[1.35]`,children:[(0,b.jsx)(`span`,{className:`block truncate text-[13px] font-medium`,children:o.displayName}),(o.username||o.email)&&(0,b.jsx)(`span`,{className:`block truncate text-[11.5px] text-muted-foreground`,children:o.email??o.username})]}),(0,b.jsx)(Wv,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{side:`top`,align:`start`,sideOffset:6,className:`z-50 flex w-64 flex-col gap-1 rounded-[10px] border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:[(s.password||s.sessions||s.twoFactor)&&!a.viewAs&&(0,b.jsx)(Eh,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/account`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-[13px] hover:bg-muted`,children:[(0,b.jsx)(cx,{className:`size-4`}),t(`auth.account`)]})}),a.audit.view&&(0,b.jsx)(Eh,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/-/audit`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-[13px] hover:bg-muted`,children:[(0,b.jsx)(bb,{className:`size-4`}),t(`audit.title`)]})}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 border-y border-border px-2 py-2`,children:[(0,b.jsx)(nT,{}),(0,b.jsx)(rT,{}),(0,b.jsx)(tT,{}),(0,b.jsx)(oT,{})]}),s.logout&&!a.open&&(0,b.jsxs)(`button`,{type:`button`,className:`flex h-[34px] items-center gap-2.5 rounded-md px-2 text-start text-[13px] hover:bg-muted`,onClick:()=>void l(),children:[(0,b.jsx)(Ry,{className:`size-4 rtl:-scale-x-100`}),t(`auth.signOut`)]})]})})]})}var xT=`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-control px-2.5 text-start text-[13.5px] text-sidebar-foreground hover:bg-muted`,ST=({isActive:e})=>W(`flex h-8 items-center rounded-[7px] px-2.5 text-[13px] text-muted-foreground hover:bg-muted hover:text-foreground`,e&&`bg-primary-soft font-semibold text-primary-text hover:bg-primary-soft hover:text-primary-text`);function CT(e){return e.kind===`resource`?{key:e.name,to:`/${e.name}`,label:e.label,pin:e.name,...e.badge?{badge:e.badge}:{}}:e.kind===`page`?{key:`page:${e.name}`,to:`/p/${e.name}`,label:e.label}:{key:`link:${e.href}`,to:e.href,label:e.label,external:/^https?:\/\//i.test(e.href)}}var wT=(e,t)=>!t.external&&(e===t.to||e.startsWith(`${t.to}/`));function TT(e,t,n,r,i){let a=e.map(e=>{let r=e.items.map(CT);return{key:e.key,label:e.label,icon:Yw(e.icon,`group`),entries:r,collapsedByDefault:xw({menu:t,current:r.some(e=>wT(n,e))}),asLink:t&&!e.advanced&&r.length===1}});return r.length>0?[{key:`~pinned`,label:i,icon:ub,entries:r},...a]:a}function ET({title:e,logo:t,groups:n,menu:r,rail:i=!1,onClose:a}){let{t:o}=Y(),s=hT(),{pathname:c}=qi(),l=Gg(r).data,u=new Map(n.flatMap(e=>e.items.flatMap(e=>e.kind===`resource`?[[e.name,CT(e)]]:[]))),d=TT(n,r,c,gT(s.pinned,new Set(u.keys())).map(e=>u.get(e)),o(`shell.pinned`)),f=d.find(e=>n.some(t=>t.advanced&&t.key===e.key)),p=d.filter(e=>e!==f),m=NT(),h=(e,t=!1)=>i?(0,b.jsx)(jT,{section:e,muted:t},e.key):(0,b.jsx)(AT,{section:e,collapsed:_T(s,e.key,e.collapsedByDefault??!1),badges:l,muted:t,large:!!a},e.key);return(0,b.jsxs)(`nav`,{"aria-label":o(`shell.resources`),className:`flex h-full flex-col`,children:[(0,b.jsx)(kT,{title:e,logo:t,rail:i,onClose:a}),(0,b.jsxs)(`div`,{className:W(`flex flex-1 flex-col gap-0.5 overflow-y-auto`,i?`items-center px-0 py-2.5`:`p-2.5`),children:[r&&(0,b.jsx)(DT,{to:`/`,label:o(`shell.dashboard`),icon:Ey,rail:i,large:!!a,end:!0}),p.map(e=>h(e))]}),(0,b.jsxs)(`div`,{className:W(`flex flex-col gap-1 border-t border-sidebar-border`,i?`items-center px-0 py-2.5`:`p-2.5`),children:[f&&h(f,!0),m&&h(m,!0),(0,b.jsx)(bT,{rail:i})]})]})}function DT({to:e,label:t,icon:n,rail:r,large:i,end:a,external:o,count:s}){let c=({isActive:e})=>r?W(`flex size-10 items-center justify-center rounded-control hover:bg-muted`,e&&`bg-primary-soft text-primary-text hover:bg-primary-soft`):W(xT,i&&`h-11 text-[15px]`,e&&`bg-primary-soft font-semibold text-primary-text hover:bg-primary-soft`),l=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),!r&&(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:t}),!r&&s&&(0,b.jsx)(OT,{count:s})]});return o?(0,b.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,"aria-label":r?t:void 0,title:r?t:void 0,className:c({isActive:!1}),children:l}):(0,b.jsx)(xo,{to:e,end:a,"aria-label":r?t:void 0,title:r?t:void 0,className:c,children:l})}function OT({count:e,strong:t}){return(0,b.jsxs)(`span`,{className:W(`inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full px-1.5 text-[11px]`,t?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`),children:[e.estimate?`~`:``,Qh(e.count)]})}function kT({title:e,logo:t,rail:n,onClose:r}){let{t:i}=Y(),a=t?(0,b.jsx)(`img`,{src:t,alt:``,className:`size-[30px] shrink-0 rounded-control object-contain`}):(0,b.jsx)(`span`,{"aria-hidden":!0,className:`flex size-[30px] shrink-0 items-center justify-center rounded-control bg-primary font-bold text-primary-foreground`,children:[...e.trim()][0]??``});return(0,b.jsxs)(`div`,{className:W(`flex h-14 shrink-0 items-center gap-2.5 border-b border-sidebar-border`,n?`justify-center`:`px-4`),children:[a,!n&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`min-w-0 flex-1 leading-[1.3]`,children:[(0,b.jsx)(`div`,{className:W(`truncate font-semibold`,r?`text-[15px]`:`text-sm`),children:e}),!r&&(0,b.jsx)(`div`,{className:`text-[11.5px] text-muted-foreground`,children:i(`shell.adminPanel`)})]}),r?(0,b.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":i(`shell.closeMenu`),onClick:r,children:(0,b.jsx)(bx,{})}):(0,b.jsx)(Ev,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})}function AT({section:e,collapsed:t,badges:n,muted:r,large:i}){let{t:a}=Y(),o=e.icon,s=`nav-group-${e.key}`,c=bw(e.entries.flatMap(e=>e.badge?[{kind:`resource`,name:e.key,label:e.label,badge:e.badge}]:[]),n);if(e.asLink){let[t]=e.entries;return(0,b.jsx)(DT,{to:t.to,label:e.label,icon:o,rail:!1,large:i,external:t.external,count:t.badge?n?.[t.badge]:void 0})}return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`button`,{type:`button`,className:W(xT,i&&`h-11 text-[15px]`,r&&`text-muted-foreground`),"aria-expanded":!t,"aria-controls":s,"aria-label":a(t?`shell.expandGroup`:`shell.collapseGroup`,{name:e.label}),onClick:()=>mT.toggleGroup(e.key,e.collapsedByDefault??!1),children:[(0,b.jsx)(o,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),t&&c&&(0,b.jsx)(OT,{count:c}),(0,b.jsx)(bv,{className:W(`size-4 shrink-0 text-muted-foreground transition-transform`,t&&`rotate-90 rtl:rotate-90 ltr:-rotate-90`),"aria-hidden":!0})]}),!t&&(0,b.jsx)(`ul`,{id:s,"aria-label":e.label,className:`ms-[18px] mt-0.5 mb-1 flex flex-col gap-px border-s border-sidebar-border ps-2.5`,children:e.entries.map(e=>(0,b.jsxs)(`li`,{className:`group/item flex items-center`,children:[e.external?(0,b.jsx)(`a`,{href:e.to,target:`_blank`,rel:`noopener noreferrer`,className:W(ST({isActive:!1}),`min-w-0 flex-1`),children:(0,b.jsx)(`span`,{className:`truncate`,children:e.label})}):(0,b.jsxs)(xo,{to:e.to,className:e=>W(ST(e),`min-w-0 flex-1 gap-2`),children:[(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.badge&&n?.[e.badge]&&(0,b.jsx)(OT,{count:n[e.badge]})]}),e.pin&&(0,b.jsx)(MT,{name:e.pin,label:e.label})]},e.key))})]})}function jT({section:e,muted:t}){let[n,r]=(0,y.useState)(!1),{pathname:i}=qi(),a=e.icon,o=e.entries.some(e=>wT(i,e));return(0,b.jsxs)(Sh,{open:n,onOpenChange:r,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,onMouseEnter:()=>r(!0),"data-nav-section":``,className:W(`flex size-10 cursor-pointer items-center justify-center rounded-control hover:bg-muted`,t&&`text-muted-foreground`,o&&`bg-primary-soft text-primary-text hover:bg-primary-soft`),children:(0,b.jsx)(a,{className:`size-4`,"aria-hidden":!0})})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{side:`right`,align:`start`,sideOffset:8,onMouseLeave:()=>r(!1),className:`z-50 flex flex-col items-start gap-1.5`,children:[(0,b.jsx)(`span`,{className:`rounded-control bg-foreground px-3 py-1.5 text-[13px] font-medium text-background`,children:e.label}),(0,b.jsx)(`div`,{className:`flex min-w-40 flex-col gap-px rounded-[10px] border border-border bg-card p-1.5 shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:e.entries.map(e=>e.external?(0,b.jsx)(`a`,{href:e.to,target:`_blank`,rel:`noopener noreferrer`,className:ST({isActive:!1}),onClick:()=>r(!1),children:e.label},e.key):(0,b.jsx)(xo,{to:e.to,className:ST,onClick:()=>r(!1),children:e.label},e.key))})]})})]})}function MT({name:e,label:t}){let{t:n}=Y(),r=hT().pinned.includes(e);return(0,b.jsx)(`button`,{type:`button`,className:W(`cursor-pointer rounded-md p-1 text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/item:opacity-100`,r&&`opacity-100`),"aria-label":n(r?`shell.unpin`:`shell.pin`,{name:t}),"aria-pressed":r,onClick:()=>mT.togglePin(e),children:r?(0,b.jsx)(cb,{className:`size-3.5`}):(0,b.jsx)(ub,{className:`size-3.5`})})}function NT(){let{t:e}=Y();if(Hg().data?.rbac.view)return{key:`~administration`,label:e(`rbac.administration`),icon:Mb,entries:[{key:`users`,to:`/-/users`,label:e(`rbac.users`)},{key:`groups`,to:`/-/groups`,label:e(`rbac.groups`)},{key:`roles`,to:`/-/roles`,label:e(`rbac.roles`)},{key:`debugger`,to:`/-/debugger`,label:e(`debugger.title`)}]}}var PT={success:5e3,error:1e4},FT=4;function IT(e=globalThis){let t=[],n=1,r=new Map,i=new Set,a=e=>{t=e;for(let e of i)e()},o=n=>{let i=r.get(n);i!==void 0&&e.clearTimeout(i),r.delete(n),t.some(e=>e.id===n)&&a(t.filter(e=>e.id!==n))};return{get:()=>t,subscribe(e){return i.add(e),()=>i.delete(e)},show(i,s=`success`){let c=n++,l=[...t,{id:c,message:i,tone:s}];for(let e of l.slice(0,Math.max(0,l.length-FT)))o(e.id);return a([...t,{id:c,message:i,tone:s}]),r.set(c,e.setTimeout(()=>o(c),PT[s])),c},dismiss:o}}var LT=IT(),RT=(e,t=`success`)=>LT.show(e,t);function zT(){return(0,y.useSyncExternalStore)(LT.subscribe,LT.get)}function BT(){let e=X(),t=zT();return(0,b.jsx)(`div`,{role:`region`,"aria-label":e(`toast.region`),className:`pointer-events-none fixed inset-x-4 bottom-4 z-[60] flex flex-col items-end gap-2 sm:start-auto sm:w-96`,children:t.map(t=>(0,b.jsxs)(`div`,{role:t.tone===`error`?`alert`:`status`,className:W(`pointer-events-auto flex w-full items-start gap-2 rounded-lg border bg-popover px-3 py-2 text-sm text-popover-foreground shadow-lg`,t.tone===`error`?`border-destructive/50`:`border-green-600/40`),children:[(0,b.jsx)(`span`,{className:W(`min-w-0 flex-1 break-words`,t.tone===`error`&&`text-destructive`),children:t.message}),(0,b.jsx)(`button`,{type:`button`,className:`rounded-md p-0.5 text-muted-foreground hover:text-foreground`,"aria-label":e(`toast.dismiss`),onClick:()=>LT.dismiss(t.id),children:(0,b.jsx)(bx,{className:`size-4`,"aria-hidden":!0})})]},t.id))})}function VT(e,t){return e===void 0||typeof e==`string`?e:e[t]??e[lg.locale]??Object.values(e)[0]}function HT(){let{t:e}=Y(),t=Hg(),n=qi(),r=S(),i=t.isError&&xg()!==void 0&&t.error instanceof ug&&(t.error.status===403||t.error.status===404);return(0,y.useEffect)(()=>{i&&(Sg(void 0),r.clear())},[i,r]),t.isPending||i?(0,b.jsx)(G,{children:e(`common.loading`)}):t.isError?t.error instanceof ug&&t.error.status===401?(0,b.jsx)(Da,{to:`/login?${new URLSearchParams({next:n.pathname+n.search})}`,replace:!0}):(0,b.jsxs)(G,{tone:`error`,children:[dg(t.error),` `,(0,b.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:e(`list.retry`)})]}):(0,b.jsx)(WT,{})}function UT(){let{t:e}=Y(),t=Hg(),n=S(),r=Yi(),i=t.data;return i?.viewAs?(0,b.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center justify-center gap-3 bg-amber-400 px-4 py-2 text-sm font-medium text-amber-950`,children:[(0,b.jsx)(Xv,{className:`size-4`,"aria-hidden":!0}),(0,b.jsx)(`span`,{children:e(`viewAs.banner`,{name:i.user.displayName})}),(0,b.jsx)(q,{size:`sm`,variant:`outline`,className:`h-7 border-amber-950/30 bg-amber-50 text-amber-950 hover:bg-amber-100`,onClick:()=>{let e=i.user.id;Sg(void 0),n.clear(),r(`/-/users/${encodeURIComponent(e)}`)},children:e(`viewAs.stop`)})]}):null}function WT(){let e=Ug(),{t,locale:n}=Y(),r=hT(),i=qi(),[a,o]=(0,y.useState)(!1),s=(0,y.useRef)(null),c=Hg().data?.appearance?.accent;(0,y.useEffect)(()=>{c!==void 0&&qw({admin:c})},[c]);let l=(0,y.useMemo)(()=>e.data?yw(e.data):[],[e.data]),u=e.data?.menu!==void 0,d=VT(lg.branding.name,n)??e.data?.title??lg.title,f=lg.branding.logo;return(0,y.useEffect)(()=>{o(!1);let e=decodeURIComponent(i.pathname.split(`/`).filter(Boolean)[0]??``);l.some(t=>t.resources.some(t=>t.name===e))&&mT.visit(e)},[i.pathname,l]),(0,y.useEffect)(()=>{e.data&&(document.title=e.data.title)},[e.data]),(0,y.useEffect)(()=>{if(!a)return;s.current?.querySelector(`a, button, input`)?.focus();let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),(0,b.jsxs)(`div`,{className:`flex min-h-svh bg-background text-foreground`,children:[(0,b.jsx)(lT,{}),(0,b.jsx)(`aside`,{className:W(`sticky top-0 hidden h-svh shrink-0 border-e border-sidebar-border bg-sidebar text-sidebar-foreground md:block`,r.railCollapsed?`w-16`:`w-64`),children:(0,b.jsx)(ET,{title:d,logo:f,groups:l,menu:u,rail:r.railCollapsed})}),a&&(0,b.jsxs)(`div`,{className:`fixed inset-0 z-40 md:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shell.menu`),ref:s,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,"aria-hidden":!0,onClick:()=>o(!1)}),(0,b.jsx)(`aside`,{className:`absolute inset-y-0 start-0 flex w-[300px] max-w-[85vw] flex-col border-e border-sidebar-border bg-sidebar text-sidebar-foreground shadow-xl`,onClick:e=>{e.target.closest(`a`)&&o(!1)},children:(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,b.jsx)(ET,{title:d,logo:f,groups:l,menu:u,onClose:()=>o(!1)})})})]}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,inert:a||void 0,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-30 bg-background`,children:[(0,b.jsx)(UT,{}),(0,b.jsx)(yT,{meta:e.data,onOpenMenu:()=>o(!0)})]}),(0,b.jsx)(`main`,{className:`flex-1 p-4 md:p-7`,children:(0,b.jsx)(`div`,{className:`mx-auto w-full max-w-[1400px]`,children:(0,b.jsx)(Oa,{})})})]}),(0,b.jsx)(BT,{})]})}function GT(e){let t=lg.branding.name;return t===void 0?lg.title:typeof t==`string`?t:t[e]??t[lg.locale]??Object.values(t)[0]??lg.title}function KT(){let{t:e,locale:t}=Y(),n=Yi(),r=S(),[i]=wo(),a=yg(i.get(`next`),lg.basePath),o=Hg(),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(`password`),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1);if(o.isSuccess)return(0,b.jsx)(Da,{to:a,replace:!0});async function x(t){if(t.preventDefault(),!s.trim()||!l){g(e(`auth.required`));return}if(d===`otp`&&!p.trim()){g(e(`auth.otpRequired`));return}v(!0),g(null);try{let e=await Q.login(s.trim(),l,d===`otp`?p.trim():void 0);mg(e.csrfToken),Sg(void 0),r.clear(),r.setQueryData([`session`],e),n(a,{replace:!0})}catch(t){if(t instanceof ug&&t.body.code===`TWO_FACTOR_REQUIRED`){g(d===`otp`?t.message:null),f(`otp`),m(``);return}f(`password`),m(``),u(``),g(t instanceof ug&&(t.status===401||t.status===429||t.status===404)?t.message:e(`auth.failed`))}finally{v(!1)}}let C=lg.branding.logo;return(0,b.jsxs)(`main`,{className:`flex min-h-dvh flex-col bg-muted/30`,children:[(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 p-4`,children:[(0,b.jsx)(nT,{}),(0,b.jsx)(tT,{})]}),(0,b.jsx)(`div`,{className:`flex flex-1 items-start justify-center px-4 pt-[10vh]`,children:(0,b.jsxs)(`form`,{onSubmit:x,noValidate:!0,className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border bg-background p-6 shadow-sm`,"aria-labelledby":`login-title`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[C&&(0,b.jsx)(`img`,{src:C,alt:``,className:`size-10 rounded-md object-contain`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:GT(t)}),(0,b.jsx)(`h1`,{id:`login-title`,className:`text-[22px] font-bold`,children:e(d===`otp`?`auth.otpTitle`:`auth.title`)})]}),h&&(0,b.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}),d===`otp`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-otp`,children:e(`auth.otp`)}),(0,b.jsx)(Oh,{id:`login-otp`,autoComplete:`one-time-code`,inputMode:`text`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,dir:`ltr`,maxLength:40,value:p,onChange:e=>m(e.target.value),"aria-describedby":`login-otp-help`}),(0,b.jsx)(`p`,{id:`login-otp-help`,className:`text-sm text-muted-foreground`,children:e(`auth.otpHelp`)})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-username`,children:e(`auth.username`)}),(0,b.jsx)(Oh,{id:`login-username`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(kh,{htmlFor:`login-password`,children:e(`auth.password`)}),(0,b.jsx)(Oh,{id:`login-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>u(e.target.value)})]})]}),(0,b.jsx)(q,{type:`submit`,disabled:_,children:e(_?`auth.signingIn`:d===`otp`?`auth.verify`:`auth.signIn`)}),d===`otp`&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,onClick:()=>{f(`password`),m(``),u(``),g(null)},children:e(`auth.startOver`)})]})})]})}var qT=3;function JT({field:e,files:t,detailed:n=!1,plain:r=!1}){let i=X();if(t.length===0)return(0,b.jsx)(b.Fragment,{children:`—`});let a=t=>e.widget===`image`&&t.contentType.startsWith(`image/`),o=n?t:t.slice(0,qT);return(0,b.jsxs)(`span`,{className:W(`inline-flex flex-wrap items-center`,n?`gap-2`:`gap-1 align-middle`),children:[o.map(e=>{let t=a(e)?(0,b.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,className:W(`rounded-md border bg-muted object-cover`,n?`size-24`:`size-8`)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ny,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`bdi`,{className:`max-w-48 truncate`,children:e.name}),n&&(0,b.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:Mg(e.size)})]});return r?(0,b.jsx)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:t},e.key):(0,b.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":i(`upload.open`,{name:e.name}),title:e.name,className:`inline-flex min-w-0 items-center gap-1 hover:underline`,onClick:e=>e.stopPropagation(),children:t},e.key)}),t.length>o.length&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`upload.more`,{count:t.length-o.length})})]})}var YT={ok:`bg-ok-bg text-ok`,warn:`bg-warn-bg text-warn`,bad:`bg-bad-bg text-bad`,info:`bg-info-bg text-info`,neutral:`bg-muted text-muted-foreground`,primary:`bg-primary-soft text-primary-text`};function XT({tone:e=`neutral`,className:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`badge`,"data-tone":e,className:W(`inline-flex h-[22px] items-center gap-1 rounded-full px-2 text-xs leading-none font-medium whitespace-nowrap`,YT[e],t),...n})}var ZT={gray:`neutral`,red:`bad`,amber:`warn`,green:`ok`,blue:`info`,purple:`primary`,pink:`bad`};function QT(e){return ZT[e]??`neutral`}function $T({value:e,field:t,className:n}){if(e==null)return(0,b.jsx)(b.Fragment,{children:jx(e,t)});let r=t.colors?.[String(e)]??`gray`;return(0,b.jsx)(XT,{"data-color":r,tone:QT(r),className:n,children:jx(e,t)})}function eE({value:e,field:t,record:n,detailed:r,plain:i}){return t.file&&n?(0,b.jsx)(JT,{field:t,files:pC(n,t.name),detailed:r,plain:i}):t.widget===`badge`?(0,b.jsx)($T,{value:e,field:t}):(0,b.jsx)(b.Fragment,{children:jx(e,t)})}function tE({title:e,subtitle:t,icon:n,actions:r,footer:i,className:a,bodyClassName:o,children:s,...c}){let l=(0,y.useId)(),u=e!==void 0&&c[`aria-labelledby`]===void 0?{"aria-labelledby":l}:{};return(0,b.jsxs)(`section`,{"data-slot":`card`,className:W(`rounded-card border border-border bg-card text-card-foreground shadow-card`,a),...u,...c,children:[e!==void 0&&(0,b.jsxs)(`header`,{className:`flex min-h-14 items-center gap-2 border-b border-border px-5 py-3`,children:[n&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&_svg]:size-4`,children:n}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`h2`,{id:l,className:`text-[15px] font-semibold`,children:e}),t&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]}),r&&(0,b.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]}),(0,b.jsx)(`div`,{className:W(e!==void 0&&`p-5`,o),children:s}),i&&(0,b.jsx)(`footer`,{className:`border-t border-border px-5 py-3`,children:i})]})}function nE({card:e,values:t,schema:n}){let r=X(),i=Wg(e.relation?.resource??``,e.relation!==void 0);if(!t)return null;let a=e.relation?i.data?.fields:n.fields;if(!a)return null;let o=Xw(e.icon),s=e.fields.flatMap(e=>{let t=a.find(t=>t.name===e);return t?[t]:[]}),c=e.relation?.link&&typeof t._id==`string`?`/${e.relation.resource}/${encodeURIComponent(t._id)}`:void 0;return(0,b.jsx)(tE,{title:e.title,icon:o?(0,b.jsx)(o,{}):void 0,actions:c&&(0,b.jsx)(bo,{to:c,className:`text-[13px] font-medium text-primary hover:underline`,children:r(`form.viewProfile`)}),children:(0,b.jsxs)(`dl`,{className:`flex flex-col gap-2.5 text-[13px]`,children:[e.relation&&typeof t._title==`string`&&(0,b.jsx)(`dt`,{className:`text-[14px] font-semibold`,children:t._title}),s.map(e=>(0,b.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`min-w-0 text-end break-words`,children:(0,b.jsx)(eE,{value:t[e.name],field:e,record:t})})]},e.name))]})})}function rE(e,t,n){let r=e.steps?.values??e.enumValues??[],i=typeof t==`string`?r.indexOf(t):-1;return r.map((t,r)=>{let a=n?.[t],o=a?tg(new Date(a)):null,s=i===-1?`future`:r<i?`done`:r===i?`current`:`future`;return{key:t,label:e.enumLabels?.[t]??t,state:s,at:s===`future`?null:o,caption:s===`current`&&o?J(`stepper.since`,{time:o}):null}})}function iE({field:e,value:t,reached:n}){let r=rE(e,t,n);return(0,b.jsx)(tE,{"aria-label":e.label,bodyClassName:`overflow-x-auto px-5 py-4`,children:(0,b.jsx)(`ol`,{className:`flex min-w-max`,children:r.map((e,t)=>(0,b.jsxs)(`li`,{"aria-current":e.state===`current`?`step`:void 0,className:`relative flex min-w-28 flex-1 flex-col items-center gap-1.5 text-center`,children:[t<r.length-1&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:W(`absolute start-1/2 top-3.5 h-0.5 w-full`,e.state===`done`?`bg-primary`:`bg-border`)}),(0,b.jsx)(`span`,{className:W(`relative z-10 flex size-7 items-center justify-center rounded-full border-2 bg-card text-xs font-semibold`,e.state===`done`&&`border-primary bg-primary text-primary-foreground`,e.state===`current`&&`border-primary text-primary`,e.state===`future`&&`border-border text-muted-foreground`),children:e.state===`done`?(0,b.jsx)(vv,{className:`size-3.5`,"aria-hidden":!0}):Qh(t+1)}),(0,b.jsx)(`span`,{className:W(`text-[13px]`,e.state===`current`?`font-semibold text-primary`:e.state===`done`?`font-semibold`:`text-muted-foreground`),children:e.label}),(0,b.jsx)(`span`,{className:`text-[11.5px] text-muted-foreground`,children:e.caption??e.at??`—`})]},e.key))})})}var aE=class{options;pending=[];problems=[];uploads=new Map;nextId=0;disposed=!1;constructor(e){this.options=e}get busy(){return this.pending.length>0}start(e,t){if(!(this.disposed||e.length===0)){this.problems=[];for(let n of e){let e=this.options.check(n);if(e){this.problems=[...this.problems,this.options.describe(n.name,e)];continue}let r=++this.nextId,i=this.options.preview?.(n),a=this.options.send(n,e=>{this.disposed||(this.pending=this.pending.map(t=>t.id===r?{...t,progress:e}:t),this.options.onChange())});this.uploads.set(r,a),this.pending=[...this.pending,{id:r,name:n.name,progress:0,preview:i}],a.promise.then(e=>{this.disposed||(this.finish(r),t(e,n,i))},e=>{this.disposed||(i&&this.options.revoke?.(i),e instanceof Cg||(this.problems=[...this.problems,this.options.describe(n.name,Og(e))]),this.finish(r))})}this.options.onChange()}}report(e,t){this.problems=[...this.problems,this.options.describe(e,t)],this.options.onChange()}cancel(e){this.uploads.get(e)?.abort()}cancelAll(){for(let e of[...this.uploads.values()])e.abort()}dispose(){this.disposed=!0;for(let e of this.pending)e.preview&&this.options.revoke?.(e.preview);this.cancelAll(),this.uploads.clear(),this.pending=[]}finish(e){this.uploads.delete(e),this.pending=this.pending.filter(t=>t.id!==e),this.options.onChange()}};function oE({resource:e,field:t,rules:n,onBusy:r}){let i=X(),[,a]=(0,y.useReducer)(e=>e+1,0),o=(0,y.useRef)({resource:e,field:t,rules:n,t:i});o.current={resource:e,field:t,rules:n,t:i};let s=(0,y.useRef)(null),c=()=>new aE({send:(e,t)=>Q.upload(e,{resource:o.current.resource,field:o.current.field.name},t),check:e=>Ag(e,o.current.rules),describe:(e,t)=>o.current.t(`upload.failed`,{name:e,message:t}),preview:e=>e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,revoke:e=>URL.revokeObjectURL(e),onChange:a});s.current??=c();let l=s.current.busy;return(0,y.useEffect)(()=>{r?.(l)},[l]),(0,y.useEffect)(()=>(s.current||(s.current=c(),a()),()=>{s.current?.dispose(),s.current=null,r?.(!1)}),[]),s.current}function sE({resource:e,field:t,value:n,onChange:r,onBusy:i}){let a=t.file?.many===!0,o=fC(n),s=(0,y.useRef)(o);s.current=o;let c=oE({resource:e,field:t,rules:t.file??{accept:[],maxBytes:1/0},onBusy:i}),l=(0,y.useRef)(new Map);(0,y.useEffect)(()=>()=>{for(let e of l.current.values())URL.revokeObjectURL(e);l.current.clear()},[]);function u(e){let t=new Set(e.map(e=>e.token));for(let[e,n]of l.current)t.has(e)||(URL.revokeObjectURL(n),l.current.delete(e));s.current=e,r(a?e:e[0]??null)}function d(e){let t=a?e:e.slice(0,1);t.length!==0&&(a||c.cancelAll(),c.start(t,(e,t,n)=>{n&&l.current.set(e.token,n);let r={token:e.token,name:e.name,size:e.size,contentType:e.contentType,...e.url?{url:e.url}:{}};u(a?[...s.current,r]:[r])}))}return{many:a,files:o,pending:c.pending,problems:c.problems,add:d,remove:e=>u(o.filter((t,n)=>n!==e)),move:(e,t)=>u(Ng(o,e,t)),cancel:e=>c.cancel(e),previewOf:e=>e.url??(e.token?l.current.get(e.token):void 0)}}function cE(e){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(null),a=()=>{n(null),i(null)};return{dragging:t,over:r,item:r=>({draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(r)),n(r)},onDragOver:e=>{t!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,i(r))},onDrop:n=>{t!==null&&(n.preventDefault(),e(t,r),a())},onDragEnd:a})}}function lE({id:e,field:t,label:n,compact:r,onFiles:i,aria:a}){let o=X(),s=(0,y.useRef)(null),[c,l]=(0,y.useState)(!1),u=t.file?.many===!0,d=t.file?.accept??[],f=d.length===0||d.some(e=>e===`*`||e===`*/*`),p=e=>e.dataTransfer.types.includes(`Files`);return(0,b.jsxs)(`div`,{"data-dropzone":t.name,onDragOver:e=>{p(e)&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:e=>{p(e)&&(e.preventDefault(),l(!1),i([...e.dataTransfer.files]))},className:W(`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg text-sm has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/50`,!r&&`border border-dashed border-input px-3 py-3`,c&&`border-primary bg-muted/50`),children:[(0,b.jsx)(`input`,{ref:s,id:e,type:`file`,className:`sr-only`,multiple:u,accept:f?void 0:d.join(`,`),onChange:e=>{i([...e.target.files??[]]),e.target.value=``},...a}),(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,tabIndex:-1,"aria-hidden":!0,onClick:()=>s.current?.click(),children:[(0,b.jsx)(ox,{}),n]}),!r&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[o(u?`upload.dropMany`:`upload.drop`),t.file&&` · ${o(`upload.limit`,{max:Mg(t.file.maxBytes)})}`]})]})}function uE({upload:e,onCancel:t,className:n}){let r=X(),i=Math.round(e.progress*100);return(0,b.jsxs)(`div`,{className:W(`flex items-center gap-2`,n),children:[(0,b.jsx)(`div`,{role:`progressbar`,"aria-label":r(`upload.uploading`,{name:e.name}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${i}%`}})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":r(`upload.cancel`,{name:e.name}),onClick:t,children:(0,b.jsx)(bx,{})})]})}function dE({problems:e}){return e.length===0?null:(0,b.jsx)(`ul`,{role:`alert`,className:`flex flex-col gap-0.5 text-sm text-destructive`,children:e.map((e,t)=>(0,b.jsx)(`li`,{children:e},t))})}function fE(e){let t=X(),{id:n,field:r,aria:i}=e,{many:a,files:o,pending:s,problems:c,add:l,remove:u,move:d,cancel:f}=sE(e),p=cE(d);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(o.length>0||s.length>0)&&(0,b.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[o.map((e,n)=>(0,b.jsxs)(`li`,{"data-file":e.name,...a&&o.length>1?p.item(n):{},className:W(`flex items-center gap-2 rounded-lg border px-2 py-1.5 text-sm`,p.dragging===n&&`opacity-50`,p.over===n&&p.dragging!==n&&`border-primary`),children:[a&&o.length>1?(0,b.jsx)(cy,{className:`size-4 shrink-0 cursor-grab text-muted-foreground`,"aria-hidden":!0}):(0,b.jsx)(ny,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),e.url?(0,b.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 truncate hover:underline`,"aria-label":t(`upload.open`,{name:e.name}),children:(0,b.jsx)(`bdi`,{children:e.name})}):(0,b.jsx)(`bdi`,{className:`min-w-0 truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:Mg(e.size)}),a&&o.length>1&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,disabled:n===0,"aria-label":t(`list.moveUp`,{name:e.name}),onClick:()=>d(n,n-1),children:(0,b.jsx)(J_,{})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,disabled:n===o.length-1,"aria-label":t(`list.moveDown`,{name:e.name}),onClick:()=>d(n,n+1),children:(0,b.jsx)(W_,{})})]}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":t(`upload.remove`,{name:e.name}),onClick:()=>u(n),children:(0,b.jsx)(bx,{})})]},e.token??e.key)),s.map(e=>(0,b.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-dashed px-2 py-1.5 text-sm`,children:[(0,b.jsx)(`bdi`,{className:`truncate text-muted-foreground`,children:e.name}),(0,b.jsx)(uE,{upload:e,onCancel:()=>f(e.id)})]},`pending-${e.id}`))]}),(0,b.jsx)(lE,{id:n,field:r,label:t(a?`upload.chooseMany`:o.length>0?`upload.replace`:`upload.choose`),compact:!a&&o.length>0,onFiles:l,aria:i}),(0,b.jsx)(dE,{problems:c})]})}function pE(e){let t=X(),{id:n,field:r,aria:i}=e,{many:a,files:o,pending:s,problems:c,add:l,remove:u,move:d,cancel:f,previewOf:p}=sE(e),m=cE(d),h=a&&o.length>1;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(o.length>0||s.length>0)&&(0,b.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,children:[o.map((e,n)=>{let r=p(e);return(0,b.jsxs)(`li`,{"data-file":e.name,...h?m.item(n):{},className:W(`group relative size-28 overflow-hidden rounded-lg border bg-muted`,h&&`cursor-grab`,m.dragging===n&&`opacity-50`,m.over===n&&m.dragging!==n&&`border-primary ring-2 ring-primary/40`),children:[r?(0,b.jsx)(`img`,{src:r,alt:e.name,draggable:!1,className:`size-full object-cover`}):(0,b.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1 p-1 text-center text-xs text-muted-foreground`,children:[(0,b.jsx)(my,{className:`size-5`,"aria-hidden":!0}),(0,b.jsx)(`bdi`,{className:`w-full truncate`,children:e.name})]}),(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`absolute end-1 top-1 shadow`,"aria-label":t(`upload.remove`,{name:e.name}),onClick:()=>u(n),children:(0,b.jsx)(bx,{})}),h&&(0,b.jsxs)(`div`,{className:`absolute inset-x-1 bottom-1 flex justify-between`,children:[(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`shadow`,disabled:n===0,"aria-label":t(`list.moveUp`,{name:e.name}),onClick:()=>d(n,n-1),children:(0,b.jsx)(Sv,{className:`rtl:rotate-180`})}),(0,b.jsx)(q,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`shadow`,disabled:n===o.length-1,"aria-label":t(`list.moveDown`,{name:e.name}),onClick:()=>d(n,n+1),children:(0,b.jsx)(wv,{className:`rtl:rotate-180`})})]})]},e.token??e.key)}),s.map(e=>(0,b.jsxs)(`li`,{className:`relative size-28 overflow-hidden rounded-lg border border-dashed bg-muted`,children:[e.preview&&(0,b.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover opacity-40`}),(0,b.jsx)(uE,{upload:e,onCancel:()=>f(e.id),className:`absolute inset-x-1 bottom-1 rounded-md bg-background/80 ps-1.5`})]},`pending-${e.id}`))]}),(0,b.jsx)(lE,{id:n,field:r,label:t(a?`upload.chooseImages`:o.length>0?`upload.replace`:`upload.chooseImage`),compact:!a&&o.length>0,onFiles:l,aria:i}),(0,b.jsx)(dE,{problems:c})]})}function mE({className:e,...t}){return(0,b.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function hE({id:e,field:t,value:n,onChange:r,aria:i}){let{unit:a,position:o}=kx(`0`,{currency:t.currency}),s=a&&(0,b.jsx)(`span`,{className:`shrink-0 text-[13px] text-muted-foreground`,children:a});return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o===`before`&&s,(0,b.jsx)(Oh,{id:e,type:`text`,inputMode:`decimal`,dir:`ltr`,className:`text-end`,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),onBlur:()=>r(Tx(n,t.scale)),...i}),o!==`before`&&s]})}function gE({id:e,checked:t,onChange:n,aria:r}){return(0,b.jsx)(`button`,{id:e,type:`button`,role:`switch`,"aria-checked":t,onClick:()=>n(!t),className:W(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,t?`bg-primary`:`bg-input`),...r,children:(0,b.jsx)(`span`,{className:W(`block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-4 rtl:-translate-x-4`:`translate-x-0`)})})}function _E({id:e,field:t,value:n,onChange:r,aria:i,label:a,required:o}){let s=X(),c=(t.enumValues??[]).map(e=>[e,kC(t,e)]);return t.nullable&&!o&&c.unshift([``,s(`common.empty`)]),(0,b.jsxs)(`fieldset`,{id:e,className:`flex flex-col gap-1.5`,...i,children:[(0,b.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:a}),(0,b.jsx)(`div`,{role:`radiogroup`,className:`flex flex-wrap gap-x-4 gap-y-1.5`,children:c.map(([t,i])=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`radio`,name:e,value:t,checked:n===t,onChange:()=>r(t),className:`size-4 accent-primary`}),i]},t))})]})}var vE=/^#[0-9a-f]{6}$/i;function yE({id:e,field:t,value:n,onChange:r,aria:i}){let a=X();return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`input`,{type:`color`,"aria-hidden":!0,tabIndex:-1,className:`h-8 w-10 shrink-0 cursor-pointer rounded-md border border-input bg-transparent p-0.5`,value:vE.test(n)?n.toLowerCase():`#000000`,onChange:e=>r(e.target.value)}),(0,b.jsx)(Oh,{id:e,dir:`ltr`,value:n,placeholder:t.placeholder??`#000000`,"aria-label":a(`form.colorCode`,{name:t.label}),onChange:e=>r(e.target.value),...i})]})}function bE({id:e,field:t,value:n,onChange:r,aria:i}){let a=X(),[o,s]=(0,y.useState)(null),c=`${e}-json`;function l(){if(n.trim()!==``)try{r(JSON.stringify(JSON.parse(n),null,2)),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}}let u=[i[`aria-describedby`],o?c:void 0].filter(Boolean).join(` `)||void 0;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(mE,{id:e,dir:`ltr`,rows:6,className:`font-mono`,spellCheck:!1,value:n,placeholder:t.placeholder,onChange:e=>{s(null),r(e.target.value)},...i,"aria-invalid":i[`aria-invalid`]??(o?!0:void 0),"aria-describedby":u}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:l,children:a(`form.formatJson`)}),o&&(0,b.jsx)(`p`,{id:c,className:`text-sm text-destructive`,children:o})]})]})}function xE({id:e,field:t,value:n,onChange:r,aria:i}){return(0,b.jsx)(mE,{id:e,rows:4,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),...i})}function SE({id:e,field:t,value:n,onChange:r,aria:i,...a}){return(0,b.jsx)(Oh,{id:e,value:n,placeholder:t.placeholder,onChange:e=>r(e.target.value),...a,...i})}var CE=(0,y.lazy)(()=>Xa(()=>import(`./rich-text-input-D_ViXscs.js`),__vite__mapDeps([0,1]),import.meta.url));function wE(e){let t=X();return(0,b.jsx)(y.Suspense,{fallback:(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`editor.loading`)}),children:(0,b.jsx)(CE,{...e})})}var TE=`h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive`;function EE({resource:e,field:t,value:n,required:r,errors:i,constraints:a,formValues:o,onChange:s,onBusy:c,idPrefix:l=`field`,parent:u,hideLabel:d}){let f=`${l}-${t.name}`,p=`${f}-error`,m=`${f}-help`,h=(i?.length??0)>0,g=[t.help?m:void 0,h?p:void 0].filter(Boolean).join(` `)||void 0,_={"aria-invalid":h?!0:void 0,"aria-describedby":g},v=typeof n==`string`?n:``,y=t.type===`relation`?void 0:OC(t,a),x=(0,b.jsxs)(b.Fragment,{children:[t.label,r&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-destructive`,children:`*`})]}),S=(0,b.jsx)(kh,{htmlFor:f,className:d?`sr-only`:void 0,children:x}),C=t.help?(0,b.jsx)(`p`,{id:m,className:`text-sm text-muted-foreground`,children:t.help}):null,w={id:f,field:t,value:v,onChange:e=>s(e),aria:_};if(t.type===`boolean`){let e=n===!0;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y===`switch`?(0,b.jsx)(gE,{id:f,checked:e,onChange:s,aria:_}):(0,b.jsx)(`input`,{id:f,type:`checkbox`,className:`size-4 accent-primary`,checked:e,onChange:e=>s(e.target.checked),..._}),S]}),C,(0,b.jsx)(OE,{id:p,errors:i})]})}if(t.type===`enum`&&y===`radio`)return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,b.jsx)(_E,{...w,label:x,required:r}),C,(0,b.jsx)(OE,{id:p,errors:i})]});let T;if(t.type===`relation`)T=(0,b.jsx)(HS,{id:f,resource:e,field:t,value:n??null,onChange:s,clearable:t.nullable,values:o,parent:u,invalid:h,describedBy:g});else if(t.type===`enum`)T=(0,b.jsxs)(`select`,{id:f,className:TE,value:v,onChange:e=>s(e.target.value),..._,children:[(0,b.jsx)(`option`,{value:``,children:t.placeholder??`—`}),t.enumValues?.map(e=>(0,b.jsx)(`option`,{value:e,children:kC(t,e)},e))]});else switch(y){case`file`:T=(0,b.jsx)(fE,{id:f,resource:e,field:t,value:n,onChange:s,onBusy:c,aria:_});break;case`image`:T=(0,b.jsx)(pE,{id:f,resource:e,field:t,value:n,onChange:s,onBusy:c,aria:_});break;case`richtext`:T=(0,b.jsx)(wE,{id:f,resource:e,field:t,value:v,onChange:s,onBusy:c,invalid:h,describedBy:g});break;case`money`:T=(0,b.jsx)(hE,{...w});break;case`date`:T=(0,b.jsx)(IS,{id:f,live:!0,value:v,label:t.label,onChange:e=>s(e),..._});break;case`datetime`:T=(0,b.jsx)(zS,{id:f,value:v,label:t.label,onChange:e=>s(e),..._});break;case`json`:T=(0,b.jsx)(bE,{...w});break;case`textarea`:T=(0,b.jsx)(xE,{...w});break;case`color`:T=(0,b.jsx)(yE,{...w});break;case`password`:T=(0,b.jsx)(SE,{...w,type:`password`,autoComplete:`new-password`});break;case`slug`:T=(0,b.jsx)(SE,{...w,dir:`ltr`,autoCapitalize:`none`,spellCheck:!1});break;default:T=(0,b.jsx)(SE,{...w,...DE(t,y)})}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,T,C,(0,b.jsx)(OE,{id:p,errors:i})]})}function DE(e,t){if(t===`email`||t===`url`)return{type:t};switch(e.type){case`number`:case`decimal`:return{type:`text`,inputMode:`decimal`};case`bigint`:return{type:`text`,inputMode:`numeric`};case`date`:return{type:`date`};case`datetime`:return{type:`datetime-local`};default:return{type:`text`}}}function OE({id:e,errors:t}){return t?.length?(0,b.jsx)(`p`,{id:e,className:`text-sm text-destructive`,children:t.join(` `)}):null}var kE={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 lg:grid-cols-3`};function AE({layout:e,names:t,render:n,errors:r,renderInline:i,renderSummary:a,plain:o}){let s=e&&(i?e:PE(e)),c=new Set((s??[]).flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>ME(e)||NE(e)?[]:e.fields)),l=t.filter(e=>!c.has(e)),u=(s??[]).filter(e=>`tab`in e),d=(s??[]).findIndex(e=>`tab`in e),f=d===-1?(s??[]).filter(e=>!(`tab`in e)):(s??[]).slice(0,d).filter(e=>!(`tab`in e)),p=d===-1?[]:(s??[]).slice(d).filter(e=>!(`tab`in e)),m=(e,t)=>ME(e)?(0,b.jsx)(y.Fragment,{children:i?.(e)},t):NE(e)?(0,b.jsx)(y.Fragment,{children:a?.(e)},t):(0,b.jsx)(jE,{section:e,render:n,plain:o},t);return(0,b.jsxs)(b.Fragment,{children:[f.map((e,t)=>m(e,`b${t}`)),u.length>0&&(0,b.jsx)(FE,{tabs:u,render:n,errors:r,block:m}),p.map((e,t)=>m(e,`a${t}`)),l.length>0&&(0,b.jsx)(jE,{section:{fields:l,columns:1},render:n,plain:o})]})}function jE({section:e,render:t,plain:n}){let r=(0,y.useId)(),i=e.fields.map(e=>[e,t(e)]).filter(([,e])=>e!==null);if(i.length===0)return null;let a=(0,b.jsx)(`div`,{className:W(`grid gap-5`,kE[e.columns]),children:i.map(([e,t])=>(0,b.jsx)(`div`,{className:`min-w-0`,children:t},e))});return n?e.title?(0,b.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-3`,children:[(0,b.jsx)(`h3`,{id:r,className:`text-[13px] font-semibold text-muted-foreground`,children:e.title}),a]}):a:e.title?(0,b.jsx)(tE,{"aria-labelledby":r,title:(0,b.jsx)(`span`,{id:r,children:e.title}),children:a}):(0,b.jsx)(tE,{bodyClassName:`p-5`,children:a})}var ME=e=>`inline`in e,NE=e=>`summary`in e;function PE(e){return e.filter(e=>!ME(e)&&!NE(e)).map(e=>`tab`in e?{...e,sections:e.sections.filter(e=>!ME(e)&&!NE(e))}:e)}function FE({tabs:e,render:t,errors:n,block:r}){let i=X(),{locale:a}=Y(),o=(0,y.useId)(),[s,c]=(0,y.useState)(0),l=(0,y.useRef)([]),u=e=>e.sections.some(e=>(ME(e)?[`_inlines.${e.inline}`]:NE(e)?[]:e.fields).some(e=>Object.keys(n).some(t=>t===e||t.startsWith(`${e}.`))));(0,y.useEffect)(()=>{if(u(e[s]))return;let t=e.findIndex(u);t!==-1&&c(t)},[n]);function d(t){let n=Xh(a)?`ArrowLeft`:`ArrowRight`,r=Xh(a)?`ArrowRight`:`ArrowLeft`,i;t.key===n?i=(s+1)%e.length:t.key===r?i=(s-1+e.length)%e.length:t.key===`Home`?i=0:t.key===`End`&&(i=e.length-1),i!==void 0&&(t.preventDefault(),c(i),l.current[i]?.focus())}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`div`,{role:`tablist`,className:`flex gap-0.5 overflow-x-auto border-b`,onKeyDown:d,children:e.map((e,t)=>(0,b.jsxs)(`button`,{ref:e=>{l.current[t]=e},id:`${o}-tab-${t}`,type:`button`,role:`tab`,"aria-selected":t===s,"aria-controls":`${o}-panel-${t}`,tabIndex:t===s?0:-1,onClick:()=>c(t),className:W(`-mb-px flex h-[38px] items-center gap-1.5 border-b-2 px-3 text-[13px] whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,t===s?`border-foreground font-semibold`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.tab,u(e)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-destructive`}),(0,b.jsx)(`span`,{className:`sr-only`,children:i(`form.tabHasErrors`)})]})]},t))}),e.map((e,t)=>(0,b.jsx)(`div`,{id:`${o}-panel-${t}`,role:`tabpanel`,"aria-labelledby":`${o}-tab-${t}`,hidden:t!==s,className:W(`flex-col gap-5`,t===s?`flex`:`hidden`),children:e.sections.map((e,t)=>r(e,String(t)))},t))]})}var IE=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{};function LE({resource:e,field:t,path:n,pattern:r,value:i,constraints:a,markRequired:o,errors:s,onChange:c,idPrefix:l}){let u=X(),d=s[n];if(t.many){let f=Array.isArray(i)?i:[];return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:t.label}),f.map((i,d)=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-dashed p-3`,children:[(0,b.jsx)(RE,{resource:e,field:t,path:`${n}.${d}`,pattern:`${r}.*`,value:i,constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:e=>c(f.map((t,n)=>n===d?e:t))}),(0,b.jsx)(`div`,{children:(0,b.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>c(f.filter((e,t)=>t!==d)),children:[(0,b.jsx)(ex,{}),u(`form.remove`,{name:t.label,index:d+1})]})})]},d)),(0,b.jsx)(`div`,{children:(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>c([...f,xC(t.fields??[])]),children:[(0,b.jsx)(fb,{}),u(`form.add`,{name:t.label})]})}),d&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:d.join(` `)})]})}return(0,b.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,b.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:t.label}),(0,b.jsx)(RE,{resource:e,field:t,path:n,pattern:r,value:IE(i),constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:c}),d&&(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:d.join(` `)})]})}function RE({resource:e,field:t,path:n,pattern:r,value:i,constraints:a,markRequired:o,errors:s,onChange:c,idPrefix:l}){return(0,b.jsx)(b.Fragment,{children:(t.fields??[]).filter(e=>!e.readonly).map(t=>{let u=`${n}.${t.name}`,d=`${r}.${t.name}`,f=e=>c({...i,[t.name]:e});return t.type===`object`?(0,b.jsx)(LE,{resource:e,field:t,path:u,pattern:d,value:i[t.name],constraints:a,markRequired:o,errors:s,idPrefix:l,onChange:f},t.name):(0,b.jsx)(EE,{resource:e,field:{...t,name:u},value:i[t.name],required:o&&a[d]?.required===!0,errors:s[u],constraints:a[d],idPrefix:l,onChange:f},t.name)})})}function zE(e,t){let n=t?._perm?.actions;return e.actions.filter(e=>e.target===`record`&&(n===void 0||typeof n[e.name]==`string`)).map(e=>n?.[e.name]?{...e,label:n[e.name]}:e)}function BE(e,t){let n=zE(e,t),r=n.find(e=>e.primary),i=n.filter(e=>e!==r);return{...r?{primary:r}:{},buttons:i.slice(0,3),overflow:i.slice(3)}}function VE(e,t){let n=e.actions.filter(e=>e.target===`record`&&e.bulk);return t.length===0?n:n.filter(n=>t.some(t=>zE(e,t).some(e=>e.name===n.name)))}function HE(e){return e.actions.filter(e=>e.target===`resource`)}function UE(e,t=0){return e.confirm!==void 0||e.variant===`destructive`||t>1}function WE(e,t=0){return!e.input&&!UE(e,t)}function GE(e,t,n,r){if(UE(e,t))return typeof e.confirm==`string`?e.confirm:t>1?r(`action.confirmSelected`,{action:e.label,count:t}):n===void 0?r(`action.confirm`,{action:e.label}):r(`action.confirmRecord`,{action:e.label,name:n})}function KE(e){let t=e.message===void 0?{}:{message:e.message};return`record`in e?{kind:`record`,record:e.record,...t}:`ok`in e&&`failed`in e?{kind:`bulk`,result:{ok:e.ok,failed:e.failed},...t}:{kind:`resource`,...t}}function qE(e,t){return e.kind===`bulk`?e.result:{ok:t,failed:[]}}function JE(e,t){if(!(e instanceof ug))return{fields:{},form:e.message};let n=Object.entries(e.fields),r=e=>t.includes(e.split(`.`)[0]),i=Object.fromEntries(n.filter(([e])=>r(e))),a=n.filter(([e])=>!r(e)).map(([e,t])=>`${e}: ${t.join(`, `)}`);return{fields:i,form:Object.keys(i).length>0&&a.length===0?null:[e.message,...a].join(` — `)}}function YE(e,t){let n=uC(e)?String(e.id):e;return t===null?n==null||n===``:typeof t==`boolean`?n===t||n===String(t):typeof n!=`string`||n.trim()===``?!1:typeof t==`number`?Number(Nh(n).trim().replace(/,/g,``))===t:n===t}function XE(e,t){return!e.showIf||Object.entries(e.showIf).every(([e,n])=>(Array.isArray(n)?n:[n]).some(n=>YE(t[e],n)))}var ZE=/^.+@[^\s@]+\.[^\s@]+$/,QE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $E(e){if(/\s/.test(e))return!1;try{let{hostname:t}=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:`http://${e}`);return t.includes(`.`)||t.startsWith(`[`)}catch{return!1}}function eD(e,t){try{return new RegExp(t.source,t.flags).test(e)}catch{return!0}}function tD(e){let t=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)??[],n=e.match(/[^\uFE0F\uFE0E][\uFE0F\uFE0E]/g)??[];return e.length-t.length-n.length}function nD(e,t){let n=[];if(typeof e==`string`){let r=tD(e);t.minLength!==void 0&&r<t.minLength&&n.push(J(`validation.minLength`,{min:t.minLength})),t.maxLength!==void 0&&r>t.maxLength&&n.push(J(`validation.maxLength`,{max:t.maxLength})),t.pattern&&!eD(e,t.pattern)&&n.push(t.pattern.message??J(`validation.pattern`)),t.format===`email`&&!ZE.test(e)&&n.push(J(`validation.email`)),t.format===`url`&&!$E(e)&&n.push(J(`validation.url`)),t.format===`uuid`&&!QE.test(e)&&n.push(J(`validation.uuid`)),t.oneOf&&!t.oneOf.includes(e)&&n.push(J(`validation.oneOf`,{values:t.oneOf.join(`, `)}))}return typeof e==`number`&&(t.integer&&!Number.isInteger(e)&&n.push(J(`validation.integer`)),t.min!==void 0&&e<t.min&&n.push(J(`validation.min`,{min:t.min})),t.max!==void 0&&e>t.max&&n.push(J(`validation.max`,{max:t.max}))),n}function rD(e,t,n){let r={};for(let[i,a]of Object.entries(t))for(let{path:t,value:o,sent:s,parentSent:c}of iD(e,i.split(`.`))){if(o==null||o===``){a.required&&c&&(n===`create`||s)&&(r[t]=[J(`validation.required`)]);continue}let e=nD(o,a);e.length>0&&(r[t]=e)}return r}function iD(e,t,n=``,r=!0){let[i,...a]=t,o=typeof e==`object`&&e?e:void 0;if(i===`*`)return(Array.isArray(e)?e:[]).flatMap((e,t)=>iD(e,a,`${n}${t}.`,!0));let s=o!==void 0&&Object.hasOwn(o,i),c=o?.[i],l=`${n}${i}`;return a.length===0?[{path:l,value:c,sent:s,parentSent:r}]:iD(c,a,`${l}.`,r&&s)}function aD({resource:e,action:t,count:n,subject:r,running:i,error:a,onRun:o,onClose:s}){let c=X(),l=t.input?.fields??[],[u,d]=(0,y.useState)(()=>xC(l)),[f,p]=(0,y.useState)({}),[m,h]=(0,y.useState)(!1),g=l.filter(e=>XE(e,u)),_=a&&!m?JE(a,l.map(e=>e.name)):{fields:{},form:null},v={..._.fields,...f};function x(e){if(e.preventDefault(),e.stopPropagation(),!t.input)return o(void 0);let{payload:n,errors:r}=CC(g,u),i={...rD(n,Object.fromEntries(Object.entries(t.input.constraints).filter(([e])=>g.some(t=>t.name===e.split(`.`)[0]))),`create`),...r};p(i),h(Object.keys(i).length>0),Object.keys(i).length===0&&o(n)}let S=GE(t,n,r,c);function C(n){let r=g.find(e=>e.name===n);if(!r||!t.input)return null;let i=e=>d(t=>({...t,[n]:e}));return r.type===`object`?(0,b.jsx)(LE,{resource:e,field:r,path:n,pattern:n,value:u[n],constraints:t.input.constraints,markRequired:!0,errors:v,idPrefix:`action`,onChange:i}):(0,b.jsx)(EE,{resource:e,field:r,value:u[n],required:t.input.required.includes(n),errors:v[n],constraints:t.input.constraints[n],idPrefix:`action`,onChange:i})}return(0,b.jsx)(jd,{open:!0,onOpenChange:e=>!e&&!i&&s(),children:(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/30`}),(0,b.jsx)(Ud,{"aria-describedby":S?`action-question`:void 0,className:`fixed inset-x-3 top-[12vh] z-50 mx-auto flex max-h-[76vh] max-w-lg flex-col overflow-hidden rounded-xl border bg-background shadow-xl outline-none`,children:(0,b.jsxs)(`form`,{onSubmit:x,noValidate:!0,className:`flex min-h-0 flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto p-4`,children:[(0,b.jsx)(Jd,{className:`text-lg font-semibold`,children:t.label}),S&&(0,b.jsx)(`p`,{id:`action-question`,className:`text-sm`,children:S}),n>1&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(t.atomic?`action.atomicNote`:`action.eachNote`,{count:n})}),_.form&&(0,b.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:_.form}),t.input&&(0,b.jsx)(AE,{layout:void 0,names:l.map(e=>e.name),errors:v,render:C})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t p-4`,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:i,onClick:s,children:c(`common.cancel`)}),(0,b.jsx)(q,{type:`submit`,variant:t.variant===`destructive`?`destructive`:`default`,disabled:i,children:i?c(`action.running`):t.label})]})]})})]})})}function oD({resource:e,action:t,ids:n,subject:r,size:i=`default`,className:a,primary:o=!1,menuItem:s=!1,blocked:c=!1,describedBy:l,onDone:u}){let d=X(),f=S(),[p,m]=(0,y.useState)(!1),h=WE(t,n?.length??0),g=pt({mutationFn:r=>Q.runAction(e,t.name,{...n?{ids:n}:{},...r?{input:r}:{}}),onSuccess:r=>{let i=KE(r);m(!1),i.kind===`bulk`?i.message&&RT(i.message):RT(i.message??d(i.kind===`record`&&i.record===null?`action.doneGone`:`action.done`,{action:t.label})),u(i,n??[]);for(let t of[`list`,`count`,`record`,`history`])f.invalidateQueries({queryKey:[t,e]})},onError:e=>{h&&RT(dg(e),`error`)}}),_=Xw(t.icon);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(q,{type:`button`,size:i,variant:t.variant===`destructive`?`destructive`:o?`default`:s?`ghost`:`outline`,className:W(s&&`w-full justify-start font-normal`,a),disabled:c||g.isPending,"aria-describedby":l,"data-action":t.name,onClick:()=>{g.reset(),h?g.mutate(void 0):m(!0)},children:[_&&(0,b.jsx)(_,{"aria-hidden":!0}),t.label,o&&(0,b.jsx)(Sv,{className:`ltr:rotate-180`,"aria-hidden":!0})]}),p&&(0,b.jsx)(aD,{resource:e,action:t,count:n?.length??0,subject:r,running:g.isPending,error:g.error,onRun:e=>g.mutate(e),onClose:()=>m(!1)})]})}function sD({schema:e,record:t,id:n,dirty:r,onGone:i,onChanged:a}){let o=X(),s=S(),[c,l]=(0,y.useState)(!1),{primary:u,buttons:d,overflow:f}=BE(e,t);if(!u&&d.length===0)return null;let p=`record-actions-note`,m=(o,c={})=>(0,b.jsx)(oD,{resource:e.name,action:o,ids:[n],subject:typeof t._title==`string`?t._title:`#${n}`,blocked:r,describedBy:r?p:void 0,...c,onDone:t=>{l(!1);let r=t.kind===`record`?t.record:void 0;if(r===null){i(),s.removeQueries({queryKey:[`record`,e.name,n]});return}r&&s.setQueryData([`record`,e.name,n],r),a()}},o.name);return(0,b.jsxs)(`div`,{role:`group`,"aria-label":o(`list.actions`),className:`ms-auto flex flex-wrap items-center gap-2`,children:[r&&(0,b.jsx)(`span`,{id:p,className:`text-xs text-muted-foreground`,children:o(`action.saveFirst`)}),d.map(e=>m(e)),f.length>0&&(0,b.jsxs)(Sh,{open:c,onOpenChange:l,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`icon`,"aria-label":o(`action.more`),children:(0,b.jsx)(Kv,{})})}),(0,b.jsx)(wh,{forceMount:!0,children:(0,b.jsx)(Th,{forceMount:!0,align:`end`,sideOffset:6,className:`z-50 flex min-w-48 flex-col gap-0.5 rounded-[10px] border bg-popover p-1.5 shadow-lg data-[state=closed]:hidden`,onClick:()=>l(!1),children:f.map(e=>m(e,{menuItem:!0}))})})]}),u&&m(u,{primary:!0})]})}function cD({schema:e,ids:t,bulkOnly:n=!1,size:r=`default`}){let i=X(),a=(e.prints??[]).filter(e=>!n||e.bulk);return t.length===0||a.length===0?null:(0,b.jsx)(b.Fragment,{children:a.map(n=>{let a=Xw(n.icon)??mb;return(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:r,"aria-label":i(`print.open`,{name:n.label}),onClick:()=>window.open(Bg(e.name,n.name,t),`_blank`,`noopener`),children:[(0,b.jsx)(a,{}),n.label]},n.name)})})}function lD({schema:e,query:t,iconOnly:n=!1}){let r=X(),[i,a]=(0,y.useState)(!1);if(!e.list.export)return null;async function o(){a(!0);try{let{blob:n,filename:i,truncated:a}=await Q.exportList(e.name,t),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=i,s.click(),setTimeout(()=>URL.revokeObjectURL(o),1e4),RT(a?r(`list.exportTruncated`,{count:a}):r(`list.exportDone`,{file:i}),a?`error`:`success`)}catch(e){RT(dg(e),`error`)}finally{a(!1)}}return(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:n?`icon`:`default`,disabled:i,"aria-label":n?r(`list.export`):void 0,onClick:()=>void o(),children:[(0,b.jsx)(Qv,{}),!n&&r(i?`list.exporting`:`list.export`)]})}function uD(e){let t=(0,y.useRef)(!1),n=ha(({currentLocation:n,nextLocation:r})=>e&&!t.current&&(n.pathname!==r.pathname||n.search!==r.search));return(0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e]),{blocker:n,release:()=>{t.current=!0}}}function dD({blocker:e}){let t=X();return e.state===`blocked`?(0,b.jsxs)(`div`,{role:`alertdialog`,"aria-labelledby":`leave-title`,className:`sticky top-16 z-10 flex flex-wrap items-center gap-2 rounded-md border border-amber-500/50 bg-background p-3 shadow-sm`,children:[(0,b.jsx)(`p`,{id:`leave-title`,className:`flex-1 text-sm font-medium`,children:t(`form.leaveTitle`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,autoFocus:!0,onClick:()=>e.reset(),children:t(`form.stay`)}),(0,b.jsx)(q,{type:`button`,variant:`destructive`,onClick:()=>e.proceed(),children:t(`form.leave`)})]}):null}function fD(e,t){let n=(0,y.useRef)(t);n.current=t,(0,y.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey)||t.altKey||t.shiftKey||t.key.toLowerCase()!==`s`)return;t.preventDefault();let r=document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`);(!r||r.contains(e.current))&&(n.current?.(),e.current?.requestSubmit())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function pD(e){let[t,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(e);return a.current=e,(0,y.useEffect)(()=>{t.length>0||!r||(i(!1),a.current())},[t.length,r]),{busy:t.length>0,setBusy:(e,t)=>n(n=>t===n.includes(e)?n:t?[...n,e]:n.filter(t=>t!==e)),refuse:()=>i(!0)}}function mD({dirty:e,children:t}){let n=X();return(0,b.jsxs)(`div`,{className:`sticky bottom-3 z-10 flex flex-wrap items-center gap-2 rounded-card border bg-card px-4 py-2.5 shadow-[0_12px_32px_rgba(0,0,0,.12)]`,children:[e&&(0,b.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[13px] font-semibold`,children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full bg-amber-500`}),n(`form.unsaved`)]}),(0,b.jsx)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:t})]})}function hD(){let e=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);return(0,b.jsx)(`kbd`,{"aria-hidden":!0,className:`rounded border border-current/30 px-1 font-sans text-[10.5px] opacity-80`,children:e?`⌘S`:`Ctrl S`})}var gD=`—`,_D=e=>e==null||e===``;function vD(e,t){let n=t?.value;switch(e.kind){case`image`:return typeof n==`string`&&n!==``?{kind:`image`,src:n}:{kind:`image`};case`toggle`:return{kind:`toggle`,on:n===!0};case`money`:{if(_D(n))return{kind:`money`,text:gD};let e=kx(String(n),_D(t?.previous)?{}:{previous:String(t.previous)});return{kind:`money`,text:e.main,...e.unit?{unit:e.unit,unitPosition:e.position}:{},...e.previous===void 0?{}:{previous:e.previous}}}case`badge`:return{kind:`badge`,text:t?.label??(_D(n)?gD:String(n)),...t?.tone?{tone:t.tone}:{}};case`count`:return{kind:`count`,text:typeof n==`number`?Qh(n):_D(n)?gD:$h(String(n))};case`title`:return{kind:`title`,text:_D(n)?gD:String(n),..._D(t?.subline)?{}:{subline:String(t.subline)}}}}function yD({schema:e,name:t,column:n,item:r,compact:i=!1}){let a=r._computed?.[t],o=vD(n,a);switch(o.kind){case`image`:return(0,b.jsx)(`span`,{className:W(`flex shrink-0 items-center justify-center overflow-hidden rounded-control border bg-muted text-muted-foreground`,i?`size-14`:`size-10`),children:o.src?(0,b.jsx)(`img`,{src:o.src,alt:``,className:`size-full object-cover`,loading:`lazy`}):(0,b.jsx)(gy,{className:`size-[18px]`,"aria-hidden":!0})});case`title`:return(0,b.jsxs)(`span`,{className:`flex min-w-0 flex-col leading-[1.45]`,children:[(0,b.jsx)(`span`,{className:W(`truncate font-semibold`,i?`text-[14.5px]`:`text-[13.5px]`),children:o.text}),o.subline&&(0,b.jsx)(`span`,{className:`truncate text-start font-mono text-[11.5px] text-muted-foreground`,children:(0,b.jsx)(`bdi`,{dir:`ltr`,children:o.subline})})]});case`money`:return(0,b.jsxs)(`span`,{className:`flex flex-col leading-[1.4]`,children:[(0,b.jsxs)(`span`,{className:`font-semibold whitespace-nowrap`,children:[o.unit&&o.unitPosition===`before`&&(0,b.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[o.unit,` `]}),o.text,o.unit&&o.unitPosition!==`before`&&(0,b.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[` `,o.unit]})]}),o.previous&&(0,b.jsx)(`s`,{className:`text-xs text-muted-foreground`,children:o.previous})]});case`badge`:return(0,b.jsx)(XT,{tone:o.tone,children:o.text});case`count`:return(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:o.text});case`toggle`:return(0,b.jsx)(bD,{schema:e,column:n,item:r,on:o.on===!0})}}function bD({schema:e,column:t,item:n,on:r}){let i=X(),a=S(),[o,s]=(0,y.useState)(r),c=t.toggle,l=c!==void 0&&n._perm?.update!==!1&&!(Array.isArray(n._readonly)&&n._readonly.includes(c.field)),u=pt({mutationFn:t=>Q.update(e.name,String(n._id),{[c.field]:t?c.on:c.off},e.version?n[e.version]:void 0),onSuccess:()=>a.invalidateQueries({queryKey:[`list`,e.name]}),onError:e=>{s(r),RT(dg(e),`error`)}}),d=typeof n._title==`string`?n._title:String(n._id);return(0,b.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":i(`list.toggleRow`,{column:t.label,name:d}),disabled:!l||u.isPending,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(!o),u.mutate(!o)},className:W(`relative inline-block h-5 w-9 shrink-0 cursor-pointer rounded-full bg-input transition-colors disabled:cursor-default disabled:opacity-60`,o&&`bg-primary`,`after:absolute after:top-0.5 after:size-4 after:rounded-full after:bg-white after:shadow-sm after:transition-[inset-inline-start] after:content-[''] after:start-0.5`,o&&`after:start-[18px]`)})}function xD(e){let t=e.form.layout;return t?t.flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>`fields`in e&&!(`inline`in e)?e.fields:[]):[...new Set([...e.form.update,...e.form.readonly])]}function SD(e){let t=(e.form.layout??[]).flatMap(e=>`tab`in e?e.sections:[e]).flatMap(e=>`summary`in e?e.summary.flatMap(e=>`field`in e.value?[e.value.field]:[]):[]),n=(e.form.aside??[]).flatMap(e=>e.relation?[e.relation.field]:e.fields),r=[...e.form.header?.badges??[],...(e.form.header?.subtitle??[]).flatMap(e=>`field`in e?[e.field]:[])],i=new Set(e.form.update);return new Set([...t,...n,...r].filter(e=>!i.has(e)))}function CD(e,t,n){let r=e.form.mode===`view`&&t!==void 0&&!n,i=new Set(xD(e)),a=r?[]:e.form.update.filter(t=>i.has(t)||!e.form.layout),o=e.form.header,s=t=>e.fields.find(e=>e.name===t),c=e=>e!==void 0&&t?.[e.name]!==void 0&&t?.[e.name]!==null,l=(o?.badges?o.badges.map(s):e.fields.filter(e=>e.widget===`badge`)).filter(c),u=o?.stepper?s(o.stepper):void 0;u&&c(u)&&u.steps?.exclude.includes(String(t[u.name]))&&!l.includes(u)&&l.push(u);let d=t?._computed??{};return{editable:a,header:{badges:l,subtitle:(o?.subtitle??[]).flatMap(n=>{if(`field`in n){let e=s(n.field);return e&&c(e)?[jx(t[e.name],e)]:[]}let r=e.list.computed?.[n.computed];if(!r||!d[n.computed])return[];let i=vD(r,d[n.computed]);return i.text?[r.kind===`count`?`${i.text} ${r.label}`:i.text]:[]}),...u?{stepper:u}:{}},aside:e.form.aside??[]}}function wD(e,t,n){return e.relation?n?._aside?.[String(t)]:n}function TD(e,t,n){let r=n?._computed??{};return e.summary.flatMap(e=>{if(`field`in e.value){let r=t.fields.find(t=>t.name===e.value.field),i=n?.[e.value.field];return r&&i!=null?[{label:e.label,text:jx(i,r)}]:[]}let i=t.list.computed?.[e.value.computed],a=r[e.value.computed];if(!i||!a)return[];let o=vD(i,a),s=o.unit?o.unitPosition===`before`?`${o.unit} ${o.text}`:`${o.text} ${o.unit}`:o.text;return s?[{label:e.label,text:s}]:[]})}function ED(e,t){let n={};for(let r of e){if(!r.warnIf||!(r.name in t))continue;let e=t[r.name];(e==null||typeof e==`string`&&e.trim()===``)&&(n[r.name]=r.warnIf.message)}return n}function DD(e,t){return e.fields.filter(t=>t!==e.order).flatMap(e=>t.fields.filter(t=>t.name===e))}function OD(e,t,n){let r=n?._inlines?.[e.inline],i=DD(e,t);return(r?.rows??[]).map(e=>({key:String(e._id),id:String(e._id),record:e,values:xC(i,e)}))}function kD(e,t,n){return{key:n,values:xC(DD(e,t))}}function AD(e,t){if(!e.record)return new Set;let n=e.record._perm;if(t.permissions?.update===!1||n?.update===!1)return new Set(t.fields.map(e=>e.name));let r=Array.isArray(e.record._readonly)?e.record._readonly:[];return new Set([...t.form.readonly,...r])}function jD(e,t,n,r){let i=DD(e,t),a={},o=[],s=[],c=new Map(n.map(e=>[e.key,e]));for(let e of r){let n=c.get(e.key);if(n?.id!==void 0){let r=AD(e,t),{payload:o,errors:c}=CC(i.filter(e=>!r.has(e.name)),e.values,n.values),l={...rD(o,t.form.constraints.update,`update`),...c};if(Object.keys(l).length>0&&(a[e.key]=l),Object.keys(o).length===0)continue;let u=t.version?n.record?.[t.version]:void 0;s.push({_id:n.id,...o,...typeof u==`number`?{_version:u}:{}})}else{let{payload:n,errors:r}=CC(i,e.values),s={...rD(n,t.form.constraints.create,`create`),...r};Object.keys(s).length>0&&(a[e.key]=s),o.push({_key:e.key,...n})}}let l=new Set(r.map(e=>e.key)),u=n.filter(e=>e.id!==void 0&&!l.has(e.key)).map(e=>e.id),d=e.order!==void 0&&t.form.update.includes(e.order),f=r.map(e=>e.key),p=d&&f.join(`
|
|
56
56
|
`)!==n.map(e=>e.key).join(`
|
|
57
57
|
`)?f:void 0,m={...o.length?{create:o}:{},...s.length?{update:s}:{},...u.length?{delete:u}:{},...p?{order:p}:{}};return{changes:Object.keys(m).length?m:void 0,errors:a}}function MD(e,t,n,r,i){let a={},o={};for(let s of e){let e=t[s.inline];if(!e||s.readonly)continue;let c=r[s.inline]??[],l=jD(s,e,n[s.inline]??[],c),u=l.changes?i(s,c.length):null;(Object.keys(l.errors).length>0||u)&&(o[s.inline]={rows:l.errors,inline:u?[u]:[]}),l.changes&&(a[s.inline]=l.changes)}return{changes:Object.keys(a).length?a:void 0,errors:o}}function ND(e,t){let n={},r={};for(let[i,a]of Object.entries(e)){if(i!==`_inlines`&&!i.startsWith(`_inlines.`)){r[i]=a;continue}let[,e=``,o,s,...c]=i.split(`.`),l=n[e]??={rows:{},inline:[]},u=o===`create`?t?.[e]?.create?.[Number(s)]?._key:o===`update`||o===`delete`?s:void 0,d=c.join(`.`);u===void 0||o===`create`&&!/^\d+$/.test(s??``)||d===``?l.inline.push(...a):((l.rows[u]??={})[d]??=[]).push(...a)}return{inlines:n,parent:r}}var PD=e=>Object.values(e).some(e=>e.inline.length>0||Object.keys(e.rows).length>0);function FD({inline:e,child:t,rows:n,onChange:r,readOnly:i,errors:a,parent:o,parentValues:s,onBusy:c,truncated:l}){let u=X(),d=(0,y.useId)(),f=DD(e,t),p=(0,y.useRef)(0),[m,h]=(0,y.useState)(null),g=!i&&t.permissions?.create!==!1&&t.form.create.length>0&&n.length<e.max,_=!i&&e.order!==void 0&&t.form.update.includes(e.order)&&n.length>1,v=e=>!i&&(e.id===void 0||t.permissions?.delete!==!1&&e.record?._perm?.delete!==!1),x=e=>s===void 0?void 0:JSON.stringify({...JSON.parse(wC(f,e.values)??`{}`),_parent:JSON.parse(s)});function S(){let i;do i=`n${++p.current}`;while(n.some(e=>e.key===i));r([...n,kD(e,t,i)])}let C=(e,t,i)=>r(n.map(n=>n.key===e?{...n,values:{...n.values,[t]:i}}:n)),w=e=>r(n.filter(t=>t.key!==e));function T(e,t){if(t<0||t>=n.length||e===t)return;let i=[...n];i.splice(t,0,i.splice(e,1)[0]),r(i)}function E(n,r,s){let l=`inline-${t.name}-${n.key}`,u=a?.rows[n.key]??{},d=n.id===void 0;if(i||!(d?t.form.create:t.form.update).includes(r.name)||AD(n,t).has(r.name))return d?null:e.readonly&&s?(0,b.jsx)(eE,{value:n.record?.[r.name],field:r,record:n.record}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-readonly":r.name,children:[!s&&(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:r.label}),(0,b.jsx)(`div`,{className:`min-h-8 rounded-lg bg-muted/50 px-2.5 py-1.5 text-sm break-words`,children:(0,b.jsx)(eE,{value:n.record?.[r.name],field:r,record:n.record})})]});let f=d?`create`:`update`;if(r.type===`object`)return(0,b.jsx)(LE,{resource:t.name,field:r,path:r.name,pattern:r.name,value:n.values[r.name],constraints:t.form.constraints[f],markRequired:d,errors:u,idPrefix:l,onChange:e=>C(n.key,r.name,e)});let p=ED([r],n.values)[r.name],m=(0,b.jsx)(EE,{resource:t.name,field:r,value:n.values[r.name],required:d&&t.form.requiredOnCreate.includes(r.name),errors:u[r.name],constraints:t.form.constraints[f][r.name],formValues:r.type===`relation`?x(n):void 0,parent:o,idPrefix:l,hideLabel:s,onChange:e=>C(n.key,r.name,e),onBusy:e=>c(`${t.name}:${n.key}:${r.name}`,e)});return p?(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m,(0,b.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-warn`,children:[(0,b.jsx)(nx,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),p]})]}):m}function D(t,r){let i=u(`inline.row`,{name:e.label,index:r+1});return(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`cursor-grab text-muted-foreground`,draggable:!0,"aria-hidden":!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,h(r)},onDragEnd:()=>h(null),children:(0,b.jsx)(cy,{className:`size-4`})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:r===0,"aria-label":u(`inline.moveUp`,{name:i}),onClick:()=>T(r,r-1),children:(0,b.jsx)(J_,{})}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:r===n.length-1,"aria-label":u(`inline.moveDown`,{name:i}),onClick:()=>T(r,r+1),children:(0,b.jsx)(W_,{})})]}),v(t)&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":u(`inline.remove`,{name:i}),onClick:()=>w(t.key),children:(0,b.jsx)(ex,{})})]})}let O=e=>_?{onDragOver:e=>{m!==null&&e.preventDefault()},onDrop:t=>{t.preventDefault(),m!==null&&T(m,e),h(null)}}:{},k=e=>{let t=Object.entries(a?.rows[e.key]??{}).filter(([e])=>!f.some(t=>t.name===e.split(`.`)[0]));return t.length>0?(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:t.map(([e,t])=>`${e}: ${t.join(`, `)}`).join(` — `)}):null},A=_||n.some(v);return(0,b.jsxs)(`section`,{"aria-labelledby":d,className:`flex min-w-0 flex-col rounded-card border bg-card shadow-card`,"data-inline":t.name,children:[(0,b.jsxs)(`div`,{className:`flex min-h-14 flex-wrap items-center gap-2 border-b px-5 py-3`,children:[(0,b.jsx)(`h2`,{id:d,className:`text-[15px] font-semibold`,children:e.label}),(0,b.jsx)(`span`,{className:`inline-flex h-5 items-center rounded-full bg-muted px-2 text-[11px] text-muted-foreground`,children:LD(u,e,n.length)}),g&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto`,onClick:S,children:[(0,b.jsx)(fb,{}),u(`form.add`,{name:e.label})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 p-5 empty:hidden`,children:[l&&(0,b.jsxs)(`p`,{role:`note`,className:`text-sm text-muted-foreground`,children:[u(`inline.truncated`,{count:l.total-n.length}),` `,(0,b.jsx)(bo,{to:l.href,className:`text-primary hover:underline`,children:u(`inline.openList`)})]}),n.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`inline.empty`)}),n.length>0&&e.display===`table`&&(0,b.jsx)(`div`,{className:`relative -mx-5 overflow-x-auto border-y first:-mt-5 first:border-t-0 last:-mb-5 last:border-b-0`,children:(0,b.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,b.jsx)(`thead`,{className:`bg-[color-mix(in_oklab,var(--muted)_50%,transparent)] text-[12.5px] text-muted-foreground`,children:(0,b.jsxs)(`tr`,{children:[(e.computed??[]).map(e=>(0,b.jsx)(`th`,{scope:`col`,className:`px-3.5 py-2.5 text-start font-medium whitespace-nowrap`,children:t.list.computed?.[e]?.label},`~${e}`)),f.map(e=>(0,b.jsxs)(`th`,{scope:`col`,className:`px-3.5 py-2.5 text-start font-medium whitespace-nowrap`,children:[e.label,t.form.requiredOnCreate.includes(e.name)&&n.some(e=>e.id===void 0)&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-destructive`,children:`*`})]},e.name)),A&&(0,b.jsx)(`th`,{scope:`col`,className:`px-3.5 py-2.5`,children:(0,b.jsx)(`span`,{className:`sr-only`,children:u(`inline.rowActions`)})})]})}),(0,b.jsx)(`tbody`,{children:n.map((n,r)=>(0,b.jsxs)(`tr`,{"data-row":n.key,className:W(`border-t align-top`,m===r&&`opacity-50`),...O(r),children:[(e.computed??[]).map(e=>(0,b.jsx)(`td`,{className:`px-3.5 py-2`,children:n.record&&t.list.computed?.[e]&&(0,b.jsx)(yD,{schema:t,name:e,column:t.list.computed[e],item:n.record})},`~${e}`)),f.map(e=>(0,b.jsx)(`td`,{className:`min-w-32 px-3.5 py-2`,children:E(n,e,!0)},e.name)),A&&(0,b.jsx)(`td`,{className:`px-3.5 py-2`,children:D(n,r)})]},n.key))})]})}),e.display===`table`&&n.map(e=>(0,b.jsx)(y.Fragment,{children:k(e)},e.key)),e.display===`cards`&&n.map((n,r)=>(0,b.jsxs)(`div`,{"data-row":n.key,className:W(`flex flex-col gap-4 rounded-card border bg-background/40 p-4`,m===r&&`opacity-50`),...O(r),children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[ID(n)??u(`inline.newRow`,{name:e.label,index:r+1}),r===0&&e.markFirst&&(0,b.jsx)(XT,{tone:`primary`,children:e.markFirst})]}),D(n,r)]}),(0,b.jsx)(AE,{plain:!0,layout:t.form.layout,names:f.map(e=>e.name),errors:a?.rows[n.key]??{},render:e=>{let t=f.find(t=>t.name===e);return t?E(n,t,!1):null}}),k(n)]},n.key)),a&&a.inline.length>0&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a.inline.join(` — `)})]})]})}var ID=e=>typeof e.record?._title==`string`?e.record._title:void 0;function LD(e,t,n){return t.min?e(`inline.limitsBetween`,{min:t.min,max:t.max,count:n}):e(`inline.limitsMax`,{max:t.max,count:n})}var RD=(e,t)=>t===void 0?[`history`,e]:[`history`,e,t];function zD({schema:e,id:t,record:n}){let r=X(),i=Ug(),a=mt({queryKey:RD(e.name,t),initialPageParam:void 0,queryFn:({pageParam:n})=>Q.history(e.name,t,n),getNextPageParam:e=>e.next,staleTime:0});if(a.isPending)return(0,b.jsx)(G,{children:r(`common.loading`)});if(a.isError&&!a.data)return(0,b.jsx)(G,{tone:`error`,children:dg(a.error)});let o=a.data.pages.flatMap(e=>e.entries);if(o.length===0)return(0,b.jsx)(G,{children:r(`audit.empty`)});let s=t=>t===e.name?e:void 0;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,b.jsx)(rS,{entries:o,now:new Date(a.dataUpdatedAt),names:Px(i.data,s),schemaOf:s,titleOf:(e,t)=>BD(n,e,t)}),a.isError&&(0,b.jsx)(G,{tone:`error`,children:dg(a.error)}),a.hasNextPage&&(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,className:`self-center`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:r(a.isFetchingNextPage?`common.loading`:`list.loadMore`)})]})}function BD(e,t,n){let r=e?.[t],i=(Array.isArray(r)?r:[r]).find(e=>typeof e==`object`&&!!e&&String(e.id)===n);return typeof i?.title==`string`?i.title:void 0}function VD(e){return e.normalize(`NFKD`).replace(/\p{M}/gu,``).normalize(`NFC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``)}function HD(e,t,n){let r=typeof t?._title==`string`?t._title:`#${n}`;return r.startsWith(`#`)?`${e} ${r}`:`${e}: ${r}`}function UD({mode:e}){let t=X(),{resource:n=``,id:r}=$i(),i=qi(),[a]=wo(),o=e===`create`?a.get(`from`)??void 0:void 0,s=e===`edit`?r:o,c=Wg(n),l=Jg(n,s),[u,d]=(0,y.useState)(0),f=`${n}:${r}`,[p,m]=(0,y.useState)({of:f,tab:`details`}),h=p.of===f?p.tab:`details`;if(c.isPending||s!==void 0&&l.isPending)return(0,b.jsx)(G,{children:t(`common.loading`)});if(c.isError)return(0,b.jsx)(G,{tone:`error`,children:c.error.message});if(s!==void 0&&l.isError)return(0,b.jsx)(G,{tone:`error`,children:l.error.message});let g=i.state?.saved;return(0,b.jsx)(GD,{schema:c.data,mode:e,id:r,record:e===`edit`?l.data:void 0,source:o?l.data:void 0,saved:u===0?g:void 0,onChanged:()=>d(e=>e+1),tab:h,onTab:e=>m({of:f,tab:e})},e===`edit`?`${n}:${r}:${u}`:`${n}:new:${i.key}`)}function WD(e,t){let n=new Set(e.fields.filter(e=>e.primary||e.unique||e.readonly||e.file).map(e=>e.name)),r=new Set(e.fields.filter(e=>e.widget===`richtext`).map(e=>e.name));return Object.fromEntries(Object.entries(t).filter(([e])=>!n.has(e)&&!e.startsWith(`_`)).map(([e,t])=>[e,r.has(e)&&typeof t==`string`?vC(t):t]))}function GD({schema:e,mode:t,id:n,record:r,source:i,saved:a,onChanged:o,tab:s,onTab:c}){let l=X(),{locale:u}=Y(),d=Yi(),f=S(),p=r?._perm,m=t===`create`||e.permissions?.update!==!1&&p?.update!==!1,h=e.permissions?.delete!==!1&&p?.delete!==!1,[g,_]=(0,y.useState)(!1),v=CD(e,t===`edit`?r:void 0,g),x=t===`edit`&&e.form.mode===`view`&&!g,C=new Set(t===`edit`?m&&!x?[...e.form.readonly,...YD(r)]:[...e.form.update,...e.form.readonly]:[]),w=t===`create`?e.form.create:[...e.form.update,...e.form.readonly],T=e.fields.filter(e=>w.includes(e.name)),E=SD(e),D=T.filter(e=>!C.has(e.name)),O=D.map(e=>e.name),[k,A]=(0,y.useState)(r),[j,M]=(0,y.useState)(()=>xC(D,r??(i?WD(e,i):void 0))),[N,ee]=(0,y.useState)(j);(0,y.useEffect)(()=>{if(!g||!r)return;let e=xC(D,r);M(e),ee(e)},[g]);let te=KD(e),P=t=>Object.fromEntries(te.map(n=>[n.inline,OD(n,e.inlines[n.inline],t)])),[ne,re]=(0,y.useState)(()=>P(r)),[ie,ae]=(0,y.useState)(ne),[oe,se]=(0,y.useState)({}),ce=(0,y.useRef)(void 0),le=e.version?k?.[e.version]:void 0,[F,ue]=(0,y.useState)(null),de=wC(D,N),[fe,pe]=(0,y.useState)({}),[me,I]=(0,y.useState)(null),he=Hg(),ge=t===`edit`&&n!==void 0&&he.data?.audit.enabled===!0,_e=ge?s:`details`,ve=(0,y.useRef)(new Set(D.filter(e=>e.widget===`slug`&&j[e.name]!==``).map(e=>e.name)));function ye(e,t){ee(n=>{let r={...n,[e]:t};if(typeof t==`string`)for(let n of D)n.slugFrom===e&&!ve.current.has(n.name)&&(r[n.name]=VD(t));return r}),D.some(t=>t.name===e&&t.widget===`slug`)&&ve.current.add(e)}let[be,xe]=(0,y.useState)(a?l(`form.savedName`,{name:a}):null),L=pD(()=>I(null)),Se=JSON.stringify(N)!==JSON.stringify(j)||JSON.stringify(ie)!==JSON.stringify(ne),{blocker:Ce,release:we}=uD(Se),Te=(0,y.useRef)(null),Ee=(0,y.useRef)(`list`);fD(Te,()=>{Ee.current=`stay`});let De=pt({mutationFn:({payload:r,version:i})=>t===`create`?Q.create(e.name,r):Q.update(e.name,n,r,i),onSuccess:async(r,{then:i})=>{f.invalidateQueries({queryKey:RD(e.name)}),await f.invalidateQueries({queryKey:[`list`,e.name]});let a=typeof r._title==`string`?r._title:`#${String(r._id)}`;if(i===`stay`&&t===`edit`){let t=xC(D,r),i=P(r);A(r),M(t),ee(t),re(i),ae(i),se({}),xe(l(`form.savedName`,{name:a})),await f.invalidateQueries({queryKey:[`record`,e.name,n]});return}we(),f.removeQueries({queryKey:[`record`,e.name]}),i===`new`?d(`/${e.name}/new`,{state:{saved:a}}):i===`stay`?d(`/${e.name}/${encodeURIComponent(String(r._id))}`,{replace:!0,state:{saved:a}}):d(`/${e.name}`)},onError:e=>{if(c(`details`),!(e instanceof ug)){I(e.message);return}if(e.status===409&&e.body.current){ue(e.body.current);return}let t=JE(e,[...O,`_inlines`]),n=ND(t.fields,ce.current);pe(n.parent),se(n.inlines),I(t.form)}}),[Oe,ke]=(0,y.useState)(!1),Ae=pt({mutationFn:()=>Q.remove(e.name,n,le),onSuccess:async()=>{we(),await f.invalidateQueries({queryKey:[`list`,e.name]}),d(`/${e.name}`),f.removeQueries({queryKey:[`record`,e.name,n]})},onError:e=>{ke(!1),I(dg(e))}}),je=D.filter(e=>XE(e,N));function Me(){let n=CC(je,N,t===`edit`?j:void 0),r=MD(te,e.inlines??{},ne,ie,(e,t)=>e.min!==void 0&&t<e.min?l(`inline.countMin`,{min:e.min,count:t}):t>e.max?l(`inline.countMax`,{max:e.max,count:t}):null);return ce.current=r.changes,{payload:r.changes?{...n.payload,_inlines:r.changes}:n.payload,errors:n.errors,inlineErrors:r.errors}}function Ne(n){if(n.preventDefault(),!m)return;let r=n.nativeEvent.submitter,i=r?.value===`new`?`new`:r?`list`:Ee.current;if(Ee.current=`list`,xe(null),L.busy){I(l(`upload.busy`)),L.refuse();return}let{payload:a,errors:o,inlineErrors:s}=Me(),u=t===`create`?`create`:`update`,d={...rD(a,Object.fromEntries(Object.entries(e.form.constraints[u]).filter(([e])=>je.some(t=>t.name===e.split(`.`)[0]))),u),...o};pe(d),se(s),I(null),Object.keys(d).length===0&&!PD(s)?De.mutate({payload:a,version:le,then:i}):c(`details`)}function Pe(t){ue(null),De.mutate({payload:Me().payload,version:e.version?t[e.version]:void 0,then:De.variables?.then??`list`})}function Fe(e){let t=xC(D,e);ue(null),A(e),M(t),ee(t),pe({})}function Ie(t){let i=e.inlines?.[t.inline];if(!i)return null;let a=r?._inlines?.[t.inline],o=a?.truncated&&n!==void 0?{total:a.total,href:`/${i.name}?${new URLSearchParams({[`filter[${t.link}]`]:String(r?.[e.primaryKeys[0]]??n)})}`}:void 0;return(0,b.jsx)(FD,{inline:t,child:i,rows:ie[t.inline]??[],onChange:e=>ae(n=>({...n,[t.inline]:e})),readOnly:!m||x||t.readonly===!0||o!==void 0,errors:oe[t.inline],parent:e.name,parentValues:de,onBusy:L.setBusy,truncated:o})}function Le(t){let n=TD(t,e,r);return n.length===0?null:(0,b.jsx)(tE,{title:t.title,bodyClassName:t.title?void 0:`p-5`,children:(0,b.jsx)(`dl`,{className:`flex flex-col gap-2 text-[13px]`,children:n.map((e,t)=>(0,b.jsxs)(`div`,{className:W(`flex items-baseline justify-between gap-3`,t===n.length-1&&n.length>1&&`border-t pt-2.5 text-sm font-bold`),children:[(0,b.jsx)(`dt`,{className:W(t===n.length-1&&n.length>1?``:`text-muted-foreground`),children:e.label}),(0,b.jsx)(`dd`,{children:e.text})]},e.label))})})}let Re=ED(D,N);function ze(e){let t=Be(e);return t&&Re[e]?(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t,(0,b.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-warn`,children:[(0,b.jsx)(nx,{className:`size-3.5`,"aria-hidden":!0}),Re[e]]})]}):t}function Be(n){let i=T.find(e=>e.name===n);if(!i||!XE(i,N))return null;if(C.has(n))return(0,b.jsx)(XD,{resource:e.name,field:i,record:r,plain:x});let a=t===`create`?`create`:`update`;return i.type===`object`?(0,b.jsx)(LE,{resource:e.name,field:i,path:i.name,pattern:i.name,value:N[i.name],constraints:e.form.constraints[a],markRequired:t===`create`,errors:fe,onChange:e=>ye(i.name,e)}):(0,b.jsx)(EE,{resource:e.name,field:i,value:N[i.name],required:t===`create`&&e.form.requiredOnCreate.includes(i.name),errors:fe[i.name],formValues:i.type===`relation`?de:void 0,constraints:e.form.constraints[a][i.name],onChange:e=>ye(i.name,e),onBusy:e=>L.setBusy(i.name,e)})}return(0,b.jsxs)(`form`,{ref:Te,onSubmit:Ne,noValidate:!0,className:W(`flex flex-col gap-5`,v.aside.length>0?`max-w-[1400px]`:e.form.layout?.length?`max-w-4xl`:`max-w-2xl`),children:[t===`create`?(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(ZD,{to:`/${e.name}`}),(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:l(`form.new`,{name:e.label})})]}):(0,b.jsx)(QD,{schema:e,record:r,id:n,dirty:Se,onGone:()=>{we(),d(`/${e.name}`)},onChanged:o,badges:v.header.badges,subtitle:v.header.subtitle,extra:(0,b.jsxs)(b.Fragment,{children:[x&&m&&(0,b.jsxs)(q,{type:`button`,variant:`outline`,onClick:()=>_(!0),children:[(0,b.jsx)(ib,{}),l(`form.edit`)]}),e.creatable&&(0,b.jsx)(q,{asChild:!0,variant:`outline`,children:(0,b.jsxs)(bo,{to:`/${e.name}/new?${new URLSearchParams({from:n})}`,children:[(0,b.jsx)(Pv,{}),l(`form.duplicate`)]})}),h&&(Oe?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q,{type:`button`,variant:`destructive`,disabled:Ae.isPending,onClick:()=>Ae.mutate(),children:l(Ae.isPending?`form.deleting`:e.softDelete?`form.confirmMoveToTrash`:`form.confirmDelete`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,onClick:()=>ke(!1),children:l(`form.keep`)})]}):(0,b.jsxs)(q,{type:`button`,variant:`outline`,className:`text-destructive`,onClick:()=>ke(!0),children:[(0,b.jsx)(ex,{}),l(e.softDelete?`form.moveToTrash`:`form.delete`)]}))]})}),i&&te.length>0&&(0,b.jsx)(`p`,{role:`note`,className:`rounded-md border bg-muted/40 px-3 py-2 text-sm text-muted-foreground`,children:l(`inline.duplicateNote`,{names:new Intl.ListFormat(u).format(te.map(e=>e.label))})}),!m&&e.form.mode!==`view`&&(0,b.jsx)(`p`,{role:`note`,className:`rounded-md border bg-muted/40 px-3 py-2 text-sm text-muted-foreground`,children:l(`form.viewOnly`)}),be&&(0,b.jsx)(`p`,{role:`status`,className:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:be}),(0,b.jsx)(dD,{blocker:Ce}),ge&&(0,b.jsx)(JD,{active:_e,onChange:c}),F&&(0,b.jsx)($D,{fields:D,before:k,current:F,busy:De.isPending,onKeepMine:()=>Pe(F),onLoadTheirs:()=>Fe(F)}),me&&(0,b.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:me}),ge&&_e===`history`&&(0,b.jsx)(`div`,{role:`tabpanel`,id:`record-panel-history`,"aria-labelledby":`record-tab-history`,children:(0,b.jsx)(zD,{schema:e,id:n,record:r})}),(0,b.jsxs)(`div`,{className:_e===`details`?`contents`:`hidden`,...ge?{role:`tabpanel`,id:`record-panel-details`,"aria-labelledby":`record-tab-details`}:{},children:[t===`edit`&&r&&v.header.stepper&&(0,b.jsx)(iE,{field:v.header.stepper,value:r[v.header.stepper.name],reached:r._steps}),(0,b.jsxs)(`div`,{className:W(v.aside.length>0?`grid items-start gap-5 lg:grid-cols-[minmax(0,1fr)_340px]`:`contents`),children:[(0,b.jsxs)(`div`,{className:W(v.aside.length>0?`flex min-w-0 flex-col gap-5`:`contents`),children:[(0,b.jsx)(AE,{layout:e.form.layout,names:T.map(e=>e.name).filter(e=>!E.has(e)),errors:{...fe,...Object.fromEntries(Object.entries(oe).filter(([,e])=>PD({found:e})).map(([e])=>[`_inlines.${e}`,[``]]))},render:ze,renderInline:Ie,renderSummary:Le}),!x&&(0,b.jsxs)(mD,{dirty:Se,children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>d(`/${e.name}`),children:l(m?`common.cancel`:`form.back`)}),m&&e.creatable&&(0,b.jsx)(q,{type:`submit`,value:`new`,variant:`outline`,disabled:De.isPending||L.busy,children:l(`form.saveAndNew`)}),m&&(0,b.jsxs)(q,{type:`submit`,value:`list`,disabled:De.isPending||L.busy,"aria-keyshortcuts":`Control+S Meta+S`,children:[l(De.isPending?`form.saving`:`form.save`),(0,b.jsx)(hD,{})]})]}),t===`edit`&&r&&e.related.length>0&&(0,b.jsxs)(`nav`,{"aria-label":l(`form.related`),className:`flex flex-col gap-2 border-t pt-4`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground`,children:l(`form.related`)}),(0,b.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:e.related.map(t=>(0,b.jsx)(`li`,{children:(0,b.jsx)(q,{asChild:!0,variant:`outline`,size:`sm`,children:(0,b.jsx)(bo,{to:`/${t.resource}?${new URLSearchParams({[`filter[${t.field}][${t.operator}]`]:String(r[e.primaryKeys[0]])})}`,children:t.label})})},`${t.resource}:${t.field}`))})]})]}),v.aside.length>0&&(0,b.jsx)(`aside`,{className:`flex flex-col gap-5`,children:v.aside.map((t,n)=>(0,b.jsx)(nE,{card:t,values:wD(t,n,r),schema:e},n))})]})]})]})}function KD(e){return(e.form.layout??[]).flatMap(e=>`tab`in e?e.sections:[e]).filter(t=>`inline`in t&&e.inlines?.[t.inline]!==void 0)}var qD=[`details`,`history`];function JD({active:e,onChange:t}){let n=X(),r=(0,y.useRef)({});return(0,b.jsx)(`div`,{role:`tablist`,"aria-label":n(`audit.recordTabs`),className:`flex gap-0.5 overflow-x-auto border-b`,onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`&&n.key!==`Home`&&n.key!==`End`)return;n.preventDefault();let i=n.key===`Home`?`details`:n.key===`End`||e===`details`?`history`:`details`;t(i),r.current[i]?.focus()},children:qD.map(i=>(0,b.jsx)(`button`,{ref:e=>{r.current[i]=e},id:`record-tab-${i}`,type:`button`,role:`tab`,"aria-selected":i===e,"aria-controls":i===`details`||e===`history`?`record-panel-${i}`:void 0,tabIndex:i===e?0:-1,onClick:()=>t(i),className:W(`-mb-px flex h-[38px] items-center border-b-2 px-3 text-[13px] whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,i===e?`border-foreground font-semibold`:`border-transparent text-muted-foreground hover:text-foreground`),children:n(i===`details`?`audit.details`:`audit.history`)},i))})}var YD=e=>Array.isArray(e?._readonly)?e._readonly:[];function XD({resource:e,field:t,record:n,plain:r=!1}){let i=X(),a=n?.[t.name];return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-readonly":t.name,children:[(0,b.jsxs)(`span`,{className:W(`flex items-center gap-1.5 font-medium`,r?`text-[12.5px] text-muted-foreground`:`text-sm`),children:[t.label,!r&&(0,b.jsx)(Iy,{className:`size-3.5 text-muted-foreground`,"aria-label":i(`form.readOnly`),role:`img`})]}),(0,b.jsx)(`div`,{className:W(`text-sm break-words`,!r&&`min-h-8 rounded-lg bg-muted/50 px-2.5 py-1.5`),children:t.widget===`richtext`&&typeof a==`string`&&a!==``?(0,b.jsx)(wE,{id:`field-${t.name}`,resource:e,field:t,value:a,readOnly:!0}):(0,b.jsx)(eE,{value:a,field:t,record:n,detailed:!0})}),t.help&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.help})]})}function ZD({to:e}){let t=X();return(0,b.jsx)(q,{asChild:!0,variant:`outline`,size:`icon`,className:`shrink-0`,children:(0,b.jsx)(bo,{to:e,"aria-label":t(`form.back`),children:(0,b.jsx)(wv,{className:`ltr:rotate-180`})})})}function QD({schema:e,record:t,id:n,dirty:r,onGone:i,onChanged:a,extra:o,badges:s,subtitle:c}){let l=X(),u=Array.isArray(t?._links)?t._links:[];return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,b.jsx)(ZD,{to:`/${e.name}`}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:HD(e.label,t,n)}),s.map(e=>(0,b.jsx)($T,{value:t[e.name],field:e},e.name))]}),c.length>0&&(0,b.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:c.join(` · `)}),u.length>0&&(0,b.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[13px]`,children:u.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`,"aria-label":l(`form.externalLink`,{name:e.label}),children:[e.label,(0,b.jsx)(Jv,{className:`size-3.5 rtl:-scale-x-100`,"aria-hidden":!0})]})},`${e.label}:${e.href}`))})]}),(0,b.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[t&&n!==void 0&&(0,b.jsx)(cD,{schema:e,ids:[n]}),t&&n!==void 0&&(0,b.jsx)(sD,{schema:e,record:t,id:n,dirty:r,onGone:i,onChanged:a}),o]})]})}function $D({fields:e,before:t,current:n,busy:r,onKeepMine:i,onLoadTheirs:a}){let o=X(),s=e.filter(e=>JSON.stringify(t?.[e.name]??null)!==JSON.stringify(n[e.name]??null));return(0,b.jsxs)(`div`,{role:`alertdialog`,"aria-labelledby":`conflict-title`,"aria-describedby":`conflict-body`,className:`flex flex-col gap-3 rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm`,children:[(0,b.jsx)(`p`,{id:`conflict-title`,className:`font-medium`,children:o(`form.conflictTitle`)}),(0,b.jsx)(`div`,{id:`conflict-body`,children:s.length>0?(0,b.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:s.map(e=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsxs)(`dd`,{children:[(0,b.jsx)(`span`,{className:`line-through opacity-60`,children:jx(t?.[e.name],e)}),` → `,jx(n[e.name],e)]})]},e.name))}):(0,b.jsx)(`p`,{children:o(`form.conflictNone`)})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(q,{type:`button`,disabled:r,onClick:i,children:o(`form.keepMine`)}),(0,b.jsx)(q,{type:`button`,variant:`outline`,onClick:a,children:o(`form.loadTheirs`)})]})]})}function eO(){let{t:e}=Y(),{group:t}=$i(),n=Ug();if(n.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(n.isError)return(0,b.jsx)(G,{tone:`error`,children:n.error.message});let r=yw(n.data).find(e=>e.key===t);return r?(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:r.label}),(0,b.jsx)(nO,{group:r})]}):(0,b.jsx)(G,{children:e(`common.pageNotFound`)})}function tO({groups:e}){return(0,b.jsx)(`div`,{className:`flex flex-col gap-8`,children:e.map(e=>(0,b.jsxs)(`section`,{"aria-labelledby":`group-${e.key}`,className:`flex flex-col gap-3`,children:[(0,b.jsx)(`h2`,{id:`group-${e.key}`,className:`text-lg font-semibold`,children:(0,b.jsx)(bo,{to:`/g/${e.key}`,className:`hover:underline`,children:e.label})}),(0,b.jsx)(nO,{group:e})]},e.key))})}function nO({group:e}){return(0,b.jsxs)(b.Fragment,{children:[e.resources.length>0&&(0,b.jsx)(aO,{resources:e.resources}),e.pages.length>0&&(0,b.jsx)(iO,{pages:e.pages})]})}var rO=`flex items-center gap-3 rounded-card border bg-card shadow-card p-4 hover:bg-muted/50`;function iO({pages:e}){return(0,b.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=Yw(e.icon,`page`);return(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/p/${e.name}`,className:rO,children:[(0,b.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-md bg-muted`,children:(0,b.jsx)(t,{className:`size-5 text-muted-foreground`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`truncate font-medium`,children:e.label})]})},e.name)})})}function aO({resources:e}){let{t,locale:n}=Y(),r=ut({queries:e.map(e=>({queryKey:[`count`,e.name],queryFn:()=>Q.list(e.name,new URLSearchParams({pageSize:`1`})),staleTime:6e4}))});return(0,b.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map((e,i)=>{let a=Yw(e.icon,`resource`),o=r[i]?.data,s=o&&o.total!==null?t(o.estimated?`shell.aboutRecords`:`shell.records`,{count:Qh(o.total,n)}):void 0;return(0,b.jsx)(`li`,{children:(0,b.jsxs)(bo,{to:`/${e.name}`,className:rO,children:[(0,b.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-md bg-muted`,children:(0,b.jsx)(a,{className:`size-5 text-muted-foreground`,"aria-hidden":!0})}),(0,b.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,b.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),s&&(0,b.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:s})]})]})},e.name)})})}var oO=(e,t=2)=>String(e).padStart(t,`0`),sO=e=>`${oO(e.getFullYear(),4)}-${oO(e.getMonth()+1)}-${oO(e.getDate())}`,cO=e=>new Date(`${e}T00:00:00`).toISOString(),lO=(e,t)=>{let[n,r]=e.split(`-`).map(Number),i=n*12+(r-1)+t;return`${oO(Math.floor(i/12),4)}-${oO(i%12+1)}-01`};function uO(e,t,n,r,i){let a=sO(t),o=(t,n,r,i)=>({period:e,from:cO(t),to:cO(n),previousFrom:cO(r),previousTo:cO(i)}),s=(e,t)=>Math.round((Date.parse(`${t}T00:00:00Z`)-Date.parse(`${e}T00:00:00Z`))/864e5);switch(e){case`day`:return o(a,OS(a,1),OS(a,-1),a);case`week`:return o(OS(a,-6),OS(a,1),OS(a,-13),OS(a,-6));case`month`:{if(n===`persian`){let{jy:e,jm:t}=SS(a),n=CS(e,t,1);return o(n,DS(n,1),DS(n,-1),n)}let e=`${a.slice(0,7)}-01`;return o(e,lO(e,1),lO(e,-1),e)}case`year`:{if(n===`persian`){let{jy:e}=SS(a);return o(CS(e,1,1),CS(e+1,1,1),CS(e-1,1,1),CS(e,1,1))}let e=Number(a.slice(0,4));return o(`${oO(e,4)}-01-01`,`${oO(e+1,4)}-01-01`,`${oO(e-1,4)}-01-01`,`${oO(e,4)}-01-01`)}case`range`:{let e=r??a,t=OS(i??a,1);return o(e,t,OS(e,-s(e,t)),e)}}}function dO(e){if(e===void 0)return;let t=`${Math.abs(e)}%`;return e>0?{tone:`ok`,arrow:`up`,text:t}:e<0?{tone:`bad`,arrow:`down`,text:t}:{tone:`neutral`,arrow:null,text:t}}function fO(e,t,n){let r=Math.max(1,...e.series.flatMap(e=>e.values)),i=Math.max(1,e.labels.length),a=t/i,o=e=>n-e/r*n;return{max:r,gridlines:[.25,.5,.75,1].map(e=>({y:n-e*n,value:r*e})),series:e.series.map(e=>{let r=e.values.map((e,n)=>[i===1?t/2:n*t/(i-1),o(e)]);return{label:e.label,dashed:e.dashed===!0,path:r.map(([e,t],n)=>`${n===0?`M`:`L`}${pO(e)} ${pO(t)}`).join(` `),bars:e.values.map((e,t)=>{let r=a*.6;return{x:t*a+a/2-r/2,y:o(e),width:r,height:n-o(e)}})}})}}var pO=e=>Math.round(e*10)/10,mO=600,hO=200;function gO({title:e,data:t}){let n=X(),r=fO(t,mO,hO),i=Math.max(1,Math.ceil(t.labels.length/6));return(0,b.jsxs)(`div`,{className:`flex flex-col gap-3.5 p-5`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),t.subtitle&&(0,b.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t.subtitle})]}),(0,b.jsx)(`div`,{className:`ms-auto flex gap-4 text-xs text-muted-foreground`,children:t.series.map(e=>(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:e.dashed?`h-0 w-3.5 border-t-2 border-dashed border-muted-foreground`:`h-[3px] w-3.5 rounded-sm bg-primary`}),e.label]},e.label))})]}),(0,b.jsxs)(`svg`,{viewBox:`0 0 ${mO} ${hO}`,preserveAspectRatio:`none`,role:`img`,"aria-label":e,className:`h-[230px] w-full overflow-visible rtl:-scale-x-100`,children:[(0,b.jsx)(`g`,{className:`stroke-border`,children:r.gridlines.map(e=>(0,b.jsx)(`path`,{d:`M0 ${e.y}H${mO}`,vectorEffect:`non-scaling-stroke`},e.y))}),r.series.map((e,n)=>t.kind===`bar`&&!e.dashed?(0,b.jsx)(`g`,{className:`fill-primary`,children:e.bars.map((e,t)=>(0,b.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:3},t))},e.label):(0,b.jsxs)(`g`,{children:[!e.dashed&&n===0&&(0,b.jsx)(`path`,{d:`${e.path} L${mO} ${hO} L0 ${hO} Z`,className:`fill-primary/10`}),(0,b.jsx)(`path`,{d:e.path,fill:`none`,vectorEffect:`non-scaling-stroke`,strokeWidth:e.dashed?2:2.5,strokeDasharray:e.dashed?`5 5`:void 0,className:e.dashed||n>0?`stroke-muted-foreground`:`stroke-primary`})]},e.label))]}),(0,b.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-between text-[11.5px] text-muted-foreground`,children:t.labels.filter((e,t)=>t%i===0).map(e=>(0,b.jsx)(`span`,{children:e},e))}),(0,b.jsxs)(`span`,{className:`sr-only`,children:[t.series.map(e=>`${e.label}: ${e.values.map(e=>Qh(e)).join(`, `)}`).join(`; `),` `,n(`dashboard.period`)]})]})}var _O={ok:`bg-ok`,warn:`bg-warn`,bad:`bg-bad`,info:`bg-info`,neutral:`bg-muted-foreground`,primary:`bg-primary`};function vO({title:e,data:t}){return(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 p-5`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:t.items.map((e,t)=>{let n=Yw(e.icon,`resource`),r=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-control bg-muted text-muted-foreground`,children:(0,b.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:e.text}),e.status&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:W(`size-2 shrink-0 rounded-full`,_O[e.status])})]});return(0,b.jsx)(`li`,{children:e.link?(0,b.jsx)(bo,{to:e.link,className:`flex items-center gap-3 rounded-control hover:bg-muted`,children:r}):(0,b.jsx)(`div`,{className:`flex items-center gap-3`,children:r})},t)})})]})}function yO({items:e,value:t,onChange:n,className:r}){return(0,b.jsx)(`div`,{role:`tablist`,className:W(`flex w-full gap-0.5 border-b border-border`,r),children:e.map(e=>{let r=e.key===t;return(0,b.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.key),className:W(`-mb-px inline-flex h-[38px] cursor-pointer items-center gap-1.5 border-b-2 border-transparent px-3 text-[13px] text-muted-foreground`,r&&`border-foreground font-semibold text-foreground`),children:[e.label,e.count!==void 0&&(0,b.jsxs)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-muted px-1.5 text-[11px] text-muted-foreground`,children:[e.estimate?`~`:``,e.count]})]},e.key)})})}function bO({period:e,from:t,to:n,onChange:r}){let i=X(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(t??``),[l,u]=(0,y.useState)(n??``);return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(yO,{className:`w-auto`,items:[`day`,`week`,`month`,`year`].map(e=>({key:e,label:i(`dashboard.${e}`)})),value:e===`range`?``:e,onChange:e=>r(e)}),(0,b.jsxs)(Sh,{open:a,onOpenChange:o,children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsx)(q,{variant:e===`range`?`secondary`:`outline`,size:`icon`,"aria-label":i(`dashboard.range`),"aria-pressed":e===`range`,children:(0,b.jsx)(fv,{})})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{align:`end`,sideOffset:6,className:`z-50 flex w-72 flex-col gap-3 rounded-[10px] border bg-popover p-3 shadow-lg`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:`dashboard-from`,children:i(`filters.from`)}),(0,b.jsx)(IS,{id:`dashboard-from`,label:i(`filters.from`),value:s,onChange:c,live:!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(kh,{htmlFor:`dashboard-to`,children:i(`filters.to`)}),(0,b.jsx)(IS,{id:`dashboard-to`,label:i(`filters.to`),value:l,onChange:u,live:!0})]}),(0,b.jsx)(q,{disabled:!/^\d{4}-\d{2}-\d{2}$/.test(s)||!/^\d{4}-\d{2}-\d{2}$/.test(l)||s>l,onClick:()=>{o(!1),r(`range`,s,l)},children:i(`dashboard.apply`)})]})})]})]})}var xO=42,SO=2*Math.PI*xO;function CO({title:e,data:t}){let n=Math.max(0,Math.min(100,t.percent));return(0,b.jsxs)(`div`,{className:`flex items-center gap-5 p-5`,children:[(0,b.jsxs)(`svg`,{viewBox:`0 0 100 100`,role:`img`,"aria-label":$h(t.value),className:`size-[104px] shrink-0 -rotate-90`,children:[(0,b.jsx)(`circle`,{cx:`50`,cy:`50`,r:xO,fill:`none`,strokeWidth:10,className:`stroke-muted`}),(0,b.jsx)(`circle`,{cx:`50`,cy:`50`,r:xO,fill:`none`,strokeWidth:10,strokeLinecap:`round`,strokeDasharray:`${n/100*SO} ${SO}`,className:`stroke-primary`})]}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`text-2xl leading-tight font-bold`,children:$h(t.value)}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold`,children:e}),(0,b.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t.caption})]})]})}function wO({title:e,data:t}){let n=dO(t.change);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 py-[18px]`,children:[(0,b.jsx)(`div`,{className:`text-[13px] font-medium text-muted-foreground`,children:e}),(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[26px] leading-[1.3] font-bold`,children:$h(t.value)}),t.unit&&(0,b.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:t.unit})]}),(n||t.previousLabel)&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[n&&(0,b.jsxs)(`span`,{className:W(`inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 font-medium`,n.tone===`ok`?`bg-ok-bg text-ok`:n.tone===`bad`?`bg-bad-bg text-bad`:`bg-muted text-muted-foreground`),children:[n.arrow===`up`&&(0,b.jsx)(J_,{className:`size-3`,"aria-hidden":!0}),n.arrow===`down`&&(0,b.jsx)(W_,{className:`size-3`,"aria-hidden":!0}),$h(n.text)]}),t.previousLabel&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:t.previousLabel})]})]})}function TO({title:e,data:t}){let n=X(),r=t.link?`/${t.link.resource}${t.link.filter?`?${new URLSearchParams(t.link.filter)}`:``}`:void 0;return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2 border-b px-5 py-3`,children:[(0,b.jsx)(`h2`,{className:`flex-1 text-[15px] font-semibold`,children:e}),r&&(0,b.jsxs)(bo,{to:r,className:`inline-flex items-center gap-1 text-[13px] font-medium text-primary hover:underline`,children:[n(`dashboard.viewAll`),(0,b.jsx)(Sv,{className:`size-3.5 ltr:rotate-180`,"aria-hidden":!0})]})]}),(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,b.jsx)(`thead`,{className:`bg-[color-mix(in_oklab,var(--muted)_50%,transparent)] text-[12.5px] text-muted-foreground`,children:(0,b.jsx)(`tr`,{children:t.columns.map(e=>(0,b.jsx)(`th`,{className:`px-3.5 py-2.5 text-start font-medium whitespace-nowrap`,children:e.label},e.key))})}),(0,b.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,b.jsx)(`tr`,{className:`border-t`,children:t.columns.map(t=>{let n=e[t.key];return(0,b.jsx)(`td`,{className:`px-3.5 py-2.5 whitespace-nowrap`,children:typeof n==`object`&&n?(0,b.jsx)(XT,{tone:n.tone,children:n.label}):typeof n==`number`?Qh(n):$h(String(n??``))},t.key)})},n))})]})})]})}var EO=[`day`,`week`,`month`,`year`,`range`],DO={1:`lg:col-span-4`,2:`lg:col-span-6`,3:`lg:col-span-8`,4:`lg:col-span-12`};function OO(){let{t:e,calendar:t}=Y(),[n,r]=wo(),i=n.get(`period`),a=i&&EO.includes(i)?i:`week`,o=n.get(`from`)??void 0,s=n.get(`to`)??void 0,c=uO(a,new Date,t===`persian`?`persian`:`gregory`,o,s),l=ft({queryKey:[`dashboard`],queryFn:Q.dashboard});return(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:e(`dashboard.title`)}),(0,b.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:e(`dashboard.subtitle`)})]}),(0,b.jsx)(`div`,{className:`ms-auto`,children:(0,b.jsx)(bO,{period:a,from:o,to:s,onChange:(e,t,n)=>r(e===`range`?{period:e,from:t,to:n}:e===`week`?{}:{period:e})})})]}),l.isPending&&(0,b.jsx)(G,{children:e(`common.loading`)}),l.isError&&(0,b.jsx)(G,{tone:`error`,children:dg(l.error)}),l.data&&(0,b.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-12`,children:l.data.widgets.map(e=>(0,b.jsx)(kO,{widget:e,params:c},e.name))})]})}function kO({widget:e,params:t}){let{t:n}=Y(),r=ft({queryKey:[`dashboard`,e.name,t],queryFn:()=>Q.widget(e.name,t),retry:!1}),i=e.type===`stat`?`lg:col-span-3`:DO[e.size];return(0,b.jsxs)(`section`,{"aria-label":e.title,"data-widget":e.name,className:W(`min-w-0 overflow-hidden rounded-card border bg-card shadow-card`,i),children:[r.isPending&&(0,b.jsxs)(`div`,{"aria-hidden":!0,className:`flex flex-col gap-3 p-5`,children:[(0,b.jsx)(`div`,{className:`h-4 w-1/3 animate-pulse rounded bg-muted`}),(0,b.jsx)(`div`,{className:`h-8 w-2/3 animate-pulse rounded bg-muted`})]}),r.isError&&(0,b.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-5 text-[13px]`,children:[(0,b.jsx)(`span`,{className:`font-semibold`,children:e.title}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:n(`dashboard.failed`)}),(0,b.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void r.refetch(),children:n(`dashboard.retry`)})]}),r.data&&(0,b.jsx)(AO,{type:e.type,title:e.title,data:r.data})]})}function AO({type:e,title:t,data:n}){switch(e){case`stat`:return(0,b.jsx)(wO,{title:t,data:n});case`chart`:return(0,b.jsx)(gO,{title:t,data:n});case`table`:return(0,b.jsx)(TO,{title:t,data:n});case`progress`:return(0,b.jsx)(CO,{title:t,data:n});case`list`:return(0,b.jsx)(vO,{title:t,data:n})}}function jO(){let e=X(),t=Ug();if(t.isPending)return(0,b.jsx)(G,{children:e(`common.loading`)});if(t.isError)return(0,b.jsx)(G,{tone:`error`,children:t.error.message});if(t.data.dashboard)return(0,b.jsx)(OO,{});let n=yw(t.data);return n.length===0?(0,b.jsx)(G,{children:e(`shell.noResources`)}):(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:t.data.title}),(0,b.jsx)(tO,{groups:n})]})}var MO={order:[],hidden:[],widths:{},density:`comfortable`},NO=e=>`nma.columns.${e}`;function PO(e,t){return FO(e,t).filter(e=>!t.hidden.includes(e))}function FO(e,t){let n=t.order.filter(t=>e.includes(t));return[...n,...e.filter(e=>!n.includes(e))]}function IO(e){let t=new Map,n=new Set,r=n=>{let r=t.get(n);if(!r){r=MO;try{let t=e?.getItem(NO(n));t&&(r={...MO,...JSON.parse(t)})}catch{r=MO}t.set(n,r)}return r},i=(r,i)=>{t.set(r,i);try{e?.setItem(NO(r),JSON.stringify(i))}catch{}for(let e of n)e()};return{get:r,subscribe(e){return n.add(e),()=>n.delete(e)},toggle(e,t){let n=r(e),a=n.hidden.includes(t)?n.hidden.filter(e=>e!==t):[...n.hidden,t];i(e,{...n,hidden:a})},move(e,t,n,a){let o=r(e),s=FO(t,o),c=s.indexOf(n),l=c+a;c<0||l<0||l>=s.length||([s[c],s[l]]=[s[l],s[c]],i(e,{...o,order:s}))},setWidth(e,t,n){let a=r(e),o=Math.round(Math.min(600,Math.max(60,n)));i(e,{...a,widths:{...a.widths,[t]:o}})},setDensity(e,t){i(e,{...r(e),density:t})},reset(r){try{e?.removeItem(NO(r))}catch{}t.set(r,MO);for(let e of n)e()}}}function LO(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var RO=IO(LO());function zO(e){return(0,y.useSyncExternalStore)(RO.subscribe,()=>RO.get(e))}function BO({schema:e,prefs:t}){let n=X(),r=FO(e.list.columns,t),i=t=>e.list.computed?.[t]?.label??e.fields.find(e=>e.name===t)?.label??t,a=r.filter(e=>!t.hidden.includes(e));return(0,b.jsxs)(Sh,{children:[(0,b.jsx)(Ch,{asChild:!0,children:(0,b.jsxs)(q,{variant:`outline`,size:`sm`,className:`hidden md:inline-flex`,children:[(0,b.jsx)(Mv,{}),n(`list.columns`),(0,b.jsx)(bv,{className:`text-muted-foreground`})]})}),(0,b.jsx)(wh,{children:(0,b.jsxs)(Th,{align:`end`,sideOffset:4,className:`z-50 flex w-72 flex-col gap-3 rounded-[10px] border bg-popover p-3 text-popover-foreground shadow-lg`,children:[(0,b.jsx)(`ul`,{"aria-label":n(`list.columns`),className:`flex flex-col gap-0.5`,children:r.map((o,s)=>{let c=!t.hidden.includes(o);return(0,b.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md px-1 py-0.5 hover:bg-accent`,children:[(0,b.jsxs)(`label`,{className:`flex flex-1 cursor-pointer items-center gap-2 text-sm`,children:[(0,b.jsx)(ff,{checked:c,disabled:c&&a.length===1,onCheckedChange:()=>RO.toggle(e.name,o),className:`flex size-4 items-center justify-center rounded border border-input disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground`,children:(0,b.jsx)(mf,{children:(0,b.jsx)(vv,{className:`size-3`})})}),i(o)]}),(0,b.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":n(`list.moveUp`,{name:i(o)}),disabled:s===0,onClick:()=>RO.move(e.name,e.list.columns,o,-1),children:(0,b.jsx)(J_,{})}),(0,b.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":n(`list.moveDown`,{name:i(o)}),disabled:s===r.length-1,onClick:()=>RO.move(e.name,e.list.columns,o,1),children:(0,b.jsx)(W_,{})})]},o)})}),(0,b.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`list.density`),className:`flex gap-1`,children:[`comfortable`,`compact`].map(r=>(0,b.jsx)(q,{role:`radio`,"aria-checked":t.density===r,variant:t.density===r?`secondary`:`ghost`,size:`sm`,onClick:()=>RO.setDensity(e.name,r),children:n(r===`compact`?`list.compact`:`list.comfortable`)},r))}),(0,b.jsx)(q,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>RO.reset(e.name),children:n(`list.resetColumns`)})]})})]})}function VO({resource:e,column:t,label:n,width:r}){let i=X(),a=(0,y.useRef)(null);return(0,b.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i(`list.resize`,{name:n}),"aria-valuenow":r,tabIndex:0,className:W(`absolute inset-y-1 end-0 w-1.5 cursor-col-resize touch-none rounded bg-transparent hover:bg-border focus-visible:bg-ring`),onPointerDown:e=>{let t=e.currentTarget.parentElement;a.current={x:e.clientX,width:t.getBoundingClientRect().width,rtl:getComputedStyle(t).direction===`rtl`},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:n=>{if(!a.current)return;let r=(n.clientX-a.current.x)*(a.current.rtl?-1:1);RO.setWidth(e,t,a.current.width+r)},onPointerUp:()=>a.current=null,onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`)return;n.preventDefault();let i=r??n.currentTarget.parentElement.getBoundingClientRect().width,a=getComputedStyle(n.currentTarget).direction===`rtl`,o=n.key===`ArrowRight`!==a;RO.setWidth(e,t,i+(o?10:-10))},onClick:e=>e.stopPropagation()})}var HO=`h-7 w-full min-w-20 rounded-md border border-input bg-background px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 aria-invalid:border-destructive`;function UO({schema:e,item:t,field:n}){let r=X(),i=S(),[a,o]=(0,y.useState)(!1),s=xC([n],t)[n.name],[c,l]=(0,y.useState)(s),[u,d]=(0,y.useState)(null),f=pt({mutationFn:n=>Q.update(e.name,String(t._id),n,e.version?t[e.version]:void 0),onSuccess:n=>{i.setQueriesData({queryKey:[`list`,e.name]},e=>e&&{...e,items:e.items.map(e=>e._id===n._id?{...e,...n}:e)}),i.removeQueries({queryKey:[`record`,e.name,String(t._id)]}),o(!1),d(null)},onError:e=>{d(e instanceof ug?e.fields[n.name]?.join(` `)??e.message:e.message),l(s),o(!1)}});function p(t=c){if(t===s){o(!1);return}let{payload:r,errors:i}=CC([n],{[n.name]:t},{[n.name]:s}),a=rD(r,{[n.name]:e.form.constraints.update[n.name]??{}},`update`),l=i[n.name]??a[n.name];if(l){d(l.join(` `));return}f.mutate(r)}let m=e=>{e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),l(s),d(null),o(!1))},h=`cell-${e.name}-${String(t._id)}-${n.name}-error`,g={"aria-label":n.label,"aria-invalid":u?!0:void 0,"aria-describedby":u?h:void 0,autoFocus:!0,disabled:f.isPending,className:HO,onKeyDown:m},_;if(!a)_=(0,b.jsx)(`button`,{type:`button`,className:W(`-mx-1 rounded px-1 text-start hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,u&&`text-destructive`),"aria-label":r(`list.editCell`,{name:n.label,value:jx(t[n.name],n)}),onClick:()=>{l(s),o(!0)},children:(0,b.jsx)(eE,{value:t[n.name],field:n})});else if(n.type===`enum`||n.type===`boolean`){let e=n.type===`boolean`?[[`true`,r(`common.yes`)],[`false`,r(`common.no`)]]:(n.enumValues??[]).map(e=>[e,kC(n,e)]);_=(0,b.jsxs)(`select`,{...g,value:String(c),onChange:e=>{let t=n.type===`boolean`?e.target.value===`true`:e.target.value;l(t),p(t)},onBlur:()=>o(!1),children:[n.nullable&&n.type===`enum`&&(0,b.jsx)(`option`,{value:``,children:r(`common.empty`)}),e.map(([e,t])=>(0,b.jsx)(`option`,{value:e,children:t},e))]})}else if(n.type===`date`)_=(0,b.jsx)(IS,{id:`cell-${e.name}-${String(t._id)}-${n.name}`,label:n.label,value:String(c),onChange:e=>{l(e),p(e)},autoFocus:!0,"aria-invalid":u?!0:void 0,"aria-describedby":u?h:void 0,className:`min-w-44`,onKeyDown:m});else{let e=n.type===`number`||n.type===`decimal`||n.type===`bigint`;_=(0,b.jsx)(`input`,{...g,type:`text`,inputMode:e?n.type===`bigint`?`numeric`:`decimal`:void 0,value:String(c),onChange:e=>l(e.target.value),onBlur:()=>p()})}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[_,u&&(0,b.jsx)(`p`,{id:h,role:`alert`,className:`text-xs text-destructive`,children:u})]})}var WO=e=>e.total===null?e.hasMore===!0:e.page*e.pageSize<e.total;function GO({schema:e,query:t,columns:n,trash:r,selectMode:i,selected:a,onSelect:o,restore:s,empty:c}){let l=X(),u=e.list.pagination===`keyset`,d=mt({queryKey:[`list`,e.name,`cards`,t],initialPageParam:void 0,queryFn:({pageParam:n})=>{let r=new URLSearchParams(t);return n&&r.set(u?`after`:`page`,n),Q.list(e.name,r)},getNextPageParam:e=>u?e.nextCursor??void 0:WO(e)?String(e.page+1):void 0}),f=new Set,p=(d.data?.pages??[]).flatMap(e=>e.items).filter(e=>{let t=String(e._id);return!f.has(t)&&(f.add(t),!0)}),m=d.data?.pages[0]?.total??null,h=(0,y.useRef)(null),{hasNextPage:g,isFetchingNextPage:_,fetchNextPage:v}=d;(0,y.useEffect)(()=>{let e=h.current;if(!e||!g||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&!_&&v()},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[g,_,v]);let x=e=>{let t=new Set(a);t.has(e)?t.delete(e):t.add(e),o(t)};return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`ul`,{"aria-label":e.label,"aria-busy":d.isFetching,className:`flex flex-col gap-2.5`,children:[d.isPending&&Array.from({length:4},(e,t)=>(0,b.jsx)(`li`,{"aria-hidden":!0,className:`h-20 animate-pulse rounded-card border bg-muted/40`},`skeleton-${t}`)),p.map(t=>{let o=String(t._id),c=(0,b.jsx)(KO,{schema:e,item:t,columns:n});return(0,b.jsx)(`li`,{children:r?(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2 rounded-card border bg-card p-3 shadow-card`,children:[c,s(t)]}):i?(0,b.jsxs)(`label`,{className:W(`flex cursor-pointer items-start gap-3 rounded-card border bg-card p-3 shadow-card`,a.has(o)&&`border-primary bg-primary-soft`),children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-primary`,checked:a.has(o),onChange:()=>x(o),"aria-label":l(`list.selectRow`,{name:String(t._title??o)})}),c]}):(0,b.jsx)(bo,{to:`/${e.name}/${encodeURIComponent(o)}`,className:`block rounded-card border bg-card p-3 shadow-card active:bg-muted`,children:c})},o)}),d.isSuccess&&p.length===0&&(0,b.jsx)(`li`,{className:`flex flex-col items-center gap-2 py-6 text-center text-sm text-muted-foreground`,children:c})]}),d.isError&&(0,b.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[(0,b.jsx)(`span`,{children:l(`list.loadFailed`)}),(0,b.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void d.refetch(),children:l(`list.retry`)})]}),(0,b.jsxs)(`div`,{ref:h,className:`flex flex-col items-center gap-2 py-2 text-sm text-muted-foreground`,children:[p.length>0&&(0,b.jsx)(`span`,{children:m===null?l(`list.showing`,{shown:Qh(p.length)}):l(`list.showingOf`,{shown:Qh(p.length),total:Qh(m)})}),g&&(0,b.jsx)(q,{variant:`outline`,size:`sm`,disabled:_,onClick:()=>void v(),children:l(_?`common.loading`:`list.loadMore`)})]})]})}function KO({schema:e,item:t,columns:n}){let r=Object.entries(e.list.computed??{}).filter(([t])=>e.list.columns.includes(t));if(r.length>0)return(0,b.jsx)(qO,{schema:e,item:t,computed:r});let i=e.list.mobile,a=typeof t._title==`string`?t._title:String(t._id);if(!i)return(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`div`,{className:`text-[14.5px] font-semibold`,children:a}),(0,b.jsx)(`dl`,{className:`mt-1 grid grid-cols-2 gap-x-3 gap-y-0.5 text-sm`,children:n.filter(e=>jx(t[e.name],e)!==t._title).map(e=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`truncate`,children:(0,b.jsx)(eE,{value:t[e.name],field:e,record:t,plain:!0})})]},e.name))})]});let o=t=>t?e.fields.find(e=>e.name===t):void 0,s=o(i.title),c=o(i.subtitle),l=o(i.badge),u=i.meta.map(o).filter(e=>e!==void 0);return(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-[14.5px] font-semibold`,children:s?jx(t[s.name],s):a}),l&&t[l.name]!==null&&t[l.name]!==void 0&&(0,b.jsx)($T,{value:t[l.name],field:l,className:`shrink-0`})]}),c&&(0,b.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:jx(t[c.name],c)}),u.length>0&&(0,b.jsx)(`dl`,{className:`mt-1 flex flex-wrap gap-x-4 gap-y-0.5 text-sm`,children:u.map(e=>(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{children:(0,b.jsx)(eE,{value:t[e.name],field:e,record:t,plain:!0})})]},e.name))})]})}function qO({schema:e,item:t,computed:n}){let r=e=>n.filter(([,t])=>t.kind===e),i=([n,r],i=!0)=>(0,b.jsx)(yD,{schema:e,name:n,column:r,item:t,compact:i},n),[a]=r(`image`),[o]=r(`title`);return(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[a&&i(a),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,b.jsx)(`div`,{className:`min-w-0 flex-1`,children:o?i(o):(0,b.jsx)(`span`,{className:`text-[14.5px] font-semibold`,children:typeof t._title==`string`?t._title:String(t._id)})}),r(`toggle`).map(e=>i(e))]}),r(`money`).map(e=>i(e)),(r(`badge`).length>0||r(`count`).length>0)&&(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[r(`badge`).map(e=>i(e)),r(`count`).map(([e,n])=>(0,b.jsxs)(XT,{tone:`neutral`,children:[vD(n,t._computed?.[e]).text,` `,n.label]},e))]})]})]})}function JO({schema:e,item:t,onClose:n}){let r=X(),i=(0,y.useRef)(null);t&&!i.current&&(i.current=document.activeElement);let a=t?String(t._id):void 0,o=Jg(e.name,a).data??t,s=typeof o?._title==`string`?o._title:`#${a}`,c=e.fields.filter(e=>e.persisted&&!e.name.includes(`.`)&&o!==void 0&&Object.hasOwn(o,e.name));return(0,b.jsx)(jd,{open:t!==void 0,onOpenChange:e=>!e&&n(),children:(0,b.jsxs)(Ld,{children:[(0,b.jsx)(zd,{className:`fixed inset-0 z-40 bg-black/30`}),(0,b.jsxs)(Ud,{className:`fixed inset-y-0 end-0 z-50 flex w-full max-w-md flex-col border-s bg-background shadow-xl outline-none`,"aria-describedby":void 0,onCloseAutoFocus:e=>{e.preventDefault(),i.current?.focus(),i.current=null},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 border-b p-4`,children:[(0,b.jsx)(Jd,{className:`min-w-0 flex-1 truncate text-lg font-semibold`,children:r(`list.quickView`,{name:s})}),(0,b.jsx)(Xd,{asChild:!0,children:(0,b.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":r(`list.close`),children:(0,b.jsx)(bx,{})})})]}),(0,b.jsx)(`dl`,{className:`grid flex-1 grid-cols-[minmax(6rem,auto)_1fr] content-start gap-x-4 gap-y-2 overflow-y-auto p-4 text-sm`,children:c.map(e=>(0,b.jsxs)(`div`,{className:`contents`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,b.jsx)(`dd`,{className:`break-words`,children:(0,b.jsx)(eE,{value:o[e.name],field:e,record:o,detailed:!0})})]},e.name))}),(0,b.jsxs)(`div`,{className:`flex gap-2 border-t p-4`,children:[(0,b.jsx)(q,{asChild:!0,children:(0,b.jsxs)(bo,{to:`/${e.name}/${encodeURIComponent(a??``)}`,children:[(0,b.jsx)(ib,{}),r(`list.edit`)]})}),(0,b.jsx)(Xd,{asChild:!0,children:(0,b.jsx)(q,{variant:`outline`,children:r(`list.close`)})})]})]})]})})}function YO({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full`,children:(0,b.jsx)(`table`,{"data-slot":`table`,className:W(`w-full caption-bottom text-[13px]`,e),...t})})}function XO({className:e,...t}){return(0,b.jsx)(`thead`,{"data-slot":`table-header`,className:W(`[&_tr]:border-b`,e),...t})}function ZO({className:e,...t}){return(0,b.jsx)(`tbody`,{"data-slot":`table-body`,className:W(`[&_tr:last-child]:border-0`,e),...t})}function QO({className:e,...t}){return(0,b.jsx)(`tr`,{"data-slot":`table-row`,className:W(`border-b border-border transition-colors hover:bg-[color-mix(in_oklab,var(--muted)_60%,transparent)] has-aria-expanded:bg-muted/50 data-[state=selected]:bg-primary-soft`,e),...t})}function $O({className:e,...t}){return(0,b.jsx)(`th`,{"data-slot":`table-head`,className:W(`px-3.5 py-2.5 text-start align-middle text-[12.5px] font-medium whitespace-nowrap text-muted-foreground bg-[color-mix(in_oklab,var(--muted)_50%,transparent)] [&:has([role=checkbox])]:pe-0`,e),...t})}function ek({className:e,...t}){return(0,b.jsx)(`td`,{"data-slot":`table-cell`,className:W(`px-3.5 py-2.5 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0`,e),...t})}function tk(e){let t=e.map(e=>String(e).replace(/~/g,`~0`).replace(/,/g,`~1`)).join(`,`);return t===`new`?`~new`:t}function nk(){let{resource:e=``}=$i(),[t,n]=wo(),r=Math.max(1,Number(t.get(`page`))||1),i=t.get(`sort`)??void 0,a=Wg(e),o=DC(),s=qg(e,GS(t),!o),[c,l]=(0,y.useState)(!1),u=S(),d=X(),f=pt({mutationFn:t=>Q.restore(e,t),onSuccess:()=>u.invalidateQueries({queryKey:[`list`,e]})}),p=t.get(`trashed`)===`only`,m=zO(e),h=GS(t),g=(()=>{let e=new URLSearchParams(h);return e.delete(`page`),e.delete(`after`),e.toString()})(),[_,v]=(0,y.useState)(new Set);(0,y.useEffect)(()=>v(new Set),[h,e]);let[x,C]=(0,y.useState)(),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)();(0,y.useEffect)(()=>D(void 0),[e]);let O=pt({mutationFn:t=>Q.bulkDelete(e,t),onSuccess:async t=>{v(new Set),T(!1),D({title:d(`list.bulkDeleted`,{count:t.ok.length}),result:t}),await u.invalidateQueries({queryKey:[`list`,e]})},onError:()=>T(!1)}),[k,A]=(0,y.useState)([]),j=t.has(`after`);if((0,y.useEffect)(()=>{j||A([])},[j]),a.isPending)return(0,b.jsx)(G,{children:d(`common.loading`)});if(a.isError)return(0,b.jsx)(G,{tone:`error`,children:a.error.message});let M=a.data,N=PO(M.list.columns,m).flatMap(e=>{let t=M.list.computed?.[e];if(t)return[{name:e,label:t.label,computed:t}];let n=M.fields.find(t=>t.name===e);return n?[{name:e,label:n.label,field:n}]:[]}),ee=N.flatMap(e=>e.field&&!M.primaryKeys.includes(e.name)?[e.field]:[]);for(let e=N.length-2;e>=0;e--)N[e].computed?.kind===`image`&&N[e+1].computed?.kind===`title`&&(N[e+1]={...N[e+1],image:N[e]},N.splice(e,1));let te=N.findIndex(e=>e.computed?.kind!==`image`&&e.computed?.kind!==`toggle`),P=i?{field:i.replace(/^-/,``),direction:i.startsWith(`-`)?`desc`:`asc`}:M.list.defaultSort,ne=s.data?.items??[],re=M.list.pagination===`keyset`,ie=t.get(`after`),ae=re?{summary:XS(s.data,1).summary,label:d(`list.page`,{page:k.length+1}),hasNext:!!s.data?.nextCursor}:XS(s.data,r),oe=re?k.length>0:r>1;function se(){if(!re)return fe({page:String(r+1)});A([...k,ie??``]),fe({after:s.data?.nextCursor??null})}function ce(){if(!re)return fe({page:String(r-1)});let e=k[k.length-1];A(k.slice(0,-1)),fe({after:e||null})}let le=M.permissions??{create:!0,update:!0,delete:!0,purge:!0},F=!p&&(le.delete||VE(M,[]).length>0||(M.prints??[]).some(e=>e.bulk)),ue=VE(M,ne.filter(e=>_.has(String(e._id)))),de=e=>`/${M.name}/${encodeURIComponent(String(e._id))}`;function fe(e){n(t=>YS(t,e))}function pe(e){fe({sort:P.field===e&&P.direction===`asc`?`-${e}`:e})}let me=`border-transparent bg-transparent text-inherit hover:bg-background/15`,I=F&&_.size>0&&(0,b.jsxs)(`div`,{role:`region`,"aria-label":d(`list.selected`,{count:_.size}),className:W(`flex flex-wrap items-center gap-2 text-sm`,o?`fixed inset-x-3 bottom-4 z-30 rounded-[14px] bg-foreground py-1.5 ps-2 pe-1.5 text-background shadow-[0_12px_32px_rgba(0,0,0,.25)]`:`border-b bg-primary-soft px-3.5 py-2`),children:[(0,b.jsx)(`span`,{className:W(`font-semibold`,o?`flex-1 text-sm`:`pe-1.5 text-primary`),children:d(`list.selected`,{count:_.size})}),(0,b.jsx)(cD,{schema:M,ids:[..._],bulkOnly:!0,size:`sm`}),ue.map(e=>(0,b.jsx)(oD,{resource:M.name,action:e,ids:[..._],size:`sm`,className:o?me:void 0,onDone:(t,n)=>{let r=qE(t,n);v(new Set),O.reset(),D({title:d(`action.bulkDone`,{action:e.label,count:r.ok.length}),result:r})}},e.name)),le.delete?w?(0,b.jsx)(q,{variant:`destructive`,size:`sm`,disabled:O.isPending,onClick:()=>O.mutate([..._]),children:d(`list.confirmDeleteSelected`,{count:_.size})}):(0,b.jsxs)(q,{variant:`outline`,size:o?`icon-sm`:`sm`,className:o?me:`text-destructive`,"aria-label":o?d(`list.deleteSelected`):void 0,onClick:()=>T(!0),children:[(0,b.jsx)(ex,{}),!o&&d(`list.deleteSelected`)]}):null,(0,b.jsx)(q,{variant:`ghost`,size:o?`icon-sm`:`sm`,className:o?W(me,`-order-1`):`ms-auto`,"aria-label":o?d(`list.clearSelection`):void 0,onClick:()=>v(new Set),children:o?(0,b.jsx)(bx,{}):d(`list.clearSelection`)})]});return(0,b.jsxs)(`div`,{className:W(`flex flex-col gap-4`,o&&_.size>0&&`pb-16`),children:[(0,b.jsxs)(`div`,{className:W(`flex flex-wrap gap-3`,o?`items-center gap-2`:`items-end`),children:[(0,b.jsxs)(`div`,{className:W(`flex gap-0.5`,o?`items-baseline gap-1.5`:`flex-col`),children:[(0,b.jsx)(`h1`,{className:o?`text-base font-semibold`:`text-[22px] font-bold`,children:M.label}),s.data&&s.data.total!==null&&(0,b.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:XS(s.data,r).summary})]}),(0,b.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[M.softDelete&&le.delete&&(0,b.jsxs)(q,{variant:p?`secondary`:`outline`,size:o?`icon`:`default`,"aria-pressed":p,"aria-label":o?d(`list.trash`):void 0,onClick:()=>fe({trashed:p?null:`only`}),children:[(0,b.jsx)(ex,{}),!o&&d(`list.trash`)]}),o&&F&&(0,b.jsx)(q,{variant:c?`secondary`:`outline`,size:`icon`,"aria-pressed":c,"aria-label":d(c?`list.done`:`list.select`),onClick:()=>{l(!c),v(new Set)},children:(0,b.jsx)(Ay,{})}),!p&&HE(M).map(e=>(0,b.jsx)(oD,{resource:M.name,action:e,onDone:()=>void 0},e.name)),!p&&(0,b.jsx)(lD,{schema:M,query:sk(t),iconOnly:o}),M.creatable&&!p&&(0,b.jsx)(q,{asChild:!0,size:o?`icon`:`default`,className:W(o&&`size-10`),children:(0,b.jsxs)(bo,{to:`/${M.name}/new`,"aria-label":o?d(`list.new`):void 0,children:[(0,b.jsx)(fb,{}),!o&&d(`list.new`)]})})]})]}),M.list.tabs&&M.list.tabs.length>0&&!p&&(0,b.jsx)(rk,{schema:M,params:t,onChange:fe}),(0,b.jsx)(MC,{schema:M,params:t,onChange:fe,trailing:(0,b.jsx)(BO,{schema:M,prefs:m})}),s.isError&&(0,b.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[(0,b.jsxs)(`span`,{children:[d(`list.loadFailed`),` `,dg(s.error)]}),(0,b.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:d(`list.retry`)})]}),f.isError&&(0,b.jsx)(G,{tone:`error`,children:dg(f.error)}),p&&(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(`list.trashNote`)}),o&&I,E&&(0,b.jsx)(ok,{title:E.title,result:E.result,items:ne}),O.isError&&(0,b.jsx)(G,{tone:`error`,children:dg(O.error)}),o?(0,b.jsx)(GO,{schema:M,query:g,columns:ee,trash:p,selectMode:c,selected:_,onSelect:v,restore:e=>(0,b.jsx)(ak,{item:e,pending:f.isPending,onRestore:e=>f.mutate(e)}),empty:(0,b.jsxs)(b.Fragment,{children:[d(qS(t)?`list.noMatches`:`list.noRecords`),!qS(t)&&M.creatable&&!p&&(0,b.jsx)(q,{asChild:!0,size:`sm`,variant:`outline`,children:(0,b.jsxs)(bo,{to:`/${M.name}/new`,children:[(0,b.jsx)(fb,{}),d(`list.new`)]})})]})}):(0,b.jsx)(b.Fragment,{children:(0,b.jsxs)(`section`,{className:`overflow-hidden rounded-card border bg-card shadow-card`,children:[I,(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(YO,{className:W(m.density===`compact`&&`[&_td]:py-1 [&_th]:h-8`),children:[(0,b.jsx)(XO,{children:(0,b.jsxs)(QO,{children:[F&&(0,b.jsx)($O,{className:`w-0`,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":d(`list.selectPage`),checked:ne.length>0&&ne.every(e=>_.has(String(e._id))),onChange:e=>v(e.target.checked?new Set(ne.map(e=>String(e._id))):new Set)})}),N.map(e=>(0,b.jsxs)($O,{className:`relative`,style:m.widths[e.name]?{width:m.widths[e.name],minWidth:m.widths[e.name]}:void 0,"aria-sort":P.field===e.name?P.direction===`asc`?`ascending`:`descending`:void 0,children:[M.list.sortable.includes(e.name)?(0,b.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1`,onClick:()=>pe(e.name),children:[e.label,P.field===e.name&&(P.direction===`asc`?(0,b.jsx)(J_,{className:`size-3.5`}):(0,b.jsx)(W_,{className:`size-3.5`}))]}):e.label,(0,b.jsx)(VO,{resource:M.name,column:e.name,label:e.label,width:m.widths[e.name]})]},e.name)),p&&(0,b.jsx)($O,{className:`w-0`,children:(0,b.jsx)(`span`,{className:`sr-only`,children:d(`list.actions`)})})]})}),(0,b.jsxs)(ZO,{children:[s.isPending&&Array.from({length:5},(e,t)=>(0,b.jsxs)(QO,{"aria-hidden":!0,children:[F&&(0,b.jsx)(ek,{}),N.map(e=>(0,b.jsx)(ek,{children:(0,b.jsx)(`div`,{className:`h-4 w-3/4 animate-pulse rounded bg-muted`})},e.name))]},`skeleton-${t}`)),ne.map(e=>(0,b.jsxs)(QO,{"data-state":_.has(String(e._id))?`selected`:void 0,className:p?void 0:`cursor-pointer focus-visible:bg-muted/50 focus-visible:outline-none`,tabIndex:p?void 0:0,onClick:p?void 0:()=>C(e),onKeyDown:p?void 0:t=>{t.key===`Enter`&&t.target===t.currentTarget&&(t.preventDefault(),C(e))},children:[F&&(0,b.jsx)(ek,{onClick:e=>e.stopPropagation(),children:(0,b.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":d(`list.selectRow`,{name:String(e._title??e._id)}),checked:_.has(String(e._id)),onChange:t=>{let n=new Set(_);t.target.checked?n.add(String(e._id)):n.delete(String(e._id)),v(n)}})}),N.map((t,n)=>(0,b.jsx)(ek,{children:t.computed?(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t.image&&(0,b.jsx)(yD,{schema:M,name:t.image.name,column:t.image.computed,item:e}),n===te&&!p?(0,b.jsx)(bo,{to:de(e),className:`min-w-0 hover:underline`,onClick:e=>e.stopPropagation(),children:(0,b.jsx)(yD,{schema:M,name:t.name,column:t.computed,item:e})}):(0,b.jsx)(yD,{schema:M,name:t.name,column:t.computed,item:e})]}):n===te&&!p?(0,b.jsx)(bo,{to:de(e),className:`font-semibold hover:underline`,onClick:e=>e.stopPropagation(),children:jx(e[t.name],t.field)}):!p&&M.list.editable.includes(t.name)&&!(Array.isArray(e._readonly)&&e._readonly.includes(t.name))&&e._perm?.update!==!1?(0,b.jsx)(UO,{schema:M,item:e,field:t.field}):(0,b.jsx)(ik,{value:e[t.name],field:t.field,record:e})},t.name)),p&&(0,b.jsx)(ek,{children:(0,b.jsx)(ak,{item:e,pending:f.isPending,onRestore:e=>f.mutate(e)})})]},String(e._id))),s.isSuccess&&ne.length===0&&(0,b.jsx)(QO,{children:(0,b.jsx)(ek,{colSpan:N.length+(p||F?1:0),className:`text-center text-muted-foreground`,children:(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6`,children:[d(qS(t)?`list.noMatches`:`list.noRecords`),!qS(t)&&M.creatable&&!p&&(0,b.jsx)(q,{asChild:!0,size:`sm`,variant:`outline`,children:(0,b.jsxs)(bo,{to:`/${M.name}/new`,children:[(0,b.jsx)(fb,{}),d(`list.new`)]})})]})})})]})]})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t px-3.5 py-2.5 text-[13px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:ZS(s.data,re?1:r,ne.length)||ae.summary}),(0,b.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[!re&&(0,b.jsxs)(`label`,{className:`flex items-center gap-2`,children:[d(`list.rowsPerPage`),(0,b.jsx)(`select`,{className:`h-8 rounded-lg border border-input bg-card px-2 text-[12.5px] text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:s.data?.pageSize??M.list.pageSize,onChange:e=>fe({pageSize:Number(e.target.value)===M.list.pageSize?null:e.target.value}),children:QS(M.list.pageSize).map(e=>(0,b.jsx)(`option`,{value:e,children:Qh(e)},e))})]}),(0,b.jsx)(`span`,{children:ae.label}),(0,b.jsx)(q,{variant:`outline`,size:`icon-sm`,"aria-label":d(`list.previousPage`),disabled:!oe,onClick:ce,children:(0,b.jsx)(Sv,{className:`rtl:rotate-180`})}),(0,b.jsx)(q,{variant:`outline`,size:`icon-sm`,"aria-label":d(`list.nextPage`),disabled:!ae.hasNext,onClick:se,children:(0,b.jsx)(wv,{className:`rtl:rotate-180`})})]})]})]})}),(0,b.jsx)(JO,{schema:M,item:x,onClose:()=>C(void 0)})]})}function rk({schema:e,params:t,onChange:n}){let r=ft({queryKey:[`list`,e.name,`tab-counts`],queryFn:()=>Q.tabCounts(e.name)}),i=e.list.tabs,a=nC(i,t);return(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsx)(yO,{items:i.map(e=>{let t=r.data?.[e.key];return{key:e.key,label:e.label,...t?{count:Qh(t.count),estimate:t.estimate}:{}}}),value:a?.key??``,onChange:e=>n(rC(i.find(t=>t.key===e),t))})})}function ik({value:e,field:t,record:n}){let r=t.relation?.resource;if(!r||e==null)return(0,b.jsx)(eE,{value:e,field:t,record:n});let i=(Array.isArray(e)?e:[e]).filter(uC);return i.length===0?(0,b.jsx)(b.Fragment,{children:jx(e,t)}):(0,b.jsx)(b.Fragment,{children:i.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&`, `,(0,b.jsx)(bo,{to:`/${r}/${encodeURIComponent(tk([e.id]))}`,className:`hover:underline`,onClick:e=>e.stopPropagation(),children:e.title})]},String(e.id)))})}function ak({item:e,pending:t,onRestore:n}){let r=X();return(0,b.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,disabled:t,"aria-label":r(`list.restoreRecord`,{name:String(e._title??e._id)}),onClick:()=>n(String(e._id)),children:[(0,b.jsx)(Sb,{}),r(`list.restore`)]})}function ok({title:e,result:t,items:n}){let r=X(),i=e=>{let t=n.find(t=>String(t._id)===e);return typeof t?._title==`string`?t._title:`#${e}`};return(0,b.jsxs)(`div`,{role:`status`,className:`rounded-lg border px-3 py-2 text-sm`,children:[(0,b.jsxs)(`p`,{children:[e,t.failed.length>0&&` · ${r(`list.bulkFailed`,{count:t.failed.length})}`]}),t.failed.length>0&&(0,b.jsx)(`ul`,{className:`mt-1 list-disc ps-5 text-destructive`,children:t.failed.map(e=>(0,b.jsxs)(`li`,{children:[i(e.id),`: `,e.message]},e.id))})]})}function sk(e){let t=new URLSearchParams(e);for(let e of[`page`,`pageSize`,`after`])t.delete(e);return t}function ck(){let e=X();return(0,b.jsx)(G,{children:e(`common.pageNotFound`)})}function lk(e){let t=xC(e.schema.fields.filter(e=>!e.secret),{...e.values,_files:e.files});for(let n of e.schema.fields)n.secret&&(t[n.name]=``);return t}function uk(e,t,n){let r=e.filter(e=>XE(e,t)),i=r.filter(e=>!e.secret),{payload:a,errors:o}=CC(i,t,n),s=CC(i.filter(e=>e.type===`object`&&!e.many&&Object.hasOwn(a,e.name)),t);Object.assign(a,s.payload),Object.assign(o,s.errors);for(let e of r){if(!e.secret)continue;let n=t[e.name];n===null?a[e.name]=null:typeof n==`string`&&n.trim()!==``&&(a[e.name]=n)}return{payload:a,errors:o}}function dk(e,t){let n=new Set(t.fields.filter(e=>e.secret).map(e=>e.name)),r=Object.entries(t.constraints).filter(([t])=>Object.hasOwn(e,t.split(`.`)[0])),i=r.filter(([e])=>!e.includes(`.`)).map(([e,t])=>[e,n.has(e)?{...t,required:!1}:t]),a=r.filter(([e])=>e.includes(`.`));return{...rD(e,Object.fromEntries(a),`create`),...rD(e,Object.fromEntries(i),`update`)}}function fk(){let e=X(),{page:t=``}=$i(),n=Kg(t);return n.isPending?(0,b.jsx)(G,{children:e(`common.loading`)}):n.isError?(0,b.jsx)(G,{tone:`error`,children:dg(n.error)}):(0,b.jsx)(pk,{page:n.data},t)}function pk({page:e}){let t=X(),{locale:n}=Y(),r=S(),{schema:i}=e,a=i.fields.map(e=>e.name),[o,s]=(0,y.useState)(()=>lk(e)),[c,l]=(0,y.useState)(o),[u,d]=(0,y.useState)([]),[f,p]=(0,y.useState)({}),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),v=pD(()=>h(null)),x=JSON.stringify(c)!==JSON.stringify(o),{blocker:C}=uD(x),w=(0,y.useRef)(null);fD(w);let T=(e,t)=>l(n=>({...n,[e]:t})),E=pt({mutationFn:e=>Q.savePage(i.name,e),gcTime:0,onSuccess:e=>{E.reset();let a=lk(e);r.setQueryData([`page`,i.name,n],e),s(a),l(a),d([]),p({}),_(t(`form.savedName`,{name:e.schema.label}))},onError:e=>{let t=JE(e,a);p(t.fields),h(t.form)}});function D(e){if(e.preventDefault(),i.readonly)return;if(_(null),v.busy){h(t(`upload.busy`)),v.refuse();return}let{payload:n,errors:r}=uk(i.fields,c,o),a={...dk(n,i),...r};if(p(a),h(null),!(Object.keys(a).length>0)){if(Object.keys(n).length===0){l(o),d([]);return}E.mutate(n)}}let O={...e.values,_files:e.files};function k(t){let n=i.fields.find(e=>e.name===t);if(!n||!XE(n,c))return null;let r=i.required.includes(t);return n.secret?(0,b.jsx)(mk,{field:n,stored:e.secrets[t]===!0,value:c[t],replacing:u.includes(t),readOnly:i.readonly,required:r,errors:f[t],onChange:e=>T(t,e),onReplacing:e=>d(n=>e?[...n,t]:n.filter(e=>e!==t))}):i.readonly?(0,b.jsx)(XD,{resource:`page:${i.name}`,field:n,record:O}):n.type===`object`?(0,b.jsx)(LE,{resource:`page:${i.name}`,field:n,path:t,pattern:t,value:c[t],constraints:i.constraints,markRequired:!0,errors:f,onChange:e=>T(t,e)}):(0,b.jsx)(EE,{resource:`page:${i.name}`,field:n,value:c[t],required:r,errors:f[t],constraints:i.constraints[t],onChange:e=>T(t,e),onBusy:e=>v.setBusy(t,e)})}return(0,b.jsxs)(`form`,{ref:w,onSubmit:D,noValidate:!0,className:W(`flex flex-col gap-5`,i.layout?.length?`max-w-4xl`:`max-w-2xl`),children:[(0,b.jsx)(`h1`,{className:`text-[22px] font-bold`,children:i.label}),i.readonly&&(0,b.jsx)(`p`,{role:`note`,className:`rounded-md border bg-muted/40 px-3 py-2 text-sm text-muted-foreground`,children:t(`settings.viewOnly`)}),g&&(0,b.jsx)(`p`,{role:`status`,className:`rounded-md border border-green-600/30 bg-green-500/10 px-3 py-2 text-sm`,children:g}),(0,b.jsx)(dD,{blocker:C}),m&&(0,b.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:m}),(0,b.jsx)(AE,{layout:i.layout,names:a,errors:f,render:k}),!i.readonly&&(0,b.jsxs)(mD,{dirty:x,children:[x&&(0,b.jsx)(q,{type:`button`,variant:`outline`,disabled:E.isPending,onClick:()=>{l(o),d([]),p({}),h(null)},children:t(`settings.discard`)}),(0,b.jsxs)(q,{type:`submit`,disabled:E.isPending||v.busy,"aria-keyshortcuts":`Control+S Meta+S`,children:[t(E.isPending?`form.saving`:`form.save`),(0,b.jsx)(hD,{})]})]})]})}function mk({field:e,stored:t,value:n,replacing:r,readOnly:i,required:a,errors:o,onChange:s,onReplacing:c}){let l=X(),u=`field-${e.name}`,d=`${u}-label`,f=`${u}-help`,p=`${u}-error`,m=(o?.length??0)>0,h=[e.help?f:void 0,m?p:void 0].filter(Boolean).join(` `)||void 0,g=n===null,_=!i&&!g&&(!t||r);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-secret":e.name,children:[(0,b.jsxs)(`label`,{id:d,htmlFor:_?u:void 0,className:`text-sm font-medium`,children:[e.label,a&&(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-destructive`,children:`*`})]}),_?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(Oh,{id:u,type:`password`,autoComplete:`new-password`,dir:`ltr`,className:`min-w-0 flex-1`,value:typeof n==`string`?n:``,autoFocus:r,"aria-invalid":m?!0:void 0,"aria-describedby":h,onChange:e=>s(e.target.value)}),t&&(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{s(``),c(!1)},children:l(`secret.keep`)})]}):(0,b.jsx)(`div`,{role:`group`,"aria-labelledby":d,"aria-describedby":h,className:`flex min-h-8 flex-wrap items-center gap-2 text-sm`,children:g?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`text-amber-800 dark:text-amber-300`,children:l(`secret.willClear`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>s(``),children:l(`secret.undo`)})]}):t?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-green-800 dark:text-green-300`,children:[l(`secret.set`),(0,b.jsx)(vv,{className:`size-4`,"aria-hidden":!0})]}),!i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,"aria-label":l(`secret.replaceName`,{name:e.label}),onClick:()=>c(!0),children:l(`secret.replace`)}),(0,b.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":l(`secret.clearName`,{name:e.label}),onClick:()=>s(null),children:l(`secret.clear`)})]})]}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:l(`secret.notSet`)})}),e.help&&(0,b.jsx)(`p`,{id:f,className:`text-sm text-muted-foreground`,children:e.help}),m&&(0,b.jsx)(`p`,{id:p,className:`text-sm text-destructive`,children:o.join(` `)})]})}document.title=lg.title,jw(Ow()),Rw(lg.branding),qw({branding:lg.branding.primaryColor}),Dx(lg.currency),Fw(Ow);var hk=new Qe({defaultOptions:{queries:{retry:1,staleTime:3e4}}}),gk=_o([{path:`login`,element:(0,b.jsx)(KT,{})},{element:(0,b.jsx)(HT,{}),children:[{index:!0,element:(0,b.jsx)(jO,{})},{path:`account`,element:(0,b.jsx)(g_,{})},{path:`-/users`,element:(0,b.jsx)(gw,{})},{path:`-/users/new`,element:(0,b.jsx)(_w,{})},{path:`-/users/:id`,element:(0,b.jsx)(_w,{})},{path:`-/groups`,element:(0,b.jsx)(rw,{})},{path:`-/groups/new`,element:(0,b.jsx)(iw,{})},{path:`-/groups/:id`,element:(0,b.jsx)(iw,{})},{path:`-/roles`,element:(0,b.jsx)(hw,{})},{path:`-/roles/new`,element:(0,b.jsx)(fw,{})},{path:`-/roles/:name`,element:(0,b.jsx)(fw,{})},{path:`-/debugger`,element:(0,b.jsx)(ew,{})},{path:`-/audit`,element:(0,b.jsx)(ZC,{})},{path:`g/:group`,element:(0,b.jsx)(eO,{})},{path:`p/:page`,element:(0,b.jsx)(fk,{})},{path:`:resource`,element:(0,b.jsx)(nk,{})},{path:`:resource/new`,element:(0,b.jsx)(UD,{mode:`create`})},{path:`:resource/:id`,element:(0,b.jsx)(UD,{mode:`edit`})},{path:`*`,element:(0,b.jsx)(ck,{})}]}],{basename:lg.basePath});gg(()=>{let e=vg(gk.state.location.pathname,lg.basePath),{search:t}=gk.state.location;e!==`/login`&&(hk.clear(),gk.navigate(`/login?${new URLSearchParams({next:e+t})}`,{replace:!0}))}),(0,Ka.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(y.StrictMode,{children:(0,b.jsx)(sg,{locales:lg.locales,fallback:lg.locale,children:(0,b.jsx)(C,{client:hk,children:(0,b.jsx)(Ca,{router:gk})})})}));export{c as _,Py as a,$ as c,q as d,W as f,o as g,u as h,ex as i,X as l,m,uE as n,Oy as o,v as p,oE as r,Mv as s,dE as t,Oh as u};
|