forlogic-core 1.6.3 → 1.6.5
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/README.md +260 -1
- package/dist/README.md +260 -1
- package/dist/assets/index-CcfrwM_o.js +7935 -0
- package/dist/assets/index-D7GOryJi.css +1 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.html +19 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as e from"react";import
|
|
1
|
+
import*as e from"react";import t,{createContext as n,useContext as r,useState as a,useCallback as s,useEffect as i,useMemo as o,memo as l,useRef as c,useLayoutEffect as u,Component as d}from"react";import{Slot as f,createSlot as m}from"@radix-ui/react-slot";import{cva as p}from"class-variance-authority";import{clsx as h}from"clsx";import{twMerge as g}from"tailwind-merge";import{parseISO as x,isValid as y,format as b}from"date-fns";import*as v from"@radix-ui/react-label";import*as w from"@radix-ui/react-dialog";import{X as k,ChevronDown as N,ChevronUp as j,Check as S,Loader2 as C,AlertCircle as T,Search as I,FileX as E,ChevronRight as P,Circle as A,Edit as R,PowerOff as _,Power as D,Trash2 as O,EllipsisVertical as z,ArrowUpDown as L,ArrowUp as F,ArrowDown as M,Target as B,Trophy as U,Award as $,Sparkles as V,Flame as H,Zap as q,Key as W,Shield as Q,EyeOff as K,Eye as Y,Unlock as J,Lock as X,Archive as G,FolderOpen as Z,Folder as ee,FileText as te,Save as ne,Copy as re,Share as ae,Upload as se,Download as ie,HelpCircle as oe,Info as le,Bell as ce,Clock as ue,ArrowRight as de,ArrowLeft as fe,ChevronLeft as me,Minus as pe,Plus as he,Filter as ge,Bookmark as xe,Book as ye,Video as be,Music as ve,Image as we,Camera as ke,MapPin as Ne,Calendar as je,Phone as Se,Mail as Ce,Settings as Te,User as Ie,Home as Ee,Heart as Pe,Star as Ae,ChevronsLeft as Re,ChevronsRight as _e,RefreshCw as De,MoreHorizontal as Oe,PanelLeft as ze,ExternalLink as Le,Building2 as Fe,LogOut as Me,AlertTriangle as Be,MessageCircle as Ue,Send as $e}from"lucide-react";import{useFormContext as Ve,FormProvider as He,Controller as qe}from"react-hook-form";import*as We from"@radix-ui/react-select";import*as Qe from"@radix-ui/react-checkbox";import*as Ke from"@radix-ui/react-toast";import{createClient as Ye}from"@supabase/supabase-js";import{useQueryClient as Je,useQuery as Xe,useMutation as Ge,QueryClient as Ze}from"@tanstack/react-query";import{useSearchParams as et,useLocation as tt,useNavigate as nt,Link as rt}from"react-router-dom";import{toast as at,Toaster as st}from"sonner";export{toast as sonnerToast}from"sonner";import*as it from"@radix-ui/react-alert-dialog";import*as ot from"@radix-ui/react-dropdown-menu";import*as lt from"@radix-ui/react-popover";import*as ct from"@radix-ui/react-scroll-area";import*as ut from"@radix-ui/react-accordion";import*as dt from"@radix-ui/react-aspect-ratio";import*as ft from"@radix-ui/react-avatar";import{DayPicker as mt}from"react-day-picker";import*as pt from"@radix-ui/react-collapsible";import*as ht from"@radix-ui/react-progress";import*as gt from"@radix-ui/react-radio-group";import*as xt from"@radix-ui/react-separator";import*as yt from"@radix-ui/react-tooltip";import*as bt from"@radix-ui/react-slider";import{useTheme as vt}from"next-themes";import"react-dom";import*as wt from"@radix-ui/react-tabs";import*as kt from"@radix-ui/react-toggle";import*as Nt from"@radix-ui/react-toggle-group";function jt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var St,Ct={exports:{}},Tt={};var It,Et,Pt={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,4 +7,4 @@ import*as e from"react";import a,{createContext as t,useContext as s,useState as
|
|
|
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 Ea(){return Ra||(Ra=1,"production"!==process.env.NODE_ENV&&function(){var e=a,t=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),h=Symbol.iterator;var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var a=arguments.length,t=new Array(a>1?a-1:0),s=1;s<a;s++)t[s-1]=arguments[s];!function(e,a,t){var s=x.ReactDebugCurrentFrame,r=s.getStackAddendum();""!==r&&(a+="%s",t=t.concat([r]));var n=t.map(function(e){return String(e)});n.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,n)}("error",e,t)}var b;function y(e){return e.displayName||"Context"}function v(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 i:return"Profiler";case n:return"StrictMode";case d:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return y(e)+".Consumer";case o:return y(e._context)+".Provider";case c:return function(e,a,t){var s=e.displayName;if(s)return s;var r=a.displayName||a.name||"";return""!==r?t+"("+r+")":t}(e,e.render,"ForwardRef");case u:var a=e.displayName||null;return null!==a?a:v(e.type)||"Memo";case f:var t=e,p=t._payload,h=t._init;try{return v(h(p))}catch(x){return null}}return null}b=Symbol.for("react.module.reference");var N,j,w,k,S,C,T,R=Object.assign,_=0;function P(){}P.__reactDisabledLog=!0;var E,I=x.ReactCurrentDispatcher;function A(e,a,t){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,z=!1,O="function"==typeof WeakMap?WeakMap:Map;function $(e,a){if(!e||z)return"";var t,s=D.get(e);if(void 0!==s)return s;z=!0;var r,n=Error.prepareStackTrace;Error.prepareStackTrace=void 0,r=I.current,I.current=null,function(){if(0===_){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:P,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}_++}();try{if(a){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(p){t=p}Reflect.construct(e,[],i)}else{try{i.call()}catch(p){t=p}e.call(i.prototype)}}else{try{throw Error()}catch(p){t=p}e()}}catch(h){if(h&&t&&"string"==typeof h.stack){for(var o=h.stack.split("\n"),l=t.stack.split("\n"),c=o.length-1,d=l.length-1;c>=1&&d>=0&&o[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(o[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||o[c]!==l[d]){var m="\n"+o[c].replace(" at new "," at ");return e.displayName&&m.includes("<anonymous>")&&(m=m.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,m),m}}while(c>=1&&d>=0);break}}}finally{z=!1,I.current=r,function(){if(0===--_){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},e,{value:N}),info:R({},e,{value:j}),warn:R({},e,{value:w}),error:R({},e,{value:k}),group:R({},e,{value:S}),groupCollapsed:R({},e,{value:C}),groupEnd:R({},e,{value:T})})}_<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=n}var u=e?e.displayName||e.name:"",f=u?A(u):"";return"function"==typeof e&&D.set(e,f),f}function F(e,a,t){if(null==e)return"";if("function"==typeof e)return $(e,function(e){var a=e.prototype;return!(!a||!a.isReactComponent)}(e));if("string"==typeof e)return A(e);switch(e){case d:return A("Suspense");case m:return A("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return $(e.render,!1);case u:return F(e.type,a,t);case f:var s=e,r=s._payload,n=s._init;try{return F(n(r),a,t)}catch(i){}}return""}D=new O;var L=Object.prototype.hasOwnProperty,M={},U=x.ReactDebugCurrentFrame;function V(e){if(e){var a=e._owner,t=F(e.type,e._source,a?a.type:null);U.setExtraStackFrame(t)}else U.setExtraStackFrame(null)}var B=Array.isArray;function W(e){return B(e)}function q(e){return""+e}function H(e){if(function(e){try{return q(e),!1}catch(a){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)),q(e)}var Q,K,J=x.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function Y(e,a,s,r,n){var i,o={},l=null,c=null;for(i in void 0!==s&&(H(s),l=""+s),function(e){if(L.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return void 0!==e.key}(a)&&(H(a.key),l=""+a.key),function(e){if(L.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return void 0!==e.ref}(a)&&(c=a.ref,function(e){"string"==typeof e.ref&&J.current}(a)),a)L.call(a,i)&&!X.hasOwnProperty(i)&&(o[i]=a[i]);if(e&&e.defaultProps){var d=e.defaultProps;for(i in d)void 0===o[i]&&(o[i]=d[i])}if(l||c){var m="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,a){var t=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)",a))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(o,m),c&&function(e,a){var t=function(){K||(K=!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)",a))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(o,m)}return function(e,a,s,r,n,i,o){var l={$$typeof:t,type:e,key:a,ref:s,props:o,_owner:i,_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,J.current,o)}var G,Z=x.ReactCurrentOwner,ee=x.ReactDebugCurrentFrame;function ae(e){if(e){var a=e._owner,t=F(e.type,e._source,a?a.type:null);ee.setExtraStackFrame(t)}else ee.setExtraStackFrame(null)}function te(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function se(){if(Z.current){var e=v(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}G=!1;var re={};function ne(e,a){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var a=se();if(!a){var t="string"==typeof e?e:e.displayName||e.name;t&&(a="\n\nCheck the top-level render call using <"+t+">.")}return a}(a);if(!re[t]){re[t]=!0;var s="";e&&e._owner&&e._owner!==Z.current&&(s=" It was passed a child from "+v(e._owner.type)+"."),ae(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.',t,s),ae(null)}}}function ie(e,a){if("object"==typeof e)if(W(e))for(var t=0;t<e.length;t++){var s=e[t];te(s)&&ne(s,a)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var r=function(e){if(null===e||"object"!=typeof e)return null;var a=h&&e[h]||e["@@iterator"];return"function"==typeof a?a:null}(e);if("function"==typeof r&&r!==e.entries)for(var n,i=r.call(e);!(n=i.next()).done;)te(n.value)&&ne(n.value,a)}}function oe(e){var a,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)a=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==c&&t.$$typeof!==u)return;a=t.propTypes}if(a){var s=v(t);!function(e,a,t,s,r){var n=Function.call.bind(L);for(var i in e)if(n(e,i)){var o=void 0;try{if("function"!=typeof e[i]){var l=Error((s||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}o=e[i](a,i,s,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){o=c}!o||o instanceof Error||(V(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",t,i,typeof o),V(null)),o instanceof Error&&!(o.message in M)&&(M[o.message]=!0,V(r),g("Failed %s type: %s",t,o.message),V(null))}}(a,e.props,"prop",s,e)}else if(void 0!==t.PropTypes&&!G){G=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v(t)||"Unknown")}"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ce(e,a,s,h,x,y){var N=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===i||e===n||e===d||e===m||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===u||e.$$typeof===o||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":W(e)?w="array":void 0!==e&&e.$$typeof===t?(w="<"+(v(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=Y(e,a,s,x,y);if(null==k)return k;if(N){var S=a.children;if(void 0!==S)if(h)if(W(S)){for(var C=0;C<S.length;C++)ie(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 ie(S,e)}if(L.call(a,"key")){var T=v(e),R=Object.keys(a).filter(function(e){return"key"!==e}),_=R.length>0?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+_])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} />',_,T,R.length>0?"{"+R.join(": ..., ")+": ...}":"{}",T),le[T+_]=!0}return e===r?function(e){for(var a=Object.keys(e.props),t=0;t<a.length;t++){var s=a[t];if("children"!==s&&"key"!==s){ae(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),ae(null);break}}null!==e.ref&&(ae(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),ae(null))}(k):oe(k),k}var de=function(e,a,t){return ce(e,a,t,!1)},me=function(e,a,t){return ce(e,a,t,!0)};Pa.Fragment=r,Pa.jsx=de,Pa.jsxs=me}()),Pa}var Ia=(_a||(_a=1,"production"===process.env.NODE_ENV?Ca.exports=function(){if(Sa)return Ta;Sa=1;var e=a,t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(e,a,s){var o,l={},c=null,d=null;for(o in void 0!==s&&(c=""+s),void 0!==a.key&&(c=""+a.key),void 0!==a.ref&&(d=a.ref),a)r.call(a,o)&&!i.hasOwnProperty(o)&&(l[o]=a[o]);if(e&&e.defaultProps)for(o in a=e.defaultProps)void 0===l[o]&&(l[o]=a[o]);return{$$typeof:t,type:e,key:c,ref:d,props:l,_owner:n.current}}return Ta.Fragment=s,Ta.jsx=o,Ta.jsxs=o,Ta}():Ca.exports=Ea()),Ca.exports);function Aa(...e){return h(p(e))}const Da=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Da);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Da(s);return a}return e},za=e=>{if(!e)return"";const a=x(e);if(!g(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})} ${a.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`},Oa=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),$a=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},Fa=f("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"}}),La=e.forwardRef(({className:e,variant:a,size:t,asChild:s=!1,...r},n)=>{const i=s?m:"button";return Ia.jsx(i,{className:Aa(Fa({variant:a,size:t,className:e})),ref:n,...r})});La.displayName="Button";const Ma=e.forwardRef(({className:e,type:a,...t},s)=>Ia.jsx("input",{type:a,className:Aa("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,...t}));Ma.displayName="Input";const Ua=f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Va=e.forwardRef(({className:e,...a},t)=>Ia.jsx(y.Root,{ref:t,className:Aa(Ua(),e),...a}));Va.displayName=y.Root.displayName;const Ba=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));Ba.displayName="Card";const Wa=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("flex flex-col space-y-1.5 p-6",e),...a}));Wa.displayName="CardHeader";const qa=e.forwardRef(({className:e,...a},t)=>Ia.jsx("h3",{ref:t,className:Aa("text-2xl font-semibold leading-none tracking-tight",e),...a}));qa.displayName="CardTitle";const Ha=e.forwardRef(({className:e,...a},t)=>Ia.jsx("p",{ref:t,className:Aa("text-sm text-muted-foreground",e),...a}));Ha.displayName="CardDescription";const Qa=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("p-6 pt-0",e),...a}));Qa.displayName="CardContent";const Ka=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("flex items-center p-6 pt-0",e),...a}));Ka.displayName="CardFooter";const Ja=v.Root,Xa=v.Trigger,Ya=v.Portal,Ga=v.Close,Za=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Overlay,{ref:t,className:Aa("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),...a}));Za.displayName=v.Overlay.displayName;const et=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsxs(Ya,{children:[Ia.jsx(Za,{}),Ia.jsxs(v.Content,{ref:s,className:Aa("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),...t,children:[a,Ia.jsxs(v.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:[Ia.jsx(N,{className:"h-4 w-4"}),Ia.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));et.displayName=v.Content.displayName;const at=({className:e,...a})=>Ia.jsx("div",{className:Aa("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),...a});at.displayName="DialogHeader";const tt=({className:e,...a})=>Ia.jsx("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});tt.displayName="DialogFooter";const st=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Title,{ref:t,className:Aa("text-lg font-semibold leading-none tracking-tight",e),...a}));st.displayName=v.Title.displayName;const rt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Description,{ref:t,className:Aa("text-sm text-muted-foreground",e),...a}));rt.displayName=v.Description.displayName;const nt=Be,it=e.createContext({}),ot=({...e})=>Ia.jsx(it.Provider,{value:{name:e.name},children:Ia.jsx(We,{...e})}),lt=()=>{const a=e.useContext(it),t=e.useContext(ct),{getFieldState:s,formState:r}=Ve(),n=s(a.name,r);if(!a)throw new Error("useFormField should be used within <FormField>");const{id:i}=t;return{id:i,name:a.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},ct=e.createContext({}),dt=e.forwardRef(({className:a,...t},s)=>{const r=e.useId();return Ia.jsx(ct.Provider,{value:{id:r},children:Ia.jsx("div",{ref:s,className:Aa("space-y-2",a),...t})})});dt.displayName="FormItem";const mt=e.forwardRef(({className:e,...a},t)=>{const{error:s,formItemId:r}=lt();return Ia.jsx(Va,{ref:t,className:Aa(s&&"text-destructive",e),htmlFor:r,...a})});mt.displayName="FormLabel";const ut=e.forwardRef(({...e},a)=>{const{error:t,formItemId:s,formDescriptionId:r,formMessageId:n}=lt();return Ia.jsx(m,{ref:a,id:s,"aria-describedby":t?`${r} ${n}`:`${r}`,"aria-invalid":!!t,...e})});ut.displayName="FormControl";e.forwardRef(({className:e,...a},t)=>{const{formDescriptionId:s}=lt();return Ia.jsx("p",{ref:t,id:s,className:Aa("text-sm text-muted-foreground",e),...a})}).displayName="FormDescription";const ft=e.forwardRef(({className:e,children:a,...t},s)=>{const{error:r,formMessageId:n}=lt(),i=r?String(r?.message):a;return i?Ia.jsx("p",{ref:s,id:n,className:Aa("text-sm font-medium text-destructive",e),...t,children:i}):null});ft.displayName="FormMessage";const pt=qe.Root,ht=qe.Value,xt=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsxs(qe.Trigger,{ref:s,className:Aa("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),...t,children:[a,Ia.jsx(qe.Icon,{asChild:!0,children:Ia.jsx(j,{className:"h-4 w-4 opacity-50"})})]}));xt.displayName=qe.Trigger.displayName;const gt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(qe.ScrollUpButton,{ref:t,className:Aa("flex cursor-default items-center justify-center py-1",e),...a,children:Ia.jsx(w,{className:"h-4 w-4"})}));gt.displayName=qe.ScrollUpButton.displayName;const bt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(qe.ScrollDownButton,{ref:t,className:Aa("flex cursor-default items-center justify-center py-1",e),...a,children:Ia.jsx(j,{className:"h-4 w-4"})}));bt.displayName=qe.ScrollDownButton.displayName;const yt=e.forwardRef(({className:e,children:a,position:t="popper",...s},r)=>Ia.jsx(qe.Portal,{children:Ia.jsxs(qe.Content,{ref:r,className:Aa("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"===t&&"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:t,...s,children:[Ia.jsx(gt,{}),Ia.jsx(qe.Viewport,{className:Aa("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),Ia.jsx(bt,{})]})}));yt.displayName=qe.Content.displayName;e.forwardRef(({className:e,...a},t)=>Ia.jsx(qe.Label,{ref:t,className:Aa("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a})).displayName=qe.Label.displayName;const vt=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsxs(qe.Item,{ref:s,className:Aa("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),...t,children:[Ia.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ia.jsx(qe.ItemIndicator,{children:Ia.jsx(k,{className:"h-4 w-4"})})}),Ia.jsx(qe.ItemText,{children:a})]}));vt.displayName=qe.Item.displayName;e.forwardRef(({className:e,...a},t)=>Ia.jsx(qe.Separator,{ref:t,className:Aa("-mx-1 my-1 h-px bg-muted",e),...a})).displayName=qe.Separator.displayName;const Nt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(He.Root,{ref:t,className:Aa("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),...a,children:Ia.jsx(He.Indicator,{className:Aa("flex items-center justify-center text-current"),children:Ia.jsx(k,{className:"h-4 w-4"})})}));Nt.displayName=He.Root.displayName;const jt=e.forwardRef(({className:e,...a},t)=>Ia.jsx("textarea",{className:Aa("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:t,...a}));jt.displayName="Textarea";const wt=f("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"}}),kt=e.forwardRef(({className:e,variant:a,...t},s)=>Ia.jsx("div",{ref:s,className:Aa(wt({variant:a}),e),...t}));kt.displayName="Badge";const St={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ct({size:e="md",className:a}){return Ia.jsx(S,{className:Aa("animate-spin text-muted-foreground",St[e],a)})}function Tt({isLoading:e,children:a,className:t,type:s="spinner",size:r="md"}){return e?"overlay"===s?Ia.jsxs("div",{className:Aa("relative",t),children:[a,Ia.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Ia.jsx(Ct,{size:r})})]}):"skeleton"===s?Ia.jsx("div",{className:Aa("animate-pulse",t),children:Ia.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Ia.jsx("div",{className:Aa("flex items-center justify-center py-8",t),children:Ia.jsx(Ct,{size:r})}):Ia.jsx(Ia.Fragment,{children:a})}let Rt=0;const _t=new Map,Pt=e=>{if(_t.has(e))return;const a=setTimeout(()=>{_t.delete(e),Dt({type:"REMOVE_TOAST",toastId:e})},1e6);_t.set(e,a)},Et=(e,a)=>{switch(a.type){case"ADD_TOAST":return{...e,toasts:[a.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===a.toast.id?{...e,...a.toast}:e)};case"DISMISS_TOAST":{const{toastId:t}=a;return t?Pt(t):e.toasts.forEach(e=>{Pt(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===t||void 0===t?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===a.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==a.toastId)}}},It=[];let At={toasts:[]};function Dt(e){At=Et(At,e),It.forEach(e=>{e(At)})}function zt({...e}){const a=(Rt=(Rt+1)%Number.MAX_SAFE_INTEGER,Rt.toString()),t=()=>Dt({type:"DISMISS_TOAST",toastId:a});return Dt({type:"ADD_TOAST",toast:{...e,id:a,open:!0,onOpenChange:e=>{e||t()}}}),{id:a,dismiss:t,update:e=>Dt({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function Ot(){const[a,t]=e.useState(At);return e.useEffect(()=>(It.push(t),()=>{const e=It.indexOf(t);e>-1&&It.splice(e,1)}),[a]),{...a,toast:zt,dismiss:e=>Dt({type:"DISMISS_TOAST",toastId:e})}}const $t=Qe.Provider,Ft=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Qe.Viewport,{ref:t,className:Aa("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),...a}));Ft.displayName=Qe.Viewport.displayName;const Lt=f("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"}}),Mt=e.forwardRef(({className:e,variant:a,...t},s)=>Ia.jsx(Qe.Root,{ref:s,className:Aa(Lt({variant:a}),e),...t}));Mt.displayName=Qe.Root.displayName;const Ut=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Qe.Action,{ref:t,className:Aa("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),...a}));Ut.displayName=Qe.Action.displayName;const Vt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Qe.Close,{ref:t,className:Aa("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":"",...a,children:Ia.jsx(N,{className:"h-4 w-4"})}));Vt.displayName=Qe.Close.displayName;const Bt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Qe.Title,{ref:t,className:Aa("text-sm font-semibold",e),...a}));Bt.displayName=Qe.Title.displayName;const Wt=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Qe.Description,{ref:t,className:Aa("text-sm opacity-90",e),...a}));function qt(){const{toasts:e}=Ot();return Ia.jsxs($t,{children:[e.map(function({id:e,title:a,description:t,action:s,...r}){return Ia.jsxs(Mt,{...r,children:[Ia.jsxs("div",{className:"grid gap-1",children:[a&&Ia.jsx(Bt,{children:a}),t&&Ia.jsx(Wt,{children:t})]}),s,Ia.jsx(Vt,{})]},e)}),Ia.jsx(Ft,{})]})}Wt.displayName=Qe.Description.displayName;var Ht=Object.defineProperty;class Qt{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}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),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),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:t,errors:s}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";t.push(e),i=!1}if(r.exp&&r.exp<o){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?Ht(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(Qt,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Kt="qualiex_access_token",Jt="qualiex_id_token",Xt="supabase_token",Yt="oauth_state",Gt="oauth_nonce",Zt="selected_alias",es="manual_logout",as={setAccessToken:e=>localStorage.setItem(Kt,e),getAccessToken:()=>localStorage.getItem(Kt),setIdToken:e=>localStorage.setItem(Jt,e),getIdToken:()=>localStorage.getItem(Jt),getSupabaseToken:()=>localStorage.getItem(Xt),setOAuthState:e=>sessionStorage.setItem(Yt,e),getOAuthState:()=>sessionStorage.getItem(Yt),clearOAuthState:()=>sessionStorage.removeItem(Yt),setOAuthNonce:e=>sessionStorage.setItem(Gt,e),getOAuthNonce:()=>sessionStorage.getItem(Gt),clearOAuthNonce:()=>sessionStorage.removeItem(Gt),setSelectedAlias:e=>localStorage.setItem(Zt,e),getSelectedAlias:()=>localStorage.getItem(Zt),clearSelectedAlias:()=>localStorage.removeItem(Zt),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!as.getAccessToken()||!as.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Xt,e),as._clearValidationCache()},areAllTokensValid:()=>{const e=as.getAccessToken(),a=as.getIdToken();if(!e||!a)return!1;try{const t=Qt.validateTokens(e,a);return!!t.idTokenValid&&(t.accessTokenValid,t.idTokenValid)}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=as.getAccessToken(),t=as.getIdToken(),s=as.getSupabaseToken();return a&&as.isTokenExpired(a)&&(localStorage.removeItem(Kt),e=!0),t&&as.isTokenExpired(t)&&(localStorage.removeItem(Jt),e=!0),s&&as.isTokenExpired(s)&&(localStorage.removeItem(Xt),e=!0),e},clearAll:()=>{localStorage.removeItem(Kt),localStorage.removeItem(Jt),localStorage.removeItem(Xt),localStorage.removeItem(Zt),localStorage.removeItem(es),sessionStorage.removeItem(Yt),sessionStorage.removeItem(Gt)},setManualLogout:()=>localStorage.setItem(es,"true"),isManualLogout:()=>"true"===localStorage.getItem(es),clearManualLogout:()=>localStorage.removeItem(es),isTokenExpired:e=>{try{return Qt.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{as._validationCache.isValid=!1,as._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=as.getSupabaseToken();if(!e)return!1;if(as.isTokenExpired(e))return as._clearValidationCache(),as._handleExpiredToken(),!1;const a=Date.now();return a-as._validationCache.timestamp<as._validationCache.cacheValidityMs?as._validationCache.isValid:(as._validationCache.isValid=!0,as._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>as.isSupabaseTokenValid()?as.getSupabaseToken():null,_handleExpiredToken:()=>{as.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!as.isSupabaseTokenValid())return null;const e=as.getSupabaseToken();if(!e)return null;try{const a=Qt.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias;let s=a.company_id;if(!s&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=a[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===t){s=e[7];break}}}return{alias:t,companyId:s,payload:a}}catch(a){return as._handleExpiredToken(),null}},getCompanyId:e=>{const a=as.extractTokenData();if(!a)return null;if(!e)return a.companyId;const t=as.getIdToken();if(!t)return null;try{const a=Qt.parseJwtPayload(t);if(!a)return null;for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(a.length>7&&a[0]===e)return a[7]}}}catch{return null}return null},getCurrentCompanyId:()=>{const e=as.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=as.getIdToken();if(!e)return[];try{const a=Qt.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var ts=Object.defineProperty,ss=(e,a,t)=>((e,a,t)=>a in e?ts(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const rs=new class{constructor(){ss(this,"errors",[]),ss(this,"toastCount",0),ss(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()&&zt({title:"Erro",description:t,variant:"destructive"})}success(e,a){zt({title:e,description:a,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 ns=Object.defineProperty,is=(e,a,t)=>((e,a,t)=>a in e?ns(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const os=import.meta.env.VITE_SUPABASE_URL,ls=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,cs=class e{constructor(){is(this,"client"),is(this,"currentToken",null),is(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:ls};return e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`),Ke(os,ls,{auth:{persistSession:!1,autoRefreshToken:!1,storage:void 0},global:{headers:a}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=as.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return rs.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};is(cs,"instance");let ds=cs;const ms=()=>ds.getInstance().getClient();var us=Object.freeze({__proto__:null,getSupabaseClient:ms}),fs=Object.defineProperty,ps=(e,a,t)=>((e,a,t)=>a in e?fs(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const hs=new class{constructor(){ps(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=as.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const r=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{r.searchParams.append(e,a)});const n=await fetch(r.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return rs.handleError("[QualiexApi] Unexpected response format",!1),[];s=t}if(!Array.isArray(s))return rs.handleError("[QualiexApi] Response is not an array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){return rs.handleError(t instanceof Error?t:"[QualiexApi] Error fetching users"),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return rs.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const a=as.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):(rs.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}};class xs{static async extractTokenData(){const e=as.extractTokenData();return e||(rs.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,a){if(!e||0===e.length)return rs.handleError(`[QualiexEnrichment.${a.entityName}] Nenhuma entidade encontrada`,!1),e;try{const t=await this.extractTokenData();if(!t)return e.map(e=>({...e,responsible_name:e.id_user?"Token não encontrado":null}));const{alias:s,companyId:r}=t;if(!s||!r)return rs.handleError(`[QualiexEnrichment.${a.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 hs.getUsers(s),i=e.map(e=>{if(e.id_user){const a=n.find(a=>a.userId===e.id_user);return{...e,responsible_name:a?.userName||`ID não encontrado: ${e.id_user}`}}return{...e,responsible_name:null}});i.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 i}catch(t){return rs.handleError(t instanceof Error?t:`[QualiexEnrichment.${a.entityName}] 💥 ERRO CRÍTICO`),e.map(e=>({...e,responsible_name:e.id_user?`Erro: ${t.message}`:null}))}}}const gs={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},bs={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},ys={debounceDelay:500},vs=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},Ns={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]};let js={enableUserEnrichment:!1,enableUsersApi:!1};const ws=()=>js,ks=e=>{js={...js,...e}},Ss={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}`}},Cs=["responsible_name"],Ts=e=>Cs.includes(e);function Rs(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"central"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"central",...e},{tableName:r,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:c=!1}=s,d=()=>{if(!as.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return ms().schema(o).from(r)};return{async getAll(e={}){const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:o=1,limit:m=25,...u}=e;let f=d().select(i||"*",{count:"exact"});f=f.eq("is_removed",!1),Object.entries(u).forEach(([e,a])=>{null!=a&&""!==a&&(f=Array.isArray(a)?f.in(e,a):"object"==typeof a&&a&&"operator"in a&&"not_null"===a.operator?f.not(e,"is",null):f.eq(e,a))}),f=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(f,a);t.includes(".")||Ts(t)||(f=f.order(t,{ascending:"asc"===s})),f=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(f,o,m);const{data:p,error:h,count:x}=await f;if(h)throw new Error(`Error fetching ${r}: ${h.message}`);let g=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(p||[],x,o,m);const b=ws();if(c&&b.enableUserEnrichment&&l&&g.data.length>0){if(g.data.some(e=>e.id_user)){const a=t&&t.includes(".");if(t&&(Ts(t)||a)){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 i=await xs.enrichWithResponsibleNames(n.data,{entityName:l});let c;c=a?i.sort((e,a)=>{const r=t.split(".").reduce((e,a)=>e?.[a],e)||"",n=t.split(".").reduce((e,a)=>e?.[a],a)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===s?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(i,t,s);const d=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,o,m);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 xs.enrichWithResponsibleNames(g.data,{entityName:l});g={...g,data:r}}}return g},async getById(e){const{data:a,error:t}=await d().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Da(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await d().insert(t).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,a){const t={...Da(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await d().update(t).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 a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await d().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}}}const _s=()=>{as.clearManualLogout()},Ps=import.meta.env.VITE_SUPABASE_URL,Es=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;class Is{static async generateToken(e,a,t,s=!1){try{if(!s){const e=as.getSupabaseToken();if(e&&as.isSupabaseTokenValid())return e}const r=Ke(Ps,Es,{auth:{persistSession:!1,autoRefreshToken:!1}}),{data:n,error:i}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token&&n.access_token?(as.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}var As=Object.defineProperty,Ds=(e,a,t)=>((e,a,t)=>a in e?As(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class zs{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=as.getAccessToken(),a=as.getSelectedAlias();if(!e||!a)return null;const t=await Is.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(as.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}Ds(zs,"isRegenerating",!1),Ds(zs,"onLogoutCallback",null);const Os=class{static async initialize(){try{if(!as.hasAllTokens()||!as.areAllTokensValid())return as.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null};const e=as.getAccessToken(),a=as.getIdToken();_s();const t=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=as.extractTokenData(),i=n?.alias;let o=null;if(i&&s.some(e=>e.alias===i))o=i;else{const e=as.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);o=a?e:r||s[0]?.alias||null}!as.isSupabaseTokenValid()&&o&&await zs.attemptRegeneration();let l=null;if(o){const e=as.getCompanyId(o),a=s.find(e=>e.alias===o);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}return{isAuthenticated:!0,isLoading:!1,user:t,alias:o,companies:s,selectedUnit:l,userId:t?.id||null,userAlias:t?.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 us}),a=e(),{data:t,error:s}=await a.functions.invoke("dev-tokens",{body:{environment:"development"}});if(s)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=as.generateOAuthState();as.setOAuthState(e);const a=as.generateOAuthNonce();as.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(gs.oauth.authUrl);s.searchParams.set("client_id",gs.oauth.clientId),s.searchParams.set("response_type",gs.oauth.responseType),s.searchParams.set("scope",gs.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),vs(),window.location.href=s.toString()}static async processCallback(){try{if(as.hasAllTokens()){if(!as.getValidSupabaseToken()){as.getAccessToken();await zs.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");as.setAccessToken(s),as.setIdToken(r),_s();const i=this.extractAliasFromAccessToken(s);if(i)as.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");as.setSelectedAlias(e[0].alias)}if(!await zs.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return as.clearOAuthState(),as.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){as.setManualLogout(),as.clearAll(),window.location.href="/login"}static decodeToken(e){return Qt.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};zs.setLogoutCallback(()=>{Os.logout()});let $s=Os;class Fs{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(as.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}const Ls=t(void 0),Ms=({children:e})=>{const[a,t]=r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null});let s=null;try{s=Je()}catch{}const[l,c]=r(!1),[d,m]=r(0),u=n(e=>{t(a=>({...a,...e}))},[]),f=n(e=>{t(a=>({...a,isLoading:e}))},[]),p=n(()=>{t({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null})},[]),h=n(async e=>{try{f(!0);const a=as.getAccessToken();if(!a)return;const t=await Is.generateToken(a,e.alias,void 0,!0);if(!t)return;as.setSupabaseToken(t),as.setSelectedAlias(e.alias);const r=as.extractTokenData(),n=r?.alias||e.alias,i={id:r?.companyId||as.getCompanyId(e.alias)||e.id,name:e.name,alias:n};u({alias:n,selectedUnit:i}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{f(!1)}},[u,s,f]),x=n(async()=>await $s.processCallback(),[]),g=n(async()=>{$s.logout(),p(),s&&await s.clear()},[p,s]),b=n(e=>{c(e)},[]),y=n(()=>{m(e=>e+1)},[]),v=n(()=>{m(e=>e+1)},[]);i(()=>{if(!a.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(as.areAllTokensValid()||e&&g())},6e5);return()=>{e=!1,clearInterval(t)}},[a.isAuthenticated,g]),i(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await $s.initialize();if(!e)return;a&&a.isAuthenticated?u({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias}):e&&f(!1)}catch(a){e&&(Fs.handleError(a),f(!1))}})(),()=>{e=!1}},[u,f,g]);const N=o(()=>({...a,logout:g,processCallback:x,switchUnit:h,availableUnits:a.companies,isSearchVisible:l,setSearchVisible:b,clearSearch:y,refreshData:v}),[a.user,a.companies,a.alias,a.isAuthenticated,a.isLoading,a.selectedUnit,a.userId,a.userAlias,g,x,h,l,b,y,v]);return Ia.jsx(Ls.Provider,{value:N,children:e})},Us=()=>{const e=s(Ls);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Vs({queryKey:e,service:a,entityName:t,searchFields:s,additionalFilters:i={},onSuccess:l}){const[c,d]=Ze(),m=Je(),{alias:u,userId:f}=Us(),p=c.get("search")||"",h=c.get("sortField")||bs.sorting.defaultField,x=c.get("sortDirection")||bs.sorting.defaultDirection,g=parseInt(c.get("page")||"1"),b=parseInt(c.get("limit")||String(bs.pagination.defaultPageSize)),y=p,v=o(()=>({search:y,sortField:h,sortDirection:x,page:g,limit:b,...i}),[y,h,x,g,b,i]),N=n(()=>a.getAll(v),[a,v]),j=Xe({queryKey:[e,u,f,v],queryFn:N});if(!j)throw new Error(`useCrud: Query initialization failed for "${t}". Ensure QueryClientProvider is configured in your app root.`);const w=Ye({mutationFn:a.create,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),sa.success(Ss.success.created(t)),l?.()},onError:e=>{sa.error(`${Ss.error.create(t)}: ${e.message}`)}}),k=Ye({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),sa.success(Ss.success.updated(t)),l?.()},onError:e=>{sa.error(`${Ss.error.update(t)}: ${e.message}`)}}),S=Ye({mutationFn:a.delete,onSuccess:()=>{m.invalidateQueries({queryKey:[e]}),sa.success(Ss.success.deleted(t))},onError:e=>{sa.error(`${Ss.error.delete(t)}: ${e.message}`)}}),C=n(e=>{const a={...Object.fromEntries(c)};Object.entries(e).forEach(([e,t])=>{""===t||0===t?delete a[e]:a[e]=String(t)}),d(a)},[c,d]),T=n(e=>{C({search:e,page:1})},[C]),R=n(e=>{C({sortField:e,sortDirection:h===e&&"asc"===x?"desc":"asc",page:1})},[h,x,C]),_=n(e=>{C({page:e})},[C]),P=n(e=>{C({limit:e,page:1})},[C]),E=n(()=>{d({})},[d]),[I,A]=r([]),D=n(e=>{A(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),z=n(()=>{const e=j?.data?.data.map(e=>e.id)||[];A(a=>a.length===e.length?[]:e)},[j?.data?.data]),O=n(()=>{A([])},[]),$=o(()=>{const e=j?.data?.data.map(e=>e.id)||[];return e.length>0&&I.length===e.length},[I,j?.data?.data]),F=Ye({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,s)=>{m.invalidateQueries({queryKey:[e]}),sa.success(`${s.length} ${t}(s) deletado(s) com sucesso`),O()},onError:e=>{sa.error(`Erro ao deletar itens: ${e.message}`)}});return{entities:j?.data?.data||[],pagination:{currentPage:j?.data?.currentPage||1,totalPages:j?.data?.totalPages||1,totalItems:j?.data?.totalItems||0,itemsPerPage:j?.data?.itemsPerPage||bs.pagination.defaultPageSize,hasNextPage:j?.data?.hasNextPage||!1,hasPreviousPage:j?.data?.hasPreviousPage||!1},isLoading:j?.isLoading??!0,isCreating:w?.isPending??!1,isUpdating:k?.isPending??!1,isDeleting:S?.isPending??!1,error:j?.error||null,searchTerm:p,sortField:h,sortDirection:x,currentPage:g,itemsPerPage:b,createEntity:w.mutate,updateEntity:(e,a)=>k.mutate({id:e,data:a}),deleteEntity:S.mutate,handleSearch:T,handleSort:R,handlePageChange:_,handleItemsPerPageChange:P,clearFilters:E,refetch:j.refetch,selectedIds:I,selectItem:D,selectAll:z,clearSelection:O,isAllSelected:$,bulkDelete:F.mutate,isBulkDeleting:F.isPending}}function Bs(e){const a=Rs({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0});return{service:a,useCrudHook:(t,s)=>Vs({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}}const Ws=na.Root,qs=na.Trigger,Hs=na.Portal,Qs=e.forwardRef(({className:e,...a},t)=>Ia.jsx(na.Overlay,{className:Aa("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),...a,ref:t}));Qs.displayName=na.Overlay.displayName;const Ks=e.forwardRef(({className:e,...a},t)=>Ia.jsxs(Hs,{children:[Ia.jsx(Qs,{}),Ia.jsx(na.Content,{ref:t,className:Aa("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),...a})]}));Ks.displayName=na.Content.displayName;const Js=({className:e,...a})=>Ia.jsx("div",{className:Aa("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),...a});Js.displayName="AlertDialogHeader";const Xs=({className:e,...a})=>Ia.jsx("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Xs.displayName="AlertDialogFooter";const Ys=e.forwardRef(({className:e,...a},t)=>Ia.jsx(na.Title,{ref:t,className:Aa("text-lg font-semibold",e),...a}));Ys.displayName=na.Title.displayName;const Gs=e.forwardRef(({className:e,...a},t)=>Ia.jsx(na.Description,{ref:t,className:Aa("text-sm text-muted-foreground",e),...a}));Gs.displayName=na.Description.displayName;const Zs=e.forwardRef(({className:e,...a},t)=>Ia.jsx(na.Action,{ref:t,className:Aa(Fa(),e),...a}));Zs.displayName=na.Action.displayName;const er=e.forwardRef(({className:e,...a},t)=>Ia.jsx(na.Cancel,{ref:t,className:Aa(Fa({variant:"outline"}),"mt-2 sm:mt-0",e),...a}));er.displayName=na.Cancel.displayName;const ar=({open:e,onOpenChange:a,item:t,onConfirm:s,entityName:n="item",isDeleting:o=!1})=>{const[l,c]=r("");i(()=>{e||c("")},[e]);const d=()=>{c(""),a(!1)},m=l===t?.title;return t?Ia.jsx(Ws,{open:e,onOpenChange:d,children:Ia.jsxs(Ks,{className:"sm:max-w-[500px]",children:[Ia.jsx(Js,{children:Ia.jsxs("div",{className:"flex items-center space-x-2",children:[Ia.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Ia.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Ia.jsx("div",{className:"flex-1",children:Ia.jsx(Ys,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Ia.jsx(Gs,{asChild:!0,children:Ia.jsxs("div",{className:"space-y-4",children:[Ia.jsxs("div",{className:"text-sm text-muted-foreground",children:[Ia.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",n,":"]}),Ia.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Ia.jsx("p",{className:"font-medium text-foreground",children:t.title})})]}),Ia.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Ia.jsxs("div",{className:"flex items-start space-x-2",children:[Ia.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Ia.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Ia.jsxs("div",{className:"text-sm text-orange-800",children:[Ia.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Ia.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",n," será removido permanentemente do sistema."]})]})]})}),Ia.jsxs("div",{className:"space-y-2",children:[Ia.jsxs(Va,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",Ia.jsxs("strong",{children:['"',t.title,'"']})," abaixo:"]}),Ia.jsx(Ma,{id:"confirmation",type:"text",value:l,onChange:e=>c(e.target.value),placeholder:`Digite: ${t.title}`,className:"w-full"})]})]})}),Ia.jsxs(Xs,{children:[Ia.jsx(er,{onClick:d,children:"Cancelar"}),Ia.jsx(Zs,{onClick:()=>{t&&l===t.title&&(s(t),c(""),a(!1))},disabled:!m||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${n}`})]})]})}):null},tr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("table",{ref:t,className:Aa("w-full caption-bottom text-sm",e),...a}));tr.displayName="Table";const sr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("thead",{ref:t,className:Aa("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...a}));sr.displayName="TableHeader";const rr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("tbody",{ref:t,className:Aa("[&_tr:last-child]:border-0",e),...a}));rr.displayName="TableBody";const nr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("tfoot",{ref:t,className:Aa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a}));nr.displayName="TableFooter";const ir=e.forwardRef(({className:e,...a},t)=>Ia.jsx("tr",{ref:t,className:Aa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...a}));ir.displayName="TableRow";const or=e.forwardRef(({className:e,...a},t)=>Ia.jsx("th",{ref:t,className:Aa("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),...a}));or.displayName="TableHead";const lr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("td",{ref:t,className:Aa("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...a}));lr.displayName="TableCell";const cr=e.forwardRef(({className:e,...a},t)=>Ia.jsx("caption",{ref:t,className:Aa("mt-4 text-sm text-muted-foreground",e),...a}));function dr({className:e,...a}){return Ia.jsx("div",{className:Aa("animate-pulse rounded-md bg-muted",e),...a})}function mr({rows:e=5,columns:a=4}){return Ia.jsx("div",{className:"w-full",children:Ia.jsxs("div",{className:"rounded-md border",children:[Ia.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Ia.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>Ia.jsx(dr,{className:"h-4 w-24"},a))})}),Ia.jsx("div",{children:Array.from({length:e}).map((e,t)=>Ia.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Ia.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>Ia.jsx(dr,{className:"h-4 w-20"},a))})},t))})]})})}function ur({count:e=3}){return Ia.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,a)=>Ia.jsxs(Ba,{children:[Ia.jsxs(Wa,{children:[Ia.jsx(dr,{className:"h-4 w-3/4"}),Ia.jsx(dr,{className:"h-3 w-1/2"})]}),Ia.jsx(Qa,{children:Ia.jsxs("div",{className:"space-y-2",children:[Ia.jsx(dr,{className:"h-3 w-full"}),Ia.jsx(dr,{className:"h-3 w-2/3"})]})})]},a))})}function fr({fields:e=4}){return Ia.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,a)=>Ia.jsxs("div",{className:"space-y-2",children:[Ia.jsx(dr,{className:"h-4 w-24"}),Ia.jsx(dr,{className:"h-10 w-full"})]},a)),Ia.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ia.jsx(dr,{className:"h-10 w-20"}),Ia.jsx(dr,{className:"h-10 w-20"})]})]})}function pr(){return Ia.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Ia.jsxs("div",{className:"flex items-center space-x-3",children:[Ia.jsx(dr,{className:"h-8 w-8 rounded-full"}),Ia.jsx(dr,{className:"h-6 w-32"})]}),Ia.jsxs("div",{className:"flex items-center space-x-2",children:[Ia.jsx(dr,{className:"h-8 w-8"}),Ia.jsx(dr,{className:"h-8 w-24"})]})]})}function hr(){return Ia.jsx("div",{className:"w-64 border-r bg-muted/10",children:Ia.jsxs("div",{className:"p-4",children:[Ia.jsx(dr,{className:"h-8 w-32 mb-6"}),Ia.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,a)=>Ia.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Ia.jsx(dr,{className:"h-4 w-4"}),Ia.jsx(dr,{className:"h-4 w-20"})]},a))})]})})}cr.displayName="TableCaption";const xr={default:R,search:T,error:C};function gr({icon:e,title:a,description:t,action:s,className:r,variant:n="default"}){const i=e?()=>e:xr[n];return Ia.jsxs("div",{className:Aa("flex flex-col items-center justify-center py-12 px-4 text-center",r),children:[Ia.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Ia.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Ia.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),t&&Ia.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:t}),s&&Ia.jsx(La,{onClick:s.onClick,variant:"outline",children:s.label})]})}const br=ia.Root,yr=ia.Trigger,vr=ia.Group,Nr=ia.Portal,jr=ia.Sub,wr=ia.RadioGroup,kr=e.forwardRef(({className:e,inset:a,children:t,...s},r)=>Ia.jsxs(ia.SubTrigger,{ref:r,className:Aa("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",e),...s,children:[t,Ia.jsx(_,{className:"ml-auto h-4 w-4"})]}));kr.displayName=ia.SubTrigger.displayName;const Sr=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ia.SubContent,{ref:t,className:Aa("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),...a}));Sr.displayName=ia.SubContent.displayName;const Cr=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>Ia.jsx(ia.Portal,{children:Ia.jsx(ia.Content,{ref:s,sideOffset:a,className:Aa("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),...t})}));Cr.displayName=ia.Content.displayName;const Tr=e.forwardRef(({className:e,inset:a,...t},s)=>Ia.jsx(ia.Item,{ref:s,className:Aa("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",a&&"pl-8",e),...t}));Tr.displayName=ia.Item.displayName;const Rr=e.forwardRef(({className:e,children:a,checked:t,...s},r)=>Ia.jsxs(ia.CheckboxItem,{ref:r,className:Aa("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:t,...s,children:[Ia.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ia.jsx(ia.ItemIndicator,{children:Ia.jsx(k,{className:"h-4 w-4"})})}),a]}));Rr.displayName=ia.CheckboxItem.displayName;const _r=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsxs(ia.RadioItem,{ref:s,className:Aa("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),...t,children:[Ia.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ia.jsx(ia.ItemIndicator,{children:Ia.jsx(P,{className:"h-2 w-2 fill-current"})})}),a]}));_r.displayName=ia.RadioItem.displayName;const Pr=e.forwardRef(({className:e,inset:a,...t},s)=>Ia.jsx(ia.Label,{ref:s,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...t}));Pr.displayName=ia.Label.displayName;const Er=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ia.Separator,{ref:t,className:Aa("-mx-1 my-1 h-px bg-muted",e),...a}));Er.displayName=ia.Separator.displayName;const Ir=({className:e,...a})=>Ia.jsx("span",{className:Aa("ml-auto text-xs tracking-widest opacity-60",e),...a});Ir.displayName="DropdownMenuShortcut";const Ar=({onEdit:e,onDelete:a,onToggleStatus:t,isActive:s=!0,canDelete:r=!0,renderAs:n})=>{const i=[];if(e){const a={icon:E,label:"Editar",onClick:e};i.push(a)}if(t){const e={icon:s?I:A,label:s?"Inativar":"Ativar",onClick:t};i.push(e)}if(r&&a){const e={icon:D,label:"Remover",onClick:a,destructive:!0};i.push(e)}return"dropdown"===n?Ia.jsx(Ia.Fragment,{children:i.map((e,a)=>Ia.jsxs(Tr,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Ia.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},a))}):Ia.jsx(Ia.Fragment,{children:i.map((e,a)=>Ia.jsxs(La,{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:[Ia.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},a))})},Dr=({onEdit:e,onDelete:a,canDelete:t=!0,onToggleStatus:s,isActive:r=!0})=>Ia.jsxs(br,{children:[Ia.jsx(yr,{asChild:!0,children:Ia.jsx(La,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Ia.jsx(z,{size:12})})}),Ia.jsx(Cr,{align:"end",children:Ia.jsx(Ar,{onEdit:a=>{a?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),a?.()},onToggleStatus:e=>{e?.stopPropagation(),s?.()},isActive:r,canDelete:t,renderAs:"dropdown"})})]}),zr=({manager:e,columns:a,onEdit:t,onView:s,onToggleStatus:n,onDelete:o,renderActions:l,enableBulkActions:c=!1})=>{const[d,m]=r(!1),[u,f]=r(null);i(()=>{const e=()=>m(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i(()=>{const e=()=>f(null);if(u)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[u]);const p=(()=>{a.length;let e=0;const t=a.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,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?e.isLoading?Ia.jsx(ur,{count:3}):0===e.entities.length?Ia.jsx(gr,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Ia.jsxs("div",{className:"space-y-4",children:[e.entities.map(r=>Ia.jsx(Ba,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(r.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||t?.(r)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),f({x:e.clientX,y:e.clientY,item:r})},children:Ia.jsx(Qa,{className:"p-4",children:Ia.jsxs("div",{className:"flex items-start gap-3",children:[c&&Ia.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Ia.jsx(Nt,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>e.selectItem(r.id)})}),Ia.jsxs("div",{className:"flex-1",children:[a.map(e=>Ia.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Ia.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Ia.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(r):r[e.key]})]},String(e.key))),(t||s||l)&&Ia.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(r):Ia.jsx(Dr,{onEdit:t?()=>{t(r)}:void 0,onDelete:o?()=>o(r):void 0,onToggleStatus:n?()=>n(r):void 0,isActive:r.is_actived})})]})]})})},r.id)),u&&Ia.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:u.x,top:u.y},onClick:e=>e.stopPropagation(),children:Ia.jsx(Ar,{onEdit:t?()=>{t(u.item),f(null)}:void 0,onDelete:o?()=>{o(u.item),f(null)}:void 0,onToggleStatus:n?()=>{n(u.item),f(null)}:void 0,isActive:u.item.is_actived,canDelete:!!o,renderAs:"context"})})]}):Ia.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Ia.jsx(mr,{rows:5,columns:a.length}):Ia.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Ia.jsx("div",{className:"flex-1 overflow-auto",children:Ia.jsxs(tr,{className:"table-auto",children:[Ia.jsxs("colgroup",{children:[c&&Ia.jsx("col",{style:{width:"50px"}}),p.map((e,a)=>Ia.jsx("col",{style:e.style},a)),Ia.jsx("col",{style:{width:"100px"}})]}),Ia.jsx(sr,{children:Ia.jsxs(ir,{children:[c&&Ia.jsx(or,{className:"w-[50px]",children:Ia.jsx(Nt,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),a.map(a=>{return Ia.jsx(or,{className:`${a.className||""} ${a.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:a.sortable?()=>e.handleSort(String(a.key)):void 0,children:Ia.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(t=String(a.key),e.sortField!==t?Ia.jsx(O,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Ia.jsx($,{size:14,className:"ml-1"}):Ia.jsx(F,{size:14,className:"ml-1"}))]})},String(a.key));var t}),Ia.jsx(or,{className:"w-[100px] text-center",children:"Ações"})]})}),Ia.jsx(rr,{children:0===e.entities.length?Ia.jsx(ir,{children:Ia.jsx(lr,{colSpan:a.length+1,className:"h-32",children:Ia.jsx(gr,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(s=>Ia.jsxs(ir,{className:Aa("cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(s.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||t?.(s)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),f({x:e.clientX,y:e.clientY,item:s})},children:[c&&Ia.jsx(lr,{onClick:e=>e.stopPropagation(),children:Ia.jsx(Nt,{checked:e.selectedIds.includes(s.id),onCheckedChange:()=>e.selectItem(s.id)})}),a.map(e=>Ia.jsx(lr,{className:e.className,children:e.render?e.render(s):s[e.key]},String(e.key))),Ia.jsx(lr,{className:"text-center",children:l?l(s):Ia.jsx(Dr,{onEdit:t?()=>t(s):void 0,onDelete:o?()=>o(s):void 0,onToggleStatus:n?()=>n(s):void 0,isActive:s.is_actived})})]},s.id))})]})})}),u&&Ia.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:u.x,top:u.y},onClick:e=>e.stopPropagation(),children:Ia.jsx(Ar,{onEdit:t?()=>{t(u.item),f(null)}:void 0,onDelete:o?()=>{o(u.item),f(null)}:void 0,onToggleStatus:n?()=>{n(u.item),f(null)}:void 0,isActive:u.item.is_actived,canDelete:!!o,renderAs:"context"})})]})};function Or(e,a,t,s){const[n,l]=r({}),[c,d]=r({}),m=o(()=>e,[e]),u=e=>e instanceof Date&&!isNaN(e.getTime()),f=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{}}},p=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return f(e)}},h=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.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(a,t);if(e)return e}catch(s){}}};i(()=>{if(!s)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},r=e(m),n={};r.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);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=f(e);n[e.name]=t}),r.forEach(e=>{const a=p(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{r.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),l(n),d({}),t&&t(n)},[m,a,t,s]);const x=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...x(e.fields))}),a},g=()=>{const e=x(m),a={};return e.forEach(e=>{const t=h(e,n[e.name],n);t&&(a[e.name]=t)}),d(a),0===Object.keys(a).length};return{formData:n,errors:c,updateField:(e,a)=>{l(s=>{const r={...s,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(m).filter(a=>a.dependsOn===e).forEach(e=>{const a=p(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return t&&t(n),n}),c[e]&&d(a=>{const t={...a};return delete t[e],t});const s=x(m).find(a=>a.name===e);if(s){const t=h(s,a,n);t&&d(a=>({...a,[e]:t}))}},validateForm:g,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),g()&&e(n)}}}const $r=oa.Root,Fr=oa.Trigger,Lr=e.forwardRef(({className:e,align:a="center",sideOffset:t=4,...s},r)=>Ia.jsx(oa.Portal,{children:Ia.jsx(oa.Content,{ref:r,align:a,sideOffset:t,className:Aa("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})}));Lr.displayName=oa.Content.displayName;const Mr=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ur=({value:e="#3b82f6",onChange:a,label:t})=>Ia.jsxs("div",{className:"space-y-2",children:[t&&Ia.jsx(Va,{children:t}),Ia.jsxs($r,{children:[Ia.jsx(Fr,{asChild:!0,children:Ia.jsxs(La,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ia.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Ia.jsx(Lr,{className:"w-64",children:Ia.jsxs("div",{className:"space-y-3",children:[Ia.jsxs("div",{children:[Ia.jsx(Va,{htmlFor:"color-input",children:"Cor personalizada"}),Ia.jsx(Ma,{id:"color-input",type:"color",value:e,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),Ia.jsxs("div",{children:[Ia.jsx(Va,{children:"Cores predefinidas"}),Ia.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Mr.map(e=>Ia.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>a?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]}),Vr=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsxs(la.Root,{ref:s,className:Aa("relative overflow-hidden",e),...t,children:[Ia.jsx(la.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),Ia.jsx(Br,{}),Ia.jsx(la.Corner,{})]}));Vr.displayName=la.Root.displayName;const Br=e.forwardRef(({className:e,orientation:a="vertical",...t},s)=>Ia.jsx(la.ScrollAreaScrollbar,{ref:s,orientation:a,className:Aa("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...t,children:Ia.jsx(la.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Br.displayName=la.ScrollAreaScrollbar.displayName;const Wr={Star:Pe,Heart:_e,Home:Re,User:Te,Settings:Ce,Mail:Se,Phone:ke,Calendar:we,MapPin:je,Camera:Ne,Image:ve,Music:ye,Video:be,Book:ge,Bookmark:xe,Search:T,Filter:he,Edit:E,Trash2:D,Plus:pe,Minus:fe,Check:k,X:N,ChevronDown:j,ChevronUp:w,ChevronLeft:ue,ChevronRight:_,ArrowUp:$,ArrowDown:F,ArrowLeft:me,ArrowRight:de,Clock:ce,Bell:le,AlertCircle:C,Info:oe,HelpCircle:ie,Download:ne,Upload:re,Share:se,Copy:te,Save:ae,FileText:ee,Folder:Z,FolderOpen:G,Archive:Y,Lock:X,Unlock:J,Eye:K,EyeOff:Q,Shield:H,Key:q,Zap:W,Flame:B,Sparkles:V,Award:U,Trophy:M,Target:L},qr=({value:e="Star",onChange:a,label:t})=>{const[s,n]=r(""),i=Object.entries(Wr).filter(([e])=>e.toLowerCase().includes(s.toLowerCase())),o=Wr[e]||Pe;return Ia.jsxs("div",{className:"space-y-2",children:[t&&Ia.jsx(Va,{children:t}),Ia.jsxs($r,{children:[Ia.jsx(Fr,{asChild:!0,children:Ia.jsxs(La,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ia.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Ia.jsx(Lr,{className:"w-80",children:Ia.jsxs("div",{className:"space-y-3",children:[Ia.jsxs("div",{children:[Ia.jsx(Va,{htmlFor:"icon-search",children:"Buscar ícone"}),Ia.jsx(Ma,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:s,onChange:e=>n(e.target.value)})]}),Ia.jsx(Vr,{className:"h-48",children:Ia.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([t,s])=>Ia.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(e===t?"border-primary bg-primary/10":"border-border"),onClick:()=>a?.(t),title:t,children:Ia.jsx(s,{className:"h-4 w-4"})},t))})})]})})]})]})};function Hr({value:e,onChange:a,items:t,isLoading:s=!1,error:n=null,getItemValue:i,getItemLabel:l,searchPlaceholder:c="Buscar...",emptyMessage:d="Nenhum item disponível",noResultsMessage:m="Nenhum resultado encontrado",sortItems:u,placeholder:f="Selecionar...",disabled:p=!1,className:h}){const[x,g]=r(""),b=o(()=>{const e=u?[...t].sort(u):[...t].sort((e,a)=>l(e).localeCompare(l(a),"pt-BR"));if(!x.trim())return e;const a=x.toLowerCase();return e.filter(e=>l(e).toLowerCase().includes(a))},[t,x,u,l]);return s?Ia.jsx(dr,{className:Aa("h-10 w-full",h)}):n?Ia.jsxs("div",{className:Aa("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Ia.jsx(C,{className:"h-4 w-4 text-destructive"}),Ia.jsx("span",{className:"text-sm text-destructive",children:n.message||"Erro ao carregar dados"})]}):Ia.jsxs(pt,{value:e,onValueChange:a,disabled:p||0===t.length,children:[Ia.jsx(xt,{className:h,children:Ia.jsx(ht,{placeholder:f})}),Ia.jsxs(yt,{children:[Ia.jsx("div",{className:"px-2 pb-2",children:Ia.jsxs("div",{className:"relative",children:[Ia.jsx(T,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Ia.jsx(Ma,{placeholder:c,value:x,onChange:e=>g(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===b.length?Ia.jsx(vt,{value:"no-items",disabled:!0,children:x?m:d}):b.map(e=>Ia.jsx(vt,{value:i(e),children:l(e)},i(e)))]})]})}const Qr=(e={})=>{const{user:a,alias:t}=Us(),s=ws(),{enabled:r=s.enableUsersApi}=e;return Xe({queryKey:["qualiex-users",t],queryFn:()=>hs.getUsers(t),enabled:r&&!!t&&!!a,retry:2,retryDelay:1e3})},Kr=({value:e="",onChange:a,placeholder:t="Selecionar usuário",disabled:s,className:r,enabled:n})=>{const{data:i=[],isLoading:o,error:l}=Qr({enabled:n});return Ia.jsx(Hr,{value:e,onChange:a,items:i,isLoading:o,error:l,getItemValue:e=>e.userId,getItemLabel:e=>e.userName,placeholder:t,searchPlaceholder:"Buscar usuário...",emptyMessage:"Nenhum usuário disponível",noResultsMessage:"Nenhum usuário encontrado",disabled:s,className:r})};function Jr({title:e,sections:t,initialData:s,onSubmit:i,onCancel:l,open:c,submitButtonText:d="Salvar",isLoading:m=!1,usersData:u}){const[f,p]=r(t?.[0]?.id||""),h=o(()=>t&&Array.isArray(t)?t.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[t]),{formData:x,errors:g,updateField:b,handleSubmit:y}=Or(h,s,void 0,c),v=o(()=>t&&Array.isArray(t)?t.map(e=>({...e,disabled:e.condition?!e.condition(x):e.disabled||!1})):[],[t,x]),N=o(()=>{const e=v.find(e=>e.id===f);if(e&&!e.disabled)return f;const a=v.find(e=>!e.disabled);return a?.id||f},[v,f]);a.useEffect(()=>{N!==f&&p(N)},[N,f]);const j=v.find(e=>e.id===N),w=e=>{const a=(e.computedValue,x[e.name]),t=void 0!==a?a:"",s=g[e.name];switch(e.type){case"group":return Ia.jsxs("div",{className:"space-y-2",children:[e.label,Ia.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>w(e))})]},e.name);case"user-select":return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Kr,{value:t||"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"textarea":return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(jt,{id:e.name,value:t||"",onChange:a=>{b(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"select":return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsxs(pt,{value:String(t),onValueChange:a=>{b(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[Ia.jsx(xt,{className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Ia.jsx(ht,{placeholder:e.placeholder})}),Ia.jsx(yt,{children:e.options?.map(e=>Ia.jsx(vt,{value:e.value,children:e.label},e.value))})]}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"date":return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Ma,{id:e.name,type:"date",value:String(t),onChange:a=>b(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Aa("w-full",s?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"single-responsible-select":const a=ws();return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Kr,{value:String(t),onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":"",enabled:a.enableUsersApi}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"simple-qualiex-user-field":const r=ws();return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Kr,{value:t??"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":"",enabled:r.enableUsersApi}),s&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"color":return Ia.jsxs("div",{children:[Ia.jsxs(Va,{htmlFor:e.name,children:[e.label," ",e.required&&Ia.jsx("span",{className:"text-destructive",children:"*"})]}),Ia.jsx(Ma,{id:e.name,type:"color",value:t||e.defaultValue||"#000000",onChange:a=>b(e.name,a.target.value),className:"h-10"}),s&&Ia.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return Ia.jsxs("div",{children:[Ia.jsx(Ur,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"#3b82f6",onChange:a=>b(e.name,a)}),s&&Ia.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return Ia.jsxs("div",{children:[Ia.jsx(qr,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"Star",onChange:a=>b(e.name,a)}),s&&Ia.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"number":return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Ma,{id:e.name,type:"number",value:null!=t?String(t):"",onChange:a=>{const t=a.target.value,s=""===t?null:Number(t);b(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&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);default:return Ia.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ia.jsx(Va,{htmlFor:e.name,children:e.label}),Ia.jsx(Ma,{id:e.name,type:"text",value:t||"",onChange:a=>{b(e.name,a.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&&Ia.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name)}},k=n(()=>{if(!j)return null;if(j.disabled)return Ia.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Ia.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Ia.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Ia.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Ia.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Ia.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(j.component){const e=j.component;return Ia.jsx(e,{formData:x,updateField:b,errors:g,users:u,disabled:j.disabled})}return Ia.jsx("div",{className:"space-y-3",children:j.fields.map(w)})},[j,x,b,g,u,w]),S=Ia.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Ia.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Ia.jsx("div",{className:"flex space-x-2",children:v.map(e=>Ia.jsx(La,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=v.find(a=>a.id===e);a&&!a.disabled&&p(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Ia.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:m?Ia.jsx("div",{className:"flex items-center justify-center py-12",children:Ia.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Ia.jsxs("form",{onSubmit:y(i),className:"space-y-3 md:space-y-4",children:[k(),Ia.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ia.jsx(La,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Ia.jsx(La,{type:"submit",disabled:m,children:d})]})]})})]});return Ia.jsx(Ja,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Ia.jsxs(et,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Ia.jsxs(at,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Ia.jsx(st,{className:"text-white",children:e}),Ia.jsx(rt,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Xr({open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:i=!1,submitButtonText:o="Salvar"}){return Ia.jsx(Jr,{open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:i,submitButtonText:o})}const Yr=({manager:e})=>{const{pagination:a={totalItems:0,totalPages:1},currentPage:t=1,itemsPerPage:s=10,handlePageChange:r=()=>{},handleItemsPerPageChange:n=()=>{}}=e,{totalItems:i=0,totalPages:o=1}=a,l=i>0?(t-1)*s+1:0,c=Math.min(t*s,i);return Ia.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:[Ia.jsxs("div",{className:"flex items-center space-x-3",children:[Ia.jsx("span",{children:"Itens por página"}),Ia.jsxs(pt,{value:s.toString(),onValueChange:e=>n(Number(e)),children:[Ia.jsx(xt,{className:"w-20 h-8 border-border",children:Ia.jsx(ht,{})}),Ia.jsxs(yt,{children:[Ia.jsx(vt,{value:"10",children:"10"}),Ia.jsx(vt,{value:"25",children:"25"}),Ia.jsx(vt,{value:"50",children:"50"}),Ia.jsx(vt,{value:"100",children:"100"})]})]})]}),Ia.jsx("div",{className:"flex-1 flex justify-center",children:Ia.jsx("span",{children:i>0?`${l}-${c} de ${i} itens (página ${t} de ${o})`:"0 itens"})}),Ia.jsxs("div",{className:"flex items-center space-x-1",children:[Ia.jsx(La,{variant:"outline",size:"sm",onClick:()=>r(1),disabled:1===t,children:Ia.jsx(Ee,{className:"h-4 w-4"})}),Ia.jsx(La,{variant:"outline",size:"sm",onClick:()=>r(Math.max(1,t-1)),disabled:1===t,children:Ia.jsx(ue,{className:"h-4 w-4"})}),Ia.jsx(La,{variant:"outline",size:"sm",onClick:()=>r(Math.min(o,t+1)),disabled:t===o,children:Ia.jsx(_,{className:"h-4 w-4"})}),Ia.jsx(La,{variant:"outline",size:"sm",onClick:()=>r(o),disabled:t===o,children:Ia.jsx(Ie,{className:"h-4 w-4"})})]})]})},Gr=({selectedCount:e,onClearSelection:a,onBulkDelete:t,customActions:s=[],isLoading:r=!1})=>Ia.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Ia.jsxs("div",{className:"flex items-center gap-3",children:[Ia.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Ia.jsxs(La,{variant:"ghost",size:"sm",onClick:a,className:"h-7 px-2",children:[Ia.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Ia.jsxs("div",{className:"flex items-center gap-2",children:[s.map((e,a)=>{const t=e.icon;return Ia.jsxs(La,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:r,className:"h-7",children:[t&&Ia.jsx(t,{size:14,className:"mr-1"}),e.label]},a)}),t&&Ia.jsxs(La,{variant:"destructive",size:"sm",onClick:t,disabled:r,className:"h-7",children:[Ia.jsx(D,{size:14,className:"mr-1"}),"Deletar"]})]})]}),Zr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},en={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},an={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function tn({children:e,direction:a="column",gap:t="md",align:s="stretch",justify:r="start",wrap:n=!1,className:i}){return Ia.jsx("div",{className:Aa("flex","column"===a?"flex-col":"flex-row",Zr[t],en[s],an[r],n&&"flex-wrap",i),children:e})}function sn({manager:e,filters:a,inline:t=!1}){const{isSearchVisible:s}=Us(),r=e.searchTerm,n=Ia.jsxs(Ia.Fragment,{children:[a.some(e=>"search"===e.type)&&!s&&Ia.jsxs("div",{className:"relative flex-1",children:[Ia.jsx(T,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ia.jsx(Ma,{placeholder:"Buscar...",value:e.searchTerm,onChange:a=>e.handleSearch(a.target.value),className:"pl-10"})]}),a.filter(e=>"custom"===e.type&&e.component).map((e,a)=>{const s=e.component;return Ia.jsx("div",{className:t?"":"w-full sm:w-auto",children:Ia.jsx(s,{...e.props})},a)}),r&&Ia.jsxs(La,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Ia.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return t?Ia.jsx("div",{className:"flex items-center gap-2",children:n}):Ia.jsx(tn,{direction:"column",gap:"md",className:"mb-6",children:Ia.jsx(tn,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:n})})}function rn({manager:e,config:a,formSections:t,onSave:s,onToggleStatus:n}){const{setSearchVisible:o}=Us(),[l,c]=r(!1),[d,m]=r(null),[u,f]=r({isOpen:!1,entityId:null,entityName:""}),[p,h]=r({isOpen:!1,count:0});i(()=>(o(!0),()=>{o(!1)}),[o]);return Ia.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[a.enableBulkActions&&e.selectedIds.length>0&&Ia.jsx(Gr,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:s?()=>{h({isOpen:!0,count:e.selectedIds.length})}:void 0,customActions:a.bulkActions,isLoading:e.isBulkDeleting}),Ia.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Ia.jsx("div",{className:"flex items-center gap-4",children:Ia.jsxs(La,{onClick:()=>{m(null),c(!0)},children:[Ia.jsx(pe,{size:16,className:"mr-2"}),"Novo"]})}),a.filters&&a.filters.length>0&&Ia.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Ia.jsx(sn,{manager:e,filters:a.filters,inline:!0})})]}),Ia.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:Ia.jsx(zr,{manager:e,columns:a.columns,onEdit:e=>{m(e),c(!0)},onDelete:e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:n,enableBulkActions:a.enableBulkActions})}),Ia.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Ia.jsx(Yr,{manager:e})}),Ia.jsx(Xr,{open:l,title:d?`Editar ${a.entityName}`:`Novo ${a.entityName}`,sections:t,initialData:d||void 0,onSubmit:e=>{s(e),c(!1),m(null)},onCancel:()=>{c(!1),m(null)},isLoading:e.isLoading,submitButtonText:d?"Atualizar":"Criar"}),Ia.jsx(ar,{open:u.isOpen,onOpenChange:()=>{f({isOpen:!1,entityId:null,entityName:""})},onConfirm:a=>{u.entityId&&(e.deleteEntity(u.entityId),f({isOpen:!1,entityId:null,entityName:""}))},item:u.entityId?{id:u.entityId,title:u.entityName}:void 0,entityName:a.entityName,isDeleting:e.isDeleting}),Ia.jsx(ar,{open:p.isOpen,onOpenChange:()=>h({isOpen:!1,count:0}),onConfirm:()=>(e.bulkDelete?.(e.selectedIds),void h({isOpen:!1,count:0})),item:{id:"bulk",title:`${p.count} ${1===p.count?"item":"itens"}`},entityName:a.entityName,isDeleting:e.isBulkDeleting})]})}function nn(e){return()=>{const{manager:a,config:t,onSave:s,onToggleStatus:r}=e,n={entityName:t.entityName,entityNamePlural:t.entityNamePlural,filters:t.filters||[],columns:t.columns,cardFields:t.cardFields||[]};return Ia.jsx(rn,{manager:a,config:n,formSections:t.formSections,onSave:s,onToggleStatus:r})}}function on(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}}function ln(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:dn(e),label:dn(e),...cn(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}}function cn(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function dn(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const mn={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}};function un(e,a,t={}){const s=mn[e];return ln(s.title,a,{...s,...t})}const fn=({children:e})=>{const{isAuthenticated:t,isLoading:s}=Us();if(a.useEffect(()=>{if(!t)return;const e=()=>{as.areAllTokensValid()||$s.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[t]),a.useEffect(()=>{if(s)return;if(t)return;if(as.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,r=new URLSearchParams(a);if(e.has("access_token")||r.has("access_token"))return;const n=vs();(async()=>{n?await $s.loginDev():$s.loginProd()})()},[t,s]),s)return Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsx(qa,{className:"text-xl font-semibold",children:"Carregando..."})}),Ia.jsxs(Qa,{className:"text-center",children:[Ia.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ia.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!t){if(new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token"))return Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsx(qa,{className:"text-xl font-semibold",children:"Processando..."})}),Ia.jsxs(Qa,{className:"text-center",children:[Ia.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ia.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(as.areAllTokensValid())return Ia.jsx(Ia.Fragment,{children:e})}catch{}return Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsx(qa,{className:"text-xl font-semibold",children:"Iniciando..."})}),Ia.jsxs(Qa,{className:"text-center",children:[Ia.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ia.jsx("p",{className:"text-muted-foreground",children:vs()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Ia.jsx(Ia.Fragment,{children:e})},pn=f("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"}}),hn=e.forwardRef(({className:e,variant:a,...t},s)=>Ia.jsx("div",{ref:s,role:"alert",className:Aa(pn({variant:a}),e),...t}));hn.displayName="Alert";const xn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("h5",{ref:t,className:Aa("mb-1 font-medium leading-none tracking-tight",e),...a}));xn.displayName="AlertTitle";const gn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("text-sm [&_p]:leading-relaxed",e),...a}));gn.displayName="AlertDescription";const bn=()=>{const{processCallback:e}=Us(),[a,t]=r(null),[s,n]=r(!1);i(()=>{(async()=>{try{if(await e()){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 t("Falha na autenticação. Tente novamente.")}catch(a){t(a?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const o=async()=>{n(!0),t(null);try{await e()||t("Falha na autenticação. Tente novamente.")}catch(a){t(a?.message||"Erro ao tentar novamente.")}finally{n(!1)}},l=()=>{window.location.href="/"};return a?Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsxs(qa,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Ia.jsx(C,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Ia.jsxs(Qa,{className:"space-y-4",children:[Ia.jsx(hn,{variant:"destructive",children:Ia.jsx(gn,{children:a})}),Ia.jsx("div",{className:"text-sm text-muted-foreground",children:Ia.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Ia.jsxs("div",{className:"flex gap-2",children:[Ia.jsx(La,{onClick:o,disabled:s,className:"flex-1",children:s?Ia.jsxs(Ia.Fragment,{children:[Ia.jsx(Ct,{size:"sm",className:"mr-2"}),"Tentando..."]}):Ia.jsxs(Ia.Fragment,{children:[Ia.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Ia.jsx(La,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsx(qa,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Ia.jsxs(Qa,{className:"text-center",children:[Ia.jsx("div",{className:"flex justify-center mb-4",children:Ia.jsx(Ct,{size:"lg"})}),Ia.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},yn=()=>Ia.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsx(Wa,{className:"text-center",children:Ia.jsx(qa,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Ia.jsxs(Qa,{className:"text-center space-y-4",children:[Ia.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Ia.jsx(La,{onClick:async()=>{vs()?await $s.loginDev():$s.loginProd()},className:"w-full",size:"lg",children:vs()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})});function vn(e){return{queryClient:e.queryClient||new Ge({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Nn=ca.Root,jn=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ca.Item,{ref:t,className:Aa("border-b",e),...a}));jn.displayName="AccordionItem";const wn=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsx(ca.Header,{className:"flex",children:Ia.jsxs(ca.Trigger,{ref:s,className:Aa("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...t,children:[a,Ia.jsx(j,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));wn.displayName=ca.Trigger.displayName;const kn=e.forwardRef(({className:e,children:a,...t},s)=>Ia.jsx(ca.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...t,children:Ia.jsx("div",{className:Aa("pb-4 pt-0",e),children:a})}));kn.displayName=ca.Content.displayName;const Sn=da.Root,Cn=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ma.Root,{ref:t,className:Aa("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...a}));Cn.displayName=ma.Root.displayName;const Tn=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ma.Image,{ref:t,className:Aa("aspect-square h-full w-full",e),...a}));Tn.displayName=ma.Image.displayName;const Rn=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ma.Fallback,{ref:t,className:Aa("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...a}));Rn.displayName=ma.Fallback.displayName;const _n=e.forwardRef(({...e},a)=>Ia.jsx("nav",{ref:a,"aria-label":"breadcrumb",...e}));_n.displayName="Breadcrumb";const Pn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("ol",{ref:t,className:Aa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...a}));Pn.displayName="BreadcrumbList";const En=e.forwardRef(({className:e,...a},t)=>Ia.jsx("li",{ref:t,className:Aa("inline-flex items-center gap-1.5",e),...a}));En.displayName="BreadcrumbItem";const In=e.forwardRef(({asChild:a,className:t,...s},r)=>{const n=a?e.Fragment:"a";return Ia.jsx(n,{ref:r,className:Aa("transition-colors hover:text-foreground",t),...s})});In.displayName="BreadcrumbLink";const An=e.forwardRef(({className:e,...a},t)=>Ia.jsx("span",{ref:t,role:"link","aria-disabled":"true","aria-current":"page",className:Aa("font-normal text-foreground",e),...a}));An.displayName="BreadcrumbPage";const Dn=({children:e,className:a,...t})=>Ia.jsx("li",{role:"presentation","aria-hidden":"true",className:Aa("[&>svg]:size-3.5",a),...t,children:e??Ia.jsx(_,{})});Dn.displayName="BreadcrumbSeparator";const zn=({className:e,...a})=>Ia.jsxs("span",{role:"presentation","aria-hidden":"true",className:Aa("flex h-9 w-9 items-center justify-center",e),...a,children:[Ia.jsx(De,{className:"h-4 w-4"}),Ia.jsx("span",{className:"sr-only",children:"More"})]});function On(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function $n(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Fn(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const i=n[0],o=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=t.valueCallback?t.valueCallback(c):c;return{value:c,rest:a.slice(i.length)}}}zn.displayName="BreadcrumbEllipsis";const Ln={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"}},Mn={date:On({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:On({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:On({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Un={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Vn={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:$n({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:$n({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:$n({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:$n({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:$n({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"})},Bn={ordinalNumber:(Wn={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,a={})=>{const t=e.match(Wn.matchPattern);if(!t)return null;const s=t[0],r=e.match(Wn.parsePattern);if(!r)return null;let n=Wn.valueCallback?Wn.valueCallback(r[0]):r[0];return n=a.valueCallback?a.valueCallback(n):n,{value:n,rest:e.slice(s.length)}}),era:Fn({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:Fn({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:Fn({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:Fn({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:Fn({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 Wn;const qn={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Ln[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:Mn,formatRelative:(e,a,t,s)=>{const r=Un[e];return"function"==typeof r?r(a):r},localize:Vn,match:Bn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Hn({className:e,classNames:a,showOutsideDays:t=!0,...s}){return Ia.jsx(ua,{showOutsideDays:t,className:Aa("p-3",e),locale:qn,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:Aa(Fa({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:Aa(Fa({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",...a},components:{IconLeft:({...e})=>Ia.jsx(ue,{className:"h-4 w-4"}),IconRight:({...e})=>Ia.jsx(_,{className:"h-4 w-4"})},...s})}Hn.displayName="Calendar";const Qn=fa.Root,Kn=fa.CollapsibleTrigger,Jn=fa.CollapsibleContent,Xn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a}));Xn.displayName="Command";const Yn=({children:e,...a})=>Ia.jsx("div",{...a,children:Ia.jsx(Xn,{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})}),Gn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Ia.jsx("input",{ref:t,className:Aa("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),...a})}));Gn.displayName="CommandInput";const Zn=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));Zn.displayName="CommandList";const ei=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("py-6 text-center text-sm text-muted-foreground",e),...a}));ei.displayName="CommandEmpty";const ai=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("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),...a}));ai.displayName="CommandGroup";const ti=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,className:Aa("-mx-1 h-px bg-border",e),...a}));ti.displayName="CommandSeparator";const si=e.forwardRef(({className:e,disabled:a,onSelect:t,value:s,...r},n)=>Ia.jsx("div",{ref:n,className:Aa("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":a,onClick:()=>!a&&t?.(s||""),...r}));si.displayName="CommandItem";const ri=({className:e,...a})=>Ia.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});ri.displayName="CommandShortcut";const ni={Root:function({children:e,className:a}){return Ia.jsx("div",{className:Aa("space-y-4",a),children:e})},Item:function({children:e,onClick:a,className:t}){return Ia.jsx(Ba,{className:Aa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",t),onClick:a,children:Ia.jsx(Qa,{className:"p-4",children:e})})},Field:function({label:e,value:a,className:t}){return Ia.jsxs("div",{className:Aa("flex justify-between items-center text-sm",t),children:[Ia.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Ia.jsx("span",{className:"text-foreground",children:a})]})}},ii={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))]"},oi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function li({children:e,cols:a="auto-fit",gap:t="md",className:s}){return Ia.jsx("div",{className:Aa("grid",ii[a],oi[t],s),children:e})}function ci({items:e,maxItems:a=3,className:t}){return e.length>a&&(e[0],e.slice(-(a-1))),e.length,Ia.jsx(_n,{className:t})}function di(){const e=ea();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()}const mi=({className:e,...a})=>Ia.jsx("nav",{role:"navigation","aria-label":"pagination",className:Aa("mx-auto flex w-full justify-center",e),...a});mi.displayName="Pagination";const ui=e.forwardRef(({className:e,...a},t)=>Ia.jsx("ul",{ref:t,className:Aa("flex flex-row items-center gap-1",e),...a}));ui.displayName="PaginationContent";const fi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("li",{ref:t,className:Aa("",e),...a}));fi.displayName="PaginationItem";const pi=({className:e,isActive:a,size:t="icon",...s})=>Ia.jsx("a",{"aria-current":a?"page":void 0,className:Aa(Fa({variant:a?"outline":"ghost",size:t}),e),...s});pi.displayName="PaginationLink";const hi=({className:e,...a})=>Ia.jsxs(pi,{"aria-label":"Go to previous page",size:"default",className:Aa("gap-1 pl-2.5",e),...a,children:[Ia.jsx(ue,{className:"h-4 w-4"}),Ia.jsx("span",{children:"Previous"})]});hi.displayName="PaginationPrevious";const xi=({className:e,...a})=>Ia.jsxs(pi,{"aria-label":"Go to next page",size:"default",className:Aa("gap-1 pr-2.5",e),...a,children:[Ia.jsx("span",{children:"Next"}),Ia.jsx(_,{className:"h-4 w-4"})]});xi.displayName="PaginationNext";const gi=({className:e,...a})=>Ia.jsxs("span",{"aria-hidden":!0,className:Aa("flex h-9 w-9 items-center justify-center",e),...a,children:[Ia.jsx(De,{className:"h-4 w-4"}),Ia.jsx("span",{className:"sr-only",children:"More pages"})]});gi.displayName="PaginationEllipsis";const bi=e.forwardRef(({className:e,value:a,...t},s)=>Ia.jsx(pa.Root,{ref:s,className:Aa("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...t,children:Ia.jsx(pa.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));bi.displayName=pa.Root.displayName;const yi=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ha.Root,{className:Aa("grid gap-2",e),...a,ref:t}));yi.displayName=ha.Root.displayName;const vi=e.forwardRef(({className:e,...a},t)=>Ia.jsx(ha.Item,{ref:t,className:Aa("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),...a,children:Ia.jsx(ha.Indicator,{className:"flex items-center justify-center",children:Ia.jsx(P,{className:"h-2.5 w-2.5 fill-current text-current"})})}));vi.displayName=ha.Item.displayName;const Ni=e.forwardRef(({className:e,orientation:a="horizontal",decorative:t=!0,...s},r)=>Ia.jsx(xa.Root,{ref:r,decorative:t,orientation:a,className:Aa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...s}));Ni.displayName=xa.Root.displayName;const ji=v.Root,wi=v.Trigger,ki=v.Close,Si=v.Portal,Ci=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Overlay,{className:Aa("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),...a,ref:t}));Ci.displayName=v.Overlay.displayName;const Ti=f("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"}}),Ri=e.forwardRef(({side:e="right",className:a,children:t,...s},r)=>Ia.jsxs(Si,{children:[Ia.jsx(Ci,{}),Ia.jsxs(v.Content,{ref:r,className:Aa(Ti({side:e}),a),...s,children:[t,Ia.jsxs(v.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:[Ia.jsx(N,{className:"h-4 w-4"}),Ia.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ri.displayName=v.Content.displayName;const _i=({className:e,...a})=>Ia.jsx("div",{className:Aa("flex flex-col space-y-2 text-center sm:text-left",e),...a});_i.displayName="SheetHeader";const Pi=({className:e,...a})=>Ia.jsx("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Pi.displayName="SheetFooter";const Ei=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Title,{ref:t,className:Aa("text-lg font-semibold text-foreground",e),...a}));Ei.displayName=v.Title.displayName;const Ii=e.forwardRef(({className:e,...a},t)=>Ia.jsx(v.Description,{ref:t,className:Aa("text-sm text-muted-foreground",e),...a}));Ii.displayName=v.Description.displayName;const Ai=ga.Provider,Di=ga.Root,zi=ga.Trigger,Oi=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>Ia.jsx(ga.Content,{ref:s,sideOffset:a,className:Aa("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),...t}));Oi.displayName=ga.Content.displayName;const $i="sidebar:state",Fi=e.createContext(null);function Li(){const a=e.useContext(Fi);if(!a)throw new Error("useSidebar must be used within a SidebarProvider.");return a}const Mi=e.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[c,d]=e.useState(!1);e.useEffect(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[m,u]=e.useState(!1),[f,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem($i);return null!==e?"true"===e:a}return a}),h=t??f,x=e.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem($i,String(a))},[s,h]),g=e.useCallback(()=>c?u(e=>!e):x(e=>!e),[c,x,u]);e.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 b=h?"expanded":"collapsed",y=e.useMemo(()=>({state:b,open:h,setOpen:x,isMobile:c,openMobile:m,setOpenMobile:u,toggleSidebar:g}),[b,h,x,c,m,u,g]);return Ia.jsx(Fi.Provider,{value:y,children:Ia.jsx(Ai,{delayDuration:0,children:Ia.jsx("div",{className:Aa("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",...n},ref:l,...o,children:i})})})});Mi.displayName="SidebarProvider";const Ui=e.forwardRef(({side:e="left",variant:a="sidebar",collapsible:t="offcanvas",className:s,children:r,...n},i)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:d}=Li();return"none"===t?Ia.jsx("div",{className:Aa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:i,...n,children:r}):o?Ia.jsx(ji,{open:c,onOpenChange:d,...n,children:Ia.jsxs(Ri,{"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:[Ia.jsx(Ei,{className:"sr-only",children:"Menu de Navegação"}),Ia.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):Ia.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?t:"","data-variant":a,"data-side":e,children:[Ia.jsx("div",{className:Aa("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"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),Ia.jsx("div",{className:Aa("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"===a||"inset"===a?"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:Ia.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})})]})});Ui.displayName="Sidebar";const Vi=e.forwardRef(({className:e,onClick:a,...t},s)=>{const{toggleSidebar:r}=Li();return Ia.jsxs(La,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Aa("h-7 w-7",e),onClick:e=>{a?.(e),r()},...t,children:[Ia.jsx(ze,{}),Ia.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Vi.displayName="SidebarTrigger";const Bi=e.forwardRef(({className:e,...a},t)=>{const{toggleSidebar:s}=Li();return Ia.jsx("button",{ref:t,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:Aa("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),...a})});Bi.displayName="SidebarRail";const Wi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("main",{ref:t,className:Aa("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),...a}));Wi.displayName="SidebarInset";const qi=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Ma,{ref:t,"data-sidebar":"input",className:Aa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...a}));qi.displayName="SidebarInput";const Hi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"header",className:Aa("flex flex-col gap-2 p-2",e),...a}));Hi.displayName="SidebarHeader";const Qi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"footer",className:Aa("flex flex-col gap-2 p-2",e),...a}));Qi.displayName="SidebarFooter";const Ki=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Ni,{ref:t,"data-sidebar":"separator",className:Aa("mx-2 w-auto bg-sidebar-border",e),...a}));Ki.displayName="SidebarSeparator";const Ji=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"content",className:Aa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...a}));Ji.displayName="SidebarContent";const Xi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"group",className:Aa("relative flex w-full min-w-0 flex-col p-2",e),...a}));Xi.displayName="SidebarGroup";const Yi=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?m:"div";return Ia.jsx(r,{ref:s,"data-sidebar":"group-label",className:Aa("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),...t})});Yi.displayName="SidebarGroupLabel";const Gi=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?m:"button";return Ia.jsx(r,{ref:s,"data-sidebar":"group-action",className:Aa("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),...t})});Gi.displayName="SidebarGroupAction";const Zi=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"group-content",className:Aa("w-full text-sm",e),...a}));Zi.displayName="SidebarGroupContent";const eo=e.forwardRef(({className:e,...a},t)=>Ia.jsx("ul",{ref:t,"data-sidebar":"menu",className:Aa("flex w-full min-w-0 flex-col gap-1",e),...a}));eo.displayName="SidebarMenu";const ao=e.forwardRef(({className:e,...a},t)=>Ia.jsx("li",{ref:t,"data-sidebar":"menu-item",className:Aa("group/menu-item relative",e),...a}));ao.displayName="SidebarMenuItem";const to=f("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"}}),so=e.forwardRef(({asChild:e=!1,isActive:a=!1,variant:t="default",size:s="default",tooltip:r,className:n,...i},o)=>{const l=e?m:"button",{isMobile:c,state:d}=Li(),u=Ia.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":s,"data-active":a,className:Aa(to({variant:t,size:s}),n),...i});return r?("string"==typeof r&&(r={children:r}),Ia.jsxs(Di,{children:[Ia.jsx(zi,{asChild:!0,children:u}),Ia.jsx(Oi,{side:"right",align:"center",hidden:"collapsed"!==d||c,...r})]})):u});so.displayName="SidebarMenuButton";const ro=e.forwardRef(({className:e,asChild:a=!1,showOnHover:t=!1,...s},r)=>{const n=a?m:"button";return Ia.jsx(n,{ref:r,"data-sidebar":"menu-action",className:Aa("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",t&&"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),...s})});ro.displayName="SidebarMenuAction";const no=e.forwardRef(({className:e,...a},t)=>Ia.jsx("div",{ref:t,"data-sidebar":"menu-badge",className:Aa("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),...a}));no.displayName="SidebarMenuBadge";const io=e.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Ia.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Aa("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&Ia.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Ia.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});io.displayName="SidebarMenuSkeleton";const oo=e.forwardRef(({className:e,...a},t)=>Ia.jsx("ul",{ref:t,"data-sidebar":"menu-sub",className:Aa("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),...a}));oo.displayName="SidebarMenuSub";const lo=e.forwardRef(({...e},a)=>Ia.jsx("li",{ref:a,...e}));lo.displayName="SidebarMenuSubItem";const co=e.forwardRef(({asChild:e=!1,size:a="md",isActive:t,className:s,...r},n)=>{const i=e?m:"a";return Ia.jsx(i,{ref:n,"data-sidebar":"menu-sub-button","data-size":a,"data-active":t,className:Aa("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",s),...r})});co.displayName="SidebarMenuSubButton";const mo=e.forwardRef(({className:e,...a},t)=>Ia.jsxs(ba.Root,{ref:t,className:Aa("relative flex w-full touch-none select-none items-center",e),...a,children:[Ia.jsx(ba.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Ia.jsx(ba.Range,{className:"absolute h-full bg-primary"})}),Ia.jsx(ba.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"})]}));mo.displayName=ba.Root.displayName;const uo=({...e})=>{const{theme:a="system"}=ya();return Ia.jsx(ra,{theme:a,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})};function fo(e,a,{checkForDefaultPrevented:t=!0}={}){return function(s){if(e?.(s),!1===t||!s.defaultPrevented)return a?.(s)}}function po(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function ho(...a){return e.useCallback(function(...e){return a=>{let t=!1;const s=e.map(e=>{const s=po(e,a);return t||"function"!=typeof s||(t=!0),s});if(t)return()=>{for(let a=0;a<s.length;a++){const t=s[a];"function"==typeof t?t():po(e[a],null)}}}}(...a),a)}function xo(...a){const t=a[0];if(1===a.length)return t;const s=()=>{const s=a.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(a){const r=s.reduce((e,{useScope:t,scopeName:s})=>({...e,...t(a)[`__scope${s}`]}),{});return e.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return s.scopeName=t.scopeName,s}var go=globalThis?.document?e.useLayoutEffect:()=>{},bo=e[" useInsertionEffect ".trim().toString()]||go;function yo({prop:a,defaultProp:t,onChange:s=()=>{},caller:r}){const[n,i,o]=function({defaultProp:a,onChange:t}){const[s,r]=e.useState(a),n=e.useRef(s),i=e.useRef(t);return bo(()=>{i.current=t},[t]),e.useEffect(()=>{n.current!==s&&(i.current?.(s),n.current=s)},[s,n]),[s,r,i]}({defaultProp:t,onChange:s}),l=void 0!==a,c=l?a:n;{const t=e.useRef(void 0!==a);e.useEffect(()=>{const e=t.current;if(e!==l){}t.current=l},[l,r])}const d=e.useCallback(e=>{if(l){const t=function(e){return"function"==typeof e}(e)?e(a):e;t!==a&&o.current?.(t)}else i(e)},[l,a,i,o]);return[c,d]}var vo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((a,t)=>{const s=u(`Primitive.${t}`),r=e.forwardRef((e,a)=>{const{asChild:r,...n}=e,i=r?s:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),Ia.jsx(i,{...n,ref:a})});return r.displayName=`Primitive.${t}`,{...a,[t]:r}},{}),No="Switch",[jo]=function(a,t=[]){let s=[];const r=()=>{const t=s.map(a=>e.createContext(a));return function(s){const r=s?.[a]||t;return e.useMemo(()=>({[`__scope${a}`]:{...s,[a]:r}}),[s,r])}};return r.scopeName=a,[function(t,r){const n=e.createContext(r),i=s.length;s=[...s,r];const o=t=>{const{scope:s,children:r,...o}=t,l=s?.[a]?.[i]||n,c=e.useMemo(()=>o,Object.values(o));return Ia.jsx(l.Provider,{value:c,children:r})};return o.displayName=t+"Provider",[o,function(s,o){const l=o?.[a]?.[i]||n,c=e.useContext(l);if(c)return c;if(void 0!==r)return r;throw new Error(`\`${s}\` must be used within \`${t}\``)}]},xo(r,...t)]}(No),[wo,ko]=jo(No),So=e.forwardRef((a,t)=>{const{__scopeSwitch:s,name:r,checked:n,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:m,...u}=a,[f,p]=e.useState(null),h=ho(t,e=>p(e)),x=e.useRef(!1),g=!f||(m||!!f.closest("form")),[b,y]=yo({prop:n,defaultProp:i??!1,onChange:d,caller:No});return Ia.jsxs(wo,{scope:s,checked:b,disabled:l,children:[Ia.jsx(vo.button,{type:"button",role:"switch","aria-checked":b,"aria-required":o,"data-state":_o(b),"data-disabled":l?"":void 0,disabled:l,value:c,...u,ref:h,onClick:fo(a.onClick,e=>{y(e=>!e),g&&(x.current=e.isPropagationStopped(),x.current||e.stopPropagation())})}),g&&Ia.jsx(Ro,{control:f,bubbles:!x.current,name:r,value:c,checked:b,required:o,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});So.displayName=No;var Co="SwitchThumb",To=e.forwardRef((e,a)=>{const{__scopeSwitch:t,...s}=e,r=ko(Co,t);return Ia.jsx(vo.span,{"data-state":_o(r.checked),"data-disabled":r.disabled?"":void 0,...s,ref:a})});To.displayName=Co;var Ro=e.forwardRef(({__scopeSwitch:a,control:t,checked:s,bubbles:r=!0,...n},i)=>{const o=e.useRef(null),l=ho(o,i),c=function(a){const t=e.useRef({value:a,previous:a});return e.useMemo(()=>(t.current.value!==a&&(t.current.previous=t.current.value,t.current.value=a),t.current.previous),[a])}(s),d=function(a){const[t,s]=e.useState(void 0);return go(()=>{if(a){s({width:a.offsetWidth,height:a.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const t=e[0];let r,n;if("borderBoxSize"in t){const e=t.borderBoxSize,a=Array.isArray(e)?e[0]:e;r=a.inlineSize,n=a.blockSize}else r=a.offsetWidth,n=a.offsetHeight;s({width:r,height:n})});return e.observe(a,{box:"border-box"}),()=>e.unobserve(a)}s(void 0)},[a]),t}(t);return e.useEffect(()=>{const e=o.current;if(!e)return;const a=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(a,"checked").set;if(c!==s&&t){const a=new Event("click",{bubbles:r});t.call(e,s),e.dispatchEvent(a)}},[c,s,r]),Ia.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...n,tabIndex:-1,ref:l,style:{...n.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function _o(e){return e?"checked":"unchecked"}Ro.displayName="SwitchBubbleInput";var Po=So,Eo=To;const Io=e.forwardRef(({className:e,...a},t)=>Ia.jsx(Po,{className:Aa("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),...a,ref:t,children:Ia.jsx(Eo,{className:Aa("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")})}));Io.displayName=Po.displayName;const Ao=va.Root,Do=e.forwardRef(({className:e,...a},t)=>Ia.jsx(va.List,{ref:t,className:Aa("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));Do.displayName=va.List.displayName;const zo=e.forwardRef(({className:e,...a},t)=>Ia.jsx(va.Trigger,{ref:t,className:Aa("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),...a}));zo.displayName=va.Trigger.displayName;const Oo=e.forwardRef(({className:e,...a},t)=>Ia.jsx(va.Content,{ref:t,className:Aa("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));function $o({children:e,className:a}){return Ia.jsx("div",{className:Aa("flex flex-col h-full",a),children:Ia.jsx(Vr,{className:"flex-1",children:Ia.jsx("div",{className:"space-y-6 p-6",children:e})})})}function Fo({title:e,description:a,actions:t,className:s}){return Ia.jsxs("div",{className:Aa("space-y-4",s),children:[Ia.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Ia.jsxs("div",{className:"space-y-1",children:[Ia.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),a&&Ia.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),t&&Ia.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t})]}),Ia.jsx(Ni,{})]})}function Lo({children:e,className:a}){return Ia.jsx("div",{className:Aa("space-y-6",a),children:e})}Oo.displayName=va.Content.displayName;const Mo=f("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"}}),Uo=e.forwardRef(({className:e,variant:a,size:t,...s},r)=>Ia.jsx(Na.Root,{ref:r,className:Aa(Mo({variant:a,size:t,className:e})),...s}));Uo.displayName=Na.Root.displayName;const Vo=e.createContext({size:"default",variant:"default"}),Bo=e.forwardRef(({className:e,variant:a,size:t,children:s,...r},n)=>Ia.jsx(ja.Root,{ref:n,className:Aa("flex items-center justify-center gap-1",e),...r,children:Ia.jsx(Vo.Provider,{value:{variant:a,size:t},children:s})}));Bo.displayName=ja.Root.displayName;const Wo=e.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=e.useContext(Vo);return Ia.jsx(ja.Item,{ref:i,className:Aa(Mo({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Wo.displayName=ja.Item.displayName;const qo=a.forwardRef(({variant:e="default",className:a,children:t,...s},r)=>Ia.jsx(La,{ref:r,variant:"outline",size:"sm",className:Aa("h-7 px-2 text-xs","border-primary/20 text-primary hover:bg-primary/5",a),...s,children:t||Ia.jsx(z,{size:12})}));function Ho({manager:e,config:a,onEdit:t,onDelete:s}){return e.isLoading?Ia.jsx(li,{children:Array.from({length:3}).map((e,a)=>Ia.jsxs(Ba,{children:[Ia.jsxs(Wa,{children:[Ia.jsx(dr,{className:"h-4 w-3/4"}),Ia.jsx(dr,{className:"h-3 w-1/2"})]}),Ia.jsx(Qa,{children:Ia.jsxs("div",{className:"space-y-2",children:[Ia.jsx(dr,{className:"h-3 w-full"}),Ia.jsx(dr,{className:"h-3 w-2/3"})]})})]},a))}):Ia.jsx(ni.Root,{children:e.entities.map(e=>Ia.jsxs(ni.Item,{onClick:()=>t(e),children:[Ia.jsx(Wa,{className:"pb-3",children:Ia.jsxs("div",{className:"flex items-start justify-between",children:[Ia.jsxs("div",{className:"flex-1 min-w-0",children:[Ia.jsx(qa,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Ia.jsx(Ha,{className:"text-sm",children:b(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:qn})})]}),Ia.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Ia.jsx(La,{variant:"external-link",size:"icon-xs",onClick:a=>{a.stopPropagation(),(e=>{try{const a=window.open(e,"_blank");a&&!a.closed&&void 0!==a.closed||(navigator.clipboard.writeText(e),sa.info("Link copiado para a área de transferência"))}catch(a){window.location.href=e}})(e.link)},title:"Abrir link externo",children:Ia.jsx(Oe,{className:"h-4 w-4"})}),Ia.jsx("div",{onClick:e=>e.stopPropagation(),children:Ia.jsx(Dr,{onEdit:()=>t(e),onDelete:s?()=>s(e):void 0,canDelete:!!s})})]})]})}),Ia.jsx(Qa,{className:"pt-0",children:Ia.jsx("div",{className:"space-y-2",children:a.cardFields?.map(a=>{const t=e[a.key];return t?Ia.jsx(ni.Field,{label:a.label,value:a.render?a.render(t,e):String(t)},String(a.key)):null})})})]},e.id))})}function Qo(e){const a=aa();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}function Ko(e){return Qo({basePath:e})}qo.displayName="ActionButton";const Jo=a.memo(({variant:e="card",className:t="",selectedUnit:s,onUnitChange:r})=>{const{user:n,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:d}=Us(),m=i?.[0]||null,u=o?i?.find(e=>e.alias===o):m,f=i||[],p=s||u||m||m,h=a.useCallback(e=>{r?r(e):d(e)},[r,d]),x=a.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===p?.alias),s=a.filter(e=>e.alias!==p?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[f,p?.alias]);if(!l||!n)return null;const g=()=>Ia.jsxs(Ia.Fragment,{children:[Ia.jsxs("div",{className:"flex items-center space-x-3",children:[Ia.jsx("div",{className:"flex-shrink-0",children:Ia.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Ia.jsx(Te,{className:"h-5 w-5 text-primary-foreground"})})}),Ia.jsxs("div",{className:"flex-1 min-w-0",children:[Ia.jsx("p",{className:"text-sm font-medium truncate",children:n.name}),Ia.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Ia.jsx("div",{className:"mt-3",children:Ia.jsxs("div",{className:"flex items-center space-x-2",children:[Ia.jsx($e,{className:"h-4 w-4 text-muted-foreground"}),Ia.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),x.length>1&&Ia.jsxs("div",{className:"mt-2",children:[Ia.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",x.length]}),Ia.jsxs("div",{className:"flex flex-wrap gap-1",children:[x.slice(0,3).map(e=>Ia.jsx(kt,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),x.length>3&&Ia.jsxs(kt,{variant:"outline",className:"text-xs",children:["+",x.length-3]})]})]})]});return"dropdown"===e?Ia.jsxs(br,{children:[Ia.jsx(yr,{asChild:!0,children:Ia.jsx(La,{variant:"ghost",className:`h-auto p-2 ${t}`,children:Ia.jsxs("div",{className:"flex items-center space-x-2",children:[Ia.jsxs("div",{className:"hidden md:block text-left",children:[Ia.jsx("p",{className:"text-sm font-medium",children:n.name}),Ia.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Ia.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Ia.jsx(Te,{className:"h-4 w-4 text-primary-foreground"})}),Ia.jsx(j,{className:"h-4 w-4"})]})})}),Ia.jsxs(Cr,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Ia.jsxs(jr,{children:[Ia.jsxs(kr,{children:[Ia.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Ia.jsx(Sr,{children:x.map(e=>Ia.jsxs(Tr,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Ia.jsx($e,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Ia.jsx(kt,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Ia.jsx(Er,{}),Ia.jsxs(Tr,{onClick:c,children:[Ia.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Ia.jsxs(Ba,{className:t,children:[Ia.jsx(Wa,{children:Ia.jsx(qa,{className:"text-lg",children:"Informações do Usuário"})}),Ia.jsxs(Qa,{className:"space-y-4",children:[Ia.jsx(g,{}),Ia.jsx(Ni,{}),Ia.jsxs(La,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Ia.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Xo=t({});function Yo({children:e,config:a}){const t=o(()=>({navigation:a?.navigation,appName:a?.appName}),[a?.navigation,a?.appName]);return Ia.jsx(Xo.Provider,{value:t,children:e})}function Go(){return s(Xo)}function Zo(){const e=ea(),{navigation:a}=Go(),t=a?.find(a=>a.path===e.pathname);return t?.label||"Página"}function el(e,a){const[t,s]=r(e),o=l(),c=n(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return i(()=>(c(),o.current=setTimeout(()=>{s(e)},a),c),[e,a,c]),[t,c]}const al=c(function({actions:e}){const a=ea(),t=Zo(),{navigation:s,appName:n}=Go(),{companies:o,alias:l,isSearchVisible:c,clearSearch:d,refreshData:m,switchUnit:u}=Us(),f=l?o?.find(e=>e.alias===l)||o?.[0]||null:o?.[0]||null,[p,h]=Ze(),[x,g]=r(()=>p.get("search")||""),[b,y]=el(x,ys.debounceDelay);i(()=>{if(!c)return;const e=new URLSearchParams(p);b?(e.set("search",b),e.set("page","1")):e.delete("search"),h(e)},[b,h,c]);const v=s?.find(e=>e.path===a.pathname);return Ia.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Ia.jsxs("div",{className:"flex items-center gap-4",children:[Ia.jsxs("div",{className:"flex-shrink-0",children:[Ia.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Ia.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:t}),Ia.jsx(kt,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:n||"Módulo"})]}),Ia.jsx("p",{className:"text-sm text-muted-foreground truncate",children:v?.complementaryText||"Detalhes do item"})]}),c&&Ia.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Ia.jsxs("div",{className:"relative flex-1",children:[Ia.jsx(T,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ia.jsx(Ma,{placeholder:"/wiki"===a.pathname?"Buscar artigos...":"Buscar...",value:x,onChange:e=>(e=>{g(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&Ia.jsx(La,{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(),g("");const e=new URLSearchParams(p);e.delete("search"),e.delete("page"),h(e)},title:"Limpar busca",children:Ia.jsx(N,{size:14})})]}),Ia.jsx(La,{variant:"outline",size:"sm",onClick:m,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Ia.jsx(Ae,{size:14})})]}),Ia.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Ia.jsx("div",{className:"flex items-center gap-2",children:e}),Ia.jsx("div",{className:"text-sm",children:Ia.jsx(Jo,{variant:"dropdown",selectedUnit:f,onUnitChange:u})})]})]})})}),tl=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Us();return Xe({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=ms(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!Fs.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},sl=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>Xe({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),rl=import.meta.env.VITE_SUPABASE_PROJECT_ID,nl={logo:`https://${rl}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${rl}.supabase.co/storage/v1/object/public/library-assets/small.svg`},il=nl.logo,ol=nl.smallLogo,ll="forlogic-sidebar-pinned",cl=()=>{try{const e=localStorage.getItem(ll);return!!e&&JSON.parse(e)}catch{return!1}};function dl({config:e}={}){const{state:a,open:t,setOpen:s}=Li(),n=ea(),{alias:o,user:l}=Us(),[c,d]=r(!1),[m,u]=r(cl),[f,p]=r(!1);i(()=>{s(!!m||!(!f&&!c))},[m,f,c,s]);const{data:h,isLoading:x,error:g}=tl({enabled:c}),b=e=>{const a=["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 a[e%a.length]};return Ia.jsxs(Ui,{collapsible:"icon",onMouseEnter:()=>{m||p(!0)},onMouseLeave:()=>{m||p(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[Ia.jsxs(Hi,{className:"p-0 gap-0",children:[Ia.jsx("div",{className:"flex items-center justify-between h-[34px]",children:t?Ia.jsxs(Ia.Fragment,{children:[Ia.jsx("div",{className:"flex items-center pl-[12px]",children:Ia.jsx("img",{src:nl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Ia.jsx("button",{onClick:()=>{const e=!m;u(e),(e=>{try{localStorage.setItem(ll,JSON.stringify(e))}catch{}})(e)},className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(m?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:Ia.jsx(ze,{className:"h-4 w-4"})})]}):Ia.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Ia.jsx("img",{src:nl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Ia.jsx("div",{className:"mt-2 pt-0",children:Ia.jsxs(br,{onOpenChange:d,children:[Ia.jsx(yr,{asChild:!0,children:t?Ia.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:[Ia.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Ia.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"}),Ia.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Ia.jsx(j,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Ia.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:Ia.jsx(j,{className:"h-6 w-6 text-muted-foreground"})})}),Ia.jsx(Cr,{className:t?"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:t?"start":"center",children:x?Ia.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Ia.jsx(S,{className:"h-4 w-4 animate-spin"}),Ia.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):g?Ia.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Ia.jsx(C,{className:"h-4 w-4"}),Ia.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Ia.jsx("div",{className:"space-y-2",children:h.map((e,a)=>Ia.jsx("div",{onClick:()=>(e=>{const a=h?.find(a=>a.url===e);a?.url&&window.open(a.url,"_blank")})(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${b(a)} transition-colors duration-200\n `,children:Ia.jsxs("div",{className:"flex items-center justify-between",children:[Ia.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Ia.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Ia.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Ia.jsx(Ji,{children:Ia.jsx(Xi,{className:"p-0 mt-6",children:Ia.jsx(Zi,{children:Ia.jsx(eo,{className:"space-y-2",children:Ia.jsx(Ai,{children:e?.navigation?.map((e,a)=>{const t=({item:e,index:a})=>{const t=`${e.path}-${a}-${o??"noalias"}-${l?.id??"nouser"}`,{data:s=!0,isLoading:r}=sl({key:t,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),i=e.permissionCheck&&!s,c=r?S:i?X:e.icon;return i||e.complementaryText,Ia.jsx(ao,{children:i||r?Ia.jsxs(Di,{children:[Ia.jsx(zi,{asChild:!0,children:Ia.jsx(so,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Ia.jsxs("div",{className:"flex w-full items-center gap-3",children:[Ia.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ia.jsx(c,{className:"h-4 w-4 "+(r?"animate-spin":"")})}),Ia.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Ia.jsx(Oi,{children:Ia.jsx("p",{children:r?"Verificando acesso...":"Acesso restrito"})})]}):Ia.jsx(so,{asChild:!0,isActive:(d=e.path,n.pathname===d),size:"lg",className:"h-10",children:Ia.jsxs(ta,{to:e.path,className:"flex w-full items-center gap-3",children:[Ia.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ia.jsx(c,{className:"h-5 w-4"})}),Ia.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path);var d};return Ia.jsx(t,{item:e,index:a},e.path)})})})})})})]})}const ml=c(function({children:e,sidebar:a,sidebarConfig:t,showHeader:s=!0}){const r=o(()=>a||Ia.jsx(dl,{config:t}),[a,t]),n=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Ia.jsx(Yo,{config:t,children:Ia.jsx(Mi,{defaultOpen:!1,style:n,children:Ia.jsxs("div",{className:"min-h-screen flex w-full",children:[r,Ia.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[s&&Ia.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Ia.jsx(al,{})}),Ia.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})});class ul extends d{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,a){rs.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:Ia.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Ia.jsxs(Ba,{className:"w-full max-w-md",children:[Ia.jsxs(Wa,{className:"text-center",children:[Ia.jsx("div",{className:"flex justify-center mb-4",children:Ia.jsx(Le,{className:"h-12 w-12 text-destructive"})}),Ia.jsx(qa,{children:"Algo deu errado"})]}),Ia.jsxs(Qa,{className:"text-center space-y-4",children:[Ia.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Ia.jsx(La,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function fl(){const[e,a]=r([]),[t,s]=r(!1),[o,l]=r(null),[c,d]=r(null);i(()=>{m()},[]);const m=async()=>{try{const e=ms(),{data:t,error:s}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(s)throw s;l(t.threadId),a([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){d("Erro ao inicializar conversa"),sa.error("Erro ao inicializar conversa")}};return{messages:e,isLoading:t,error:c,sendMessage:n(async e=>{if(!o||!e.trim())return;const t={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};a(e=>[...e,t]),s(!0),d(null);try{const t=ms(),{data:s,error:r}=await t.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:o,message:e}});if(r)throw r;const{runId:n}=s,i=await(async e=>{if(!o)return!1;for(let t=0;t<60;t++)try{const a=ms(),{data:t,error:s}=await a.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:o,runId:e}});if(s)throw s;const{status:r}=t;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(a){throw a}throw new Error("Tempo limite excedido")})(n);i&&await(async()=>{if(o)try{const e=ms(),{data:t,error:s}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:o}});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(r){const e=r instanceof Error?r.message:"Erro ao enviar mensagem";d(e),sa.error(e),a(e=>e.filter(e=>e.id!==t.id))}finally{s(!1)}},[o]),threadId:o}}function pl({content:e,className:a}){return Ia.jsx("div",{className:Aa("prose prose-sm max-w-none",a),children:Ia.jsx(wa,{remarkPlugins:[ka],components:{h1:({children:e})=>Ia.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Ia.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Ia.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Ia.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Ia.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Ia.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Ia.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:a,...t})=>e?Ia.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...t,children:a}):Ia.jsx("code",{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...t,children:a}),pre:({children:e})=>Ia.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:a})=>Ia.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Ia.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Ia.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Ia.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function hl(){const[e,a]=r(!1),[t,s]=r(""),{messages:n,isLoading:o,error:c,sendMessage:d}=fl(),m=l(null),u=l(null);i(()=>{if(m.current){const e=m.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[n]),i(()=>{e&&u.current&&u.current.focus()},[e]),i(()=>{const t=t=>{"Escape"===t.key&&e&&a(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]);const f=()=>{t.trim()&&!o&&(d(t),s(""))};return Ia.jsxs(Ia.Fragment,{children:[Ia.jsx(La,{onClick:()=>a(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Ia.jsx(N,{className:"h-6 w-6"}):Ia.jsx(Me,{className:"h-6 w-6"})}),e&&Ia.jsxs(Ba,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Ia.jsxs(Wa,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Ia.jsx(qa,{className:"text-lg font-semibold",children:"Chat Assistant"}),Ia.jsx(La,{variant:"ghost",size:"icon",onClick:()=>a(!1),className:"h-8 w-8",children:Ia.jsx(N,{className:"h-4 w-4"})})]}),Ia.jsxs(Qa,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Ia.jsx(Vr,{ref:m,className:"flex-1 px-4",children:Ia.jsxs("div",{className:"space-y-4 py-4",children:[n.map(e=>Ia.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Ia.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?Ia.jsx(pl,{content:e.content}):Ia.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Ia.jsx("div",{className:"flex justify-start",children:Ia.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Ia.jsxs("div",{className:"flex space-x-2",children:[Ia.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Ia.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Ia.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),c&&Ia.jsx("div",{className:"text-center text-sm text-destructive py-2",children:c})]})}),Ia.jsx("div",{className:"border-t p-4",children:Ia.jsxs("div",{className:"flex space-x-2",children:[Ia.jsx(Ma,{ref:u,value:t,onChange:e=>s(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),f())},placeholder:"Digite sua mensagem...",disabled:o,className:"flex-1"}),Ia.jsx(La,{onClick:f,disabled:o||!t.trim(),size:"icon",children:Ia.jsx(Ue,{className:"h-4 w-4"})})]})})]})]})]})}export{gs as AUTH_CONFIG,Nn as Accordion,kn as AccordionContent,jn as AccordionItem,wn as AccordionTrigger,qo as ActionButton,Ar as ActionMenuItems,hn as Alert,gn as AlertDescription,Ws as AlertDialog,Zs as AlertDialogAction,er as AlertDialogCancel,Ks as AlertDialogContent,Gs as AlertDialogDescription,Xs as AlertDialogFooter,Js as AlertDialogHeader,Qs as AlertDialogOverlay,Hs as AlertDialogPortal,Ys as AlertDialogTitle,qs as AlertDialogTrigger,xn as AlertTitle,al as AppHeader,ml as AppLayout,dl as AppSidebar,Sn as AspectRatio,Fs as AuthErrorInterceptor,Ms as AuthProvider,$s as AuthService,Cn as Avatar,Rn as AvatarFallback,Tn as AvatarImage,kt as Badge,Jr as BaseForm,_n as Breadcrumb,zn as BreadcrumbEllipsis,En as BreadcrumbItem,In as BreadcrumbLink,Pn as BreadcrumbList,An as BreadcrumbPage,Dn as BreadcrumbSeparator,Gr as BulkActionBar,La as Button,bs as CRUD_CONFIG,Hn as Calendar,bn as CallbackPage,Ba as Card,Qa as CardContent,Ha as CardDescription,Ka as CardFooter,Wa as CardHeader,ur as CardSkeleton,qa as CardTitle,hl as ChatbotPage,Nt as Checkbox,Qn as Collapsible,Jn as CollapsibleContent,Kn as CollapsibleTrigger,Ur as ColorPicker,Xn as Command,Yn as CommandDialog,ei as CommandEmpty,ai as CommandGroup,Gn as CommandInput,si as CommandItem,Zn as CommandList,ti as CommandSeparator,ri as CommandShortcut,Ho as CrudCards,Xr as CrudForm,zr as CrudTable,ni as DataList,ar as DeleteConfirmationDialog,Ja as Dialog,Ga as DialogClose,et as DialogContent,rt as DialogDescription,tt as DialogFooter,at as DialogHeader,Za as DialogOverlay,Ya as DialogPortal,st as DialogTitle,Xa as DialogTrigger,br as DropdownMenu,Rr as DropdownMenuCheckboxItem,Cr as DropdownMenuContent,vr as DropdownMenuGroup,Tr as DropdownMenuItem,Pr as DropdownMenuLabel,Nr as DropdownMenuPortal,wr as DropdownMenuRadioGroup,_r as DropdownMenuRadioItem,Er as DropdownMenuSeparator,Ir as DropdownMenuShortcut,jr as DropdownMenuSub,Sr as DropdownMenuSubContent,kr as DropdownMenuSubTrigger,yr as DropdownMenuTrigger,gr as EmptyState,Hr as EntitySelect,ul as ErrorBoundary,sn as FilterBar,nt as Form,ut as FormControl,ot as FormField,dt as FormItem,mt as FormLabel,ft as FormMessage,fr as FormSkeleton,li as Grid,pr as HeaderSkeleton,qr as IconPicker,Ma as Input,Va as Label,Tt as LoadingState,yn as LoginPage,Ss as MESSAGES,pl as MarkdownMessage,Yo as NavigationProvider,ci as PageBreadcrumb,mi as Pagination,ui as PaginationContent,gi as PaginationEllipsis,fi as PaginationItem,pi as PaginationLink,xi as PaginationNext,hi as PaginationPrevious,$r as Popover,Lr as PopoverContent,Fr as PopoverTrigger,bi as Progress,fn as ProtectedRoute,Ns as QUERY_KEYS,xs as QualiexEnrichmentService,Kr as QualiexUserField,yi as RadioGroup,vi as RadioGroupItem,ys as SEARCH_CONFIG,Vr as ScrollArea,Br as ScrollBar,pt as Select,yt as SelectContent,vt as SelectItem,xt as SelectTrigger,ht as SelectValue,Ni as Separator,ji as Sheet,ki as SheetClose,Ri as SheetContent,Ii as SheetDescription,Pi as SheetFooter,_i as SheetHeader,Ci as SheetOverlay,Si as SheetPortal,Ei as SheetTitle,wi as SheetTrigger,Ui as Sidebar,Ji as SidebarContent,Qi as SidebarFooter,Xi as SidebarGroup,Gi as SidebarGroupAction,Zi as SidebarGroupContent,Yi as SidebarGroupLabel,Hi as SidebarHeader,qi as SidebarInput,Wi as SidebarInset,eo as SidebarMenu,ro as SidebarMenuAction,no as SidebarMenuBadge,so as SidebarMenuButton,ao as SidebarMenuItem,io as SidebarMenuSkeleton,oo as SidebarMenuSub,co as SidebarMenuSubButton,lo as SidebarMenuSubItem,Mi as SidebarProvider,Bi as SidebarRail,Ki as SidebarSeparator,hr as SidebarSkeleton,Vi as SidebarTrigger,dr as Skeleton,mo as Slider,uo as SonnerToaster,Ct as Spinner,tn as Stack,Io as Switch,Lo as TabPageContent,Fo as TabPageHeader,$o as TabPageLayout,tr as Table,rr as TableBody,cr as TableCaption,lr as TableCell,nr as TableFooter,or as TableHead,sr as TableHeader,ir as TableRow,Dr as TableRowActions,mr as TableSkeleton,Ao as Tabs,Oo as TabsContent,Do as TabsList,zo as TabsTrigger,jt as Textarea,Mt as Toast,Ut as ToastAction,Vt as ToastClose,Wt as ToastDescription,$t as ToastProvider,Bt as ToastTitle,Ft as ToastViewport,qt as Toaster,Uo as Toggle,Bo as ToggleGroup,Wo as ToggleGroupItem,as as TokenManager,Qt as TokenService,Di as Tooltip,Oi as TooltipContent,Ai as TooltipProvider,zi as TooltipTrigger,nl as assets,wt as badgeVariants,Fa as buttonVariants,Aa as cn,nn as createCrudPage,Qo as createRoutingHandlers,Rs as createService,on as createSimpleSaveHandler,Bs as createSimpleService,mn as crudPresets,$a as debounce,rs as errorService,Oa as formatCurrency,za as formatDatetime,ln as generateCrudConfig,ws as getQualiexConfig,ms as getSupabaseClient,vs as isDevEnvironment,il as logoSrc,hs as qualiexApi,ks as setQualiexConfig,vn as setupQualiexCore,ol as smallLogoSrc,zt as toast,Mo as toggleVariants,Da as trimTextFields,tl as useActiveModules,Us as useAuth,Or as useBaseForm,Vs as useCrud,Ko as useCrudRouting,el as useDebounce,Go as useNavigation,fl as useOpenAIChat,Zo as usePageTitle,sl as usePermissionQuery,Qr as useQualiexUsers,di as useRouteBreadcrumbs,Li as useSidebar,Ot as useToast,un as withPreset};
|
|
10
|
+
*/function At(){return It||(It=1,"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=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"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),h=Symbol.iterator;var g=e.__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 s=n.map(function(e){return String(e)});s.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,s)}("error",e,n)}var y;function b(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 i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return b(e)+".Consumer";case o:return b(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 m:var n=e,p=n._payload,h=n._init;try{return v(h(p))}catch(g){return null}}return null}y=Symbol.for("react.module.reference");var w,k,N,j,S,C,T,I=Object.assign,E=0;function P(){}P.__reactDisabledLog=!0;var A,R=g.ReactCurrentDispatcher;function _(e,t,n){if(void 0===A)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return"\n"+A+e}var D,O=!1,z="function"==typeof WeakMap?WeakMap:Map;function L(e,t){if(!e||O)return"";var n,r=D.get(e);if(void 0!==r)return r;O=!0;var a,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=R.current,R.current=null,function(){if(0===E){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:P,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}E++}();try{if(t){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(p){n=p}Reflect.construct(e,[],i)}else{try{i.call()}catch(p){n=p}e.call(i.prototype)}}else{try{throw Error()}catch(p){n=p}e()}}catch(h){if(h&&n&&"string"==typeof h.stack){for(var o=h.stack.split("\n"),l=n.stack.split("\n"),c=o.length-1,u=l.length-1;c>=1&&u>=0&&o[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(o[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||o[c]!==l[u]){var d="\n"+o[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{O=!1,R.current=a,function(){if(0===--E){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:w}),info:I({},e,{value:k}),warn:I({},e,{value:N}),error:I({},e,{value:j}),group:I({},e,{value:S}),groupCollapsed:I({},e,{value:C}),groupEnd:I({},e,{value:T})})}E<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var f=e?e.displayName||e.name:"",m=f?_(f):"";return"function"==typeof e&&D.set(e,m),m}function F(e,t,n){if(null==e)return"";if("function"==typeof e)return L(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return _(e);switch(e){case u:return _("Suspense");case d:return _("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return L(e.render,!1);case f:return F(e.type,t,n);case m:var r=e,a=r._payload,s=r._init;try{return F(s(a),t,n)}catch(i){}}return""}D=new z;var M=Object.prototype.hasOwnProperty,B={},U=g.ReactDebugCurrentFrame;function $(e){if(e){var t=e._owner,n=F(e.type,e._source,t?t.type:null);U.setExtraStackFrame(n)}else U.setExtraStackFrame(null)}var V=Array.isArray;function H(e){return V(e)}function q(e){return""+e}function W(e){if(function(e){try{return q(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)),q(e)}var Q,K,Y=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function X(e,t,r,a,s){var i,o={},l=null,c=null;for(i 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&&Y.current}(t)),t)M.call(t,i)&&!J.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===o[i]&&(o[i]=u[i])}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})}(o,d),c&&function(e,t){var n=function(){K||(K=!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})}(o,d)}return function(e,t,r,a,s,i,o){var l={$$typeof:n,type:e,key:t,ref:r,props:o,_owner:i,_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:s}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,s,a,Y.current,o)}var G,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,n=F(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""}G=!1;var ae={};function se(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 ie(e,t){if("object"==typeof e)if(H(e))for(var n=0;n<e.length;n++){var r=e[n];ne(r)&&se(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 s,i=a.call(e);!(s=i.next()).done;)ne(s.value)&&se(s.value,t)}}function oe(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 s=Function.call.bind(M);for(var i in e)if(s(e,i)){var o=void 0;try{if("function"!=typeof e[i]){var l=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}o=e[i](t,i,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){o=c}!o||o 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,i,typeof o),$(null)),o instanceof Error&&!(o.message in B)&&(B[o.message]=!0,$(a),x("Failed %s type: %s",n,o.message),$(null))}}(t,e.props,"prop",r,e)}else if(void 0!==n.PropTypes&&!G){G=!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,b){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===s||e===u||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===o||e.$$typeof===l||e.$$typeof===c||e.$$typeof===y||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":H(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=X(e,t,r,g,b);if(null==j)return j;if(w){var S=t.children;if(void 0!==S)if(h)if(H(S)){for(var C=0;C<S.length;C++)ie(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 ie(S,e)}if(M.call(t,"key")){var T=v(e),I=Object.keys(t).filter(function(e){return"key"!==e}),E=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+E])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} />',E,T,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",T),le[T+E]=!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):oe(j),j}var ue=function(e,t,n){return ce(e,t,n,!1)},de=function(e,t,n){return ce(e,t,n,!0)};Pt.Fragment=a,Pt.jsx=ue,Pt.jsxs=de}()),Pt}var Rt=(Et||(Et=1,"production"===process.env.NODE_ENV?Ct.exports=function(){if(St)return Tt;St=1;var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(e,t,r){var o,l={},c=null,u=null;for(o in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,o)&&!i.hasOwnProperty(o)&&(l[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===l[o]&&(l[o]=t[o]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:s.current}}return Tt.Fragment=r,Tt.jsx=o,Tt.jsxs=o,Tt}():Ct.exports=At()),Ct.exports);function _t(...e){return g(h(e))}const Dt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Dt);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=Dt(r);return t}return e},Ot=e=>{if(!e)return"";const t=x(e);if(!y(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"})}`},zt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Lt=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Ft=p("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"}}),Mt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?f:"button";return Rt.jsx(i,{className:_t(Ft({variant:t,size:n,className:e})),ref:s,...a})});Mt.displayName="Button";const Bt=e.forwardRef(({className:e,type:t,...n},r)=>Rt.jsx("input",{type:t,className:_t("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}));Bt.displayName="Input";const Ut=p("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),$t=e.forwardRef(({className:e,...t},n)=>Rt.jsx(v.Root,{ref:n,className:_t(Ut(),e),...t}));$t.displayName=v.Root.displayName;const Vt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Vt.displayName="Card";const Ht=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("flex flex-col space-y-1.5 p-6",e),...t}));Ht.displayName="CardHeader";const qt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h3",{ref:n,className:_t("text-2xl font-semibold leading-none tracking-tight",e),...t}));qt.displayName="CardTitle";const Wt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("p",{ref:n,className:_t("text-sm text-muted-foreground",e),...t}));Wt.displayName="CardDescription";const Qt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("p-6 pt-0",e),...t}));Qt.displayName="CardContent";const Kt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("flex items-center p-6 pt-0",e),...t}));Kt.displayName="CardFooter";const Yt=w.Root,Jt=w.Trigger,Xt=w.Portal,Gt=w.Close,Zt=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Overlay,{ref:n,className:_t("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}));Zt.displayName=w.Overlay.displayName;const en=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Xt,{children:[Rt.jsx(Zt,{}),Rt.jsxs(w.Content,{ref:r,className:_t("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,Rt.jsxs(w.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:[Rt.jsx(k,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));en.displayName=w.Content.displayName;const tn=({className:e,...t})=>Rt.jsx("div",{className:_t("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});tn.displayName="DialogHeader";const nn=({className:e,...t})=>Rt.jsx("div",{className:_t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});nn.displayName="DialogFooter";const rn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Title,{ref:n,className:_t("text-lg font-semibold leading-none tracking-tight",e),...t}));rn.displayName=w.Title.displayName;const an=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Description,{ref:n,className:_t("text-sm text-muted-foreground",e),...t}));an.displayName=w.Description.displayName;const sn=He,on=e.createContext({}),ln=({...e})=>Rt.jsx(on.Provider,{value:{name:e.name},children:Rt.jsx(qe,{...e})}),cn=()=>{const t=e.useContext(on),n=e.useContext(un),{getFieldState:r,formState:a}=Ve(),s=r(t.name,a);if(!t)throw new Error("useFormField should be used within <FormField>");const{id:i}=n;return{id:i,name:t.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...s}},un=e.createContext({}),dn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Rt.jsx(un.Provider,{value:{id:a},children:Rt.jsx("div",{ref:r,className:_t("space-y-2",t),...n})})});dn.displayName="FormItem";const fn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=cn();return Rt.jsx($t,{ref:n,className:_t(r&&"text-destructive",e),htmlFor:a,...t})});fn.displayName="FormLabel";const mn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=cn();return Rt.jsx(f,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});mn.displayName="FormControl";e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=cn();return Rt.jsx("p",{ref:n,id:r,className:_t("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const pn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=cn(),i=a?String(a?.message):t;return i?Rt.jsx("p",{ref:r,id:s,className:_t("text-sm font-medium text-destructive",e),...n,children:i}):null});pn.displayName="FormMessage";const hn=We.Root,gn=We.Value,xn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(We.Trigger,{ref:r,className:_t("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,Rt.jsx(We.Icon,{asChild:!0,children:Rt.jsx(N,{className:"h-4 w-4 opacity-50"})})]}));xn.displayName=We.Trigger.displayName;const yn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(We.ScrollUpButton,{ref:n,className:_t("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(j,{className:"h-4 w-4"})}));yn.displayName=We.ScrollUpButton.displayName;const bn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(We.ScrollDownButton,{ref:n,className:_t("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(N,{className:"h-4 w-4"})}));bn.displayName=We.ScrollDownButton.displayName;const vn=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Rt.jsx(We.Portal,{children:Rt.jsxs(We.Content,{ref:a,className:_t("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:[Rt.jsx(yn,{}),Rt.jsx(We.Viewport,{className:_t("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Rt.jsx(bn,{})]})}));vn.displayName=We.Content.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(We.Label,{ref:n,className:_t("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=We.Label.displayName;const wn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(We.Item,{ref:r,className:_t("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(We.ItemIndicator,{children:Rt.jsx(S,{className:"h-4 w-4"})})}),Rt.jsx(We.ItemText,{children:t})]}));wn.displayName=We.Item.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(We.Separator,{ref:n,className:_t("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=We.Separator.displayName;const kn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Qe.Root,{ref:n,className:_t("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:Rt.jsx(Qe.Indicator,{className:_t("flex items-center justify-center text-current"),children:Rt.jsx(S,{className:"h-4 w-4"})})}));kn.displayName=Qe.Root.displayName;const Nn=e.forwardRef(({className:e,...t},n)=>Rt.jsx("textarea",{className:_t("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}));Nn.displayName="Textarea";const jn=p("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"}}),Sn=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx("div",{ref:r,className:_t(jn({variant:t}),e),...n}));Sn.displayName="Badge";const Cn={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Tn({size:e="md",className:t}){return Rt.jsx(C,{className:_t("animate-spin text-muted-foreground",Cn[e],t)})}function In({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Rt.jsxs("div",{className:_t("relative",n),children:[t,Rt.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Rt.jsx(Tn,{size:a})})]}):"skeleton"===r?Rt.jsx("div",{className:_t("animate-pulse",n),children:Rt.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Rt.jsx("div",{className:_t("flex items-center justify-center py-8",n),children:Rt.jsx(Tn,{size:a})}):Rt.jsx(Rt.Fragment,{children:t})}let En=0;const Pn=new Map,An=e=>{if(Pn.has(e))return;const t=setTimeout(()=>{Pn.delete(e),On({type:"REMOVE_TOAST",toastId:e})},1e6);Pn.set(e,t)},Rn=(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?An(n):e.toasts.forEach(e=>{An(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)}}},_n=[];let Dn={toasts:[]};function On(e){Dn=Rn(Dn,e),_n.forEach(e=>{e(Dn)})}function zn({...e}){const t=(En=(En+1)%Number.MAX_SAFE_INTEGER,En.toString()),n=()=>On({type:"DISMISS_TOAST",toastId:t});return On({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>On({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Ln(){const[t,n]=e.useState(Dn);return e.useEffect(()=>(_n.push(n),()=>{const e=_n.indexOf(n);e>-1&&_n.splice(e,1)}),[t]),{...t,toast:zn,dismiss:e=>On({type:"DISMISS_TOAST",toastId:e})}}const Fn=Ke.Provider,Mn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Viewport,{ref:n,className:_t("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}));Mn.displayName=Ke.Viewport.displayName;const Bn=p("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"}}),Un=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx(Ke.Root,{ref:r,className:_t(Bn({variant:t}),e),...n}));Un.displayName=Ke.Root.displayName;const $n=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Action,{ref:n,className:_t("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}));$n.displayName=Ke.Action.displayName;const Vn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Close,{ref:n,className:_t("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:Rt.jsx(k,{className:"h-4 w-4"})}));Vn.displayName=Ke.Close.displayName;const Hn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Title,{ref:n,className:_t("text-sm font-semibold",e),...t}));Hn.displayName=Ke.Title.displayName;const qn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Description,{ref:n,className:_t("text-sm opacity-90",e),...t}));function Wn(){const{toasts:e}=Ln();return Rt.jsxs(Fn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Rt.jsxs(Un,{...a,children:[Rt.jsxs("div",{className:"grid gap-1",children:[t&&Rt.jsx(Hn,{children:t}),n&&Rt.jsx(qn,{children:n})]}),r,Rt.jsx(Vn,{})]},e)}),Rt.jsx(Mn,{})]})}qn.displayName=Ke.Description.displayName;var Qn=Object.defineProperty;class Kn{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 s=a[1];s.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(s),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(s),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(s),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),s=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 i=!0;if(!s){const e="Access token decode falhou - será tentado novamente nas chamadas de API";n.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(s?.exp&&s.exp<o){const e="Access token expirado - pode precisar de refresh";n.push(e),i=!1}if(a.exp&&a.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:n,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,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?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(Kn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Yn="qualiex_access_token",Jn="qualiex_id_token",Xn="supabase_token",Gn="oauth_state",Zn="oauth_nonce",er="selected_alias",tr="manual_logout",nr={setAccessToken:e=>localStorage.setItem(Yn,e),getAccessToken:()=>localStorage.getItem(Yn),setIdToken:e=>localStorage.setItem(Jn,e),getIdToken:()=>localStorage.getItem(Jn),getSupabaseToken:()=>localStorage.getItem(Xn),setOAuthState:e=>sessionStorage.setItem(Gn,e),getOAuthState:()=>sessionStorage.getItem(Gn),clearOAuthState:()=>sessionStorage.removeItem(Gn),setOAuthNonce:e=>sessionStorage.setItem(Zn,e),getOAuthNonce:()=>sessionStorage.getItem(Zn),clearOAuthNonce:()=>sessionStorage.removeItem(Zn),setSelectedAlias:e=>localStorage.setItem(er,e),getSelectedAlias:()=>localStorage.getItem(er),clearSelectedAlias:()=>localStorage.removeItem(er),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!nr.getAccessToken()||!nr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Xn,e),nr._clearValidationCache()},areAllTokensValid:()=>{const e=nr.getAccessToken(),t=nr.getIdToken();if(!e||!t)return!1;try{const n=Kn.validateTokens(e,t);return!!n.idTokenValid&&(n.accessTokenValid,n.idTokenValid)}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=nr.getAccessToken(),n=nr.getIdToken(),r=nr.getSupabaseToken();return t&&nr.isTokenExpired(t)&&(localStorage.removeItem(Yn),e=!0),n&&nr.isTokenExpired(n)&&(localStorage.removeItem(Jn),e=!0),r&&nr.isTokenExpired(r)&&(localStorage.removeItem(Xn),e=!0),e},clearAll:()=>{localStorage.removeItem(Yn),localStorage.removeItem(Jn),localStorage.removeItem(Xn),localStorage.removeItem(er),localStorage.removeItem(tr),sessionStorage.removeItem(Gn),sessionStorage.removeItem(Zn)},setManualLogout:()=>localStorage.setItem(tr,"true"),isManualLogout:()=>"true"===localStorage.getItem(tr),clearManualLogout:()=>localStorage.removeItem(tr),isTokenExpired:e=>{try{return Kn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{nr._validationCache.isValid=!1,nr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=nr.getSupabaseToken();if(!e)return!1;if(nr.isTokenExpired(e))return nr._clearValidationCache(),nr._handleExpiredToken(),!1;const t=Date.now();return t-nr._validationCache.timestamp<nr._validationCache.cacheValidityMs?nr._validationCache.isValid:(nr._validationCache.isValid=!0,nr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>nr.isSupabaseTokenValid()?nr.getSupabaseToken():null,_handleExpiredToken:()=>{nr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!nr.isSupabaseTokenValid())return null;const e=nr.getSupabaseToken();if(!e)return null;try{const t=Kn.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 nr._handleExpiredToken(),null}},getCompanyId:e=>{const t=nr.extractTokenData();if(!t)return null;if(!e)return t.companyId;const n=nr.getIdToken();if(!n)return null;try{const t=Kn.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=nr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=nr.getIdToken();if(!e)return[];try{const t=Kn.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 rr=Object.defineProperty,ar=(e,t,n)=>((e,t,n)=>t in e?rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const sr=new class{constructor(){ar(this,"errors",[]),ar(this,"toastCount",0),ar(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()&&zn({title:"Erro",description:n,variant:"destructive"})}success(e,t){zn({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 ir=Object.defineProperty,or=(e,t,n)=>((e,t,n)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const lr=import.meta.env.VITE_SUPABASE_URL,cr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,ur=class e{constructor(){or(this,"client"),or(this,"currentToken",null),or(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:cr};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),Ye(lr,cr,{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=nr.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 sr.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};or(ur,"instance");let dr=ur;const fr=()=>dr.getInstance().getClient();var mr=Object.freeze({__proto__:null,getSupabaseClient:fr}),pr=Object.defineProperty,hr=(e,t,n)=>((e,t,n)=>t in e?pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const gr=new class{constructor(){hr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=nr.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 s=await fetch(a.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!s.ok)throw new Error(`API call failed: ${s.status} ${s.statusText}`);return await s.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 sr.handleError("[QualiexApi] Unexpected response format",!1),[];r=n}if(!Array.isArray(r))return sr.handleError("[QualiexApi] Response is not an array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){return sr.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 sr.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const t=nr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):(sr.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}};class xr{static async extractTokenData(){const e=nr.extractTokenData();return e||(sr.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,t){if(!e||0===e.length)return sr.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 sr.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 s=await gr.getUsers(r),i=e.map(e=>{if(e.id_user){const t=s.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}});i.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 i}catch(n){return sr.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 yr={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},br={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},vr={debounceDelay:500},wr=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},kr={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let Nr={enableUserEnrichment:!1,enableUsersApi:!1};const jr=()=>Nr,Sr=e=>{Nr={...Nr,...e}},Cr={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}`}},Tr=["responsible_name"],Ir=e=>Tr.includes(e);function Er(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:s,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:c=!1}=r,u=()=>{if(!nr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return fr().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:r="desc",page:o=1,limit:d=25,...f}=e;let m=u().select(i||"*",{count:"exact"});m=m.eq("is_removed",!1),Object.entries(f).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?m=m.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?m=m.not(e,"is",null):"is_null"===t.operator&&(m=m.is(e,null)):null!==t&&(m=m.eq(e,t)))}),m=((e,t)=>{if(t&&s.length>0){const n=s.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(m,t);n.includes(".")||Ir(n)||(m=m.order(n,{ascending:"asc"===r})),m=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(m,o,d);const{data:p,error:h,count:g}=await m;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}})(p||[],g,o,d);const y=jr();if(c&&y.enableUserEnrichment&&l&&x.data.length>0){if(x.data.some(e=>e.id_user)){const t=n&&n.includes(".");if(n&&(Ir(n)||t)){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},s=await this.getAll(a);if(!s?.data?.length)return s;const i=await xr.enrichWithResponsibleNames(s.data,{entityName:l});let c;c=t?i.sort((e,t)=>{const a=n.split(".").reduce((e,t)=>e?.[t],e)||"",s=n.split(".").reduce((e,t)=>e?.[t],t)||"",i=String(a).localeCompare(String(s),"pt-BR");return"asc"===r?i:-i}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",s=r[t]||"",i=a.localeCompare(s,"pt-BR",{sensitivity:"base"});return"asc"===n?i:-i}))(i,n,r);const u=((e,t=1,n=25)=>{const r=(t-1)*n,a=r+n,s=e.slice(r,a);return{data:s,pagination:{currentPage:t,totalPages:Math.ceil(e.length/n),totalItems:s.length,totalCount:e.length,itemsPerPage:n,hasNextPage:a<e.length,hasPreviousPage:t>1}}})(c,o,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 xr.enrichWithResponsibleNames(x.data,{entityName:l});x={...x,data:a}}}return x},async getById(e){const{data:t,error:n}=await u().select(i||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=Dt(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:s}=await u().insert(n).select().single();if(s)throw new Error(`Error creating ${a}: ${s.message}`);if(!r)throw new Error(`No data returned from create ${a} operation`);return r},async update(e,t){const n={...Dt(t),updated_at:(new Date).toISOString()},{data:r,error:s}=await u().update(n).eq("id",e).select().single();if(s)throw new Error(`Error updating ${a}: ${s.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 Pr=()=>{nr.clearManualLogout()},Ar=import.meta.env.VITE_SUPABASE_URL,Rr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;class _r{static async generateToken(e,t,n,r=!1){try{if(!r){const e=nr.getSupabaseToken();if(e&&nr.isSupabaseTokenValid())return e}const a=Ye(Ar,Rr,{auth:{persistSession:!1,autoRefreshToken:!1}}),{data:s,error:i}=await a.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(n?.(),null):s?.access_token&&s.access_token?(nr.setSupabaseToken(s.access_token),s.access_token):null}catch(a){return a instanceof Error&&(a.message.includes("401")||a.message.includes("Unauthorized"))&&n?.(),null}}}var Dr=Object.defineProperty,Or=(e,t,n)=>((e,t,n)=>t in e?Dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class zr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=nr.getAccessToken(),t=nr.getSelectedAlias();if(!e||!t)return null;const n=await _r.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(nr.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}Or(zr,"isRegenerating",!1),Or(zr,"onLogoutCallback",null);const Lr=class{static async initialize(){try{if(!nr.hasAllTokens()||!nr.areAllTokensValid())return nr.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null};const e=nr.getAccessToken(),t=nr.getIdToken();Pr();const n=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),a=this.extractAliasFromAccessToken(e),s=nr.extractTokenData(),i=s?.alias;let o=null;if(i&&r.some(e=>e.alias===i))o=i;else{const e=nr.getSelectedAlias(),t=e&&r.some(t=>t.alias===e);o=t?e:a||r[0]?.alias||null}!nr.isSupabaseTokenValid()&&o&&await zr.attemptRegeneration();let l=null;if(o){const e=nr.getCompanyId(o),t=r.find(e=>e.alias===o);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}return{isAuthenticated:!0,isLoading:!1,user:n,alias:o,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 mr}),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=nr.generateOAuthState();nr.setOAuthState(e);const t=nr.generateOAuthNonce();nr.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(yr.oauth.authUrl);r.searchParams.set("client_id",yr.oauth.clientId),r.searchParams.set("response_type",yr.oauth.responseType),r.searchParams.set("scope",yr.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),wr(),window.location.href=r.toString()}static async processCallback(){try{if(nr.hasAllTokens()){if(!nr.getValidSupabaseToken()){nr.getAccessToken();await zr.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"),s=n("error");if(s)throw new Error(`Erro OAuth: ${s}`);if(!r||!a)throw new Error("Tokens não encontrados na URL de callback");nr.setAccessToken(r),nr.setIdToken(a),Pr();const i=this.extractAliasFromAccessToken(r);if(i)nr.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");nr.setSelectedAlias(e[0].alias)}if(!await zr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return nr.clearOAuthState(),nr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){nr.setManualLogout(),nr.clearAll(),window.location.href="/login"}static decodeToken(e){return Kn.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}};zr.setLogoutCallback(()=>{Lr.logout()});let Fr=Lr;class Mr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(nr.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 Br=n(void 0),Ur=({children:e})=>{const[t,n]=a({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null});let r=null;try{r=Je()}catch{}const[l,c]=a(!1),[u,d]=a(0),f=s(e=>{n(t=>({...t,...e}))},[]),m=s(e=>{n(t=>({...t,isLoading:e}))},[]),p=s(()=>{n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null})},[]),h=s(async e=>{try{m(!0);const t=nr.getAccessToken();if(!t)return;const n=await _r.generateToken(t,e.alias,void 0,!0);if(!n)return;nr.setSupabaseToken(n),nr.setSelectedAlias(e.alias);const a=nr.extractTokenData(),s=a?.alias||e.alias,i={id:a?.companyId||nr.getCompanyId(e.alias)||e.id,name:e.name,alias:s};f({alias:s,selectedUnit:i}),r&&(await r.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{m(!1)}},[f,r,m]),g=s(async()=>await Fr.processCallback(),[]),x=s(async()=>{Fr.logout(),p(),r&&await r.clear()},[p,r]),y=s(e=>{c(e)},[]),b=s(()=>{d(e=>e+1)},[]),v=s(()=>{d(e=>e+1)},[]);i(()=>{if(!t.isAuthenticated)return;let e=!0;const n=setInterval(()=>{e&&(nr.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(n)}},[t.isAuthenticated,x]),i(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Fr.initialize();if(!e)return;t&&t.isAuthenticated?f({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias}):e&&m(!1)}catch(t){e&&(Mr.handleError(t),m(!1))}})(),()=>{e=!1}},[f,m,x]);const w=o(()=>({...t,logout:x,processCallback:g,switchUnit:h,availableUnits:t.companies,isSearchVisible:l,setSearchVisible:y,clearSearch:b,refreshData:v}),[t.user,t.companies,t.alias,t.isAuthenticated,t.isLoading,t.selectedUnit,t.userId,t.userAlias,x,g,h,l,y,b,v]);return Rt.jsx(Br.Provider,{value:w,children:e})},$r=()=>{const e=r(Br);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Vr({queryKey:e,service:t,entityName:n,searchFields:r,additionalFilters:i={},onSuccess:l}){const[c,u]=et(),d=Je(),{alias:f,userId:m}=$r(),p=c.get("search")||"",h=c.get("sortField")||br.sorting.defaultField,g=c.get("sortDirection")||br.sorting.defaultDirection,x=parseInt(c.get("page")||"1"),y=parseInt(c.get("limit")||String(br.pagination.defaultPageSize)),b=p,v=o(()=>({search:b,sortField:h,sortDirection:g,page:x,limit:y,...i}),[b,h,g,x,y,i]),w=s(()=>t.getAll(v),[t,v]),k=Xe({queryKey:[e,f,m,v],queryFn:w});if(!k)throw new Error(`useCrud: Query initialization failed for "${n}". Ensure QueryClientProvider is configured in your app root.`);const N=Ge({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),at.success(Cr.success.created(n)),l?.()},onError:e=>{at.error(`${Cr.error.create(n)}: ${e.message}`)}}),j=Ge({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),at.success(Cr.success.updated(n)),l?.()},onError:e=>{at.error(`${Cr.error.update(n)}: ${e.message}`)}}),S=Ge({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),at.success(Cr.success.deleted(n))},onError:e=>{at.error(`${Cr.error.delete(n)}: ${e.message}`)}}),C=s(e=>{const t={...Object.fromEntries(c)};Object.entries(e).forEach(([e,n])=>{""===n||0===n?delete t[e]:t[e]=String(n)}),u(t)},[c,u]),T=s(e=>{C({search:e,page:1})},[C]),I=s(e=>{C({sortField:e,sortDirection:h===e&&"asc"===g?"desc":"asc",page:1})},[h,g,C]),E=s(e=>{C({page:e})},[C]),P=s(e=>{C({limit:e,page:1})},[C]),A=s(()=>{u({})},[u]),[R,_]=a([]),D=s(e=>{_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),O=s(()=>{const e=k?.data?.data.map(e=>e.id)||[];_(t=>t.length===e.length?[]:e)},[k?.data?.data]),z=s(()=>{_([])},[]),L=o(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),F=Ge({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,r)=>{d.invalidateQueries({queryKey:[e]}),at.success(`${r.length} ${n}(s) deletado(s) com sucesso`),z()},onError:e=>{at.error(`Erro ao deletar itens: ${e.message}`)}});return{entities:k?.data?.data||[],pagination:{currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||br.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:N?.isPending??!1,isUpdating:j?.isPending??!1,isDeleting:S?.isPending??!1,error:k?.error||null,searchTerm:p,sortField:h,sortDirection:g,currentPage:x,itemsPerPage:y,createEntity:N.mutate,updateEntity:(e,t)=>j.mutate({id:e,data:t}),deleteEntity:S.mutate,handleSearch:T,handleSort:I,handlePageChange:E,handleItemsPerPageChange:P,clearFilters:A,refetch:k.refetch,selectedIds:R,selectItem:D,selectAll:O,clearSelection:z,isAllSelected:L,bulkDelete:F.mutate,isBulkDeleting:F.isPending}}function Hr(e){const t=Er({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)=>Vr({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const qr=it.Root,Wr=it.Trigger,Qr=it.Portal,Kr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Overlay,{className:_t("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}));Kr.displayName=it.Overlay.displayName;const Yr=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(Qr,{children:[Rt.jsx(Kr,{}),Rt.jsx(it.Content,{ref:n,className:_t("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})]}));Yr.displayName=it.Content.displayName;const Jr=({className:e,...t})=>Rt.jsx("div",{className:_t("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});Jr.displayName="AlertDialogHeader";const Xr=({className:e,...t})=>Rt.jsx("div",{className:_t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Xr.displayName="AlertDialogFooter";const Gr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Title,{ref:n,className:_t("text-lg font-semibold",e),...t}));Gr.displayName=it.Title.displayName;const Zr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Description,{ref:n,className:_t("text-sm text-muted-foreground",e),...t}));Zr.displayName=it.Description.displayName;const ea=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Action,{ref:n,className:_t(Ft(),e),...t}));ea.displayName=it.Action.displayName;const ta=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Cancel,{ref:n,className:_t(Ft({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));ta.displayName=it.Cancel.displayName;const na=({open:e,onOpenChange:t,item:n,onConfirm:r,entityName:s="item",isDeleting:o=!1})=>{const[l,c]=a("");i(()=>{e||c("")},[e]);const u=()=>{c(""),t(!1)},d=l===n?.title;return n?Rt.jsx(qr,{open:e,onOpenChange:u,children:Rt.jsxs(Yr,{className:"sm:max-w-[500px]",children:[Rt.jsx(Jr,{children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Rt.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Rt.jsx("div",{className:"flex-1",children:Rt.jsx(Gr,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Rt.jsx(Zr,{asChild:!0,children:Rt.jsxs("div",{className:"space-y-4",children:[Rt.jsxs("div",{className:"text-sm text-muted-foreground",children:[Rt.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",s,":"]}),Rt.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Rt.jsx("p",{className:"font-medium text-foreground",children:n.title})})]}),Rt.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Rt.jsxs("div",{className:"flex items-start space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Rt.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Rt.jsxs("div",{className:"text-sm text-orange-800",children:[Rt.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Rt.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})]})]})}),Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsxs($t,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",Rt.jsxs("strong",{children:['"',n.title,'"']})," abaixo:"]}),Rt.jsx(Bt,{id:"confirmation",type:"text",value:l,onChange:e=>c(e.target.value),placeholder:`Digite: ${n.title}`,className:"w-full"})]})]})}),Rt.jsxs(Xr,{children:[Rt.jsx(ta,{onClick:u,children:"Cancelar"}),Rt.jsx(ea,{onClick:()=>{n&&l===n.title&&(r(n),c(""),t(!1))},disabled:!d||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${s}`})]})]})}):null},ra=e.forwardRef(({className:e,...t},n)=>Rt.jsx("table",{ref:n,className:_t("w-full caption-bottom text-sm",e),...t}));ra.displayName="Table";const aa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("thead",{ref:n,className:_t("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));aa.displayName="TableHeader";const sa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tbody",{ref:n,className:_t("[&_tr:last-child]:border-0",e),...t}));sa.displayName="TableBody";const ia=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tfoot",{ref:n,className:_t("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));ia.displayName="TableFooter";const oa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tr",{ref:n,className:_t("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));oa.displayName="TableRow";const la=e.forwardRef(({className:e,...t},n)=>Rt.jsx("th",{ref:n,className:_t("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}));la.displayName="TableHead";const ca=e.forwardRef(({className:e,...t},n)=>Rt.jsx("td",{ref:n,className:_t("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ca.displayName="TableCell";const ua=e.forwardRef(({className:e,...t},n)=>Rt.jsx("caption",{ref:n,className:_t("mt-4 text-sm text-muted-foreground",e),...t}));function da({className:e,...t}){return Rt.jsx("div",{className:_t("animate-pulse rounded-md bg-muted",e),...t})}function fa({rows:e=5,columns:t=4}){return Rt.jsx("div",{className:"w-full",children:Rt.jsxs("div",{className:"rounded-md border",children:[Rt.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(da,{className:"h-4 w-24"},t))})}),Rt.jsx("div",{children:Array.from({length:e}).map((e,n)=>Rt.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(da,{className:"h-4 w-20"},t))})},n))})]})})}function ma({count:e=3}){return Rt.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Rt.jsxs(Vt,{children:[Rt.jsxs(Ht,{children:[Rt.jsx(da,{className:"h-4 w-3/4"}),Rt.jsx(da,{className:"h-3 w-1/2"})]}),Rt.jsx(Qt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(da,{className:"h-3 w-full"}),Rt.jsx(da,{className:"h-3 w-2/3"})]})})]},t))})}function pa({fields:e=4}){return Rt.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(da,{className:"h-4 w-24"}),Rt.jsx(da,{className:"h-10 w-full"})]},t)),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(da,{className:"h-10 w-20"}),Rt.jsx(da,{className:"h-10 w-20"})]})]})}function ha(){return Rt.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx(da,{className:"h-8 w-8 rounded-full"}),Rt.jsx(da,{className:"h-6 w-32"})]}),Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(da,{className:"h-8 w-8"}),Rt.jsx(da,{className:"h-8 w-24"})]})]})}function ga(){return Rt.jsx("div",{className:"w-64 border-r bg-muted/10",children:Rt.jsxs("div",{className:"p-4",children:[Rt.jsx(da,{className:"h-8 w-32 mb-6"}),Rt.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Rt.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Rt.jsx(da,{className:"h-4 w-4"}),Rt.jsx(da,{className:"h-4 w-20"})]},t))})]})})}ua.displayName="TableCaption";const xa={default:E,search:I,error:T};function ya({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:xa[s];return Rt.jsxs("div",{className:_t("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Rt.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Rt.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Rt.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Rt.jsx(Mt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ba=ot.Root,va=ot.Trigger,wa=ot.Group,ka=ot.Portal,Na=ot.Sub,ja=ot.RadioGroup,Sa=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Rt.jsxs(ot.SubTrigger,{ref:a,className:_t("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,Rt.jsx(P,{className:"ml-auto h-4 w-4"})]}));Sa.displayName=ot.SubTrigger.displayName;const Ca=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.SubContent,{ref:n,className:_t("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}));Ca.displayName=ot.SubContent.displayName;const Ta=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(ot.Portal,{children:Rt.jsx(ot.Content,{ref:r,sideOffset:t,className:_t("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})}));Ta.displayName=ot.Content.displayName;const Ia=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(ot.Item,{ref:r,className:_t("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}));Ia.displayName=ot.Item.displayName;const Ea=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Rt.jsxs(ot.CheckboxItem,{ref:a,className:_t("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(ot.ItemIndicator,{children:Rt.jsx(S,{className:"h-4 w-4"})})}),t]}));Ea.displayName=ot.CheckboxItem.displayName;const Pa=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(ot.RadioItem,{ref:r,className:_t("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(ot.ItemIndicator,{children:Rt.jsx(A,{className:"h-2 w-2 fill-current"})})}),t]}));Pa.displayName=ot.RadioItem.displayName;const Aa=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(ot.Label,{ref:r,className:_t("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Aa.displayName=ot.Label.displayName;const Ra=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Separator,{ref:n,className:_t("-mx-1 my-1 h-px bg-muted",e),...t}));Ra.displayName=ot.Separator.displayName;const _a=({className:e,...t})=>Rt.jsx("span",{className:_t("ml-auto text-xs tracking-widest opacity-60",e),...t});_a.displayName="DropdownMenuShortcut";const Da=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,renderAs:s})=>{const i=[];if(e){const t={icon:R,label:"Editar",onClick:e};i.push(t)}if(n){const e={icon:r?_:D,label:r?"Inativar":"Ativar",onClick:n};i.push(e)}if(a&&t){const e={icon:O,label:"Remover",onClick:t,destructive:!0};i.push(e)}return"dropdown"===s?Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(Ia,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Rt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(Mt,{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:[Rt.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},Oa=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>Rt.jsxs(ba,{children:[Rt.jsx(va,{asChild:!0,children:Rt.jsx(Mt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Rt.jsx(z,{size:12})})}),Rt.jsx(Ta,{align:"end",children:Rt.jsx(Da,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),za=l(({checked:e,onCheckedChange:t})=>Rt.jsx(kn,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),La=({manager:e,columns:t,onEdit:n,onView:r,onToggleStatus:o,onDelete:l,renderActions:d,enableBulkActions:f=!1})=>{const[m,p]=a(!1),[h,g]=a(null),x=c(null),y=c(0),b=c(0),v=s(()=>{x.current&&(y.current=x.current.scrollTop),b.current=window.scrollY},[]);u(()=>{x.current&&y.current>0&&(x.current.scrollTop=y.current),b.current>0&&window.scrollTo(0,b.current)},[e.selectedIds]);const w=s(t=>{v(),e.selectItem(t)},[v,e]),k=s(()=>{v(),e.selectAll()},[v,e]);i(()=>{const e=()=>p(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i(()=>{const e=()=>g(null);if(h)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[h]);const N=(()=>{t.length;let e=0;const n=t.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,n.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})();return m?e.isLoading?Rt.jsx(ma,{count:3}):0===e.entities.length?Rt.jsx(ya,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Rt.jsxs("div",{className:"space-y-4",children:[e.entities.map(a=>Rt.jsx(Vt,{className:_t("overflow-hidden cursor-pointer hover:bg-muted/50",f&&e.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),f||n?.(a)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),g({x:e.clientX,y:e.clientY,item:a})},children:Rt.jsx(Qt,{className:"p-4",children:Rt.jsxs("div",{className:"flex items-start gap-3",children:[f&&Rt.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Rt.jsx(za,{checked:e.selectedIds.includes(a.id),onCheckedChange:()=>w(a.id)})}),Rt.jsxs("div",{className:"flex-1",children:[t.map(e=>Rt.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Rt.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Rt.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(a):a[e.key]})]},String(e.key))),(n||r||d)&&Rt.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(a):Rt.jsx(Oa,{onEdit:n?()=>{n(a)}:void 0,onDelete:l?()=>l(a):void 0,onToggleStatus:o?()=>o(a):void 0,isActive:a.is_actived})})]})]})})},a.id)),h&&Rt.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:h.x,top:h.y},onClick:e=>e.stopPropagation(),children:Rt.jsx(Da,{onEdit:n?()=>{n(h.item),g(null)}:void 0,onDelete:l?()=>{l(h.item),g(null)}:void 0,onToggleStatus:o?()=>{o(h.item),g(null)}:void 0,isActive:h.item.is_actived,canDelete:!!l,renderAs:"context"})})]}):Rt.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Rt.jsx(fa,{rows:5,columns:t.length}):Rt.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Rt.jsx("div",{className:"flex-1 overflow-auto",ref:x,children:Rt.jsxs(ra,{className:"table-auto",children:[Rt.jsxs("colgroup",{children:[f&&Rt.jsx("col",{style:{width:"50px"}}),N.map((e,t)=>Rt.jsx("col",{style:e.style},t)),Rt.jsx("col",{style:{width:"100px"}})]}),Rt.jsx(aa,{children:Rt.jsxs(oa,{children:[f&&Rt.jsx(la,{className:"w-[50px]",children:Rt.jsx(za,{checked:e.isAllSelected,onCheckedChange:k})}),t.map(t=>{return Rt.jsx(la,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Rt.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),e.sortField!==n?Rt.jsx(L,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Rt.jsx(F,{size:14,className:"ml-1"}):Rt.jsx(M,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Rt.jsx(la,{className:"w-[100px] text-center",children:"Ações"})]})}),Rt.jsx(sa,{children:0===e.entities.length?Rt.jsx(oa,{children:Rt.jsx(ca,{colSpan:t.length+1,className:"h-32",children:Rt.jsx(ya,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(r=>Rt.jsxs(oa,{className:_t("cursor-pointer hover:bg-muted/50",f&&e.selectedIds.includes(r.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),f||n?.(r)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),g({x:e.clientX,y:e.clientY,item:r})},children:[f&&Rt.jsx(ca,{onClick:e=>e.stopPropagation(),children:Rt.jsx(za,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>w(r.id)})}),t.map(e=>Rt.jsx(ca,{className:e.className,children:e.render?e.render(r):r[e.key]},String(e.key))),Rt.jsx(ca,{className:"text-center",children:d?d(r):Rt.jsx(Oa,{onEdit:n?()=>n(r):void 0,onDelete:l?()=>l(r):void 0,onToggleStatus:o?()=>o(r):void 0,isActive:r.is_actived})})]},r.id))})]})})}),h&&Rt.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:h.x,top:h.y},onClick:e=>e.stopPropagation(),children:Rt.jsx(Da,{onEdit:n?()=>{n(h.item),g(null)}:void 0,onDelete:l?()=>{l(h.item),g(null)}:void 0,onToggleStatus:o?()=>{o(h.item),g(null)}:void 0,isActive:h.item.is_actived,canDelete:!!l,renderAs:"context"})})]})};function Fa(e,t,n,r){const[s,l]=a({}),[c,u]=a({}),d=o(()=>e,[e]),f=e=>e instanceof Date&&!isNaN(e.getTime()),m=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{}}},p=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(n){return m(e)}},h=(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){}}};i(()=>{if(!r)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},a=e(d),s={};a.forEach(e=>{let n;if(t&&void 0!==t[e.name]){if(n=t[e.name],null==n&&(n=""),"date"===e.type&&n)if("string"==typeof n){const e=new Date(n);f(e)&&(n=e.toISOString().split("T")[0])}else f(n)&&(n=n.toISOString().split("T")[0])}else n=m(e);s[e.name]=n}),a.forEach(e=>{const t=p(e,s);void 0!==t&&(s[e.name]=t)}),t&&Object.keys(t).forEach(e=>{a.find(t=>t.name===e)||void 0===t[e]||(s[e]=t[e])}),l(s),u({}),n&&n(s)},[d,t,n,r]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},x=()=>{const e=g(d),t={};return e.forEach(e=>{const n=h(e,s[e.name],s);n&&(t[e.name]=n)}),u(t),0===Object.keys(t).length};return{formData:s,errors:c,updateField:(e,t)=>{l(r=>{const a={...r,[e]:t},s=((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(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,a);return n&&n(s),s}),c[e]&&u(t=>{const n={...t};return delete n[e],n});const r=g(d).find(t=>t.name===e);if(r){const n=h(r,t,s);n&&u(t=>({...t,[e]:n}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(s)}}}const Ma=lt.Root,Ba=lt.Trigger,Ua=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>Rt.jsx(lt.Portal,{children:Rt.jsx(lt.Content,{ref:a,align:t,sideOffset:n,className:_t("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})}));Ua.displayName=lt.Content.displayName;const $a=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Va=({value:e="#3b82f6",onChange:t,label:n})=>Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx($t,{children:n}),Rt.jsxs(Ma,{children:[Rt.jsx(Ba,{asChild:!0,children:Rt.jsxs(Mt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Rt.jsx(Ua,{className:"w-64",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx($t,{htmlFor:"color-input",children:"Cor personalizada"}),Rt.jsx(Bt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Rt.jsxs("div",{children:[Rt.jsx($t,{children:"Cores predefinidas"}),Rt.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:$a.map(e=>Rt.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))})]})]})})]})]}),Ha=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(ct.Root,{ref:r,className:_t("relative overflow-hidden",e),...n,children:[Rt.jsx(ct.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Rt.jsx(qa,{}),Rt.jsx(ct.Corner,{})]}));Ha.displayName=ct.Root.displayName;const qa=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Rt.jsx(ct.ScrollAreaScrollbar,{ref:r,orientation:t,className:_t("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:Rt.jsx(ct.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));qa.displayName=ct.ScrollAreaScrollbar.displayName;const Wa={Star:Ae,Heart:Pe,Home:Ee,User:Ie,Settings:Te,Mail:Ce,Phone:Se,Calendar:je,MapPin:Ne,Camera:ke,Image:we,Music:ve,Video:be,Book:ye,Bookmark:xe,Search:I,Filter:ge,Edit:R,Trash2:O,Plus:he,Minus:pe,Check:S,X:k,ChevronDown:N,ChevronUp:j,ChevronLeft:me,ChevronRight:P,ArrowUp:F,ArrowDown:M,ArrowLeft:fe,ArrowRight:de,Clock:ue,Bell:ce,AlertCircle:T,Info:le,HelpCircle:oe,Download:ie,Upload:se,Share:ae,Copy:re,Save:ne,FileText:te,Folder:ee,FolderOpen:Z,Archive:G,Lock:X,Unlock:J,Eye:Y,EyeOff:K,Shield:Q,Key:W,Zap:q,Flame:H,Sparkles:V,Award:$,Trophy:U,Target:B},Qa=({value:e="Star",onChange:t,label:n})=>{const[r,s]=a(""),i=Object.entries(Wa).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=Wa[e]||Ae;return Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx($t,{children:n}),Rt.jsxs(Ma,{children:[Rt.jsx(Ba,{asChild:!0,children:Rt.jsxs(Mt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Rt.jsx(Ua,{className:"w-80",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx($t,{htmlFor:"icon-search",children:"Buscar ícone"}),Rt.jsx(Bt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>s(e.target.value)})]}),Rt.jsx(Ha,{className:"h-48",children:Rt.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Rt.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(e===n?"border-primary bg-primary/10":"border-border"),onClick:()=>t?.(n),title:n,children:Rt.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})};function Ka({value:e,onChange:t,items:n,isLoading:r=!1,error:s=null,getItemValue:i,getItemLabel:l,searchPlaceholder:c="Buscar...",emptyMessage:u="Nenhum item disponível",noResultsMessage:d="Nenhum resultado encontrado",sortItems:f,placeholder:m="Selecionar...",disabled:p=!1,className:h}){const[g,x]=a(""),y=o(()=>{const e=f?[...n].sort(f):[...n].sort((e,t)=>l(e).localeCompare(l(t),"pt-BR"));if(!g.trim())return e;const t=g.toLowerCase();return e.filter(e=>l(e).toLowerCase().includes(t))},[n,g,f,l]);return r?Rt.jsx(da,{className:_t("h-10 w-full",h)}):s?Rt.jsxs("div",{className:_t("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Rt.jsx(T,{className:"h-4 w-4 text-destructive"}),Rt.jsx("span",{className:"text-sm text-destructive",children:s.message||"Erro ao carregar dados"})]}):Rt.jsxs(hn,{value:e,onValueChange:t,disabled:p||0===n.length,children:[Rt.jsx(xn,{className:h,children:Rt.jsx(gn,{placeholder:m})}),Rt.jsxs(vn,{children:[Rt.jsx("div",{className:"px-2 pb-2",children:Rt.jsxs("div",{className:"relative",children:[Rt.jsx(I,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Rt.jsx(Bt,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Rt.jsx(wn,{value:"no-items",disabled:!0,children:g?d:u}):y.map(e=>Rt.jsx(wn,{value:i(e),children:l(e)},i(e)))]})]})}const Ya=(e={})=>{const{user:t,alias:n}=$r(),r=jr(),{enabled:a=r.enableUsersApi}=e;return Xe({queryKey:["qualiex-users",n],queryFn:()=>gr.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},Ja=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=Ya({enabled:s});return Rt.jsx(Ka,{value:e,onChange:t,items:i,isLoading:o,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 Xa({title:e,sections:n,initialData:r,onSubmit:i,onCancel:l,open:c,submitButtonText:u="Salvar",isLoading:d=!1,usersData:f}){const[m,p]=a(n?.[0]?.id||""),h=o(()=>n&&Array.isArray(n)?n.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[n]),{formData:g,errors:x,updateField:y,handleSubmit:b}=Fa(h,r,void 0,c),v=o(()=>n&&Array.isArray(n)?n.map(e=>({...e,disabled:e.condition?!e.condition(g):e.disabled||!1})):[],[n,g]),w=o(()=>{const e=v.find(e=>e.id===m);if(e&&!e.disabled)return m;const t=v.find(e=>!e.disabled);return t?.id||m},[v,m]);t.useEffect(()=>{w!==m&&p(w)},[w,m]);const k=v.find(e=>e.id===w),N=e=>{const t=(e.computedValue,g[e.name]),n=void 0!==t?t:"",r=x[e.name];switch(e.type){case"group":return Rt.jsxs("div",{className:"space-y-2",children:[e.label,Rt.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>N(e))})]},e.name);case"user-select":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Ja,{value:n||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Nn,{id:e.name,value:n||"",onChange:t=>{y(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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsxs(hn,{value:String(n),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Rt.jsx(xn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Rt.jsx(gn,{placeholder:e.placeholder})}),Rt.jsx(vn,{children:e.options?.map(e=>Rt.jsx(wn,{value:e.value,children:e.label},e.value))})]}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Bt,{id:e.name,type:"date",value:String(n),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:_t("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"single-responsible-select":const t=jr();return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Ja,{value:String(n),onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":"",enabled:t.enableUsersApi}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"simple-qualiex-user-field":const a=jr();return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Ja,{value:n??"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":"",enabled:a.enableUsersApi}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Rt.jsxs("div",{children:[Rt.jsxs($t,{htmlFor:e.name,children:[e.label," ",e.required&&Rt.jsx("span",{className:"text-destructive",children:"*"})]}),Rt.jsx(Bt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Rt.jsxs("div",{children:[Rt.jsx(Va,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Rt.jsxs("div",{children:[Rt.jsx(Qa,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>y(e.name,t)}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"number":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Bt,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);y(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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx($t,{htmlFor:e.name,children:e.label}),Rt.jsx(Bt,{id:e.name,type:"text",value:n||"",onChange:t=>{y(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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},j=s(()=>{if(!k)return null;if(k.disabled)return Rt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Rt.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Rt.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Rt.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Rt.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(k.component){const e=k.component;return Rt.jsx(e,{formData:g,updateField:y,errors:x,users:f,disabled:k.disabled})}return Rt.jsx("div",{className:"space-y-3",children:k.fields.map(N)})},[k,g,y,x,f,N]),S=Rt.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Rt.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Rt.jsx("div",{className:"flex space-x-2",children:v.map(e=>Rt.jsx(Mt,{variant:w===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=v.find(t=>t.id===e);t&&!t.disabled&&p(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?Rt.jsx("div",{className:"flex items-center justify-center py-12",children:Rt.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Rt.jsxs("form",{onSubmit:b(i),className:"space-y-3 md:space-y-4",children:[j(),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(Mt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Rt.jsx(Mt,{type:"submit",disabled:d,children:u})]})]})})]});return Rt.jsx(Yt,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Rt.jsxs(en,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Rt.jsxs(tn,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Rt.jsx(rn,{className:"text-white",children:e}),Rt.jsx(an,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Ga({open:e,title:t,sections:n,initialData:r,onSubmit:a,onCancel:s,isLoading:i=!1,submitButtonText:o="Salvar"}){return Rt.jsx(Xa,{open:e,title:t,sections:n,initialData:r,onSubmit:a,onCancel:s,isLoading:i,submitButtonText:o})}const Za=({manager:e})=>{const{pagination:t={totalItems:0,totalPages:1},currentPage:n=1,itemsPerPage:r=10,handlePageChange:a=()=>{},handleItemsPerPageChange:s=()=>{}}=e,{totalItems:i=0,totalPages:o=1}=t,l=i>0?(n-1)*r+1:0,c=Math.min(n*r,i);return Rt.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:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx("span",{children:"Itens por página"}),Rt.jsxs(hn,{value:r.toString(),onValueChange:e=>s(Number(e)),children:[Rt.jsx(xn,{className:"w-20 h-8 border-border",children:Rt.jsx(gn,{})}),Rt.jsxs(vn,{children:[Rt.jsx(wn,{value:"10",children:"10"}),Rt.jsx(wn,{value:"25",children:"25"}),Rt.jsx(wn,{value:"50",children:"50"}),Rt.jsx(wn,{value:"100",children:"100"})]})]})]}),Rt.jsx("div",{className:"flex-1 flex justify-center",children:Rt.jsx("span",{children:i>0?`${l}-${c} de ${i} itens (página ${n} de ${o})`:"0 itens"})}),Rt.jsxs("div",{className:"flex items-center space-x-1",children:[Rt.jsx(Mt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===n,children:Rt.jsx(Re,{className:"h-4 w-4"})}),Rt.jsx(Mt,{variant:"outline",size:"sm",onClick:()=>a(Math.max(1,n-1)),disabled:1===n,children:Rt.jsx(me,{className:"h-4 w-4"})}),Rt.jsx(Mt,{variant:"outline",size:"sm",onClick:()=>a(Math.min(o,n+1)),disabled:n===o,children:Rt.jsx(P,{className:"h-4 w-4"})}),Rt.jsx(Mt,{variant:"outline",size:"sm",onClick:()=>a(o),disabled:n===o,children:Rt.jsx(_e,{className:"h-4 w-4"})})]})]})},es=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Rt.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Rt.jsxs("div",{className:"flex items-center gap-3",children:[Rt.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Rt.jsxs(Mt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Rt.jsx(k,{size:14,className:"mr-1"}),"Limpar"]})]}),Rt.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Rt.jsxs(Mt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Rt.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Rt.jsxs(Mt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Rt.jsx(O,{size:14,className:"mr-1"}),"Deletar"]})]})]}),ts={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ns={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},rs={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function as({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Rt.jsx("div",{className:_t("flex","column"===t?"flex-col":"flex-row",ts[n],ns[r],rs[a],s&&"flex-wrap",i),children:e})}function ss({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=$r(),a=e.searchTerm,s=Rt.jsxs(Rt.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx(Bt,{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 Rt.jsx("div",{className:n?"":"w-full sm:w-auto",children:Rt.jsx(r,{...e.props})},t)}),a&&Rt.jsxs(Mt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Rt.jsx(k,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Rt.jsx("div",{className:"flex items-center gap-2",children:s}):Rt.jsx(as,{direction:"column",gap:"md",className:"mb-6",children:Rt.jsx(as,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function is({manager:e,config:t,formSections:n,onSave:r,onToggleStatus:s}){const{setSearchVisible:o}=$r(),[l,c]=a(!1),[u,d]=a(null),[f,m]=a({isOpen:!1,entityId:null,entityName:""}),[p,h]=a({isOpen:!1,count:0});i(()=>(o(!0),()=>{o(!1)}),[o]);return Rt.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Rt.jsx(es,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:void 0,customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Rt.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Rt.jsx("div",{className:"flex items-center gap-4",children:Rt.jsxs(Mt,{onClick:()=>{d(null),c(!0)},children:[Rt.jsx(he,{size:16,className:"mr-2"}),"Novo"]})}),t.filters&&t.filters.length>0&&Rt.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Rt.jsx(ss,{manager:e,filters:t.filters,inline:!0})})]}),Rt.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:Rt.jsx(La,{manager:e,columns:t.columns,onEdit:e=>{d(e),c(!0)},onDelete:e=>{m({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:s,enableBulkActions:t.enableBulkActions})}),Rt.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Rt.jsx(Za,{manager:e})}),Rt.jsx(Ga,{open:l,title:u?`Editar ${t.entityName}`:`Novo ${t.entityName}`,sections:n,initialData:u||void 0,onSubmit:e=>{r(e),c(!1),d(null)},onCancel:()=>{c(!1),d(null)},isLoading:e.isLoading,submitButtonText:u?"Atualizar":"Criar"}),Rt.jsx(na,{open:f.isOpen,onOpenChange:()=>{m({isOpen:!1,entityId:null,entityName:""})},onConfirm:t=>{f.entityId&&(e.deleteEntity(f.entityId),m({isOpen:!1,entityId:null,entityName:""}))},item:f.entityId?{id:f.entityId,title:f.entityName}:void 0,entityName:t.entityName,isDeleting:e.isDeleting}),Rt.jsx(na,{open:p.isOpen,onOpenChange:()=>h({isOpen:!1,count:0}),onConfirm:()=>(e.bulkDelete?.(e.selectedIds),void h({isOpen:!1,count:0})),item:{id:"bulk",title:`${p.count} ${1===p.count?"item":"itens"}`},entityName:t.entityName,isDeleting:e.isBulkDeleting})]})}function os(e){return()=>{const{manager:t,config:n,onSave:r,onToggleStatus:a}=e,s={entityName:n.entityName,entityNamePlural:n.entityNamePlural,filters:n.filters||[],columns:n.columns,cardFields:n.cardFields||[],enableBulkActions:!0};return Rt.jsx(is,{manager:t,config:s,formSections:n.formSections,onSave:r,onToggleStatus:a})}}function ls(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)}}}function cs(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:ds(e),label:ds(e),...us(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 us(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 ds(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const fs={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}};function ms(e,t,n={}){const r=fs[e];return cs(r.title,t,{...r,...n})}const ps=({children:e})=>{const{isAuthenticated:n,isLoading:r}=$r();if(t.useEffect(()=>{if(!n)return;const e=()=>{nr.areAllTokensValid()||Fr.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(nr.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 s=wr();(async()=>{s?await Fr.loginDev():Fr.loginProd()})()},[n,r]),r)return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsx(qt,{className:"text-xl font-semibold",children:"Carregando..."})}),Rt.jsxs(Qt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.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 Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsx(qt,{className:"text-xl font-semibold",children:"Processando..."})}),Rt.jsxs(Qt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(nr.areAllTokensValid())return Rt.jsx(Rt.Fragment,{children:e})}catch{}return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsx(qt,{className:"text-xl font-semibold",children:"Iniciando..."})}),Rt.jsxs(Qt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:wr()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Rt.jsx(Rt.Fragment,{children:e})},hs=p("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"}}),gs=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx("div",{ref:r,role:"alert",className:_t(hs({variant:t}),e),...n}));gs.displayName="Alert";const xs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h5",{ref:n,className:_t("mb-1 font-medium leading-none tracking-tight",e),...t}));xs.displayName="AlertTitle";const ys=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("text-sm [&_p]:leading-relaxed",e),...t}));ys.displayName="AlertDescription";const bs=()=>{const{processCallback:e}=$r(),[t,n]=a(null),[r,s]=a(!1);i(()=>{(async()=>{try{if(await e()){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 n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const o=async()=>{s(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro ao tentar novamente.")}finally{s(!1)}},l=()=>{window.location.href="/"};return t?Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsxs(qt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Rt.jsx(T,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Rt.jsxs(Qt,{className:"space-y-4",children:[Rt.jsx(gs,{variant:"destructive",children:Rt.jsx(ys,{children:t})}),Rt.jsx("div",{className:"text-sm text-muted-foreground",children:Rt.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Rt.jsxs("div",{className:"flex gap-2",children:[Rt.jsx(Mt,{onClick:o,disabled:r,className:"flex-1",children:r?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Tn,{size:"sm",className:"mr-2"}),"Tentando..."]}):Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(De,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Rt.jsx(Mt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsx(qt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Rt.jsxs(Qt,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(Tn,{size:"lg"})}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},vs=()=>Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsx(Ht,{className:"text-center",children:Rt.jsx(qt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Rt.jsxs(Qt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Rt.jsx(Mt,{onClick:async()=>{wr()?await Fr.loginDev():Fr.loginProd()},className:"w-full",size:"lg",children:wr()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})});function ws(e){return{queryClient:e.queryClient||new Ze({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const ks=ut.Root,Ns=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ut.Item,{ref:n,className:_t("border-b",e),...t}));Ns.displayName="AccordionItem";const js=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(ut.Header,{className:"flex",children:Rt.jsxs(ut.Trigger,{ref:r,className:_t("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,Rt.jsx(N,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));js.displayName=ut.Trigger.displayName;const Ss=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(ut.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Rt.jsx("div",{className:_t("pb-4 pt-0",e),children:t})}));Ss.displayName=ut.Content.displayName;const Cs=dt.Root,Ts=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Root,{ref:n,className:_t("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Ts.displayName=ft.Root.displayName;const Is=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Image,{ref:n,className:_t("aspect-square h-full w-full",e),...t}));Is.displayName=ft.Image.displayName;const Es=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Fallback,{ref:n,className:_t("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Es.displayName=ft.Fallback.displayName;const Ps=e.forwardRef(({...e},t)=>Rt.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));Ps.displayName="Breadcrumb";const As=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ol",{ref:n,className:_t("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));As.displayName="BreadcrumbList";const Rs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:_t("inline-flex items-center gap-1.5",e),...t}));Rs.displayName="BreadcrumbItem";const _s=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Rt.jsx(s,{ref:a,className:_t("transition-colors hover:text-foreground",n),...r})});_s.displayName="BreadcrumbLink";const Ds=e.forwardRef(({className:e,...t},n)=>Rt.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:_t("font-normal text-foreground",e),...t}));Ds.displayName="BreadcrumbPage";const Os=({children:e,className:t,...n})=>Rt.jsx("li",{role:"presentation","aria-hidden":"true",className:_t("[&>svg]:size-3.5",t),...n,children:e??Rt.jsx(P,{})});Os.displayName="BreadcrumbSeparator";const zs=({className:e,...t})=>Rt.jsxs("span",{role:"presentation","aria-hidden":"true",className:_t("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(Oe,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More"})]});function Ls(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Fs(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 Ms(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(o,e=>e.test(i)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(o,e=>e.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:t.slice(i.length)}}}zs.displayName="BreadcrumbEllipsis";const Bs={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"}},Us={date:Ls({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:Ls({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ls({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},$s={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"},Vs={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:Fs({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Fs({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:Fs({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:Fs({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:Fs({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"})},Hs={ordinalNumber:(qs={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(qs.matchPattern);if(!n)return null;const r=n[0],a=e.match(qs.parsePattern);if(!a)return null;let s=qs.valueCallback?qs.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Ms({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:Ms({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:Ms({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:Ms({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:Ms({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 qs;const Ws={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=Bs[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:Us,formatRelative:(e,t,n,r)=>{const a=$s[e];return"function"==typeof a?a(t):a},localize:Vs,match:Hs,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Qs({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Rt.jsx(mt,{showOutsideDays:n,className:_t("p-3",e),locale:Ws,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:_t(Ft({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:_t(Ft({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})=>Rt.jsx(me,{className:"h-4 w-4"}),IconRight:({...e})=>Rt.jsx(P,{className:"h-4 w-4"})},...r})}Qs.displayName="Calendar";const Ks=pt.Root,Ys=pt.CollapsibleTrigger,Js=pt.CollapsibleContent,Xs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Xs.displayName="Command";const Gs=({children:e,...t})=>Rt.jsx("div",{...t,children:Rt.jsx(Xs,{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})}),Zs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Rt.jsx("input",{ref:n,className:_t("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})}));Zs.displayName="CommandInput";const ei=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ei.displayName="CommandList";const ti=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("py-6 text-center text-sm text-muted-foreground",e),...t}));ti.displayName="CommandEmpty";const ni=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("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}));ni.displayName="CommandGroup";const ri=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:_t("-mx-1 h-px bg-border",e),...t}));ri.displayName="CommandSeparator";const ai=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Rt.jsx("div",{ref:s,className:_t("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}));ai.displayName="CommandItem";const si=({className:e,...t})=>Rt.jsx("span",{className:_t("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});si.displayName="CommandShortcut";const ii={Root:function({children:e,className:t}){return Rt.jsx("div",{className:_t("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Rt.jsx(Vt,{className:_t("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Rt.jsx(Qt,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Rt.jsxs("div",{className:_t("flex justify-between items-center text-sm",n),children:[Rt.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Rt.jsx("span",{className:"text-foreground",children:t})]})}},oi={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))]"},li={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function ci({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Rt.jsx("div",{className:_t("grid",oi[t],li[n],r),children:e})}function ui({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Rt.jsx(Ps,{className:n})}function di(){const e=tt();return(()=>{const t=e.pathname.split("/").filter(Boolean),n=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,a)=>{r+=`/${e}`;const s=a===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");n.push({label:i,href:s?void 0:r,isCurrentPage:s})}),n})()}const fi=({className:e,...t})=>Rt.jsx("nav",{role:"navigation","aria-label":"pagination",className:_t("mx-auto flex w-full justify-center",e),...t});fi.displayName="Pagination";const mi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,className:_t("flex flex-row items-center gap-1",e),...t}));mi.displayName="PaginationContent";const pi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:_t("",e),...t}));pi.displayName="PaginationItem";const hi=({className:e,isActive:t,size:n="icon",...r})=>Rt.jsx("a",{"aria-current":t?"page":void 0,className:_t(Ft({variant:t?"outline":"ghost",size:n}),e),...r});hi.displayName="PaginationLink";const gi=({className:e,...t})=>Rt.jsxs(hi,{"aria-label":"Go to previous page",size:"default",className:_t("gap-1 pl-2.5",e),...t,children:[Rt.jsx(me,{className:"h-4 w-4"}),Rt.jsx("span",{children:"Previous"})]});gi.displayName="PaginationPrevious";const xi=({className:e,...t})=>Rt.jsxs(hi,{"aria-label":"Go to next page",size:"default",className:_t("gap-1 pr-2.5",e),...t,children:[Rt.jsx("span",{children:"Next"}),Rt.jsx(P,{className:"h-4 w-4"})]});xi.displayName="PaginationNext";const yi=({className:e,...t})=>Rt.jsxs("span",{"aria-hidden":!0,className:_t("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(Oe,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More pages"})]});yi.displayName="PaginationEllipsis";const bi=e.forwardRef(({className:e,value:t,...n},r)=>Rt.jsx(ht.Root,{ref:r,className:_t("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Rt.jsx(ht.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));bi.displayName=ht.Root.displayName;const vi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(gt.Root,{className:_t("grid gap-2",e),...t,ref:n}));vi.displayName=gt.Root.displayName;const wi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(gt.Item,{ref:n,className:_t("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:Rt.jsx(gt.Indicator,{className:"flex items-center justify-center",children:Rt.jsx(A,{className:"h-2.5 w-2.5 fill-current text-current"})})}));wi.displayName=gt.Item.displayName;const ki=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Rt.jsx(xt.Root,{ref:a,decorative:n,orientation:t,className:_t("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ki.displayName=xt.Root.displayName;const Ni=w.Root,ji=w.Trigger,Si=w.Close,Ci=w.Portal,Ti=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Overlay,{className:_t("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}));Ti.displayName=w.Overlay.displayName;const Ii=p("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"}}),Ei=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Rt.jsxs(Ci,{children:[Rt.jsx(Ti,{}),Rt.jsxs(w.Content,{ref:a,className:_t(Ii({side:e}),t),...r,children:[n,Rt.jsxs(w.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:[Rt.jsx(k,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ei.displayName=w.Content.displayName;const Pi=({className:e,...t})=>Rt.jsx("div",{className:_t("flex flex-col space-y-2 text-center sm:text-left",e),...t});Pi.displayName="SheetHeader";const Ai=({className:e,...t})=>Rt.jsx("div",{className:_t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ai.displayName="SheetFooter";const Ri=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Title,{ref:n,className:_t("text-lg font-semibold text-foreground",e),...t}));Ri.displayName=w.Title.displayName;const _i=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Description,{ref:n,className:_t("text-sm text-muted-foreground",e),...t}));_i.displayName=w.Description.displayName;const Di=yt.Provider,Oi=yt.Root,zi=yt.Trigger,Li=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(yt.Content,{ref:r,sideOffset:t,className:_t("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}));Li.displayName=yt.Content.displayName;const Fi="sidebar:state",Mi=e.createContext(null);function Bi(){const t=e.useContext(Mi);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const Ui=e.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:r,className:a,style:s,children:i,...o},l)=>{const[c,u]=e.useState(!1);e.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[d,f]=e.useState(!1),[m,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Fi);return null!==e?"true"===e:t}return t}),h=n??m,g=e.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Fi,String(t))},[r,h]),x=e.useCallback(()=>c?f(e=>!e):g(e=>!e),[c,g,f]);e.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 y=h?"expanded":"collapsed",b=e.useMemo(()=>({state:y,open:h,setOpen:g,isMobile:c,openMobile:d,setOpenMobile:f,toggleSidebar:x}),[y,h,g,c,d,f,x]);return Rt.jsx(Mi.Provider,{value:b,children:Rt.jsx(Di,{delayDuration:0,children:Rt.jsx("div",{className:_t("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",a),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...s},ref:l,...o,children:i})})})});Ui.displayName="SidebarProvider";const $i=e.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:a,...s},i)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:u}=Bi();return"none"===n?Rt.jsx("div",{className:_t("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Rt.jsx(Ni,{open:c,onOpenChange:u,...s,children:Rt.jsxs(Ei,{"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:[Rt.jsx(Ri,{className:"sr-only",children:"Menu de Navegação"}),Rt.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Rt.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?n:"","data-variant":t,"data-side":e,children:[Rt.jsx("div",{className:_t("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]")}),Rt.jsx("div",{className:_t("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),...s,children:Rt.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})})]})});$i.displayName="Sidebar";const Vi=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=Bi();return Rt.jsxs(Mt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:_t("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Rt.jsx(ze,{}),Rt.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Vi.displayName="SidebarTrigger";const Hi=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Bi();return Rt.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:_t("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})});Hi.displayName="SidebarRail";const qi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("main",{ref:n,className:_t("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}));qi.displayName="SidebarInset";const Wi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Bt,{ref:n,"data-sidebar":"input",className:_t("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Wi.displayName="SidebarInput";const Qi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"header",className:_t("flex flex-col gap-2 p-2",e),...t}));Qi.displayName="SidebarHeader";const Ki=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"footer",className:_t("flex flex-col gap-2 p-2",e),...t}));Ki.displayName="SidebarFooter";const Yi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ki,{ref:n,"data-sidebar":"separator",className:_t("mx-2 w-auto bg-sidebar-border",e),...t}));Yi.displayName="SidebarSeparator";const Ji=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"content",className:_t("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Ji.displayName="SidebarContent";const Xi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group",className:_t("relative flex w-full min-w-0 flex-col p-2",e),...t}));Xi.displayName="SidebarGroup";const Gi=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?f:"div";return Rt.jsx(a,{ref:r,"data-sidebar":"group-label",className:_t("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),...n})});Gi.displayName="SidebarGroupLabel";const Zi=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?f:"button";return Rt.jsx(a,{ref:r,"data-sidebar":"group-action",className:_t("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),...n})});Zi.displayName="SidebarGroupAction";const eo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group-content",className:_t("w-full text-sm",e),...t}));eo.displayName="SidebarGroupContent";const to=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,"data-sidebar":"menu",className:_t("flex w-full min-w-0 flex-col gap-1",e),...t}));to.displayName="SidebarMenu";const no=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,"data-sidebar":"menu-item",className:_t("group/menu-item relative",e),...t}));no.displayName="SidebarMenuItem";const ro=p("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"}}),ao=e.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:a,className:s,...i},o)=>{const l=e?f:"button",{isMobile:c,state:u}=Bi(),d=Rt.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:_t(ro({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Rt.jsxs(Oi,{children:[Rt.jsx(zi,{asChild:!0,children:d}),Rt.jsx(Li,{side:"right",align:"center",hidden:"collapsed"!==u||c,...a})]})):d});ao.displayName="SidebarMenuButton";const so=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?f:"button";return Rt.jsx(s,{ref:a,"data-sidebar":"menu-action",className:_t("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",n&&"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})});so.displayName="SidebarMenuAction";const io=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:_t("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}));io.displayName="SidebarMenuBadge";const oo=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Rt.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:_t("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Rt.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Rt.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});oo.displayName="SidebarMenuSkeleton";const lo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:_t("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}));lo.displayName="SidebarMenuSub";const co=e.forwardRef(({...e},t)=>Rt.jsx("li",{ref:t,...e}));co.displayName="SidebarMenuSubItem";const uo=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?f:"a";return Rt.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:_t("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"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",r),...a})});uo.displayName="SidebarMenuSubButton";const fo=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(bt.Root,{ref:n,className:_t("relative flex w-full touch-none select-none items-center",e),...t,children:[Rt.jsx(bt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Rt.jsx(bt.Range,{className:"absolute h-full bg-primary"})}),Rt.jsx(bt.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"})]}));fo.displayName=bt.Root.displayName;const mo=({...e})=>{const{theme:t="system"}=vt();return Rt.jsx(st,{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})};function po(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function ho(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function go(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=ho(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():ho(e[t],null)}}}}(...t),t)}function xo(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const a=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}var yo=globalThis?.document?e.useLayoutEffect:()=>{},bo=e[" useInsertionEffect ".trim().toString()]||yo;function vo({prop:t,defaultProp:n,onChange:r=()=>{},caller:a}){const[s,i,o]=function({defaultProp:t,onChange:n}){const[r,a]=e.useState(t),s=e.useRef(r),i=e.useRef(n);return bo(()=>{i.current=n},[n]),e.useEffect(()=>{s.current!==r&&(i.current?.(r),s.current=r)},[r,s]),[r,a,i]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:s;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,a])}const u=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&o.current?.(n)}else i(e)},[l,t,i,o]);return[c,u]}var wo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=m(`Primitive.${n}`),a=e.forwardRef((e,t)=>{const{asChild:a,...s}=e,i=a?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),Rt.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),ko="Switch",[No]=function(t,n=[]){let r=[];const a=()=>{const n=r.map(t=>e.createContext(t));return function(r){const a=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:a}}),[r,a])}};return a.scopeName=t,[function(n,a){const s=e.createContext(a),i=r.length;r=[...r,a];const o=n=>{const{scope:r,children:a,...o}=n,l=r?.[t]?.[i]||s,c=e.useMemo(()=>o,Object.values(o));return Rt.jsx(l.Provider,{value:c,children:a})};return o.displayName=n+"Provider",[o,function(r,o){const l=o?.[t]?.[i]||s,c=e.useContext(l);if(c)return c;if(void 0!==a)return a;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},xo(a,...n)]}(ko),[jo,So]=No(ko),Co=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:a,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:u,form:d,...f}=t,[m,p]=e.useState(null),h=go(n,e=>p(e)),g=e.useRef(!1),x=!m||(d||!!m.closest("form")),[y,b]=vo({prop:s,defaultProp:i??!1,onChange:u,caller:ko});return Rt.jsxs(jo,{scope:r,checked:y,disabled:l,children:[Rt.jsx(wo.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":Po(y),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:h,onClick:po(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Rt.jsx(Eo,{control:m,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});Co.displayName=ko;var To="SwitchThumb",Io=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=So(To,n);return Rt.jsx(wo.span,{"data-state":Po(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Io.displayName=To;var Eo=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=go(o,i),c=function(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}(r),u=function(t){const[n,r]=e.useState(void 0);return yo(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let a,s;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;a=t.inlineSize,s=t.blockSize}else a=t.offsetWidth,s=t.offsetHeight;r({width:a,height:s})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:a});n.call(e,r),e.dispatchEvent(t)}},[c,r,a]),Rt.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Po(e){return e?"checked":"unchecked"}Eo.displayName="SwitchBubbleInput";var Ao=Co,Ro=Io;const _o=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ao,{className:_t("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:Rt.jsx(Ro,{className:_t("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")})}));_o.displayName=Ao.displayName;const Do=wt.Root,Oo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.List,{ref:n,className:_t("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Oo.displayName=wt.List.displayName;const zo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.Trigger,{ref:n,className:_t("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}));zo.displayName=wt.Trigger.displayName;const Lo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.Content,{ref:n,className:_t("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function Fo({children:e,className:t}){return Rt.jsx("div",{className:_t("flex flex-col h-full",t),children:Rt.jsx(Ha,{className:"flex-1",children:Rt.jsx("div",{className:"space-y-6 p-6",children:e})})})}function Mo({title:e,description:t,actions:n,className:r}){return Rt.jsxs("div",{className:_t("space-y-4",r),children:[Rt.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Rt.jsxs("div",{className:"space-y-1",children:[Rt.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Rt.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Rt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Rt.jsx(ki,{})]})}function Bo({children:e,className:t}){return Rt.jsx("div",{className:_t("space-y-6",t),children:e})}Lo.displayName=wt.Content.displayName;const Uo=p("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"}}),$o=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Rt.jsx(kt.Root,{ref:a,className:_t(Uo({variant:t,size:n,className:e})),...r}));$o.displayName=kt.Root.displayName;const Vo=e.createContext({size:"default",variant:"default"}),Ho=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Rt.jsx(Nt.Root,{ref:s,className:_t("flex items-center justify-center gap-1",e),...a,children:Rt.jsx(Vo.Provider,{value:{variant:t,size:n},children:r})}));Ho.displayName=Nt.Root.displayName;const qo=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(Vo);return Rt.jsx(Nt.Item,{ref:i,className:_t(Uo({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});qo.displayName=Nt.Item.displayName;const Wo=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Rt.jsx(Mt,{ref:a,variant:"outline",size:"sm",className:_t("h-7 px-2 text-xs","border-primary/20 text-primary hover:bg-primary/5",t),...r,children:n||Rt.jsx(z,{size:12})}));function Qo({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Rt.jsx(ci,{children:Array.from({length:3}).map((e,t)=>Rt.jsxs(Vt,{children:[Rt.jsxs(Ht,{children:[Rt.jsx(da,{className:"h-4 w-3/4"}),Rt.jsx(da,{className:"h-3 w-1/2"})]}),Rt.jsx(Qt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(da,{className:"h-3 w-full"}),Rt.jsx(da,{className:"h-3 w-2/3"})]})})]},t))}):Rt.jsx(ii.Root,{children:e.entities.map(e=>Rt.jsxs(ii.Item,{onClick:()=>n(e),children:[Rt.jsx(Ht,{className:"pb-3",children:Rt.jsxs("div",{className:"flex items-start justify-between",children:[Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx(qt,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Rt.jsx(Wt,{className:"text-sm",children:b(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:Ws})})]}),Rt.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Rt.jsx(Mt,{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),at.info("Link copiado para a área de transferência"))}catch(t){window.location.href=e}})(e.link)},title:"Abrir link externo",children:Rt.jsx(Le,{className:"h-4 w-4"})}),Rt.jsx("div",{onClick:e=>e.stopPropagation(),children:Rt.jsx(Oa,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Rt.jsx(Qt,{className:"pt-0",children:Rt.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Rt.jsx(ii.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function Ko(e){const t=nt();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)}}}function Yo(e){return Ko({basePath:e})}Wo.displayName="ActionButton";const Jo=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:u}=$r(),d=i?.[0]||null,f=o?i?.find(e=>e.alias===o):d,m=i||[],p=r||f||d||d,h=t.useCallback(e=>{a?a(e):u(e)},[a,u]),g=t.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===p?.alias),r=t.filter(e=>e.alias!==p?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),n?[n,...r]:r},[m,p?.alias]);if(!l||!s)return null;const x=()=>Rt.jsxs(Rt.Fragment,{children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx("div",{className:"flex-shrink-0",children:Rt.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ie,{className:"h-5 w-5 text-primary-foreground"})})}),Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Rt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Rt.jsx("div",{className:"mt-3",children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(Fe,{className:"h-4 w-4 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Rt.jsxs("div",{className:"mt-2",children:[Rt.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Rt.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Rt.jsx(Sn,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Rt.jsxs(Sn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Rt.jsxs(ba,{children:[Rt.jsx(va,{asChild:!0,children:Rt.jsx(Mt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsxs("div",{className:"hidden md:block text-left",children:[Rt.jsx("p",{className:"text-sm font-medium",children:s.name}),Rt.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Rt.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ie,{className:"h-4 w-4 text-primary-foreground"})}),Rt.jsx(N,{className:"h-4 w-4"})]})})}),Rt.jsxs(Ta,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Rt.jsxs(Na,{children:[Rt.jsxs(Sa,{children:[Rt.jsx(De,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Rt.jsx(Ca,{children:g.map(e=>Rt.jsxs(Ia,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Rt.jsx(Fe,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Rt.jsx(Sn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Rt.jsx(Ra,{}),Rt.jsxs(Ia,{onClick:c,children:[Rt.jsx(Me,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Rt.jsxs(Vt,{className:n,children:[Rt.jsx(Ht,{children:Rt.jsx(qt,{className:"text-lg",children:"Informações do Usuário"})}),Rt.jsxs(Qt,{className:"space-y-4",children:[Rt.jsx(x,{}),Rt.jsx(ki,{}),Rt.jsxs(Mt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Rt.jsx(Me,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Xo=n({});function Go({children:e,config:t}){const n=o(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Rt.jsx(Xo.Provider,{value:n,children:e})}function Zo(){return r(Xo)}function el(){const e=tt(),{navigation:t}=Zo(),n=t?.find(t=>t.path===e.pathname);return n?.label||"Página"}function tl(e,t){const[n,r]=a(e),o=c(),l=s(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return i(()=>(l(),o.current=setTimeout(()=>{r(e)},t),l),[e,t,l]),[n,l]}const nl=l(function({actions:e}){const t=tt(),n=el(),{navigation:r,appName:s}=Zo(),{companies:o,alias:l,isSearchVisible:c,clearSearch:u,refreshData:d,switchUnit:f}=$r(),m=l?o?.find(e=>e.alias===l)||o?.[0]||null:o?.[0]||null,[p,h]=et(),[g,x]=a(()=>p.get("search")||""),[y,b]=tl(g,vr.debounceDelay);i(()=>{if(!c)return;const e=new URLSearchParams(p);y?(e.set("search",y),e.set("page","1")):e.delete("search"),h(e)},[y,h,c]);const v=r?.find(e=>e.path===t.pathname);return Rt.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Rt.jsxs("div",{className:"flex items-center gap-4",children:[Rt.jsxs("div",{className:"flex-shrink-0",children:[Rt.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Rt.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:n}),Rt.jsx(Sn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Rt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:v?.complementaryText||"Detalhes do item"})]}),c&&Rt.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx(Bt,{placeholder:"/wiki"===t.pathname?"Buscar artigos...":"Buscar...",value:g,onChange:e=>(e=>{x(e)})(e.target.value),className:"w-full pl-10 pr-8"}),g&&Rt.jsx(Mt,{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:()=>{b(),x("");const e=new URLSearchParams(p);e.delete("search"),e.delete("page"),h(e)},title:"Limpar busca",children:Rt.jsx(k,{size:14})})]}),Rt.jsx(Mt,{variant:"outline",size:"sm",onClick:d,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Rt.jsx(De,{size:14})})]}),Rt.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Rt.jsx("div",{className:"flex items-center gap-2",children:e}),Rt.jsx("div",{className:"text-sm",children:Rt.jsx(Jo,{variant:"dropdown",selectedUnit:m,onUnitChange:f})})]})]})})}),rl=(e={})=>{const{enabled:t=!0}=e,{alias:n}=$r();return Xe({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=fr(),{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(!Mr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},al=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>Xe({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),sl=import.meta.env.VITE_SUPABASE_PROJECT_ID,il={logo:`https://${sl}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${sl}.supabase.co/storage/v1/object/public/library-assets/small.svg`},ol=il.logo,ll=il.smallLogo,cl="forlogic-sidebar-pinned",ul=()=>{try{const e=localStorage.getItem(cl);return!!e&&JSON.parse(e)}catch{return!1}};function dl({config:e}={}){const{state:t,open:n,setOpen:r}=Bi(),s=tt(),{alias:o,user:l}=$r(),[c,u]=a(!1),[d,f]=a(ul),[m,p]=a(!1);i(()=>{r(!!d||!(!m&&!c))},[d,m,c,r]);const{data:h,isLoading:g,error:x}=rl({enabled:c}),y=e=>s.pathname===e,b=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 Rt.jsxs($i,{collapsible:"icon",onMouseEnter:()=>{d||p(!0)},onMouseLeave:()=>{d||p(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[Rt.jsxs(Qi,{className:"p-0 gap-0",children:[Rt.jsx("div",{className:"flex items-center justify-between h-[34px]",children:n?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx("div",{className:"flex items-center pl-[12px]",children:Rt.jsx("img",{src:il.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Rt.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(cl,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:Rt.jsx(ze,{className:"h-4 w-4"})})]}):Rt.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Rt.jsx("img",{src:il.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Rt.jsx("div",{className:"mt-2 pt-0",children:Rt.jsxs(ba,{onOpenChange:u,children:[Rt.jsx(va,{asChild:!0,children:n?Rt.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:[Rt.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Rt.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"}),Rt.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Rt.jsx(N,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Rt.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:Rt.jsx(N,{className:"h-6 w-6 text-muted-foreground"})})}),Rt.jsx(Ta,{className:n?"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:n?"start":"center",children:g?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Rt.jsx(C,{className:"h-4 w-4 animate-spin"}),Rt.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):x?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Rt.jsx(T,{className:"h-4 w-4"}),Rt.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Rt.jsx("div",{className:"space-y-2",children:h.map((e,t)=>Rt.jsx("div",{onClick:()=>(e=>{const t=h?.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 ${b(t)} transition-colors duration-200\n `,children:Rt.jsxs("div",{className:"flex items-center justify-between",children:[Rt.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Rt.jsx(Le,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Rt.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Rt.jsx(Ji,{children:Rt.jsx(Xi,{className:"p-0 mt-6",children:Rt.jsx(eo,{children:Rt.jsx(to,{className:"space-y-2",children:Rt.jsx(Di,{children:e?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const n=`${e.path}-${t}-${o??"noalias"}-${l?.id??"nouser"}`,{data:r=!0,isLoading:a}=al({key:n,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),s=e.permissionCheck&&!r,i=a?C:s?X:e.icon;return s||e.complementaryText,Rt.jsx(no,{children:s||a?Rt.jsxs(Oi,{children:[Rt.jsx(zi,{asChild:!0,children:Rt.jsx(ao,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Rt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Rt.jsx(Li,{children:Rt.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):Rt.jsx(ao,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:Rt.jsxs(rt,{to:e.path,className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-5 w-4"})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Rt.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const fl=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:r=!0}){const a=o(()=>t||Rt.jsx(dl,{config:n}),[t,n]),s=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Rt.jsx(Go,{config:n,children:Rt.jsx(Ui,{defaultOpen:!1,style:s,children:Rt.jsxs("div",{className:"min-h-screen flex w-full",children:[a,Rt.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&Rt.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Rt.jsx(nl,{})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})});class ml extends d{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){sr.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:Rt.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Rt.jsxs(Vt,{className:"w-full max-w-md",children:[Rt.jsxs(Ht,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(Be,{className:"h-12 w-12 text-destructive"})}),Rt.jsx(qt,{children:"Algo deu errado"})]}),Rt.jsxs(Qt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Rt.jsx(Mt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function pl(){const[e,t]=a([]),[n,r]=a(!1),[o,l]=a(null),[c,u]=a(null);i(()=>{d()},[]);const d=async()=>{try{const e=fr(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;l(n.threadId),t([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){u("Erro ao inicializar conversa"),at.error("Erro ao inicializar conversa")}},f=s(async e=>{if(!o||!e.trim())return;const n={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,n]),r(!0),u(null);try{const n=fr(),{data:r,error:a}=await n.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=fr(),{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=fr(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:o}});if(r)throw r;const a=n.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));t(a)}catch(e){throw e}})()}catch(a){const e=a instanceof Error?a.message:"Erro ao enviar mensagem";u(e),at.error(e),t(e=>e.filter(e=>e.id!==n.id))}finally{r(!1)}},[o]);return{messages:e,isLoading:n,error:c,sendMessage:f,threadId:o}}function hl(){}function gl(){}const xl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bl={};function vl(e,t){return(bl.jsx?yl:xl).test(e)}const wl=/[ \t\n\f\r]/g;function kl(e){return""===e.replace(wl,"")}class Nl{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function jl(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Nl(n,r,t)}function Sl(e){return e.toLowerCase()}Nl.prototype.normal={},Nl.prototype.property={},Nl.prototype.space=void 0;class Cl{constructor(e,t){this.attribute=t,this.property=e}}Cl.prototype.attribute="",Cl.prototype.booleanish=!1,Cl.prototype.boolean=!1,Cl.prototype.commaOrSpaceSeparated=!1,Cl.prototype.commaSeparated=!1,Cl.prototype.defined=!1,Cl.prototype.mustUseProperty=!1,Cl.prototype.number=!1,Cl.prototype.overloadedBoolean=!1,Cl.prototype.property="",Cl.prototype.spaceSeparated=!1,Cl.prototype.space=void 0;let Tl=0;const Il=Ol(),El=Ol(),Pl=Ol(),Al=Ol(),Rl=Ol(),_l=Ol(),Dl=Ol();function Ol(){return 2**++Tl}var zl=Object.freeze({__proto__:null,boolean:Il,booleanish:El,commaOrSpaceSeparated:Dl,commaSeparated:_l,number:Al,overloadedBoolean:Pl,spaceSeparated:Rl});const Ll=Object.keys(zl);class Fl extends Cl{constructor(e,t,n,r){let a=-1;if(super(e,t),Ml(this,"space",r),"number"==typeof n)for(;++a<Ll.length;){const e=Ll[a];Ml(this,Ll[a],(n&zl[e])===zl[e])}}}function Ml(e,t,n){n&&(e[t]=n)}function Bl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new Fl(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Sl(r)]=r,n[Sl(s.attribute)]=r}return new Nl(t,n,e.space)}Fl.prototype.defined=!0;const Ul=Bl({properties:{ariaActiveDescendant:null,ariaAtomic:El,ariaAutoComplete:null,ariaBusy:El,ariaChecked:El,ariaColCount:Al,ariaColIndex:Al,ariaColSpan:Al,ariaControls:Rl,ariaCurrent:null,ariaDescribedBy:Rl,ariaDetails:null,ariaDisabled:El,ariaDropEffect:Rl,ariaErrorMessage:null,ariaExpanded:El,ariaFlowTo:Rl,ariaGrabbed:El,ariaHasPopup:null,ariaHidden:El,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rl,ariaLevel:Al,ariaLive:null,ariaModal:El,ariaMultiLine:El,ariaMultiSelectable:El,ariaOrientation:null,ariaOwns:Rl,ariaPlaceholder:null,ariaPosInSet:Al,ariaPressed:El,ariaReadOnly:El,ariaRelevant:null,ariaRequired:El,ariaRoleDescription:Rl,ariaRowCount:Al,ariaRowIndex:Al,ariaRowSpan:Al,ariaSelected:El,ariaSetSize:Al,ariaSort:null,ariaValueMax:Al,ariaValueMin:Al,ariaValueNow:Al,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function $l(e,t){return t in e?e[t]:t}function Vl(e,t){return $l(e,t.toLowerCase())}const Hl=Bl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_l,acceptCharset:Rl,accessKey:Rl,action:null,allow:null,allowFullScreen:Il,allowPaymentRequest:Il,allowUserMedia:Il,alt:null,as:null,async:Il,autoCapitalize:null,autoComplete:Rl,autoFocus:Il,autoPlay:Il,blocking:Rl,capture:null,charSet:null,checked:Il,cite:null,className:Rl,cols:Al,colSpan:null,content:null,contentEditable:El,controls:Il,controlsList:Rl,coords:Al|_l,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Il,defer:Il,dir:null,dirName:null,disabled:Il,download:Pl,draggable:El,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Il,formTarget:null,headers:Rl,height:Al,hidden:Pl,high:Al,href:null,hrefLang:null,htmlFor:Rl,httpEquiv:Rl,id:null,imageSizes:null,imageSrcSet:null,inert:Il,inputMode:null,integrity:null,is:null,isMap:Il,itemId:null,itemProp:Rl,itemRef:Rl,itemScope:Il,itemType:Rl,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Il,low:Al,manifest:null,max:null,maxLength:Al,media:null,method:null,min:null,minLength:Al,multiple:Il,muted:Il,name:null,nonce:null,noModule:Il,noValidate:Il,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:Il,optimum:Al,pattern:null,ping:Rl,placeholder:null,playsInline:Il,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Il,referrerPolicy:null,rel:Rl,required:Il,reversed:Il,rows:Al,rowSpan:Al,sandbox:Rl,scope:null,scoped:Il,seamless:Il,selected:Il,shadowRootClonable:Il,shadowRootDelegatesFocus:Il,shadowRootMode:null,shape:null,size:Al,sizes:null,slot:null,span:Al,spellCheck:El,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Al,step:null,style:null,tabIndex:Al,target:null,title:null,translate:null,type:null,typeMustMatch:Il,useMap:null,value:El,width:Al,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rl,axis:null,background:null,bgColor:null,border:Al,borderColor:null,bottomMargin:Al,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Il,declare:Il,event:null,face:null,frame:null,frameBorder:null,hSpace:Al,leftMargin:Al,link:null,longDesc:null,lowSrc:null,marginHeight:Al,marginWidth:Al,noResize:Il,noHref:Il,noShade:Il,noWrap:Il,object:null,profile:null,prompt:null,rev:null,rightMargin:Al,rules:null,scheme:null,scrolling:El,standby:null,summary:null,text:null,topMargin:Al,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Al,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Il,disableRemotePlayback:Il,prefix:null,property:null,results:Al,security:null,unselectable:null},space:"html",transform:Vl}),ql=Bl({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:Dl,accentHeight:Al,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Al,amplitude:Al,arabicForm:null,ascent:Al,attributeName:null,attributeType:null,azimuth:Al,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Al,by:null,calcMode:null,capHeight:Al,className:Rl,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:Al,diffuseConstant:Al,direction:null,display:null,dur:null,divisor:Al,dominantBaseline:null,download:Il,dx:null,dy:null,edgeMode:null,editable:null,elevation:Al,enableBackground:null,end:null,event:null,exponent:Al,externalResourcesRequired:null,fill:null,fillOpacity:Al,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:_l,g2:_l,glyphName:_l,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Al,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Al,horizOriginX:Al,horizOriginY:Al,id:null,ideographic:Al,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Al,k:Al,k1:Al,k2:Al,k3:Al,k4:Al,kernelMatrix:Dl,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Al,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:Al,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:Al,overlineThickness:Al,paintOrder:null,panose1:null,path:null,pathLength:Al,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rl,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Al,pointsAtY:Al,pointsAtZ:Al,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Dl,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Dl,rev:Dl,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Dl,requiredFeatures:Dl,requiredFonts:Dl,requiredFormats:Dl,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:Al,specularExponent:Al,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Al,strikethroughThickness:Al,string:null,stroke:null,strokeDashArray:Dl,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Al,strokeOpacity:Al,strokeWidth:null,style:null,surfaceScale:Al,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Dl,tabIndex:Al,tableValues:null,target:null,targetX:Al,targetY:Al,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Dl,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Al,underlineThickness:Al,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Al,values:null,vAlphabetic:Al,vMathematical:Al,vectorEffect:null,vHanging:Al,vIdeographic:Al,version:null,vertAdvY:Al,vertOriginX:Al,vertOriginY:Al,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Al,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$l}),Wl=Bl({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()}),Ql=Bl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Vl}),Kl=Bl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Yl={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"},Jl=/[A-Z]/g,Xl=/-[a-z]/g,Gl=/^data[-\w.:]+$/i;function Zl(e){return"-"+e.toLowerCase()}function ec(e){return e.charAt(1).toUpperCase()}const tc=jl([Ul,Hl,Wl,Ql,Kl],"html"),nc=jl([Ul,ql,Wl,Ql,Kl],"svg");var rc,ac,sc,ic={};function oc(){if(sc)return ic;sc=1;var e=ic&&ic.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ic,"__esModule",{value:!0}),ic.default=function(e,n){var r=null;if(!e||"string"!=typeof e)return r;var a=(0,t.default)(e),s="function"==typeof n;return a.forEach(function(e){if("declaration"===e.type){var t=e.property,a=e.value;s?n(t,a,e):a&&((r=r||{})[t]=a)}}),r};var t=e(function(){if(ac)return rc;ac=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,o=/^\s+|\s+$/g,l="";function c(e){return e?e.replace(o,l):l}return rc=function(o,u){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];u=u||{};var d=1,f=1;function m(e){var n=e.match(t);n&&(d+=n.length);var r=e.lastIndexOf("\n");f=~r?e.length-r:f+e.length}function p(){var e={line:d,column:f};return function(t){return t.position=new h(e),y(),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=o,!u.silent)throw t}function x(e){var t=e.exec(o);if(t){var n=t[0];return m(n),o=o.slice(n.length),t}}function y(){x(n)}function b(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var e=p();if("/"==o.charAt(0)&&"*"==o.charAt(1)){for(var t=2;l!=o.charAt(t)&&("*"!=o.charAt(t)||"/"!=o.charAt(t+1));)++t;if(t+=2,l===o.charAt(t-1))return g("End of comment missing");var n=o.slice(2,t-2);return f+=2,m(n),o=o.slice(t),f+=2,e({type:"comment",comment:n})}}function w(){var t=p(),n=x(r);if(n){if(v(),!x(a))return g("property missing ':'");var o=x(s),u=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return x(i),u}}return h.prototype.content=o,y(),function(){var e,t=[];for(b(t);e=w();)!1!==e&&(t.push(e),b(t));return t}()},rc}());return ic}var lc,cc,uc,dc={};function fc(){if(lc)return dc;lc=1,Object.defineProperty(dc,"__esModule",{value:!0}),dc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,s=function(e,t){return t.toUpperCase()},i=function(e,t){return"".concat(t,"-")};return dc.camelCase=function(o,l){return void 0===l&&(l={}),function(t){return!t||n.test(t)||e.test(t)}(o)?o:(o=o.toLowerCase(),(o=l.reactCompat?o.replace(a,i):o.replace(r,i)).replace(t,s))},dc}var mc=function(){if(uc)return cc;uc=1;var e=(cc&&cc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(oc()),t=fc();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,cc=n}(),pc=jt(mc);const hc=xc("end"),gc=xc("start");function xc(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 yc(e){return e&&"object"==typeof e?"position"in e||"type"in e?vc(e.position):"start"in e||"end"in e?vc(e):"line"in e||"column"in e?bc(e):"":""}function bc(e){return wc(e&&e.line)+":"+wc(e&&e.column)}function vc(e){return bc(e&&e.start)+"-"+bc(e&&e.end)}function wc(e){return e&&"number"==typeof e?e:1}class kc extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",a={},s=!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&&(s=!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 i=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=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=yc(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=s&&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}}kc.prototype.file="",kc.prototype.name="",kc.prototype.reason="",kc.prototype.message="",kc.prototype.stack="",kc.prototype.column=void 0,kc.prototype.line=void 0,kc.prototype.ancestors=void 0,kc.prototype.cause=void 0,kc.prototype.fatal=void 0,kc.prototype.place=void 0,kc.prototype.ruleId=void 0,kc.prototype.source=void 0;const Nc={}.hasOwnProperty,jc=new Map,Sc=/[A-Z]/g,Cc=new Set(["table","tbody","thead","tfoot","tr"]),Tc=new Set(["td","th"]),Ic="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ec(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,s){const i=Array.isArray(a.children),o=gc(n);return t(r,a,s,i,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.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,s){const i=Array.isArray(a.children)?n:t;return s?i(r,a,s):i(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?nc:tc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=Pc(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function Pc(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=nc,e.schema=a);e.ancestors.push(t);const s=Oc(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&Nc.call(t.properties,a)){const s=Dc(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&Tc.has(t.tagName)?r=i:n[a]=i}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let o=_c(e,t);Cc.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&kl(t.value):kl(t));var t}));return Ac(e,i,s,t),Rc(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,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)}zc(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=nc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:Oc(e,t.name,!0),i=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];hl(t.type);const a=t.expression;hl(a.type);const s=a.properties[0];hl(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else zc(e,t.position);else{const a=r.name;let s;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];hl(t.type),s=e.evaluater.evaluateExpression(t.expression)}else zc(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=_c(e,t);return Ac(e,i,s,t),Rc(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,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);zc(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return Rc(r,_c(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 Ac(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Rc(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function _c(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:jc;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=a.get(e)||0;i=e+"-"+t,a.set(e,t+1)}}const o=Pc(e,s,i);void 0!==o&&n.push(o)}return n}function Dc(e,t,n){const r=function(e,t){const n=Sl(t);let r=t,a=Cl;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Gl.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Xl,ec);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Xl.test(e)){let n=e.replace(Jl,Zl);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=Fl}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 pc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new kc("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=Ic+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)Nc.call(e,n)&&(t[Lc(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Yl[r.property]||r.property:r.attribute,n]}}function Oc(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=vl(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=vl(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 Nc.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);zc(e)}function zc(e,t){const n=new kc("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=Ic+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Lc(e){let t=e.replace(Sc,Fc);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function Fc(e){return"-"+e.toLowerCase()}const Mc={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"]},Bc={};function Uc(e,t){return $c(e,"boolean"!=typeof Bc.includeImageAlt||Bc.includeImageAlt,"boolean"!=typeof Bc.includeHtml||Bc.includeHtml)}function $c(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 Vc(e.children,t,n)}return Array.isArray(e)?Vc(e,t,n):""}function Vc(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=$c(e[a],t,n);return r.join("")}const Hc=document.createElement("i");function qc(e){const t="&"+e+";";Hc.innerHTML=t;const n=Hc.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Wc(e,t,n,r){const a=e.length;let s,i=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Qc(e,t){return e.length>0?(Wc(e,e.length,0,t),e):t}const Kc={}.hasOwnProperty;function Yc(e){const t={};let n=-1;for(;++n<e.length;)Jc(t,e[n]);return t}function Jc(e,t){let n;for(n in t){const r=(Kc.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Kc.call(r,s)||(r[s]=[]);const e=a[s];Xc(r[s],Array.isArray(e)?e:e?[e]:[])}}}function Xc(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Wc(e,0,0,r)}function Gc(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 Zc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const eu=fu(/[A-Za-z]/),tu=fu(/[\dA-Za-z]/),nu=fu(/[#-'*+\--9=?A-Z^-~]/);function ru(e){return null!==e&&(e<32||127===e)}const au=fu(/\d/),su=fu(/[\dA-Fa-f]/),iu=fu(/[!-/:-@[-`{-~]/);function ou(e){return null!==e&&e<-2}function lu(e){return null!==e&&(e<0||32===e)}function cu(e){return-2===e||-1===e||32===e}const uu=fu(/\p{P}|\p{S}/u),du=fu(/\s/);function fu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mu(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&tu(e.charCodeAt(n+1))&&tu(e.charCodeAt(n+2)))a=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),a=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+a+1,i=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function pu(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(cu(r))return e.enter(n),i(r);return t(r)};function i(r){return cu(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const hu={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"),pu(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)):ou(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const gu={tokenize:function(e){const t=this,n=[];let r,a,s,i=0;return o;function o(r){if(i<n.length){const a=n[i];return t.containerState=a[1],e.attempt(a[0].continuation,l,c)(r)}return c(r)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&y();const n=t.events.length;let a,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){a=t.events[s][1].end;break}x(i);let o=n;for(;o<t.events.length;)t.events[o][1].end={...a},o++;return Wc(t.events,s+1,0,t.events.slice(n)),t.events.length=o,c(e)}return o(e)}function c(a){if(i===n.length){if(!r)return f(a);if(r.currentConstruct&&r.currentConstruct.concrete)return p(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(xu,u,d)(a)}function u(e){return r&&y(),x(i),f(e)}function d(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function f(n){return t.containerState={},e.attempt(xu,m,p)(n)}function m(e){return i++,n.push([t.currentConstruct,t.containerState]),f(e)}function p(n){return null===n?(r&&y(),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)):ou(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(n),h)}function g(e,n){const o=t.sliceStream(e);if(n&&o.push(null),e.previous=a,a&&(a.next=e),a=e,r.defineSkip(e.start),r.write(o),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<s&&(!r.events[e][1].end||r.events[e][1].end.offset>s))return;const n=t.events.length;let a,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(a){o=t.events[l][1].end;break}a=!0}for(x(i),e=n;e<t.events.length;)t.events[e][1].end={...o},e++;Wc(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 y(){r.write([null]),a=void 0,r=void 0,t.containerState._closeFlow=void 0}}},xu={tokenize:function(e,t,n){return pu(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function yu(e){return null===e||lu(e)||du(e)?1:uu(e)?2:void 0}function bu(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const s=e[a].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const vu={name:"attention",resolveAll:function(e,t){let n,r,a,s,i,o,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;o=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};wu(d,-o),wu(f,o),s={type:o>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},i={type:o>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:f},a={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:o>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[u][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=Qc(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=Qc(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=Qc(l,bu(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=Qc(l,[["exit",a,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=Qc(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,Wc(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=yu(r);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(o){if(o===s)return e.consume(o),i;const l=e.exit("attentionSequence"),c=yu(o),u=!c||2===c&&a||n.includes(o),d=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===s?u:u&&(a||!d)),l._close=Boolean(42===s?d:d&&(c||!u)),t(o)}}};function wu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ku={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 eu(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||tu(e)?(r=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),r=0,o):(43===t||45===t||46===t||tu(t))&&r++<32?(e.consume(t),i):(r=0,l(t))}function o(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||ru(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):nu(t)?(e.consume(t),l):n(t)}function c(e){return tu(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||tu(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const Nu={partial:!0,tokenize:function(e,t,n){return function(t){return cu(t)?pu(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||ou(e)?t(e):n(e)}}};const ju={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(cu(t))return pu(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(ju,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 cu(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const Su={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 iu(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const Cu={name:"characterReference",tokenize:function(e,t,n){const r=this;let a,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),a=31,s=tu,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,s=su,c):(e.enter("characterReferenceValue"),a=7,s=au,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==tu||qc(r.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(o)}return s(o)&&i++<a?(e.consume(o),c):n(o)}}};const Tu={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)}}},Iu={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),cu(t)?pu(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),u(t)):n(t)}function u(t){return t===s?(a++,e.consume(t),u):a>=o?(e.exit("codeFencedFenceSequence"),cu(t)?pu(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||ou(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let s,i=0,o=0;return function(t){return function(t){const n=r.events[r.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),cu(t)?pu(e,c,"whitespace")(t):c(t))}function c(n){return null===n||ou(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Tu,m,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||ou(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):cu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),pu(e,d,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),u)}function d(t){return null===t||ou(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||ou(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),f)}function m(t){return e.attempt(a,y,p)(t)}function p(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return i>0&&cu(t)?pu(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||ou(t)?e.check(Tu,m,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||ou(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const Eu={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),pu(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?s(e):n(e)}function s(t){return null===t?o(t):ou(t)?e.attempt(Pu,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||ou(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},Pu={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):ou(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):pu(e,s,"linePrefix",5)(t)}function s(e){const s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):ou(e)?a(e):n(e)}}};const Au={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,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),o(t))}function o(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):96===t?(a=e.enter("codeTextSequence"),r=0,c(t)):ou(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||ou(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(a.type="codeTextData",l(n))}}};class Ru{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&&_u(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),_u(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),_u(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);_u(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);_u(this.left,t.reverse())}}}function _u(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 Du(e){const t={};let n,r,a,s,i,o,l,c=-1;const u=new Ru(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&&(o=n[1]._tokenizer.events,a=0,a<o.length&&"lineEndingBlank"===o[a][1].type&&(a+=2),a<o.length&&"content"===o[a][1].type))for(;++a<o.length&&"content"!==o[a][1].type;)"chunkText"===o[a][1].type&&(o[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,Ou(u,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(s=u.get(a),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(r&&(u.get(r)[1].type="lineEndingBlank"),s[1].type="lineEnding",r=a);else if("linePrefix"!==s[1].type&&"listItemIndent"!==s[1].type)break;r&&(n[1].end={...u.get(r)[1].start},i=u.slice(r,c),i.unshift(n),u.splice(r,c-r+1,i))}}return Wc(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function Ou(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const s=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const o=i.events,l=[],c={};let u,d,f=-1,m=n,p=0,h=0;const g=[h];for(;m;){for(;e.get(++a)[1]!==m;);s.push(a),m._tokenizer||(u=r.sliceStream(m),m.next||u.push(null),d&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(u),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=m,m=m.next}for(m=n;++f<o.length;)"exit"===o[f][0]&&"enter"===o[f-1][0]&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(h=f+1,g.push(h),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):g.pop(),f=g.length;f--;){const t=o.slice(g[f],g[f+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),f=-1;++f<l.length;)c[p+l[f][0]]=p+l[f][1],p+=l[f][1]-l[f][0]-1;return c}const zu={resolve:function(e){return Du(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):ou(t)?e.check(Lu,s,a)(t):(e.consume(t),r)}function a(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},Lu={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"),pu(e,a,"linePrefix")};function a(a){if(null===a||ou(a))return n(a);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}};function Fu(e,t,n,r,a,s,i,o,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(s),e.consume(t),e.exit(s),d;if(null===t||32===t||41===t||ru(t))return n(t);return e.enter(r),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function d(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(a),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(o),d(t)):null===t||60===t||ou(t)?n(t):(e.consume(t),92===t?m:f)}function m(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function p(a){return u||null!==a&&41!==a&&!lu(a)?u<c&&40===a?(e.consume(a),u++,p):41===a?(e.consume(a),u--,p):null===a||32===a||40===a||ru(a)?n(a):(e.consume(a),92===a?h:p):(e.exit("chunkString"),e.exit(o),e.exit(i),e.exit(r),t(a))}function h(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function Mu(e,t,n,r,a,s){const i=this;let o,l=0;return function(t){return e.enter(r),e.enter(a),e.consume(t),e.exit(a),e.enter(s),c};function c(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):93===d?(e.exit(s),e.enter(a),e.consume(d),e.exit(a),e.exit(r),t):ou(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||ou(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!cu(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function Bu(e,t,n,r,a,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(a),e.consume(t),e.exit(a),i=40===t?41:t,o;return n(t)};function o(n){return n===i?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),o(i)):null===t?n(t):ou(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),pu(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||ou(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===i||92===t?(e.consume(t),c):c(t)}}function Uu(e,t){let n;return function r(a){if(ou(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(cu(a))return pu(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const $u={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return Mu.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=Zc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return lu(t)?Uu(e,o)(t):o(t)}function o(t){return Fu(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Vu,c,c)(t)}function c(t){return cu(t)?pu(e,u,"whitespace")(t):u(t)}function u(s){return null===s||ou(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},Vu={partial:!0,tokenize:function(e,t,n){return function(t){return lu(t)?Uu(e,r)(t):n(t)};function r(t){return Bu(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return cu(t)?pu(e,s,"whitespace")(t):s(t)}function s(e){return null===e||ou(e)?t(e):n(e)}}};const Hu={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return ou(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const qu={name:"headingAtx",resolve:function(e,t){let n,r,a=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);a-2>s&&"whitespace"===e[a][1].type&&(a-=2);"atxHeadingSequence"===e[a][1].type&&(s===a-1||a-4>s&&"whitespace"===e[a-2][1].type)&&(a-=s+1===a?2:4);a>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[a][1].end},r={type:"chunkText",start:e[s][1].start,end:e[a][1].end,contentType:"text"},Wc(e,s,a-s+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||lu(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||ou(n)?(e.exit("atxHeading"),t(n)):cu(n)?pu(e,s,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function o(t){return null===t||35===t||lu(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const Wu=["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"],Qu=["pre","script","style","textarea"],Ku={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,s,i,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),s=!0,m):63===o?(e.consume(o),a=3,r.interrupt?t:D):eu(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function u(s){return 45===s?(e.consume(s),a=2,d):91===s?(e.consume(s),a=5,o=0,f):eu(s)?(e.consume(s),a=4,r.interrupt?t:D):n(s)}function d(a){return 45===a?(e.consume(a),r.interrupt?t:D):n(a)}function f(a){const s="CDATA[";return a===s.charCodeAt(o++)?(e.consume(a),6===o?r.interrupt?t:C:f):n(a)}function m(t){return eu(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||lu(o)){const l=47===o,c=i.toLowerCase();return l||s||!Qu.includes(c)?Wu.includes(i.toLowerCase())?(a=6,l?(e.consume(o),h):r.interrupt?t(o):C(o)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(o):s?g(o):x(o)):(a=1,r.interrupt?t(o):C(o))}return 45===o||tu(o)?(e.consume(o),i+=String.fromCharCode(o),p):n(o)}function h(a){return 62===a?(e.consume(a),r.interrupt?t:C):n(a)}function g(t){return cu(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||eu(t)?(e.consume(t),y):cu(t)?(e.consume(t),x):j(t)}function y(t){return 45===t||46===t||58===t||95===t||tu(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),v):cu(t)?(e.consume(t),b):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):cu(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,N):null===t||ou(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||lu(t)?b(t):(e.consume(t),k)}function N(e){return 47===e||62===e||cu(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||ou(t)?C(t):cu(t)?(e.consume(t),S):n(t)}function C(t){return 45===t&&2===a?(e.consume(t),P):60===t&&1===a?(e.consume(t),A):62===t&&4===a?(e.consume(t),O):63===t&&3===a?(e.consume(t),D):93===t&&5===a?(e.consume(t),_):!ou(t)||6!==a&&7!==a?null===t||ou(t)?(e.exit("htmlFlowData"),T(t)):(e.consume(t),C):(e.exit("htmlFlowData"),e.check(Yu,z,T)(t))}function T(t){return e.check(Ju,I,z)(t)}function I(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||ou(t)?T(t):(e.enter("htmlFlowData"),C(t))}function P(t){return 45===t?(e.consume(t),D):C(t)}function A(t){return 47===t?(e.consume(t),i="",R):C(t)}function R(t){if(62===t){const n=i.toLowerCase();return Qu.includes(n)?(e.consume(t),O):C(t)}return eu(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),R):C(t)}function _(t){return 93===t?(e.consume(t),D):C(t)}function D(t){return 62===t?(e.consume(t),O):45===t&&2===a?(e.consume(t),D):C(t)}function O(t){return null===t||ou(t)?(e.exit("htmlFlowData"),z(t)):(e.consume(t),O)}function z(n){return e.exit("htmlFlow"),t(n)}}},Yu={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Nu,t,n)}}},Ju={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(ou(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 Xu={name:"htmlText",tokenize:function(e,t,n){const r=this;let a,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),y):eu(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,m):eu(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):ou(t)?(i=u,R(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),f):u(t)}function f(e){return 62===e?A(e):45===e?d(e):u(e)}function m(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:m):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),h):ou(t)?(i=p,R(t)):(e.consume(t),p)}function h(t){return 93===t?(e.consume(t),g):p(t)}function g(t){return 62===t?A(t):93===t?(e.consume(t),g):p(t)}function x(t){return null===t||62===t?A(t):ou(t)?(i=x,R(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):ou(t)?(i=y,R(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function v(t){return eu(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||tu(t)?(e.consume(t),w):k(t)}function k(t){return ou(t)?(i=k,R(t)):cu(t)?(e.consume(t),k):A(t)}function N(t){return 45===t||tu(t)?(e.consume(t),N):47===t||62===t||lu(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),A):58===t||95===t||eu(t)?(e.consume(t),S):ou(t)?(i=j,R(t)):cu(t)?(e.consume(t),j):A(t)}function S(t){return 45===t||46===t||58===t||95===t||tu(t)?(e.consume(t),S):C(t)}function C(t){return 61===t?(e.consume(t),T):ou(t)?(i=C,R(t)):cu(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,I):ou(t)?(i=T,R(t)):cu(t)?(e.consume(t),T):(e.consume(t),E)}function I(t){return t===a?(e.consume(t),a=void 0,P):null===t?n(t):ou(t)?(i=I,R(t)):(e.consume(t),I)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||lu(t)?j(t):(e.consume(t),E)}function P(e){return 47===e||62===e||lu(e)?j(e):n(e)}function A(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function R(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),_}function _(t){return cu(t)?pu(e,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),i(t)}}};const Gu={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&&Wc(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,a,s,i=e.length,o=0;for(;i--;)if(n=e[i][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(a){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=i,"labelLink"!==n.type)){o=2;break}}else"labelEnd"===n.type&&(a=i);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+o+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=Qc(s,e.slice(r+1,r+o+3)),s=Qc(s,[["enter",u,t]]),s=Qc(s,bu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=Qc(s,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),s=Qc(s,e.slice(a+1)),s=Qc(s,[["exit",l,t]]),Wc(e,r,e.length,s),e},tokenize:function(e,t,n){const r=this;let a,s,i=r.events.length;for(;i--;)if(("labelImage"===r.events[i][1].type||"labelLink"===r.events[i][1].type)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return function(t){if(!a)return n(t);if(a._inactive)return u(t);return s=r.parser.defined.includes(Zc(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o};function o(t){return 40===t?e.attempt(Zu,c,s?c:u)(t):91===t?e.attempt(ed,c,s?l:u)(t):s?c(t):u(t)}function l(t){return e.attempt(td,c,u)(t)}function c(e){return t(e)}function u(e){return a._balanced=!0,n(e)}}},Zu={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 lu(t)?Uu(e,a)(t):a(t)}function a(t){return 41===t?c(t):Fu(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return lu(t)?Uu(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?Bu(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return lu(t)?Uu(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)}}},ed={tokenize:function(e,t,n){const r=this;return function(t){return Mu.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(Zc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},td={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 nd={name:"labelStartImage",resolveAll:Gu.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"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const rd={name:"labelStartLink",resolveAll:Gu.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 ad={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),pu(e,t,"linePrefix")}}};const sd={name:"thematicBreak",tokenize:function(e,t,n){let r,a=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,s(e)}(t)};function s(s){return s===r?(e.enter("thematicBreakSequence"),i(s)):a>=3&&(null===s||ou(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),cu(t)?pu(e,s,"whitespace")(t):s(t))}}};const id={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Nu,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,pu(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!cu(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ld,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,pu(e,e.attempt(id,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 s=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,i=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:au(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(sd,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return au(t)&&++i<10?(e.consume(t),o):(!r.interrupt||i<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(Nu,r.interrupt?n:c,e.attempt(od,d,u))}function c(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return cu(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},od={partial:!0,tokenize:function(e,t,n){const r=this;return pu(e,function(e){const a=r.events[r.events.length-1];return!cu(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},ld={partial:!0,tokenize:function(e,t,n){const r=this;return pu(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 cd={name:"setextUnderline",resolveTo:function(e,t){let n,r,a,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),a||"definition"!==e[s][1].type||(a=s);const i={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",i,t]),e.splice(a+1,0,["exit",e[n][1],t]),e[n][1].end={...e[a][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const r=this;let a;return function(t){let i,o=r.events.length;for(;o--;)if("lineEnding"!==r.events[o][1].type&&"linePrefix"!==r.events[o][1].type&&"content"!==r.events[o][1].type){i="paragraph"===r.events[o][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||i))return e.enter("setextHeadingLine"),a=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===a?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),cu(t)?pu(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||ou(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const ud={tokenize:function(e){const t=this,n=e.attempt(Nu,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,pu(e,e.attempt(this.parser.constructs.flow,r,e.attempt(zu,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 dd={resolveAll:hd()},fd=pd("string"),md=pd("text");function pd(e){return{resolveAll:hd("text"===e?gd:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],a=t.attempt(r,s,i);return s;function s(e){return l(e)?a(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),a(e)):(t.consume(e),o)}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 hd(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 gd(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 s,i=a.length,o=-1,l=0;for(;i--;){const e=a[i];if("string"==typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const a={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,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 xd={42:id,43:id,45:id,48:id,49:id,50:id,51:id,52:id,53:id,54:id,55:id,56:id,57:id,62:ju},yd={91:$u},bd={[-2]:Eu,[-1]:Eu,32:Eu},vd={35:qu,42:sd,45:[cd,sd],60:Ku,61:cd,95:sd,96:Iu,126:Iu},wd={38:Cu,92:Su},kd={[-5]:ad,[-4]:ad,[-3]:ad,33:nd,38:Cu,42:vu,60:[ku,Xu],91:rd,92:[Hu,Su],93:Gu,95:vu,96:Au},Nd={null:[vu,dd]};var jd=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:yd,disable:{null:[]},document:xd,flow:vd,flowInitial:bd,insideSpan:Nd,string:wd,text:kd});function Sd(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={},s=[];let i=[],o=[];const l={attempt:g(function(e,t){x(e,t.from)}),check:g(h),consume:function(e){ou(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,y()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[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]),o.push(n),n},exit:function(e){const t=o.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,y()},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 s=e[n];let i;if("string"==typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&a)continue;i=" ";break;default:i=String.fromCharCode(s)}a=-2===s,r.push(i)}return r.join("")}(d(e),t)},sliceStream:d,write:function(e){if(i=Qc(i,e),m(),null!==i[i.length-1])return[];return x(t,0),c.events=bu(s,c.events,c),c.events}};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,s=t.end._bufferIndex;let i;if(n===a)i=[e[n].slice(r,s)];else{if(i=e.slice(n,a),r>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(r):i.shift()}s>0&&i.push(e[a].slice(0,s))}return i}(i,e)}function f(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:s}}function m(){let e;for(;r._index<i.length;){const t=i[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)p(t.charCodeAt(r._bufferIndex));else p(t)}}function p(e){u=u(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,s){let i,u,d,m;return Array.isArray(n)?p(n):"tokenize"in n?p([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return p([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function p(e){return i=e,u=0,0===e.length?s:h(e[u])}function h(e){return function(n){m=function(){const e=f(),t=c.previous,n=c.currentConstruct,a=c.events.length,s=Array.from(o);return{from:a,restore:i};function i(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=a,o=s,y()}}(),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,m),a}function x(e){return m.restore(),++u<i.length?h(i[u]):s}}}function x(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&Wc(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function y(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}const Cd=/[\0\t\n\r]/g;const Td=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Id(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Gc(n.slice(t?2:1),t?16:10)}return qc(n)||e}const Ed={}.hasOwnProperty;function Pd(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:s(te),autolinkProtocol:S,autolinkEmail:S,atxHeading:s(X),blockQuote:s(W),characterEscape:S,characterReference:S,codeFenced:s(Q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(Q,i),codeText:s(K,i),codeTextData:S,data:S,codeFlowValue:S,definition:s(Y),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(G),hardBreakTrailing:s(G),htmlFlow:s(Z,i),htmlFlowData:S,htmlText:s(Z,i),htmlTextData:S,image:s(ee),label:i,link:s(te),listItem:s(re),listItemValue:f,listOrdered:s(ne,d),listUnordered:s(ne),paragraph:s(ae),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(X),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:q,autolinkProtocol:H,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:$,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:m,codeFencedFenceMeta:p,codeFlowValue:C,codeIndented:l(x),codeText:l(A),codeTextData:C,data:C,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(E),htmlFlowData:C,htmlText:l(P),htmlTextData:C,image:l(_),label:O,labelText:D,lineEnding:T,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:z,resourceTitleString:L,resource:F,setextHeading:l(j),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};Rd(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const s={stack:[r],tokenStack:[],config:t,enter:o,exit:c,buffer:i,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]];Ed.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},s),e[d][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||Dd).call(s,void 0,e[0])}for(r.position={start:Ad(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Ad(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,s,i,o=t-1,l=-1,c=!1;for(;++o<=n;){const t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||i||l||s||(s=o),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=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 i=o;for(a=void 0;i--;){const t=e[i];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=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!a||s<a)&&(r._spread=!0),r.end=Object.assign({},a?e[a][1].start:t[1].end),e.splice(a||o,0,["exit",r,t[2]]),o++,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(o,0,["enter",a,t[2]]),o++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(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:Ad(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+"` ("+yc({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]||Dd).call(this,e,r[0])}n.position.end=Ad(e.end)}function u(){return Uc(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 m(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function p(){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 y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Zc(this.sliceSerialize(e)).toLowerCase()}function b(){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=ie(),n.position={start:Ad(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=Ad(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=Ad(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 I(){this.data.atHardBreak=!0}function E(){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 A(){const e=this.resume();this.stack[this.stack.length-1].value=e}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 _(){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 D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(Td,Id)}(t),n.identifier=Zc(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 z(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function F(){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=Zc(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=Gc(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=qc(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=Ad(e.end)}function H(e){C.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function q(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 K(){return{type:"inlineCode",value:""}}function Y(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function G(){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 se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}(n)(function(e){for(;!Du(e););return e}(function(e){const t={constructs:Yc([jd,...(e||{}).extensions||[]]),content:n(hu),defined:[],document:n(gu),flow:n(ud),lazy:{},string:n(fd),text:n(md)};return t;function n(e){return function(n){return Sd(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,s,i){const o=[];let l,c,u,d,f;for(a=n+("string"==typeof a?a.toString():new TextDecoder(s||void 0).decode(a)),u=0,n="",r&&(65279===a.charCodeAt(0)&&u++,r=void 0);u<a.length;){if(Cd.lastIndex=u,l=Cd.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)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),u<d&&(o.push(a.slice(u,d)),t+=d-u),f){case 0:o.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),o.push(-2);t++<c;)o.push(-1);break;case 10:o.push(-4),t=1;break;default:e=!0,t=1}u=d+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function Ad(e){return{line:e.line,column:e.column,offset:e.offset}}function Rd(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Rd(e,r):_d(e,r)}}function _d(e,t){let n;for(n in t)if(Ed.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 Dd(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+yc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+yc({start:t.start,end:t.end})+") is still open")}function Od(e){const t=this;t.parser=function(n){return Pd(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function zd(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),s=a[0];s&&"text"===s.type?s.value="["+s.value:a.unshift({type:"text",value:"["});const i=a[a.length-1];return i&&"text"===i.type?i.value+=r:a.push({type:"text",value:r}),a}function Ld(e){const t=e.spread;return null==t?e.children.length>1:t}function Fd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(Md(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(Md(t.slice(a),a>0,!1)),s.join("")}function Md(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 Bd={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=mu(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let i,o=e.footnoteCounts.get(r);void 0===o?(o=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};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 zd(e,t);const a={src:mu(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:mu(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 zd(e,t);const a={href:mu(r.url||"")};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:mu(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=Ld(n[r])}return t}(n):Ld(t),s={},i=[];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:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const e=r[o];(a||0!==o||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||a?i.push(e):i.push(...e.children)}const l=r[r.length-1];l&&(a||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};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 s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},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)},s=gc(t.children[1]),i=hc(t.children[t.children.length-1]);s&&i&&(r.position={start:s,end:i}),a.push(r)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,s),e.applyData(t,s)},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",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let o=-1;const l=[];for(;++o<i;){const n=t.children[o],r={},i=s?s[o]:void 0;i&&(r.align=i);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:Fd(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:Ud,yaml:Ud,definition:Ud,footnoteDefinition:Ud};function Ud(){}const $d="object"==typeof self?self:globalThis,Vd=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=a=>{if(e.has(a))return e.get(a);const[s,i]=t[a];switch(s){case 0:case-1:return n(i,a);case 1:{const e=n([],a);for(const t of i)e.push(r(t));return e}case 2:{const e=n({},a);for(const[t,n]of i)e[r(t)]=r(n);return e}case 3:return n(new Date(i),a);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),a)}case 5:{const e=n(new Map,a);for(const[t,n]of i)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,a);for(const t of i)e.add(r(t));return e}case 7:{const{name:e,message:t}=i;return n(new $d[e](t),a)}case 8:return n(BigInt(i),a);case"BigInt":return n(Object(BigInt(i)),a);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:e}=new Uint8Array(i);return n(new DataView(e),i)}}return n(new $d[s](i),a)};return r})(new Map,e)(0),Hd="",{toString:qd}={},{keys:Wd}=Object,Qd=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=qd.call(e).slice(8,-1);switch(n){case"Array":return[1,Hd];case"Object":return[2,Hd];case"Date":return[3,Hd];case"RegExp":return[4,Hd];case"Map":return[5,Hd];case"Set":return[6,Hd];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Kd=([e,t])=>0===e&&("function"===t||"symbol"===t),Yd=(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},s=r=>{if(n.has(r))return n.get(r);let[i,o]=Qd(r);switch(i){case 0:{let t=r;switch(o){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return a([-1],r)}return a([i,t],r)}case 1:{if(o){let e=r;return"DataView"===o?e=new Uint8Array(r.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(r)),a([o,[...e]],r)}const e=[],t=a([i,e],r);for(const n of r)e.push(s(n));return t}case 2:{if(o)switch(o){case"BigInt":return a([o,r.toString()],r);case"Boolean":case"Number":case"String":return a([o,r.valueOf()],r)}if(t&&"toJSON"in r)return s(r.toJSON());const n=[],l=a([i,n],r);for(const t of Wd(r))!e&&Kd(Qd(r[t]))||n.push([s(t),s(r[t])]);return l}case 3:return a([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return a([i,{source:e,flags:t}],r)}case 5:{const t=[],n=a([i,t],r);for(const[a,i]of r)(e||!Kd(Qd(a))&&!Kd(Qd(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&Kd(Qd(a))||t.push(s(a));return n}}const{message:l}=r;return a([i,{name:o,message:l}],r)};return s})(!(t||n),!!t,new Map,r)(e),r};var Jd="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Vd(Yd(e,t)):structuredClone(e):(e,t)=>Vd(Yd(e,t));function Xd(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 Gd(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Zd=function(e){if(null==e)return tf;if("function"==typeof e)return ef(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Zd(e[n]);return ef(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 ef(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 ef(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function ef(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 tf(){return!0}const nf=[],rf=!0,af=!1;function sf(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=Zd(a),i=r?-1:1;!function e(a,o,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=nf;if((!t||s(a,o,l[l.length-1]||void 0))&&(f=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[rf,e];return null==e?nf:[e]}(n(a,l)),f[0]===af))return f;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==f[0])for(u=(r?t.children.length:-1)+i,d=l.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===af)return c;u="number"==typeof c[1]?c[1]:u+i}}return f}}(e,void 0,[])()}function of(e,t,n,r){let a,s,i;"function"==typeof t&&"function"!=typeof n?(s=void 0,i=t,a=n):(s=t,i=n,a=r),sf(e,s,function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return i(e,r,n)},a)}const lf={}.hasOwnProperty,cf={};function uf(e,t){e.position&&(t.position=function(e){const t=gc(e),n=hc(e);if(t&&n)return{start:t,end:n}}(e))}function df(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,Jd(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function ff(e,t){const n=t.data||{},r=!("value"in t)||lf.call(n,"hProperties")||lf.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 mf(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 pf(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function hf(e,t){const n=function(e,t){const n=t||cf,r=new Map,a=new Map,s=new Map,i={...Bd,...n.handlers},o={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const a=o.one(n[r],e);if(a){if(r&&"break"===n[r-1].type&&(Array.isArray(a)||"text"!==a.type||(a.value=pf(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=pf(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:df,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(lf.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=Jd(n);return r.children=o.all(e),r}return Jd(e)}return(o.options.unknownHandler||ff)(o,e,t)},options:n,patch:uf,wrap:mf};return of(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)}}),o}(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||Xd,r=e.options.footnoteBackLabel||Gd,a=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const a=e.footnoteById.get(e.footnoteOrder[l]);if(!a)continue;const s=e.all(a),i=String(a.identifier).toUpperCase(),c=mu(i.toLowerCase());let u=0;const d=[],f=e.footnoteCounts.get(i);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 m=s[s.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else s.push(...d);const p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(a,p),o.push(p)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Jd(i),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:"\n"}]}}(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&s.children.push({type:"text",value:"\n"},a),s}function gf(e,t){return e&&"run"in e?async function(n,r){const a=hf(n,{file:r,...t});await e.run(a,r)}:function(n,r){return hf(n,{file:r,...e||t})}}function xf(e){if(e)throw e}var yf,bf;var vf=function(){if(bf)return yf;bf=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)},s=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,a=e.call(n,"constructor"),s=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!a&&!s)return!1;for(r in n);return void 0===r||e.call(n,r)},i=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},o=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return yf=function e(){var t,n,r,l,c,u,d=arguments[0],f=1,m=arguments.length,p=!1;for("boolean"==typeof d&&(p=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<m;++f)if(null!=(t=arguments[f]))for(n in t)r=o(d,n),d!==(l=o(t,n))&&(p&&l&&(s(l)||(c=a(l)))?(c?(c=!1,u=r&&a(r)?r:[]):u=r&&s(r)?r:{},i(d,{name:n,newValue:e(p,u,l)})):void 0!==l&&i(d,{name:n,newValue:l}));return d},yf}(),wf=jt(vf);function kf(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 Nf(){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(s,...i){const o=e[++n];let l=-1;if(s)r(s);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,o?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let o;r&&t.push(a);try{o=e.apply(this,t)}catch(s){if(r&&n)throw s;return a(s)}r||(o&&o.then&&"function"==typeof o.then?o.then(i,a):o instanceof Error?a(o):i(o))}function a(e,...r){n||(n=!0,t(e,...r))}function i(e){a(null,e)}}(o,a)(...i):r(null,...i)}}(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 jf={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Sf(e);let n,r=0,a=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else a<0&&(n=!0,a=s+1);return a<0?"":e.slice(r,a)}if(t===e)return"";let i=-1,o=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1),o>-1&&(e.codePointAt(s)===t.codePointAt(o--)?o<0&&(a=s):(o=-1,a=i));r===a?a=i:a<0&&(a=e.length);return e.slice(r,a)},dirname:function(e){if(Sf(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){Sf(e);let t,n=e.length,r=-1,a=0,s=-1,i=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)r<0&&(t=!0,r=n+1),46===o?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){a=n+1;break}}if(s<0||r<0||0===i||1===i&&s===r-1&&s===a+1)return"";return e.slice(s,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)Sf(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Sf(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,a="",s=0,i=-1,o=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(i===l-1||1===o);else if(i!==l-1&&2===o){if(a.length<2||2!==s||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="",s=0):(a=a.slice(0,r),s=a.length-1-a.lastIndexOf("/")),i=l,o=0;continue}}else if(a.length>0){a="",s=0,i=l,o=0;continue}t&&(a=a.length>0?a+"/..":"..",s=2)}else a.length>0?a+="/"+e.slice(i+1,l):a=e.slice(i+1,l),s=l-i-1;i=l,o=0}else 46===n&&o>-1?o++:o=-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 Sf(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Cf={cwd:function(){return"/"}};function Tf(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function If(e){if("string"==typeof e)e=new URL(e);else if(!Tf(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 Ef=["history","path","basename","stem","extname","dirname"];class Pf{constructor(e){let t;t=e?Tf(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?"":Cf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<Ef.length;){const e=Ef[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Ef.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?jf.basename(this.path):void 0}set basename(e){Rf(e,"basename"),Af(e,"basename"),this.path=jf.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?jf.dirname(this.path):void 0}set dirname(e){_f(this.basename,"dirname"),this.path=jf.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?jf.extname(this.path):void 0}set extname(e){if(Af(e,"extname"),_f(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=jf.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Tf(e)&&(e=If(e)),Rf(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?jf.basename(this.path,this.extname):void 0}set stem(e){Rf(e,"stem"),Af(e,"stem"),this.path=jf.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 kc(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 Af(e,t){if(e&&e.includes(jf.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+jf.sep+"`")}function Rf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function _f(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Df=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},Of={}.hasOwnProperty;class zf extends Df{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=Nf()}copy(){const e=new zf;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(wf(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Bf("data",this.frozen),this.namespace[e]=t,this):Of.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Bf("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=Vf(e),n=this.parser||this.Parser;return Ff("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),Ff("process",this.parser||this.Parser),Mf("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=Vf(e),i=n.parse(s);function o(e,n){e||!n?a(e):r?r(n):t(void 0,n)}n.run(i,s,function(e,t,r){if(e||!t||!r)return o(e);const a=t,s=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)}(s)?r.result=s:r.value=s,o(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),Ff("processSync",this.parser||this.Parser),Mf("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,xf(e),t=r}),$f("processSync","process",n),t}run(e,t,n){Uf(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,s){const i=Vf(t);r.run(e,i,function(t,r,i){const o=r||e;t?s(t):a?a(o):n(void 0,o,i)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){xf(e),n=t,r=!0}),$f("runSync","run",r),n}stringify(e,t){this.freeze();const n=Vf(t),r=this.compiler||this.Compiler;return Mf("stringify",r),Uf(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(Bf("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):s(e)}return this;function a(e){if("function"==typeof e)o(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;o(t,n)}else s(e)}}function s(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");i(e.plugins),e.settings&&(r.settings=wf(!0,r.settings,e.settings))}function i(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 o(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,...s]=t;const i=n[a][1];kf(i)&&kf(r)&&(r=wf(!0,i,r)),n[a]=[e,r,...s]}}}}const Lf=(new zf).freeze();function Ff(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Mf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Bf(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 Uf(e){if(!kf(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function $f(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Vf(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new Pf(e)}const Hf=[],qf={allowDangerousHtml:!0},Wf=/^(https?|ircs?|mailto|xmpp)$/i,Qf=[{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 Kf(e){const t=function(e){const t=e.rehypePlugins||Hf,n=e.remarkPlugins||Hf,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qf}:qf,a=Lf().use(Od).use(n).use(gf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new Pf;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||Yf;for(const u of Qf)Object.hasOwn(t,u.from)&&gl((u.from,u.to&&u.to,u.id));return of(e,c),Ec(e,{Fragment:Rt.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Rt.jsx,jsxs:Rt.jsxs,passKeys:!0,passNode:!0});function c(e,t,a){if("raw"===e.type&&a&&"number"==typeof t)return i?a.children.splice(t,1):a.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in Mc)if(Object.hasOwn(Mc,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=Mc[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&r&&"number"==typeof t&&(i=!r(e,t,a)),i&&a&&"number"==typeof t)return o&&e.children?a.children.splice(t,1,...e.children):a.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Yf(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||Wf.test(e.slice(0,t))?e:""}function Jf(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 Xf(e,t,n){const r=Zd((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([Gf(e[0]),Zf(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)sf(e,"text",i);function i(e,t){let n,i=-1;for(;++i<t.length;){const e=t[i],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[s][0],i=a[s][1];let o=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 s=i(...d,a);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(o!==n&&u.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?u.push(...s):s&&u.push(s),o=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}c?(o<e.value.length&&u.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...u)):u=[e];return l+u.length}(e,t)}}function Gf(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 Zf(e){return"function"==typeof e?e:function(){return e}}const em="phrasing",tm=["autolink","link","image","label"];function nm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function rm(e){this.config.enter.autolinkProtocol.call(this,e)}function am(e){this.config.exit.autolinkProtocol.call(this,e)}function sm(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 im(e){this.config.exit.autolinkEmail.call(this,e)}function om(e){this.exit(e)}function lm(e){Xf(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,cm],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,um]],{ignore:["link","linkReference"]})}function cm(e,t,n,r,a){let s="";if(!dm(a))return!1;if(/^w/i.test(t)&&(n=t+n,t="",s="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 i=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=Jf(e,"(");let s=Jf(e,")");for(;-1!==r&&a>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}(n+r);if(!i[0])return!1;const o={type:"link",title:null,url:s+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[o,{type:"text",value:i[1]}]:o}function um(e,t,n,r){return!(!dm(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function dm(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||du(n)||uu(n))&&(!t||47!==n)}function fm(){this.buffer()}function mm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function pm(){this.buffer()}function hm(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function gm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zc(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xm(e){this.exit(e)}function ym(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zc(this.sliceSerialize(e)).toLowerCase(),n.label=t}function bm(e){this.exit(e)}function vm(e,t,n,r){const a=n.createTracker(r);let s=a.move("[^");const i=n.enter("footnoteReference"),o=n.enter("reference");return s+=a.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),i(),s+=a.move("]"),s}function wm(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,r,a){const s=r.createTracker(a);let i=s.move("[^");const o=r.enter("footnoteDefinition"),l=r.enter("label");i+=s.move(r.safe(r.associationId(e),{before:i,after:"]"})),l(),i+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),i+=s.move((t?"\n":" ")+r.indentLines(r.containerFlow(e,s.current()),t?Nm:km)));return o(),i},footnoteReference:vm},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function km(e,t,n){return 0===t?e:Nm(e,t,n)}function Nm(e,t,n){return(n?"":" ")+e}vm.peek=function(){return"["};const jm=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function Sm(e){this.enter({type:"delete",children:[]},e)}function Cm(e){this.exit(e)}function Tm(e,t,n,r){const a=n.createTracker(r),s=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(e,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),s(),i}function Im(e){return e.length}function Em(e){return null==e?"":String(e)}function Pm(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 Am(e,t,n){return">"+(n?"":" ")+e}function Rm(e,t){return _m(e,t.inConstruct,!0)&&!_m(e,t.notInConstruct,!1)}function _m(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 Dm(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&Rm(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function Om(e,t,n){return(n?"":" ")+e}function zm(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 Lm(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Fm(e,t,n){const r=yu(e),a=yu(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 Mm(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),s=n.enter("emphasis"),i=n.createTracker(r),o=i.move(a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),u=Fm(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Lm(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=Fm(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Lm(d));const m=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}function Bm(e){return e.value||""}function Um(e,t,n,r){const a=zm(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("image");let o=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("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),c+=l.move(")"),i(),c}function $m(e,t,n,r){const a=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function Vm(e,t,n){let r=e.value||"",a="`",s=-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+" ");++s<n.unsafe.length;){const e=n.unsafe[s],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 Hm(e,t){const n=Uc(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 qm(e,t,n,r){const a=zm(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(Hm(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let r=i.move("<");return r+=i.move(n.containerPhrasing(e,{before:r,after:">",...i.current()})),r+=i.move(">"),o(),n.stack=t,r}o=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(e,{before:c,after:"](",...i.current()})),c+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(e.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(e.url,{before:c,after:e.title?" ":")",...i.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=i.move(" "+a),c+=i.move(n.safe(e.title,{before:c,after:a,...i.current()})),c+=i.move(a),l()),c+=i.move(")"),o(),c}function Wm(e,t,n,r){const a=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function Qm(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 Km(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}Tm.peek=function(){return"~"},Mm.peek=function(e,t,n){return n.options.emphasis||"*"},Bm.peek=function(){return"<"},Um.peek=function(){return"!"},$m.peek=function(){return"!"},Vm.peek=function(){return"`"},qm.peek=function(e,t,n){return Hm(e,n)?"<":"["},Wm.peek=function(){return"["};const Ym=Zd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Jm(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),s=n.enter("strong"),i=n.createTracker(r),o=i.move(a+a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),u=Fm(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Lm(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=Fm(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Lm(d));const m=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}Jm.peek=function(e,t,n){return n.options.strong||"*"};const Xm={blockquote:function(e,t,n,r){const a=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(e,s.current()),Am);return a(),i},break:Dm,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),s=e.value||"",i="`"===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(s,Om);return e(),t}const o=n.createTracker(r),l=a.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),a=r,s=0,i=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===a?++s>i&&(i=s):s=1,a=r+t.length,r=n.indexOf(t,a);return i}(s,a)+1,3)),c=n.enter("codeFenced");let u=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${i}`);u+=o.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${i}`);u+=o.move(" "),u+=o.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...o.current()})),t()}return u+=o.move("\n"),s&&(u+=o.move(s+"\n")),u+=o.move(l),c(),u},definition:function(e,t,n,r){const a=zm(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("definition");let o=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("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),i(),c},emphasis:Mm,hardBreak:Dm,heading:function(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(function(e,t){let n=!1;return of(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,af}),Boolean((!e.depth||e.depth<3)&&Uc(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),i=n.containerPhrasing(e,{...s.current(),before:"\n",after:"\n"});return r(),t(),i+"\n"+(1===a?"=":"-").repeat(i.length-(Math.max(i.lastIndexOf("\r"),i.lastIndexOf("\n"))+1))}const i="#".repeat(a),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...s.current()});return/^[\t ]/.test(c)&&(c=Lm(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:Bm,image:Um,imageReference:$m,inlineCode:Vm,link:qm,linkReference:Wm,list:function(e,t,n,r){const a=n.enter("list"),s=n.bulletCurrent;let i=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):Qm(n);const o=e.ordered?"."===i?")":".":function(e){const t=Qm(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)&&i===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==i&&"-"!==i||!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),Km(n)===i&&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&&(i=o),n.bulletCurrent=i;const c=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=s,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 s=n.bulletCurrent||Qm(n);t&&"list"===t.type&&t.ordered&&(s=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let i=s.length+1;("tab"===a||"mixed"===a&&(t&&"list"===t.type&&t.spread||e.spread))&&(i=4*Math.ceil(i/4));const o=n.createTracker(r);o.move(s+" ".repeat(i-s.length)),o.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(i))+e;return(n?s:s+" ".repeat(i-s.length))+e});return l(),c},paragraph:function(e,t,n,r){const a=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,r);return s(),a(),i},root:function(e,t,n,r){return(e.children.some(function(e){return Ym(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:Jm,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Km(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 Gm(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 Zm(e){this.exit(e),this.data.inTable=void 0}function ep(e){this.enter({type:"tableRow",children:[]},e)}function tp(e){this.exit(e)}function np(e){this.enter({type:"tableCell",children:[]},e)}function rp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ap));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ap(e,t){return"|"===t?t:e}function sp(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,s=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=Xm.inlineCode(e,t,n);n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&"));return r},table:function(e,t,n,r){return o(function(e,t,n){const r=e.children;let a=-1;const s=[],i=t.enter("table");for(;++a<r.length;)s[a]=l(r[a],t,n);return i(),s}(e,n,r),e.align)},tableCell:i,tableRow:function(e,t,n,r){const a=l(e,n,r),s=o([a]);return s.slice(0,s.indexOf("\n"))}}};function i(e,t,n,r){const a=n.enter("tableCell"),i=n.enter("phrasing"),o=n.containerPhrasing(e,{...r,before:s,after:s});return i(),a(),o}function o(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||Im,s=[],i=[],o=[],l=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let s=-1;for(e[u].length>c&&(c=e[u].length);++s<e[u].length;){const i=Em(e[u][s]);if(!1!==n.alignDelimiters){const e=a(i);r[s]=e,(void 0===l[s]||e>l[s])&&(l[s]=e)}t.push(i)}i[u]=t,o[u]=r}let d=-1;if("object"==typeof r&&"length"in r)for(;++d<c;)s[d]=Pm(r[d]);else{const e=Pm(r);for(;++d<c;)s[d]=e}d=-1;const f=[],m=[];for(;++d<c;){const e=s[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 i=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[d]&&(l[d]=a),m[d]=a),f[d]=i}i.splice(1,0,f),o.splice(1,0,m),u=-1;const p=[];for(;++u<i.length;){const e=i[u],t=o[u];d=-1;const r=[];for(;++d<c;){const a=e[d]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[d]-(t[d]||0),n=s[d];114===n?i=" ".repeat(e):99===n?e%2?(i=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):(i=" ".repeat(e/2),o=i):o=" ".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(i),r.push(a),!1!==n.alignDelimiters&&r.push(o),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&d===c-1||r.push("|")}p.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return p.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:a})}function l(e,t,n){const r=e.children;let a=-1;const s=[],o=t.enter("tableRow");for(;++a<r.length;)s[a]=i(r[a],0,t,n);return o(),s}}function ip(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function op(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,s=-1;for(;++s<r.length;){const e=r[s];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 lp(e,t,n,r){const a=e.children[0],s="boolean"==typeof e.checked&&a&&"paragraph"===a.type,i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(i);let l=Xm.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const cp={tokenize:function(e,t,n){let r=0;return function t(s){if((87===s||119===s)&&r<3)return r++,e.consume(s),t;if(46===s&&3===r)return e.consume(s),a;return n(s)};function a(e){return null===e?n(e):t(e)}},partial:!0},up={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(fp,l,o)(t):null===t||lu(t)||du(t)||45!==t&&uu(t)?l(t):(s=!0,e.consume(t),i)}function o(t){return 95===t?r=!0:(a=r,r=void 0),e.consume(t),i}function l(e){return a||r||!s?n(e):t(e)}},partial:!0},dp={tokenize:function(e,t){let n=0,r=0;return a;function a(i){return 40===i?(n++,e.consume(i),a):41===i&&r<n?s(i):33===i||34===i||38===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||60===i||63===i||93===i||95===i||126===i?e.check(fp,t,s)(i):null===i||lu(i)||du(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},fp={tokenize:function(e,t,n){return r;function r(i){return 33===i||34===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||63===i||95===i||126===i?(e.consume(i),r):38===i?(e.consume(i),s):93===i?(e.consume(i),a):60===i||null===i||lu(i)||du(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||lu(e)||du(e)?t(e):r(e)}function s(e){return eu(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):eu(t)?(e.consume(t),i):n(t)}},partial:!0},mp={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return tu(e)?n(e):t(e)}},partial:!0},pp={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!bp.call(r,r.previous)||Np(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(cp,e.attempt(up,e.attempt(dp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:bp},hp={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&vp.call(r,r.previous)&&!Np(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(eu(t)&&a.length<5)return a+=String.fromCodePoint(t),e.consume(t),i;if(58===t){const n=a.toLowerCase();if("http"===n||"https"===n)return e.consume(t),o}return n(t)}function o(t){return 47===t?(e.consume(t),s?l:(s=!0,o)):n(t)}function l(t){return null===t||ru(t)||lu(t)||du(t)||uu(t)?n(t):e.attempt(up,e.attempt(dp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:vp},gp={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!kp(t)||!wp.call(r,r.previous)||Np(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return kp(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(mp,c,l)(t):45===t||95===t||tu(t)?(s=!0,e.consume(t),o):c(t)}function l(t){return e.consume(t),a=!0,o}function c(i){return s&&a&&eu(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:wp},xp={};let yp=48;for(;yp<123;)xp[yp]=gp,yp++,58===yp?yp=65:91===yp&&(yp=97);function bp(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||lu(e)}function vp(e){return!eu(e)}function wp(e){return!(47===e||kp(e))}function kp(e){return 43===e||45===e||46===e||95===e||tu(e)}function Np(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}xp[43]=gp,xp[45]=gp,xp[46]=gp,xp[95]=gp,xp[72]=[gp,hp],xp[104]=[gp,hp],xp[87]=[gp,pp],xp[119]=[gp,pp];const jp={tokenize:function(e,t,n){const r=this;return pu(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 Sp(e,t,n){const r=this;let a=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const e=r.events[a][1];if("labelImage"===e.type){i=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!i||!i._balanced)return n(a);const o=Zc(r.sliceSerialize({start:i.end,end:r.now()}));if(94!==o.codePointAt(0)||!s.includes(o.slice(1)))return n(a);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)}}function Cp(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 s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function Tp(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(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(o){if(i>999||93===o&&!s||null===o||91===o||lu(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(Zc(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return lu(o)||(s=!0),i++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),i++,l):l(t)}}function Ip(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i,o=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(o>999||93===t&&!i||null===t||91===t||lu(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=Zc(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return lu(t)||(i=!0),o++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(s)||a.push(s),pu(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function Ep(e,t,n){return e.check(Nu,t,e.attempt(jp,t,n))}function Pp(e){e.exit("gfmFootnoteDefinition")}function Ap(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const a=this.previous,s=this.events;let i=0;return function(t){if(126===a&&"characterEscape"!==s[s.length-1][1].type)return r(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(s){const l=yu(a);if(126===s)return i>1?r(s):(e.consume(s),i++,o);if(i<2&&!t)return r(s);const c=e.exit("strikethroughSequenceTemporary"),u=yu(s);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),n(s)}},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)},s={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},i=[["enter",a,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",s,t]],o=t.parser.constructs.insideSpan.null;o&&Wc(i,i.length,0,bu(o,e.slice(r+1,n),t)),Wc(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),Wc(e,r-1,n-r+3,i),n=r+i.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 Rp{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 _p(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 Dp(e,t,n){const r=this;let a,s=0,i=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,s="tableHead"===a||"tableRow"===a?v:o;if(s===v&&r.parser.lazy[r.now().line])return n(e);return s(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return a=!0,i+=1,l(e)}(t)}function l(t){return null===t?n(t):ou(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):cu(t)?pu(e,l,"whitespace")(t):(i+=1,a&&(a=!1,s+=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||lu(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,cu(t)?pu(e,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):f(t))}function f(t){return 45===t||58===t?p(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):b(t)}function m(t){return cu(t)?pu(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),h):45===t?(i+=1,h(t)):null===t||ou(t)?y(t):b(t)}function h(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):b(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 cu(t)?pu(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?f(n):(null===n||ou(n))&&a&&s===i?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):b(n)}function b(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||ou(n)?(e.exit("tableRow"),t(n)):cu(n)?pu(e,w,"whitespace")(n):(e.enter("data"),k(n))}function k(t){return null===t||124===t||lu(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 Op(e,t){let n,r,a,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const f=new Rp;for(;++s<e.length;){const m=e[s],p=m[1];"enter"===m[0]?"tableHead"===p.type?(u=!1,0!==d&&(Lp(f,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.add(s,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(i=!0,a=void 0,l=[0,0,0,0],c=[0,s+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.add(s,0,[["enter",r,t]])),o="tableDelimiterRow"===p.type?2:r?3:1):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type?"tableCellDivider"===p.type&&(i?i=!1:(0!==l[1]&&(c[0]=c[1],a=zp(f,t,l,o,void 0,a)),l=c,c=[l[1],s,0,0])):(i=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],a=zp(f,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(u=!0,d=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=s,0!==l[1]?(c[0]=c[1],a=zp(f,t,l,o,s,a)):0!==c[1]&&(a=zp(f,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==d&&Lp(f,t,d,n,r),f.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=_p(t.events,s))}return e}function zp(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},Fp(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Fp(t.events,n[1]);if(s={type:i,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){const a=Fp(t.events,n[2]),s=Fp(t.events,n[3]),i={type:"tableContent",start:Object.assign({},a),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",i,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",i,t]])}return void 0!==a&&(s.end=Object.assign({},Fp(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function Lp(e,t,n,r,a){const s=[],i=Fp(t.events,n);a&&(a.end=Object.assign({},i),s.push(["exit",a,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function Fp(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const Mp={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 lu(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(t)}function i(r){return ou(r)?t(r):cu(r)?e.check({tokenize:Bp},t,n)(r):n(r)}}};function Bp(e,t,n){return pu(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Up={};function $p(e){const t=e||Up,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Yc([{text:xp},{document:{91:{name:"gfmFootnoteDefinition",tokenize:Ip,continuation:{tokenize:Ep},exit:Pp}},text:{91:{name:"gfmFootnoteCall",tokenize:Tp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Sp,resolveTo:Cp}}},Ap(e),{flow:{null:{name:"table",tokenize:Dp,resolveAll:Op}}},{text:{91:Mp}}])}(t)),a.push([{transforms:[lm],enter:{literalAutolink:nm,literalAutolinkEmail:rm,literalAutolinkHttp:rm,literalAutolinkWww:rm},exit:{literalAutolink:om,literalAutolinkEmail:im,literalAutolinkHttp:am,literalAutolinkWww:sm}},{enter:{gfmFootnoteCallString:fm,gfmFootnoteCall:mm,gfmFootnoteDefinitionLabelString:pm,gfmFootnoteDefinition:hm},exit:{gfmFootnoteCallString:gm,gfmFootnoteCall:xm,gfmFootnoteDefinitionLabelString:ym,gfmFootnoteDefinition:bm}},{canContainEols:["delete"],enter:{strikethrough:Sm},exit:{strikethrough:Cm}},{enter:{table:Gm,tableData:np,tableHeader:np,tableRow:ep},exit:{codeText:rp,table:Zm,tableData:tp,tableHeader:tp,tableRow:tp}},{exit:{taskListCheckValueChecked:ip,taskListCheckValueUnchecked:ip,paragraph:op}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:em,notInConstruct:tm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:em,notInConstruct:tm},{character:":",before:"[ps]",after:"\\/",inConstruct:em,notInConstruct:tm}]},wm(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:jm}],handlers:{delete:Tm}},sp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:lp}}]}}(t))}function Vp({content:e,className:t}){return Rt.jsx("div",{className:_t("prose prose-sm max-w-none",t),children:Rt.jsx(Kf,{remarkPlugins:[$p],components:{h1:({children:e})=>Rt.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Rt.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Rt.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Rt.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Rt.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Rt.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Rt.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Rt.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Rt.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})=>Rt.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Rt.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Rt.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Rt.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Rt.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function Hp(){const[e,t]=a(!1),[n,r]=a(""),{messages:s,isLoading:o,error:l,sendMessage:u}=pl(),d=c(null),f=c(null);i(()=>{if(d.current){const e=d.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[s]),i(()=>{e&&f.current&&f.current.focus()},[e]),i(()=>{const n=n=>{"Escape"===n.key&&e&&t(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]);const m=()=>{n.trim()&&!o&&(u(n),r(""))};return Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Mt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Rt.jsx(k,{className:"h-6 w-6"}):Rt.jsx(Ue,{className:"h-6 w-6"})}),e&&Rt.jsxs(Vt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Rt.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Rt.jsx(qt,{className:"text-lg font-semibold",children:"Chat Assistant"}),Rt.jsx(Mt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Rt.jsx(k,{className:"h-4 w-4"})})]}),Rt.jsxs(Qt,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Rt.jsx(Ha,{ref:d,className:"flex-1 px-4",children:Rt.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Rt.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Rt.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?Rt.jsx(Vp,{content:e.content}):Rt.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Rt.jsx("div",{className:"flex justify-start",children:Rt.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Rt.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Rt.jsx("div",{className:"border-t p-4",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx(Bt,{ref:f,value:n,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"}),Rt.jsx(Mt,{onClick:m,disabled:o||!n.trim(),size:"icon",children:Rt.jsx($e,{className:"h-4 w-4"})})]})})]})]})]})}export{yr as AUTH_CONFIG,ks as Accordion,Ss as AccordionContent,Ns as AccordionItem,js as AccordionTrigger,Wo as ActionButton,Da as ActionMenuItems,gs as Alert,ys as AlertDescription,qr as AlertDialog,ea as AlertDialogAction,ta as AlertDialogCancel,Yr as AlertDialogContent,Zr as AlertDialogDescription,Xr as AlertDialogFooter,Jr as AlertDialogHeader,Kr as AlertDialogOverlay,Qr as AlertDialogPortal,Gr as AlertDialogTitle,Wr as AlertDialogTrigger,xs as AlertTitle,nl as AppHeader,fl as AppLayout,dl as AppSidebar,Cs as AspectRatio,Mr as AuthErrorInterceptor,Ur as AuthProvider,Fr as AuthService,Ts as Avatar,Es as AvatarFallback,Is as AvatarImage,Sn as Badge,Xa as BaseForm,Ps as Breadcrumb,zs as BreadcrumbEllipsis,Rs as BreadcrumbItem,_s as BreadcrumbLink,As as BreadcrumbList,Ds as BreadcrumbPage,Os as BreadcrumbSeparator,es as BulkActionBar,Mt as Button,br as CRUD_CONFIG,Qs as Calendar,bs as CallbackPage,Vt as Card,Qt as CardContent,Wt as CardDescription,Kt as CardFooter,Ht as CardHeader,ma as CardSkeleton,qt as CardTitle,Hp as ChatbotPage,kn as Checkbox,Ks as Collapsible,Js as CollapsibleContent,Ys as CollapsibleTrigger,Va as ColorPicker,Xs as Command,Gs as CommandDialog,ti as CommandEmpty,ni as CommandGroup,Zs as CommandInput,ai as CommandItem,ei as CommandList,ri as CommandSeparator,si as CommandShortcut,Qo as CrudCards,Ga as CrudForm,is as CrudPageInternal,La as CrudTable,ii as DataList,na as DeleteConfirmationDialog,Yt as Dialog,Gt as DialogClose,en as DialogContent,an as DialogDescription,nn as DialogFooter,tn as DialogHeader,Zt as DialogOverlay,Xt as DialogPortal,rn as DialogTitle,Jt as DialogTrigger,ba as DropdownMenu,Ea as DropdownMenuCheckboxItem,Ta as DropdownMenuContent,wa as DropdownMenuGroup,Ia as DropdownMenuItem,Aa as DropdownMenuLabel,ka as DropdownMenuPortal,ja as DropdownMenuRadioGroup,Pa as DropdownMenuRadioItem,Ra as DropdownMenuSeparator,_a as DropdownMenuShortcut,Na as DropdownMenuSub,Ca as DropdownMenuSubContent,Sa as DropdownMenuSubTrigger,va as DropdownMenuTrigger,ya as EmptyState,Ka as EntitySelect,ml as ErrorBoundary,ss as FilterBar,sn as Form,mn as FormControl,ln as FormField,dn as FormItem,fn as FormLabel,pn as FormMessage,pa as FormSkeleton,ci as Grid,ha as HeaderSkeleton,Qa as IconPicker,Bt as Input,$t as Label,In as LoadingState,vs as LoginPage,Cr as MESSAGES,Vp as MarkdownMessage,Go as NavigationProvider,ui as PageBreadcrumb,fi as Pagination,mi as PaginationContent,yi as PaginationEllipsis,pi as PaginationItem,hi as PaginationLink,xi as PaginationNext,gi as PaginationPrevious,Ma as Popover,Ua as PopoverContent,Ba as PopoverTrigger,bi as Progress,ps as ProtectedRoute,kr as QUERY_KEYS,xr as QualiexEnrichmentService,Ja as QualiexUserField,vi as RadioGroup,wi as RadioGroupItem,vr as SEARCH_CONFIG,Ha as ScrollArea,qa as ScrollBar,hn as Select,vn as SelectContent,wn as SelectItem,xn as SelectTrigger,gn as SelectValue,ki as Separator,Ni as Sheet,Si as SheetClose,Ei as SheetContent,_i as SheetDescription,Ai as SheetFooter,Pi as SheetHeader,Ti as SheetOverlay,Ci as SheetPortal,Ri as SheetTitle,ji as SheetTrigger,$i as Sidebar,Ji as SidebarContent,Ki as SidebarFooter,Xi as SidebarGroup,Zi as SidebarGroupAction,eo as SidebarGroupContent,Gi as SidebarGroupLabel,Qi as SidebarHeader,Wi as SidebarInput,qi as SidebarInset,to as SidebarMenu,so as SidebarMenuAction,io as SidebarMenuBadge,ao as SidebarMenuButton,no as SidebarMenuItem,oo as SidebarMenuSkeleton,lo as SidebarMenuSub,uo as SidebarMenuSubButton,co as SidebarMenuSubItem,Ui as SidebarProvider,Hi as SidebarRail,Yi as SidebarSeparator,ga as SidebarSkeleton,Vi as SidebarTrigger,da as Skeleton,fo as Slider,mo as SonnerToaster,Tn as Spinner,as as Stack,_o as Switch,Bo as TabPageContent,Mo as TabPageHeader,Fo as TabPageLayout,ra as Table,sa as TableBody,ua as TableCaption,ca as TableCell,ia as TableFooter,la as TableHead,aa as TableHeader,oa as TableRow,Oa as TableRowActions,fa as TableSkeleton,Do as Tabs,Lo as TabsContent,Oo as TabsList,zo as TabsTrigger,Nn as Textarea,Un as Toast,$n as ToastAction,Vn as ToastClose,qn as ToastDescription,Fn as ToastProvider,Hn as ToastTitle,Mn as ToastViewport,Wn as Toaster,$o as Toggle,Ho as ToggleGroup,qo as ToggleGroupItem,nr as TokenManager,Kn as TokenService,Oi as Tooltip,Li as TooltipContent,Di as TooltipProvider,zi as TooltipTrigger,il as assets,jn as badgeVariants,Ft as buttonVariants,_t as cn,os as createCrudPage,Ko as createRoutingHandlers,Er as createService,ls as createSimpleSaveHandler,Hr as createSimpleService,fs as crudPresets,Lt as debounce,sr as errorService,zt as formatCurrency,Ot as formatDatetime,cs as generateCrudConfig,jr as getQualiexConfig,fr as getSupabaseClient,wr as isDevEnvironment,ol as logoSrc,gr as qualiexApi,Sr as setQualiexConfig,ws as setupQualiexCore,ll as smallLogoSrc,zn as toast,Uo as toggleVariants,Dt as trimTextFields,rl as useActiveModules,$r as useAuth,Fa as useBaseForm,Vr as useCrud,Yo as useCrudRouting,tl as useDebounce,Zo as useNavigation,pl as useOpenAIChat,el as usePageTitle,al as usePermissionQuery,Ya as useQualiexUsers,di as useRouteBreadcrumbs,Bi as useSidebar,Ln as useToast,ms as withPreset};
|