forlogic-core 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("react"),t=require("@radix-ui/react-slot"),a=require("class-variance-authority"),s=require("clsx"),r=require("tailwind-merge"),n=require("date-fns"),o=require("@radix-ui/react-label"),i=require("@radix-ui/react-dialog"),l=require("lucide-react"),c=require("react-hook-form"),d=require("@radix-ui/react-select"),u=require("@radix-ui/react-checkbox"),m=require("@radix-ui/react-toast"),p=require("@supabase/supabase-js"),f=require("@tanstack/react-query"),h=require("react-router-dom"),x=require("sonner"),g=require("@radix-ui/react-alert-dialog"),b=require("@radix-ui/react-dropdown-menu"),v=require("@radix-ui/react-popover"),y=require("@radix-ui/react-scroll-area"),N=require("@radix-ui/react-accordion"),j=require("@radix-ui/react-aspect-ratio"),w=require("@radix-ui/react-avatar"),k=require("react-day-picker"),S=require("@radix-ui/react-collapsible"),C=require("@radix-ui/react-progress"),T=require("@radix-ui/react-radio-group"),P=require("@radix-ui/react-separator"),A=require("@radix-ui/react-tooltip"),R=require("@radix-ui/react-slider"),E=require("next-themes");require("react-dom");var I=require("@radix-ui/react-tabs"),_=require("@radix-ui/react-toggle"),D=require("@radix-ui/react-toggle-group"),O=require("react-markdown"),z=require("remark-gfm");function F(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var L,M=F(e),$=F(o),U=F(i),B=F(d),V=F(u),q=F(m),W=F(g),H=F(b),Q=F(v),G=F(y),X=F(N),K=F(j),J=F(w),Y=F(S),Z=F(C),ee=F(T),te=F(P),ae=F(A),se=F(R),re=F(I),ne=F(_),oe=F(D),ie={exports:{}},le={};var ce,de,ue={};
1
+ "use strict";var e=require("react"),t=require("@radix-ui/react-slot"),n=require("class-variance-authority"),r=require("clsx"),a=require("tailwind-merge"),o=require("date-fns"),s=require("@radix-ui/react-label"),i=require("@radix-ui/react-dialog"),l=require("lucide-react"),c=require("react-hook-form"),u=require("@radix-ui/react-select"),d=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-toast"),p=require("@supabase/supabase-js"),m=require("@tanstack/react-query"),h=require("react-router-dom"),g=require("sonner"),x=require("@radix-ui/react-alert-dialog"),b=require("@radix-ui/react-dropdown-menu"),y=require("@radix-ui/react-popover"),v=require("@radix-ui/react-scroll-area"),w=require("@radix-ui/react-accordion"),k=require("@radix-ui/react-aspect-ratio"),N=require("@radix-ui/react-avatar"),j=require("react-day-picker"),S=require("@radix-ui/react-collapsible"),C=require("@radix-ui/react-progress"),T=require("@radix-ui/react-radio-group"),E=require("@radix-ui/react-separator"),I=require("@radix-ui/react-tooltip"),A=require("@radix-ui/react-slider"),P=require("next-themes");require("react-dom");var D=require("@radix-ui/react-tabs"),R=require("@radix-ui/react-toggle"),_=require("@radix-ui/react-toggle-group");function O(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var L=O(e),F=O(s),z=O(i),M=O(u),B=O(d),U=O(f),$=O(x),V=O(b),q=O(y),H=O(v),W=O(w),Q=O(k),X=O(N),K=O(S),Y=O(C),G=O(T),J=O(E),Z=O(I),ee=O(A),te=O(D),ne=O(R),re=O(_);function ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oe,se={exports:{}},ie={};var le,ce,ue={};
2
2
  /**
3
3
  * @license React
4
4
  * react-jsx-runtime.development.js
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */function me(){return ce||(ce=1,"production"!==process.env.NODE_ENV&&function(){var t=e,a=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),h=Symbol.iterator;var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];!function(e,t,a){var s=x.ReactDebugCurrentFrame,r=s.getStackAddendum();""!==r&&(t+="%s",a=a.concat([r]));var n=a.map(function(e){return String(e)});n.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,n)}("error",e,a)}var b;function v(e){return e.displayName||"Context"}function y(e){if(null==e)return null;if("number"==typeof e.tag&&g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case r:return"Fragment";case s:return"Portal";case o:return"Profiler";case n:return"StrictMode";case d:return"Suspense";case u:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return v(e)+".Consumer";case i:return v(e._context)+".Provider";case c:return function(e,t,a){var s=e.displayName;if(s)return s;var r=t.displayName||t.name||"";return""!==r?a+"("+r+")":a}(e,e.render,"ForwardRef");case m:var t=e.displayName||null;return null!==t?t:y(e.type)||"Memo";case p:var a=e,f=a._payload,h=a._init;try{return y(h(f))}catch(x){return null}}return null}b=Symbol.for("react.module.reference");var N,j,w,k,S,C,T,P=Object.assign,A=0;function R(){}R.__reactDisabledLog=!0;var E,I=x.ReactCurrentDispatcher;function _(e,t,a){if(void 0===E)try{throw Error()}catch(r){var s=r.stack.trim().match(/\n( *(at )?)/);E=s&&s[1]||""}return"\n"+E+e}var D,O=!1,z="function"==typeof WeakMap?WeakMap:Map;function F(e,t){if(!e||O)return"";var a,s=D.get(e);if(void 0!==s)return s;O=!0;var r,n=Error.prepareStackTrace;Error.prepareStackTrace=void 0,r=I.current,I.current=null,function(){if(0===A){N=console.log,j=console.info,w=console.warn,k=console.error,S=console.group,C=console.groupCollapsed,T=console.groupEnd;var e={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}A++}();try{if(t){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(o,[])}catch(f){a=f}Reflect.construct(e,[],o)}else{try{o.call()}catch(f){a=f}e.call(o.prototype)}}else{try{throw Error()}catch(f){a=f}e()}}catch(h){if(h&&a&&"string"==typeof h.stack){for(var i=h.stack.split("\n"),l=a.stack.split("\n"),c=i.length-1,d=l.length-1;c>=1&&d>=0&&i[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(i[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||i[c]!==l[d]){var u="\n"+i[c].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,u),u}}while(c>=1&&d>=0);break}}}finally{O=!1,I.current=r,function(){if(0===--A){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:N}),info:P({},e,{value:j}),warn:P({},e,{value:w}),error:P({},e,{value:k}),group:P({},e,{value:S}),groupCollapsed:P({},e,{value:C}),groupEnd:P({},e,{value:T})})}A<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=n}var m=e?e.displayName||e.name:"",p=m?_(m):"";return"function"==typeof e&&D.set(e,p),p}function L(e,t,a){if(null==e)return"";if("function"==typeof e)return F(e,!(!(s=e.prototype)||!s.isReactComponent));var s;if("string"==typeof e)return _(e);switch(e){case d:return _("Suspense");case u:return _("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return F(e.render,!1);case m:return L(e.type,t,a);case p:var r=e,n=r._payload,o=r._init;try{return L(o(n),t,a)}catch(i){}}return""}D=new z;var M=Object.prototype.hasOwnProperty,$={},U=x.ReactDebugCurrentFrame;function B(e){if(e){var t=e._owner,a=L(e.type,e._source,t?t.type:null);U.setExtraStackFrame(a)}else U.setExtraStackFrame(null)}var V=Array.isArray;function q(e){return V(e)}function W(e){return""+e}function H(e){if(function(e){try{return W(e),!1}catch(t){return!0}}(e))return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),W(e)}var Q,G,X=x.ReactCurrentOwner,K={key:!0,ref:!0,__self:!0,__source:!0};function J(e,t,s,r,n){var o,i={},l=null,c=null;for(o in void 0!==s&&(H(s),l=""+s),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(H(t.key),l=""+t.key),function(e){if(M.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&X.current}(t)),t)M.call(t,o)&&!K.hasOwnProperty(o)&&(i[o]=t[o]);if(e&&e.defaultProps){var d=e.defaultProps;for(o in d)void 0===i[o]&&(i[o]=d[o])}if(l||c){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var a=function(){Q||(Q=!0,g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}(i,u),c&&function(e,t){var a=function(){G||(G=!0,g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}(i,u)}return function(e,t,s,r,n,o,i){var l={$$typeof:a,type:e,key:t,ref:s,props:i,_owner:o,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,n,r,X.current,i)}var Y,Z=x.ReactCurrentOwner,ee=x.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,a=L(e.type,e._source,t?t.type:null);ee.setExtraStackFrame(a)}else ee.setExtraStackFrame(null)}function ae(e){return"object"==typeof e&&null!==e&&e.$$typeof===a}function se(){if(Z.current){var e=y(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Y=!1;var re={};function ne(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var a=function(e){var t=se();if(!t){var a="string"==typeof e?e:e.displayName||e.name;a&&(t="\n\nCheck the top-level render call using <"+a+">.")}return t}(t);if(!re[a]){re[a]=!0;var s="";e&&e._owner&&e._owner!==Z.current&&(s=" It was passed a child from "+y(e._owner.type)+"."),te(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,s),te(null)}}}function oe(e,t){if("object"==typeof e)if(q(e))for(var a=0;a<e.length;a++){var s=e[a];ae(s)&&ne(s,t)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var r=function(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof r&&r!==e.entries)for(var n,o=r.call(e);!(n=o.next()).done;)ae(n.value)&&ne(n.value,t)}}function ie(e){var t,a=e.type;if(null!=a&&"string"!=typeof a){if("function"==typeof a)t=a.propTypes;else{if("object"!=typeof a||a.$$typeof!==c&&a.$$typeof!==m)return;t=a.propTypes}if(t){var s=y(a);!function(e,t,a,s,r){var n=Function.call.bind(M);for(var o in e)if(n(e,o)){var i=void 0;try{if("function"!=typeof e[o]){var l=Error((s||"React class")+": "+a+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}i=e[o](t,o,s,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){i=c}!i||i instanceof Error||(B(r),g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",a,o,typeof i),B(null)),i instanceof Error&&!(i.message in $)&&($[i.message]=!0,B(r),g("Failed %s type: %s",a,i.message),B(null))}}(t,e.props,"prop",s,e)}else if(void 0!==a.PropTypes&&!Y){Y=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y(a)||"Unknown")}"function"!=typeof a.getDefaultProps||a.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ce(e,t,s,h,x,v){var N=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===o||e===n||e===d||e===u||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===p||e.$$typeof===m||e.$$typeof===i||e.$$typeof===l||e.$$typeof===c||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!N){var j="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(j+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var w;j+=se(),null===e?w="null":q(e)?w="array":void 0!==e&&e.$$typeof===a?(w="<"+(y(e.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,j)}var k=J(e,t,s,x,v);if(null==k)return k;if(N){var S=t.children;if(void 0!==S)if(h)if(q(S)){for(var C=0;C<S.length;C++)oe(S[C],e);Object.freeze&&Object.freeze(S)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else oe(S,e)}if(M.call(t,"key")){var T=y(e),P=Object.keys(t).filter(function(e){return"key"!==e}),A=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+A])g('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',A,T,P.length>0?"{"+P.join(": ..., ")+": ...}":"{}",T),le[T+A]=!0}return e===r?function(e){for(var t=Object.keys(e.props),a=0;a<t.length;a++){var s=t[a];if("children"!==s&&"key"!==s){te(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),te(null);break}}null!==e.ref&&(te(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(k):ie(k),k}var de=function(e,t,a){return ce(e,t,a,!1)},me=function(e,t,a){return ce(e,t,a,!0)};ue.Fragment=r,ue.jsx=de,ue.jsxs=me}()),ue}var pe=(de||(de=1,"production"===process.env.NODE_ENV?ie.exports=function(){if(L)return le;L=1;var t=e,a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(e,t,s){var i,l={},c=null,d=null;for(i in void 0!==s&&(c=""+s),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)r.call(t,i)&&!o.hasOwnProperty(i)&&(l[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===l[i]&&(l[i]=t[i]);return{$$typeof:a,type:e,key:c,ref:d,props:l,_owner:n.current}}return le.Fragment=s,le.jsx=i,le.jsxs=i,le}():ie.exports=me()),ie.exports);function fe(...e){return r.twMerge(s.clsx(e))}const he=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(he);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=he(s);return t}return e},xe=a.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6"}},defaultVariants:{variant:"default",size:"default"}}),ge=M.forwardRef(({className:e,variant:a,size:s,asChild:r=!1,...n},o)=>{const i=r?t.Slot:"button";return pe.jsx(i,{className:fe(xe({variant:a,size:s,className:e})),ref:o,...n})});ge.displayName="Button";const be=M.forwardRef(({className:e,type:t,...a},s)=>pe.jsx("input",{type:t,className:fe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...a}));be.displayName="Input";const ve=a.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ye=M.forwardRef(({className:e,...t},a)=>pe.jsx($.Root,{ref:a,className:fe(ve(),e),...t}));ye.displayName=$.Root.displayName;const Ne=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Ne.displayName="Card";const je=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("flex flex-col space-y-1.5 p-6",e),...t}));je.displayName="CardHeader";const we=M.forwardRef(({className:e,...t},a)=>pe.jsx("h3",{ref:a,className:fe("text-2xl font-semibold leading-none tracking-tight",e),...t}));we.displayName="CardTitle";const ke=M.forwardRef(({className:e,...t},a)=>pe.jsx("p",{ref:a,className:fe("text-sm text-muted-foreground",e),...t}));ke.displayName="CardDescription";const Se=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("p-6 pt-0",e),...t}));Se.displayName="CardContent";const Ce=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("flex items-center p-6 pt-0",e),...t}));Ce.displayName="CardFooter";const Te=U.Root,Pe=U.Trigger,Ae=U.Portal,Re=U.Close,Ee=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Overlay,{ref:a,className:fe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ee.displayName=U.Overlay.displayName;const Ie=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsxs(Ae,{children:[pe.jsx(Ee,{}),pe.jsxs(U.Content,{ref:s,className:fe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 bg-background p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg overflow-hidden",e),...a,children:[t,pe.jsxs(U.Close,{className:"absolute right-4 top-4 z-10 rounded-sm text-white opacity-70 ring-offset-background transition-opacity hover:opacity-100 hover:text-white focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[pe.jsx(l.X,{className:"h-4 w-4"}),pe.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ie.displayName=U.Content.displayName;const _e=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col space-y-1.5 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-3 rounded-t-lg",e),...t});_e.displayName="DialogHeader";const De=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});De.displayName="DialogFooter";const Oe=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Title,{ref:a,className:fe("text-lg font-semibold leading-none tracking-tight",e),...t}));Oe.displayName=U.Title.displayName;const ze=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Description,{ref:a,className:fe("text-sm text-muted-foreground",e),...t}));ze.displayName=U.Description.displayName;const Fe=c.FormProvider,Le=M.createContext({}),Me=()=>{const e=M.useContext(Le),t=M.useContext($e),{getFieldState:a,formState:s}=c.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},$e=M.createContext({}),Ue=M.forwardRef(({className:e,...t},a)=>{const s=M.useId();return pe.jsx($e.Provider,{value:{id:s},children:pe.jsx("div",{ref:a,className:fe("space-y-2",e),...t})})});Ue.displayName="FormItem";const Be=M.forwardRef(({className:e,...t},a)=>{const{error:s,formItemId:r}=Me();return pe.jsx(ye,{ref:a,className:fe(s&&"text-destructive",e),htmlFor:r,...t})});Be.displayName="FormLabel";const Ve=M.forwardRef(({...e},a)=>{const{error:s,formItemId:r,formDescriptionId:n,formMessageId:o}=Me();return pe.jsx(t.Slot,{ref:a,id:r,"aria-describedby":s?`${n} ${o}`:`${n}`,"aria-invalid":!!s,...e})});Ve.displayName="FormControl";M.forwardRef(({className:e,...t},a)=>{const{formDescriptionId:s}=Me();return pe.jsx("p",{ref:a,id:s,className:fe("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const qe=M.forwardRef(({className:e,children:t,...a},s)=>{const{error:r,formMessageId:n}=Me(),o=r?String(r?.message):t;return o?pe.jsx("p",{ref:s,id:n,className:fe("text-sm font-medium text-destructive",e),...a,children:o}):null});qe.displayName="FormMessage";const We=B.Root,He=B.Value,Qe=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsxs(B.Trigger,{ref:s,className:fe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...a,children:[t,pe.jsx(B.Icon,{asChild:!0,children:pe.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Qe.displayName=B.Trigger.displayName;const Ge=M.forwardRef(({className:e,...t},a)=>pe.jsx(B.ScrollUpButton,{ref:a,className:fe("flex cursor-default items-center justify-center py-1",e),...t,children:pe.jsx(l.ChevronUp,{className:"h-4 w-4"})}));Ge.displayName=B.ScrollUpButton.displayName;const Xe=M.forwardRef(({className:e,...t},a)=>pe.jsx(B.ScrollDownButton,{ref:a,className:fe("flex cursor-default items-center justify-center py-1",e),...t,children:pe.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Xe.displayName=B.ScrollDownButton.displayName;const Ke=M.forwardRef(({className:e,children:t,position:a="popper",...s},r)=>pe.jsx(B.Portal,{children:pe.jsxs(B.Content,{ref:r,className:fe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===a&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...s,children:[pe.jsx(Ge,{}),pe.jsx(B.Viewport,{className:fe("p-1","popper"===a&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),pe.jsx(Xe,{})]})}));Ke.displayName=B.Content.displayName;M.forwardRef(({className:e,...t},a)=>pe.jsx(B.Label,{ref:a,className:fe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=B.Label.displayName;const Je=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsxs(B.Item,{ref:s,className:fe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[pe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:pe.jsx(B.ItemIndicator,{children:pe.jsx(l.Check,{className:"h-4 w-4"})})}),pe.jsx(B.ItemText,{children:t})]}));Je.displayName=B.Item.displayName;M.forwardRef(({className:e,...t},a)=>pe.jsx(B.Separator,{ref:a,className:fe("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=B.Separator.displayName;const Ye=M.forwardRef(({className:e,...t},a)=>pe.jsx(V.Root,{ref:a,className:fe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:pe.jsx(V.Indicator,{className:fe("flex items-center justify-center text-current"),children:pe.jsx(l.Check,{className:"h-4 w-4"})})}));Ye.displayName=V.Root.displayName;const Ze=M.forwardRef(({className:e,...t},a)=>pe.jsx("textarea",{className:fe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:a,...t}));Ze.displayName="Textarea";const et=a.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white hover:bg-green-600",warning:"border-transparent bg-yellow-500 text-white hover:bg-yellow-600",info:"border-transparent bg-blue-500 text-white hover:bg-blue-600"}},defaultVariants:{variant:"default"}}),tt=M.forwardRef(({className:e,variant:t,...a},s)=>pe.jsx("div",{ref:s,className:fe(et({variant:t}),e),...a}));tt.displayName="Badge";const at={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function st({size:e="md",className:t}){return pe.jsx(l.Loader2,{className:fe("animate-spin text-muted-foreground",at[e],t)})}let rt=0;const nt=new Map,ot=e=>{if(nt.has(e))return;const t=setTimeout(()=>{nt.delete(e),dt({type:"REMOVE_TOAST",toastId:e})},1e6);nt.set(e,t)},it=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:a}=t;return a?ot(a):e.toasts.forEach(e=>{ot(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},lt=[];let ct={toasts:[]};function dt(e){ct=it(ct,e),lt.forEach(e=>{e(ct)})}function ut({...e}){const t=(rt=(rt+1)%Number.MAX_SAFE_INTEGER,rt.toString()),a=()=>dt({type:"DISMISS_TOAST",toastId:t});return dt({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||a()}}}),{id:t,dismiss:a,update:e=>dt({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function mt(){const[e,t]=M.useState(ct);return M.useEffect(()=>(lt.push(t),()=>{const e=lt.indexOf(t);e>-1&&lt.splice(e,1)}),[e]),{...e,toast:ut,dismiss:e=>dt({type:"DISMISS_TOAST",toastId:e})}}const pt=q.Provider,ft=M.forwardRef(({className:e,...t},a)=>pe.jsx(q.Viewport,{ref:a,className:fe("fixed top-4 left-1/2 transform -translate-x-1/2 z-[100] flex max-h-screen w-full max-w-[420px] flex-col p-4",e),...t}));ft.displayName=q.Viewport.displayName;const ht=a.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),xt=M.forwardRef(({className:e,variant:t,...a},s)=>pe.jsx(q.Root,{ref:s,className:fe(ht({variant:t}),e),...a}));xt.displayName=q.Root.displayName;const gt=M.forwardRef(({className:e,...t},a)=>pe.jsx(q.Action,{ref:a,className:fe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));gt.displayName=q.Action.displayName;const bt=M.forwardRef(({className:e,...t},a)=>pe.jsx(q.Close,{ref:a,className:fe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:pe.jsx(l.X,{className:"h-4 w-4"})}));bt.displayName=q.Close.displayName;const vt=M.forwardRef(({className:e,...t},a)=>pe.jsx(q.Title,{ref:a,className:fe("text-sm font-semibold",e),...t}));vt.displayName=q.Title.displayName;const yt=M.forwardRef(({className:e,...t},a)=>pe.jsx(q.Description,{ref:a,className:fe("text-sm opacity-90",e),...t}));yt.displayName=q.Description.displayName;var Nt=Object.defineProperty;class jt{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,a)=>{t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(jt,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const wt="qualiex_access_token",kt="qualiex_id_token",St="supabase_token",Ct="oauth_state",Tt="oauth_nonce",Pt="selected_alias",At="manual_logout",Rt={setAccessToken:e=>localStorage.setItem(wt,e),getAccessToken:()=>localStorage.getItem(wt),setIdToken:e=>localStorage.setItem(kt,e),getIdToken:()=>localStorage.getItem(kt),getSupabaseToken:()=>localStorage.getItem(St),setOAuthState:e=>sessionStorage.setItem(Ct,e),getOAuthState:()=>sessionStorage.getItem(Ct),clearOAuthState:()=>sessionStorage.removeItem(Ct),setOAuthNonce:e=>sessionStorage.setItem(Tt,e),getOAuthNonce:()=>sessionStorage.getItem(Tt),clearOAuthNonce:()=>sessionStorage.removeItem(Tt),setSelectedAlias:e=>localStorage.setItem(Pt,e),getSelectedAlias:()=>localStorage.getItem(Pt),clearSelectedAlias:()=>localStorage.removeItem(Pt),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Rt.getAccessToken()||!Rt.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(St,e),Rt._clearValidationCache()},areAllTokensValid:()=>{const e=Rt.getAccessToken(),t=Rt.getIdToken();if(!e||!t)return!1;try{const a=jt.validateTokens(e,t);return!!a.idTokenValid&&(a.accessTokenValid,a.idTokenValid)}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Rt.getAccessToken(),a=Rt.getIdToken(),s=Rt.getSupabaseToken();return t&&Rt.isTokenExpired(t)&&(localStorage.removeItem(wt),e=!0),a&&Rt.isTokenExpired(a)&&(localStorage.removeItem(kt),e=!0),s&&Rt.isTokenExpired(s)&&(localStorage.removeItem(St),e=!0),e},clearAll:()=>{localStorage.removeItem(wt),localStorage.removeItem(kt),localStorage.removeItem(St),localStorage.removeItem(Pt),localStorage.removeItem(At),sessionStorage.removeItem(Ct),sessionStorage.removeItem(Tt)},setManualLogout:()=>localStorage.setItem(At,"true"),isManualLogout:()=>"true"===localStorage.getItem(At),clearManualLogout:()=>localStorage.removeItem(At),isTokenExpired:e=>{try{return jt.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Rt._validationCache.isValid=!1,Rt._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Rt.getSupabaseToken();if(!e)return!1;if(Rt.isTokenExpired(e))return Rt._clearValidationCache(),Rt._handleExpiredToken(),!1;const t=Date.now();return t-Rt._validationCache.timestamp<Rt._validationCache.cacheValidityMs?Rt._validationCache.isValid:(Rt._validationCache.isValid=!0,Rt._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Rt.isSupabaseTokenValid()?Rt.getSupabaseToken():null,_handleExpiredToken:()=>{Rt.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Rt.isSupabaseTokenValid())return null;const e=Rt.getSupabaseToken();if(!e)return null;try{const t=jt.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias;let s=t.company_id;if(!s&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===a){s=e[7];break}}}return{alias:a,companyId:s,payload:t}}catch(t){return Rt._handleExpiredToken(),null}},getCompanyId:e=>{const t=Rt.extractTokenData();if(!t)return null;if(!e)return t.companyId;const a=Rt.getIdToken();if(!a)return null;try{const t=jt.parseJwtPayload(a);if(!t)return null;for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(t.length>7&&t[0]===e)return t[7]}}}catch{return null}return null},getCurrentCompanyId:()=>{const e=Rt.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Rt.getIdToken();if(!e)return[];try{const t=jt.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var Et=Object.defineProperty,It=(e,t,a)=>((e,t,a)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const _t=new class{constructor(){It(this,"errors",[]),It(this,"toastCount",0),It(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message;this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()&&ut({title:"Erro",description:a,variant:"destructive"})}success(e,t){ut({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Dt=Object.defineProperty,Ot=(e,t,a)=>((e,t,a)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const zt=(void 0).VITE_SUPABASE_URL,Ft=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,Lt=class e{constructor(){Ot(this,"client"),Ot(this,"currentToken",null),Ot(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Ft};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),p.createClient(zt,Ft,{auth:{persistSession:!1,autoRefreshToken:!1,storage:void 0},global:{headers:t}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Rt.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),a=Math.floor(Date.now()/1e3);return t.exp>a}catch(t){return _t.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};Ot(Lt,"instance");let Mt=Lt;const $t=()=>Mt.getInstance().getClient();var Ut=Object.freeze({__proto__:null,getSupabaseClient:$t}),Bt=Object.defineProperty,Vt=(e,t,a)=>((e,t,a)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const qt=new class{constructor(){Vt(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const s=Rt.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const r=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{r.searchParams.append(e,t)});const n=await fetch(r.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!n.ok)throw new Error(`API call failed: ${n.status} ${n.statusText}`);return await n.json()}mapToQualiexUser(e){return{userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível"}}async fetchUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let s=a;if(a.data)s=a.data;else{if(!Array.isArray(a))return _t.handleError("[QualiexApi] Unexpected response format",!1),[];s=a}if(!Array.isArray(s))return _t.handleError("[QualiexApi] Response is not an array",!1),[];return s.map(this.mapToQualiexUser)}catch(a){return _t.handleError(a instanceof Error?a:"[QualiexApi] Error fetching users"),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return _t.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const t=Rt.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):(_t.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}};class Wt{static async extractTokenData(){const e=Rt.extractTokenData();return e||(_t.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,t){if(!e||0===e.length)return _t.handleError(`[QualiexEnrichment.${t.entityName}] Nenhuma entidade encontrada`,!1),e;try{const a=await this.extractTokenData();if(!a)return e.map(e=>({...e,responsible_name:e.id_user?"Token não encontrado":null}));const{alias:s,companyId:r}=a;if(!s||!r)return _t.handleError(`[QualiexEnrichment.${t.entityName}] DADOS OBRIGATÓRIOS FALTANDO - alias: ${!!s}, companyId: ${!!r}`,!1),e.map(e=>({...e,responsible_name:e.id_user?`Configuração incompleta (alias: ${!!s}, companyId: ${!!r})`:null}));const n=await qt.getUsers(s),o=e.map(e=>{if(e.id_user){const t=n.find(t=>t.userId===e.id_user);return{...e,responsible_name:t?.userName||`ID não encontrado: ${e.id_user}`}}return{...e,responsible_name:null}});o.filter(e=>e.responsible_name&&!e.responsible_name.includes("ID não encontrado")&&!e.responsible_name.includes("Erro:")&&!e.responsible_name.includes("Token não encontrado")&&!e.responsible_name.includes("Configuração incompleta")).length;return o}catch(a){return _t.handleError(a instanceof Error?a:`[QualiexEnrichment.${t.entityName}] 💥 ERRO CRÍTICO`),e.map(e=>({...e,responsible_name:e.id_user?`Erro: ${a.message}`:null}))}}}const Ht={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},Qt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Gt={debounceDelay:500},Xt=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV};let Kt={enableUserEnrichment:!1,enableUsersApi:!1};const Jt=()=>Kt,Yt={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}},Zt=["responsible_name"],ea=e=>Zt.includes(e);function ta(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"central"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"central",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=s,d=()=>{if(!Rt.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return $t().schema(i).from(r)};return{async getAll(e={}){const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:i=1,limit:u=25,...m}=e;let p=d().select(o||"*",{count:"exact"});p=p.eq("is_removed",!1),Object.entries(m).forEach(([e,t])=>{null!=t&&""!==t&&(p=Array.isArray(t)?p.in(e,t):"object"==typeof t&&t&&"operator"in t&&"not_null"===t.operator?p.not(e,"is",null):p.eq(e,t))}),p=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(p,t);a.includes(".")||ea(a)||(p=p.order(a,{ascending:"asc"===s})),p=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(p,i,u);const{data:f,error:h,count:x}=await p;if(h)throw new Error(`Error fetching ${r}: ${h.message}`);let g=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],x,i,u);const b=Jt();if(c&&b.enableUserEnrichment&&l&&g.data.length>0){if(g.data.some(e=>e.id_user)){const t=a&&a.includes(".");if(a&&(ea(a)||t)){const r={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},n=await this.getAll(r);if(!n?.data?.length)return n;const o=await Wt.enrichWithResponsibleNames(n.data,{entityName:l});let c;c=t?o.sort((e,t)=>{const r=a.split(".").reduce((e,t)=>e?.[t],e)||"",n=a.split(".").reduce((e,t)=>e?.[t],t)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===s?o:-o}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(o,a,s);const d=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a,n=e.slice(s,r);return{data:n,pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:n.length,totalCount:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(c,i,u);return{data:d.data,currentPage:d.pagination.currentPage,totalPages:d.pagination.totalPages,totalItems:d.pagination.totalCount,itemsPerPage:d.pagination.itemsPerPage,hasNextPage:d.pagination.hasNextPage,hasPreviousPage:d.pagination.hasPreviousPage}}const r=await Wt.enrichWithResponsibleNames(g.data,{entityName:l});g={...g,data:r}}}return g},async getById(e){const{data:t,error:a}=await d().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=he(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await d().insert(a).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,t){const a={...he(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await d().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await d().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}}}const aa=()=>{Rt.clearManualLogout()},sa=(void 0).VITE_SUPABASE_URL,ra=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class na{static async generateToken(e,t,a,s=!1){try{if(!s){const e=Rt.getSupabaseToken();if(e&&Rt.isSupabaseTokenValid())return e}const r=p.createClient(sa,ra,{auth:{persistSession:!1,autoRefreshToken:!1}}),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(Rt.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}var oa=Object.defineProperty,ia=(e,t,a)=>((e,t,a)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class la{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Rt.getAccessToken(),t=Rt.getSelectedAlias();if(!e||!t)return null;const a=await na.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(Rt.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}ia(la,"isRegenerating",!1),ia(la,"onLogoutCallback",null);const ca=class{static async initialize(){try{if(!Rt.hasAllTokens()||!Rt.areAllTokensValid())return Rt.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null};const e=Rt.getAccessToken(),t=Rt.getIdToken();aa();const a=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),r=this.extractAliasFromAccessToken(e),n=Rt.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=Rt.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);i=t?e:r||s[0]?.alias||null}!Rt.isSupabaseTokenValid()&&i&&await la.attemptRegeneration();let l=null;if(i){const e=Rt.getCompanyId(i),t=s.find(e=>e.alias===i);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}return{isAuthenticated:!0,isLoading:!1,user:a,alias:i,companies:s,selectedUnit:l,userId:a?.id||null,userAlias:a?.id||null}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null}}}static async loginDev(){try{const{getSupabaseClient:e}=await Promise.resolve().then(function(){return Ut}),t=e(),{data:a,error:s}=await t.functions.invoke("dev-tokens",{body:{environment:"development"}});if(s)return!1;if(!a?.access_token||!a?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=Rt.generateOAuthState();Rt.setOAuthState(e);const t=Rt.generateOAuthNonce();Rt.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(Ht.oauth.authUrl);s.searchParams.set("client_id",Ht.oauth.clientId),s.searchParams.set("response_type",Ht.oauth.responseType),s.searchParams.set("scope",Ht.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),Xt(),window.location.href=s.toString()}static async processCallback(){try{if(Rt.hasAllTokens()){if(!Rt.getValidSupabaseToken()){Rt.getAccessToken();await la.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");Rt.setAccessToken(s),Rt.setIdToken(r),aa();const o=this.extractAliasFromAccessToken(s);if(o)Rt.setSelectedAlias(o);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Rt.setSelectedAlias(e[0].alias)}if(!await la.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Rt.clearOAuthState(),Rt.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Rt.setManualLogout(),Rt.clearAll(),window.location.href="/login"}static decodeToken(e){return jt.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};la.setLogoutCallback(()=>{ca.logout()});let da=ca;class ua{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Rt.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}const ma=e.createContext(void 0),pa=()=>{const t=e.useContext(ma);if(void 0===t)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return t};function fa({queryKey:t,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[i,l]=h.useSearchParams(),c=f.useQueryClient(),{alias:d,userId:u}=pa(),m=i.get("search")||"",p=i.get("sortField")||Qt.sorting.defaultField,g=i.get("sortDirection")||Qt.sorting.defaultDirection,b=parseInt(i.get("page")||"1"),v=parseInt(i.get("limit")||String(Qt.pagination.defaultPageSize)),y=m,N=e.useMemo(()=>({search:y,sortField:p,sortDirection:g,page:b,limit:v,...n}),[y,p,g,b,v,n]),j=e.useCallback(()=>a.getAll(N),[a,N]),w=f.useQuery({queryKey:[t,d,u,N],queryFn:j});if(!w)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const k=f.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),x.toast.success(Yt.success.created(s)),o?.()},onError:e=>{x.toast.error(`${Yt.error.create(s)}: ${e.message}`)}}),S=f.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),x.toast.success(Yt.success.updated(s)),o?.()},onError:e=>{x.toast.error(`${Yt.error.update(s)}: ${e.message}`)}}),C=f.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),x.toast.success(Yt.success.deleted(s))},onError:e=>{x.toast.error(`${Yt.error.delete(s)}: ${e.message}`)}}),T=e.useCallback(e=>{const t={...Object.fromEntries(i)};Object.entries(e).forEach(([e,a])=>{""===a||0===a?delete t[e]:t[e]=String(a)}),l(t)},[i,l]),P=e.useCallback(e=>{T({search:e,page:1})},[T]),A=e.useCallback(e=>{T({sortField:e,sortDirection:p===e&&"asc"===g?"desc":"asc",page:1})},[p,g,T]),R=e.useCallback(e=>{T({page:e})},[T]),E=e.useCallback(e=>{T({limit:e,page:1})},[T]),I=e.useCallback(()=>{l({})},[l]),[_,D]=e.useState([]),O=e.useCallback(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),z=e.useCallback(()=>{const e=w?.data?.data.map(e=>e.id)||[];D(t=>t.length===e.length?[]:e)},[w?.data?.data]),F=e.useCallback(()=>{D([])},[]),L=e.useMemo(()=>{const e=w?.data?.data.map(e=>e.id)||[];return e.length>0&&_.length===e.length},[_,w?.data?.data]),M=f.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(e,a)=>{c.invalidateQueries({queryKey:[t]}),x.toast.success(`${a.length} ${s}(s) deletado(s) com sucesso`),F()},onError:e=>{x.toast.error(`Erro ao deletar itens: ${e.message}`)}});return{entities:w?.data?.data||[],pagination:{currentPage:w?.data?.currentPage||1,totalPages:w?.data?.totalPages||1,totalItems:w?.data?.totalItems||0,itemsPerPage:w?.data?.itemsPerPage||Qt.pagination.defaultPageSize,hasNextPage:w?.data?.hasNextPage||!1,hasPreviousPage:w?.data?.hasPreviousPage||!1},isLoading:w?.isLoading??!0,isCreating:k?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:C?.isPending??!1,error:w?.error||null,searchTerm:m,sortField:p,sortDirection:g,currentPage:b,itemsPerPage:v,createEntity:k.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:C.mutate,handleSearch:P,handleSort:A,handlePageChange:R,handleItemsPerPageChange:E,clearFilters:I,refetch:w.refetch,selectedIds:_,selectItem:O,selectAll:z,clearSelection:F,isAllSelected:L,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}const ha=W.Root,xa=W.Trigger,ga=W.Portal,ba=M.forwardRef(({className:e,...t},a)=>pe.jsx(W.Overlay,{className:fe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:a}));ba.displayName=W.Overlay.displayName;const va=M.forwardRef(({className:e,...t},a)=>pe.jsxs(ga,{children:[pe.jsx(ba,{}),pe.jsx(W.Content,{ref:a,className:fe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));va.displayName=W.Content.displayName;const ya=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col space-y-2 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-6 rounded-t-lg",e),...t});ya.displayName="AlertDialogHeader";const Na=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Na.displayName="AlertDialogFooter";const ja=M.forwardRef(({className:e,...t},a)=>pe.jsx(W.Title,{ref:a,className:fe("text-lg font-semibold",e),...t}));ja.displayName=W.Title.displayName;const wa=M.forwardRef(({className:e,...t},a)=>pe.jsx(W.Description,{ref:a,className:fe("text-sm text-muted-foreground",e),...t}));wa.displayName=W.Description.displayName;const ka=M.forwardRef(({className:e,...t},a)=>pe.jsx(W.Action,{ref:a,className:fe(xe(),e),...t}));ka.displayName=W.Action.displayName;const Sa=M.forwardRef(({className:e,...t},a)=>pe.jsx(W.Cancel,{ref:a,className:fe(xe({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Sa.displayName=W.Cancel.displayName;const Ca=({open:t,onOpenChange:a,item:s,onConfirm:r,entityName:n="item",isDeleting:o=!1})=>{const[i,l]=e.useState("");e.useEffect(()=>{t||l("")},[t]);const c=()=>{l(""),a(!1)},d=i===s?.title;return s?pe.jsx(ha,{open:t,onOpenChange:c,children:pe.jsxs(va,{className:"sm:max-w-[500px]",children:[pe.jsx(ya,{children:pe.jsxs("div",{className:"flex items-center space-x-2",children:[pe.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:pe.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),pe.jsx("div",{className:"flex-1",children:pe.jsx(ja,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),pe.jsx(wa,{asChild:!0,children:pe.jsxs("div",{className:"space-y-4",children:[pe.jsxs("div",{className:"text-sm text-muted-foreground",children:[pe.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",n,":"]}),pe.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:pe.jsx("p",{className:"font-medium text-foreground",children:s.title})})]}),pe.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:pe.jsxs("div",{className:"flex items-start space-x-2",children:[pe.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:pe.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),pe.jsxs("div",{className:"text-sm text-orange-800",children:[pe.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),pe.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",n," será removido permanentemente do sistema."]})]})]})}),pe.jsxs("div",{className:"space-y-2",children:[pe.jsxs(ye,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",pe.jsxs("strong",{children:['"',s.title,'"']})," abaixo:"]}),pe.jsx(be,{id:"confirmation",type:"text",value:i,onChange:e=>l(e.target.value),placeholder:`Digite: ${s.title}`,className:"w-full"})]})]})}),pe.jsxs(Na,{children:[pe.jsx(Sa,{onClick:c,children:"Cancelar"}),pe.jsx(ka,{onClick:()=>{s&&i===s.title&&(r(s),l(""),a(!1))},disabled:!d||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${n}`})]})]})}):null},Ta=M.forwardRef(({className:e,...t},a)=>pe.jsx("table",{ref:a,className:fe("w-full caption-bottom text-sm",e),...t}));Ta.displayName="Table";const Pa=M.forwardRef(({className:e,...t},a)=>pe.jsx("thead",{ref:a,className:fe("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));Pa.displayName="TableHeader";const Aa=M.forwardRef(({className:e,...t},a)=>pe.jsx("tbody",{ref:a,className:fe("[&_tr:last-child]:border-0",e),...t}));Aa.displayName="TableBody";const Ra=M.forwardRef(({className:e,...t},a)=>pe.jsx("tfoot",{ref:a,className:fe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Ra.displayName="TableFooter";const Ea=M.forwardRef(({className:e,...t},a)=>pe.jsx("tr",{ref:a,className:fe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));Ea.displayName="TableRow";const Ia=M.forwardRef(({className:e,...t},a)=>pe.jsx("th",{ref:a,className:fe("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));Ia.displayName="TableHead";const _a=M.forwardRef(({className:e,...t},a)=>pe.jsx("td",{ref:a,className:fe("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));_a.displayName="TableCell";const Da=M.forwardRef(({className:e,...t},a)=>pe.jsx("caption",{ref:a,className:fe("mt-4 text-sm text-muted-foreground",e),...t}));function Oa({className:e,...t}){return pe.jsx("div",{className:fe("animate-pulse rounded-md bg-muted",e),...t})}function za({rows:e=5,columns:t=4}){return pe.jsx("div",{className:"w-full",children:pe.jsxs("div",{className:"rounded-md border",children:[pe.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:pe.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>pe.jsx(Oa,{className:"h-4 w-24"},t))})}),pe.jsx("div",{children:Array.from({length:e}).map((e,a)=>pe.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:pe.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>pe.jsx(Oa,{className:"h-4 w-20"},t))})},a))})]})})}function Fa({count:e=3}){return pe.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>pe.jsxs(Ne,{children:[pe.jsxs(je,{children:[pe.jsx(Oa,{className:"h-4 w-3/4"}),pe.jsx(Oa,{className:"h-3 w-1/2"})]}),pe.jsx(Se,{children:pe.jsxs("div",{className:"space-y-2",children:[pe.jsx(Oa,{className:"h-3 w-full"}),pe.jsx(Oa,{className:"h-3 w-2/3"})]})})]},t))})}Da.displayName="TableCaption";const La={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ma({icon:e,title:t,description:a,action:s,className:r,variant:n="default"}){const o=e?()=>e:La[n];return pe.jsxs("div",{className:fe("flex flex-col items-center justify-center py-12 px-4 text-center",r),children:[pe.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:pe.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),pe.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),a&&pe.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:a}),s&&pe.jsx(ge,{onClick:s.onClick,variant:"outline",children:s.label})]})}const $a=H.Root,Ua=H.Trigger,Ba=H.Group,Va=H.Portal,qa=H.Sub,Wa=H.RadioGroup,Ha=M.forwardRef(({className:e,inset:t,children:a,...s},r)=>pe.jsxs(H.SubTrigger,{ref:r,className:fe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...s,children:[a,pe.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ha.displayName=H.SubTrigger.displayName;const Qa=M.forwardRef(({className:e,...t},a)=>pe.jsx(H.SubContent,{ref:a,className:fe("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Qa.displayName=H.SubContent.displayName;const Ga=M.forwardRef(({className:e,sideOffset:t=4,...a},s)=>pe.jsx(H.Portal,{children:pe.jsx(H.Content,{ref:s,sideOffset:t,className:fe("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-white shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-gray-800 dark:border-gray-700",e),...a})}));Ga.displayName=H.Content.displayName;const Xa=M.forwardRef(({className:e,inset:t,...a},s)=>pe.jsx(H.Item,{ref:s,className:fe("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...a}));Xa.displayName=H.Item.displayName;const Ka=M.forwardRef(({className:e,children:t,checked:a,...s},r)=>pe.jsxs(H.CheckboxItem,{ref:r,className:fe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:a,...s,children:[pe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:pe.jsx(H.ItemIndicator,{children:pe.jsx(l.Check,{className:"h-4 w-4"})})}),t]}));Ka.displayName=H.CheckboxItem.displayName;const Ja=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsxs(H.RadioItem,{ref:s,className:fe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[pe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:pe.jsx(H.ItemIndicator,{children:pe.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Ja.displayName=H.RadioItem.displayName;const Ya=M.forwardRef(({className:e,inset:t,...a},s)=>pe.jsx(H.Label,{ref:s,className:fe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...a}));Ya.displayName=H.Label.displayName;const Za=M.forwardRef(({className:e,...t},a)=>pe.jsx(H.Separator,{ref:a,className:fe("-mx-1 my-1 h-px bg-muted",e),...t}));Za.displayName=H.Separator.displayName;const es=({className:e,...t})=>pe.jsx("span",{className:fe("ml-auto text-xs tracking-widest opacity-60",e),...t});es.displayName="DropdownMenuShortcut";const ts=({onEdit:e,onDelete:t,onToggleStatus:a,isActive:s=!0,canDelete:r=!0,renderAs:n})=>{const o=[];if(e){const t={icon:l.Edit,label:"Editar",onClick:e};o.push(t)}if(a){const e={icon:s?l.PowerOff:l.Power,label:s?"Inativar":"Ativar",onClick:a};o.push(e)}if(r&&t){const e={icon:l.Trash2,label:"Remover",onClick:t,destructive:!0};o.push(e)}return"dropdown"===n?pe.jsx(pe.Fragment,{children:o.map((e,t)=>pe.jsxs(Xa,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[pe.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):pe.jsx(pe.Fragment,{children:o.map((e,t)=>pe.jsxs(ge,{variant:"ghost",size:"sm",onClick:e.onClick,className:"w-full justify-start h-auto py-2 px-3 text-sm font-normal "+(e.destructive?"text-destructive hover:text-destructive":""),children:[pe.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},as=({onEdit:e,onDelete:t,canDelete:a=!0,onToggleStatus:s,isActive:r=!0})=>pe.jsxs($a,{children:[pe.jsx(Ua,{asChild:!0,children:pe.jsx(ge,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:pe.jsx(l.EllipsisVertical,{size:12})})}),pe.jsx(Ga,{align:"end",children:pe.jsx(ts,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),s?.()},isActive:r,canDelete:a,renderAs:"dropdown"})})]}),ss=({manager:t,columns:a,onEdit:s,onView:r,onToggleStatus:n,onDelete:o,renderActions:i,enableBulkActions:c=!1})=>{const[d,u]=e.useState(!1),[m,p]=e.useState(null);e.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e.useEffect(()=>{const e=()=>p(null);if(m)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[m]);const f=(()=>{a.length;let e=0;const t=a.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=100,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})();return d?t.isLoading?pe.jsx(Fa,{count:3}):0===t.entities.length?pe.jsx(Ma,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):pe.jsxs("div",{className:"space-y-4",children:[t.entities.map(e=>pe.jsx(Ne,{className:fe("overflow-hidden cursor-pointer hover:bg-muted/50",c&&t.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),c||s?.(e)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),p({x:t.clientX,y:t.clientY,item:e})},children:pe.jsx(Se,{className:"p-4",children:pe.jsxs("div",{className:"flex items-start gap-3",children:[c&&pe.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:pe.jsx(Ye,{checked:t.selectedIds.includes(e.id),onCheckedChange:()=>t.selectItem(e.id)})}),pe.jsxs("div",{className:"flex-1",children:[a.map(t=>pe.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[pe.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),pe.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):e[t.key]})]},String(t.key))),(s||r||i)&&pe.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:i?i(e):pe.jsx(as,{onEdit:s?()=>{s(e)}:void 0,onDelete:o?()=>o(e):void 0,onToggleStatus:n?()=>n(e):void 0,isActive:e.is_actived})})]})]})})},e.id)),m&&pe.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:pe.jsx(ts,{onEdit:s?()=>{s(m.item),p(null)}:void 0,onDelete:o?()=>{o(m.item),p(null)}:void 0,onToggleStatus:n?()=>{n(m.item),p(null)}:void 0,isActive:m.item.is_actived,canDelete:!!o,renderAs:"context"})})]}):pe.jsxs("div",{className:"flex flex-col h-full",children:[t.isLoading?pe.jsx(za,{rows:5,columns:a.length}):pe.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:pe.jsx("div",{className:"flex-1 overflow-auto",children:pe.jsxs(Ta,{className:"table-auto",children:[pe.jsxs("colgroup",{children:[c&&pe.jsx("col",{style:{width:"50px"}}),f.map((e,t)=>pe.jsx("col",{style:e.style},t)),pe.jsx("col",{style:{width:"100px"}})]}),pe.jsx(Pa,{children:pe.jsxs(Ea,{children:[c&&pe.jsx(Ia,{className:"w-[50px]",children:pe.jsx(Ye,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),a.map(e=>{return pe.jsx(Ia,{className:`${e.className||""} ${e.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:e.sortable?()=>t.handleSort(String(e.key)):void 0,children:pe.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,e.sortable&&(a=String(e.key),t.sortField!==a?pe.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?pe.jsx(l.ArrowUp,{size:14,className:"ml-1"}):pe.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]})},String(e.key));var a}),pe.jsx(Ia,{className:"w-[100px] text-center",children:"Ações"})]})}),pe.jsx(Aa,{children:0===t.entities.length?pe.jsx(Ea,{children:pe.jsx(_a,{colSpan:a.length+1,className:"h-32",children:pe.jsx(Ma,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):t.entities.map(e=>pe.jsxs(Ea,{className:fe("cursor-pointer hover:bg-muted/50",c&&t.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),c||s?.(e)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),p({x:t.clientX,y:t.clientY,item:e})},children:[c&&pe.jsx(_a,{onClick:e=>e.stopPropagation(),children:pe.jsx(Ye,{checked:t.selectedIds.includes(e.id),onCheckedChange:()=>t.selectItem(e.id)})}),a.map(t=>pe.jsx(_a,{className:t.className,children:t.render?t.render(e):e[t.key]},String(t.key))),pe.jsx(_a,{className:"text-center",children:i?i(e):pe.jsx(as,{onEdit:s?()=>s(e):void 0,onDelete:o?()=>o(e):void 0,onToggleStatus:n?()=>n(e):void 0,isActive:e.is_actived})})]},e.id))})]})})}),m&&pe.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:pe.jsx(ts,{onEdit:s?()=>{s(m.item),p(null)}:void 0,onDelete:o?()=>{o(m.item),p(null)}:void 0,onToggleStatus:n?()=>{n(m.item),p(null)}:void 0,isActive:m.item.is_actived,canDelete:!!o,renderAs:"context"})})]})};function rs(t,a,s,r){const[n,o]=e.useState({}),[i,l]=e.useState({}),c=e.useMemo(()=>t,[t]),d=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(t,a);if(e)return e}catch(s){}}};e.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(c),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);d(e)&&(t=e.toISOString().split("T")[0])}else d(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[c,a,s,r]);const f=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...f(e.fields))}),t},h=()=>{const e=f(c),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=f(c).find(t=>t.name===e);if(a){const s=p(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:h,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),h()&&e(n)}}}const ns=Q.Root,os=Q.Trigger,is=M.forwardRef(({className:e,align:t="center",sideOffset:a=4,...s},r)=>pe.jsx(Q.Portal,{children:pe.jsx(Q.Content,{ref:r,align:t,sideOffset:a,className:fe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));is.displayName=Q.Content.displayName;const ls=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],cs=({value:e="#3b82f6",onChange:t,label:a})=>pe.jsxs("div",{className:"space-y-2",children:[a&&pe.jsx(ye,{children:a}),pe.jsxs(ns,{children:[pe.jsx(os,{asChild:!0,children:pe.jsxs(ge,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[pe.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),pe.jsx(is,{className:"w-64",children:pe.jsxs("div",{className:"space-y-3",children:[pe.jsxs("div",{children:[pe.jsx(ye,{htmlFor:"color-input",children:"Cor personalizada"}),pe.jsx(be,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),pe.jsxs("div",{children:[pe.jsx(ye,{children:"Cores predefinidas"}),pe.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ls.map(e=>pe.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]}),ds=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsxs(G.Root,{ref:s,className:fe("relative overflow-hidden",e),...a,children:[pe.jsx(G.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),pe.jsx(us,{}),pe.jsx(G.Corner,{})]}));ds.displayName=G.Root.displayName;const us=M.forwardRef(({className:e,orientation:t="vertical",...a},s)=>pe.jsx(G.ScrollAreaScrollbar,{ref:s,orientation:t,className:fe("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...a,children:pe.jsx(G.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));us.displayName=G.ScrollAreaScrollbar.displayName;const ms={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},ps=({value:t="Star",onChange:a,label:s})=>{const[r,n]=e.useState(""),o=Object.entries(ms).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),i=ms[t]||l.Star;return pe.jsxs("div",{className:"space-y-2",children:[s&&pe.jsx(ye,{children:s}),pe.jsxs(ns,{children:[pe.jsx(os,{asChild:!0,children:pe.jsxs(ge,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[pe.jsx(i,{className:"h-4 w-4 mr-2"}),t]})}),pe.jsx(is,{className:"w-80",children:pe.jsxs("div",{className:"space-y-3",children:[pe.jsxs("div",{children:[pe.jsx(ye,{htmlFor:"icon-search",children:"Buscar ícone"}),pe.jsx(be,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>n(e.target.value)})]}),pe.jsx(ds,{className:"h-48",children:pe.jsx("div",{className:"grid grid-cols-6 gap-2",children:o.map(([e,s])=>pe.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===e?"border-primary bg-primary/10":"border-border"),onClick:()=>a?.(e),title:e,children:pe.jsx(s,{className:"h-4 w-4"})},e))})})]})})]})]})};function fs({value:t,onChange:a,items:s,isLoading:r=!1,error:n=null,getItemValue:o,getItemLabel:i,searchPlaceholder:c="Buscar...",emptyMessage:d="Nenhum item disponível",noResultsMessage:u="Nenhum resultado encontrado",sortItems:m,placeholder:p="Selecionar...",disabled:f=!1,className:h}){const[x,g]=e.useState(""),b=e.useMemo(()=>{const e=m?[...s].sort(m):[...s].sort((e,t)=>i(e).localeCompare(i(t),"pt-BR"));if(!x.trim())return e;const t=x.toLowerCase();return e.filter(e=>i(e).toLowerCase().includes(t))},[s,x,m,i]);return r?pe.jsx(Oa,{className:fe("h-10 w-full",h)}):n?pe.jsxs("div",{className:fe("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[pe.jsx(l.AlertCircle,{className:"h-4 w-4 text-destructive"}),pe.jsx("span",{className:"text-sm text-destructive",children:n.message||"Erro ao carregar dados"})]}):pe.jsxs(We,{value:t,onValueChange:a,disabled:f||0===s.length,children:[pe.jsx(Qe,{className:h,children:pe.jsx(He,{placeholder:p})}),pe.jsxs(Ke,{children:[pe.jsx("div",{className:"px-2 pb-2",children:pe.jsxs("div",{className:"relative",children:[pe.jsx(l.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),pe.jsx(be,{placeholder:c,value:x,onChange:e=>g(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===b.length?pe.jsx(Je,{value:"no-items",disabled:!0,children:x?u:d}):b.map(e=>pe.jsx(Je,{value:o(e),children:i(e)},o(e)))]})]})}const hs=(e={})=>{const{user:t,alias:a}=pa(),s=Jt(),{enabled:r=s.enableUsersApi}=e;return f.useQuery({queryKey:["qualiex-users",a],queryFn:()=>qt.getUsers(a),enabled:r&&!!a&&!!t,retry:2,retryDelay:1e3})},xs=({value:e="",onChange:t,placeholder:a="Selecionar usuário",disabled:s,className:r,enabled:n})=>{const{data:o=[],isLoading:i,error:l}=hs({enabled:n});return pe.jsx(fs,{value:e,onChange:t,items:o,isLoading:i,error:l,getItemValue:e=>e.userId,getItemLabel:e=>e.userName,placeholder:a,searchPlaceholder:"Buscar usuário...",emptyMessage:"Nenhum usuário disponível",noResultsMessage:"Nenhum usuário encontrado",disabled:s,className:r})};function gs({title:t,sections:a,initialData:s,onSubmit:r,onCancel:n,open:o,submitButtonText:i="Salvar",isLoading:l=!1,usersData:c}){const[d,u]=e.useState(a?.[0]?.id||""),m=e.useMemo(()=>a&&Array.isArray(a)?a.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[a]),{formData:p,errors:f,updateField:h,handleSubmit:x}=rs(m,s,void 0,o),g=e.useMemo(()=>a&&Array.isArray(a)?a.map(e=>({...e,disabled:e.condition?!e.condition(p):e.disabled||!1})):[],[a,p]),b=e.useMemo(()=>{const e=g.find(e=>e.id===d);if(e&&!e.disabled)return d;const t=g.find(e=>!e.disabled);return t?.id||d},[g,d]);e.useEffect(()=>{b!==d&&u(b)},[b,d]);const v=g.find(e=>e.id===b),y=e=>{const t=(e.computedValue,p[e.name]),a=void 0!==t?t:"",s=f[e.name];switch(e.type){case"group":return pe.jsxs("div",{className:"space-y-2",children:[e.label,pe.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>y(e))})]},e.name);case"user-select":return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(xs,{value:a||"",onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"textarea":return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(Ze,{id:e.name,value:a||"",onChange:t=>{h(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"select":return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsxs(We,{value:String(a),onValueChange:t=>{h(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[pe.jsx(Qe,{className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:pe.jsx(He,{placeholder:e.placeholder})}),pe.jsx(Ke,{children:e.options?.map(e=>pe.jsx(Je,{value:e.value,children:e.label},e.value))})]}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"date":return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(be,{id:e.name,type:"date",value:String(a),onChange:t=>h(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:fe("w-full",s?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"single-responsible-select":const t=Jt();return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(xs,{value:String(a),onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":"",enabled:t.enableUsersApi}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"simple-qualiex-user-field":const r=Jt();return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(xs,{value:a??"",onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":"",enabled:r.enableUsersApi}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"color":return pe.jsxs("div",{children:[pe.jsxs(ye,{htmlFor:e.name,children:[e.label," ",e.required&&pe.jsx("span",{className:"text-destructive",children:"*"})]}),pe.jsx(be,{id:e.name,type:"color",value:a||e.defaultValue||"#000000",onChange:t=>h(e.name,t.target.value),className:"h-10"}),s&&pe.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return pe.jsxs("div",{children:[pe.jsx(cs,{label:`${e.label} ${e.required?"*":""}`,value:a||e.defaultValue||"#3b82f6",onChange:t=>h(e.name,t)}),s&&pe.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return pe.jsxs("div",{children:[pe.jsx(ps,{label:`${e.label} ${e.required?"*":""}`,value:a||e.defaultValue||"Star",onChange:t=>h(e.name,t)}),s&&pe.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"number":return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(be,{id:e.name,type:"number",value:null!=a?String(a):"",onChange:t=>{const a=t.target.value,s=""===a?null:Number(a);h(e.name,s)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);default:return pe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[pe.jsx(ye,{htmlFor:e.name,children:e.label}),pe.jsx(be,{id:e.name,type:"text",value:a||"",onChange:t=>{h(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:e.disabled}),s&&pe.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name)}},N=e.useCallback(()=>{if(!v)return null;if(v.disabled)return pe.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[pe.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:pe.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:pe.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),pe.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),pe.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(v.component){const e=v.component;return pe.jsx(e,{formData:p,updateField:h,errors:f,users:c,disabled:v.disabled})}return pe.jsx("div",{className:"space-y-3",children:v.fields.map(y)})},[v,p,h,f,c,y]),j=pe.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[g.length>1&&pe.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:pe.jsx("div",{className:"flex space-x-2",children:g.map(e=>pe.jsx(ge,{variant:b===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=g.find(t=>t.id===e);t&&!t.disabled&&u(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),pe.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:l?pe.jsx("div",{className:"flex items-center justify-center py-12",children:pe.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):pe.jsxs("form",{onSubmit:x(r),className:"space-y-3 md:space-y-4",children:[N(),pe.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[pe.jsx(ge,{type:"button",variant:"outline",onClick:n,children:"Cancelar"}),pe.jsx(ge,{type:"submit",disabled:l,children:i})]})]})})]});return pe.jsx(Te,{open:o,onOpenChange:e=>{!1===e&&!0===o&&n()},children:pe.jsxs(Ie,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[pe.jsxs(_e,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[pe.jsx(Oe,{className:"text-white",children:t}),pe.jsx(ze,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),j]})})}function bs({open:e,title:t,sections:a,initialData:s,onSubmit:r,onCancel:n,isLoading:o=!1,submitButtonText:i="Salvar"}){return pe.jsx(gs,{open:e,title:t,sections:a,initialData:s,onSubmit:r,onCancel:n,isLoading:o,submitButtonText:i})}const vs=({manager:e})=>{const{pagination:t={totalItems:0,totalPages:1},currentPage:a=1,itemsPerPage:s=10,handlePageChange:r=()=>{},handleItemsPerPageChange:n=()=>{}}=e,{totalItems:o=0,totalPages:i=1}=t,c=o>0?(a-1)*s+1:0,d=Math.min(a*s,o);return pe.jsxs("div",{className:"px-4 h-12 flex items-center justify-between text-sm text-muted-foreground bg-muted/50 border-t border-border flex-shrink-0 mt-auto",children:[pe.jsxs("div",{className:"flex items-center space-x-3",children:[pe.jsx("span",{children:"Itens por página"}),pe.jsxs(We,{value:s.toString(),onValueChange:e=>n(Number(e)),children:[pe.jsx(Qe,{className:"w-20 h-8 border-border",children:pe.jsx(He,{})}),pe.jsxs(Ke,{children:[pe.jsx(Je,{value:"10",children:"10"}),pe.jsx(Je,{value:"25",children:"25"}),pe.jsx(Je,{value:"50",children:"50"}),pe.jsx(Je,{value:"100",children:"100"})]})]})]}),pe.jsx("div",{className:"flex-1 flex justify-center",children:pe.jsx("span",{children:o>0?`${c}-${d} de ${o} itens (página ${a} de ${i})`:"0 itens"})}),pe.jsxs("div",{className:"flex items-center space-x-1",children:[pe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>r(1),disabled:1===a,children:pe.jsx(l.ChevronsLeft,{className:"h-4 w-4"})}),pe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>r(Math.max(1,a-1)),disabled:1===a,children:pe.jsx(l.ChevronLeft,{className:"h-4 w-4"})}),pe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>r(Math.min(i,a+1)),disabled:a===i,children:pe.jsx(l.ChevronRight,{className:"h-4 w-4"})}),pe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>r(i),disabled:a===i,children:pe.jsx(l.ChevronsRight,{className:"h-4 w-4"})})]})]})},ys=({selectedCount:e,onClearSelection:t,onBulkDelete:a,customActions:s=[],isLoading:r=!1})=>pe.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[pe.jsxs("div",{className:"flex items-center gap-3",children:[pe.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),pe.jsxs(ge,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[pe.jsx(l.X,{size:14,className:"mr-1"}),"Limpar"]})]}),pe.jsxs("div",{className:"flex items-center gap-2",children:[s.map((e,t)=>{const a=e.icon;return pe.jsxs(ge,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:r,className:"h-7",children:[a&&pe.jsx(a,{size:14,className:"mr-1"}),e.label]},t)}),a&&pe.jsxs(ge,{variant:"destructive",size:"sm",onClick:a,disabled:r,className:"h-7",children:[pe.jsx(l.Trash2,{size:14,className:"mr-1"}),"Deletar"]})]})]}),Ns={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},js={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},ws={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function ks({children:e,direction:t="column",gap:a="md",align:s="stretch",justify:r="start",wrap:n=!1,className:o}){return pe.jsx("div",{className:fe("flex","column"===t?"flex-col":"flex-row",Ns[a],js[s],ws[r],n&&"flex-wrap",o),children:e})}function Ss({manager:e,filters:t,inline:a=!1}){const{isSearchVisible:s}=pa(),r=e.searchTerm,n=pe.jsxs(pe.Fragment,{children:[t.some(e=>"search"===e.type)&&!s&&pe.jsxs("div",{className:"relative flex-1",children:[pe.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),pe.jsx(be,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const s=e.component;return pe.jsx("div",{className:a?"":"w-full sm:w-auto",children:pe.jsx(s,{...e.props})},t)}),r&&pe.jsxs(ge,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[pe.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return a?pe.jsx("div",{className:"flex items-center gap-2",children:n}):pe.jsx(ks,{direction:"column",gap:"md",className:"mb-6",children:pe.jsx(ks,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:n})})}function Cs({manager:t,config:a,formSections:s,onSave:r,onToggleStatus:n}){const{setSearchVisible:o}=pa(),[i,c]=e.useState(!1),[d,u]=e.useState(null),[m,p]=e.useState({isOpen:!1,entityId:null,entityName:""}),[f,h]=e.useState({isOpen:!1,count:0});e.useEffect(()=>(o(!0),()=>{o(!1)}),[o]);return pe.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[a.enableBulkActions&&t.selectedIds.length>0&&pe.jsx(ys,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:r?()=>{h({isOpen:!0,count:t.selectedIds.length})}:void 0,customActions:a.bulkActions,isLoading:t.isBulkDeleting}),pe.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[pe.jsx("div",{className:"flex items-center gap-4",children:pe.jsxs(ge,{onClick:()=>{u(null),c(!0)},children:[pe.jsx(l.Plus,{size:16,className:"mr-2"}),"Novo"]})}),a.filters&&a.filters.length>0&&pe.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:pe.jsx(Ss,{manager:t,filters:a.filters,inline:!0})})]}),pe.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:pe.jsx(ss,{manager:t,columns:a.columns,onEdit:e=>{u(e),c(!0)},onDelete:e=>{p({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:n,enableBulkActions:a.enableBulkActions})}),pe.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:pe.jsx(vs,{manager:t})}),pe.jsx(bs,{open:i,title:d?`Editar ${a.entityName}`:`Novo ${a.entityName}`,sections:s,initialData:d||void 0,onSubmit:e=>{r(e),c(!1),u(null)},onCancel:()=>{c(!1),u(null)},isLoading:t.isLoading,submitButtonText:d?"Atualizar":"Criar"}),pe.jsx(Ca,{open:m.isOpen,onOpenChange:()=>{p({isOpen:!1,entityId:null,entityName:""})},onConfirm:e=>{m.entityId&&(t.deleteEntity(m.entityId),p({isOpen:!1,entityId:null,entityName:""}))},item:m.entityId?{id:m.entityId,title:m.entityName}:void 0,entityName:a.entityName,isDeleting:t.isDeleting}),pe.jsx(Ca,{open:f.isOpen,onOpenChange:()=>h({isOpen:!1,count:0}),onConfirm:()=>(t.bulkDelete?.(t.selectedIds),void h({isOpen:!1,count:0})),item:{id:"bulk",title:`${f.count} ${1===f.count?"item":"itens"}`},entityName:a.entityName,isDeleting:t.isBulkDeleting})]})}function Ts(e,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:As(e),label:As(e),...Ps(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}}function Ps(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function As(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Rs={user:{title:"Usuários",searchPlaceholder:"Buscar usuários...",enableDelete:!1},product:{title:"Produtos",searchPlaceholder:"Buscar produtos...",enableFilters:!0},order:{title:"Pedidos",searchPlaceholder:"Buscar pedidos...",enableCreate:!1},category:{title:"Categorias",searchPlaceholder:"Buscar categorias...",itemsPerPage:20}};const Es=a.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Is=M.forwardRef(({className:e,variant:t,...a},s)=>pe.jsx("div",{ref:s,role:"alert",className:fe(Es({variant:t}),e),...a}));Is.displayName="Alert";const _s=M.forwardRef(({className:e,...t},a)=>pe.jsx("h5",{ref:a,className:fe("mb-1 font-medium leading-none tracking-tight",e),...t}));_s.displayName="AlertTitle";const Ds=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("text-sm [&_p]:leading-relaxed",e),...t}));Ds.displayName="AlertDescription";const Os=X.Root,zs=M.forwardRef(({className:e,...t},a)=>pe.jsx(X.Item,{ref:a,className:fe("border-b",e),...t}));zs.displayName="AccordionItem";const Fs=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsx(X.Header,{className:"flex",children:pe.jsxs(X.Trigger,{ref:s,className:fe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...a,children:[t,pe.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Fs.displayName=X.Trigger.displayName;const Ls=M.forwardRef(({className:e,children:t,...a},s)=>pe.jsx(X.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...a,children:pe.jsx("div",{className:fe("pb-4 pt-0",e),children:t})}));Ls.displayName=X.Content.displayName;const Ms=K.Root,$s=M.forwardRef(({className:e,...t},a)=>pe.jsx(J.Root,{ref:a,className:fe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));$s.displayName=J.Root.displayName;const Us=M.forwardRef(({className:e,...t},a)=>pe.jsx(J.Image,{ref:a,className:fe("aspect-square h-full w-full",e),...t}));Us.displayName=J.Image.displayName;const Bs=M.forwardRef(({className:e,...t},a)=>pe.jsx(J.Fallback,{ref:a,className:fe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Bs.displayName=J.Fallback.displayName;const Vs=M.forwardRef(({...e},t)=>pe.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));Vs.displayName="Breadcrumb";const qs=M.forwardRef(({className:e,...t},a)=>pe.jsx("ol",{ref:a,className:fe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));qs.displayName="BreadcrumbList";const Ws=M.forwardRef(({className:e,...t},a)=>pe.jsx("li",{ref:a,className:fe("inline-flex items-center gap-1.5",e),...t}));Ws.displayName="BreadcrumbItem";const Hs=M.forwardRef(({asChild:e,className:t,...a},s)=>{const r=e?M.Fragment:"a";return pe.jsx(r,{ref:s,className:fe("transition-colors hover:text-foreground",t),...a})});Hs.displayName="BreadcrumbLink";const Qs=M.forwardRef(({className:e,...t},a)=>pe.jsx("span",{ref:a,role:"link","aria-disabled":"true","aria-current":"page",className:fe("font-normal text-foreground",e),...t}));Qs.displayName="BreadcrumbPage";const Gs=({children:e,className:t,...a})=>pe.jsx("li",{role:"presentation","aria-hidden":"true",className:fe("[&>svg]:size-3.5",t),...a,children:e??pe.jsx(l.ChevronRight,{})});Gs.displayName="BreadcrumbSeparator";const Xs=({className:e,...t})=>pe.jsxs("span",{role:"presentation","aria-hidden":"true",className:fe("flex h-9 w-9 items-center justify-center",e),...t,children:[pe.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),pe.jsx("span",{className:"sr-only",children:"More"})]});function Ks(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function Js(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}function Ys(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=a.valueCallback?a.valueCallback(c):c;return{value:c,rest:t.slice(o.length)}}}Xs.displayName="BreadcrumbEllipsis";const Zs={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},er={date:Ks({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Ks({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ks({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},tr={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},ar={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:Js({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Js({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Js({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:Js({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:Js({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},sr={ordinalNumber:(rr={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const a=e.match(rr.matchPattern);if(!a)return null;const s=a[0],r=e.match(rr.parsePattern);if(!r)return null;let n=rr.valueCallback?rr.valueCallback(r[0]):r[0];return n=t.valueCallback?t.valueCallback(n):n,{value:n,rest:e.slice(s.length)}}),era:Ys({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:Ys({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ys({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:Ys({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:Ys({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})};var rr;const nr={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=Zs[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:er,formatRelative:(e,t,a,s)=>{const r=tr[e];return"function"==typeof r?r(t):r},localize:ar,match:sr,options:{weekStartsOn:0,firstWeekContainsDate:1}};function or({className:e,classNames:t,showOutsideDays:a=!0,...s}){return pe.jsx(k.DayPicker,{showOutsideDays:a,className:fe("p-3",e),locale:nr,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:fe(xe({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:fe(xe({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...e})=>pe.jsx(l.ChevronLeft,{className:"h-4 w-4"}),IconRight:({...e})=>pe.jsx(l.ChevronRight,{className:"h-4 w-4"})},...s})}or.displayName="Calendar";const ir=Y.Root,lr=Y.CollapsibleTrigger,cr=Y.CollapsibleContent,dr=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));dr.displayName="Command";const ur=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:pe.jsx("input",{ref:a,className:fe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})}));ur.displayName="CommandInput";const mr=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));mr.displayName="CommandList";const pr=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("py-6 text-center text-sm text-muted-foreground",e),...t}));pr.displayName="CommandEmpty";const fr=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));fr.displayName="CommandGroup";const hr=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,className:fe("-mx-1 h-px bg-border",e),...t}));hr.displayName="CommandSeparator";const xr=M.forwardRef(({className:e,disabled:t,onSelect:a,value:s,...r},n)=>pe.jsx("div",{ref:n,className:fe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),"data-disabled":t,onClick:()=>!t&&a?.(s||""),...r}));xr.displayName="CommandItem";const gr=({className:e,...t})=>pe.jsx("span",{className:fe("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});gr.displayName="CommandShortcut";const br={Root:function({children:e,className:t}){return pe.jsx("div",{className:fe("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:a}){return pe.jsx(Ne,{className:fe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",a),onClick:t,children:pe.jsx(Se,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:a}){return pe.jsxs("div",{className:fe("flex justify-between items-center text-sm",a),children:[pe.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),pe.jsx("span",{className:"text-foreground",children:t})]})}},vr={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},yr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Nr({children:e,cols:t="auto-fit",gap:a="md",className:s}){return pe.jsx("div",{className:fe("grid",vr[t],yr[a],s),children:e})}const jr=({className:e,...t})=>pe.jsx("nav",{role:"navigation","aria-label":"pagination",className:fe("mx-auto flex w-full justify-center",e),...t});jr.displayName="Pagination";const wr=M.forwardRef(({className:e,...t},a)=>pe.jsx("ul",{ref:a,className:fe("flex flex-row items-center gap-1",e),...t}));wr.displayName="PaginationContent";const kr=M.forwardRef(({className:e,...t},a)=>pe.jsx("li",{ref:a,className:fe("",e),...t}));kr.displayName="PaginationItem";const Sr=({className:e,isActive:t,size:a="icon",...s})=>pe.jsx("a",{"aria-current":t?"page":void 0,className:fe(xe({variant:t?"outline":"ghost",size:a}),e),...s});Sr.displayName="PaginationLink";const Cr=({className:e,...t})=>pe.jsxs(Sr,{"aria-label":"Go to previous page",size:"default",className:fe("gap-1 pl-2.5",e),...t,children:[pe.jsx(l.ChevronLeft,{className:"h-4 w-4"}),pe.jsx("span",{children:"Previous"})]});Cr.displayName="PaginationPrevious";const Tr=({className:e,...t})=>pe.jsxs(Sr,{"aria-label":"Go to next page",size:"default",className:fe("gap-1 pr-2.5",e),...t,children:[pe.jsx("span",{children:"Next"}),pe.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Tr.displayName="PaginationNext";const Pr=({className:e,...t})=>pe.jsxs("span",{"aria-hidden":!0,className:fe("flex h-9 w-9 items-center justify-center",e),...t,children:[pe.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),pe.jsx("span",{className:"sr-only",children:"More pages"})]});Pr.displayName="PaginationEllipsis";const Ar=M.forwardRef(({className:e,value:t,...a},s)=>pe.jsx(Z.Root,{ref:s,className:fe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...a,children:pe.jsx(Z.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Ar.displayName=Z.Root.displayName;const Rr=M.forwardRef(({className:e,...t},a)=>pe.jsx(ee.Root,{className:fe("grid gap-2",e),...t,ref:a}));Rr.displayName=ee.Root.displayName;const Er=M.forwardRef(({className:e,...t},a)=>pe.jsx(ee.Item,{ref:a,className:fe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:pe.jsx(ee.Indicator,{className:"flex items-center justify-center",children:pe.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Er.displayName=ee.Item.displayName;const Ir=M.forwardRef(({className:e,orientation:t="horizontal",decorative:a=!0,...s},r)=>pe.jsx(te.Root,{ref:r,decorative:a,orientation:t,className:fe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...s}));Ir.displayName=te.Root.displayName;const _r=U.Root,Dr=U.Trigger,Or=U.Close,zr=U.Portal,Fr=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Overlay,{className:fe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:a}));Fr.displayName=U.Overlay.displayName;const Lr=a.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Mr=M.forwardRef(({side:e="right",className:t,children:a,...s},r)=>pe.jsxs(zr,{children:[pe.jsx(Fr,{}),pe.jsxs(U.Content,{ref:r,className:fe(Lr({side:e}),t),...s,children:[a,pe.jsxs(U.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[pe.jsx(l.X,{className:"h-4 w-4"}),pe.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mr.displayName=U.Content.displayName;const $r=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col space-y-2 text-center sm:text-left",e),...t});$r.displayName="SheetHeader";const Ur=({className:e,...t})=>pe.jsx("div",{className:fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ur.displayName="SheetFooter";const Br=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Title,{ref:a,className:fe("text-lg font-semibold text-foreground",e),...t}));Br.displayName=U.Title.displayName;const Vr=M.forwardRef(({className:e,...t},a)=>pe.jsx(U.Description,{ref:a,className:fe("text-sm text-muted-foreground",e),...t}));Vr.displayName=U.Description.displayName;const qr=ae.Provider,Wr=ae.Root,Hr=ae.Trigger,Qr=M.forwardRef(({className:e,sideOffset:t=4,...a},s)=>pe.jsx(ae.Content,{ref:s,sideOffset:t,className:fe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a}));Qr.displayName=ae.Content.displayName;const Gr="sidebar:state",Xr=M.createContext(null);function Kr(){const e=M.useContext(Xr);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Jr=M.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:a,className:s,style:r,children:n,...o},i)=>{const[l,c]=M.useState(!1);M.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[d,u]=M.useState(!1),[m,p]=M.useState(()=>{if("undefined"!=typeof window){const t=localStorage.getItem(Gr);return null!==t?"true"===t:e}return e}),f=t??m,h=M.useCallback(e=>{const t="function"==typeof e?e(f):e;a?a(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Gr,String(t))},[a,f]),x=M.useCallback(()=>l?u(e=>!e):h(e=>!e),[l,h,u]);M.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const g=f?"expanded":"collapsed",b=M.useMemo(()=>({state:g,open:f,setOpen:h,isMobile:l,openMobile:d,setOpenMobile:u,toggleSidebar:x}),[g,f,h,l,d,u,x]);return pe.jsx(Xr.Provider,{value:b,children:pe.jsx(qr,{delayDuration:0,children:pe.jsx("div",{className:fe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",s),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...r},ref:i,...o,children:n})})})});Jr.displayName="SidebarProvider";const Yr=M.forwardRef(({side:e="left",variant:t="sidebar",collapsible:a="offcanvas",className:s,children:r,...n},o)=>{const{isMobile:i,state:l,openMobile:c,setOpenMobile:d}=Kr();return"none"===a?pe.jsx("div",{className:fe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:o,...n,children:r}):i?pe.jsx(_r,{open:c,onOpenChange:d,...n,children:pe.jsxs(Mr,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:e,children:[pe.jsx(Br,{className:"sr-only",children:"Menu de Navegação"}),pe.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):pe.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?a:"","data-variant":t,"data-side":e,children:[pe.jsx("div",{className:fe("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),pe.jsx("div",{className:fe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...n,children:pe.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:r})})]})});Yr.displayName="Sidebar";const Zr=M.forwardRef(({className:e,onClick:t,...a},s)=>{const{toggleSidebar:r}=Kr();return pe.jsxs(ge,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:fe("h-7 w-7",e),onClick:e=>{t?.(e),r()},...a,children:[pe.jsx(l.PanelLeft,{}),pe.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Zr.displayName="SidebarTrigger";const en=M.forwardRef(({className:e,...t},a)=>{const{toggleSidebar:s}=Kr();return pe.jsx("button",{ref:a,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:fe("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});en.displayName="SidebarRail";const tn=M.forwardRef(({className:e,...t},a)=>pe.jsx("main",{ref:a,className:fe("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));tn.displayName="SidebarInset";const an=M.forwardRef(({className:e,...t},a)=>pe.jsx(be,{ref:a,"data-sidebar":"input",className:fe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));an.displayName="SidebarInput";const sn=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"header",className:fe("flex flex-col gap-2 p-2",e),...t}));sn.displayName="SidebarHeader";const rn=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"footer",className:fe("flex flex-col gap-2 p-2",e),...t}));rn.displayName="SidebarFooter";const nn=M.forwardRef(({className:e,...t},a)=>pe.jsx(Ir,{ref:a,"data-sidebar":"separator",className:fe("mx-2 w-auto bg-sidebar-border",e),...t}));nn.displayName="SidebarSeparator";const on=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"content",className:fe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));on.displayName="SidebarContent";const ln=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"group",className:fe("relative flex w-full min-w-0 flex-col p-2",e),...t}));ln.displayName="SidebarGroup";const cn=M.forwardRef(({className:e,asChild:a=!1,...s},r)=>{const n=a?t.Slot:"div";return pe.jsx(n,{ref:r,"data-sidebar":"group-label",className:fe("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...s})});cn.displayName="SidebarGroupLabel";const dn=M.forwardRef(({className:e,asChild:a=!1,...s},r)=>{const n=a?t.Slot:"button";return pe.jsx(n,{ref:r,"data-sidebar":"group-action",className:fe("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...s})});dn.displayName="SidebarGroupAction";const un=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"group-content",className:fe("w-full text-sm",e),...t}));un.displayName="SidebarGroupContent";const mn=M.forwardRef(({className:e,...t},a)=>pe.jsx("ul",{ref:a,"data-sidebar":"menu",className:fe("flex w-full min-w-0 flex-col gap-1",e),...t}));mn.displayName="SidebarMenu";const pn=M.forwardRef(({className:e,...t},a)=>pe.jsx("li",{ref:a,"data-sidebar":"menu-item",className:fe("group/menu-item relative",e),...t}));pn.displayName="SidebarMenuItem";const fn=a.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),hn=M.forwardRef(({asChild:e=!1,isActive:a=!1,variant:s="default",size:r="default",tooltip:n,className:o,...i},l)=>{const c=e?t.Slot:"button",{isMobile:d,state:u}=Kr(),m=pe.jsx(c,{ref:l,"data-sidebar":"menu-button","data-size":r,"data-active":a,className:fe(fn({variant:s,size:r}),o),...i});return n?("string"==typeof n&&(n={children:n}),pe.jsxs(Wr,{children:[pe.jsx(Hr,{asChild:!0,children:m}),pe.jsx(Qr,{side:"right",align:"center",hidden:"collapsed"!==u||d,...n})]})):m});hn.displayName="SidebarMenuButton";const xn=M.forwardRef(({className:e,asChild:a=!1,showOnHover:s=!1,...r},n)=>{const o=a?t.Slot:"button";return pe.jsx(o,{ref:n,"data-sidebar":"menu-action",className:fe("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",s&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});xn.displayName="SidebarMenuAction";const gn=M.forwardRef(({className:e,...t},a)=>pe.jsx("div",{ref:a,"data-sidebar":"menu-badge",className:fe("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));gn.displayName="SidebarMenuBadge";const bn=M.forwardRef(({className:e,showIcon:t=!1,...a},s)=>{const r=M.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return pe.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:fe("rounded-md h-8 flex gap-2 px-2 items-center",e),...a,children:[t&&pe.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),pe.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":r}})]})});bn.displayName="SidebarMenuSkeleton";const vn=M.forwardRef(({className:e,...t},a)=>pe.jsx("ul",{ref:a,"data-sidebar":"menu-sub",className:fe("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));vn.displayName="SidebarMenuSub";const yn=M.forwardRef(({...e},t)=>pe.jsx("li",{ref:t,...e}));yn.displayName="SidebarMenuSubItem";const Nn=M.forwardRef(({asChild:e=!1,size:a="md",isActive:s,className:r,...n},o)=>{const i=e?t.Slot:"a";return pe.jsx(i,{ref:o,"data-sidebar":"menu-sub-button","data-size":a,"data-active":s,className:fe("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",r),...n})});Nn.displayName="SidebarMenuSubButton";const jn=M.forwardRef(({className:e,...t},a)=>pe.jsxs(se.Root,{ref:a,className:fe("relative flex w-full touch-none select-none items-center",e),...t,children:[pe.jsx(se.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:pe.jsx(se.Range,{className:"absolute h-full bg-primary"})}),pe.jsx(se.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));jn.displayName=se.Root.displayName;function wn(e,t,{checkForDefaultPrevented:a=!0}={}){return function(s){if(e?.(s),!1===a||!s.defaultPrevented)return t?.(s)}}function kn(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Sn(...e){return M.useCallback(function(...e){return t=>{let a=!1;const s=e.map(e=>{const s=kn(e,t);return a||"function"!=typeof s||(a=!0),s});if(a)return()=>{for(let t=0;t<s.length;t++){const a=s[t];"function"==typeof a?a():kn(e[t],null)}}}}(...e),e)}function Cn(...e){const t=e[0];if(1===e.length)return t;const a=()=>{const a=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const s=a.reduce((t,{useScope:a,scopeName:s})=>({...t,...a(e)[`__scope${s}`]}),{});return M.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return a.scopeName=t.scopeName,a}var Tn=globalThis?.document?M.useLayoutEffect:()=>{},Pn=M[" useInsertionEffect ".trim().toString()]||Tn;function An({prop:e,defaultProp:t,onChange:a=()=>{},caller:s}){const[r,n,o]=function({defaultProp:e,onChange:t}){const[a,s]=M.useState(e),r=M.useRef(a),n=M.useRef(t);return Pn(()=>{n.current=t},[t]),M.useEffect(()=>{r.current!==a&&(n.current?.(a),r.current=a)},[a,r]),[a,s,n]}({defaultProp:t,onChange:a}),i=void 0!==e,l=i?e:r;{const t=M.useRef(void 0!==e);M.useEffect(()=>{const e=t.current;if(e!==i){}t.current=i},[i,s])}const c=M.useCallback(t=>{if(i){const a=function(e){return"function"==typeof e}(t)?t(e):t;a!==e&&o.current?.(a)}else n(t)},[i,e,n,o]);return[l,c]}var Rn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,a)=>{const s=t.createSlot(`Primitive.${a}`),r=M.forwardRef((e,t)=>{const{asChild:r,...n}=e,o=r?s:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),pe.jsx(o,{...n,ref:t})});return r.displayName=`Primitive.${a}`,{...e,[a]:r}},{}),En="Switch",[In]=function(e,t=[]){let a=[];const s=()=>{const t=a.map(e=>M.createContext(e));return function(a){const s=a?.[e]||t;return M.useMemo(()=>({[`__scope${e}`]:{...a,[e]:s}}),[a,s])}};return s.scopeName=e,[function(t,s){const r=M.createContext(s),n=a.length;a=[...a,s];const o=t=>{const{scope:a,children:s,...o}=t,i=a?.[e]?.[n]||r,l=M.useMemo(()=>o,Object.values(o));return pe.jsx(i.Provider,{value:l,children:s})};return o.displayName=t+"Provider",[o,function(a,o){const i=o?.[e]?.[n]||r,l=M.useContext(i);if(l)return l;if(void 0!==s)return s;throw new Error(`\`${a}\` must be used within \`${t}\``)}]},Cn(s,...t)]}(En),[_n,Dn]=In(En),On=M.forwardRef((e,t)=>{const{__scopeSwitch:a,name:s,checked:r,defaultChecked:n,required:o,disabled:i,value:l="on",onCheckedChange:c,form:d,...u}=e,[m,p]=M.useState(null),f=Sn(t,e=>p(e)),h=M.useRef(!1),x=!m||(d||!!m.closest("form")),[g,b]=An({prop:r,defaultProp:n??!1,onChange:c,caller:En});return pe.jsxs(_n,{scope:a,checked:g,disabled:i,children:[pe.jsx(Rn.button,{type:"button",role:"switch","aria-checked":g,"aria-required":o,"data-state":Mn(g),"data-disabled":i?"":void 0,disabled:i,value:l,...u,ref:f,onClick:wn(e.onClick,e=>{b(e=>!e),x&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),x&&pe.jsx(Ln,{control:m,bubbles:!h.current,name:s,value:l,checked:g,required:o,disabled:i,form:d,style:{transform:"translateX(-100%)"}})]})});On.displayName=En;var zn="SwitchThumb",Fn=M.forwardRef((e,t)=>{const{__scopeSwitch:a,...s}=e,r=Dn(zn,a);return pe.jsx(Rn.span,{"data-state":Mn(r.checked),"data-disabled":r.disabled?"":void 0,...s,ref:t})});Fn.displayName=zn;var Ln=M.forwardRef(({__scopeSwitch:e,control:t,checked:a,bubbles:s=!0,...r},n)=>{const o=M.useRef(null),i=Sn(o,n),l=function(e){const t=M.useRef({value:e,previous:e});return M.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(a),c=function(e){const[t,a]=M.useState(void 0);return Tn(()=>{if(e){a({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const s=t[0];let r,n;if("borderBoxSize"in s){const e=s.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,n=t.blockSize}else r=e.offsetWidth,n=e.offsetHeight;a({width:r,height:n})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}a(void 0)},[e]),t}(t);return M.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(t,"checked").set;if(l!==a&&r){const t=new Event("click",{bubbles:s});r.call(e,a),e.dispatchEvent(t)}},[l,a,s]),pe.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a,...r,tabIndex:-1,ref:i,style:{...r.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Mn(e){return e?"checked":"unchecked"}Ln.displayName="SwitchBubbleInput";var $n=On,Un=Fn;const Bn=M.forwardRef(({className:e,...t},a)=>pe.jsx($n,{className:fe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:a,children:pe.jsx(Un,{className:fe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Bn.displayName=$n.displayName;const Vn=re.Root,qn=M.forwardRef(({className:e,...t},a)=>pe.jsx(re.List,{ref:a,className:fe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));qn.displayName=re.List.displayName;const Wn=M.forwardRef(({className:e,...t},a)=>pe.jsx(re.Trigger,{ref:a,className:fe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Wn.displayName=re.Trigger.displayName;const Hn=M.forwardRef(({className:e,...t},a)=>pe.jsx(re.Content,{ref:a,className:fe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Hn.displayName=re.Content.displayName;const Qn=a.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Gn=M.forwardRef(({className:e,variant:t,size:a,...s},r)=>pe.jsx(ne.Root,{ref:r,className:fe(Qn({variant:t,size:a,className:e})),...s}));Gn.displayName=ne.Root.displayName;const Xn=M.createContext({size:"default",variant:"default"}),Kn=M.forwardRef(({className:e,variant:t,size:a,children:s,...r},n)=>pe.jsx(oe.Root,{ref:n,className:fe("flex items-center justify-center gap-1",e),...r,children:pe.jsx(Xn.Provider,{value:{variant:t,size:a},children:s})}));Kn.displayName=oe.Root.displayName;const Jn=M.forwardRef(({className:e,children:t,variant:a,size:s,...r},n)=>{const o=M.useContext(Xn);return pe.jsx(oe.Item,{ref:n,className:fe(Qn({variant:o.variant||a,size:o.size||s}),e),...r,children:t})});Jn.displayName=oe.Item.displayName;const Yn=e.forwardRef(({variant:e="default",className:t,children:a,...s},r)=>pe.jsx(ge,{ref:r,variant:"outline",size:"sm",className:fe("h-7 px-2 text-xs","border-primary/20 text-primary hover:bg-primary/5",t),...s,children:a||pe.jsx(l.EllipsisVertical,{size:12})}));function Zn(e){const t=h.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}Yn.displayName="ActionButton";const eo=e.memo(({variant:t="card",className:a="",selectedUnit:s,onUnitChange:r})=>{const{user:n,companies:o,alias:i,isAuthenticated:c,logout:d,switchUnit:u}=pa(),m=o?.[0]||null,p=i?o?.find(e=>e.alias===i):m,f=o||[],h=s||p||m||m,x=e.useCallback(e=>{r?r(e):u(e)},[r,u]),g=e.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===h?.alias),s=t.filter(e=>e.alias!==h?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[f,h?.alias]);if(!c||!n)return null;const b=()=>pe.jsxs(pe.Fragment,{children:[pe.jsxs("div",{className:"flex items-center space-x-3",children:[pe.jsx("div",{className:"flex-shrink-0",children:pe.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:pe.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),pe.jsxs("div",{className:"flex-1 min-w-0",children:[pe.jsx("p",{className:"text-sm font-medium truncate",children:n.name}),pe.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",h?.name||"N/A"]})]})]}),h&&pe.jsx("div",{className:"mt-3",children:pe.jsxs("div",{className:"flex items-center space-x-2",children:[pe.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),pe.jsx("span",{className:"text-sm font-medium",children:h.name})]})}),g.length>1&&pe.jsxs("div",{className:"mt-2",children:[pe.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),pe.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>pe.jsx(tt,{variant:e.alias===h?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>x(e),children:e.name},e.alias)),g.length>3&&pe.jsxs(tt,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===t?pe.jsxs($a,{children:[pe.jsx(Ua,{asChild:!0,children:pe.jsx(ge,{variant:"ghost",className:`h-auto p-2 ${a}`,children:pe.jsxs("div",{className:"flex items-center space-x-2",children:[pe.jsxs("div",{className:"hidden md:block text-left",children:[pe.jsx("p",{className:"text-sm font-medium",children:n.name}),pe.jsx("p",{className:"text-xs text-muted-foreground",children:h?.name||"N/A"})]}),pe.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:pe.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),pe.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),pe.jsxs(Ga,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[pe.jsxs(qa,{children:[pe.jsxs(Ha,{children:[pe.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),pe.jsx(Qa,{children:g.map(e=>pe.jsxs(Xa,{onClick:()=>x(e),className:e.alias===h?.alias?"bg-muted":"",children:[pe.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===h?.alias&&pe.jsx(tt,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),pe.jsx(Za,{}),pe.jsxs(Xa,{onClick:d,children:[pe.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):pe.jsxs(Ne,{className:a,children:[pe.jsx(je,{children:pe.jsx(we,{className:"text-lg",children:"Informações do Usuário"})}),pe.jsxs(Se,{className:"space-y-4",children:[pe.jsx(b,{}),pe.jsx(Ir,{}),pe.jsxs(ge,{variant:"outline",onClick:d,size:"sm",className:"w-full",children:[pe.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),to=e.createContext({});function ao({children:t,config:a}){const s=e.useMemo(()=>({navigation:a?.navigation,appName:a?.appName}),[a?.navigation,a?.appName]);return pe.jsx(to.Provider,{value:s,children:t})}function so(){return e.useContext(to)}function ro(){const e=h.useLocation(),{navigation:t}=so(),a=t?.find(t=>t.path===e.pathname);return a?.label||"Página"}function no(t,a){const[s,r]=e.useState(t),n=e.useRef(),o=e.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return e.useEffect(()=>(o(),n.current=setTimeout(()=>{r(t)},a),o),[t,a,o]),[s,o]}const oo=e.memo(function({actions:t}){const a=h.useLocation(),s=ro(),{navigation:r,appName:n}=so(),{companies:o,alias:i,isSearchVisible:c,clearSearch:d,refreshData:u,switchUnit:m}=pa(),p=i?o?.find(e=>e.alias===i)||o?.[0]||null:o?.[0]||null,[f,x]=h.useSearchParams(),[g,b]=e.useState(()=>f.get("search")||""),[v,y]=no(g,Gt.debounceDelay);e.useEffect(()=>{if(!c)return;const e=new URLSearchParams(f);v?(e.set("search",v),e.set("page","1")):e.delete("search"),x(e)},[v,x,c]);const N=r?.find(e=>e.path===a.pathname);return pe.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:pe.jsxs("div",{className:"flex items-center gap-4",children:[pe.jsxs("div",{className:"flex-shrink-0",children:[pe.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[pe.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:s}),pe.jsx(tt,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:n||"Módulo"})]}),pe.jsx("p",{className:"text-sm text-muted-foreground truncate",children:N?.complementaryText||"Detalhes do item"})]}),c&&pe.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[pe.jsxs("div",{className:"relative flex-1",children:[pe.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),pe.jsx(be,{placeholder:"/wiki"===a.pathname?"Buscar artigos...":"Buscar...",value:g,onChange:e=>(e=>{b(e)})(e.target.value),className:"w-full pl-10 pr-8"}),g&&pe.jsx(ge,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-gray-100",onClick:()=>{y(),b("");const e=new URLSearchParams(f);e.delete("search"),e.delete("page"),x(e)},title:"Limpar busca",children:pe.jsx(l.X,{size:14})})]}),pe.jsx(ge,{variant:"outline",size:"sm",onClick:u,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:pe.jsx(l.RefreshCw,{size:14})})]}),pe.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[t&&pe.jsx("div",{className:"flex items-center gap-2",children:t}),pe.jsx("div",{className:"text-sm",children:pe.jsx(eo,{variant:"dropdown",selectedUnit:p,onUnitChange:m})})]})]})})}),io=(e={})=>{const{enabled:t=!0}=e,{alias:a}=pa();return f.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=$t(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!ua.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},lo=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>f.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),co=(void 0).VITE_SUPABASE_PROJECT_ID,uo={logo:`https://${co}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${co}.supabase.co/storage/v1/object/public/library-assets/small.svg`},mo=uo.logo,po=uo.smallLogo,fo="forlogic-sidebar-pinned",ho=()=>{try{const e=localStorage.getItem(fo);return!!e&&JSON.parse(e)}catch{return!1}};function xo({config:t}={}){const{state:a,open:s,setOpen:r}=Kr(),n=h.useLocation(),{alias:o,user:i}=pa(),[c,d]=e.useState(!1),[u,m]=e.useState(ho),[p,f]=e.useState(!1);e.useEffect(()=>{r(!!u||!(!p&&!c))},[u,p,c,r]);const{data:x,isLoading:g,error:b}=io({enabled:c}),v=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]};return pe.jsxs(Yr,{collapsible:"icon",onMouseEnter:()=>{u||f(!0)},onMouseLeave:()=>{u||f(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[pe.jsxs(sn,{className:"p-0 gap-0",children:[pe.jsx("div",{className:"flex items-center justify-between h-[34px]",children:s?pe.jsxs(pe.Fragment,{children:[pe.jsx("div",{className:"flex items-center pl-[12px]",children:pe.jsx("img",{src:uo.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),pe.jsx("button",{onClick:()=>{const e=!u;m(e),(e=>{try{localStorage.setItem(fo,JSON.stringify(e))}catch{}})(e)},className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(u?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:pe.jsx(l.PanelLeft,{className:"h-4 w-4"})})]}):pe.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:pe.jsx("img",{src:uo.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),pe.jsx("div",{className:"mt-2 pt-0",children:pe.jsxs($a,{onOpenChange:d,children:[pe.jsx(Ua,{asChild:!0,children:s?pe.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[pe.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[pe.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),pe.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:t?.appName||"Título do módulo"})]}),pe.jsx(l.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):pe.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:pe.jsx(l.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),pe.jsx(Ga,{className:s?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:s?"start":"center",children:g?pe.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[pe.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),pe.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):b?pe.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[pe.jsx(l.AlertCircle,{className:"h-4 w-4"}),pe.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):x&&0!==x.length?pe.jsx("div",{className:"space-y-2",children:x.map((e,t)=>pe.jsx("div",{onClick:()=>(e=>{const t=x?.find(t=>t.url===e);t?.url&&window.open(t.url,"_blank")})(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${v(t)} transition-colors duration-200\n `,children:pe.jsxs("div",{className:"flex items-center justify-between",children:[pe.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&pe.jsx(l.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):pe.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),pe.jsx(on,{children:pe.jsx(ln,{className:"p-0 mt-6",children:pe.jsx(un,{children:pe.jsx(mn,{className:"space-y-2",children:pe.jsx(qr,{children:t?.navigation?.map((e,t)=>{const a=({item:e,index:t})=>{const a=`${e.path}-${t}-${o??"noalias"}-${i?.id??"nouser"}`,{data:s=!0,isLoading:r}=lo({key:a,enabled:Boolean(e.permissionCheck&&o&&i?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),c=e.permissionCheck&&!s,d=r?l.Loader2:c?l.Lock:e.icon;return c||e.complementaryText,pe.jsx(pn,{children:c||r?pe.jsxs(Wr,{children:[pe.jsx(Hr,{asChild:!0,children:pe.jsx(hn,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:pe.jsxs("div",{className:"flex w-full items-center gap-3",children:[pe.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:pe.jsx(d,{className:"h-4 w-4 "+(r?"animate-spin":"")})}),pe.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),pe.jsx(Qr,{children:pe.jsx("p",{children:r?"Verificando acesso...":"Acesso restrito"})})]}):pe.jsx(hn,{asChild:!0,isActive:(u=e.path,n.pathname===u),size:"lg",className:"h-10",children:pe.jsxs(h.Link,{to:e.path,className:"flex w-full items-center gap-3",children:[pe.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:pe.jsx(d,{className:"h-5 w-4"})}),pe.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path);var u};return pe.jsx(a,{item:e,index:t},e.path)})})})})})})]})}const go=e.memo(function({children:t,sidebar:a,sidebarConfig:s,showHeader:r=!0}){const n=e.useMemo(()=>a||pe.jsx(xo,{config:s}),[a,s]),o=e.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return pe.jsx(ao,{config:s,children:pe.jsx(Jr,{defaultOpen:!1,style:o,children:pe.jsxs("div",{className:"min-h-screen flex w-full",children:[n,pe.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&pe.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:pe.jsx(oo,{})}),pe.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:t})]})]})})})});class bo extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){_t.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:pe.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsxs(je,{className:"text-center",children:[pe.jsx("div",{className:"flex justify-center mb-4",children:pe.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),pe.jsx(we,{children:"Algo deu errado"})]}),pe.jsxs(Se,{className:"text-center space-y-4",children:[pe.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),pe.jsx(ge,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function vo(){const[t,a]=e.useState([]),[s,r]=e.useState(!1),[n,o]=e.useState(null),[i,l]=e.useState(null);e.useEffect(()=>{c()},[]);const c=async()=>{try{const e=$t(),{data:t,error:s}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(s)throw s;o(t.threadId),a([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){l("Erro ao inicializar conversa"),x.toast.error("Erro ao inicializar conversa")}};return{messages:t,isLoading:s,error:i,sendMessage:e.useCallback(async e=>{if(!n||!e.trim())return;const t={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};a(e=>[...e,t]),r(!0),l(null);try{const t=$t(),{data:s,error:r}=await t.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:n,message:e}});if(r)throw r;const{runId:o}=s,i=await(async e=>{if(!n)return!1;for(let a=0;a<60;a++)try{const t=$t(),{data:a,error:s}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:n,runId:e}});if(s)throw s;const{status:r}=a;if("completed"===r)return!0;if("failed"===r||"cancelled"===r)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(o);i&&await(async()=>{if(n)try{const e=$t(),{data:t,error:s}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:n}});if(s)throw s;const r=t.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));a(r)}catch(e){throw e}})()}catch(s){const e=s instanceof Error?s.message:"Erro ao enviar mensagem";l(e),x.toast.error(e),a(e=>e.filter(e=>e.id!==t.id))}finally{r(!1)}},[n]),threadId:n}}function yo({content:e,className:t}){return pe.jsx("div",{className:fe("prose prose-sm max-w-none",t),children:pe.jsx(O,{remarkPlugins:[z],components:{h1:({children:e})=>pe.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>pe.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>pe.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>pe.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>pe.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>pe.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>pe.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...a})=>e?pe.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...a,children:t}):pe.jsx("code",{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...a,children:t}),pre:({children:e})=>pe.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>pe.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>pe.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>pe.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>pe.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return x.toast}}),exports.AUTH_CONFIG=Ht,exports.Accordion=Os,exports.AccordionContent=Ls,exports.AccordionItem=zs,exports.AccordionTrigger=Fs,exports.ActionButton=Yn,exports.ActionMenuItems=ts,exports.Alert=Is,exports.AlertDescription=Ds,exports.AlertDialog=ha,exports.AlertDialogAction=ka,exports.AlertDialogCancel=Sa,exports.AlertDialogContent=va,exports.AlertDialogDescription=wa,exports.AlertDialogFooter=Na,exports.AlertDialogHeader=ya,exports.AlertDialogOverlay=ba,exports.AlertDialogPortal=ga,exports.AlertDialogTitle=ja,exports.AlertDialogTrigger=xa,exports.AlertTitle=_s,exports.AppHeader=oo,exports.AppLayout=go,exports.AppSidebar=xo,exports.AspectRatio=Ms,exports.AuthErrorInterceptor=ua,exports.AuthProvider=({children:t})=>{const[a,s]=e.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null});let r=null;try{r=f.useQueryClient()}catch{}const[n,o]=e.useState(!1),[i,l]=e.useState(0),c=e.useCallback(e=>{s(t=>({...t,...e}))},[]),d=e.useCallback(e=>{s(t=>({...t,isLoading:e}))},[]),u=e.useCallback(()=>{s({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null})},[]),m=e.useCallback(async e=>{try{d(!0);const t=Rt.getAccessToken();if(!t)return;const a=await na.generateToken(t,e.alias,void 0,!0);if(!a)return;Rt.setSupabaseToken(a),Rt.setSelectedAlias(e.alias);const s=Rt.extractTokenData(),n=s?.alias||e.alias,o={id:s?.companyId||Rt.getCompanyId(e.alias)||e.id,name:e.name,alias:n};c({alias:n,selectedUnit:o}),r&&(await r.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{d(!1)}},[c,r,d]),p=e.useCallback(async()=>await da.processCallback(),[]),h=e.useCallback(async()=>{da.logout(),u(),r&&await r.clear()},[u,r]),x=e.useCallback(e=>{o(e)},[]),g=e.useCallback(()=>{l(e=>e+1)},[]),b=e.useCallback(()=>{l(e=>e+1)},[]);e.useEffect(()=>{if(!a.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Rt.areAllTokensValid()||e&&h())},6e5);return()=>{e=!1,clearInterval(t)}},[a.isAuthenticated,h]),e.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await da.initialize();if(!e)return;t&&t.isAuthenticated?c({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias}):e&&d(!1)}catch(t){e&&(ua.handleError(t),d(!1))}})(),()=>{e=!1}},[c,d,h]);const v=e.useMemo(()=>({...a,logout:h,processCallback:p,switchUnit:m,availableUnits:a.companies,isSearchVisible:n,setSearchVisible:x,clearSearch:g,refreshData:b}),[a.user,a.companies,a.alias,a.isAuthenticated,a.isLoading,a.selectedUnit,a.userId,a.userAlias,h,p,m,n,x,g,b]);return pe.jsx(ma.Provider,{value:v,children:t})},exports.AuthService=da,exports.Avatar=$s,exports.AvatarFallback=Bs,exports.AvatarImage=Us,exports.Badge=tt,exports.BaseForm=gs,exports.Breadcrumb=Vs,exports.BreadcrumbEllipsis=Xs,exports.BreadcrumbItem=Ws,exports.BreadcrumbLink=Hs,exports.BreadcrumbList=qs,exports.BreadcrumbPage=Qs,exports.BreadcrumbSeparator=Gs,exports.BulkActionBar=ys,exports.Button=ge,exports.CRUD_CONFIG=Qt,exports.Calendar=or,exports.CallbackPage=()=>{const{processCallback:t}=pa(),[a,s]=e.useState(null),[r,n]=e.useState(!1);e.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else s("Falha na autenticação. Tente novamente.")}catch(e){s(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{n(!0),s(null);try{await t()||s("Falha na autenticação. Tente novamente.")}catch(e){s(e?.message||"Erro ao tentar novamente.")}finally{n(!1)}},i=()=>{window.location.href="/"};return a?pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsxs(we,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[pe.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),pe.jsxs(Se,{className:"space-y-4",children:[pe.jsx(Is,{variant:"destructive",children:pe.jsx(Ds,{children:a})}),pe.jsx("div",{className:"text-sm text-muted-foreground",children:pe.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),pe.jsxs("div",{className:"flex gap-2",children:[pe.jsx(ge,{onClick:o,disabled:r,className:"flex-1",children:r?pe.jsxs(pe.Fragment,{children:[pe.jsx(st,{size:"sm",className:"mr-2"}),"Tentando..."]}):pe.jsxs(pe.Fragment,{children:[pe.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),pe.jsx(ge,{onClick:i,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsx(we,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),pe.jsxs(Se,{className:"text-center",children:[pe.jsx("div",{className:"flex justify-center mb-4",children:pe.jsx(st,{size:"lg"})}),pe.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Ne,exports.CardContent=Se,exports.CardDescription=ke,exports.CardFooter=Ce,exports.CardHeader=je,exports.CardSkeleton=Fa,exports.CardTitle=we,exports.ChatbotPage=function(){const[t,a]=e.useState(!1),[s,r]=e.useState(""),{messages:n,isLoading:o,error:i,sendMessage:c}=vo(),d=e.useRef(null),u=e.useRef(null);e.useEffect(()=>{if(d.current){const e=d.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[n]),e.useEffect(()=>{t&&u.current&&u.current.focus()},[t]),e.useEffect(()=>{const e=e=>{"Escape"===e.key&&t&&a(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);const m=()=>{s.trim()&&!o&&(c(s),r(""))};return pe.jsxs(pe.Fragment,{children:[pe.jsx(ge,{onClick:()=>a(!t),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:t?pe.jsx(l.X,{className:"h-6 w-6"}):pe.jsx(l.MessageCircle,{className:"h-6 w-6"})}),t&&pe.jsxs(Ne,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[pe.jsxs(je,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[pe.jsx(we,{className:"text-lg font-semibold",children:"Chat Assistant"}),pe.jsx(ge,{variant:"ghost",size:"icon",onClick:()=>a(!1),className:"h-8 w-8",children:pe.jsx(l.X,{className:"h-4 w-4"})})]}),pe.jsxs(Se,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[pe.jsx(ds,{ref:d,className:"flex-1 px-4",children:pe.jsxs("div",{className:"space-y-4 py-4",children:[n.map(e=>pe.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:pe.jsx("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===e.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===e.role?pe.jsx(yo,{content:e.content}):pe.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&pe.jsx("div",{className:"flex justify-start",children:pe.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:pe.jsxs("div",{className:"flex space-x-2",children:[pe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),pe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),pe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),i&&pe.jsx("div",{className:"text-center text-sm text-destructive py-2",children:i})]})}),pe.jsx("div",{className:"border-t p-4",children:pe.jsxs("div",{className:"flex space-x-2",children:[pe.jsx(be,{ref:u,value:s,onChange:e=>r(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},placeholder:"Digite sua mensagem...",disabled:o,className:"flex-1"}),pe.jsx(ge,{onClick:m,disabled:o||!s.trim(),size:"icon",children:pe.jsx(l.Send,{className:"h-4 w-4"})})]})})]})]})]})},exports.Checkbox=Ye,exports.Collapsible=ir,exports.CollapsibleContent=cr,exports.CollapsibleTrigger=lr,exports.ColorPicker=cs,exports.Command=dr,exports.CommandDialog=({children:e,...t})=>pe.jsx("div",{...t,children:pe.jsx(dr,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})}),exports.CommandEmpty=pr,exports.CommandGroup=fr,exports.CommandInput=ur,exports.CommandItem=xr,exports.CommandList=mr,exports.CommandSeparator=hr,exports.CommandShortcut=gr,exports.CrudCards=function({manager:e,config:t,onEdit:a,onDelete:s}){return e.isLoading?pe.jsx(Nr,{children:Array.from({length:3}).map((e,t)=>pe.jsxs(Ne,{children:[pe.jsxs(je,{children:[pe.jsx(Oa,{className:"h-4 w-3/4"}),pe.jsx(Oa,{className:"h-3 w-1/2"})]}),pe.jsx(Se,{children:pe.jsxs("div",{className:"space-y-2",children:[pe.jsx(Oa,{className:"h-3 w-full"}),pe.jsx(Oa,{className:"h-3 w-2/3"})]})})]},t))}):pe.jsx(br.Root,{children:e.entities.map(e=>pe.jsxs(br.Item,{onClick:()=>a(e),children:[pe.jsx(je,{className:"pb-3",children:pe.jsxs("div",{className:"flex items-start justify-between",children:[pe.jsxs("div",{className:"flex-1 min-w-0",children:[pe.jsx(we,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),pe.jsx(ke,{className:"text-sm",children:n.format(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:nr})})]}),pe.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&pe.jsx(ge,{variant:"external-link",size:"icon-xs",onClick:t=>{t.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),x.toast.info("Link copiado para a área de transferência"))}catch(t){window.location.href=e}})(e.link)},title:"Abrir link externo",children:pe.jsx(l.ExternalLink,{className:"h-4 w-4"})}),pe.jsx("div",{onClick:e=>e.stopPropagation(),children:pe.jsx(as,{onEdit:()=>a(e),onDelete:s?()=>s(e):void 0,canDelete:!!s})})]})]})}),pe.jsx(Se,{className:"pt-0",children:pe.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const a=e[t.key];return a?pe.jsx(br.Field,{label:t.label,value:t.render?t.render(a,e):String(a)},String(t.key)):null})})})]},e.id))})},exports.CrudForm=bs,exports.CrudTable=ss,exports.DataList=br,exports.DeleteConfirmationDialog=Ca,exports.Dialog=Te,exports.DialogClose=Re,exports.DialogContent=Ie,exports.DialogDescription=ze,exports.DialogFooter=De,exports.DialogHeader=_e,exports.DialogOverlay=Ee,exports.DialogPortal=Ae,exports.DialogTitle=Oe,exports.DialogTrigger=Pe,exports.DropdownMenu=$a,exports.DropdownMenuCheckboxItem=Ka,exports.DropdownMenuContent=Ga,exports.DropdownMenuGroup=Ba,exports.DropdownMenuItem=Xa,exports.DropdownMenuLabel=Ya,exports.DropdownMenuPortal=Va,exports.DropdownMenuRadioGroup=Wa,exports.DropdownMenuRadioItem=Ja,exports.DropdownMenuSeparator=Za,exports.DropdownMenuShortcut=es,exports.DropdownMenuSub=qa,exports.DropdownMenuSubContent=Qa,exports.DropdownMenuSubTrigger=Ha,exports.DropdownMenuTrigger=Ua,exports.EmptyState=Ma,exports.EntitySelect=fs,exports.ErrorBoundary=bo,exports.FilterBar=Ss,exports.Form=Fe,exports.FormControl=Ve,exports.FormField=({...e})=>pe.jsx(Le.Provider,{value:{name:e.name},children:pe.jsx(c.Controller,{...e})}),exports.FormItem=Ue,exports.FormLabel=Be,exports.FormMessage=qe,exports.FormSkeleton=function({fields:e=4}){return pe.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>pe.jsxs("div",{className:"space-y-2",children:[pe.jsx(Oa,{className:"h-4 w-24"}),pe.jsx(Oa,{className:"h-10 w-full"})]},t)),pe.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[pe.jsx(Oa,{className:"h-10 w-20"}),pe.jsx(Oa,{className:"h-10 w-20"})]})]})},exports.Grid=Nr,exports.HeaderSkeleton=function(){return pe.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[pe.jsxs("div",{className:"flex items-center space-x-3",children:[pe.jsx(Oa,{className:"h-8 w-8 rounded-full"}),pe.jsx(Oa,{className:"h-6 w-32"})]}),pe.jsxs("div",{className:"flex items-center space-x-2",children:[pe.jsx(Oa,{className:"h-8 w-8"}),pe.jsx(Oa,{className:"h-8 w-24"})]})]})},exports.IconPicker=ps,exports.Input=be,exports.Label=ye,exports.LoadingState=function({isLoading:e,children:t,className:a,type:s="spinner",size:r="md"}){return e?"overlay"===s?pe.jsxs("div",{className:fe("relative",a),children:[t,pe.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:pe.jsx(st,{size:r})})]}):"skeleton"===s?pe.jsx("div",{className:fe("animate-pulse",a),children:pe.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):pe.jsx("div",{className:fe("flex items-center justify-center py-8",a),children:pe.jsx(st,{size:r})}):pe.jsx(pe.Fragment,{children:t})},exports.LoginPage=()=>pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsx(we,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),pe.jsxs(Se,{className:"text-center space-y-4",children:[pe.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),pe.jsx(ge,{onClick:async()=>{Xt()?await da.loginDev():da.loginProd()},className:"w-full",size:"lg",children:Xt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Yt,exports.MarkdownMessage=yo,exports.NavigationProvider=ao,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:a}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,pe.jsx(Vs,{className:a})},exports.Pagination=jr,exports.PaginationContent=wr,exports.PaginationEllipsis=Pr,exports.PaginationItem=kr,exports.PaginationLink=Sr,exports.PaginationNext=Tr,exports.PaginationPrevious=Cr,exports.Popover=ns,exports.PopoverContent=is,exports.PopoverTrigger=os,exports.Progress=Ar,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:a,isLoading:s}=pa();if(e.useEffect(()=>{if(!a)return;const e=()=>{Rt.areAllTokensValid()||da.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[a]),e.useEffect(()=>{if(s)return;if(a)return;if(Rt.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,r=new URLSearchParams(t);if(e.has("access_token")||r.has("access_token"))return;const n=Xt();(async()=>{n?await da.loginDev():da.loginProd()})()},[a,s]),s)return pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsx(we,{className:"text-xl font-semibold",children:"Carregando..."})}),pe.jsxs(Se,{className:"text-center",children:[pe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),pe.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!a){if(new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token"))return pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsx(we,{className:"text-xl font-semibold",children:"Processando..."})}),pe.jsxs(Se,{className:"text-center",children:[pe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),pe.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(Rt.areAllTokensValid())return pe.jsx(pe.Fragment,{children:t})}catch{}return pe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:pe.jsxs(Ne,{className:"w-full max-w-md",children:[pe.jsx(je,{className:"text-center",children:pe.jsx(we,{className:"text-xl font-semibold",children:"Iniciando..."})}),pe.jsxs(Se,{className:"text-center",children:[pe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),pe.jsx("p",{className:"text-muted-foreground",children:Xt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return pe.jsx(pe.Fragment,{children:t})},exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=Wt,exports.QualiexUserField=xs,exports.RadioGroup=Rr,exports.RadioGroupItem=Er,exports.SEARCH_CONFIG=Gt,exports.ScrollArea=ds,exports.ScrollBar=us,exports.Select=We,exports.SelectContent=Ke,exports.SelectItem=Je,exports.SelectTrigger=Qe,exports.SelectValue=He,exports.Separator=Ir,exports.Sheet=_r,exports.SheetClose=Or,exports.SheetContent=Mr,exports.SheetDescription=Vr,exports.SheetFooter=Ur,exports.SheetHeader=$r,exports.SheetOverlay=Fr,exports.SheetPortal=zr,exports.SheetTitle=Br,exports.SheetTrigger=Dr,exports.Sidebar=Yr,exports.SidebarContent=on,exports.SidebarFooter=rn,exports.SidebarGroup=ln,exports.SidebarGroupAction=dn,exports.SidebarGroupContent=un,exports.SidebarGroupLabel=cn,exports.SidebarHeader=sn,exports.SidebarInput=an,exports.SidebarInset=tn,exports.SidebarMenu=mn,exports.SidebarMenuAction=xn,exports.SidebarMenuBadge=gn,exports.SidebarMenuButton=hn,exports.SidebarMenuItem=pn,exports.SidebarMenuSkeleton=bn,exports.SidebarMenuSub=vn,exports.SidebarMenuSubButton=Nn,exports.SidebarMenuSubItem=yn,exports.SidebarProvider=Jr,exports.SidebarRail=en,exports.SidebarSeparator=nn,exports.SidebarSkeleton=function(){return pe.jsx("div",{className:"w-64 border-r bg-muted/10",children:pe.jsxs("div",{className:"p-4",children:[pe.jsx(Oa,{className:"h-8 w-32 mb-6"}),pe.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>pe.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[pe.jsx(Oa,{className:"h-4 w-4"}),pe.jsx(Oa,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=Zr,exports.Skeleton=Oa,exports.Slider=jn,exports.SonnerToaster=({...e})=>{const{theme:t="system"}=E.useTheme();return pe.jsx(x.Toaster,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})},exports.Spinner=st,exports.Stack=ks,exports.Switch=Bn,exports.TabPageContent=function({children:e,className:t}){return pe.jsx("div",{className:fe("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:a,className:s}){return pe.jsxs("div",{className:fe("space-y-4",s),children:[pe.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[pe.jsxs("div",{className:"space-y-1",children:[pe.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&pe.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),a&&pe.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a})]}),pe.jsx(Ir,{})]})},exports.TabPageLayout=function({children:e,className:t}){return pe.jsx("div",{className:fe("flex flex-col h-full",t),children:pe.jsx(ds,{className:"flex-1",children:pe.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Ta,exports.TableBody=Aa,exports.TableCaption=Da,exports.TableCell=_a,exports.TableFooter=Ra,exports.TableHead=Ia,exports.TableHeader=Pa,exports.TableRow=Ea,exports.TableRowActions=as,exports.TableSkeleton=za,exports.Tabs=Vn,exports.TabsContent=Hn,exports.TabsList=qn,exports.TabsTrigger=Wn,exports.Textarea=Ze,exports.Toast=xt,exports.ToastAction=gt,exports.ToastClose=bt,exports.ToastDescription=yt,exports.ToastProvider=pt,exports.ToastTitle=vt,exports.ToastViewport=ft,exports.Toaster=function(){const{toasts:e}=mt();return pe.jsxs(pt,{children:[e.map(function({id:e,title:t,description:a,action:s,...r}){return pe.jsxs(xt,{...r,children:[pe.jsxs("div",{className:"grid gap-1",children:[t&&pe.jsx(vt,{children:t}),a&&pe.jsx(yt,{children:a})]}),s,pe.jsx(bt,{})]},e)}),pe.jsx(ft,{})]})},exports.Toggle=Gn,exports.ToggleGroup=Kn,exports.ToggleGroupItem=Jn,exports.TokenManager=Rt,exports.TokenService=jt,exports.Tooltip=Wr,exports.TooltipContent=Qr,exports.TooltipProvider=qr,exports.TooltipTrigger=Hr,exports.assets=uo,exports.badgeVariants=et,exports.buttonVariants=xe,exports.cn=fe,exports.createCrudPage=function(e){return()=>{const{manager:t,config:a,onSave:s,onToggleStatus:r}=e,n={entityName:a.entityName,entityNamePlural:a.entityNamePlural,filters:a.filters||[],columns:a.columns,cardFields:a.cardFields||[]};return pe.jsx(Cs,{manager:t,config:n,formSections:a.formSections,onSave:s,onToggleStatus:r})}},exports.createRoutingHandlers=Zn,exports.createService=ta,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=ta({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0});return{service:t,useCrudHook:(a,s)=>fa({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.crudPresets=Rs,exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.errorService=_t,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDatetime=e=>{if(!e)return"";const t=n.parseISO(e);if(!n.isValid(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`},exports.generateCrudConfig=Ts,exports.getQualiexConfig=Jt,exports.getSupabaseClient=$t,exports.isDevEnvironment=Xt,exports.logoSrc=mo,exports.qualiexApi=qt,exports.setQualiexConfig=e=>{Kt={...Kt,...e}},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new f.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.smallLogoSrc=po,exports.toast=ut,exports.toggleVariants=Qn,exports.trimTextFields=he,exports.useActiveModules=io,exports.useAuth=pa,exports.useBaseForm=rs,exports.useCrud=fa,exports.useCrudRouting=function(e){return Zn({basePath:e})},exports.useDebounce=no,exports.useNavigation=so,exports.useOpenAIChat=vo,exports.usePageTitle=ro,exports.usePermissionQuery=lo,exports.useQualiexUsers=hs,exports.useRouteBreadcrumbs=function(){const e=h.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useSidebar=Kr,exports.useToast=mt,exports.withPreset=function(e,t,a={}){const s=Rs[e];return Ts(s.title,t,{...s,...a})};
10
+ */function de(){return le||(le=1,"production"!==process.env.NODE_ENV&&function(){var t=e,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),h=Symbol.iterator;var g=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];!function(e,t,n){var r=g.ReactDebugCurrentFrame,a=r.getStackAddendum();""!==a&&(t+="%s",n=n.concat([a]));var o=n.map(function(e){return String(e)});o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,n)}var b;function y(e){return e.displayName||"Context"}function v(e){if(null==e)return null;if("number"==typeof e.tag&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case r:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return y(e)+".Consumer";case i:return y(e._context)+".Provider";case c:return function(e,t,n){var r=e.displayName;if(r)return r;var a=t.displayName||t.name||"";return""!==a?n+"("+a+")":n}(e,e.render,"ForwardRef");case f:var t=e.displayName||null;return null!==t?t:v(e.type)||"Memo";case p:var n=e,m=n._payload,h=n._init;try{return v(h(m))}catch(g){return null}}return null}b=Symbol.for("react.module.reference");var w,k,N,j,S,C,T,E=Object.assign,I=0;function A(){}A.__reactDisabledLog=!0;var P,D=g.ReactCurrentDispatcher;function R(e,t,n){if(void 0===P)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);P=r&&r[1]||""}return"\n"+P+e}var _,O=!1,L="function"==typeof WeakMap?WeakMap:Map;function F(e,t){if(!e||O)return"";var n,r=_.get(e);if(void 0!==r)return r;O=!0;var a,o=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=D.current,D.current=null,function(){if(0===I){w=console.log,k=console.info,N=console.warn,j=console.error,S=console.group,C=console.groupCollapsed,T=console.groupEnd;var e={configurable:!0,enumerable:!0,value:A,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}();try{if(t){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(s,[])}catch(m){n=m}Reflect.construct(e,[],s)}else{try{s.call()}catch(m){n=m}e.call(s.prototype)}}else{try{throw Error()}catch(m){n=m}e()}}catch(h){if(h&&n&&"string"==typeof h.stack){for(var i=h.stack.split("\n"),l=n.stack.split("\n"),c=i.length-1,u=l.length-1;c>=1&&u>=0&&i[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(i[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||i[c]!==l[u]){var d="\n"+i[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&_.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{O=!1,D.current=a,function(){if(0===--I){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},e,{value:w}),info:E({},e,{value:k}),warn:E({},e,{value:N}),error:E({},e,{value:j}),group:E({},e,{value:S}),groupCollapsed:E({},e,{value:C}),groupEnd:E({},e,{value:T})})}I<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=o}var f=e?e.displayName||e.name:"",p=f?R(f):"";return"function"==typeof e&&_.set(e,p),p}function z(e,t,n){if(null==e)return"";if("function"==typeof e)return F(e,!(!(r=e.prototype)||!r.isReactComponent));var r;if("string"==typeof e)return R(e);switch(e){case u:return R("Suspense");case d:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return F(e.render,!1);case f:return z(e.type,t,n);case p:var a=e,o=a._payload,s=a._init;try{return z(s(o),t,n)}catch(i){}}return""}_=new L;var M=Object.prototype.hasOwnProperty,B={},U=g.ReactDebugCurrentFrame;function $(e){if(e){var t=e._owner,n=z(e.type,e._source,t?t.type:null);U.setExtraStackFrame(n)}else U.setExtraStackFrame(null)}var V=Array.isArray;function q(e){return V(e)}function H(e){return""+e}function W(e){if(function(e){try{return H(e),!1}catch(t){return!0}}(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),H(e)}var Q,X,K=g.ReactCurrentOwner,Y={key:!0,ref:!0,__self:!0,__source:!0};function G(e,t,r,a,o){var s,i={},l=null,c=null;for(s in void 0!==r&&(W(r),l=""+r),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(W(t.key),l=""+t.key),function(e){if(M.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&K.current}(t)),t)M.call(t,s)&&!Y.hasOwnProperty(s)&&(i[s]=t[s]);if(e&&e.defaultProps){var u=e.defaultProps;for(s in u)void 0===i[s]&&(i[s]=u[s])}if(l||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var n=function(){Q||(Q=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(i,d),c&&function(e,t){var n=function(){X||(X=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(i,d)}return function(e,t,r,a,o,s,i){var l={$$typeof:n,type:e,key:t,ref:r,props:i,_owner:s,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,o,a,K.current,i)}var J,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,n=z(e.type,e._source,t?t.type:null);ee.setExtraStackFrame(n)}else ee.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function re(){if(Z.current){var e=v(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}J=!1;var ae={};function oe(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=re();if(!t){var n="string"==typeof e?e:e.displayName||e.name;n&&(t="\n\nCheck the top-level render call using <"+n+">.")}return t}(t);if(!ae[n]){ae[n]=!0;var r="";e&&e._owner&&e._owner!==Z.current&&(r=" It was passed a child from "+v(e._owner.type)+"."),te(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),te(null)}}}function se(e,t){if("object"==typeof e)if(q(e))for(var n=0;n<e.length;n++){var r=e[n];ne(r)&&oe(r,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof a&&a!==e.entries)for(var o,s=a.call(e);!(o=s.next()).done;)ne(o.value)&&oe(o.value,t)}}function ie(e){var t,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)t=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==f)return;t=n.propTypes}if(t){var r=v(n);!function(e,t,n,r,a){var o=Function.call.bind(M);for(var s in e)if(o(e,s)){var i=void 0;try{if("function"!=typeof e[s]){var l=Error((r||"React class")+": "+n+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}i=e[s](t,s,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){i=c}!i||i instanceof Error||($(a),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,s,typeof i),$(null)),i instanceof Error&&!(i.message in B)&&(B[i.message]=!0,$(a),x("Failed %s type: %s",n,i.message),$(null))}}(t,e.props,"prop",r,e)}else if(void 0!==n.PropTypes&&!J){J=!0,x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v(n)||"Unknown")}"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ce(e,t,r,h,g,y){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===s||e===o||e===u||e===d||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===p||e.$$typeof===f||e.$$typeof===i||e.$$typeof===l||e.$$typeof===c||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!w){var k="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N;k+=re(),null===e?N="null":q(e)?N="array":void 0!==e&&e.$$typeof===n?(N="<"+(v(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):N=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,k)}var j=G(e,t,r,g,y);if(null==j)return j;if(w){var S=t.children;if(void 0!==S)if(h)if(q(S)){for(var C=0;C<S.length;C++)se(S[C],e);Object.freeze&&Object.freeze(S)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(S,e)}if(M.call(t,"key")){var T=v(e),E=Object.keys(t).filter(function(e){return"key"!==e}),I=E.length>0?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+I])x('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,T,E.length>0?"{"+E.join(": ..., ")+": ...}":"{}",T),le[T+I]=!0}return e===a?function(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if("children"!==r&&"key"!==r){te(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),te(null);break}}null!==e.ref&&(te(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(j):ie(j),j}var de=function(e,t,n){return ce(e,t,n,!1)},fe=function(e,t,n){return ce(e,t,n,!0)};ue.Fragment=a,ue.jsx=de,ue.jsxs=fe}()),ue}var fe=(ce||(ce=1,"production"===process.env.NODE_ENV?se.exports=function(){if(oe)return ie;oe=1;var t=e,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(e,t,r){var i,l={},c=null,u=null;for(i in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,i)&&!s.hasOwnProperty(i)&&(l[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===l[i]&&(l[i]=t[i]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:o.current}}return ie.Fragment=r,ie.jsx=i,ie.jsxs=i,ie}():se.exports=de()),se.exports);function pe(...e){return a.twMerge(r.clsx(e))}const me=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(me);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=me(r);return t}return e},he=n.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6"}},defaultVariants:{variant:"default",size:"default"}}),ge=L.forwardRef(({className:e,variant:n,size:r,asChild:a=!1,...o},s)=>{const i=a?t.Slot:"button";return fe.jsx(i,{className:pe(he({variant:n,size:r,className:e})),ref:s,...o})});ge.displayName="Button";const xe=L.forwardRef(({className:e,type:t,...n},r)=>fe.jsx("input",{type:t,className:pe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));xe.displayName="Input";const be=n.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ye=L.forwardRef(({className:e,...t},n)=>fe.jsx(F.Root,{ref:n,className:pe(be(),e),...t}));ye.displayName=F.Root.displayName;const ve=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ve.displayName="Card";const we=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("flex flex-col space-y-1.5 p-6",e),...t}));we.displayName="CardHeader";const ke=L.forwardRef(({className:e,...t},n)=>fe.jsx("h3",{ref:n,className:pe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ke.displayName="CardTitle";const Ne=L.forwardRef(({className:e,...t},n)=>fe.jsx("p",{ref:n,className:pe("text-sm text-muted-foreground",e),...t}));Ne.displayName="CardDescription";const je=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("p-6 pt-0",e),...t}));je.displayName="CardContent";const Se=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("flex items-center p-6 pt-0",e),...t}));Se.displayName="CardFooter";const Ce=z.Root,Te=z.Trigger,Ee=z.Portal,Ie=z.Close,Ae=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Overlay,{ref:n,className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ae.displayName=z.Overlay.displayName;const Pe=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsxs(Ee,{children:[fe.jsx(Ae,{}),fe.jsxs(z.Content,{ref:r,className:pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 bg-background p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg overflow-hidden",e),...n,children:[t,fe.jsxs(z.Close,{className:"absolute right-4 top-4 z-10 rounded-sm text-white opacity-70 ring-offset-background transition-opacity hover:opacity-100 hover:text-white focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[fe.jsx(l.X,{className:"h-4 w-4"}),fe.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pe.displayName=z.Content.displayName;const De=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col space-y-1.5 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-3 rounded-t-lg",e),...t});De.displayName="DialogHeader";const Re=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Re.displayName="DialogFooter";const _e=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Title,{ref:n,className:pe("text-lg font-semibold leading-none tracking-tight",e),...t}));_e.displayName=z.Title.displayName;const Oe=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Description,{ref:n,className:pe("text-sm text-muted-foreground",e),...t}));Oe.displayName=z.Description.displayName;const Le=c.FormProvider,Fe=L.createContext({}),ze=()=>{const e=L.useContext(Fe),t=L.useContext(Me),{getFieldState:n,formState:r}=c.useFormContext(),a=n(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:o}=t;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},Me=L.createContext({}),Be=L.forwardRef(({className:e,...t},n)=>{const r=L.useId();return fe.jsx(Me.Provider,{value:{id:r},children:fe.jsx("div",{ref:n,className:pe("space-y-2",e),...t})})});Be.displayName="FormItem";const Ue=L.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=ze();return fe.jsx(ye,{ref:n,className:pe(r&&"text-destructive",e),htmlFor:a,...t})});Ue.displayName="FormLabel";const $e=L.forwardRef(({...e},n)=>{const{error:r,formItemId:a,formDescriptionId:o,formMessageId:s}=ze();return fe.jsx(t.Slot,{ref:n,id:a,"aria-describedby":r?`${o} ${s}`:`${o}`,"aria-invalid":!!r,...e})});$e.displayName="FormControl";L.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=ze();return fe.jsx("p",{ref:n,id:r,className:pe("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const Ve=L.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:o}=ze(),s=a?String(a?.message):t;return s?fe.jsx("p",{ref:r,id:o,className:pe("text-sm font-medium text-destructive",e),...n,children:s}):null});Ve.displayName="FormMessage";const qe=M.Root,He=M.Value,We=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsxs(M.Trigger,{ref:r,className:pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,fe.jsx(M.Icon,{asChild:!0,children:fe.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));We.displayName=M.Trigger.displayName;const Qe=L.forwardRef(({className:e,...t},n)=>fe.jsx(M.ScrollUpButton,{ref:n,className:pe("flex cursor-default items-center justify-center py-1",e),...t,children:fe.jsx(l.ChevronUp,{className:"h-4 w-4"})}));Qe.displayName=M.ScrollUpButton.displayName;const Xe=L.forwardRef(({className:e,...t},n)=>fe.jsx(M.ScrollDownButton,{ref:n,className:pe("flex cursor-default items-center justify-center py-1",e),...t,children:fe.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Xe.displayName=M.ScrollDownButton.displayName;const Ke=L.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>fe.jsx(M.Portal,{children:fe.jsxs(M.Content,{ref:a,className:pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[fe.jsx(Qe,{}),fe.jsx(M.Viewport,{className:pe("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),fe.jsx(Xe,{})]})}));Ke.displayName=M.Content.displayName;L.forwardRef(({className:e,...t},n)=>fe.jsx(M.Label,{ref:n,className:pe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=M.Label.displayName;const Ye=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsxs(M.Item,{ref:r,className:pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[fe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:fe.jsx(M.ItemIndicator,{children:fe.jsx(l.Check,{className:"h-4 w-4"})})}),fe.jsx(M.ItemText,{children:t})]}));Ye.displayName=M.Item.displayName;L.forwardRef(({className:e,...t},n)=>fe.jsx(M.Separator,{ref:n,className:pe("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=M.Separator.displayName;const Ge=L.forwardRef(({className:e,...t},n)=>fe.jsx(B.Root,{ref:n,className:pe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:fe.jsx(B.Indicator,{className:pe("flex items-center justify-center text-current"),children:fe.jsx(l.Check,{className:"h-4 w-4"})})}));Ge.displayName=B.Root.displayName;const Je=L.forwardRef(({className:e,...t},n)=>fe.jsx("textarea",{className:pe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Je.displayName="Textarea";const Ze=n.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white hover:bg-green-600",warning:"border-transparent bg-yellow-500 text-white hover:bg-yellow-600",info:"border-transparent bg-blue-500 text-white hover:bg-blue-600"}},defaultVariants:{variant:"default"}}),et=L.forwardRef(({className:e,variant:t,...n},r)=>fe.jsx("div",{ref:r,className:pe(Ze({variant:t}),e),...n}));et.displayName="Badge";const tt={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function nt({size:e="md",className:t}){return fe.jsx(l.Loader2,{className:pe("animate-spin text-muted-foreground",tt[e],t)})}let rt=0;const at=new Map,ot=e=>{if(at.has(e))return;const t=setTimeout(()=>{at.delete(e),ct({type:"REMOVE_TOAST",toastId:e})},1e6);at.set(e,t)},st=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?ot(n):e.toasts.forEach(e=>{ot(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||void 0===n?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},it=[];let lt={toasts:[]};function ct(e){lt=st(lt,e),it.forEach(e=>{e(lt)})}function ut({...e}){const t=(rt=(rt+1)%Number.MAX_SAFE_INTEGER,rt.toString()),n=()=>ct({type:"DISMISS_TOAST",toastId:t});return ct({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>ct({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function dt(){const[e,t]=L.useState(lt);return L.useEffect(()=>(it.push(t),()=>{const e=it.indexOf(t);e>-1&&it.splice(e,1)}),[e]),{...e,toast:ut,dismiss:e=>ct({type:"DISMISS_TOAST",toastId:e})}}const ft=U.Provider,pt=L.forwardRef(({className:e,...t},n)=>fe.jsx(U.Viewport,{ref:n,className:pe("fixed top-4 left-1/2 transform -translate-x-1/2 z-[100] flex max-h-screen w-full max-w-[420px] flex-col p-4",e),...t}));pt.displayName=U.Viewport.displayName;const mt=n.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),ht=L.forwardRef(({className:e,variant:t,...n},r)=>fe.jsx(U.Root,{ref:r,className:pe(mt({variant:t}),e),...n}));ht.displayName=U.Root.displayName;const gt=L.forwardRef(({className:e,...t},n)=>fe.jsx(U.Action,{ref:n,className:pe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));gt.displayName=U.Action.displayName;const xt=L.forwardRef(({className:e,...t},n)=>fe.jsx(U.Close,{ref:n,className:pe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:fe.jsx(l.X,{className:"h-4 w-4"})}));xt.displayName=U.Close.displayName;const bt=L.forwardRef(({className:e,...t},n)=>fe.jsx(U.Title,{ref:n,className:pe("text-sm font-semibold",e),...t}));bt.displayName=U.Title.displayName;const yt=L.forwardRef(({className:e,...t},n)=>fe.jsx(U.Description,{ref:n,className:pe("text-sm opacity-90",e),...t}));yt.displayName=U.Description.displayName;var vt=Object.defineProperty;class wt{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const n=(4-t.length%4)%4;return t+="=".repeat(n),t}static parseJwtPayload(e){try{const a=e.split(".");if(3!==a.length)return null;const o=a[1];o.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(o),t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const r=new TextDecoder("utf-8").decode(n);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(o),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(n){try{const e=this.normalizeBase64Url(o),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(a){return null}}static validateTokens(e,t){const n=[],r=[];try{t.split(".")[1],e.split(".")[1];const a=this.parseJwtPayload(t),o=this.parseJwtPayload(e);if(!a){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}let s=!0;if(!o){const e="Access token decode falhou - será tentado novamente nas chamadas de API";n.push(e),s=!1}const i=Math.floor(Date.now()/1e3);if(o?.exp&&o.exp<i){const e="Access token expirado - pode precisar de refresh";n.push(e),s=!1}if(a.exp&&a.exp<i){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:s,warnings:n,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:s,warnings:n,errors:r}}catch(a){const e=`Erro na validação de tokens: ${a}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,n)=>{t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(wt,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const kt="qualiex_access_token",Nt="qualiex_id_token",jt="supabase_token",St="oauth_state",Ct="oauth_nonce",Tt="selected_alias",Et="manual_logout",It={setAccessToken:e=>localStorage.setItem(kt,e),getAccessToken:()=>localStorage.getItem(kt),setIdToken:e=>localStorage.setItem(Nt,e),getIdToken:()=>localStorage.getItem(Nt),getSupabaseToken:()=>localStorage.getItem(jt),setOAuthState:e=>sessionStorage.setItem(St,e),getOAuthState:()=>sessionStorage.getItem(St),clearOAuthState:()=>sessionStorage.removeItem(St),setOAuthNonce:e=>sessionStorage.setItem(Ct,e),getOAuthNonce:()=>sessionStorage.getItem(Ct),clearOAuthNonce:()=>sessionStorage.removeItem(Ct),setSelectedAlias:e=>localStorage.setItem(Tt,e),getSelectedAlias:()=>localStorage.getItem(Tt),clearSelectedAlias:()=>localStorage.removeItem(Tt),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!It.getAccessToken()||!It.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(jt,e),It._clearValidationCache()},areAllTokensValid:()=>{const e=It.getAccessToken(),t=It.getIdToken();if(!e||!t)return!1;try{const n=wt.validateTokens(e,t);return!!n.idTokenValid&&(n.accessTokenValid,n.idTokenValid)}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=It.getAccessToken(),n=It.getIdToken(),r=It.getSupabaseToken();return t&&It.isTokenExpired(t)&&(localStorage.removeItem(kt),e=!0),n&&It.isTokenExpired(n)&&(localStorage.removeItem(Nt),e=!0),r&&It.isTokenExpired(r)&&(localStorage.removeItem(jt),e=!0),e},clearAll:()=>{localStorage.removeItem(kt),localStorage.removeItem(Nt),localStorage.removeItem(jt),localStorage.removeItem(Tt),localStorage.removeItem(Et),sessionStorage.removeItem(St),sessionStorage.removeItem(Ct)},setManualLogout:()=>localStorage.setItem(Et,"true"),isManualLogout:()=>"true"===localStorage.getItem(Et),clearManualLogout:()=>localStorage.removeItem(Et),isTokenExpired:e=>{try{return wt.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{It._validationCache.isValid=!1,It._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=It.getSupabaseToken();if(!e)return!1;if(It.isTokenExpired(e))return It._clearValidationCache(),It._handleExpiredToken(),!1;const t=Date.now();return t-It._validationCache.timestamp<It._validationCache.cacheValidityMs?It._validationCache.isValid:(It._validationCache.isValid=!0,It._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>It.isSupabaseTokenValid()?It.getSupabaseToken():null,_handleExpiredToken:()=>{It.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!It.isSupabaseTokenValid())return null;const e=It.getSupabaseToken();if(!e)return null;try{const t=wt.parseJwtPayload(e);if(!t)return null;const n=t.alias||t.default||t.user_alias;let r=t.company_id;if(!r&&n)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const a=t[e];if(a&&"string"==typeof a){const e=a.split(";");if(e.length>7&&e[0]===n){r=e[7];break}}}return{alias:n,companyId:r,payload:t}}catch(t){return It._handleExpiredToken(),null}},getCompanyId:e=>{const t=It.extractTokenData();if(!t)return null;if(!e)return t.companyId;const n=It.getIdToken();if(!n)return null;try{const t=wt.parseJwtPayload(n);if(!t)return null;for(const n in t)if(n.startsWith("co")&&/^co\d+$/.test(n)){const r=t[n];if(r&&"string"==typeof r){const t=r.split(";");if(t.length>7&&t[0]===e)return t[7]}}}catch{return null}return null},getCurrentCompanyId:()=>{const e=It.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=It.getIdToken();if(!e)return[];try{const t=wt.parseJwtPayload(e);if(!t)return[];const n=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&n.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return n}catch{return[]}}};var At=Object.defineProperty,Pt=(e,t,n)=>((e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Dt=new class{constructor(){Pt(this,"errors",[]),Pt(this,"toastCount",0),Pt(this,"lastToastTime",0)}handleError(e,t=!0){const n="string"==typeof e?e:e.message;this.errors.push({id:Date.now().toString(),message:n,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()&&ut({title:"Erro",description:n,variant:"destructive"})}success(e,t){ut({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Rt=Object.defineProperty,_t=(e,t,n)=>((e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Ot=(void 0).VITE_SUPABASE_URL,Lt=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,Ft=class e{constructor(){_t(this,"client"),_t(this,"currentToken",null),_t(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Lt};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),p.createClient(Ot,Lt,{auth:{persistSession:!1,autoRefreshToken:!1,storage:void 0},global:{headers:t}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=It.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),n=Math.floor(Date.now()/1e3);return t.exp>n}catch(t){return Dt.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};_t(Ft,"instance");let zt=Ft;const Mt=()=>zt.getInstance().getClient();var Bt=Object.freeze({__proto__:null,getSupabaseClient:Mt}),Ut=Object.defineProperty,$t=(e,t,n)=>((e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Vt=new class{constructor(){$t(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=It.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!n||""===n.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const a=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{a.searchParams.append(e,t)});const o=await fetch(a.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!o.ok)throw new Error(`API call failed: ${o.status} ${o.statusText}`);return await o.json()}mapToQualiexUser(e){return{userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível"}}async fetchUsers(e,t){try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return Dt.handleError("[QualiexApi] Unexpected response format",!1),[];r=n}if(!Array.isArray(r))return Dt.handleError("[QualiexApi] Response is not an array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){return Dt.handleError(n instanceof Error?n:"[QualiexApi] Error fetching users"),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return Dt.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const t=It.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):(Dt.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}};class qt{static async extractTokenData(){const e=It.extractTokenData();return e||(Dt.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,t){if(!e||0===e.length)return Dt.handleError(`[QualiexEnrichment.${t.entityName}] Nenhuma entidade encontrada`,!1),e;try{const n=await this.extractTokenData();if(!n)return e.map(e=>({...e,responsible_name:e.id_user?"Token não encontrado":null}));const{alias:r,companyId:a}=n;if(!r||!a)return Dt.handleError(`[QualiexEnrichment.${t.entityName}] DADOS OBRIGATÓRIOS FALTANDO - alias: ${!!r}, companyId: ${!!a}`,!1),e.map(e=>({...e,responsible_name:e.id_user?`Configuração incompleta (alias: ${!!r}, companyId: ${!!a})`:null}));const o=await Vt.getUsers(r),s=e.map(e=>{if(e.id_user){const t=o.find(t=>t.userId===e.id_user);return{...e,responsible_name:t?.userName||`ID não encontrado: ${e.id_user}`}}return{...e,responsible_name:null}});s.filter(e=>e.responsible_name&&!e.responsible_name.includes("ID não encontrado")&&!e.responsible_name.includes("Erro:")&&!e.responsible_name.includes("Token não encontrado")&&!e.responsible_name.includes("Configuração incompleta")).length;return s}catch(n){return Dt.handleError(n instanceof Error?n:`[QualiexEnrichment.${t.entityName}] 💥 ERRO CRÍTICO`),e.map(e=>({...e,responsible_name:e.id_user?`Erro: ${n.message}`:null}))}}}const Ht={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},Wt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Qt={debounceDelay:500},Xt=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV};let Kt={enableUserEnrichment:!1,enableUsersApi:!1};const Yt=()=>Kt,Gt={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}},Jt=["responsible_name"],Zt=e=>Jt.includes(e);function en(e,t,n){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:n||"central"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"central",...e},{tableName:a,searchFields:o,selectFields:s,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=r,u=()=>{if(!It.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Mt().schema(i).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:r="desc",page:i=1,limit:d=25,...f}=e;let p=u().select(s||"*",{count:"exact"});p=p.eq("is_removed",!1),Object.entries(f).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?p=p.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?p=p.not(e,"is",null):"is_null"===t.operator&&(p=p.is(e,null)):null!==t&&(p=p.eq(e,t)))}),p=((e,t)=>{if(t&&o.length>0){const n=o.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(p,t);n.includes(".")||Zt(n)||(p=p.order(n,{ascending:"asc"===r})),p=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(p,i,d);const{data:m,error:h,count:g}=await p;if(h)throw new Error(`Error fetching ${a}: ${h.message}`);let x=((e,t,n,r)=>{const a=Math.ceil((t||0)/r);return{data:e,currentPage:n,totalPages:a,totalItems:t||0,itemsPerPage:r,hasNextPage:n<a,hasPreviousPage:n>1}})(m||[],g,i,d);const b=Yt();if(c&&b.enableUserEnrichment&&l&&x.data.length>0){if(x.data.some(e=>e.id_user)){const t=n&&n.includes(".");if(n&&(Zt(n)||t)){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},o=await this.getAll(a);if(!o?.data?.length)return o;const s=await qt.enrichWithResponsibleNames(o.data,{entityName:l});let c;c=t?s.sort((e,t)=>{const a=n.split(".").reduce((e,t)=>e?.[t],e)||"",o=n.split(".").reduce((e,t)=>e?.[t],t)||"",s=String(a).localeCompare(String(o),"pt-BR");return"asc"===r?s:-s}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",o=r[t]||"",s=a.localeCompare(o,"pt-BR",{sensitivity:"base"});return"asc"===n?s:-s}))(s,n,r);const u=((e,t=1,n=25)=>{const r=(t-1)*n,a=r+n,o=e.slice(r,a);return{data:o,pagination:{currentPage:t,totalPages:Math.ceil(e.length/n),totalItems:o.length,totalCount:e.length,itemsPerPage:n,hasNextPage:a<e.length,hasPreviousPage:t>1}}})(c,i,d);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}const a=await qt.enrichWithResponsibleNames(x.data,{entityName:l});x={...x,data:a}}}return x},async getById(e){const{data:t,error:n}=await u().select(s||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=me(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:o}=await u().insert(n).select().single();if(o)throw new Error(`Error creating ${a}: ${o.message}`);if(!r)throw new Error(`No data returned from create ${a} operation`);return r},async update(e,t){const n={...me(t),updated_at:(new Date).toISOString()},{data:r,error:o}=await u().update(n).eq("id",e).select().single();if(o)throw new Error(`Error updating ${a}: ${o.message}`);if(!r)throw new Error(`No data returned from update ${a} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:n}=await u().update(t).eq("id",e);if(n)throw new Error(`Error soft deleting ${a}: ${n.message}`)}}}const tn=()=>{It.clearManualLogout()},nn=(void 0).VITE_SUPABASE_URL,rn=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class an{static async generateToken(e,t,n,r=!1){try{if(!r){const e=It.getSupabaseToken();if(e&&It.isSupabaseTokenValid())return e}const a=p.createClient(nn,rn,{auth:{persistSession:!1,autoRefreshToken:!1}}),{data:o,error:s}=await a.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return s&&(s.message?.includes("401")||s.message?.includes("Unauthorized"))?(n?.(),null):o?.access_token&&o.access_token?(It.setSupabaseToken(o.access_token),o.access_token):null}catch(a){return a instanceof Error&&(a.message.includes("401")||a.message.includes("Unauthorized"))&&n?.(),null}}}var on=Object.defineProperty,sn=(e,t,n)=>((e,t,n)=>t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ln{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=It.getAccessToken(),t=It.getSelectedAlias();if(!e||!t)return null;const n=await an.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(It.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}sn(ln,"isRegenerating",!1),sn(ln,"onLogoutCallback",null);const cn=class{static async initialize(){try{if(!It.hasAllTokens()||!It.areAllTokensValid())return It.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null};const e=It.getAccessToken(),t=It.getIdToken();tn();const n=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),a=this.extractAliasFromAccessToken(e),o=It.extractTokenData(),s=o?.alias;let i=null;if(s&&r.some(e=>e.alias===s))i=s;else{const e=It.getSelectedAlias(),t=e&&r.some(t=>t.alias===e);i=t?e:a||r[0]?.alias||null}!It.isSupabaseTokenValid()&&i&&await ln.attemptRegeneration();let l=null;if(i){const e=It.getCompanyId(i),t=r.find(e=>e.alias===i);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}return{isAuthenticated:!0,isLoading:!1,user:n,alias:i,companies:r,selectedUnit:l,userId:n?.id||null,userAlias:n?.id||null}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null}}}static async loginDev(){try{const{getSupabaseClient:e}=await Promise.resolve().then(function(){return Bt}),t=e(),{data:n,error:r}=await t.functions.invoke("dev-tokens",{body:{environment:"development"}});if(r)return!1;if(!n?.access_token||!n?.id_token)return!1;const a=new URL("/callback",window.location.origin);return a.hash=`access_token=${n.access_token}&id_token=${n.id_token}&token_type=bearer`,window.location.href=a.toString(),!0}catch(e){return!1}}static loginProd(){const e=It.generateOAuthState();It.setOAuthState(e);const t=It.generateOAuthNonce();It.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Ht.oauth.authUrl);r.searchParams.set("client_id",Ht.oauth.clientId),r.searchParams.set("response_type",Ht.oauth.responseType),r.searchParams.set("scope",Ht.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),Xt(),window.location.href=r.toString()}static async processCallback(){try{if(It.hasAllTokens()){if(!It.getValidSupabaseToken()){It.getAccessToken();await ln.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),n=n=>e.get(n)||t.get(n),r=n("access_token"),a=n("id_token"),o=n("error");if(o)throw new Error(`Erro OAuth: ${o}`);if(!r||!a)throw new Error("Tokens não encontrados na URL de callback");It.setAccessToken(r),It.setIdToken(a),tn();const s=this.extractAliasFromAccessToken(r);if(s)It.setSelectedAlias(s);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");It.setSelectedAlias(e[0].alias)}if(!await ln.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return It.clearOAuthState(),It.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){It.setManualLogout(),It.clearAll(),window.location.href="/login"}static decodeToken(e){return wt.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const n=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)n.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,a]=t[e].split("|");r&&a&&n.push({id:"",alias:r.trim(),name:a.trim()})}}}),n}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};ln.setLogoutCallback(()=>{cn.logout()});let un=cn;class dn{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(It.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const n=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>n.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}const fn=e.createContext(void 0),pn=()=>{const t=e.useContext(fn);if(void 0===t)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return t};function mn({queryKey:t,service:n,entityName:r,searchFields:a,additionalFilters:o={},onSuccess:s}){const[i,l]=h.useSearchParams(),c=m.useQueryClient(),{alias:u,userId:d}=pn(),f=i.get("search")||"",p=i.get("sortField")||Wt.sorting.defaultField,x=i.get("sortDirection")||Wt.sorting.defaultDirection,b=parseInt(i.get("page")||"1"),y=parseInt(i.get("limit")||String(Wt.pagination.defaultPageSize)),v=f,w=e.useMemo(()=>({search:v,sortField:p,sortDirection:x,page:b,limit:y,...o}),[v,p,x,b,y,o]),k=e.useCallback(()=>n.getAll(w),[n,w]),N=m.useQuery({queryKey:[t,u,d,w],queryFn:k});if(!N)throw new Error(`useCrud: Query initialization failed for "${r}". Ensure QueryClientProvider is configured in your app root.`);const j=m.useMutation({mutationFn:n.create,onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),g.toast.success(Gt.success.created(r)),s?.()},onError:e=>{g.toast.error(`${Gt.error.create(r)}: ${e.message}`)}}),S=m.useMutation({mutationFn:({id:e,data:t})=>n.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),g.toast.success(Gt.success.updated(r)),s?.()},onError:e=>{g.toast.error(`${Gt.error.update(r)}: ${e.message}`)}}),C=m.useMutation({mutationFn:n.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[t]}),g.toast.success(Gt.success.deleted(r))},onError:e=>{g.toast.error(`${Gt.error.delete(r)}: ${e.message}`)}}),T=e.useCallback(e=>{const t={...Object.fromEntries(i)};Object.entries(e).forEach(([e,n])=>{""===n||0===n?delete t[e]:t[e]=String(n)}),l(t)},[i,l]),E=e.useCallback(e=>{T({search:e,page:1})},[T]),I=e.useCallback(e=>{T({sortField:e,sortDirection:p===e&&"asc"===x?"desc":"asc",page:1})},[p,x,T]),A=e.useCallback(e=>{T({page:e})},[T]),P=e.useCallback(e=>{T({limit:e,page:1})},[T]),D=e.useCallback(()=>{l({})},[l]),[R,_]=e.useState([]),O=e.useCallback(e=>{_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),L=e.useCallback(()=>{const e=N?.data?.data.map(e=>e.id)||[];_(t=>t.length===e.length?[]:e)},[N?.data?.data]),F=e.useCallback(()=>{_([])},[]),z=e.useMemo(()=>{const e=N?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,N?.data?.data]),M=m.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>n.delete(e)))},onSuccess:(e,n)=>{c.invalidateQueries({queryKey:[t]}),g.toast.success(`${n.length} ${r}(s) deletado(s) com sucesso`),F()},onError:e=>{g.toast.error(`Erro ao deletar itens: ${e.message}`)}});return{entities:N?.data?.data||[],pagination:{currentPage:N?.data?.currentPage||1,totalPages:N?.data?.totalPages||1,totalItems:N?.data?.totalItems||0,itemsPerPage:N?.data?.itemsPerPage||Wt.pagination.defaultPageSize,hasNextPage:N?.data?.hasNextPage||!1,hasPreviousPage:N?.data?.hasPreviousPage||!1},isLoading:N?.isLoading??!0,isCreating:j?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:C?.isPending??!1,error:N?.error||null,searchTerm:f,sortField:p,sortDirection:x,currentPage:b,itemsPerPage:y,createEntity:j.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:C.mutate,handleSearch:E,handleSort:I,handlePageChange:A,handleItemsPerPageChange:P,clearFilters:D,refetch:N.refetch,selectedIds:R,selectItem:O,selectAll:L,clearSelection:F,isAllSelected:z,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}const hn=$.Root,gn=$.Trigger,xn=$.Portal,bn=L.forwardRef(({className:e,...t},n)=>fe.jsx($.Overlay,{className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));bn.displayName=$.Overlay.displayName;const yn=L.forwardRef(({className:e,...t},n)=>fe.jsxs(xn,{children:[fe.jsx(bn,{}),fe.jsx($.Content,{ref:n,className:pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));yn.displayName=$.Content.displayName;const vn=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-6 rounded-t-lg",e),...t});vn.displayName="AlertDialogHeader";const wn=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});wn.displayName="AlertDialogFooter";const kn=L.forwardRef(({className:e,...t},n)=>fe.jsx($.Title,{ref:n,className:pe("text-lg font-semibold",e),...t}));kn.displayName=$.Title.displayName;const Nn=L.forwardRef(({className:e,...t},n)=>fe.jsx($.Description,{ref:n,className:pe("text-sm text-muted-foreground",e),...t}));Nn.displayName=$.Description.displayName;const jn=L.forwardRef(({className:e,...t},n)=>fe.jsx($.Action,{ref:n,className:pe(he(),e),...t}));jn.displayName=$.Action.displayName;const Sn=L.forwardRef(({className:e,...t},n)=>fe.jsx($.Cancel,{ref:n,className:pe(he({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Sn.displayName=$.Cancel.displayName;const Cn=({open:t,onOpenChange:n,item:r,onConfirm:a,entityName:o="item",isDeleting:s=!1})=>{const[i,l]=e.useState("");e.useEffect(()=>{t||l("")},[t]);const c=()=>{l(""),n(!1)},u=i===r?.title;return r?fe.jsx(hn,{open:t,onOpenChange:c,children:fe.jsxs(yn,{className:"sm:max-w-[500px]",children:[fe.jsx(vn,{children:fe.jsxs("div",{className:"flex items-center space-x-2",children:[fe.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:fe.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),fe.jsx("div",{className:"flex-1",children:fe.jsx(kn,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),fe.jsx(Nn,{asChild:!0,children:fe.jsxs("div",{className:"space-y-4",children:[fe.jsxs("div",{className:"text-sm text-muted-foreground",children:[fe.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",o,":"]}),fe.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:fe.jsx("p",{className:"font-medium text-foreground",children:r.title})})]}),fe.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:fe.jsxs("div",{className:"flex items-start space-x-2",children:[fe.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:fe.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),fe.jsxs("div",{className:"text-sm text-orange-800",children:[fe.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),fe.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",o," será removido permanentemente do sistema."]})]})]})}),fe.jsxs("div",{className:"space-y-2",children:[fe.jsxs(ye,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",fe.jsxs("strong",{children:['"',r.title,'"']})," abaixo:"]}),fe.jsx(xe,{id:"confirmation",type:"text",value:i,onChange:e=>l(e.target.value),placeholder:`Digite: ${r.title}`,className:"w-full"})]})]})}),fe.jsxs(wn,{children:[fe.jsx(Sn,{onClick:c,children:"Cancelar"}),fe.jsx(jn,{onClick:()=>{r&&i===r.title&&(a(r),l(""),n(!1))},disabled:!u||s,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:s?"Removendo...":`Excluir ${o}`})]})]})}):null},Tn=L.forwardRef(({className:e,...t},n)=>fe.jsx("table",{ref:n,className:pe("w-full caption-bottom text-sm",e),...t}));Tn.displayName="Table";const En=L.forwardRef(({className:e,...t},n)=>fe.jsx("thead",{ref:n,className:pe("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));En.displayName="TableHeader";const In=L.forwardRef(({className:e,...t},n)=>fe.jsx("tbody",{ref:n,className:pe("[&_tr:last-child]:border-0",e),...t}));In.displayName="TableBody";const An=L.forwardRef(({className:e,...t},n)=>fe.jsx("tfoot",{ref:n,className:pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));An.displayName="TableFooter";const Pn=L.forwardRef(({className:e,...t},n)=>fe.jsx("tr",{ref:n,className:pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));Pn.displayName="TableRow";const Dn=L.forwardRef(({className:e,...t},n)=>fe.jsx("th",{ref:n,className:pe("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));Dn.displayName="TableHead";const Rn=L.forwardRef(({className:e,...t},n)=>fe.jsx("td",{ref:n,className:pe("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Rn.displayName="TableCell";const _n=L.forwardRef(({className:e,...t},n)=>fe.jsx("caption",{ref:n,className:pe("mt-4 text-sm text-muted-foreground",e),...t}));function On({className:e,...t}){return fe.jsx("div",{className:pe("animate-pulse rounded-md bg-muted",e),...t})}function Ln({rows:e=5,columns:t=4}){return fe.jsx("div",{className:"w-full",children:fe.jsxs("div",{className:"rounded-md border",children:[fe.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:fe.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>fe.jsx(On,{className:"h-4 w-24"},t))})}),fe.jsx("div",{children:Array.from({length:e}).map((e,n)=>fe.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:fe.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>fe.jsx(On,{className:"h-4 w-20"},t))})},n))})]})})}function Fn({count:e=3}){return fe.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>fe.jsxs(ve,{children:[fe.jsxs(we,{children:[fe.jsx(On,{className:"h-4 w-3/4"}),fe.jsx(On,{className:"h-3 w-1/2"})]}),fe.jsx(je,{children:fe.jsxs("div",{className:"space-y-2",children:[fe.jsx(On,{className:"h-3 w-full"}),fe.jsx(On,{className:"h-3 w-2/3"})]})})]},t))})}_n.displayName="TableCaption";const zn={default:l.FileX,search:l.Search,error:l.AlertCircle};function Mn({icon:e,title:t,description:n,action:r,className:a,variant:o="default"}){const s=e?()=>e:zn[o];return fe.jsxs("div",{className:pe("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[fe.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:fe.jsx(s,{className:"h-8 w-8 text-muted-foreground"})}),fe.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&fe.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&fe.jsx(ge,{onClick:r.onClick,variant:"outline",children:r.label})]})}const Bn=V.Root,Un=V.Trigger,$n=V.Group,Vn=V.Portal,qn=V.Sub,Hn=V.RadioGroup,Wn=L.forwardRef(({className:e,inset:t,children:n,...r},a)=>fe.jsxs(V.SubTrigger,{ref:a,className:pe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,fe.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Wn.displayName=V.SubTrigger.displayName;const Qn=L.forwardRef(({className:e,...t},n)=>fe.jsx(V.SubContent,{ref:n,className:pe("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Qn.displayName=V.SubContent.displayName;const Xn=L.forwardRef(({className:e,sideOffset:t=4,...n},r)=>fe.jsx(V.Portal,{children:fe.jsx(V.Content,{ref:r,sideOffset:t,className:pe("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-white shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-gray-800 dark:border-gray-700",e),...n})}));Xn.displayName=V.Content.displayName;const Kn=L.forwardRef(({className:e,inset:t,...n},r)=>fe.jsx(V.Item,{ref:r,className:pe("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Kn.displayName=V.Item.displayName;const Yn=L.forwardRef(({className:e,children:t,checked:n,...r},a)=>fe.jsxs(V.CheckboxItem,{ref:a,className:pe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[fe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:fe.jsx(V.ItemIndicator,{children:fe.jsx(l.Check,{className:"h-4 w-4"})})}),t]}));Yn.displayName=V.CheckboxItem.displayName;const Gn=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsxs(V.RadioItem,{ref:r,className:pe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[fe.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:fe.jsx(V.ItemIndicator,{children:fe.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Gn.displayName=V.RadioItem.displayName;const Jn=L.forwardRef(({className:e,inset:t,...n},r)=>fe.jsx(V.Label,{ref:r,className:pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Jn.displayName=V.Label.displayName;const Zn=L.forwardRef(({className:e,...t},n)=>fe.jsx(V.Separator,{ref:n,className:pe("-mx-1 my-1 h-px bg-muted",e),...t}));Zn.displayName=V.Separator.displayName;const er=({className:e,...t})=>fe.jsx("span",{className:pe("ml-auto text-xs tracking-widest opacity-60",e),...t});er.displayName="DropdownMenuShortcut";const tr=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,renderAs:o})=>{const s=[];if(e){const t={icon:l.Edit,label:"Editar",onClick:e};s.push(t)}if(n){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:n};s.push(e)}if(a&&t){const e={icon:l.Trash2,label:"Remover",onClick:t,destructive:!0};s.push(e)}return"dropdown"===o?fe.jsx(fe.Fragment,{children:s.map((e,t)=>fe.jsxs(Kn,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[fe.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):fe.jsx(fe.Fragment,{children:s.map((e,t)=>fe.jsxs(ge,{variant:"ghost",size:"sm",onClick:e.onClick,className:"w-full justify-start h-auto py-2 px-3 text-sm font-normal "+(e.destructive?"text-destructive hover:text-destructive":""),children:[fe.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},nr=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>fe.jsxs(Bn,{children:[fe.jsx(Un,{asChild:!0,children:fe.jsx(ge,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:fe.jsx(l.EllipsisVertical,{size:12})})}),fe.jsx(Xn,{align:"end",children:fe.jsx(tr,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),rr=e.memo(({checked:e,onCheckedChange:t})=>fe.jsx(Ge,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),ar=({manager:t,columns:n,onEdit:r,onView:a,onToggleStatus:o,onDelete:s,renderActions:i,enableBulkActions:c=!1})=>{const[u,d]=e.useState(!1),[f,p]=e.useState(null),m=e.useRef(null),h=e.useRef(0),g=e.useRef(0),x=e.useCallback(()=>{m.current&&(h.current=m.current.scrollTop),g.current=window.scrollY},[]);e.useLayoutEffect(()=>{m.current&&h.current>0&&(m.current.scrollTop=h.current),g.current>0&&window.scrollTo(0,g.current)},[t.selectedIds]);const b=e.useCallback(e=>{x(),t.selectItem(e)},[x,t]),y=e.useCallback(()=>{x(),t.selectAll()},[x,t]);e.useEffect(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e.useEffect(()=>{const e=()=>p(null);if(f)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[f]);const v=(()=>{n.length;let e=0;const t=n.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const n=t.minWidth||120,r=t.weight||1;return e+=n,{...t,calculatedWidth:n,weight:r,isFixed:!1}}});return e+=100,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})();return u?t.isLoading?fe.jsx(Fn,{count:3}):0===t.entities.length?fe.jsx(Mn,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):fe.jsxs("div",{className:"space-y-4",children:[t.entities.map(e=>fe.jsx(ve,{className:pe("overflow-hidden cursor-pointer hover:bg-muted/50",c&&t.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),c||r?.(e)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),p({x:t.clientX,y:t.clientY,item:e})},children:fe.jsx(je,{className:"p-4",children:fe.jsxs("div",{className:"flex items-start gap-3",children:[c&&fe.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:fe.jsx(rr,{checked:t.selectedIds.includes(e.id),onCheckedChange:()=>b(e.id)})}),fe.jsxs("div",{className:"flex-1",children:[n.map(t=>fe.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[fe.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),fe.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):e[t.key]})]},String(t.key))),(r||a||i)&&fe.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:i?i(e):fe.jsx(nr,{onEdit:r?()=>{r(e)}:void 0,onDelete:s?()=>s(e):void 0,onToggleStatus:o?()=>o(e):void 0,isActive:e.is_actived})})]})]})})},e.id)),f&&fe.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:fe.jsx(tr,{onEdit:r?()=>{r(f.item),p(null)}:void 0,onDelete:s?()=>{s(f.item),p(null)}:void 0,onToggleStatus:o?()=>{o(f.item),p(null)}:void 0,isActive:f.item.is_actived,canDelete:!!s,renderAs:"context"})})]}):fe.jsxs("div",{className:"flex flex-col h-full",children:[t.isLoading?fe.jsx(Ln,{rows:5,columns:n.length}):fe.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:fe.jsx("div",{className:"flex-1 overflow-auto",ref:m,children:fe.jsxs(Tn,{className:"table-auto",children:[fe.jsxs("colgroup",{children:[c&&fe.jsx("col",{style:{width:"50px"}}),v.map((e,t)=>fe.jsx("col",{style:e.style},t)),fe.jsx("col",{style:{width:"100px"}})]}),fe.jsx(En,{children:fe.jsxs(Pn,{children:[c&&fe.jsx(Dn,{className:"w-[50px]",children:fe.jsx(rr,{checked:t.isAllSelected,onCheckedChange:y})}),n.map(e=>{return fe.jsx(Dn,{className:`${e.className||""} ${e.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:e.sortable?()=>t.handleSort(String(e.key)):void 0,children:fe.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,e.sortable&&(n=String(e.key),t.sortField!==n?fe.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?fe.jsx(l.ArrowUp,{size:14,className:"ml-1"}):fe.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]})},String(e.key));var n}),fe.jsx(Dn,{className:"w-[100px] text-center",children:"Ações"})]})}),fe.jsx(In,{children:0===t.entities.length?fe.jsx(Pn,{children:fe.jsx(Rn,{colSpan:n.length+1,className:"h-32",children:fe.jsx(Mn,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):t.entities.map(e=>fe.jsxs(Pn,{className:pe("cursor-pointer hover:bg-muted/50",c&&t.selectedIds.includes(e.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),c||r?.(e)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),p({x:t.clientX,y:t.clientY,item:e})},children:[c&&fe.jsx(Rn,{onClick:e=>e.stopPropagation(),children:fe.jsx(rr,{checked:t.selectedIds.includes(e.id),onCheckedChange:()=>b(e.id)})}),n.map(t=>fe.jsx(Rn,{className:t.className,children:t.render?t.render(e):e[t.key]},String(t.key))),fe.jsx(Rn,{className:"text-center",children:i?i(e):fe.jsx(nr,{onEdit:r?()=>r(e):void 0,onDelete:s?()=>s(e):void 0,onToggleStatus:o?()=>o(e):void 0,isActive:e.is_actived})})]},e.id))})]})})}),f&&fe.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:fe.jsx(tr,{onEdit:r?()=>{r(f.item),p(null)}:void 0,onDelete:s?()=>{s(f.item),p(null)}:void 0,onToggleStatus:o?()=>{o(f.item),p(null)}:void 0,isActive:f.item.is_actived,canDelete:!!s,renderAs:"context"})})]})};function or(t,n,r,a){const[o,s]=e.useState({}),[i,l]=e.useState({}),c=e.useMemo(()=>t,[t]),u=e=>e instanceof Date&&!isNaN(e.getTime()),d=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},f=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(n){return d(e)}},p=(e,t,n)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let a;if("function"==typeof e.validation?a=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(a=e.validation.custom),a)try{const e=a(t,n);if(e)return e}catch(r){}}};e.useEffect(()=>{if(!a)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},t=e(c),o={};t.forEach(e=>{let t;if(n&&void 0!==n[e.name]){if(t=n[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=d(e);o[e.name]=t}),t.forEach(e=>{const t=f(e,o);void 0!==t&&(o[e.name]=t)}),n&&Object.keys(n).forEach(e=>{t.find(t=>t.name===e)||void 0===n[e]||(o[e]=n[e])}),s(o),l({}),r&&r(o)},[c,n,r,a]);const m=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...m(e.fields))}),t},h=()=>{const e=m(c),t={};return e.forEach(e=>{const n=p(e,o[e.name],o);n&&(t[e.name]=n)}),l(t),0===Object.keys(t).length};return{formData:o,errors:i,updateField:(e,t)=>{s(n=>{const a={...n,[e]:t},o=((e,t)=>{let n={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=f(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,a);return r&&r(o),o}),i[e]&&l(t=>{const n={...t};return delete n[e],n});const n=m(c).find(t=>t.name===e);if(n){const r=p(n,t,o);r&&l(t=>({...t,[e]:r}))}},validateForm:h,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),h()&&e(o)}}}const sr=q.Root,ir=q.Trigger,lr=L.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>fe.jsx(q.Portal,{children:fe.jsx(q.Content,{ref:a,align:t,sideOffset:n,className:pe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));lr.displayName=q.Content.displayName;const cr=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],ur=({value:e="#3b82f6",onChange:t,label:n})=>fe.jsxs("div",{className:"space-y-2",children:[n&&fe.jsx(ye,{children:n}),fe.jsxs(sr,{children:[fe.jsx(ir,{asChild:!0,children:fe.jsxs(ge,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[fe.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),fe.jsx(lr,{className:"w-64",children:fe.jsxs("div",{className:"space-y-3",children:[fe.jsxs("div",{children:[fe.jsx(ye,{htmlFor:"color-input",children:"Cor personalizada"}),fe.jsx(xe,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),fe.jsxs("div",{children:[fe.jsx(ye,{children:"Cores predefinidas"}),fe.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:cr.map(e=>fe.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]}),dr=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsxs(H.Root,{ref:r,className:pe("relative overflow-hidden",e),...n,children:[fe.jsx(H.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),fe.jsx(fr,{}),fe.jsx(H.Corner,{})]}));dr.displayName=H.Root.displayName;const fr=L.forwardRef(({className:e,orientation:t="vertical",...n},r)=>fe.jsx(H.ScrollAreaScrollbar,{ref:r,orientation:t,className:pe("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:fe.jsx(H.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));fr.displayName=H.ScrollAreaScrollbar.displayName;const pr={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},mr=({value:t="Star",onChange:n,label:r})=>{const[a,o]=e.useState(""),s=Object.entries(pr).filter(([e])=>e.toLowerCase().includes(a.toLowerCase())),i=pr[t]||l.Star;return fe.jsxs("div",{className:"space-y-2",children:[r&&fe.jsx(ye,{children:r}),fe.jsxs(sr,{children:[fe.jsx(ir,{asChild:!0,children:fe.jsxs(ge,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[fe.jsx(i,{className:"h-4 w-4 mr-2"}),t]})}),fe.jsx(lr,{className:"w-80",children:fe.jsxs("div",{className:"space-y-3",children:[fe.jsxs("div",{children:[fe.jsx(ye,{htmlFor:"icon-search",children:"Buscar ícone"}),fe.jsx(xe,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:a,onChange:e=>o(e.target.value)})]}),fe.jsx(dr,{className:"h-48",children:fe.jsx("div",{className:"grid grid-cols-6 gap-2",children:s.map(([e,r])=>fe.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===e?"border-primary bg-primary/10":"border-border"),onClick:()=>n?.(e),title:e,children:fe.jsx(r,{className:"h-4 w-4"})},e))})})]})})]})]})};function hr({value:t,onChange:n,items:r,isLoading:a=!1,error:o=null,getItemValue:s,getItemLabel:i,searchPlaceholder:c="Buscar...",emptyMessage:u="Nenhum item disponível",noResultsMessage:d="Nenhum resultado encontrado",sortItems:f,placeholder:p="Selecionar...",disabled:m=!1,className:h}){const[g,x]=e.useState(""),b=e.useMemo(()=>{const e=f?[...r].sort(f):[...r].sort((e,t)=>i(e).localeCompare(i(t),"pt-BR"));if(!g.trim())return e;const t=g.toLowerCase();return e.filter(e=>i(e).toLowerCase().includes(t))},[r,g,f,i]);return a?fe.jsx(On,{className:pe("h-10 w-full",h)}):o?fe.jsxs("div",{className:pe("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[fe.jsx(l.AlertCircle,{className:"h-4 w-4 text-destructive"}),fe.jsx("span",{className:"text-sm text-destructive",children:o.message||"Erro ao carregar dados"})]}):fe.jsxs(qe,{value:t,onValueChange:n,disabled:m||0===r.length,children:[fe.jsx(We,{className:h,children:fe.jsx(He,{placeholder:p})}),fe.jsxs(Ke,{children:[fe.jsx("div",{className:"px-2 pb-2",children:fe.jsxs("div",{className:"relative",children:[fe.jsx(l.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),fe.jsx(xe,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===b.length?fe.jsx(Ye,{value:"no-items",disabled:!0,children:g?d:u}):b.map(e=>fe.jsx(Ye,{value:s(e),children:i(e)},s(e)))]})]})}const gr=(e={})=>{const{user:t,alias:n}=pn(),r=Yt(),{enabled:a=r.enableUsersApi}=e;return m.useQuery({queryKey:["qualiex-users",n],queryFn:()=>Vt.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},xr=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:o})=>{const{data:s=[],isLoading:i,error:l}=gr({enabled:o});return fe.jsx(hr,{value:e,onChange:t,items:s,isLoading:i,error:l,getItemValue:e=>e.userId,getItemLabel:e=>e.userName,placeholder:n,searchPlaceholder:"Buscar usuário...",emptyMessage:"Nenhum usuário disponível",noResultsMessage:"Nenhum usuário encontrado",disabled:r,className:a})};function br({title:t,sections:n,initialData:r,onSubmit:a,onCancel:o,open:s,submitButtonText:i="Salvar",isLoading:l=!1,usersData:c}){const[u,d]=e.useState(n?.[0]?.id||""),f=e.useMemo(()=>n&&Array.isArray(n)?n.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[n]),{formData:p,errors:m,updateField:h,handleSubmit:g}=or(f,r,void 0,s),x=e.useMemo(()=>n&&Array.isArray(n)?n.map(e=>({...e,disabled:e.condition?!e.condition(p):e.disabled||!1})):[],[n,p]),b=e.useMemo(()=>{const e=x.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=x.find(e=>!e.disabled);return t?.id||u},[x,u]);e.useEffect(()=>{b!==u&&d(b)},[b,u]);const y=x.find(e=>e.id===b),v=e=>{const t=(e.computedValue,p[e.name]),n=void 0!==t?t:"",r=m[e.name];switch(e.type){case"group":return fe.jsxs("div",{className:"space-y-2",children:[e.label,fe.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>v(e))})]},e.name);case"user-select":return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xr,{value:n||"",onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(Je,{id:e.name,value:n||"",onChange:t=>{h(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsxs(qe,{value:String(n),onValueChange:t=>{h(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[fe.jsx(We,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:fe.jsx(He,{placeholder:e.placeholder})}),fe.jsx(Ke,{children:e.options?.map(e=>fe.jsx(Ye,{value:e.value,children:e.label},e.value))})]}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xe,{id:e.name,type:"date",value:String(n),onChange:t=>h(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:pe("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"single-responsible-select":const t=Yt();return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xr,{value:String(n),onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":"",enabled:t.enableUsersApi}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"simple-qualiex-user-field":const a=Yt();return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xr,{value:n??"",onChange:t=>h(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":"",enabled:a.enableUsersApi}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return fe.jsxs("div",{children:[fe.jsxs(ye,{htmlFor:e.name,children:[e.label," ",e.required&&fe.jsx("span",{className:"text-destructive",children:"*"})]}),fe.jsx(xe,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>h(e.name,t.target.value),className:"h-10"}),r&&fe.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return fe.jsxs("div",{children:[fe.jsx(ur,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>h(e.name,t)}),r&&fe.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return fe.jsxs("div",{children:[fe.jsx(mr,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>h(e.name,t)}),r&&fe.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"number":return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xe,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);h(e.name,r)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return fe.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[fe.jsx(ye,{htmlFor:e.name,children:e.label}),fe.jsx(xe,{id:e.name,type:"text",value:n||"",onChange:t=>{h(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:e.disabled}),r&&fe.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},w=e.useCallback(()=>{if(!y)return null;if(y.disabled)return fe.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[fe.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:fe.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:fe.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),fe.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),fe.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(y.component){const e=y.component;return fe.jsx(e,{formData:p,updateField:h,errors:m,users:c,disabled:y.disabled})}return fe.jsx("div",{className:"space-y-3",children:y.fields.map(v)})},[y,p,h,m,c,v]),k=fe.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[x.length>1&&fe.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:fe.jsx("div",{className:"flex space-x-2",children:x.map(e=>fe.jsx(ge,{variant:b===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=x.find(t=>t.id===e);t&&!t.disabled&&d(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),fe.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:l?fe.jsx("div",{className:"flex items-center justify-center py-12",children:fe.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):fe.jsxs("form",{onSubmit:g(a),className:"space-y-3 md:space-y-4",children:[w(),fe.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[fe.jsx(ge,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),fe.jsx(ge,{type:"submit",disabled:l,children:i})]})]})})]});return fe.jsx(Ce,{open:s,onOpenChange:e=>{!1===e&&!0===s&&o()},children:fe.jsxs(Pe,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[fe.jsxs(De,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[fe.jsx(_e,{className:"text-white",children:t}),fe.jsx(Oe,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),k]})})}function yr({open:e,title:t,sections:n,initialData:r,onSubmit:a,onCancel:o,isLoading:s=!1,submitButtonText:i="Salvar"}){return fe.jsx(br,{open:e,title:t,sections:n,initialData:r,onSubmit:a,onCancel:o,isLoading:s,submitButtonText:i})}const vr=({manager:e})=>{const{pagination:t={totalItems:0,totalPages:1},currentPage:n=1,itemsPerPage:r=10,handlePageChange:a=()=>{},handleItemsPerPageChange:o=()=>{}}=e,{totalItems:s=0,totalPages:i=1}=t,c=s>0?(n-1)*r+1:0,u=Math.min(n*r,s);return fe.jsxs("div",{className:"px-4 h-12 flex items-center justify-between text-sm text-muted-foreground bg-muted/50 border-t border-border flex-shrink-0 mt-auto",children:[fe.jsxs("div",{className:"flex items-center space-x-3",children:[fe.jsx("span",{children:"Itens por página"}),fe.jsxs(qe,{value:r.toString(),onValueChange:e=>o(Number(e)),children:[fe.jsx(We,{className:"w-20 h-8 border-border",children:fe.jsx(He,{})}),fe.jsxs(Ke,{children:[fe.jsx(Ye,{value:"10",children:"10"}),fe.jsx(Ye,{value:"25",children:"25"}),fe.jsx(Ye,{value:"50",children:"50"}),fe.jsx(Ye,{value:"100",children:"100"})]})]})]}),fe.jsx("div",{className:"flex-1 flex justify-center",children:fe.jsx("span",{children:s>0?`${c}-${u} de ${s} itens (página ${n} de ${i})`:"0 itens"})}),fe.jsxs("div",{className:"flex items-center space-x-1",children:[fe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===n,children:fe.jsx(l.ChevronsLeft,{className:"h-4 w-4"})}),fe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>a(Math.max(1,n-1)),disabled:1===n,children:fe.jsx(l.ChevronLeft,{className:"h-4 w-4"})}),fe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>a(Math.min(i,n+1)),disabled:n===i,children:fe.jsx(l.ChevronRight,{className:"h-4 w-4"})}),fe.jsx(ge,{variant:"outline",size:"sm",onClick:()=>a(i),disabled:n===i,children:fe.jsx(l.ChevronsRight,{className:"h-4 w-4"})})]})]})},wr=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>fe.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[fe.jsxs("div",{className:"flex items-center gap-3",children:[fe.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),fe.jsxs(ge,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[fe.jsx(l.X,{size:14,className:"mr-1"}),"Limpar"]})]}),fe.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return fe.jsxs(ge,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&fe.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&fe.jsxs(ge,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[fe.jsx(l.Trash2,{size:14,className:"mr-1"}),"Deletar"]})]})]}),kr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Nr={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},jr={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function Sr({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:o=!1,className:s}){return fe.jsx("div",{className:pe("flex","column"===t?"flex-col":"flex-row",kr[n],Nr[r],jr[a],o&&"flex-wrap",s),children:e})}function Cr({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=pn(),a=e.searchTerm,o=fe.jsxs(fe.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&fe.jsxs("div",{className:"relative flex-1",children:[fe.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),fe.jsx(xe,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return fe.jsx("div",{className:n?"":"w-full sm:w-auto",children:fe.jsx(r,{...e.props})},t)}),a&&fe.jsxs(ge,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[fe.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?fe.jsx("div",{className:"flex items-center gap-2",children:o}):fe.jsx(Sr,{direction:"column",gap:"md",className:"mb-6",children:fe.jsx(Sr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function Tr({manager:t,config:n,formSections:r,onSave:a,onToggleStatus:o}){const{setSearchVisible:s}=pn(),[i,c]=e.useState(!1),[u,d]=e.useState(null),[f,p]=e.useState({isOpen:!1,entityId:null,entityName:""}),[m,h]=e.useState({isOpen:!1,count:0});e.useEffect(()=>(s(!0),()=>{s(!1)}),[s]);return fe.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[n.enableBulkActions&&t.selectedIds.length>0&&fe.jsx(wr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:void 0,customActions:n.bulkActions,isLoading:t.isBulkDeleting}),fe.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[fe.jsx("div",{className:"flex items-center gap-4",children:fe.jsxs(ge,{onClick:()=>{d(null),c(!0)},children:[fe.jsx(l.Plus,{size:16,className:"mr-2"}),"Novo"]})}),n.filters&&n.filters.length>0&&fe.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:fe.jsx(Cr,{manager:t,filters:n.filters,inline:!0})})]}),fe.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:fe.jsx(ar,{manager:t,columns:n.columns,onEdit:e=>{d(e),c(!0)},onDelete:e=>{p({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:o,enableBulkActions:n.enableBulkActions})}),fe.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:fe.jsx(vr,{manager:t})}),fe.jsx(yr,{open:i,title:u?`Editar ${n.entityName}`:`Novo ${n.entityName}`,sections:r,initialData:u||void 0,onSubmit:e=>{a(e),c(!1),d(null)},onCancel:()=>{c(!1),d(null)},isLoading:t.isLoading,submitButtonText:u?"Atualizar":"Criar"}),fe.jsx(Cn,{open:f.isOpen,onOpenChange:()=>{p({isOpen:!1,entityId:null,entityName:""})},onConfirm:e=>{f.entityId&&(t.deleteEntity(f.entityId),p({isOpen:!1,entityId:null,entityName:""}))},item:f.entityId?{id:f.entityId,title:f.entityName}:void 0,entityName:n.entityName,isDeleting:t.isDeleting}),fe.jsx(Cn,{open:m.isOpen,onOpenChange:()=>h({isOpen:!1,count:0}),onConfirm:()=>(t.bulkDelete?.(t.selectedIds),void h({isOpen:!1,count:0})),item:{id:"bulk",title:`${m.count} ${1===m.count?"item":"itens"}`},entityName:n.entityName,isDeleting:t.isBulkDeleting})]})}function Er(e,t,n={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const n=t[e],a={key:e,header:Ar(e),label:Ar(e),...Ir(e,n),sortable:!0,searchable:"string"==typeof n};r.push(a)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...n}}function Ir(e,t){const n=e.toLowerCase();return n.includes("email")?{type:"email",required:!0}:n.includes("phone")||n.includes("tel")?{type:"tel"}:n.includes("description")||n.includes("content")||n.includes("notes")?{type:"textarea"}:n.includes("status")||n.includes("type")||n.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Ar(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Pr={user:{title:"Usuários",searchPlaceholder:"Buscar usuários...",enableDelete:!1},product:{title:"Produtos",searchPlaceholder:"Buscar produtos...",enableFilters:!0},order:{title:"Pedidos",searchPlaceholder:"Buscar pedidos...",enableCreate:!1},category:{title:"Categorias",searchPlaceholder:"Buscar categorias...",itemsPerPage:20}};const Dr=n.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Rr=L.forwardRef(({className:e,variant:t,...n},r)=>fe.jsx("div",{ref:r,role:"alert",className:pe(Dr({variant:t}),e),...n}));Rr.displayName="Alert";const _r=L.forwardRef(({className:e,...t},n)=>fe.jsx("h5",{ref:n,className:pe("mb-1 font-medium leading-none tracking-tight",e),...t}));_r.displayName="AlertTitle";const Or=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("text-sm [&_p]:leading-relaxed",e),...t}));Or.displayName="AlertDescription";const Lr=W.Root,Fr=L.forwardRef(({className:e,...t},n)=>fe.jsx(W.Item,{ref:n,className:pe("border-b",e),...t}));Fr.displayName="AccordionItem";const zr=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsx(W.Header,{className:"flex",children:fe.jsxs(W.Trigger,{ref:r,className:pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,fe.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));zr.displayName=W.Trigger.displayName;const Mr=L.forwardRef(({className:e,children:t,...n},r)=>fe.jsx(W.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:fe.jsx("div",{className:pe("pb-4 pt-0",e),children:t})}));Mr.displayName=W.Content.displayName;const Br=Q.Root,Ur=L.forwardRef(({className:e,...t},n)=>fe.jsx(X.Root,{ref:n,className:pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Ur.displayName=X.Root.displayName;const $r=L.forwardRef(({className:e,...t},n)=>fe.jsx(X.Image,{ref:n,className:pe("aspect-square h-full w-full",e),...t}));$r.displayName=X.Image.displayName;const Vr=L.forwardRef(({className:e,...t},n)=>fe.jsx(X.Fallback,{ref:n,className:pe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Vr.displayName=X.Fallback.displayName;const qr=L.forwardRef(({...e},t)=>fe.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));qr.displayName="Breadcrumb";const Hr=L.forwardRef(({className:e,...t},n)=>fe.jsx("ol",{ref:n,className:pe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));Hr.displayName="BreadcrumbList";const Wr=L.forwardRef(({className:e,...t},n)=>fe.jsx("li",{ref:n,className:pe("inline-flex items-center gap-1.5",e),...t}));Wr.displayName="BreadcrumbItem";const Qr=L.forwardRef(({asChild:e,className:t,...n},r)=>{const a=e?L.Fragment:"a";return fe.jsx(a,{ref:r,className:pe("transition-colors hover:text-foreground",t),...n})});Qr.displayName="BreadcrumbLink";const Xr=L.forwardRef(({className:e,...t},n)=>fe.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:pe("font-normal text-foreground",e),...t}));Xr.displayName="BreadcrumbPage";const Kr=({children:e,className:t,...n})=>fe.jsx("li",{role:"presentation","aria-hidden":"true",className:pe("[&>svg]:size-3.5",t),...n,children:e??fe.jsx(l.ChevronRight,{})});Kr.displayName="BreadcrumbSeparator";const Yr=({className:e,...t})=>fe.jsxs("span",{role:"presentation","aria-hidden":"true",className:pe("flex h-9 w-9 items-center justify-center",e),...t,children:[fe.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),fe.jsx("span",{className:"sr-only",children:"More"})]});function Gr(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Jr(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):t;r=e.formattingValues[a]||e.formattingValues[t]}else{const t=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;r=e.values[a]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function Zr(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(a);if(!o)return null;const s=o[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(i,e=>e.test(s)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(i,e=>e.test(s));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:t.slice(s.length)}}}Yr.displayName="BreadcrumbEllipsis";const ea={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},ta={date:Gr({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Gr({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Gr({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},na={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},ra={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:Jr({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Jr({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Jr({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:Jr({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:Jr({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},aa={ordinalNumber:(oa={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(oa.matchPattern);if(!n)return null;const r=n[0],a=e.match(oa.parsePattern);if(!a)return null;let o=oa.valueCallback?oa.valueCallback(a[0]):a[0];return o=t.valueCallback?t.valueCallback(o):o,{value:o,rest:e.slice(r.length)}}),era:Zr({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:Zr({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Zr({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:Zr({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:Zr({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})};var oa;const sa={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=ea[e];return r="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?"em "+r:"há "+r:r},formatLong:ta,formatRelative:(e,t,n,r)=>{const a=na[e];return"function"==typeof a?a(t):a},localize:ra,match:aa,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ia({className:e,classNames:t,showOutsideDays:n=!0,...r}){return fe.jsx(j.DayPicker,{showOutsideDays:n,className:pe("p-3",e),locale:sa,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:pe(he({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:pe(he({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...e})=>fe.jsx(l.ChevronLeft,{className:"h-4 w-4"}),IconRight:({...e})=>fe.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}ia.displayName="Calendar";const la=K.Root,ca=K.CollapsibleTrigger,ua=K.CollapsibleContent,da=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));da.displayName="Command";const fa=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:fe.jsx("input",{ref:n,className:pe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})}));fa.displayName="CommandInput";const pa=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));pa.displayName="CommandList";const ma=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("py-6 text-center text-sm text-muted-foreground",e),...t}));ma.displayName="CommandEmpty";const ha=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));ha.displayName="CommandGroup";const ga=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,className:pe("-mx-1 h-px bg-border",e),...t}));ga.displayName="CommandSeparator";const xa=L.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},o)=>fe.jsx("div",{ref:o,className:pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),"data-disabled":t,onClick:()=>!t&&n?.(r||""),...a}));xa.displayName="CommandItem";const ba=({className:e,...t})=>fe.jsx("span",{className:pe("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});ba.displayName="CommandShortcut";const ya={Root:function({children:e,className:t}){return fe.jsx("div",{className:pe("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return fe.jsx(ve,{className:pe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:fe.jsx(je,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return fe.jsxs("div",{className:pe("flex justify-between items-center text-sm",n),children:[fe.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),fe.jsx("span",{className:"text-foreground",children:t})]})}},va={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},wa={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function ka({children:e,cols:t="auto-fit",gap:n="md",className:r}){return fe.jsx("div",{className:pe("grid",va[t],wa[n],r),children:e})}const Na=({className:e,...t})=>fe.jsx("nav",{role:"navigation","aria-label":"pagination",className:pe("mx-auto flex w-full justify-center",e),...t});Na.displayName="Pagination";const ja=L.forwardRef(({className:e,...t},n)=>fe.jsx("ul",{ref:n,className:pe("flex flex-row items-center gap-1",e),...t}));ja.displayName="PaginationContent";const Sa=L.forwardRef(({className:e,...t},n)=>fe.jsx("li",{ref:n,className:pe("",e),...t}));Sa.displayName="PaginationItem";const Ca=({className:e,isActive:t,size:n="icon",...r})=>fe.jsx("a",{"aria-current":t?"page":void 0,className:pe(he({variant:t?"outline":"ghost",size:n}),e),...r});Ca.displayName="PaginationLink";const Ta=({className:e,...t})=>fe.jsxs(Ca,{"aria-label":"Go to previous page",size:"default",className:pe("gap-1 pl-2.5",e),...t,children:[fe.jsx(l.ChevronLeft,{className:"h-4 w-4"}),fe.jsx("span",{children:"Previous"})]});Ta.displayName="PaginationPrevious";const Ea=({className:e,...t})=>fe.jsxs(Ca,{"aria-label":"Go to next page",size:"default",className:pe("gap-1 pr-2.5",e),...t,children:[fe.jsx("span",{children:"Next"}),fe.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Ea.displayName="PaginationNext";const Ia=({className:e,...t})=>fe.jsxs("span",{"aria-hidden":!0,className:pe("flex h-9 w-9 items-center justify-center",e),...t,children:[fe.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),fe.jsx("span",{className:"sr-only",children:"More pages"})]});Ia.displayName="PaginationEllipsis";const Aa=L.forwardRef(({className:e,value:t,...n},r)=>fe.jsx(Y.Root,{ref:r,className:pe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:fe.jsx(Y.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Aa.displayName=Y.Root.displayName;const Pa=L.forwardRef(({className:e,...t},n)=>fe.jsx(G.Root,{className:pe("grid gap-2",e),...t,ref:n}));Pa.displayName=G.Root.displayName;const Da=L.forwardRef(({className:e,...t},n)=>fe.jsx(G.Item,{ref:n,className:pe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:fe.jsx(G.Indicator,{className:"flex items-center justify-center",children:fe.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Da.displayName=G.Item.displayName;const Ra=L.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>fe.jsx(J.Root,{ref:a,decorative:n,orientation:t,className:pe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ra.displayName=J.Root.displayName;const _a=z.Root,Oa=z.Trigger,La=z.Close,Fa=z.Portal,za=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Overlay,{className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));za.displayName=z.Overlay.displayName;const Ma=n.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Ba=L.forwardRef(({side:e="right",className:t,children:n,...r},a)=>fe.jsxs(Fa,{children:[fe.jsx(za,{}),fe.jsxs(z.Content,{ref:a,className:pe(Ma({side:e}),t),...r,children:[n,fe.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[fe.jsx(l.X,{className:"h-4 w-4"}),fe.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ba.displayName=z.Content.displayName;const Ua=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ua.displayName="SheetHeader";const $a=({className:e,...t})=>fe.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});$a.displayName="SheetFooter";const Va=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Title,{ref:n,className:pe("text-lg font-semibold text-foreground",e),...t}));Va.displayName=z.Title.displayName;const qa=L.forwardRef(({className:e,...t},n)=>fe.jsx(z.Description,{ref:n,className:pe("text-sm text-muted-foreground",e),...t}));qa.displayName=z.Description.displayName;const Ha=Z.Provider,Wa=Z.Root,Qa=Z.Trigger,Xa=L.forwardRef(({className:e,sideOffset:t=4,...n},r)=>fe.jsx(Z.Content,{ref:r,sideOffset:t,className:pe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Xa.displayName=Z.Content.displayName;const Ka="sidebar:state",Ya=L.createContext(null);function Ga(){const e=L.useContext(Ya);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Ja=L.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:a,children:o,...s},i)=>{const[l,c]=L.useState(!1);L.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,d]=L.useState(!1),[f,p]=L.useState(()=>{if("undefined"!=typeof window){const t=localStorage.getItem(Ka);return null!==t?"true"===t:e}return e}),m=t??f,h=L.useCallback(e=>{const t="function"==typeof e?e(m):e;n?n(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Ka,String(t))},[n,m]),g=L.useCallback(()=>l?d(e=>!e):h(e=>!e),[l,h,d]);L.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const x=m?"expanded":"collapsed",b=L.useMemo(()=>({state:x,open:m,setOpen:h,isMobile:l,openMobile:u,setOpenMobile:d,toggleSidebar:g}),[x,m,h,l,u,d,g]);return fe.jsx(Ya.Provider,{value:b,children:fe.jsx(Ha,{delayDuration:0,children:fe.jsx("div",{className:pe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...a},ref:i,...s,children:o})})})});Ja.displayName="SidebarProvider";const Za=L.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:a,...o},s)=>{const{isMobile:i,state:l,openMobile:c,setOpenMobile:u}=Ga();return"none"===n?fe.jsx("div",{className:pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:s,...o,children:a}):i?fe.jsx(_a,{open:c,onOpenChange:u,...o,children:fe.jsxs(Ba,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:e,children:[fe.jsx(Va,{className:"sr-only",children:"Menu de Navegação"}),fe.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):fe.jsxs("div",{ref:s,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?n:"","data-variant":t,"data-side":e,children:[fe.jsx("div",{className:pe("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),fe.jsx("div",{className:pe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:fe.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:a})})]})});Za.displayName="Sidebar";const eo=L.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=Ga();return fe.jsxs(ge,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:pe("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[fe.jsx(l.PanelLeft,{}),fe.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});eo.displayName="SidebarTrigger";const to=L.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ga();return fe.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:pe("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});to.displayName="SidebarRail";const no=L.forwardRef(({className:e,...t},n)=>fe.jsx("main",{ref:n,className:pe("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));no.displayName="SidebarInset";const ro=L.forwardRef(({className:e,...t},n)=>fe.jsx(xe,{ref:n,"data-sidebar":"input",className:pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));ro.displayName="SidebarInput";const ao=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"header",className:pe("flex flex-col gap-2 p-2",e),...t}));ao.displayName="SidebarHeader";const oo=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"footer",className:pe("flex flex-col gap-2 p-2",e),...t}));oo.displayName="SidebarFooter";const so=L.forwardRef(({className:e,...t},n)=>fe.jsx(Ra,{ref:n,"data-sidebar":"separator",className:pe("mx-2 w-auto bg-sidebar-border",e),...t}));so.displayName="SidebarSeparator";const io=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"content",className:pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));io.displayName="SidebarContent";const lo=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"group",className:pe("relative flex w-full min-w-0 flex-col p-2",e),...t}));lo.displayName="SidebarGroup";const co=L.forwardRef(({className:e,asChild:n=!1,...r},a)=>{const o=n?t.Slot:"div";return fe.jsx(o,{ref:a,"data-sidebar":"group-label",className:pe("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...r})});co.displayName="SidebarGroupLabel";const uo=L.forwardRef(({className:e,asChild:n=!1,...r},a)=>{const o=n?t.Slot:"button";return fe.jsx(o,{ref:a,"data-sidebar":"group-action",className:pe("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...r})});uo.displayName="SidebarGroupAction";const fo=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"group-content",className:pe("w-full text-sm",e),...t}));fo.displayName="SidebarGroupContent";const po=L.forwardRef(({className:e,...t},n)=>fe.jsx("ul",{ref:n,"data-sidebar":"menu",className:pe("flex w-full min-w-0 flex-col gap-1",e),...t}));po.displayName="SidebarMenu";const mo=L.forwardRef(({className:e,...t},n)=>fe.jsx("li",{ref:n,"data-sidebar":"menu-item",className:pe("group/menu-item relative",e),...t}));mo.displayName="SidebarMenuItem";const ho=n.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),go=L.forwardRef(({asChild:e=!1,isActive:n=!1,variant:r="default",size:a="default",tooltip:o,className:s,...i},l)=>{const c=e?t.Slot:"button",{isMobile:u,state:d}=Ga(),f=fe.jsx(c,{ref:l,"data-sidebar":"menu-button","data-size":a,"data-active":n,className:pe(ho({variant:r,size:a}),s),...i});return o?("string"==typeof o&&(o={children:o}),fe.jsxs(Wa,{children:[fe.jsx(Qa,{asChild:!0,children:f}),fe.jsx(Xa,{side:"right",align:"center",hidden:"collapsed"!==d||u,...o})]})):f});go.displayName="SidebarMenuButton";const xo=L.forwardRef(({className:e,asChild:n=!1,showOnHover:r=!1,...a},o)=>{const s=n?t.Slot:"button";return fe.jsx(s,{ref:o,"data-sidebar":"menu-action",className:pe("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...a})});xo.displayName="SidebarMenuAction";const bo=L.forwardRef(({className:e,...t},n)=>fe.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:pe("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));bo.displayName="SidebarMenuBadge";const yo=L.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const a=L.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return fe.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:pe("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&fe.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),fe.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":a}})]})});yo.displayName="SidebarMenuSkeleton";const vo=L.forwardRef(({className:e,...t},n)=>fe.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:pe("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));vo.displayName="SidebarMenuSub";const wo=L.forwardRef(({...e},t)=>fe.jsx("li",{ref:t,...e}));wo.displayName="SidebarMenuSubItem";const ko=L.forwardRef(({asChild:e=!1,size:n="md",isActive:r,className:a,...o},s)=>{const i=e?t.Slot:"a";return fe.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":n,"data-active":r,className:pe("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===n&&"text-xs","md"===n&&"text-sm","group-data-[collapsible=icon]:hidden",a),...o})});ko.displayName="SidebarMenuSubButton";const No=L.forwardRef(({className:e,...t},n)=>fe.jsxs(ee.Root,{ref:n,className:pe("relative flex w-full touch-none select-none items-center",e),...t,children:[fe.jsx(ee.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:fe.jsx(ee.Range,{className:"absolute h-full bg-primary"})}),fe.jsx(ee.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));No.displayName=ee.Root.displayName;function jo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function So(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Co(...e){return L.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=So(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():So(e[t],null)}}}}(...e),e)}function To(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return L.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Eo=globalThis?.document?L.useLayoutEffect:()=>{},Io=L[" useInsertionEffect ".trim().toString()]||Eo;function Ao({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,o,s]=function({defaultProp:e,onChange:t}){const[n,r]=L.useState(e),a=L.useRef(n),o=L.useRef(t);return Io(()=>{o.current=t},[t]),L.useEffect(()=>{a.current!==n&&(o.current?.(n),a.current=n)},[n,a]),[n,r,o]}({defaultProp:t,onChange:n}),i=void 0!==e,l=i?e:a;{const t=L.useRef(void 0!==e);L.useEffect(()=>{const e=t.current;if(e!==i){}t.current=i},[i,r])}const c=L.useCallback(t=>{if(i){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[i,e,o,s]);return[l,c]}var Po=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=t.createSlot(`Primitive.${n}`),a=L.forwardRef((e,t)=>{const{asChild:a,...o}=e,s=a?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),fe.jsx(s,{...o,ref:t})});return a.displayName=`Primitive.${n}`,{...e,[n]:a}},{}),Do="Switch",[Ro]=function(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>L.createContext(e));return function(n){const r=n?.[e]||t;return L.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const a=L.createContext(r),o=n.length;n=[...n,r];const s=t=>{const{scope:n,children:r,...s}=t,i=n?.[e]?.[o]||a,l=L.useMemo(()=>s,Object.values(s));return fe.jsx(i.Provider,{value:l,children:r})};return s.displayName=t+"Provider",[s,function(n,s){const i=s?.[e]?.[o]||a,l=L.useContext(i);if(l)return l;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},To(r,...t)]}(Do),[_o,Oo]=Ro(Do),Lo=L.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:o,required:s,disabled:i,value:l="on",onCheckedChange:c,form:u,...d}=e,[f,p]=L.useState(null),m=Co(t,e=>p(e)),h=L.useRef(!1),g=!f||(u||!!f.closest("form")),[x,b]=Ao({prop:a,defaultProp:o??!1,onChange:c,caller:Do});return fe.jsxs(_o,{scope:n,checked:x,disabled:i,children:[fe.jsx(Po.button,{type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":Bo(x),"data-disabled":i?"":void 0,disabled:i,value:l,...d,ref:m,onClick:jo(e.onClick,e=>{b(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&fe.jsx(Mo,{control:f,bubbles:!h.current,name:r,value:l,checked:x,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Lo.displayName=Do;var Fo="SwitchThumb",zo=L.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Oo(Fo,n);return fe.jsx(Po.span,{"data-state":Bo(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});zo.displayName=Fo;var Mo=L.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const s=L.useRef(null),i=Co(s,o),l=function(e){const t=L.useRef({value:e,previous:e});return L.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(n),c=function(e){const[t,n]=L.useState(void 0);return Eo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let a,o;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;a=t.inlineSize,o=t.blockSize}else a=e.offsetWidth,o=e.offsetHeight;n({width:a,height:o})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}(t);return L.useEffect(()=>{const e=s.current;if(!e)return;const t=window.HTMLInputElement.prototype,a=Object.getOwnPropertyDescriptor(t,"checked").set;if(l!==n&&a){const t=new Event("click",{bubbles:r});a.call(e,n),e.dispatchEvent(t)}},[l,n,r]),fe.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:i,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Bo(e){return e?"checked":"unchecked"}Mo.displayName="SwitchBubbleInput";var Uo=Lo,$o=zo;const Vo=L.forwardRef(({className:e,...t},n)=>fe.jsx(Uo,{className:pe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:fe.jsx($o,{className:pe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Vo.displayName=Uo.displayName;const qo=te.Root,Ho=L.forwardRef(({className:e,...t},n)=>fe.jsx(te.List,{ref:n,className:pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Ho.displayName=te.List.displayName;const Wo=L.forwardRef(({className:e,...t},n)=>fe.jsx(te.Trigger,{ref:n,className:pe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Wo.displayName=te.Trigger.displayName;const Qo=L.forwardRef(({className:e,...t},n)=>fe.jsx(te.Content,{ref:n,className:pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Qo.displayName=te.Content.displayName;const Xo=n.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Ko=L.forwardRef(({className:e,variant:t,size:n,...r},a)=>fe.jsx(ne.Root,{ref:a,className:pe(Xo({variant:t,size:n,className:e})),...r}));Ko.displayName=ne.Root.displayName;const Yo=L.createContext({size:"default",variant:"default"}),Go=L.forwardRef(({className:e,variant:t,size:n,children:r,...a},o)=>fe.jsx(re.Root,{ref:o,className:pe("flex items-center justify-center gap-1",e),...a,children:fe.jsx(Yo.Provider,{value:{variant:t,size:n},children:r})}));Go.displayName=re.Root.displayName;const Jo=L.forwardRef(({className:e,children:t,variant:n,size:r,...a},o)=>{const s=L.useContext(Yo);return fe.jsx(re.Item,{ref:o,className:pe(Xo({variant:s.variant||n,size:s.size||r}),e),...a,children:t})});Jo.displayName=re.Item.displayName;const Zo=e.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>fe.jsx(ge,{ref:a,variant:"outline",size:"sm",className:pe("h-7 px-2 text-xs","border-primary/20 text-primary hover:bg-primary/5",t),...r,children:n||fe.jsx(l.EllipsisVertical,{size:12})}));function es(e){const t=h.useNavigate();return{onNew:()=>{const n=e.newPath||`${e.basePath}/new`;t(n)},onEdit:n=>{const r=e.editPath?e.editPath.replace(":id",n.id):`${e.basePath}/${n.id}/edit`;t(r)}}}Zo.displayName="ActionButton";const ts=e.memo(({variant:t="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:o,companies:s,alias:i,isAuthenticated:c,logout:u,switchUnit:d}=pn(),f=s?.[0]||null,p=i?s?.find(e=>e.alias===i):f,m=s||[],h=r||p||f||f,g=e.useCallback(e=>{a?a(e):d(e)},[a,d]),x=e.useMemo(()=>{if(!m?.length)return[];const e=new Map;m.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),n=t.find(e=>e.alias===h?.alias),r=t.filter(e=>e.alias!==h?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),n?[n,...r]:r},[m,h?.alias]);if(!c||!o)return null;const b=()=>fe.jsxs(fe.Fragment,{children:[fe.jsxs("div",{className:"flex items-center space-x-3",children:[fe.jsx("div",{className:"flex-shrink-0",children:fe.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:fe.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),fe.jsxs("div",{className:"flex-1 min-w-0",children:[fe.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),fe.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",h?.name||"N/A"]})]})]}),h&&fe.jsx("div",{className:"mt-3",children:fe.jsxs("div",{className:"flex items-center space-x-2",children:[fe.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),fe.jsx("span",{className:"text-sm font-medium",children:h.name})]})}),x.length>1&&fe.jsxs("div",{className:"mt-2",children:[fe.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",x.length]}),fe.jsxs("div",{className:"flex flex-wrap gap-1",children:[x.slice(0,3).map(e=>fe.jsx(et,{variant:e.alias===h?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(e),children:e.name},e.alias)),x.length>3&&fe.jsxs(et,{variant:"outline",className:"text-xs",children:["+",x.length-3]})]})]})]});return"dropdown"===t?fe.jsxs(Bn,{children:[fe.jsx(Un,{asChild:!0,children:fe.jsx(ge,{variant:"ghost",className:`h-auto p-2 ${n}`,children:fe.jsxs("div",{className:"flex items-center space-x-2",children:[fe.jsxs("div",{className:"hidden md:block text-left",children:[fe.jsx("p",{className:"text-sm font-medium",children:o.name}),fe.jsx("p",{className:"text-xs text-muted-foreground",children:h?.name||"N/A"})]}),fe.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:fe.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),fe.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),fe.jsxs(Xn,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[fe.jsxs(qn,{children:[fe.jsxs(Wn,{children:[fe.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),fe.jsx(Qn,{children:x.map(e=>fe.jsxs(Kn,{onClick:()=>g(e),className:e.alias===h?.alias?"bg-muted":"",children:[fe.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===h?.alias&&fe.jsx(et,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),fe.jsx(Zn,{}),fe.jsxs(Kn,{onClick:u,children:[fe.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):fe.jsxs(ve,{className:n,children:[fe.jsx(we,{children:fe.jsx(ke,{className:"text-lg",children:"Informações do Usuário"})}),fe.jsxs(je,{className:"space-y-4",children:[fe.jsx(b,{}),fe.jsx(Ra,{}),fe.jsxs(ge,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[fe.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),ns=e.createContext({});function rs({children:t,config:n}){const r=e.useMemo(()=>({navigation:n?.navigation,appName:n?.appName}),[n?.navigation,n?.appName]);return fe.jsx(ns.Provider,{value:r,children:t})}function as(){return e.useContext(ns)}function os(){const e=h.useLocation(),{navigation:t}=as(),n=t?.find(t=>t.path===e.pathname);return n?.label||"Página"}function ss(t,n){const[r,a]=e.useState(t),o=e.useRef(),s=e.useCallback(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return e.useEffect(()=>(s(),o.current=setTimeout(()=>{a(t)},n),s),[t,n,s]),[r,s]}const is=e.memo(function({actions:t}){const n=h.useLocation(),r=os(),{navigation:a,appName:o}=as(),{companies:s,alias:i,isSearchVisible:c,clearSearch:u,refreshData:d,switchUnit:f}=pn(),p=i?s?.find(e=>e.alias===i)||s?.[0]||null:s?.[0]||null,[m,g]=h.useSearchParams(),[x,b]=e.useState(()=>m.get("search")||""),[y,v]=ss(x,Qt.debounceDelay);e.useEffect(()=>{if(!c)return;const e=new URLSearchParams(m);y?(e.set("search",y),e.set("page","1")):e.delete("search"),g(e)},[y,g,c]);const w=a?.find(e=>e.path===n.pathname);return fe.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:fe.jsxs("div",{className:"flex items-center gap-4",children:[fe.jsxs("div",{className:"flex-shrink-0",children:[fe.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[fe.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:r}),fe.jsx(et,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:o||"Módulo"})]}),fe.jsx("p",{className:"text-sm text-muted-foreground truncate",children:w?.complementaryText||"Detalhes do item"})]}),c&&fe.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[fe.jsxs("div",{className:"relative flex-1",children:[fe.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),fe.jsx(xe,{placeholder:"/wiki"===n.pathname?"Buscar artigos...":"Buscar...",value:x,onChange:e=>(e=>{b(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&fe.jsx(ge,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-gray-100",onClick:()=>{v(),b("");const e=new URLSearchParams(m);e.delete("search"),e.delete("page"),g(e)},title:"Limpar busca",children:fe.jsx(l.X,{size:14})})]}),fe.jsx(ge,{variant:"outline",size:"sm",onClick:d,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:fe.jsx(l.RefreshCw,{size:14})})]}),fe.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[t&&fe.jsx("div",{className:"flex items-center gap-2",children:t}),fe.jsx("div",{className:"text-sm",children:fe.jsx(ts,{variant:"dropdown",selectedUnit:p,onUnitChange:f})})]})]})})}),ls=(e={})=>{const{enabled:t=!0}=e,{alias:n}=pn();return m.useQuery({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=Mt(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",n).eq("status","active").order("name");if(r){if(!dn.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},cs=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>m.useQuery({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),us=(void 0).VITE_SUPABASE_PROJECT_ID,ds={logo:`https://${us}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${us}.supabase.co/storage/v1/object/public/library-assets/small.svg`},fs=ds.logo,ps=ds.smallLogo,ms="forlogic-sidebar-pinned",hs=()=>{try{const e=localStorage.getItem(ms);return!!e&&JSON.parse(e)}catch{return!1}};function gs({config:t}={}){const{state:n,open:r,setOpen:a}=Ga(),o=h.useLocation(),{alias:s,user:i}=pn(),[c,u]=e.useState(!1),[d,f]=e.useState(hs),[p,m]=e.useState(!1);e.useEffect(()=>{a(!!d||!(!p&&!c))},[d,p,c,a]);const{data:g,isLoading:x,error:b}=ls({enabled:c}),y=e=>o.pathname===e,v=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]};return fe.jsxs(Za,{collapsible:"icon",onMouseEnter:()=>{d||m(!0)},onMouseLeave:()=>{d||m(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[fe.jsxs(ao,{className:"p-0 gap-0",children:[fe.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?fe.jsxs(fe.Fragment,{children:[fe.jsx("div",{className:"flex items-center pl-[12px]",children:fe.jsx("img",{src:ds.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),fe.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(ms,JSON.stringify(e))}catch{}})(e)},className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(d?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:fe.jsx(l.PanelLeft,{className:"h-4 w-4"})})]}):fe.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:fe.jsx("img",{src:ds.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),fe.jsx("div",{className:"mt-2 pt-0",children:fe.jsxs(Bn,{onOpenChange:u,children:[fe.jsx(Un,{asChild:!0,children:r?fe.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[fe.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[fe.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),fe.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:t?.appName||"Título do módulo"})]}),fe.jsx(l.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):fe.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:fe.jsx(l.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),fe.jsx(Xn,{className:r?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:r?"start":"center",children:x?fe.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[fe.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),fe.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):b?fe.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[fe.jsx(l.AlertCircle,{className:"h-4 w-4"}),fe.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):g&&0!==g.length?fe.jsx("div",{className:"space-y-2",children:g.map((e,t)=>fe.jsx("div",{onClick:()=>(e=>{const t=g?.find(t=>t.url===e);t?.url&&window.open(t.url,"_blank")})(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${v(t)} transition-colors duration-200\n `,children:fe.jsxs("div",{className:"flex items-center justify-between",children:[fe.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&fe.jsx(l.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):fe.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),fe.jsx(io,{children:fe.jsx(lo,{className:"p-0 mt-6",children:fe.jsx(fo,{children:fe.jsx(po,{className:"space-y-2",children:fe.jsx(Ha,{children:t?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const n=`${e.path}-${t}-${s??"noalias"}-${i?.id??"nouser"}`,{data:r=!0,isLoading:a}=cs({key:n,enabled:Boolean(e.permissionCheck&&s&&i?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),o=e.permissionCheck&&!r,c=a?l.Loader2:o?l.Lock:e.icon;return o||e.complementaryText,fe.jsx(mo,{children:o||a?fe.jsxs(Wa,{children:[fe.jsx(Qa,{asChild:!0,children:fe.jsx(go,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:fe.jsxs("div",{className:"flex w-full items-center gap-3",children:[fe.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:fe.jsx(c,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),fe.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),fe.jsx(Xa,{children:fe.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):fe.jsx(go,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:fe.jsxs(h.Link,{to:e.path,className:"flex w-full items-center gap-3",children:[fe.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:fe.jsx(c,{className:"h-5 w-4"})}),fe.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return fe.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const xs=e.memo(function({children:t,sidebar:n,sidebarConfig:r,showHeader:a=!0}){const o=e.useMemo(()=>n||fe.jsx(gs,{config:r}),[n,r]),s=e.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return fe.jsx(rs,{config:r,children:fe.jsx(Ja,{defaultOpen:!1,style:s,children:fe.jsxs("div",{className:"min-h-screen flex w-full",children:[o,fe.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[a&&fe.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:fe.jsx(is,{})}),fe.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:t})]})]})})})});class bs extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Dt.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:fe.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsxs(we,{className:"text-center",children:[fe.jsx("div",{className:"flex justify-center mb-4",children:fe.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),fe.jsx(ke,{children:"Algo deu errado"})]}),fe.jsxs(je,{className:"text-center space-y-4",children:[fe.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),fe.jsx(ge,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function ys(){const[t,n]=e.useState([]),[r,a]=e.useState(!1),[o,s]=e.useState(null),[i,l]=e.useState(null);e.useEffect(()=>{c()},[]);const c=async()=>{try{const e=Mt(),{data:t,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;s(t.threadId),n([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){l("Erro ao inicializar conversa"),g.toast.error("Erro ao inicializar conversa")}},u=e.useCallback(async e=>{if(!o||!e.trim())return;const t={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};n(e=>[...e,t]),a(!0),l(null);try{const t=Mt(),{data:r,error:a}=await t.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:o,message:e}});if(a)throw a;const{runId:s}=r,i=await(async e=>{if(!o)return!1;for(let n=0;n<60;n++)try{const t=Mt(),{data:n,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:o,runId:e}});if(r)throw r;const{status:a}=n;if("completed"===a)return!0;if("failed"===a||"cancelled"===a)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(s);i&&await(async()=>{if(o)try{const e=Mt(),{data:t,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:o}});if(r)throw r;const a=t.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));n(a)}catch(e){throw e}})()}catch(r){const e=r instanceof Error?r.message:"Erro ao enviar mensagem";l(e),g.toast.error(e),n(e=>e.filter(e=>e.id!==t.id))}finally{a(!1)}},[o]);return{messages:t,isLoading:r,error:i,sendMessage:u,threadId:o}}function vs(){}function ws(){}const ks=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ns=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,js={};function Ss(e,t){return(js.jsx?Ns:ks).test(e)}const Cs=/[ \t\n\f\r]/g;function Ts(e){return""===e.replace(Cs,"")}class Es{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Is(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Es(n,r,t)}function As(e){return e.toLowerCase()}Es.prototype.normal={},Es.prototype.property={},Es.prototype.space=void 0;class Ps{constructor(e,t){this.attribute=t,this.property=e}}Ps.prototype.attribute="",Ps.prototype.booleanish=!1,Ps.prototype.boolean=!1,Ps.prototype.commaOrSpaceSeparated=!1,Ps.prototype.commaSeparated=!1,Ps.prototype.defined=!1,Ps.prototype.mustUseProperty=!1,Ps.prototype.number=!1,Ps.prototype.overloadedBoolean=!1,Ps.prototype.property="",Ps.prototype.spaceSeparated=!1,Ps.prototype.space=void 0;let Ds=0;const Rs=Bs(),_s=Bs(),Os=Bs(),Ls=Bs(),Fs=Bs(),zs=Bs(),Ms=Bs();function Bs(){return 2**++Ds}var Us=Object.freeze({__proto__:null,boolean:Rs,booleanish:_s,commaOrSpaceSeparated:Ms,commaSeparated:zs,number:Ls,overloadedBoolean:Os,spaceSeparated:Fs});const $s=Object.keys(Us);class Vs extends Ps{constructor(e,t,n,r){let a=-1;if(super(e,t),qs(this,"space",r),"number"==typeof n)for(;++a<$s.length;){const e=$s[a];qs(this,$s[a],(n&Us[e])===Us[e])}}}function qs(e,t,n){n&&(e[t]=n)}function Hs(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new Vs(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[As(r)]=r,n[As(o.attribute)]=r}return new Es(t,n,e.space)}Vs.prototype.defined=!0;const Ws=Hs({properties:{ariaActiveDescendant:null,ariaAtomic:_s,ariaAutoComplete:null,ariaBusy:_s,ariaChecked:_s,ariaColCount:Ls,ariaColIndex:Ls,ariaColSpan:Ls,ariaControls:Fs,ariaCurrent:null,ariaDescribedBy:Fs,ariaDetails:null,ariaDisabled:_s,ariaDropEffect:Fs,ariaErrorMessage:null,ariaExpanded:_s,ariaFlowTo:Fs,ariaGrabbed:_s,ariaHasPopup:null,ariaHidden:_s,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fs,ariaLevel:Ls,ariaLive:null,ariaModal:_s,ariaMultiLine:_s,ariaMultiSelectable:_s,ariaOrientation:null,ariaOwns:Fs,ariaPlaceholder:null,ariaPosInSet:Ls,ariaPressed:_s,ariaReadOnly:_s,ariaRelevant:null,ariaRequired:_s,ariaRoleDescription:Fs,ariaRowCount:Ls,ariaRowIndex:Ls,ariaRowSpan:Ls,ariaSelected:_s,ariaSetSize:Ls,ariaSort:null,ariaValueMax:Ls,ariaValueMin:Ls,ariaValueNow:Ls,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Qs(e,t){return t in e?e[t]:t}function Xs(e,t){return Qs(e,t.toLowerCase())}const Ks=Hs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:zs,acceptCharset:Fs,accessKey:Fs,action:null,allow:null,allowFullScreen:Rs,allowPaymentRequest:Rs,allowUserMedia:Rs,alt:null,as:null,async:Rs,autoCapitalize:null,autoComplete:Fs,autoFocus:Rs,autoPlay:Rs,blocking:Fs,capture:null,charSet:null,checked:Rs,cite:null,className:Fs,cols:Ls,colSpan:null,content:null,contentEditable:_s,controls:Rs,controlsList:Fs,coords:Ls|zs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Rs,defer:Rs,dir:null,dirName:null,disabled:Rs,download:Os,draggable:_s,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Rs,formTarget:null,headers:Fs,height:Ls,hidden:Os,high:Ls,href:null,hrefLang:null,htmlFor:Fs,httpEquiv:Fs,id:null,imageSizes:null,imageSrcSet:null,inert:Rs,inputMode:null,integrity:null,is:null,isMap:Rs,itemId:null,itemProp:Fs,itemRef:Fs,itemScope:Rs,itemType:Fs,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Rs,low:Ls,manifest:null,max:null,maxLength:Ls,media:null,method:null,min:null,minLength:Ls,multiple:Rs,muted:Rs,name:null,nonce:null,noModule:Rs,noValidate:Rs,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Rs,optimum:Ls,pattern:null,ping:Fs,placeholder:null,playsInline:Rs,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Rs,referrerPolicy:null,rel:Fs,required:Rs,reversed:Rs,rows:Ls,rowSpan:Ls,sandbox:Fs,scope:null,scoped:Rs,seamless:Rs,selected:Rs,shadowRootClonable:Rs,shadowRootDelegatesFocus:Rs,shadowRootMode:null,shape:null,size:Ls,sizes:null,slot:null,span:Ls,spellCheck:_s,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ls,step:null,style:null,tabIndex:Ls,target:null,title:null,translate:null,type:null,typeMustMatch:Rs,useMap:null,value:_s,width:Ls,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fs,axis:null,background:null,bgColor:null,border:Ls,borderColor:null,bottomMargin:Ls,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Rs,declare:Rs,event:null,face:null,frame:null,frameBorder:null,hSpace:Ls,leftMargin:Ls,link:null,longDesc:null,lowSrc:null,marginHeight:Ls,marginWidth:Ls,noResize:Rs,noHref:Rs,noShade:Rs,noWrap:Rs,object:null,profile:null,prompt:null,rev:null,rightMargin:Ls,rules:null,scheme:null,scrolling:_s,standby:null,summary:null,text:null,topMargin:Ls,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ls,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Rs,disableRemotePlayback:Rs,prefix:null,property:null,results:Ls,security:null,unselectable:null},space:"html",transform:Xs}),Ys=Hs({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ms,accentHeight:Ls,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ls,amplitude:Ls,arabicForm:null,ascent:Ls,attributeName:null,attributeType:null,azimuth:Ls,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ls,by:null,calcMode:null,capHeight:Ls,className:Fs,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ls,diffuseConstant:Ls,direction:null,display:null,dur:null,divisor:Ls,dominantBaseline:null,download:Rs,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ls,enableBackground:null,end:null,event:null,exponent:Ls,externalResourcesRequired:null,fill:null,fillOpacity:Ls,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:zs,g2:zs,glyphName:zs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ls,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ls,horizOriginX:Ls,horizOriginY:Ls,id:null,ideographic:Ls,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ls,k:Ls,k1:Ls,k2:Ls,k3:Ls,k4:Ls,kernelMatrix:Ms,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ls,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ls,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ls,overlineThickness:Ls,paintOrder:null,panose1:null,path:null,pathLength:Ls,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fs,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ls,pointsAtY:Ls,pointsAtZ:Ls,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ms,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ms,rev:Ms,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ms,requiredFeatures:Ms,requiredFonts:Ms,requiredFormats:Ms,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ls,specularExponent:Ls,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ls,strikethroughThickness:Ls,string:null,stroke:null,strokeDashArray:Ms,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ls,strokeOpacity:Ls,strokeWidth:null,style:null,surfaceScale:Ls,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ms,tabIndex:Ls,tableValues:null,target:null,targetX:Ls,targetY:Ls,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ms,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ls,underlineThickness:Ls,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ls,values:null,vAlphabetic:Ls,vMathematical:Ls,vectorEffect:null,vHanging:Ls,vIdeographic:Ls,version:null,vertAdvY:Ls,vertOriginX:Ls,vertOriginY:Ls,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ls,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qs}),Gs=Hs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Js=Hs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xs}),Zs=Hs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),ei={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ti=/[A-Z]/g,ni=/-[a-z]/g,ri=/^data[-\w.:]+$/i;function ai(e){return"-"+e.toLowerCase()}function oi(e){return e.charAt(1).toUpperCase()}const si=Is([Ws,Ks,Gs,Js,Zs],"html"),ii=Is([Ws,Ys,Gs,Js,Zs],"svg");var li,ci,ui,di={};function fi(){if(ui)return di;ui=1;var e=di&&di.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(di,"__esModule",{value:!0}),di.default=function(e,n){var r=null;if(!e||"string"!=typeof e)return r;var a=(0,t.default)(e),o="function"==typeof n;return a.forEach(function(e){if("declaration"===e.type){var t=e.property,a=e.value;o?n(t,a,e):a&&((r=r||{})[t]=a)}}),r};var t=e(function(){if(ci)return li;ci=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,s=/^[;\s]*/,i=/^\s+|\s+$/g,l="";function c(e){return e?e.replace(i,l):l}return li=function(i,u){if("string"!=typeof i)throw new TypeError("First argument must be a string");if(!i)return[];u=u||{};var d=1,f=1;function p(e){var n=e.match(t);n&&(d+=n.length);var r=e.lastIndexOf("\n");f=~r?e.length-r:f+e.length}function m(){var e={line:d,column:f};return function(t){return t.position=new h(e),b(),t}}function h(e){this.start=e,this.end={line:d,column:f},this.source=u.source}function g(e){var t=new Error(u.source+":"+d+":"+f+": "+e);if(t.reason=e,t.filename=u.source,t.line=d,t.column=f,t.source=i,!u.silent)throw t}function x(e){var t=e.exec(i);if(t){var n=t[0];return p(n),i=i.slice(n.length),t}}function b(){x(n)}function y(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var e=m();if("/"==i.charAt(0)&&"*"==i.charAt(1)){for(var t=2;l!=i.charAt(t)&&("*"!=i.charAt(t)||"/"!=i.charAt(t+1));)++t;if(t+=2,l===i.charAt(t-1))return g("End of comment missing");var n=i.slice(2,t-2);return f+=2,p(n),i=i.slice(t),f+=2,e({type:"comment",comment:n})}}function w(){var t=m(),n=x(r);if(n){if(v(),!x(a))return g("property missing ':'");var i=x(o),u=t({type:"declaration",property:c(n[0].replace(e,l)),value:i?c(i[0].replace(e,l)):l});return x(s),u}}return h.prototype.content=i,b(),function(){var e,t=[];for(y(t);e=w();)!1!==e&&(t.push(e),y(t));return t}()},li}());return di}var pi,mi,hi,gi={};function xi(){if(pi)return gi;pi=1,Object.defineProperty(gi,"__esModule",{value:!0}),gi.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},s=function(e,t){return"".concat(t,"-")};return gi.camelCase=function(i,l){return void 0===l&&(l={}),function(t){return!t||n.test(t)||e.test(t)}(i)?i:(i=i.toLowerCase(),(i=l.reactCompat?i.replace(a,s):i.replace(r,s)).replace(t,o))},gi}var bi=function(){if(hi)return mi;hi=1;var e=(mi&&mi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(fi()),t=xi();function n(n,r){var a={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(a[(0,t.camelCase)(e,r)]=n)}),a):a}return n.default=n,mi=n}(),yi=ae(bi);const vi=ki("end"),wi=ki("start");function ki(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function Ni(e){return e&&"object"==typeof e?"position"in e||"type"in e?Si(e.position):"start"in e||"end"in e?Si(e):"line"in e||"column"in e?ji(e):"":""}function ji(e){return Ci(e&&e.line)+":"+Ci(e&&e.column)}function Si(e){return ji(e&&e.start)+"-"+ji(e&&e.end)}function Ci(e){return e&&"number"==typeof e?e:1}class Ti extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",a={},o=!1;if(t&&(a="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!a.cause&&e&&(o=!0,r=e.message,a.cause=e),!a.ruleId&&!a.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?a.ruleId=n:(a.source=n.slice(0,e),a.ruleId=n.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){const e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}const s=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=s?s.line:void 0,this.name=Ni(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&"string"==typeof a.cause.stack?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ti.prototype.file="",Ti.prototype.name="",Ti.prototype.reason="",Ti.prototype.message="",Ti.prototype.stack="",Ti.prototype.column=void 0,Ti.prototype.line=void 0,Ti.prototype.ancestors=void 0,Ti.prototype.cause=void 0,Ti.prototype.fatal=void 0,Ti.prototype.place=void 0,Ti.prototype.ruleId=void 0,Ti.prototype.source=void 0;const Ei={}.hasOwnProperty,Ii=new Map,Ai=/[A-Z]/g,Pi=new Set(["table","tbody","thead","tfoot","tr"]),Di=new Set(["td","th"]),Ri="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _i(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,a,o){const s=Array.isArray(a.children),i=wi(n);return t(r,a,o,s,{columnNumber:i?i.column-1:void 0,fileName:e,lineNumber:i?i.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,a,o){const s=Array.isArray(a.children)?n:t;return o?s(r,a,o):s(r,a)}}(0,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?ii:si,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},o=Oi(a,e,void 0);return o&&"string"!=typeof o?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function Oi(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(a=ii,e.schema=a);e.ancestors.push(t);const o=Bi(e,t.tagName,!1),s=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&Ei.call(t.properties,a)){const o=Mi(e,a,t.properties[a]);if(o){const[a,s]=o;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof s&&Di.has(t.tagName)?r=s:n[a]=s}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let i=zi(e,t);Pi.has(t.tagName)&&(i=i.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&Ts(t.value):Ts(t));var t}));return Li(e,s,o,t),Fi(s,i),e.ancestors.pop(),e.schema=r,e.create(t,o,s,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Ui(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.name&&"html"===r.space&&(a=ii,e.schema=a);e.ancestors.push(t);const o=null===t.name?e.Fragment:Bi(e,t.name,!0),s=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];vs(t.type);const a=t.expression;vs(a.type);const o=a.properties[0];vs(o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Ui(e,t.position);else{const a=r.name;let o;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];vs(t.type),o=e.evaluater.evaluateExpression(t.expression)}else Ui(e,t.position);else o=null===r.value||r.value;n[a]=o}return n}(e,t),i=zi(e,t);return Li(e,s,o,t),Fi(s,i),e.ancestors.pop(),e.schema=r,e.create(t,o,s,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ui(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return Fi(r,zi(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function Li(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Fi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function zi(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:Ii;for(;++r<t.children.length;){const o=t.children[r];let s;if(e.passKeys){const e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){const t=a.get(e)||0;s=e+"-"+t,a.set(e,t+1)}}const i=Oi(e,o,s);void 0!==i&&n.push(i)}return n}function Mi(e,t,n){const r=function(e,t){const n=As(t);let r=t,a=Ps;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&ri.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(ni,oi);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!ni.test(e)){let n=e.replace(ti,ai);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=Vs}return new a(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return yi(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new Ti("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=Ri+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)Ei.call(e,n)&&(t[$i(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?ei[r.property]||r.property:r.attribute,n]}}function Bi(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=Ss(e[a])?{type:"Identifier",name:e[a]}:{type:"Literal",value:e[a]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(a&&"Literal"===t.type),optional:!1}:t}r=n}else r=Ss(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return Ei.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ui(e)}function Ui(e,t){const n=new Ti("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Ri+"#cannot-handle-mdx-estrees-without-createevaluater",n}function $i(e){let t=e.replace(Ai,Vi);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function Vi(e){return"-"+e.toLowerCase()}const qi={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Hi={};function Wi(e,t){return Qi(e,"boolean"!=typeof Hi.includeImageAlt||Hi.includeImageAlt,"boolean"!=typeof Hi.includeHtml||Hi.includeHtml)}function Qi(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Xi(e.children,t,n)}return Array.isArray(e)?Xi(e,t,n):""}function Xi(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=Qi(e[a],t,n);return r.join("")}const Ki=document.createElement("i");function Yi(e){const t="&"+e+";";Ki.innerHTML=t;const n=Ki.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Gi(e,t,n,r){const a=e.length;let o,s=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ji(e,t){return e.length>0?(Gi(e,e.length,0,t),e):t}const Zi={}.hasOwnProperty;function el(e){const t={};let n=-1;for(;++n<e.length;)tl(t,e[n]);return t}function tl(e,t){let n;for(n in t){const r=(Zi.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){Zi.call(r,o)||(r[o]=[]);const e=a[o];nl(r[o],Array.isArray(e)?e:e?[e]:[])}}}function nl(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Gi(e,0,0,r)}function rl(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function al(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ol=xl(/[A-Za-z]/),sl=xl(/[\dA-Za-z]/),il=xl(/[#-'*+\--9=?A-Z^-~]/);function ll(e){return null!==e&&(e<32||127===e)}const cl=xl(/\d/),ul=xl(/[\dA-Fa-f]/),dl=xl(/[!-/:-@[-`{-~]/);function fl(e){return null!==e&&e<-2}function pl(e){return null!==e&&(e<0||32===e)}function ml(e){return-2===e||-1===e||32===e}const hl=xl(/\p{P}|\p{S}/u),gl=xl(/\s/);function xl(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function bl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let s="";if(37===o&&sl(e.charCodeAt(n+1))&&sl(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){const t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(s=String.fromCharCode(o,t),a=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+a+1,s=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function yl(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return function(r){if(ml(r))return e.enter(n),s(r);return t(r)};function s(r){return ml(r)&&o++<a?(e.consume(r),s):(e.exit(n),t(r))}}const vl={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),yl(e,t,"linePrefix")},function(t){return e.enter("paragraph"),r(t)});let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,a(t)}function a(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):fl(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const wl={tokenize:function(e){const t=this,n=[];let r,a,o,s=0;return i;function i(r){if(s<n.length){const a=n[s];return t.containerState=a[1],e.attempt(a[0].continuation,l,c)(r)}return c(r)}function l(e){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&b();const n=t.events.length;let a,o=n;for(;o--;)if("exit"===t.events[o][0]&&"chunkFlow"===t.events[o][1].type){a=t.events[o][1].end;break}x(s);let i=n;for(;i<t.events.length;)t.events[i][1].end={...a},i++;return Gi(t.events,o+1,0,t.events.slice(n)),t.events.length=i,c(e)}return i(e)}function c(a){if(s===n.length){if(!r)return f(a);if(r.currentConstruct&&r.currentConstruct.concrete)return m(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(kl,u,d)(a)}function u(e){return r&&b(),x(s),f(e)}function d(e){return t.parser.lazy[t.now().line]=s!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(kl,p,m)(n)}function p(e){return s++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){return null===n?(r&&b(),x(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:a}),h(n))}function h(n){return null===n?(g(e.exit("chunkFlow"),!0),x(0),void e.consume(n)):fl(n)?(e.consume(n),g(e.exit("chunkFlow")),s=0,t.interrupt=void 0,i):(e.consume(n),h)}function g(e,n){const i=t.sliceStream(e);if(n&&i.push(null),e.previous=a,a&&(a.next=e),a=e,r.defineSkip(e.start),r.write(i),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<o&&(!r.events[e][1].end||r.events[e][1].end.offset>o))return;const n=t.events.length;let a,i,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(a){i=t.events[l][1].end;break}a=!0}for(x(s),e=n;e<t.events.length;)t.events[e][1].end={...i},e++;Gi(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function x(r){let a=n.length;for(;a-- >r;){const r=n[a];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function b(){r.write([null]),a=void 0,r=void 0,t.containerState._closeFlow=void 0}}},kl={tokenize:function(e,t,n){return yl(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Nl(e){return null===e||pl(e)||gl(e)?1:hl(e)?2:void 0}function jl(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Sl={name:"attention",resolveAll:function(e,t){let n,r,a,o,s,i,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;i=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},f={...e[u][1].start};Cl(d,-i),Cl(f,i),o={type:i>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},s={type:i>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:f},a={type:i>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:i>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[n][1].end={...o.start},e[u][1].start={...s.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=Ji(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=Ji(l,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",a,t]]),l=Ji(l,jl(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=Ji(l,[["exit",a,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=Ji(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,Gi(e,n-1,u-n+3,l),u=n+l.length-c-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Nl(r);let o;return function(t){return o=t,e.enter("attentionSequence"),s(t)};function s(i){if(i===o)return e.consume(i),s;const l=e.exit("attentionSequence"),c=Nl(i),u=!c||2===c&&a||n.includes(i),d=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===o?u:u&&(a||!d)),l._close=Boolean(42===o?d:d&&(c||!u)),t(i)}}};function Cl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Tl={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a};function a(t){return ol(t)?(e.consume(t),o):64===t?n(t):l(t)}function o(e){return 43===e||45===e||46===e||sl(e)?(r=1,s(e)):l(e)}function s(t){return 58===t?(e.consume(t),r=0,i):(43===t||45===t||46===t||sl(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function i(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||ll(r)?n(r):(e.consume(r),i)}function l(t){return 64===t?(e.consume(t),c):il(t)?(e.consume(t),l):n(t)}function c(e){return sl(e)?u(e):n(e)}function u(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):d(n)}function d(t){if((45===t||sl(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const El={partial:!0,tokenize:function(e,t,n){return function(t){return ml(t)?yl(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||fl(e)?t(e):n(e)}}};const Il={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(ml(t))return yl(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(Il,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),a}return n(t)};function a(n){return ml(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const Al={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return dl(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const Pl={name:"characterReference",tokenize:function(e,t,n){const r=this;let a,o,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),i};function i(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),a=31,o=sl,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=ul,c):(e.enter("characterReferenceValue"),a=7,o=cl,c(t))}function c(i){if(59===i&&s){const a=e.exit("characterReferenceValue");return o!==sl||Yi(r.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(i)}return o(i)&&s++<a?(e.consume(i),c):n(i)}}};const Dl={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Rl={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return s;function s(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),ml(t)?yl(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===o?(e.enter("codeFencedFenceSequence"),u(t)):n(t)}function u(t){return t===o?(a++,e.consume(t),u):a>=i?(e.exit("codeFencedFenceSequence"),ml(t)?yl(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||fl(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let o,s=0,i=0;return function(t){return function(t){const n=r.events[r.events.length-1];return s=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,o=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===o?(i++,e.consume(t),l):i<3?n(t):(e.exit("codeFencedFenceSequence"),ml(t)?yl(e,c,"whitespace")(t):c(t))}function c(n){return null===n||fl(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Dl,p,b)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||fl(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):ml(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),yl(e,d,"whitespace")(t)):96===t&&t===o?n(t):(e.consume(t),u)}function d(t){return null===t||fl(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||fl(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===o?n(t):(e.consume(t),f)}function p(t){return e.attempt(a,b,m)(t)}function m(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return s>0&&ml(t)?yl(e,g,"linePrefix",s+1)(t):g(t)}function g(t){return null===t||fl(t)?e.check(Dl,p,b)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||fl(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function b(n){return e.exit("codeFenced"),t(n)}}};const _l={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),yl(e,a,"linePrefix",5)(t)};function a(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return null===t?i(t):fl(t)?e.attempt(Ol,o,i)(t):(e.enter("codeFlowValue"),s(t))}function s(t){return null===t||fl(t)?(e.exit("codeFlowValue"),o(t)):(e.consume(t),s)}function i(n){return e.exit("codeIndented"),t(n)}}},Ol={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):fl(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):yl(e,o,"linePrefix",5)(t)}function o(e){const o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):fl(e)?a(e):n(e)}}};const Ll={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,a=3;if(!("lineEnding"!==e[a][1].type&&"space"!==e[a][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=a;++t<r;)if("codeTextData"===e[t][1].type){e[a][1].type="codeTextPadding",e[r][1].type="codeTextPadding",a+=2,r-=2;break}t=a-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,a,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),s(t)};function s(t){return 96===t?(e.consume(t),o++,s):(e.exit("codeTextSequence"),i(t))}function i(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),i):96===t?(a=e.enter("codeTextSequence"),r=0,c(t)):fl(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||fl(t)?(e.exit("codeTextData"),i(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(a.type="codeTextData",l(n))}}};class Fl{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const a=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&zl(this.left,n),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),zl(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),zl(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);zl(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);zl(this.left,t.reverse())}}}function zl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ml(e){const t={};let n,r,a,o,s,i,l,c=-1;const u=new Fl(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&(i=n[1]._tokenizer.events,a=0,a<i.length&&"lineEndingBlank"===i[a][1].type&&(a+=2),a<i.length&&"content"===i[a][1].type))for(;++a<i.length&&"content"!==i[a][1].type;)"chunkText"===i[a][1].type&&(i[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,Bl(u,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(o=u.get(a),"lineEnding"===o[1].type||"lineEndingBlank"===o[1].type)"enter"===o[0]&&(r&&(u.get(r)[1].type="lineEndingBlank"),o[1].type="lineEnding",r=a);else if("linePrefix"!==o[1].type&&"listItemIndent"!==o[1].type)break;r&&(n[1].end={...u.get(r)[1].start},s=u.slice(r,c),s.unshift(n),u.splice(r,c-r+1,s))}}return Gi(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function Bl(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const o=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const i=s.events,l=[],c={};let u,d,f=-1,p=n,m=0,h=0;const g=[h];for(;p;){for(;e.get(++a)[1]!==p;);o.push(a),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<i.length;)"exit"===i[f][0]&&"enter"===i[f-1][0]&&i[f][1].type===i[f-1][1].type&&i[f][1].start.line!==i[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){const t=i.slice(g[f],g[f+1]),n=o.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const Ul={resolve:function(e){return Ml(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?a(t):fl(t)?e.check($l,o,a)(t):(e.consume(t),r)}function a(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},$l={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),yl(e,a,"linePrefix")};function a(a){if(null===a||fl(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}};function Vl(e,t,n,r,a,o,s,i,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(r),e.enter(a),e.enter(o),e.consume(t),e.exit(o),d;if(null===t||32===t||41===t||ll(t))return n(t);return e.enter(r),e.enter(s),e.enter(i),e.enter("chunkString",{contentType:"string"}),m(t)};function d(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(a),e.exit(r),t):(e.enter(i),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(i),d(t)):null===t||60===t||fl(t)?n(t):(e.consume(t),92===t?p:f)}function p(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function m(a){return u||null!==a&&41!==a&&!pl(a)?u<c&&40===a?(e.consume(a),u++,m):41===a?(e.consume(a),u--,m):null===a||32===a||40===a||ll(a)?n(a):(e.consume(a),92===a?h:m):(e.exit("chunkString"),e.exit(i),e.exit(s),e.exit(r),t(a))}function h(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function ql(e,t,n,r,a,o){const s=this;let i,l=0;return function(t){return e.enter(r),e.enter(a),e.consume(t),e.exit(a),e.enter(o),c};function c(d){return l>999||null===d||91===d||93===d&&!i||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(o),e.enter(a),e.consume(d),e.exit(a),e.exit(r),t):fl(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||fl(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),i||(i=!ml(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function Hl(e,t,n,r,a,o){let s;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(a),e.consume(t),e.exit(a),s=40===t?41:t,i;return n(t)};function i(n){return n===s?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),t):(e.enter(o),l(n))}function l(t){return t===s?(e.exit(o),i(s)):null===t?n(t):fl(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),yl(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||fl(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===s||92===t?(e.consume(t),c):c(t)}}function Wl(e,t){let n;return function r(a){if(fl(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(ml(a))return yl(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const Ql={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return ql.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function o(t){return a=al(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return pl(t)?Wl(e,i)(t):i(t)}function i(t){return Vl(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Xl,c,c)(t)}function c(t){return ml(t)?yl(e,u,"whitespace")(t):u(t)}function u(o){return null===o||fl(o)?(e.exit("definition"),r.parser.defined.push(a),t(o)):n(o)}}},Xl={partial:!0,tokenize:function(e,t,n){return function(t){return pl(t)?Wl(e,r)(t):n(t)};function r(t){return Hl(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return ml(t)?yl(e,o,"whitespace")(t):o(t)}function o(e){return null===e||fl(e)?t(e):n(e)}}};const Kl={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return fl(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const Yl={name:"headingAtx",resolve:function(e,t){let n,r,a=e.length-2,o=3;"whitespace"===e[o][1].type&&(o+=2);a-2>o&&"whitespace"===e[a][1].type&&(a-=2);"atxHeadingSequence"===e[a][1].type&&(o===a-1||a-4>o&&"whitespace"===e[a-2][1].type)&&(a-=o+1===a?2:4);a>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[a][1].end},r={type:"chunkText",start:e[o][1].start,end:e[a][1].end,contentType:"text"},Gi(e,o,a-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),a(t)}(t)};function a(t){return 35===t&&r++<6?(e.consume(t),a):null===t||pl(t)?(e.exit("atxHeadingSequence"),o(t)):n(t)}function o(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||fl(n)?(e.exit("atxHeading"),t(n)):ml(n)?yl(e,o,"whitespace")(n):(e.enter("atxHeadingText"),i(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),o(t))}function i(t){return null===t||35===t||pl(t)?(e.exit("atxHeadingText"),o(t)):(e.consume(t),i)}}};const Gl=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Jl=["pre","script","style","textarea"],Zl={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const r=this;let a,o,s,i,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(i){return 33===i?(e.consume(i),u):47===i?(e.consume(i),o=!0,p):63===i?(e.consume(i),a=3,r.interrupt?t:_):ol(i)?(e.consume(i),s=String.fromCharCode(i),m):n(i)}function u(o){return 45===o?(e.consume(o),a=2,d):91===o?(e.consume(o),a=5,i=0,f):ol(o)?(e.consume(o),a=4,r.interrupt?t:_):n(o)}function d(a){return 45===a?(e.consume(a),r.interrupt?t:_):n(a)}function f(a){const o="CDATA[";return a===o.charCodeAt(i++)?(e.consume(a),6===i?r.interrupt?t:C:f):n(a)}function p(t){return ol(t)?(e.consume(t),s=String.fromCharCode(t),m):n(t)}function m(i){if(null===i||47===i||62===i||pl(i)){const l=47===i,c=s.toLowerCase();return l||o||!Jl.includes(c)?Gl.includes(s.toLowerCase())?(a=6,l?(e.consume(i),h):r.interrupt?t(i):C(i)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(i):o?g(i):x(i)):(a=1,r.interrupt?t(i):C(i))}return 45===i||sl(i)?(e.consume(i),s+=String.fromCharCode(i),m):n(i)}function h(a){return 62===a?(e.consume(a),r.interrupt?t:C):n(a)}function g(t){return ml(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||ol(t)?(e.consume(t),b):ml(t)?(e.consume(t),x):j(t)}function b(t){return 45===t||46===t||58===t||95===t||sl(t)?(e.consume(t),b):y(t)}function y(t){return 61===t?(e.consume(t),v):ml(t)?(e.consume(t),y):x(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):ml(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,N):null===t||fl(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||pl(t)?y(t):(e.consume(t),k)}function N(e){return 47===e||62===e||ml(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||fl(t)?C(t):ml(t)?(e.consume(t),S):n(t)}function C(t){return 45===t&&2===a?(e.consume(t),A):60===t&&1===a?(e.consume(t),P):62===t&&4===a?(e.consume(t),O):63===t&&3===a?(e.consume(t),_):93===t&&5===a?(e.consume(t),R):!fl(t)||6!==a&&7!==a?null===t||fl(t)?(e.exit("htmlFlowData"),T(t)):(e.consume(t),C):(e.exit("htmlFlowData"),e.check(ec,L,T)(t))}function T(t){return e.check(tc,E,L)(t)}function E(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||fl(t)?T(t):(e.enter("htmlFlowData"),C(t))}function A(t){return 45===t?(e.consume(t),_):C(t)}function P(t){return 47===t?(e.consume(t),s="",D):C(t)}function D(t){if(62===t){const n=s.toLowerCase();return Jl.includes(n)?(e.consume(t),O):C(t)}return ol(t)&&s.length<8?(e.consume(t),s+=String.fromCharCode(t),D):C(t)}function R(t){return 93===t?(e.consume(t),_):C(t)}function _(t){return 62===t?(e.consume(t),O):45===t&&2===a?(e.consume(t),_):C(t)}function O(t){return null===t||fl(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),O)}function L(n){return e.exit("htmlFlow"),t(n)}}},ec={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(El,t,n)}}},tc={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(fl(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a;return n(t)};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const nc={name:"htmlText",tokenize:function(e,t,n){const r=this;let a,o,s;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),i};function i(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),b):ol(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),o=0,p):ol(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),f):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):fl(t)?(s=u,D(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),f):u(t)}function f(e){return 62===e?P(e):45===e?d(e):u(e)}function p(t){const r="CDATA[";return t===r.charCodeAt(o++)?(e.consume(t),6===o?m:p):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),h):fl(t)?(s=m,D(t)):(e.consume(t),m)}function h(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?P(t):93===t?(e.consume(t),g):m(t)}function x(t){return null===t||62===t?P(t):fl(t)?(s=x,D(t)):(e.consume(t),x)}function b(t){return null===t?n(t):63===t?(e.consume(t),y):fl(t)?(s=b,D(t)):(e.consume(t),b)}function y(e){return 62===e?P(e):b(e)}function v(t){return ol(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||sl(t)?(e.consume(t),w):k(t)}function k(t){return fl(t)?(s=k,D(t)):ml(t)?(e.consume(t),k):P(t)}function N(t){return 45===t||sl(t)?(e.consume(t),N):47===t||62===t||pl(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),P):58===t||95===t||ol(t)?(e.consume(t),S):fl(t)?(s=j,D(t)):ml(t)?(e.consume(t),j):P(t)}function S(t){return 45===t||46===t||58===t||95===t||sl(t)?(e.consume(t),S):C(t)}function C(t){return 61===t?(e.consume(t),T):fl(t)?(s=C,D(t)):ml(t)?(e.consume(t),C):j(t)}function T(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,E):fl(t)?(s=T,D(t)):ml(t)?(e.consume(t),T):(e.consume(t),I)}function E(t){return t===a?(e.consume(t),a=void 0,A):null===t?n(t):fl(t)?(s=E,D(t)):(e.consume(t),E)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||pl(t)?j(t):(e.consume(t),I)}function A(e){return 47===e||62===e||pl(e)?j(e):n(e)}function P(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function D(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return ml(t)?yl(e,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):_(t)}function _(t){return e.enter("htmlTextData"),s(t)}}};const rc={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&Gi(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,a,o,s=e.length,i=0;for(;s--;)if(n=e[s][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[s][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(a){if("enter"===e[s][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=s,"labelLink"!==n.type)){i=2;break}}else"labelEnd"===n.type&&(a=s);const l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[a][1].end}},u={type:"labelText",start:{...e[r+i+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",c,t]],o=Ji(o,e.slice(r+1,r+i+3)),o=Ji(o,[["enter",u,t]]),o=Ji(o,jl(t.parser.constructs.insideSpan.null,e.slice(r+i+4,a-3),t)),o=Ji(o,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),o=Ji(o,e.slice(a+1)),o=Ji(o,[["exit",l,t]]),Gi(e,r,e.length,o),e},tokenize:function(e,t,n){const r=this;let a,o,s=r.events.length;for(;s--;)if(("labelImage"===r.events[s][1].type||"labelLink"===r.events[s][1].type)&&!r.events[s][1]._balanced){a=r.events[s][1];break}return function(t){if(!a)return n(t);if(a._inactive)return u(t);return o=r.parser.defined.includes(al(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),i};function i(t){return 40===t?e.attempt(ac,c,o?c:u)(t):91===t?e.attempt(oc,c,o?l:u)(t):o?c(t):u(t)}function l(t){return e.attempt(sc,c,u)(t)}function c(e){return t(e)}function u(e){return a._balanced=!0,n(e)}}},ac={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return pl(t)?Wl(e,a)(t):a(t)}function a(t){return 41===t?c(t):Vl(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return pl(t)?Wl(e,i)(t):c(t)}function s(e){return n(e)}function i(t){return 34===t||39===t||40===t?Hl(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return pl(t)?Wl(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},oc={tokenize:function(e,t,n){const r=this;return function(t){return ql.call(r,e,a,o,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(al(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},sc={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const ic={name:"labelStartImage",resolveAll:rc.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),a};function a(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const lc={name:"labelStartLink",resolveAll:rc.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),a};function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const cc={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),yl(e,t,"linePrefix")}}};const uc={name:"thematicBreak",tokenize:function(e,t,n){let r,a=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,o(e)}(t)};function o(o){return o===r?(e.enter("thematicBreakSequence"),s(o)):a>=3&&(null===o||fl(o))?(e.exit("thematicBreak"),t(o)):n(o)}function s(t){return t===r?(e.consume(t),a++,s):(e.exit("thematicBreakSequence"),ml(t)?yl(e,o,"whitespace")(t):o(t))}}};const dc={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(El,a,o);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yl(e,t,"listItemIndent",r.containerState.size+1)(n)}function o(n){return r.containerState.furtherBlankLines||!ml(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pc,t,s)(n))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,yl(e,e.attempt(dc,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,a=r.events[r.events.length-1];let o=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,s=0;return function(t){const a=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===a?!r.containerState.marker||t===r.containerState.marker:cl(t)){if(r.containerState.type||(r.containerState.type=a,e.enter(a,{_container:!0})),"listUnordered"===a)return e.enter("listItemPrefix"),42===t||45===t?e.check(uc,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),i(t)}return n(t)};function i(t){return cl(t)&&++s<10?(e.consume(t),i):(!r.interrupt||s<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(El,r.interrupt?n:c,e.attempt(fc,d,u))}function c(e){return r.containerState.initialBlankLine=!0,o++,d(e)}function u(t){return ml(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},fc={partial:!0,tokenize:function(e,t,n){const r=this;return yl(e,function(e){const a=r.events[r.events.length-1];return!ml(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},pc={partial:!0,tokenize:function(e,t,n){const r=this;return yl(e,function(e){const a=r.events[r.events.length-1];return a&&"listItemIndent"===a[1].type&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}};const mc={name:"setextUnderline",resolveTo:function(e,t){let n,r,a,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),a||"definition"!==e[o][1].type||(a=o);const s={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",a?(e.splice(r,0,["enter",s,t]),e.splice(a+1,0,["exit",e[n][1],t]),e[n][1].end={...e[a][1].end}):e[n][1]=s;return e.push(["exit",s,t]),e},tokenize:function(e,t,n){const r=this;let a;return function(t){let s,i=r.events.length;for(;i--;)if("lineEnding"!==r.events[i][1].type&&"linePrefix"!==r.events[i][1].type&&"content"!==r.events[i][1].type){s="paragraph"===r.events[i][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||s))return e.enter("setextHeadingLine"),a=t,function(t){return e.enter("setextHeadingLineSequence"),o(t)}(t);return n(t)};function o(t){return t===a?(e.consume(t),o):(e.exit("setextHeadingLineSequence"),ml(t)?yl(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||fl(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const hc={tokenize:function(e){const t=this,n=e.attempt(El,function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,r,yl(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Ul,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const gc={resolveAll:vc()},xc=yc("string"),bc=yc("text");function yc(e){return{resolveAll:vc("text"===e?wc:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],a=t.attempt(r,o,s);return o;function o(e){return l(e)?a(e):s(e)}function s(e){if(null!==e)return t.enter("data"),t.consume(e),i;t.consume(e)}function i(e){return l(e)?(t.exit("data"),a(e)):(t.consume(e),i)}function l(e){if(null===e)return!0;const t=r[e];let a=-1;if(t)for(;++a<t.length;){const e=t[a];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function vc(e){return function(t,n){let r,a=-1;for(;++a<=t.length;)void 0===r?t[a]&&"data"===t[a][1].type&&(r=a,a++):t[a]&&"data"===t[a][1].type||(a!==r+2&&(t[r][1].end=t[a-1][1].end,t.splice(r+2,a-r-2),a=r+2),r=void 0);return e?e(t,n):t}}function wc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],a=t.sliceStream(r);let o,s=a.length,i=-1,l=0;for(;s--;){const e=a[s];if("string"==typeof e){for(i=e.length;32===e.charCodeAt(i-1);)l++,i--;if(i)break;i=-1}else if(-2===e)o=!0,l++;else if(-1!==e){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const a={type:n===e.length||o||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?i:r.start._bufferIndex+i,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...a.start},r.start.offset===r.end.offset?Object.assign(r,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}const kc={42:dc,43:dc,45:dc,48:dc,49:dc,50:dc,51:dc,52:dc,53:dc,54:dc,55:dc,56:dc,57:dc,62:Il},Nc={91:Ql},jc={[-2]:_l,[-1]:_l,32:_l},Sc={35:Yl,42:uc,45:[mc,uc],60:Zl,61:mc,95:uc,96:Rl,126:Rl},Cc={38:Pl,92:Al},Tc={[-5]:cc,[-4]:cc,[-3]:cc,33:ic,38:Pl,42:Sl,60:[Tl,nc],91:lc,92:[Kl,Al],93:rc,95:Sl,96:Ll},Ec={null:[Sl,gc]};var Ic=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:Nc,disable:{null:[]},document:kc,flow:Sc,flowInitial:jc,insideSpan:Ec,string:Cc,text:Tc});function Ac(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let s=[],i=[];const l={attempt:g(function(e,t){x(e,t.from)}),check:g(h),consume:function(e){fl(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,b()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=f(),c.events.push(["enter",n,c]),i.push(n),n},exit:function(e){const t=i.pop();return t.end=f(),c.events.push(["exit",t,c]),t},interrupt:g(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){a[e.line]=e.column,b()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const o=e[n];let s;if("string"==typeof o)s=o;else switch(o){case-5:s="\r";break;case-4:s="\n";break;case-3:s="\r\n";break;case-2:s=t?" ":"\t";break;case-1:if(!t&&a)continue;s=" ";break;default:s=String.fromCharCode(o)}a=-2===o,r.push(s)}return r.join("")}(d(e),t)},sliceStream:d,write:function(e){if(s=Ji(s,e),p(),null!==s[s.length-1])return[];return x(t,0),c.events=jl(o,c.events,c),c.events}};let u=t.tokenize.call(c,l);return t.resolveAll&&o.push(t),c;function d(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let s;if(n===a)s=[e[n].slice(r,o)];else{if(s=e.slice(n,a),r>-1){const e=s[0];"string"==typeof e?s[0]=e.slice(r):s.shift()}o>0&&s.push(e[a].slice(0,o))}return s}(s,e)}function f(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:o}}function p(){let e;for(;r._index<s.length;){const t=s[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)m(t.charCodeAt(r._bufferIndex));else m(t)}}function m(e){u=u(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,o){let s,u,d,p;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function m(e){return s=e,u=0,0===e.length?o:h(e[u])}function h(e){return function(n){p=function(){const e=f(),t=c.previous,n=c.currentConstruct,a=c.events.length,o=Array.from(i);return{from:a,restore:s};function s(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=a,i=o,b()}}(),d=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return x();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,x)(n)}}function g(t){return e(d,p),a}function x(e){return p.restore(),++u<s.length?h(s[u]):o}}}function x(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&Gi(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function b(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}const Pc=/[\0\t\n\r]/g;const Dc=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Rc(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return rl(n.slice(t?2:1),t?16:10)}return Yi(n)||e}const _c={}.hasOwnProperty;function Oc(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(te),autolinkProtocol:S,autolinkEmail:S,atxHeading:o(G),blockQuote:o(W),characterEscape:S,characterReference:S,codeFenced:o(Q),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Q,s),codeText:o(X,s),codeTextData:S,data:S,codeFlowValue:S,definition:o(K),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(Y),hardBreakEscape:o(J),hardBreakTrailing:o(J),htmlFlow:o(Z,s),htmlFlowData:S,htmlText:o(Z,s),htmlTextData:S,image:o(ee),label:s,link:o(te),listItem:o(re),listItemValue:f,listOrdered:o(ne,d),listUnordered:o(ne),paragraph:o(ae),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(G),strong:o(oe),thematicBreak:o(ie)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:H,autolinkProtocol:q,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:$,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:l(x),codeText:l(P),codeTextData:C,data:C,definition:l(),definitionDestinationString:v,definitionLabelString:b,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(E),hardBreakTrailing:l(E),htmlFlow:l(I),htmlFlowData:C,htmlText:l(A),htmlTextData:C,image:l(R),label:O,labelText:_,lineEnding:T,link:l(D),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:L,resourceTitleString:F,resource:z,setextHeading:l(j),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};Fc(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const o={stack:[r],tokenStack:[],config:t,enter:i,exit:c,buffer:s,resume:u,data:n},l=[];let d=-1;for(;++d<e.length;)if("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)if("enter"===e[d][0])l.push(d);else{d=a(e,l.pop(),d)}for(d=-1;++d<e.length;){const n=t[e[d][0]];_c.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},o),e[d][1])}if(o.tokenStack.length>0){const e=o.tokenStack[o.tokenStack.length-1];(e[1]||Mc).call(o,void 0,e[0])}for(r.position={start:Lc(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Lc(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function a(e,t,n){let r,a,o,s,i=t-1,l=-1,c=!1;for(;++i<=n;){const t=e[i];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||s||l||o||(o=i),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let s=i;for(a=void 0;s--;){const t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;a&&(e[a][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",a=s}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}o&&(!a||o<a)&&(r._spread=!0),r.end=Object.assign({},a?e[a][1].start:t[1].end),e.splice(a||i,0,["exit",r,t[2]]),i++,n++}if("listItemPrefix"===t[1].type){const a={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=a,e.splice(i,0,["enter",a,t[2]]),i++,n++,o=void 0,s=!0}}}return e[t][1]._spread=c,n}function o(e,t){return n;function n(n){i.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:"fragment",children:[]})}function i(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Lc(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+Ni({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||Mc).call(this,e,r[0])}n.position.end=Lc(e.end)}function u(){return Wi(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function m(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function b(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=al(this.sliceSerialize(e)).toLowerCase()}function y(){const e=this.resume();this.stack[this.stack.length-1].title=e}function v(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function S(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=se(),n.position={start:Lc(e.start),end:void 0},t.push(n)),this.stack.push(n)}function C(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Lc(e.end)}function T(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=Lc(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(S.call(this,e),C.call(this,e))}function E(){this.data.atHardBreak=!0}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function P(){const e=this.resume();this.stack[this.stack.length-1].value=e}function D(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function R(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function _(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(Dc,Rc)}(t),n.identifier=al(t).toLowerCase()}function O(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function L(){const e=this.resume();this.stack[this.stack.length-1].url=e}function F(){const e=this.resume();this.stack[this.stack.length-1].title=e}function z(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=al(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function $(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=rl(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=Yi(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=Lc(e.end)}function q(e){C.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function H(e){C.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function W(){return{type:"blockquote",children:[]}}function Q(){return{type:"code",lang:null,meta:null,value:""}}function X(){return{type:"inlineCode",value:""}}function K(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Y(){return{type:"emphasis",children:[]}}function G(){return{type:"heading",depth:0,children:[]}}function J(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function ae(){return{type:"paragraph",children:[]}}function oe(){return{type:"strong",children:[]}}function se(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}(n)(function(e){for(;!Ml(e););return e}(function(e){const t={constructs:el([Ic,...(e||{}).extensions||[]]),content:n(vl),defined:[],document:n(wl),flow:n(hc),lazy:{},string:n(xc),text:n(bc)};return t;function n(e){return function(n){return Ac(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,o,s){const i=[];let l,c,u,d,f;for(a=n+("string"==typeof a?a.toString():new TextDecoder(o||void 0).decode(a)),u=0,n="",r&&(65279===a.charCodeAt(0)&&u++,r=void 0);u<a.length;){if(Pc.lastIndex=u,l=Pc.exec(a),d=l&&void 0!==l.index?l.index:a.length,f=a.charCodeAt(d),!l){n=a.slice(u);break}if(10===f&&u===d&&e)i.push(-3),e=void 0;else switch(e&&(i.push(-5),e=void 0),u<d&&(i.push(a.slice(u,d)),t+=d-u),f){case 0:i.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),i.push(-2);t++<c;)i.push(-1);break;case 10:i.push(-4),t=1;break;default:e=!0,t=1}u=d+1}return s&&(e&&i.push(-5),n&&i.push(n),i.push(null)),i}}()(e,t,!0))))}function Lc(e){return{line:e.line,column:e.column,offset:e.offset}}function Fc(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Fc(e,r):zc(e,r)}}function zc(e,t){let n;for(n in t)if(_c.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Mc(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ni({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ni({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ni({start:t.start,end:t.end})+") is still open")}function Bc(e){const t=this;t.parser=function(n){return Oc(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Uc(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),o=a[0];o&&"text"===o.type?o.value="["+o.value:a.unshift({type:"text",value:"["});const s=a[a.length-1];return s&&"text"===s.type?s.value+=r:a.push({type:"text",value:r}),a}function $c(e){const t=e.spread;return null==t?e.children.length>1:t}function Vc(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(qc(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(qc(t.slice(a),a>0,!1)),o.join("")}function qc(e,t,n){let r=0,a=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(a-1);for(;9===t||32===t;)a--,t=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}const Hc={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={};t.lang&&(r.className=["language-"+t.lang]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=bl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let s,i=e.footnoteCounts.get(r);void 0===i?(i=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=o+1,i+=1,e.footnoteCounts.set(r,i);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(i>1?"-"+i:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);const a={src:bl(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){const n={src:bl(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Uc(e,t);const a={href:bl(r.url||"")};null!==r.title&&void 0!==r.title&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){const n={href:bl(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),a=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=$c(n[r])}return t}(n):$c(t),o={},s=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let i=-1;for(;++i<r.length;){const e=r[i];(a||0!==i||"element"!==e.type||"p"!==e.tagName)&&s.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||a?s.push(e):s.push(...e.children)}const l=r[r.length-1];l&&(a||"element"!==l.type||"p"!==l.tagName)&&s.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},r=e.all(t);let a=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++a<r.length;){const e=r[a];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),a.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=wi(t.children[1]),s=vi(t.children[t.children.length-1]);o&&s&&(r.position={start:o,end:s}),a.push(r)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,a=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,s=o?o.length:t.children.length;let i=-1;const l=[];for(;++i<s;){const n=t.children[i],r={},s=o?o[i]:void 0;s&&(r.align=s);let c={type:"element",tagName:a,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:Vc(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Wc,yaml:Wc,definition:Wc,footnoteDefinition:Wc};function Wc(){}const Qc="object"==typeof self?self:globalThis,Xc=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=a=>{if(e.has(a))return e.get(a);const[o,s]=t[a];switch(o){case 0:case-1:return n(s,a);case 1:{const e=n([],a);for(const t of s)e.push(r(t));return e}case 2:{const e=n({},a);for(const[t,n]of s)e[r(t)]=r(n);return e}case 3:return n(new Date(s),a);case 4:{const{source:e,flags:t}=s;return n(new RegExp(e,t),a)}case 5:{const e=n(new Map,a);for(const[t,n]of s)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,a);for(const t of s)e.add(r(t));return e}case 7:{const{name:e,message:t}=s;return n(new Qc[e](t),a)}case 8:return n(BigInt(s),a);case"BigInt":return n(Object(BigInt(s)),a);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:e}=new Uint8Array(s);return n(new DataView(e),s)}}return n(new Qc[o](s),a)};return r})(new Map,e)(0),Kc="",{toString:Yc}={},{keys:Gc}=Object,Jc=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Yc.call(e).slice(8,-1);switch(n){case"Array":return[1,Kc];case"Object":return[2,Kc];case"Date":return[3,Kc];case"RegExp":return[4,Kc];case"Map":return[5,Kc];case"Set":return[6,Kc];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Zc=([e,t])=>0===e&&("function"===t||"symbol"===t),eu=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const a=(e,t)=>{const a=r.push(e)-1;return n.set(t,a),a},o=r=>{if(n.has(r))return n.get(r);let[s,i]=Jc(r);switch(s){case 0:{let t=r;switch(i){case"bigint":s=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+i);t=null;break;case"undefined":return a([-1],r)}return a([s,t],r)}case 1:{if(i){let e=r;return"DataView"===i?e=new Uint8Array(r.buffer):"ArrayBuffer"===i&&(e=new Uint8Array(r)),a([i,[...e]],r)}const e=[],t=a([s,e],r);for(const n of r)e.push(o(n));return t}case 2:{if(i)switch(i){case"BigInt":return a([i,r.toString()],r);case"Boolean":case"Number":case"String":return a([i,r.valueOf()],r)}if(t&&"toJSON"in r)return o(r.toJSON());const n=[],l=a([s,n],r);for(const t of Gc(r))!e&&Zc(Jc(r[t]))||n.push([o(t),o(r[t])]);return l}case 3:return a([s,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return a([s,{source:e,flags:t}],r)}case 5:{const t=[],n=a([s,t],r);for(const[a,s]of r)(e||!Zc(Jc(a))&&!Zc(Jc(s)))&&t.push([o(a),o(s)]);return n}case 6:{const t=[],n=a([s,t],r);for(const a of r)!e&&Zc(Jc(a))||t.push(o(a));return n}}const{message:l}=r;return a([s,{name:i,message:l}],r)};return o})(!(t||n),!!t,new Map,r)(e),r};var tu="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Xc(eu(e,t)):structuredClone(e):(e,t)=>Xc(eu(e,t));function nu(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function ru(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const au=function(e){if(null==e)return su;if("function"==typeof e)return ou(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=au(e[n]);return ou(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return ou(n);function n(n){const r=n;let a;for(a in e)if(r[a]!==t[a])return!1;return!0}}(e);if("string"==typeof e)return function(e){return ou(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function ou(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function su(){return!0}const iu=[],lu=!0,cu=!1;function uu(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const o=au(a),s=r?-1:1;!function e(a,i,l){const c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){let c,u,d,f=iu;if((!t||o(a,i,l[l.length-1]||void 0))&&(f=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[lu,e];return null==e?iu:[e]}(n(a,l)),f[0]===cu))return f;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==f[0])for(u=(r?t.children.length:-1)+s,d=l.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===cu)return c;u="number"==typeof c[1]?c[1]:u+s}}return f}}(e,void 0,[])()}function du(e,t,n,r){let a,o,s;"function"==typeof t&&"function"!=typeof n?(o=void 0,s=t,a=n):(o=t,s=n,a=r),uu(e,o,function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return s(e,r,n)},a)}const fu={}.hasOwnProperty,pu={};function mu(e,t){e.position&&(t.position=function(e){const t=wi(e),n=vi(e);if(t&&n)return{start:t,end:n}}(e))}function hu(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,a=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&a&&Object.assign(n.properties,tu(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function gu(e,t){const n=t.data||{},r=!("value"in t)||fu.call(n,"hProperties")||fu.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function xu(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function bu(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function yu(e,t){const n=function(e,t){const n=t||pu,r=new Map,a=new Map,o=new Map,s={...Hc,...n.handlers},i={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const a=i.one(n[r],e);if(a){if(r&&"break"===n[r-1].type&&(Array.isArray(a)||"text"!==a.type||(a.value=bu(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=bu(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:hu,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:s,one:function(e,t){const n=e.type,r=i.handlers[n];if(fu.call(i.handlers,n)&&r)return r(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=tu(n);return r.children=i.all(e),r}return tu(e)}return(i.options.unknownHandler||gu)(i,e,t)},options:n,patch:mu,wrap:xu};return du(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:a,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),i}(e,t),r=n.one(e,void 0),a=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||nu,r=e.options.footnoteBackLabel||ru,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},i=[];let l=-1;for(;++l<e.footnoteOrder.length;){const a=e.footnoteById.get(e.footnoteOrder[l]);if(!a)continue;const o=e.all(a),s=String(a.identifier).toUpperCase(),c=bl(s.toLowerCase());let u=0;const d=[],f=e.footnoteCounts.get(s);for(;void 0!==f&&++u<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){const e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);const m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(o,!0)};e.patch(a,m),i.push(m)}if(0!==i.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...tu(s),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(i,!0)},{type:"text",value:"\n"}]}}(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&o.children.push({type:"text",value:"\n"},a),o}function vu(e,t){return e&&"run"in e?async function(n,r){const a=yu(n,{file:r,...t});await e.run(a,r)}:function(n,r){return yu(n,{file:r,...e||t})}}function wu(e){if(e)throw e}var ku,Nu;var ju=function(){if(Nu)return ku;Nu=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},o=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,a=e.call(n,"constructor"),o=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!a&&!o)return!1;for(r in n);return void 0===r||e.call(n,r)},s=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},i=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return ku=function e(){var t,n,r,l,c,u,d=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<p;++f)if(null!=(t=arguments[f]))for(n in t)r=i(d,n),d!==(l=i(t,n))&&(m&&l&&(o(l)||(c=a(l)))?(c?(c=!1,u=r&&a(r)?r:[]):u=r&&o(r)?r:{},s(d,{name:n,newValue:e(m,u,l)})):void 0!==l&&s(d,{name:n,newValue:l}));return d},ku}(),Su=ae(ju);function Cu(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function Tu(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function a(o,...s){const i=e[++n];let l=-1;if(o)r(o);else{for(;++l<t.length;)null!==s[l]&&void 0!==s[l]||(s[l]=t[l]);t=s,i?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let i;r&&t.push(a);try{i=e.apply(this,t)}catch(o){if(r&&n)throw o;return a(o)}r||(i&&i.then&&"function"==typeof i.then?i.then(s,a):i instanceof Error?a(i):s(i))}function a(e,...r){n||(n=!0,t(e,...r))}function s(e){a(null,e)}}(i,a)(...s):r(null,...s)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const Eu={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Iu(e);let n,r=0,a=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1);return a<0?"":e.slice(r,a)}if(t===e)return"";let s=-1,i=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else s<0&&(n=!0,s=o+1),i>-1&&(e.codePointAt(o)===t.codePointAt(i--)?i<0&&(a=o):(i=-1,a=s));r===a?a=s:a<0&&(a=e.length);return e.slice(r,a)},dirname:function(e){if(Iu(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){Iu(e);let t,n=e.length,r=-1,a=0,o=-1,s=0;for(;n--;){const i=e.codePointAt(n);if(47!==i)r<0&&(t=!0,r=n+1),46===i?o<0?o=n:1!==s&&(s=1):o>-1&&(s=-1);else if(t){a=n+1;break}}if(o<0||r<0||0===s||1===s&&o===r-1&&o===a+1)return"";return e.slice(o,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)Iu(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Iu(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,a="",o=0,s=-1,i=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(s===l-1||1===i);else if(s!==l-1&&2===i){if(a.length<2||2!==o||46!==a.codePointAt(a.length-1)||46!==a.codePointAt(a.length-2))if(a.length>2){if(r=a.lastIndexOf("/"),r!==a.length-1){r<0?(a="",o=0):(a=a.slice(0,r),o=a.length-1-a.lastIndexOf("/")),s=l,i=0;continue}}else if(a.length>0){a="",o=0,s=l,i=0;continue}t&&(a=a.length>0?a+"/..":"..",o=2)}else a.length>0?a+="/"+e.slice(s+1,l):a=e.slice(s+1,l),o=l-s-1;s=l,i=0}else 46===n&&i>-1?i++:i=-1}return a}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function Iu(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Au={cwd:function(){return"/"}};function Pu(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function Du(e){if("string"==typeof e)e=new URL(e);else if(!Pu(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const Ru=["history","path","basename","stem","extname","dirname"];class _u{constructor(e){let t;t=e?Pu(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":Au.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<Ru.length;){const e=Ru[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Ru.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?Eu.basename(this.path):void 0}set basename(e){Lu(e,"basename"),Ou(e,"basename"),this.path=Eu.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Eu.dirname(this.path):void 0}set dirname(e){Fu(this.basename,"dirname"),this.path=Eu.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?Eu.extname(this.path):void 0}set extname(e){if(Ou(e,"extname"),Fu(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Eu.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Pu(e)&&(e=Du(e)),Lu(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?Eu.basename(this.path,this.extname):void 0}set stem(e){Lu(e,"stem"),Ou(e,"stem"),this.path=Eu.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new Ti(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function Ou(e,t){if(e&&e.includes(Eu.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Eu.sep+"`")}function Lu(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Fu(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const zu=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},Mu={}.hasOwnProperty;class Bu extends zu{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Tu()}copy(){const e=new Bu;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(Su(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(qu("data",this.frozen),this.namespace[e]=t,this):Mu.call(this.namespace,e)&&this.namespace[e]||void 0:e?(qu("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=Qu(e),n=this.parser||this.Parser;return $u("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),$u("process",this.parser||this.Parser),Vu("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const o=Qu(e),s=n.parse(o);function i(e,n){e||!n?a(e):r?r(n):t(void 0,n)}n.run(s,o,function(e,t,r){if(e||!t||!r)return i(e);const a=t,o=n.stringify(a,r);!function(e){return"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)}(o)?r.result=o:r.value=o,i(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),$u("processSync",this.parser||this.Parser),Vu("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,wu(e),t=r}),Wu("processSync","process",n),t}run(e,t,n){Hu(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?a(void 0,n):new Promise(a);function a(a,o){const s=Qu(t);r.run(e,s,function(t,r,s){const i=r||e;t?o(t):a?a(i):n(void 0,i,s)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){wu(e),n=t,r=!0}),Wu("runSync","run",r),n}stringify(e,t){this.freeze();const n=Qu(t),r=this.compiler||this.Compiler;return Vu("stringify",r),Hu(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(qu("use",this.frozen),null==e);else if("function"==typeof e)i(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?s(e):o(e)}return this;function a(e){if("function"==typeof e)i(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;i(t,n)}else o(e)}}function o(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(e.plugins),e.settings&&(r.settings=Su(!0,r.settings,e.settings))}function s(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){a(e[t])}}}function i(e,t){let r=-1,a=-1;for(;++r<n.length;)if(n[r][0]===e){a=r;break}if(-1===a)n.push([e,...t]);else if(t.length>0){let[r,...o]=t;const s=n[a][1];Cu(s)&&Cu(r)&&(r=Su(!0,s,r)),n[a]=[e,r,...o]}}}}const Uu=(new Bu).freeze();function $u(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Vu(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function qu(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Hu(e){if(!Cu(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Wu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new _u(e)}const Xu=[],Ku={allowDangerousHtml:!0},Yu=/^(https?|ircs?|mailto|xmpp)$/i,Gu=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Ju(e){const t=function(e){const t=e.rehypePlugins||Xu,n=e.remarkPlugins||Xu,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ku}:Ku,a=Uu().use(Bc).use(n).use(vu,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new _u;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,s=t.skipHtml,i=t.unwrapDisallowed,l=t.urlTransform||Zu;for(const u of Gu)Object.hasOwn(t,u.from)&&ws((u.from,u.to&&u.to,u.id));return du(e,c),_i(e,{Fragment:fe.Fragment,components:a,ignoreInvalidStyle:!0,jsx:fe.jsx,jsxs:fe.jsxs,passKeys:!0,passNode:!0});function c(e,t,a){if("raw"===e.type&&a&&"number"==typeof t)return s?a.children.splice(t,1):a.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in qi)if(Object.hasOwn(qi,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=qi[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let s=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!s&&r&&"number"==typeof t&&(s=!r(e,t,a)),s&&a&&"number"==typeof t)return i&&e.children?a.children.splice(t,1,...e.children):a.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Zu(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return-1===t||-1!==a&&t>a||-1!==n&&t>n||-1!==r&&t>r||Yu.test(e.slice(0,t))?e:""}function ed(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;-1!==a;)r++,a=n.indexOf(t,a+t.length);return r}function td(e,t,n){const r=au((n||{}).ignore||[]),a=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const e=n[r];t.push([nd(e[0]),rd(e[1])])}return t}(t);let o=-1;for(;++o<a.length;)uu(e,"text",s);function s(e,t){let n,s=-1;for(;++s<t.length;){const e=t[s],a=n?n.children:void 0;if(r(e,a?a.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],r=a[o][0],s=a[o][1];let i=0;const l=n.children.indexOf(e);let c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){const n=d.index,a={index:d.index,input:d.input,stack:[...t,e]};let o=s(...d,a);if("string"==typeof o&&(o=o.length>0?{type:"text",value:o}:void 0),!1===o?r.lastIndex=n+1:(i!==n&&u.push({type:"text",value:e.value.slice(i,n)}),Array.isArray(o)?u.push(...o):o&&u.push(o),i=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}c?(i<e.value.length&&u.push({type:"text",value:e.value.slice(i)}),n.children.splice(l,1,...u)):u=[e];return l+u.length}(e,t)}}function nd(e){return"string"==typeof e?new RegExp(function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e}function rd(e){return"function"==typeof e?e:function(){return e}}const ad="phrasing",od=["autolink","link","image","label"];function sd(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function id(e){this.config.enter.autolinkProtocol.call(this,e)}function ld(e){this.config.exit.autolinkProtocol.call(this,e)}function cd(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function ud(e){this.config.exit.autolinkEmail.call(this,e)}function dd(e){this.exit(e)}function fd(e){td(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pd],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,md]],{ignore:["link","linkReference"]})}function pd(e,t,n,r,a){let o="";if(!hd(a))return!1;if(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!function(e){const t=e.split(".");if(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))return!1;return!0}(n))return!1;const s=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=ed(e,"(");let o=ed(e,")");for(;-1!==r&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}(n+r);if(!s[0])return!1;const i={type:"link",title:null,url:o+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[i,{type:"text",value:s[1]}]:i}function md(e,t,n,r){return!(!hd(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function hd(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||gl(n)||hl(n))&&(!t||47!==n)}function gd(){this.buffer()}function xd(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function bd(){this.buffer()}function yd(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function vd(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=al(this.sliceSerialize(e)).toLowerCase(),n.label=t}function wd(e){this.exit(e)}function kd(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=al(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Nd(e){this.exit(e)}function jd(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const s=n.enter("footnoteReference"),i=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),i(),s(),o+=a.move("]"),o}function Sd(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,r,a){const o=r.createTracker(a);let s=o.move("[^");const i=r.enter("footnoteDefinition"),l=r.enter("label");s+=o.move(r.safe(r.associationId(e),{before:s,after:"]"})),l(),s+=o.move("]:"),e.children&&e.children.length>0&&(o.shift(4),s+=o.move((t?"\n":" ")+r.indentLines(r.containerFlow(e,o.current()),t?Td:Cd)));return i(),s},footnoteReference:jd},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function Cd(e,t,n){return 0===t?e:Td(e,t,n)}function Td(e,t,n){return(n?"":" ")+e}jd.peek=function(){return"["};const Ed=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function Id(e){this.enter({type:"delete",children:[]},e)}function Ad(e){this.exit(e)}function Pd(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let s=a.move("~~");return s+=n.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),o(),s}function Dd(e){return e.length}function Rd(e){return null==e?"":String(e)}function _d(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function Od(e,t,n){return">"+(n?"":" ")+e}function Ld(e,t){return Fd(e,t.inConstruct,!0)&&!Fd(e,t.notInConstruct,!1)}function Fd(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function zd(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&Ld(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function Md(e,t,n){return(n?"":" ")+e}function Bd(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Ud(e){return"&#x"+e.toString(16).toUpperCase()+";"}function $d(e,t,n){const r=Nl(e),a=Nl(t);return void 0===r?void 0===a?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Vd(e,t,n,r){const a=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),o=n.enter("emphasis"),s=n.createTracker(r),i=s.move(a);let l=s.move(n.containerPhrasing(e,{after:a,before:i,...s.current()}));const c=l.charCodeAt(0),u=$d(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Ud(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=$d(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Ud(d));const p=s.move(a);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},i+l+p}function qd(e){return e.value||""}function Hd(e,t,n,r){const a=Bd(n),o='"'===a?"Quote":"Apostrophe",s=n.enter("image");let i=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),i(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(i=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(i=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),i(),e.title&&(i=n.enter(`title${o}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),i()),c+=l.move(")"),s(),c}function Wd(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let s=n.enter("label");const i=n.createTracker(r);let l=i.move("![");const c=n.safe(e.alt,{before:l,after:"]",...i.current()});l+=i.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...i.current()});return s(),n.stack=u,o(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=i.move("]"):l+=i.move(d+"]"),l}function Qd(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const e=n.unsafe[o],t=n.compilePattern(e);let a;if(e.atBreak)for(;a=t.exec(r);){let e=a.index;10===r.charCodeAt(e)&&13===r.charCodeAt(e-1)&&e--,r=r.slice(0,e)+" "+r.slice(a.index+1)}}return a+r+a}function Xd(e,t){const n=Wi(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function Kd(e,t,n,r){const a=Bd(n),o='"'===a?"Quote":"Apostrophe",s=n.createTracker(r);let i,l;if(Xd(e,n)){const t=n.stack;n.stack=[],i=n.enter("autolink");let r=s.move("<");return r+=s.move(n.containerPhrasing(e,{before:r,after:">",...s.current()})),r+=s.move(">"),i(),n.stack=t,r}i=n.enter("link"),l=n.enter("label");let c=s.move("[");return c+=s.move(n.containerPhrasing(e,{before:c,after:"](",...s.current()})),c+=s.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(n.safe(e.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(l=n.enter("destinationRaw"),c+=s.move(n.safe(e.url,{before:c,after:e.title?" ":")",...s.current()}))),l(),e.title&&(l=n.enter(`title${o}`),c+=s.move(" "+a),c+=s.move(n.safe(e.title,{before:c,after:a,...s.current()})),c+=s.move(a),l()),c+=s.move(")"),i(),c}function Yd(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let s=n.enter("label");const i=n.createTracker(r);let l=i.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...i.current()});l+=i.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...i.current()});return s(),n.stack=u,o(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=i.move("]"):l+=i.move(d+"]"),l}function Gd(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Jd(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}Pd.peek=function(){return"~"},Vd.peek=function(e,t,n){return n.options.emphasis||"*"},qd.peek=function(){return"<"},Hd.peek=function(){return"!"},Wd.peek=function(){return"!"},Qd.peek=function(){return"`"},Kd.peek=function(e,t,n){return Xd(e,n)?"<":"["},Yd.peek=function(){return"["};const Zd=au(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ef(e,t,n,r){const a=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),o=n.enter("strong"),s=n.createTracker(r),i=s.move(a+a);let l=s.move(n.containerPhrasing(e,{after:a,before:i,...s.current()}));const c=l.charCodeAt(0),u=$d(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Ud(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=$d(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Ud(d));const p=s.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},i+l+p}ef.peek=function(e,t,n){return n.options.strong||"*"};const tf={blockquote:function(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const s=n.indentLines(n.containerFlow(e,o.current()),Od);return a(),s},break:zd,code:function(e,t,n,r){const a=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),o=e.value||"",s="`"===a?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(o,Md);return e(),t}const i=n.createTracker(r),l=a.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,s=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===a?++o>s&&(s=o):o=1,a=r+t.length,r=n.indexOf(t,a);return s}(o,a)+1,3)),c=n.enter("codeFenced");let u=i.move(l);if(e.lang){const t=n.enter(`codeFencedLang${s}`);u+=i.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...i.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${s}`);u+=i.move(" "),u+=i.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...i.current()})),t()}return u+=i.move("\n"),o&&(u+=i.move(o+"\n")),u+=i.move(l),c(),u},definition:function(e,t,n,r){const a=Bd(n),o='"'===a?"Quote":"Apostrophe",s=n.enter("definition");let i=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),i(),!e.url||/[\0- \u007F]/.test(e.url)?(i=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(i=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),i(),e.title&&(i=n.enter(`title${o}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),i()),s(),c},emphasis:Vd,hardBreak:zd,heading:function(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(function(e,t){let n=!1;return du(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,cu}),Boolean((!e.depth||e.depth<3)&&Wi(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...o.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===a?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}const s="#".repeat(a),i=n.enter("headingAtx"),l=n.enter("phrasing");o.move(s+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...o.current()});return/^[\t ]/.test(c)&&(c=Ud(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),l(),i(),c},html:qd,image:Hd,imageReference:Wd,inlineCode:Qd,link:Kd,linkReference:Yd,list:function(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let s=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):Gd(n);const i=e.ordered?"."===s?")":".":function(e){const t=Gd(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&s===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),Jd(n)===s&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(s=i),n.bulletCurrent=s;const c=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=o,a(),c},listItem:function(e,t,n,r){const a=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let o=n.bulletCurrent||Gd(n);t&&"list"===t.type&&t.ordered&&(o=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+o);let s=o.length+1;("tab"===a||"mixed"===a&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));const i=n.createTracker(r);i.move(o+" ".repeat(s-o.length)),i.shift(s);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,i.current()),function(e,t,n){if(t)return(n?"":" ".repeat(s))+e;return(n?o:o+" ".repeat(s-o.length))+e});return l(),c},paragraph:function(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,r);return o(),a(),s},root:function(e,t,n,r){return(e.children.some(function(e){return Zd(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:ef,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Jd(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}};function nf(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function rf(e){this.exit(e),this.data.inTable=void 0}function af(e){this.enter({type:"tableRow",children:[]},e)}function of(e){this.exit(e)}function sf(e){this.enter({type:"tableCell",children:[]},e)}function lf(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,cf));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function cf(e,t){return"|"===t?t:e}function uf(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=tf.inlineCode(e,t,n);n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&"));return r},table:function(e,t,n,r){return i(function(e,t,n){const r=e.children;let a=-1;const o=[],s=t.enter("table");for(;++a<r.length;)o[a]=l(r[a],t,n);return s(),o}(e,n,r),e.align)},tableCell:s,tableRow:function(e,t,n,r){const a=l(e,n,r),o=i([a]);return o.slice(0,o.indexOf("\n"))}}};function s(e,t,n,r){const a=n.enter("tableCell"),s=n.enter("phrasing"),i=n.containerPhrasing(e,{...r,before:o,after:o});return s(),a(),i}function i(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||Dd,o=[],s=[],i=[],l=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let o=-1;for(e[u].length>c&&(c=e[u].length);++o<e[u].length;){const s=Rd(e[u][o]);if(!1!==n.alignDelimiters){const e=a(s);r[o]=e,(void 0===l[o]||e>l[o])&&(l[o]=e)}t.push(s)}s[u]=t,i[u]=r}let d=-1;if("object"==typeof r&&"length"in r)for(;++d<c;)o[d]=_d(r[d]);else{const e=_d(r);for(;++d<c;)o[d]=e}d=-1;const f=[],p=[];for(;++d<c;){const e=o[d];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let a=!1===n.alignDelimiters?1:Math.max(1,l[d]-t.length-r.length);const s=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[d]&&(l[d]=a),p[d]=a),f[d]=s}s.splice(1,0,f),i.splice(1,0,p),u=-1;const m=[];for(;++u<s.length;){const e=s[u],t=i[u];d=-1;const r=[];for(;++d<c;){const a=e[d]||"";let s="",i="";if(!1!==n.alignDelimiters){const e=l[d]-(t[d]||0),n=o[d];114===n?s=" ".repeat(e):99===n?e%2?(s=" ".repeat(e/2+.5),i=" ".repeat(e/2-.5)):(s=" ".repeat(e/2),i=s):i=" ".repeat(e)}!1===n.delimiterStart||d||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===a||!1===n.delimiterStart&&!d||r.push(" "),!1!==n.alignDelimiters&&r.push(s),r.push(a),!1!==n.alignDelimiters&&r.push(i),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&d===c-1||r.push("|")}m.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return m.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:a})}function l(e,t,n){const r=e.children;let a=-1;const o=[],i=t.enter("tableRow");for(;++a<r.length;)o[a]=s(r[a],0,t,n);return i(),o}}function df(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function ff(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let a,o=-1;for(;++o<r.length;){const e=r[o];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function pf(e,t,n,r){const a=e.children[0],o="boolean"==typeof e.checked&&a&&"paragraph"===a.type,s="["+(e.checked?"x":" ")+"] ",i=n.createTracker(r);o&&i.move(s);let l=tf.listItem(e,t,n,{...r,...i.current()});return o&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+s})),l}const mf={tokenize:function(e,t,n){let r=0;return function t(o){if((87===o||119===o)&&r<3)return r++,e.consume(o),t;if(46===o&&3===r)return e.consume(o),a;return n(o)};function a(e){return null===e?n(e):t(e)}},partial:!0},hf={tokenize:function(e,t,n){let r,a,o;return s;function s(t){return 46===t||95===t?e.check(xf,l,i)(t):null===t||pl(t)||gl(t)||45!==t&&hl(t)?l(t):(o=!0,e.consume(t),s)}function i(t){return 95===t?r=!0:(a=r,r=void 0),e.consume(t),s}function l(e){return a||r||!o?n(e):t(e)}},partial:!0},gf={tokenize:function(e,t){let n=0,r=0;return a;function a(s){return 40===s?(n++,e.consume(s),a):41===s&&r<n?o(s):33===s||34===s||38===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||60===s||63===s||93===s||95===s||126===s?e.check(xf,t,o)(s):null===s||pl(s)||gl(s)?t(s):(e.consume(s),a)}function o(t){return 41===t&&r++,e.consume(t),a}},partial:!0},xf={tokenize:function(e,t,n){return r;function r(s){return 33===s||34===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||63===s||95===s||126===s?(e.consume(s),r):38===s?(e.consume(s),o):93===s?(e.consume(s),a):60===s||null===s||pl(s)||gl(s)?t(s):n(s)}function a(e){return null===e||40===e||91===e||pl(e)||gl(e)?t(e):r(e)}function o(e){return ol(e)?s(e):n(e)}function s(t){return 59===t?(e.consume(t),r):ol(t)?(e.consume(t),s):n(t)}},partial:!0},bf={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return sl(e)?n(e):t(e)}},partial:!0},yf={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!jf.call(r,r.previous)||Ef(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mf,e.attempt(hf,e.attempt(gf,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:jf},vf={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",o=!1;return function(t){if((72===t||104===t)&&Sf.call(r,r.previous)&&!Ef(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),s;return n(t)};function s(t){if(ol(t)&&a.length<5)return a+=String.fromCodePoint(t),e.consume(t),s;if(58===t){const n=a.toLowerCase();if("http"===n||"https"===n)return e.consume(t),i}return n(t)}function i(t){return 47===t?(e.consume(t),o?l:(o=!0,i)):n(t)}function l(t){return null===t||ll(t)||pl(t)||gl(t)||hl(t)?n(t):e.attempt(hf,e.attempt(gf,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Sf},wf={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,o;return function(t){if(!Tf(t)||!Cf.call(r,r.previous)||Ef(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(t)};function s(t){return Tf(t)?(e.consume(t),s):64===t?(e.consume(t),i):n(t)}function i(t){return 46===t?e.check(bf,c,l)(t):45===t||95===t||sl(t)?(o=!0,e.consume(t),i):c(t)}function l(t){return e.consume(t),a=!0,i}function c(s){return o&&a&&ol(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(s)):n(s)}},previous:Cf},kf={};let Nf=48;for(;Nf<123;)kf[Nf]=wf,Nf++,58===Nf?Nf=65:91===Nf&&(Nf=97);function jf(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||pl(e)}function Sf(e){return!ol(e)}function Cf(e){return!(47===e||Tf(e))}function Tf(e){return 43===e||45===e||46===e||95===e||sl(e)}function Ef(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}kf[43]=wf,kf[45]=wf,kf[46]=wf,kf[95]=wf,kf[72]=[wf,vf],kf[104]=[wf,vf],kf[87]=[wf,yf],kf[119]=[wf,yf];const If={tokenize:function(e,t,n){const r=this;return yl(e,function(e){const a=r.events[r.events.length-1];return a&&"gfmFootnoteDefinitionIndent"===a[1].type&&4===a[2].sliceSerialize(a[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function Af(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;a--;){const e=r.events[a][1];if("labelImage"===e.type){s=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!s||!s._balanced)return n(a);const i=al(r.sliceSerialize({start:s.end,end:r.now()}));if(94!==i.codePointAt(0)||!o.includes(i.slice(1)))return n(a);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)}}function Pf(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},i=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...i),e}function Df(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,s=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),i};function i(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(i){if(s>999||93===i&&!o||null===i||91===i||pl(i))return n(i);if(93===i){e.exit("chunkString");const o=e.exit("gfmFootnoteCallString");return a.includes(al(r.sliceSerialize(o)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(i)}return pl(i)||(o=!0),s++,e.consume(i),92===i?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),s++,l):l(t)}}function Rf(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,s,i=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(i>999||93===t&&!s||null===t||91===t||pl(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return o=al(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return pl(t)||(s=!0),i++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),i++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(o)||a.push(o),yl(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function _f(e,t,n){return e.check(El,t,e.attempt(If,t,n))}function Of(e){e.exit("gfmFootnoteDefinition")}function Lf(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const a=this.previous,o=this.events;let s=0;return function(t){if(126===a&&"characterEscape"!==o[o.length-1][1].type)return r(t);return e.enter("strikethroughSequenceTemporary"),i(t)};function i(o){const l=Nl(a);if(126===o)return s>1?r(o):(e.consume(o),s++,i);if(s<2&&!t)return r(o);const c=e.exit("strikethroughSequenceTemporary"),u=Nl(o);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),n(o)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";const a={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},o={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},s=[["enter",a,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",o,t]],i=t.parser.constructs.insideSpan.null;i&&Gi(s,s.length,0,jl(i,e.slice(r+1,n),t)),Gi(s,s.length,0,[["exit",o,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),Gi(e,r-1,n-r+3,s),n=r+s.length-2;break}}n=-1;for(;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class Ff{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let a=0;if(0===n&&0===r.length)return;for(;a<e.map.length;){if(e.map[a][0]===t)return e.map[a][1]+=n,void e.map[a][2].push(...r);a+=1}e.map.push([t,n,r])}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(const t of r)e.push(t);r=n.pop()}this.map.length=0}}function zf(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if("enter"===a[0])"tableContent"===a[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===a[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===a[1].type)break}else"enter"===a[0]&&"tableDelimiterRow"===a[1].type&&(n=!0);t+=1}return r}function Mf(e,t,n){const r=this;let a,o=0,s=0;return function(e){let t=r.events.length-1;for(;t>-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const a=t>-1?r.events[t][1].type:null,o="tableHead"===a||"tableRow"===a?v:i;if(o===v&&r.parser.lazy[r.now().line])return n(e);return o(e)};function i(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return a=!0,s+=1,l(e)}(t)}function l(t){return null===t?n(t):fl(t)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):ml(t)?yl(e,l,"whitespace")(t):(s+=1,a&&(a=!1,o+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),a=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||pl(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),a=!1,ml(t)?yl(e,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):f(t))}function f(t){return 45===t||58===t?m(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),p):y(t)}function p(t){return ml(t)?yl(e,m,"whitespace")(t):m(t)}function m(t){return 58===t?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),h):45===t?(s+=1,h(t)):null===t||fl(t)?b(t):y(t)}function h(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):y(t)}function g(t){return 45===t?(e.consume(t),g):58===t?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(t))}function x(t){return ml(t)?yl(e,b,"whitespace")(t):b(t)}function b(n){return 124===n?f(n):(null===n||fl(n))&&a&&o===s?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):y(n)}function y(e){return n(e)}function v(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||fl(n)?(e.exit("tableRow"),t(n)):ml(n)?yl(e,w,"whitespace")(n):(e.enter("data"),k(n))}function k(t){return null===t||124===t||pl(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?N:k)}function N(t){return 92===t||124===t?(e.consume(t),k):k(t)}}function Bf(e,t){let n,r,a,o=-1,s=!0,i=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const f=new Ff;for(;++o<e.length;){const p=e[o],m=p[1];"enter"===p[0]?"tableHead"===m.type?(u=!1,0!==d&&($f(f,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(o,0,[["enter",n,t]])):"tableRow"===m.type||"tableDelimiterRow"===m.type?(s=!0,a=void 0,l=[0,0,0,0],c=[0,o+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(o,0,[["enter",r,t]])),i="tableDelimiterRow"===m.type?2:r?3:1):!i||"data"!==m.type&&"tableDelimiterMarker"!==m.type&&"tableDelimiterFiller"!==m.type?"tableCellDivider"===m.type&&(s?s=!1:(0!==l[1]&&(c[0]=c[1],a=Uf(f,t,l,i,void 0,a)),l=c,c=[l[1],o,0,0])):(s=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],a=Uf(f,t,l,i,void 0,a),l=[0,0,0,0]),c[2]=o)):"tableHead"===m.type?(u=!0,d=o):"tableRow"===m.type||"tableDelimiterRow"===m.type?(d=o,0!==l[1]?(c[0]=c[1],a=Uf(f,t,l,i,o,a)):0!==c[1]&&(a=Uf(f,t,c,i,o,a)),i=0):!i||"data"!==m.type&&"tableDelimiterMarker"!==m.type&&"tableDelimiterFiller"!==m.type||(c[3]=o)}for(0!==d&&$f(f,t,d,n,r),f.consume(t.events),o=-1;++o<t.events.length;){const e=t.events[o];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=zf(t.events,o))}return e}function Uf(e,t,n,r,a,o){const s=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(o.end=Object.assign({},Vf(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const i=Vf(t.events,n[1]);if(o={type:s,start:Object.assign({},i),end:Object.assign({},i)},e.add(n[1],0,[["enter",o,t]]),0!==n[2]){const a=Vf(t.events,n[2]),o=Vf(t.events,n[3]),s={type:"tableContent",start:Object.assign({},a),end:Object.assign({},o)};if(e.add(n[2],0,[["enter",s,t]]),2!==r){const r=t.events[n[2]],a=t.events[n[3]];if(r[1].end=Object.assign({},a[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",s,t]])}return void 0!==a&&(o.end=Object.assign({},Vf(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function $f(e,t,n,r,a){const o=[],s=Vf(t.events,n);a&&(a.end=Object.assign({},s),o.push(["exit",a,t])),r.end=Object.assign({},s),o.push(["exit",r,t]),e.add(n+1,0,o)}function Vf(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const qf={name:"tasklistCheck",tokenize:function(e,t,n){const r=this;return function(t){if(null!==r.previous||!r._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),a};function a(t){return pl(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),o):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),o):n(t)}function o(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(t)}function s(r){return fl(r)?t(r):ml(r)?e.check({tokenize:Hf},t,n)(r):n(r)}}};function Hf(e,t,n){return yl(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Wf={};function Qf(e){const t=e||Wf,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),o=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return el([{text:kf},{document:{91:{name:"gfmFootnoteDefinition",tokenize:Rf,continuation:{tokenize:_f},exit:Of}},text:{91:{name:"gfmFootnoteCall",tokenize:Df},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Af,resolveTo:Pf}}},Lf(e),{flow:{null:{name:"table",tokenize:Mf,resolveAll:Bf}}},{text:{91:qf}}])}(t)),a.push([{transforms:[fd],enter:{literalAutolink:sd,literalAutolinkEmail:id,literalAutolinkHttp:id,literalAutolinkWww:id},exit:{literalAutolink:dd,literalAutolinkEmail:ud,literalAutolinkHttp:ld,literalAutolinkWww:cd}},{enter:{gfmFootnoteCallString:gd,gfmFootnoteCall:xd,gfmFootnoteDefinitionLabelString:bd,gfmFootnoteDefinition:yd},exit:{gfmFootnoteCallString:vd,gfmFootnoteCall:wd,gfmFootnoteDefinitionLabelString:kd,gfmFootnoteDefinition:Nd}},{canContainEols:["delete"],enter:{strikethrough:Id},exit:{strikethrough:Ad}},{enter:{table:nf,tableData:sf,tableHeader:sf,tableRow:af},exit:{codeText:lf,table:rf,tableData:of,tableHeader:of,tableRow:of}},{exit:{taskListCheckValueChecked:df,taskListCheckValueUnchecked:df,paragraph:ff}}]),o.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ad,notInConstruct:od},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ad,notInConstruct:od},{character:":",before:"[ps]",after:"\\/",inConstruct:ad,notInConstruct:od}]},Sd(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Ed}],handlers:{delete:Pd}},uf(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:pf}}]}}(t))}function Xf({content:e,className:t}){return fe.jsx("div",{className:pe("prose prose-sm max-w-none",t),children:fe.jsx(Ju,{remarkPlugins:[Qf],components:{h1:({children:e})=>fe.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>fe.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>fe.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>fe.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>fe.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>fe.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>fe.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?fe.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):fe.jsx("code",{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...n,children:t}),pre:({children:e})=>fe.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>fe.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>fe.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>fe.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>fe.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return g.toast}}),exports.AUTH_CONFIG=Ht,exports.Accordion=Lr,exports.AccordionContent=Mr,exports.AccordionItem=Fr,exports.AccordionTrigger=zr,exports.ActionButton=Zo,exports.ActionMenuItems=tr,exports.Alert=Rr,exports.AlertDescription=Or,exports.AlertDialog=hn,exports.AlertDialogAction=jn,exports.AlertDialogCancel=Sn,exports.AlertDialogContent=yn,exports.AlertDialogDescription=Nn,exports.AlertDialogFooter=wn,exports.AlertDialogHeader=vn,exports.AlertDialogOverlay=bn,exports.AlertDialogPortal=xn,exports.AlertDialogTitle=kn,exports.AlertDialogTrigger=gn,exports.AlertTitle=_r,exports.AppHeader=is,exports.AppLayout=xs,exports.AppSidebar=gs,exports.AspectRatio=Br,exports.AuthErrorInterceptor=dn,exports.AuthProvider=({children:t})=>{const[n,r]=e.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null});let a=null;try{a=m.useQueryClient()}catch{}const[o,s]=e.useState(!1),[i,l]=e.useState(0),c=e.useCallback(e=>{r(t=>({...t,...e}))},[]),u=e.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),d=e.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null})},[]),f=e.useCallback(async e=>{try{u(!0);const t=It.getAccessToken();if(!t)return;const n=await an.generateToken(t,e.alias,void 0,!0);if(!n)return;It.setSupabaseToken(n),It.setSelectedAlias(e.alias);const r=It.extractTokenData(),o=r?.alias||e.alias,s={id:r?.companyId||It.getCompanyId(e.alias)||e.id,name:e.name,alias:o};c({alias:o,selectedUnit:s}),a&&(await a.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{u(!1)}},[c,a,u]),p=e.useCallback(async()=>await un.processCallback(),[]),h=e.useCallback(async()=>{un.logout(),d(),a&&await a.clear()},[d,a]),g=e.useCallback(e=>{s(e)},[]),x=e.useCallback(()=>{l(e=>e+1)},[]),b=e.useCallback(()=>{l(e=>e+1)},[]);e.useEffect(()=>{if(!n.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(It.areAllTokensValid()||e&&h())},6e5);return()=>{e=!1,clearInterval(t)}},[n.isAuthenticated,h]),e.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await un.initialize();if(!e)return;t&&t.isAuthenticated?c({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias}):e&&u(!1)}catch(t){e&&(dn.handleError(t),u(!1))}})(),()=>{e=!1}},[c,u,h]);const y=e.useMemo(()=>({...n,logout:h,processCallback:p,switchUnit:f,availableUnits:n.companies,isSearchVisible:o,setSearchVisible:g,clearSearch:x,refreshData:b}),[n.user,n.companies,n.alias,n.isAuthenticated,n.isLoading,n.selectedUnit,n.userId,n.userAlias,h,p,f,o,g,x,b]);return fe.jsx(fn.Provider,{value:y,children:t})},exports.AuthService=un,exports.Avatar=Ur,exports.AvatarFallback=Vr,exports.AvatarImage=$r,exports.Badge=et,exports.BaseForm=br,exports.Breadcrumb=qr,exports.BreadcrumbEllipsis=Yr,exports.BreadcrumbItem=Wr,exports.BreadcrumbLink=Qr,exports.BreadcrumbList=Hr,exports.BreadcrumbPage=Xr,exports.BreadcrumbSeparator=Kr,exports.BulkActionBar=wr,exports.Button=ge,exports.CRUD_CONFIG=Wt,exports.Calendar=ia,exports.CallbackPage=()=>{const{processCallback:t}=pn(),[n,r]=e.useState(null),[a,o]=e.useState(!1);e.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const s=async()=>{o(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{o(!1)}},i=()=>{window.location.href="/"};return n?fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsxs(ke,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[fe.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),fe.jsxs(je,{className:"space-y-4",children:[fe.jsx(Rr,{variant:"destructive",children:fe.jsx(Or,{children:n})}),fe.jsx("div",{className:"text-sm text-muted-foreground",children:fe.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),fe.jsxs("div",{className:"flex gap-2",children:[fe.jsx(ge,{onClick:s,disabled:a,className:"flex-1",children:a?fe.jsxs(fe.Fragment,{children:[fe.jsx(nt,{size:"sm",className:"mr-2"}),"Tentando..."]}):fe.jsxs(fe.Fragment,{children:[fe.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),fe.jsx(ge,{onClick:i,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsx(ke,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),fe.jsxs(je,{className:"text-center",children:[fe.jsx("div",{className:"flex justify-center mb-4",children:fe.jsx(nt,{size:"lg"})}),fe.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=ve,exports.CardContent=je,exports.CardDescription=Ne,exports.CardFooter=Se,exports.CardHeader=we,exports.CardSkeleton=Fn,exports.CardTitle=ke,exports.ChatbotPage=function(){const[t,n]=e.useState(!1),[r,a]=e.useState(""),{messages:o,isLoading:s,error:i,sendMessage:c}=ys(),u=e.useRef(null),d=e.useRef(null);e.useEffect(()=>{if(u.current){const e=u.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[o]),e.useEffect(()=>{t&&d.current&&d.current.focus()},[t]),e.useEffect(()=>{const e=e=>{"Escape"===e.key&&t&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);const f=()=>{r.trim()&&!s&&(c(r),a(""))};return fe.jsxs(fe.Fragment,{children:[fe.jsx(ge,{onClick:()=>n(!t),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:t?fe.jsx(l.X,{className:"h-6 w-6"}):fe.jsx(l.MessageCircle,{className:"h-6 w-6"})}),t&&fe.jsxs(ve,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[fe.jsxs(we,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[fe.jsx(ke,{className:"text-lg font-semibold",children:"Chat Assistant"}),fe.jsx(ge,{variant:"ghost",size:"icon",onClick:()=>n(!1),className:"h-8 w-8",children:fe.jsx(l.X,{className:"h-4 w-4"})})]}),fe.jsxs(je,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[fe.jsx(dr,{ref:u,className:"flex-1 px-4",children:fe.jsxs("div",{className:"space-y-4 py-4",children:[o.map(e=>fe.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:fe.jsx("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===e.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===e.role?fe.jsx(Xf,{content:e.content}):fe.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),s&&fe.jsx("div",{className:"flex justify-start",children:fe.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:fe.jsxs("div",{className:"flex space-x-2",children:[fe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),fe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),fe.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),i&&fe.jsx("div",{className:"text-center text-sm text-destructive py-2",children:i})]})}),fe.jsx("div",{className:"border-t p-4",children:fe.jsxs("div",{className:"flex space-x-2",children:[fe.jsx(xe,{ref:d,value:r,onChange:e=>a(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),f())},placeholder:"Digite sua mensagem...",disabled:s,className:"flex-1"}),fe.jsx(ge,{onClick:f,disabled:s||!r.trim(),size:"icon",children:fe.jsx(l.Send,{className:"h-4 w-4"})})]})})]})]})]})},exports.Checkbox=Ge,exports.Collapsible=la,exports.CollapsibleContent=ua,exports.CollapsibleTrigger=ca,exports.ColorPicker=ur,exports.Command=da,exports.CommandDialog=({children:e,...t})=>fe.jsx("div",{...t,children:fe.jsx(da,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})}),exports.CommandEmpty=ma,exports.CommandGroup=ha,exports.CommandInput=fa,exports.CommandItem=xa,exports.CommandList=pa,exports.CommandSeparator=ga,exports.CommandShortcut=ba,exports.CrudCards=function({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?fe.jsx(ka,{children:Array.from({length:3}).map((e,t)=>fe.jsxs(ve,{children:[fe.jsxs(we,{children:[fe.jsx(On,{className:"h-4 w-3/4"}),fe.jsx(On,{className:"h-3 w-1/2"})]}),fe.jsx(je,{children:fe.jsxs("div",{className:"space-y-2",children:[fe.jsx(On,{className:"h-3 w-full"}),fe.jsx(On,{className:"h-3 w-2/3"})]})})]},t))}):fe.jsx(ya.Root,{children:e.entities.map(e=>fe.jsxs(ya.Item,{onClick:()=>n(e),children:[fe.jsx(we,{className:"pb-3",children:fe.jsxs("div",{className:"flex items-start justify-between",children:[fe.jsxs("div",{className:"flex-1 min-w-0",children:[fe.jsx(ke,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),fe.jsx(Ne,{className:"text-sm",children:o.format(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:sa})})]}),fe.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&fe.jsx(ge,{variant:"external-link",size:"icon-xs",onClick:t=>{t.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),g.toast.info("Link copiado para a área de transferência"))}catch(t){window.location.href=e}})(e.link)},title:"Abrir link externo",children:fe.jsx(l.ExternalLink,{className:"h-4 w-4"})}),fe.jsx("div",{onClick:e=>e.stopPropagation(),children:fe.jsx(nr,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),fe.jsx(je,{className:"pt-0",children:fe.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?fe.jsx(ya.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})},exports.CrudForm=yr,exports.CrudPageInternal=Tr,exports.CrudTable=ar,exports.DataList=ya,exports.DeleteConfirmationDialog=Cn,exports.Dialog=Ce,exports.DialogClose=Ie,exports.DialogContent=Pe,exports.DialogDescription=Oe,exports.DialogFooter=Re,exports.DialogHeader=De,exports.DialogOverlay=Ae,exports.DialogPortal=Ee,exports.DialogTitle=_e,exports.DialogTrigger=Te,exports.DropdownMenu=Bn,exports.DropdownMenuCheckboxItem=Yn,exports.DropdownMenuContent=Xn,exports.DropdownMenuGroup=$n,exports.DropdownMenuItem=Kn,exports.DropdownMenuLabel=Jn,exports.DropdownMenuPortal=Vn,exports.DropdownMenuRadioGroup=Hn,exports.DropdownMenuRadioItem=Gn,exports.DropdownMenuSeparator=Zn,exports.DropdownMenuShortcut=er,exports.DropdownMenuSub=qn,exports.DropdownMenuSubContent=Qn,exports.DropdownMenuSubTrigger=Wn,exports.DropdownMenuTrigger=Un,exports.EmptyState=Mn,exports.EntitySelect=hr,exports.ErrorBoundary=bs,exports.FilterBar=Cr,exports.Form=Le,exports.FormControl=$e,exports.FormField=({...e})=>fe.jsx(Fe.Provider,{value:{name:e.name},children:fe.jsx(c.Controller,{...e})}),exports.FormItem=Be,exports.FormLabel=Ue,exports.FormMessage=Ve,exports.FormSkeleton=function({fields:e=4}){return fe.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>fe.jsxs("div",{className:"space-y-2",children:[fe.jsx(On,{className:"h-4 w-24"}),fe.jsx(On,{className:"h-10 w-full"})]},t)),fe.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[fe.jsx(On,{className:"h-10 w-20"}),fe.jsx(On,{className:"h-10 w-20"})]})]})},exports.Grid=ka,exports.HeaderSkeleton=function(){return fe.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[fe.jsxs("div",{className:"flex items-center space-x-3",children:[fe.jsx(On,{className:"h-8 w-8 rounded-full"}),fe.jsx(On,{className:"h-6 w-32"})]}),fe.jsxs("div",{className:"flex items-center space-x-2",children:[fe.jsx(On,{className:"h-8 w-8"}),fe.jsx(On,{className:"h-8 w-24"})]})]})},exports.IconPicker=mr,exports.Input=xe,exports.Label=ye,exports.LoadingState=function({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?fe.jsxs("div",{className:pe("relative",n),children:[t,fe.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:fe.jsx(nt,{size:a})})]}):"skeleton"===r?fe.jsx("div",{className:pe("animate-pulse",n),children:fe.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):fe.jsx("div",{className:pe("flex items-center justify-center py-8",n),children:fe.jsx(nt,{size:a})}):fe.jsx(fe.Fragment,{children:t})},exports.LoginPage=()=>fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsx(ke,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),fe.jsxs(je,{className:"text-center space-y-4",children:[fe.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),fe.jsx(ge,{onClick:async()=>{Xt()?await un.loginDev():un.loginProd()},className:"w-full",size:"lg",children:Xt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Gt,exports.MarkdownMessage=Xf,exports.NavigationProvider=rs,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,fe.jsx(qr,{className:n})},exports.Pagination=Na,exports.PaginationContent=ja,exports.PaginationEllipsis=Ia,exports.PaginationItem=Sa,exports.PaginationLink=Ca,exports.PaginationNext=Ea,exports.PaginationPrevious=Ta,exports.Popover=sr,exports.PopoverContent=lr,exports.PopoverTrigger=ir,exports.Progress=Aa,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:n,isLoading:r}=pn();if(e.useEffect(()=>{if(!n)return;const e=()=>{It.areAllTokensValid()||un.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),e.useEffect(()=>{if(r)return;if(n)return;if(It.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const o=Xt();(async()=>{o?await un.loginDev():un.loginProd()})()},[n,r]),r)return fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsx(ke,{className:"text-xl font-semibold",children:"Carregando..."})}),fe.jsxs(je,{className:"text-center",children:[fe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),fe.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){if(new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token"))return fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsx(ke,{className:"text-xl font-semibold",children:"Processando..."})}),fe.jsxs(je,{className:"text-center",children:[fe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),fe.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(It.areAllTokensValid())return fe.jsx(fe.Fragment,{children:t})}catch{}return fe.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:fe.jsxs(ve,{className:"w-full max-w-md",children:[fe.jsx(we,{className:"text-center",children:fe.jsx(ke,{className:"text-xl font-semibold",children:"Iniciando..."})}),fe.jsxs(je,{className:"text-center",children:[fe.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),fe.jsx("p",{className:"text-muted-foreground",children:Xt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return fe.jsx(fe.Fragment,{children:t})},exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=qt,exports.QualiexUserField=xr,exports.RadioGroup=Pa,exports.RadioGroupItem=Da,exports.SEARCH_CONFIG=Qt,exports.ScrollArea=dr,exports.ScrollBar=fr,exports.Select=qe,exports.SelectContent=Ke,exports.SelectItem=Ye,exports.SelectTrigger=We,exports.SelectValue=He,exports.Separator=Ra,exports.Sheet=_a,exports.SheetClose=La,exports.SheetContent=Ba,exports.SheetDescription=qa,exports.SheetFooter=$a,exports.SheetHeader=Ua,exports.SheetOverlay=za,exports.SheetPortal=Fa,exports.SheetTitle=Va,exports.SheetTrigger=Oa,exports.Sidebar=Za,exports.SidebarContent=io,exports.SidebarFooter=oo,exports.SidebarGroup=lo,exports.SidebarGroupAction=uo,exports.SidebarGroupContent=fo,exports.SidebarGroupLabel=co,exports.SidebarHeader=ao,exports.SidebarInput=ro,exports.SidebarInset=no,exports.SidebarMenu=po,exports.SidebarMenuAction=xo,exports.SidebarMenuBadge=bo,exports.SidebarMenuButton=go,exports.SidebarMenuItem=mo,exports.SidebarMenuSkeleton=yo,exports.SidebarMenuSub=vo,exports.SidebarMenuSubButton=ko,exports.SidebarMenuSubItem=wo,exports.SidebarProvider=Ja,exports.SidebarRail=to,exports.SidebarSeparator=so,exports.SidebarSkeleton=function(){return fe.jsx("div",{className:"w-64 border-r bg-muted/10",children:fe.jsxs("div",{className:"p-4",children:[fe.jsx(On,{className:"h-8 w-32 mb-6"}),fe.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>fe.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[fe.jsx(On,{className:"h-4 w-4"}),fe.jsx(On,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=eo,exports.Skeleton=On,exports.Slider=No,exports.SonnerToaster=({...e})=>{const{theme:t="system"}=P.useTheme();return fe.jsx(g.Toaster,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})},exports.Spinner=nt,exports.Stack=Sr,exports.Switch=Vo,exports.TabPageContent=function({children:e,className:t}){return fe.jsx("div",{className:pe("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:n,className:r}){return fe.jsxs("div",{className:pe("space-y-4",r),children:[fe.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[fe.jsxs("div",{className:"space-y-1",children:[fe.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&fe.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&fe.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),fe.jsx(Ra,{})]})},exports.TabPageLayout=function({children:e,className:t}){return fe.jsx("div",{className:pe("flex flex-col h-full",t),children:fe.jsx(dr,{className:"flex-1",children:fe.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Tn,exports.TableBody=In,exports.TableCaption=_n,exports.TableCell=Rn,exports.TableFooter=An,exports.TableHead=Dn,exports.TableHeader=En,exports.TableRow=Pn,exports.TableRowActions=nr,exports.TableSkeleton=Ln,exports.Tabs=qo,exports.TabsContent=Qo,exports.TabsList=Ho,exports.TabsTrigger=Wo,exports.Textarea=Je,exports.Toast=ht,exports.ToastAction=gt,exports.ToastClose=xt,exports.ToastDescription=yt,exports.ToastProvider=ft,exports.ToastTitle=bt,exports.ToastViewport=pt,exports.Toaster=function(){const{toasts:e}=dt();return fe.jsxs(ft,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return fe.jsxs(ht,{...a,children:[fe.jsxs("div",{className:"grid gap-1",children:[t&&fe.jsx(bt,{children:t}),n&&fe.jsx(yt,{children:n})]}),r,fe.jsx(xt,{})]},e)}),fe.jsx(pt,{})]})},exports.Toggle=Ko,exports.ToggleGroup=Go,exports.ToggleGroupItem=Jo,exports.TokenManager=It,exports.TokenService=wt,exports.Tooltip=Wa,exports.TooltipContent=Xa,exports.TooltipProvider=Ha,exports.TooltipTrigger=Qa,exports.assets=ds,exports.badgeVariants=Ze,exports.buttonVariants=he,exports.cn=pe,exports.createCrudPage=function(e){return()=>{const{manager:t,config:n,onSave:r,onToggleStatus:a}=e,o={entityName:n.entityName,entityNamePlural:n.entityNamePlural,filters:n.filters||[],columns:n.columns,cardFields:n.cardFields||[],enableBulkActions:!0};return fe.jsx(Tr,{manager:t,config:o,formSections:n.formSections,onSave:r,onToggleStatus:a})}},exports.createRoutingHandlers=es,exports.createService=en,exports.createSimpleSaveHandler=function(e,t,n){return r=>{if(r.id){const t=n(r);e.updateEntity(r.id,t)}else{const n=t(r);e.createEntity(n)}}},exports.createSimpleService=function(e){const t=en({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0});return{service:t,useCrudHook:(n,r)=>mn({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}},exports.crudPresets=Pr,exports.debounce=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},exports.errorService=Dt,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDatetime=e=>{if(!e)return"";const t=o.parseISO(e);if(!o.isValid(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`},exports.generateCrudConfig=Er,exports.getQualiexConfig=Yt,exports.getSupabaseClient=Mt,exports.isDevEnvironment=Xt,exports.logoSrc=fs,exports.qualiexApi=Vt,exports.setQualiexConfig=e=>{Kt={...Kt,...e}},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new m.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.smallLogoSrc=ps,exports.toast=ut,exports.toggleVariants=Xo,exports.trimTextFields=me,exports.useActiveModules=ls,exports.useAuth=pn,exports.useBaseForm=or,exports.useCrud=mn,exports.useCrudRouting=function(e){return es({basePath:e})},exports.useDebounce=ss,exports.useNavigation=as,exports.useOpenAIChat=ys,exports.usePageTitle=os,exports.usePermissionQuery=cs,exports.useQualiexUsers=gr,exports.useRouteBreadcrumbs=function(){const e=h.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),n=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,a)=>{r+=`/${e}`;const o=a===t.length-1,s=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");n.push({label:s,href:o?void 0:r,isCurrentPage:o})}),n})()},exports.useSidebar=Ga,exports.useToast=dt,exports.withPreset=function(e,t,n={}){const r=Pr[e];return Er(r.title,t,{...r,...n})};