forlogic-core 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"react";import a,{useState as t,useEffect as s,createContext as r,useContext as n,useCallback as o,useMemo as i,useRef as l,Component as d}from"react";import*as c from"@radix-ui/react-alert-dialog";import{clsx as m}from"clsx";import{twMerge as u}from"tailwind-merge";import{parseISO as f,isValid as p,format as h}from"date-fns";import{Slot as x}from"@radix-ui/react-slot";import{cva as g}from"class-variance-authority";import{ChevronRight as b,MoreHorizontal as v,X as y,Check as N,Circle as j,AlertCircle as w,Search as k,FileX as S,MessageCircle as C,Target as T,Trophy as E,Award as R,Sparkles as P,Flame as _,Zap as A,Key as I,Shield as O,EyeOff as D,Eye as z,Unlock as F,Lock as $,Archive as L,FolderOpen as M,Folder as U,FileText as V,Save as W,Copy as B,Share as q,Upload as H,Download as Q,HelpCircle as K,Info as X,Bell as G,Clock as Y,ArrowRight as J,ArrowLeft as Z,ArrowDown as ee,ArrowUp as ae,ChevronLeft as te,ChevronUp as se,ChevronDown as re,Minus as ne,Plus as oe,Trash2 as ie,Edit as le,Filter as de,Bookmark as ce,Book as me,Video as ue,Music as fe,Image as pe,Camera as he,MapPin as xe,Calendar as ge,Phone as be,Mail as ve,Settings as ye,User as Ne,Home as je,Heart as we,Star as ke,Dot as Se,Loader2 as Ce,PanelLeft as Te,RefreshCw as Ee,Building2 as Re,LogOut as Pe,ExternalLink as _e,AlertTriangle as Ae,PowerOff as Ie,Power as Oe,EllipsisVertical as De,ArrowUpDown as ze,ChevronsLeft as Fe,ChevronsRight as $e}from"lucide-react";import*as Le from"@radix-ui/react-label";import*as Me from"@radix-ui/react-popover";import*as Ue from"@radix-ui/react-dialog";import*as Ve from"@radix-ui/react-dropdown-menu";import{useQueryClient as We,useQuery as Be,useMutation as qe,QueryClient as He}from"@tanstack/react-query";import{createClient as Qe}from"@supabase/supabase-js";import{useFormContext as Ke,FormProvider as Xe,Controller as Ge}from"react-hook-form";import*as Ye from"@radix-ui/react-scroll-area";import{OTPInput as Je,OTPInputContext as Ze}from"input-otp";import{useLocation as ea,useSearchParams as aa,Link as ta}from"react-router-dom";import*as sa from"@radix-ui/react-select";import*as ra from"@radix-ui/react-separator";import*as na from"@radix-ui/react-tooltip";import"next-themes";import{toast as oa}from"sonner";import*as ia from"@radix-ui/react-toast";var la,da={exports:{}},ca={};var ma,ua,fa={};
1
+ import*as e from"react";import a,{useState as t,useEffect as s,createContext as r,useContext as n,useCallback as i,useMemo as o,useRef as l,Component as d}from"react";import*as c from"@radix-ui/react-alert-dialog";import{clsx as m}from"clsx";import{twMerge as u}from"tailwind-merge";import{parseISO as f,isValid as p,format as h}from"date-fns";import{Slot as x}from"@radix-ui/react-slot";import{cva as g}from"class-variance-authority";import{ChevronRight as b,MoreHorizontal as v,X as y,Check as N,Circle as j,AlertCircle as w,Search as k,FileX as S,MessageCircle as C,Target as T,Trophy as E,Award as R,Sparkles as P,Flame as _,Zap as A,Key as I,Shield as O,EyeOff as D,Eye as z,Unlock as F,Lock as $,Archive as L,FolderOpen as M,Folder as U,FileText as V,Save as W,Copy as B,Share as q,Upload as H,Download as Q,HelpCircle as K,Info as X,Bell as G,Clock as Y,ArrowRight as J,ArrowLeft as Z,ArrowDown as ee,ArrowUp as ae,ChevronLeft as te,ChevronUp as se,ChevronDown as re,Minus as ne,Plus as ie,Trash2 as oe,Edit as le,Filter as de,Bookmark as ce,Book as me,Video as ue,Music as fe,Image as pe,Camera as he,MapPin as xe,Calendar as ge,Phone as be,Mail as ve,Settings as ye,User as Ne,Home as je,Heart as we,Star as ke,Dot as Se,Loader2 as Ce,PanelLeft as Te,RefreshCw as Ee,Building2 as Re,LogOut as Pe,ExternalLink as _e,AlertTriangle as Ae,PowerOff as Ie,Power as Oe,EllipsisVertical as De,ArrowUpDown as ze,ChevronsLeft as Fe,ChevronsRight as $e}from"lucide-react";import*as Le from"@radix-ui/react-label";import*as Me from"@radix-ui/react-popover";import*as Ue from"@radix-ui/react-dialog";import*as Ve from"@radix-ui/react-dropdown-menu";import{useQueryClient as We,useQuery as Be,useMutation as qe,QueryClient as He}from"@tanstack/react-query";import{createClient as Qe}from"@supabase/supabase-js";import{useFormContext as Ke,FormProvider as Xe,Controller as Ge}from"react-hook-form";import*as Ye from"@radix-ui/react-scroll-area";import{OTPInput as Je,OTPInputContext as Ze}from"input-otp";import{useLocation as ea,useSearchParams as aa,Link as ta}from"react-router-dom";import*as sa from"@radix-ui/react-select";import*as ra from"@radix-ui/react-separator";import*as na from"@radix-ui/react-tooltip";import"next-themes";import{toast as ia}from"sonner";import*as oa from"@radix-ui/react-toast";var la,da={exports:{}},ca={};var ma,ua,fa={};
2
2
  /**
3
3
  * @license React
4
4
  * react-jsx-runtime.development.js
@@ -7,5 +7,5 @@ import*as e from"react";import a,{useState as t,useEffect as s,createContext 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 pa(){return ma||(ma=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"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),c=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 v(e){return e.displayName||"Context"}function y(e){if(null==e)return null;if("number"==typeof e.tag&&g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case r:return"Fragment";case s:return"Portal";case o:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return v(e)+".Consumer";case i:return v(e._context)+".Provider";case d: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:y(e.type)||"Memo";case f:var t=e,p=t._payload,h=t._init;try{return y(h(p))}catch(e){return null}}return null}b=Symbol.for("react.module.reference");var N,j,w,k,S,C,T,E=Object.assign,R=0;function P(){}P.__reactDisabledLog=!0;var _,A=x.ReactCurrentDispatcher;function I(e,a,t){if(void 0===_)try{throw Error()}catch(e){var s=e.stack.trim().match(/\n( *(at )?)/);_=s&&s[1]||""}return"\n"+_+e}var O,D=!1,z="function"==typeof WeakMap?WeakMap:Map;function F(e,a){if(!e||D)return"";var t,s=O.get(e);if(void 0!==s)return s;D=!0;var r,n=Error.prepareStackTrace;Error.prepareStackTrace=void 0,r=A.current,A.current=null,function(){if(0===R){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})}R++}();try{if(a){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(o,[])}catch(e){t=e}Reflect.construct(e,[],o)}else{try{o.call()}catch(e){t=e}e.call(o.prototype)}}else{try{throw Error()}catch(e){t=e}e()}}catch(a){if(a&&t&&"string"==typeof a.stack){for(var i=a.stack.split("\n"),l=t.stack.split("\n"),d=i.length-1,c=l.length-1;d>=1&&c>=0&&i[d]!==l[c];)c--;for(;d>=1&&c>=0;d--,c--)if(i[d]!==l[c]){if(1!==d||1!==c)do{if(d--,--c<0||i[d]!==l[c]){var m="\n"+i[d].replace(" at new "," at ");return e.displayName&&m.includes("<anonymous>")&&(m=m.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,m),m}}while(d>=1&&c>=0);break}}}finally{D=!1,A.current=r,function(){if(0===--R){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},e,{value:N}),info:E({},e,{value:j}),warn:E({},e,{value:w}),error:E({},e,{value:k}),group:E({},e,{value:S}),groupCollapsed:E({},e,{value:C}),groupEnd:E({},e,{value:T})})}R<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?I(u):"";return"function"==typeof e&&O.set(e,f),f}function $(e,a,t){if(null==e)return"";if("function"==typeof e)return F(e,function(e){var a=e.prototype;return!(!a||!a.isReactComponent)}(e));if("string"==typeof e)return I(e);switch(e){case c:return I("Suspense");case m:return I("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return F(e.render,!1);case u:return $(e.type,a,t);case f:var s=e,r=s._payload,n=s._init;try{return $(n(r),a,t)}catch(e){}}return""}O=new z;var L=Object.prototype.hasOwnProperty,M={},U=x.ReactDebugCurrentFrame;function V(e){if(e){var a=e._owner,t=$(e.type,e._source,a?a.type:null);U.setExtraStackFrame(t)}else U.setExtraStackFrame(null)}var W=Array.isArray;function B(e){return W(e)}function q(e){return""+e}function H(e){if(function(e){try{return q(e),!1}catch(e){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,X=x.ReactCurrentOwner,G={key:!0,ref:!0,__self:!0,__source:!0};function Y(e,a,s,r,n){var o,i={},l=null,d=null;for(o 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)&&(d=a.ref,function(e){"string"==typeof e.ref&&X.current}(a)),a)L.call(a,o)&&!G.hasOwnProperty(o)&&(i[o]=a[o]);if(e&&e.defaultProps){var c=e.defaultProps;for(o in c)void 0===i[o]&&(i[o]=c[o])}if(l||d){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})}(i,m),d&&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})}(i,m)}return function(e,a,s,r,n,o,i){var l={$$typeof:t,type:e,key:a,ref:s,props:i,_owner:o,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,d,n,r,X.current,i)}var J,Z=x.ReactCurrentOwner,ee=x.ReactDebugCurrentFrame;function ae(e){if(e){var a=e._owner,t=$(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=y(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}J=!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 "+y(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 oe(e,a){if("object"==typeof e)if(B(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,o=r.call(e);!(n=o.next()).done;)te(n.value)&&ne(n.value,a)}}function ie(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!==d&&t.$$typeof!==u)return;a=t.propTypes}if(a){var s=y(t);!function(e,a,t,s,r){var n=Function.call.bind(L);for(var o in e)if(n(e,o)){var i=void 0;try{if("function"!=typeof e[o]){var l=Error((s||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}i=e[o](a,o,s,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){i=e}!i||i 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,o,typeof i),V(null)),i instanceof Error&&!(i.message in M)&&(M[i.message]=!0,V(r),g("Failed %s type: %s",t,i.message),V(null))}}(a,e.props,"prop",s,e)}else if(void 0!==t.PropTypes&&!J){J=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y(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 de(e,a,s,h,x,v){var N=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===o||e===n||e===c||e===m||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===u||e.$$typeof===i||e.$$typeof===l||e.$$typeof===d||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":B(e)?w="array":void 0!==e&&e.$$typeof===t?(w="<"+(y(e.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,j)}var k=Y(e,a,s,x,v);if(null==k)return k;if(N){var S=a.children;if(void 0!==S)if(h)if(B(S)){for(var C=0;C<S.length;C++)oe(S[C],e);Object.freeze&&Object.freeze(S)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else oe(S,e)}if(L.call(a,"key")){var T=y(e),E=Object.keys(a).filter(function(e){return"key"!==e}),R=E.length>0?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+R])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} />',R,T,E.length>0?"{"+E.join(": ..., ")+": ...}":"{}",T),le[T+R]=!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):ie(k),k}var ce=function(e,a,t){return de(e,a,t,!1)},me=function(e,a,t){return de(e,a,t,!0)};fa.Fragment=r,fa.jsx=ce,fa.jsxs=me}()),fa}var ha=(ua||(ua=1,"production"===process.env.NODE_ENV?da.exports=function(){if(la)return ca;la=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,o={key:!0,ref:!0,__self:!0,__source:!0};function i(e,a,s){var i,l={},d=null,c=null;for(i in void 0!==s&&(d=""+s),void 0!==a.key&&(d=""+a.key),void 0!==a.ref&&(c=a.ref),a)r.call(a,i)&&!o.hasOwnProperty(i)&&(l[i]=a[i]);if(e&&e.defaultProps)for(i in a=e.defaultProps)void 0===l[i]&&(l[i]=a[i]);return{$$typeof:t,type:e,key:d,ref:c,props:l,_owner:n.current}}return ca.Fragment=s,ca.jsx=i,ca.jsxs=i,ca}():da.exports=pa()),da.exports);function xa(...e){return u(m(e))}const ga=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(ga);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=ga(s);return a}return e},ba=e=>{if(!e)return"";const a=f(e);if(!p(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"})}`},va=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},ya=g("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","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"}}),Na=e.forwardRef(({className:e,variant:a,size:t,asChild:s=!1,...r},n)=>{const o=s?x:"button";return ha.jsx(o,{className:xa(ya({variant:a,size:t,className:e})),ref:n,...r})});Na.displayName="Button";const ja=c.Root,wa=c.Trigger,ka=c.Portal,Sa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Overlay,{className:xa("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}));Sa.displayName=c.Overlay.displayName;const Ca=e.forwardRef(({className:e,...a},t)=>ha.jsxs(ka,{children:[ha.jsx(Sa,{}),ha.jsx(c.Content,{ref:t,className:xa("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})]}));Ca.displayName=c.Content.displayName;const Ta=({className:e,...a})=>ha.jsx("div",{className:xa("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});Ta.displayName="AlertDialogHeader";const Ea=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Ea.displayName="AlertDialogFooter";const Ra=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Title,{ref:t,className:xa("text-lg font-semibold",e),...a}));Ra.displayName=c.Title.displayName;const Pa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Pa.displayName=c.Description.displayName;const _a=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Action,{ref:t,className:xa(ya(),e),...a}));_a.displayName=c.Action.displayName;const Aa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Cancel,{ref:t,className:xa(ya({variant:"outline"}),"mt-2 sm:mt-0",e),...a}));Aa.displayName=c.Cancel.displayName;const Ia=g("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"}}),Oa=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx("div",{ref:s,role:"alert",className:xa(Ia({variant:a}),e),...t}));Oa.displayName="Alert";const Da=e.forwardRef(({className:e,...a},t)=>ha.jsx("h5",{ref:t,className:xa("mb-1 font-medium leading-none tracking-tight",e),...a}));Da.displayName="AlertTitle";const za=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("text-sm [&_p]:leading-relaxed",e),...a}));za.displayName="AlertDescription";const Fa=g("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"}}),$a=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx("div",{ref:s,className:xa(Fa({variant:a}),e),...t}));$a.displayName="Badge";const La=e.forwardRef(({...e},a)=>ha.jsx("nav",{ref:a,"aria-label":"breadcrumb",...e}));La.displayName="Breadcrumb";const Ma=e.forwardRef(({className:e,...a},t)=>ha.jsx("ol",{ref:t,className:xa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...a}));Ma.displayName="BreadcrumbList";const Ua=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,className:xa("inline-flex items-center gap-1.5",e),...a}));Ua.displayName="BreadcrumbItem";const Va=e.forwardRef(({asChild:a,className:t,...s},r)=>{const n=a?e.Fragment:"a";return ha.jsx(n,{ref:r,className:xa("transition-colors hover:text-foreground",t),...s})});Va.displayName="BreadcrumbLink";const Wa=e.forwardRef(({className:e,...a},t)=>ha.jsx("span",{ref:t,role:"link","aria-disabled":"true","aria-current":"page",className:xa("font-normal text-foreground",e),...a}));Wa.displayName="BreadcrumbPage";const Ba=({children:e,className:a,...t})=>ha.jsx("li",{role:"presentation","aria-hidden":"true",className:xa("[&>svg]:size-3.5",a),...t,children:e??ha.jsx(b,{})});Ba.displayName="BreadcrumbSeparator";const qa=({className:e,...a})=>ha.jsxs("span",{role:"presentation","aria-hidden":"true",className:xa("flex h-9 w-9 items-center justify-center",e),...a,children:[ha.jsx(v,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"More"})]});qa.displayName="BreadcrumbEllipsis";const Ha=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));Ha.displayName="Card";const Qa=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex flex-col space-y-1.5 p-6",e),...a}));Qa.displayName="CardHeader";const Ka=e.forwardRef(({className:e,...a},t)=>ha.jsx("h3",{ref:t,className:xa("text-2xl font-semibold leading-none tracking-tight",e),...a}));Ka.displayName="CardTitle";const Xa=e.forwardRef(({className:e,...a},t)=>ha.jsx("p",{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Xa.displayName="CardDescription";const Ga=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("p-6 pt-0",e),...a}));Ga.displayName="CardContent";const Ya=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex items-center p-6 pt-0",e),...a}));Ya.displayName="CardFooter";const Ja=e.forwardRef(({className:e,type:a,...t},s)=>ha.jsx("input",{type:a,className:xa("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}));Ja.displayName="Input";const Za=g("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),et=e.forwardRef(({className:e,...a},t)=>ha.jsx(Le.Root,{ref:t,className:xa(Za(),e),...a}));et.displayName=Le.Root.displayName;const at=Me.Root,tt=Me.Trigger,st=e.forwardRef(({className:e,align:a="center",sideOffset:t=4,...s},r)=>ha.jsx(Me.Portal,{children:ha.jsx(Me.Content,{ref:r,align:a,sideOffset:t,className:xa("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})}));st.displayName=Me.Content.displayName;const rt=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],nt=({value:e="#3b82f6",onChange:a,label:t})=>ha.jsxs("div",{className:"space-y-2",children:[t&&ha.jsx(et,{children:t}),ha.jsxs(at,{children:[ha.jsx(tt,{asChild:!0,children:ha.jsxs(Na,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[ha.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),ha.jsx(st,{className:"w-64",children:ha.jsxs("div",{className:"space-y-3",children:[ha.jsxs("div",{children:[ha.jsx(et,{htmlFor:"color-input",children:"Cor personalizada"}),ha.jsx(Ja,{id:"color-input",type:"color",value:e,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),ha.jsxs("div",{children:[ha.jsx(et,{children:"Cores predefinidas"}),ha.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:rt.map(e=>ha.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))})]})]})})]})]}),ot=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a}));ot.displayName="Command";const it=({children:e,...a})=>ha.jsx("div",{...a,children:ha.jsx(ot,{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})}),lt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:ha.jsx("input",{ref:t,className:xa("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})}));lt.displayName="CommandInput";const dt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));dt.displayName="CommandList";const ct=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("py-6 text-center text-sm text-muted-foreground",e),...a}));ct.displayName="CommandEmpty";const mt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("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}));mt.displayName="CommandGroup";const ut=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("-mx-1 h-px bg-border",e),...a}));ut.displayName="CommandSeparator";const ft=e.forwardRef(({className:e,disabled:a,onSelect:t,value:s,...r},n)=>ha.jsx("div",{ref:n,className:xa("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}));ft.displayName="CommandItem";const pt=({className:e,...a})=>ha.jsx("span",{className:xa("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});pt.displayName="CommandShortcut";const ht={Root:function({children:e,className:a}){return ha.jsx("div",{className:xa("space-y-4",a),children:e})},Item:function({children:e,onClick:a,className:t}){return ha.jsx(Ha,{className:xa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",t),onClick:a,children:ha.jsx(Ga,{className:"p-4",children:e})})},Field:function({label:e,value:a,className:t}){return ha.jsxs("div",{className:xa("flex justify-between items-center text-sm",t),children:[ha.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),ha.jsx("span",{className:"text-foreground",children:a})]})}},xt=({open:e,onOpenChange:a,item:r,onConfirm:n,entityName:o="item",isDeleting:i=!1})=>{const[l,d]=t("");s(()=>{e||d("")},[e]);const c=()=>{d(""),a(!1)},m=l===r?.title;return r?ha.jsx(ja,{open:e,onOpenChange:c,children:ha.jsxs(Ca,{className:"sm:max-w-[500px]",children:[ha.jsx(Ta,{children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:ha.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),ha.jsx("div",{className:"flex-1",children:ha.jsx(Ra,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),ha.jsx(Pa,{asChild:!0,children:ha.jsxs("div",{className:"space-y-4",children:[ha.jsxs("div",{className:"text-sm text-muted-foreground",children:[ha.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",o,":"]}),ha.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:ha.jsx("p",{className:"font-medium text-foreground",children:r.title})})]}),ha.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:ha.jsxs("div",{className:"flex items-start space-x-2",children:[ha.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:ha.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),ha.jsxs("div",{className:"text-sm text-orange-800",children:[ha.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),ha.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",o," será removido permanentemente do sistema."]})]})]})}),ha.jsxs("div",{className:"space-y-2",children:[ha.jsxs(et,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",ha.jsxs("strong",{children:['"',r.title,'"']})," abaixo:"]}),ha.jsx(Ja,{id:"confirmation",type:"text",value:l,onChange:e=>d(e.target.value),placeholder:`Digite: ${r.title}`,className:"w-full"})]})]})}),ha.jsxs(Ea,{children:[ha.jsx(Aa,{onClick:c,children:"Cancelar"}),ha.jsx(_a,{onClick:()=>{r&&l===r.title&&(n(r),d(""),a(!1))},disabled:!m||i,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:i?"Removendo...":`Excluir ${o}`})]})]})}):null},gt=Ue.Root,bt=Ue.Trigger,vt=Ue.Portal,yt=Ue.Close,Nt=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Overlay,{ref:t,className:xa("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}));Nt.displayName=Ue.Overlay.displayName;const jt=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(vt,{children:[ha.jsx(Nt,{}),ha.jsxs(Ue.Content,{ref:s,className:xa("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,ha.jsxs(Ue.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:[ha.jsx(y,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));jt.displayName=Ue.Content.displayName;const wt=({className:e,...a})=>ha.jsx("div",{className:xa("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});wt.displayName="DialogHeader";const kt=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});kt.displayName="DialogFooter";const St=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Title,{ref:t,className:xa("text-lg font-semibold leading-none tracking-tight",e),...a}));St.displayName=Ue.Title.displayName;const Ct=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Ct.displayName=Ue.Description.displayName;const Tt=Ve.Root,Et=Ve.Trigger,Rt=Ve.Group,Pt=Ve.Portal,_t=Ve.Sub,At=Ve.RadioGroup,It=e.forwardRef(({className:e,inset:a,children:t,...s},r)=>ha.jsxs(Ve.SubTrigger,{ref:r,className:xa("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,ha.jsx(b,{className:"ml-auto h-4 w-4"})]}));It.displayName=Ve.SubTrigger.displayName;const Ot=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ve.SubContent,{ref:t,className:xa("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}));Ot.displayName=Ve.SubContent.displayName;const Dt=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>ha.jsx(Ve.Portal,{children:ha.jsx(Ve.Content,{ref:s,sideOffset:a,className:xa("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})}));Dt.displayName=Ve.Content.displayName;const zt=e.forwardRef(({className:e,inset:a,...t},s)=>ha.jsx(Ve.Item,{ref:s,className:xa("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}));zt.displayName=Ve.Item.displayName;const Ft=e.forwardRef(({className:e,children:a,checked:t,...s},r)=>ha.jsxs(Ve.CheckboxItem,{ref:r,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(Ve.ItemIndicator,{children:ha.jsx(N,{className:"h-4 w-4"})})}),a]}));Ft.displayName=Ve.CheckboxItem.displayName;const $t=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(Ve.RadioItem,{ref:s,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(Ve.ItemIndicator,{children:ha.jsx(j,{className:"h-2 w-2 fill-current"})})}),a]}));$t.displayName=Ve.RadioItem.displayName;const Lt=e.forwardRef(({className:e,inset:a,...t},s)=>ha.jsx(Ve.Label,{ref:s,className:xa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...t}));Lt.displayName=Ve.Label.displayName;const Mt=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ve.Separator,{ref:t,className:xa("-mx-1 my-1 h-px bg-muted",e),...a}));Mt.displayName=Ve.Separator.displayName;const Ut=({className:e,...a})=>ha.jsx("span",{className:xa("ml-auto text-xs tracking-widest opacity-60",e),...a});Ut.displayName="DropdownMenuShortcut";const Vt={default:S,search:k,error:w};function Wt({icon:e,title:a,description:t,action:s,className:r,variant:n="default"}){const o=e?()=>e:Vt[n];return ha.jsxs("div",{className:xa("flex flex-col items-center justify-center py-12 px-4 text-center",r),children:[ha.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:ha.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),ha.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),t&&ha.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:t}),s&&ha.jsx(Na,{onClick:s.onClick,variant:"outline",children:s.label})]})}const Bt="qualiex_access_token",qt="qualiex_id_token",Ht="supabase_token",Qt="oauth_state",Kt="oauth_nonce",Xt="selected_alias",Gt={setAccessToken:e=>localStorage.setItem(Bt,e),getAccessToken:()=>localStorage.getItem(Bt),setIdToken:e=>localStorage.setItem(qt,e),getIdToken:()=>localStorage.getItem(qt),setSupabaseToken:e=>localStorage.setItem(Ht,e),getSupabaseToken:()=>localStorage.getItem(Ht),setOAuthState:e=>sessionStorage.setItem(Qt,e),getOAuthState:()=>sessionStorage.getItem(Qt),clearOAuthState:()=>sessionStorage.removeItem(Qt),setOAuthNonce:e=>sessionStorage.setItem(Kt,e),getOAuthNonce:()=>sessionStorage.getItem(Kt),clearOAuthNonce:()=>sessionStorage.removeItem(Kt),setSelectedAlias:e=>localStorage.setItem(Xt,e),getSelectedAlias:()=>localStorage.getItem(Xt),clearSelectedAlias:()=>localStorage.removeItem(Xt),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Gt.getAccessToken()||!Gt.getIdToken()),clearAll:()=>{localStorage.removeItem(Bt),localStorage.removeItem(qt),localStorage.removeItem(Ht),localStorage.removeItem(Xt),sessionStorage.removeItem(Qt),sessionStorage.removeItem(Kt)},isTokenExpired:e=>{try{return 1e3*JSON.parse(atob(e.split(".")[1])).exp<Date.now()}catch{return!0}},isSupabaseTokenValid:()=>{const e=Gt.getSupabaseToken();return!!e&&!Gt.isTokenExpired(e)},getValidSupabaseToken:()=>{const e=Gt.getSupabaseToken();return!e||Gt.isTokenExpired(e)?null:e},extractTokenData:()=>{const e=Gt.getSupabaseToken();if(!e)return null;try{const a=JSON.parse(atob(e.split(".")[1])),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{return null}}};let Yt=0;const Jt=new Map,Zt=e=>{if(Jt.has(e))return;const a=setTimeout(()=>{Jt.delete(e),ss({type:"REMOVE_TOAST",toastId:e})},1e6);Jt.set(e,a)},es=(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?Zt(t):e.toasts.forEach(e=>{Zt(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)}}},as=[];let ts={toasts:[]};function ss(e){ts=es(ts,e),as.forEach(e=>{e(ts)})}function rs({...e}){const a=(Yt=(Yt+1)%Number.MAX_SAFE_INTEGER,Yt.toString()),t=()=>ss({type:"DISMISS_TOAST",toastId:a});return ss({type:"ADD_TOAST",toast:{...e,id:a,open:!0,onOpenChange:e=>{e||t()}}}),{id:a,dismiss:t,update:e=>ss({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function ns(){const[a,t]=e.useState(ts);return e.useEffect(()=>(as.push(t),()=>{const e=as.indexOf(t);e>-1&&as.splice(e,1)}),[a]),{...a,toast:rs,dismiss:e=>ss({type:"DISMISS_TOAST",toastId:e})}}var os=Object.defineProperty,is=(e,a,t)=>((e,a,t)=>a in e?os(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const ls=new class{constructor(){is(this,"errors",[]),is(this,"toastCount",0),is(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()&&rs({title:"Erro",description:t,variant:"destructive"})}success(e,a){rs({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 ds=Object.defineProperty,cs=(e,a,t)=>((e,a,t)=>a in e?ds(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const ms=import.meta.env.VITE_SUPABASE_URL,us=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,fs=class e{constructor(){cs(this,"client"),cs(this,"currentToken",null),cs(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:us};return e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`),Qe(ms,us,{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:a}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Gt.getSupabaseToken();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(e){return ls.handleError(e instanceof Error?e:"❌ Supabase - Error validating token",!1),!1}}};cs(fs,"instance");let ps=fs;const hs=()=>ps.getInstance().getClient(),xs={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"}},gs={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},bs={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},ys={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},Ns={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}`}};class js{static async initialize(){try{if(!Gt.hasAllTokens())return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[]};const e=Gt.getAccessToken(),a=Gt.getIdToken(),t=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=Gt.getSelectedAlias(),o=n&&s.some(e=>e.alias===n)?n:r||s[0]?.alias||null;if(!Gt.isSupabaseTokenValid()&&o){const a=await this.generateSupabaseToken(e,o);a&&Gt.setSupabaseToken(a)}return{isAuthenticated:!0,isLoading:!1,user:t,alias:o,companies:s}}catch(e){return console.error("[Auth] Erro na inicialização:",e),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[]}}}static async loginDev(){try{const e=hs(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return console.error("[Auth] Erro na Edge Function dev-tokens:",t),!1;if(!a?.access_token||!a?.id_token)return console.error("[Auth] Tokens ausentes na resposta"),!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return console.error("[Auth] Erro no login dev:",e),!1}}static loginProd(){const e=Gt.generateOAuthState();Gt.setOAuthState(e);const a=Gt.generateOAuthNonce();Gt.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(xs.oauth.authUrl);s.searchParams.set("client_id",xs.oauth.clientId),s.searchParams.set("response_type",xs.oauth.responseType),s.searchParams.set("scope",xs.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(Gt.hasAllTokens()){if(!Gt.getValidSupabaseToken()){const e=Gt.getAccessToken(),a=this.extractAliasFromAccessToken(e),t=this.extractCompaniesFromIdToken(Gt.getIdToken())[0]?.alias,s=a||t;if(s){const a=await this.generateSupabaseToken(e,s);a&&Gt.setSupabaseToken(a)}}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");Gt.setAccessToken(s),Gt.setIdToken(r);const o=this.extractAliasFromAccessToken(s);if(o){const e=await this.generateSupabaseToken(s,o);if(!e)throw new Error("Falha ao gerar token Supabase");Gt.setSupabaseToken(e)}else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");const a=e[0].alias,t=await this.generateSupabaseToken(s,a);if(!t)throw new Error("Falha ao gerar token Supabase");Gt.setSupabaseToken(t)}return Gt.clearOAuthState(),Gt.clearOAuthNonce(),!0}catch(e){throw console.error("❌ [CallbackPage] Erro ao processar callback:",e),e}}static logout(){Gt.clearAll(),window.location.href="/"}static decodeToken(e){try{const a=e.split(".")[1],t=atob(a),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);const r=new TextDecoder("utf-8").decode(s);return JSON.parse(r)}catch{return null}}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({alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}static async generateSupabaseToken(e,a){try{const t=hs(),{data:s,error:r}=await t.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return r?(console.error("[Auth] Erro na Edge Function validate-token:",r),null):s?.access_token?s.access_token:(console.error("[Auth] Token Supabase ausente na resposta"),null)}catch(e){return console.error("[Auth] Erro ao gerar token Supabase:",e),null}}}const ws=r(void 0),ks=({children:e})=>{const[a,r]=t({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0}),n=We(),[l,d]=t(!1),[c,m]=t(0),u=o(e=>{r(a=>({...a,...e}))},[]),f=o(e=>{r(a=>({...a,isLoading:e}))},[]),p=o(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0})},[]),h=o(async e=>{try{f(!0);const a=Gt.getAccessToken();if(!a)return void console.error("[AuthContext] Access token não encontrado para trocar unidade");const t=await js.generateSupabaseToken(a,e.alias);if(!t)return void console.error("[AuthContext] Erro ao gerar token Supabase para nova unidade");Gt.setSupabaseToken(t),Gt.setSelectedAlias(e.alias),u({alias:e.alias}),await n.invalidateQueries()}catch(a){console.error("[AuthContext] Erro ao trocar unidade",a,e)}finally{f(!1)}},[u,n,f]),x=o(async()=>await js.processCallback(),[]),g=o(async()=>{js.logout(),p(),await n.clear()},[p,n]),b=o(e=>{d(e)},[]),v=o(()=>{m(e=>e+1)},[]),y=o(()=>{m(e=>e+1)},[]);s(()=>{(async()=>{try{await new Promise(e=>setTimeout(e,100));const e=await js.initialize();e&&e.isAuthenticated?u({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1}):f(!1)}catch(e){console.error("[AuthContext] Erro na inicialização da autenticação",e),f(!1)}})()},[u,f]);const N=i(()=>({...a,logout:g,processCallback:x,switchUnit:h,availableUnits:a.companies,isSearchVisible:l,setSearchVisible:b,clearSearch:v,refreshData:y}),[a,g,x,h,l,b,v,y]);return ha.jsx(ws.Provider,{value:N,children:e})},Ss=()=>{const e=n(ws);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e},Cs=({variant:e="button",className:s="",children:r})=>{const[n,o]=t(!1),{user:i}=Ss(),{companies:l,alias:d}=Ss(),c=d?l?.find(e=>e.alias===d)||l?.[0]||null:l?.[0]||null,m=(()=>{if(!i?.email)return"";return`${`${import.meta.env.VITE_FEEDBACK_APP_URL}/`}?${new URLSearchParams({email:i.email,module:"OKR",alias:c?.alias||""}).toString()}`})();if(!i?.email||!c)return null;const u=a.forwardRef((a,t)=>"menuItem"===e?ha.jsxs("div",{ref:t,className:"flex items-center cursor-pointer w-full px-2 py-1.5 text-sm hover:bg-accent rounded-sm",...a,children:[ha.jsx(C,{className:"mr-2 h-4 w-4"}),"Feedback"]}):ha.jsxs(Na,{ref:t,variant:"default",size:"sm",className:`bg-primary hover:bg-primary/90 ${s}`,...a,children:[ha.jsx(C,{className:"mr-2 h-4 w-4"}),"Feedback"]}));return u.displayName="TriggerButton",ha.jsxs(gt,{open:n,onOpenChange:o,children:[ha.jsx(bt,{asChild:!0,children:ha.jsx(u,{})}),ha.jsxs(jt,{className:"max-w-4xl max-h-[90vh] w-full h-full p-0 overflow-hidden",children:[ha.jsxs(wt,{className:"sr-only",children:[ha.jsx(St,{children:"Feedback"}),ha.jsx(Ct,{children:"Formulário de feedback para melhorias no sistema"})]}),ha.jsx("div",{className:"w-full h-full",children:ha.jsx("iframe",{src:m,width:"100%",height:"600px",className:"feedback-iframe",title:"Formulário de Feedback",loading:"lazy"})})]})]})},Ts=Xe,Es=e.createContext({}),Rs=({...e})=>ha.jsx(Es.Provider,{value:{name:e.name},children:ha.jsx(Ge,{...e})}),Ps=()=>{const a=e.useContext(Es),t=e.useContext(_s),{getFieldState:s,formState:r}=Ke(),n=s(a.name,r);if(!a)throw new Error("useFormField should be used within <FormField>");const{id:o}=t;return{id:o,name:a.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...n}},_s=e.createContext({}),As=e.forwardRef(({className:a,...t},s)=>{const r=e.useId();return ha.jsx(_s.Provider,{value:{id:r},children:ha.jsx("div",{ref:s,className:xa("space-y-2",a),...t})})});As.displayName="FormItem";const Is=e.forwardRef(({className:e,...a},t)=>{const{error:s,formItemId:r}=Ps();return ha.jsx(et,{ref:t,className:xa(s&&"text-destructive",e),htmlFor:r,...a})});Is.displayName="FormLabel";const Os=e.forwardRef(({...e},a)=>{const{error:t,formItemId:s,formDescriptionId:r,formMessageId:n}=Ps();return ha.jsx(x,{ref:a,id:s,"aria-describedby":t?`${r} ${n}`:`${r}`,"aria-invalid":!!t,...e})});Os.displayName="FormControl";const Ds=e.forwardRef(({className:e,...a},t)=>{const{formDescriptionId:s}=Ps();return ha.jsx("p",{ref:t,id:s,className:xa("text-sm text-muted-foreground",e),...a})});Ds.displayName="FormDescription";const zs=e.forwardRef(({className:e,children:a,...t},s)=>{const{error:r,formMessageId:n}=Ps(),o=r?String(r?.message):a;return o?ha.jsx("p",{ref:s,id:n,className:xa("text-sm font-medium text-destructive",e),...t,children:o}):null});zs.displayName="FormMessage";const Fs={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))]"},$s={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Ls({children:e,cols:a="auto-fit",gap:t="md",className:s}){return ha.jsx("div",{className:xa("grid",Fs[a],$s[t],s),children:e})}const Ms=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(Ye.Root,{ref:s,className:xa("relative overflow-hidden",e),...t,children:[ha.jsx(Ye.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),ha.jsx(Us,{}),ha.jsx(Ye.Corner,{})]}));Ms.displayName=Ye.Root.displayName;const Us=e.forwardRef(({className:e,orientation:a="vertical",...t},s)=>ha.jsx(Ye.ScrollAreaScrollbar,{ref:s,orientation:a,className:xa("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:ha.jsx(Ye.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Us.displayName=Ye.ScrollAreaScrollbar.displayName;const Vs={Star:ke,Heart:we,Home:je,User:Ne,Settings:ye,Mail:ve,Phone:be,Calendar:ge,MapPin:xe,Camera:he,Image:pe,Music:fe,Video:ue,Book:me,Bookmark:ce,Search:k,Filter:de,Edit:le,Trash2:ie,Plus:oe,Minus:ne,Check:N,X:y,ChevronDown:re,ChevronUp:se,ChevronLeft:te,ChevronRight:b,ArrowUp:ae,ArrowDown:ee,ArrowLeft:Z,ArrowRight:J,Clock:Y,Bell:G,AlertCircle:w,Info:X,HelpCircle:K,Download:Q,Upload:H,Share:q,Copy:B,Save:W,FileText:V,Folder:U,FolderOpen:M,Archive:L,Lock:$,Unlock:F,Eye:z,EyeOff:D,Shield:O,Key:I,Zap:A,Flame:_,Sparkles:P,Award:R,Trophy:E,Target:T},Ws=({value:e="Star",onChange:a,label:s})=>{const[r,n]=t(""),o=Object.entries(Vs).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),i=Vs[e]||ke;return ha.jsxs("div",{className:"space-y-2",children:[s&&ha.jsx(et,{children:s}),ha.jsxs(at,{children:[ha.jsx(tt,{asChild:!0,children:ha.jsxs(Na,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[ha.jsx(i,{className:"h-4 w-4 mr-2"}),e]})}),ha.jsx(st,{className:"w-80",children:ha.jsxs("div",{className:"space-y-3",children:[ha.jsxs("div",{children:[ha.jsx(et,{htmlFor:"icon-search",children:"Buscar ícone"}),ha.jsx(Ja,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>n(e.target.value)})]}),ha.jsx(Ms,{className:"h-48",children:ha.jsx("div",{className:"grid grid-cols-6 gap-2",children:o.map(([t,s])=>ha.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:ha.jsx(s,{className:"h-4 w-4"})},t))})})]})})]})]})},Bs=e.forwardRef(({className:e,containerClassName:a,...t},s)=>ha.jsx(Je,{ref:s,containerClassName:xa("flex items-center gap-2 has-[:disabled]:opacity-50",a),className:xa("disabled:cursor-not-allowed",e),...t}));Bs.displayName="InputOTP";const qs=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex items-center",e),...a}));qs.displayName="InputOTPGroup";const Hs=e.forwardRef(({index:a,className:t,...s},r)=>{const n=e.useContext(Ze),{char:o,hasFakeCaret:i,isActive:l}=n.slots[a];return ha.jsxs("div",{ref:r,className:xa("relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",l&&"z-10 ring-2 ring-ring ring-offset-background",t),...s,children:[o,i&&ha.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:ha.jsx("div",{className:"h-4 w-px animate-caret-blink bg-foreground duration-1000"})})]})});Hs.displayName="InputOTPSlot";const Qs=e.forwardRef(({...e},a)=>ha.jsx("div",{ref:a,role:"separator",...e,children:ha.jsx(Se,{})}));Qs.displayName="InputOTPSeparator";const Ks={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Xs({size:e="md",className:a}){return ha.jsx(Ce,{className:xa("animate-spin text-muted-foreground",Ks[e],a)})}function Gs({isLoading:e,children:a,className:t,type:s="spinner",size:r="md"}){return e?"overlay"===s?ha.jsxs("div",{className:xa("relative",t),children:[a,ha.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:ha.jsx(Xs,{size:r})})]}):"skeleton"===s?ha.jsx("div",{className:xa("animate-pulse",t),children:ha.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):ha.jsx("div",{className:xa("flex items-center justify-center py-8",t),children:ha.jsx(Xs,{size:r})}):ha.jsx(ha.Fragment,{children:a})}function Ys({items:e,maxItems:a=3,className:t}){const s=e.length>a?[e[0],...e.slice(-(a-1))]:e,r=e.length>a;return ha.jsx(La,{className:t,children:ha.jsx(Ma,{children:s.map((e,a)=>{const t=a===s.length-1,n=r&&1===a;return ha.jsxs("div",{className:"flex items-center",children:[n&&ha.jsxs(ha.Fragment,{children:[ha.jsx(Ua,{children:ha.jsx(qa,{})}),ha.jsx(Ba,{})]}),ha.jsx(Ua,{children:t||e.isCurrentPage?ha.jsx(Wa,{className:"font-bold text-lg",children:e.label}):ha.jsx(Va,{href:e.href,children:e.label})}),!t&&ha.jsx(Ba,{})]},`${e.label}-${a}`)})})})}function Js(){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,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:o,href:n?void 0:s,isCurrentPage:n})}),t})()}const Zs=({className:e,...a})=>ha.jsx("nav",{role:"navigation","aria-label":"pagination",className:xa("mx-auto flex w-full justify-center",e),...a});Zs.displayName="Pagination";const er=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,className:xa("flex flex-row items-center gap-1",e),...a}));er.displayName="PaginationContent";const ar=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,className:xa("",e),...a}));ar.displayName="PaginationItem";const tr=({className:e,isActive:a,size:t="icon",...s})=>ha.jsx("a",{"aria-current":a?"page":void 0,className:xa(ya({variant:a?"outline":"ghost",size:t}),e),...s});tr.displayName="PaginationLink";const sr=({className:e,...a})=>ha.jsxs(tr,{"aria-label":"Go to previous page",size:"default",className:xa("gap-1 pl-2.5",e),...a,children:[ha.jsx(te,{className:"h-4 w-4"}),ha.jsx("span",{children:"Previous"})]});sr.displayName="PaginationPrevious";const rr=({className:e,...a})=>ha.jsxs(tr,{"aria-label":"Go to next page",size:"default",className:xa("gap-1 pr-2.5",e),...a,children:[ha.jsx("span",{children:"Next"}),ha.jsx(b,{className:"h-4 w-4"})]});rr.displayName="PaginationNext";const nr=({className:e,...a})=>ha.jsxs("span",{"aria-hidden":!0,className:xa("flex h-9 w-9 items-center justify-center",e),...a,children:[ha.jsx(v,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"More pages"})]});nr.displayName="PaginationEllipsis";const or=sa.Root,ir=sa.Group,lr=sa.Value,dr=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(sa.Trigger,{ref:s,className:xa("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,ha.jsx(sa.Icon,{asChild:!0,children:ha.jsx(re,{className:"h-4 w-4 opacity-50"})})]}));dr.displayName=sa.Trigger.displayName;const cr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.ScrollUpButton,{ref:t,className:xa("flex cursor-default items-center justify-center py-1",e),...a,children:ha.jsx(se,{className:"h-4 w-4"})}));cr.displayName=sa.ScrollUpButton.displayName;const mr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.ScrollDownButton,{ref:t,className:xa("flex cursor-default items-center justify-center py-1",e),...a,children:ha.jsx(re,{className:"h-4 w-4"})}));mr.displayName=sa.ScrollDownButton.displayName;const ur=e.forwardRef(({className:e,children:a,position:t="popper",...s},r)=>ha.jsx(sa.Portal,{children:ha.jsxs(sa.Content,{ref:r,className:xa("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:[ha.jsx(cr,{}),ha.jsx(sa.Viewport,{className:xa("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),ha.jsx(mr,{})]})}));ur.displayName=sa.Content.displayName;const fr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.Label,{ref:t,className:xa("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a}));fr.displayName=sa.Label.displayName;const pr=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(sa.Item,{ref:s,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(sa.ItemIndicator,{children:ha.jsx(N,{className:"h-4 w-4"})})}),ha.jsx(sa.ItemText,{children:a})]}));pr.displayName=sa.Item.displayName;const hr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.Separator,{ref:t,className:xa("-mx-1 my-1 h-px bg-muted",e),...a}));hr.displayName=sa.Separator.displayName;const xr=e.forwardRef(({className:e,orientation:a="horizontal",decorative:t=!0,...s},r)=>ha.jsx(ra.Root,{ref:r,decorative:t,orientation:a,className:xa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...s}));xr.displayName=ra.Root.displayName;const gr=Ue.Root,br=Ue.Trigger,vr=Ue.Close,yr=Ue.Portal,Nr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Overlay,{className:xa("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}));Nr.displayName=Ue.Overlay.displayName;const jr=g("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"}}),wr=e.forwardRef(({side:e="right",className:a,children:t,...s},r)=>ha.jsxs(yr,{children:[ha.jsx(Nr,{}),ha.jsxs(Ue.Content,{ref:r,className:xa(jr({side:e}),a),...s,children:[t,ha.jsxs(Ue.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:[ha.jsx(y,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wr.displayName=Ue.Content.displayName;const kr=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col space-y-2 text-center sm:text-left",e),...a});kr.displayName="SheetHeader";const Sr=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Sr.displayName="SheetFooter";const Cr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Title,{ref:t,className:xa("text-lg font-semibold text-foreground",e),...a}));Cr.displayName=Ue.Title.displayName;const Tr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Tr.displayName=Ue.Description.displayName;const Er=na.Provider,Rr=na.Root,Pr=na.Trigger,_r=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>ha.jsx(na.Content,{ref:s,sideOffset:a,className:xa("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}));_r.displayName=na.Content.displayName;const Ar="sidebar:state",Ir=e.createContext(null);function Or(){const a=e.useContext(Ir);if(!a)throw new Error("useSidebar must be used within a SidebarProvider.");return a}const Dr=e.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const[d,c]=e.useState(!1);e.useEffect(()=>{const e=()=>c(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(Ar);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(Ar,String(a))},[s,h]),g=e.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,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",v=e.useMemo(()=>({state:b,open:h,setOpen:x,isMobile:d,openMobile:m,setOpenMobile:u,toggleSidebar:g}),[b,h,x,d,m,u,g]);return ha.jsx(Ir.Provider,{value:v,children:ha.jsx(Er,{delayDuration:0,children:ha.jsx("div",{className:xa("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":"3rem",...n},ref:l,...i,children:o})})})});Dr.displayName="SidebarProvider";const zr=e.forwardRef(({side:e="left",variant:a="sidebar",collapsible:t="offcanvas",className:s,children:r,...n},o)=>{const{isMobile:i,state:l,openMobile:d,setOpenMobile:c}=Or();return"none"===t?ha.jsx("div",{className:xa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:o,...n,children:r}):i?ha.jsx(gr,{open:d,onOpenChange:c,...n,children:ha.jsxs(wr,{"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:[ha.jsx(Cr,{className:"sr-only",children:"Menu de Navegação"}),ha.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):ha.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?t:"","data-variant":a,"data-side":e,children:[ha.jsx("div",{className:xa("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]")}),ha.jsx("div",{className:xa("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:ha.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:r})})]})});zr.displayName="Sidebar";const Fr=e.forwardRef(({className:e,onClick:a,...t},s)=>{const{toggleSidebar:r}=Or();return ha.jsxs(Na,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:xa("h-7 w-7",e),onClick:e=>{a?.(e),r()},...t,children:[ha.jsx(Te,{}),ha.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Fr.displayName="SidebarTrigger";const $r=e.forwardRef(({className:e,...a},t)=>{const{toggleSidebar:s}=Or();return ha.jsx("button",{ref:t,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:xa("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})});$r.displayName="SidebarRail";const Lr=e.forwardRef(({className:e,...a},t)=>ha.jsx("main",{ref:t,className:xa("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}));Lr.displayName="SidebarInset";const Mr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ja,{ref:t,"data-sidebar":"input",className:xa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...a}));Mr.displayName="SidebarInput";const Ur=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"header",className:xa("flex flex-col gap-2 p-2",e),...a}));Ur.displayName="SidebarHeader";const Vr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"footer",className:xa("flex flex-col gap-2 p-2",e),...a}));Vr.displayName="SidebarFooter";const Wr=e.forwardRef(({className:e,...a},t)=>ha.jsx(xr,{ref:t,"data-sidebar":"separator",className:xa("mx-2 w-auto bg-sidebar-border",e),...a}));Wr.displayName="SidebarSeparator";const Br=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"content",className:xa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...a}));Br.displayName="SidebarContent";const qr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"group",className:xa("relative flex w-full min-w-0 flex-col p-2",e),...a}));qr.displayName="SidebarGroup";const Hr=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?x:"div";return ha.jsx(r,{ref:s,"data-sidebar":"group-label",className:xa("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})});Hr.displayName="SidebarGroupLabel";const Qr=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?x:"button";return ha.jsx(r,{ref:s,"data-sidebar":"group-action",className:xa("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})});Qr.displayName="SidebarGroupAction";const Kr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"group-content",className:xa("w-full text-sm",e),...a}));Kr.displayName="SidebarGroupContent";const Xr=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,"data-sidebar":"menu",className:xa("flex w-full min-w-0 flex-col gap-1",e),...a}));Xr.displayName="SidebarMenu";const Gr=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,"data-sidebar":"menu-item",className:xa("group/menu-item relative",e),...a}));Gr.displayName="SidebarMenuItem";const Yr=g("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",{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"}}),Jr=e.forwardRef(({asChild:e=!1,isActive:a=!1,variant:t="default",size:s="default",tooltip:r,className:n,...o},i)=>{const l=e?x:"button",{isMobile:d,state:c}=Or(),m=ha.jsx(l,{ref:i,"data-sidebar":"menu-button","data-size":s,"data-active":a,className:xa(Yr({variant:t,size:s}),n),...o});return r?("string"==typeof r&&(r={children:r}),ha.jsxs(Rr,{children:[ha.jsx(Pr,{asChild:!0,children:m}),ha.jsx(_r,{side:"right",align:"center",hidden:"collapsed"!==c||d,...r})]})):m});Jr.displayName="SidebarMenuButton";const Zr=e.forwardRef(({className:e,asChild:a=!1,showOnHover:t=!1,...s},r)=>{const n=a?x:"button";return ha.jsx(n,{ref:r,"data-sidebar":"menu-action",className:xa("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})});Zr.displayName="SidebarMenuAction";const en=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"menu-badge",className:xa("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}));en.displayName="SidebarMenuBadge";const an=e.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return ha.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:xa("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&ha.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),ha.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});an.displayName="SidebarMenuSkeleton";const tn=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,"data-sidebar":"menu-sub",className:xa("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}));tn.displayName="SidebarMenuSub";const sn=e.forwardRef(({...e},a)=>ha.jsx("li",{ref:a,...e}));sn.displayName="SidebarMenuSubItem";const rn=e.forwardRef(({asChild:e=!1,size:a="md",isActive:t,className:s,...r},n)=>{const o=e?x:"a";return ha.jsx(o,{ref:n,"data-sidebar":"menu-sub-button","data-size":a,"data-active":t,className:xa("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})});function nn({className:e,...a}){return ha.jsx("div",{className:xa("animate-pulse rounded-md bg-muted",e),...a})}function on({rows:e=5,columns:a=4}){return ha.jsx("div",{className:"w-full",children:ha.jsxs("div",{className:"rounded-md border",children:[ha.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:ha.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>ha.jsx(nn,{className:"h-4 w-24"},a))})}),ha.jsx("div",{children:Array.from({length:e}).map((e,t)=>ha.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:ha.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>ha.jsx(nn,{className:"h-4 w-20"},a))})},t))})]})})}function ln({count:e=3}){return ha.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,a)=>ha.jsxs(Ha,{children:[ha.jsxs(Qa,{children:[ha.jsx(nn,{className:"h-4 w-3/4"}),ha.jsx(nn,{className:"h-3 w-1/2"})]}),ha.jsx(Ga,{children:ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(nn,{className:"h-3 w-full"}),ha.jsx(nn,{className:"h-3 w-2/3"})]})})]},a))})}function dn({fields:e=4}){return ha.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,a)=>ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(nn,{className:"h-4 w-24"}),ha.jsx(nn,{className:"h-10 w-full"})]},a)),ha.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[ha.jsx(nn,{className:"h-10 w-20"}),ha.jsx(nn,{className:"h-10 w-20"})]})]})}function cn(){return ha.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx(nn,{className:"h-8 w-8 rounded-full"}),ha.jsx(nn,{className:"h-6 w-32"})]}),ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx(nn,{className:"h-8 w-8"}),ha.jsx(nn,{className:"h-8 w-24"})]})]})}function mn(){return ha.jsx("div",{className:"w-64 border-r bg-muted/10",children:ha.jsxs("div",{className:"p-4",children:[ha.jsx(nn,{className:"h-8 w-32 mb-6"}),ha.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,a)=>ha.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[ha.jsx(nn,{className:"h-4 w-4"}),ha.jsx(nn,{className:"h-4 w-20"})]},a))})]})})}rn.displayName="SidebarMenuSubButton";const un={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},fn={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},pn={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function hn({children:e,direction:a="column",gap:t="md",align:s="stretch",justify:r="start",wrap:n=!1,className:o}){return ha.jsx("div",{className:xa("flex","column"===a?"flex-col":"flex-row",un[t],fn[s],pn[r],n&&"flex-wrap",o),children:e})}const xn=e.forwardRef(({className:e,...a},t)=>ha.jsx("table",{ref:t,className:xa("w-full caption-bottom text-sm",e),...a}));xn.displayName="Table";const gn=e.forwardRef(({className:e,...a},t)=>ha.jsx("thead",{ref:t,className:xa("[&_tr]:border-b sticky top-0 z-10 bg-background",e),...a}));gn.displayName="TableHeader";const bn=e.forwardRef(({className:e,...a},t)=>ha.jsx("tbody",{ref:t,className:xa("[&_tr:last-child]:border-0",e),...a}));bn.displayName="TableBody";e.forwardRef(({className:e,...a},t)=>ha.jsx("tfoot",{ref:t,className:xa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a})).displayName="TableFooter";const vn=e.forwardRef(({className:e,...a},t)=>ha.jsx("tr",{ref:t,className:xa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...a}));vn.displayName="TableRow";const yn=e.forwardRef(({className:e,...a},t)=>ha.jsx("th",{ref:t,className:xa("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}));yn.displayName="TableHead";const Nn=e.forwardRef(({className:e,...a},t)=>ha.jsx("td",{ref:t,className:xa("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...a}));Nn.displayName="TableCell";const jn=e.forwardRef(({className:e,...a},t)=>ha.jsx("caption",{ref:t,className:xa("mt-4 text-sm text-muted-foreground",e),...a}));jn.displayName="TableCaption";const wn=e.forwardRef(({className:e,...a},t)=>ha.jsx("textarea",{className:xa("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}));wn.displayName="Textarea";const kn=ia.Provider,Sn=e.forwardRef(({className:e,...a},t)=>ha.jsx(ia.Viewport,{ref:t,className:xa("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}));Sn.displayName=ia.Viewport.displayName;const Cn=g("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"}}),Tn=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx(ia.Root,{ref:s,className:xa(Cn({variant:a}),e),...t}));Tn.displayName=ia.Root.displayName;const En=e.forwardRef(({className:e,...a},t)=>ha.jsx(ia.Action,{ref:t,className:xa("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}));En.displayName=ia.Action.displayName;const Rn=e.forwardRef(({className:e,...a},t)=>ha.jsx(ia.Close,{ref:t,className:xa("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:ha.jsx(y,{className:"h-4 w-4"})}));Rn.displayName=ia.Close.displayName;const Pn=e.forwardRef(({className:e,...a},t)=>ha.jsx(ia.Title,{ref:t,className:xa("text-sm font-semibold",e),...a}));Pn.displayName=ia.Title.displayName;const _n=e.forwardRef(({className:e,...a},t)=>ha.jsx(ia.Description,{ref:t,className:xa("text-sm opacity-90",e),...a}));function An(){const{toasts:e}=ns();return ha.jsxs(kn,{children:[e.map(function({id:e,title:a,description:t,action:s,...r}){return ha.jsxs(Tn,{...r,children:[ha.jsxs("div",{className:"grid gap-1",children:[a&&ha.jsx(Pn,{children:a}),t&&ha.jsx(_n,{children:t})]}),s,ha.jsx(Rn,{})]},e)}),ha.jsx(Sn,{})]})}_n.displayName=ia.Description.displayName;const In=r({});function On({children:e,config:a}){return ha.jsx(In.Provider,{value:{navigation:a?.navigation},children:e})}function Dn(){return n(In)}function zn(){const e=ea(),{navigation:a}=Dn(),t=a?.find(a=>a.path===e.pathname);return t?.label||"Página"}const Fn=a.memo(({variant:e="card",className:t="",selectedUnit:s,onUnitChange:r})=>{const{user:n,companies:o,alias:i,isAuthenticated:l,logout:d,switchUnit:c}=Ss(),m=o?.[0]||null,u=i?o?.find(e=>e.alias===i):m,f=o||[],p=s||u||m||m,h=a.useCallback(e=>{r?r(e):c(e)},[r,c]),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=()=>ha.jsxs(ha.Fragment,{children:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx("div",{className:"flex-shrink-0",children:ha.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:ha.jsx(Ne,{className:"h-5 w-5 text-primary-foreground"})})}),ha.jsxs("div",{className:"flex-1 min-w-0",children:[ha.jsx("p",{className:"text-sm font-medium truncate",children:n.name}),ha.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&ha.jsx("div",{className:"mt-3",children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),ha.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),x.length>1&&ha.jsxs("div",{className:"mt-2",children:[ha.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",x.length]}),ha.jsxs("div",{className:"flex flex-wrap gap-1",children:[x.slice(0,3).map(e=>ha.jsx($a,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),x.length>3&&ha.jsxs($a,{variant:"outline",className:"text-xs",children:["+",x.length-3]})]})]})]});return"dropdown"===e?ha.jsxs(Tt,{children:[ha.jsx(Et,{asChild:!0,children:ha.jsx(Na,{variant:"ghost",className:`h-auto p-2 ${t}`,children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsxs("div",{className:"hidden md:block text-left",children:[ha.jsx("p",{className:"text-sm font-medium",children:n.name}),ha.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),ha.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:ha.jsx(Ne,{className:"h-4 w-4 text-primary-foreground"})}),ha.jsx(re,{className:"h-4 w-4"})]})})}),ha.jsxs(Dt,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[ha.jsxs(_t,{children:[ha.jsxs(It,{children:[ha.jsx(Ee,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),ha.jsx(Ot,{children:x.map(e=>ha.jsxs(zt,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[ha.jsx(Re,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&ha.jsx($a,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),ha.jsx(Mt,{}),ha.jsx(Cs,{variant:"menuItem"}),ha.jsxs(zt,{onClick:d,children:[ha.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):ha.jsxs(Ha,{className:t,children:[ha.jsx(Qa,{children:ha.jsx(Ka,{className:"text-lg",children:"Informações do Usuário"})}),ha.jsxs(Ga,{className:"space-y-4",children:[ha.jsx(g,{}),ha.jsx(xr,{}),ha.jsxs("div",{className:"flex space-x-2",children:[ha.jsx(Cs,{className:"flex-1"}),ha.jsxs(Na,{variant:"outline",onClick:d,size:"sm",className:"flex-1",children:[ha.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})});function $n(e,a){const[r,n]=t(e),i=l(),d=o(()=>{i.current&&(clearTimeout(i.current),i.current=void 0)},[]);return s(()=>(d(),i.current=setTimeout(()=>{n(e)},a),d),[e,a,d]),[r,d]}const Ln=({actions:e})=>{ea();const a=zn(),{companies:r,alias:n,isSearchVisible:o,clearSearch:i,refreshData:l,switchUnit:d}=Ss(),c=n?r?.find(e=>e.alias===n)||r?.[0]||null:r?.[0]||null,[m,u]=aa(),[f,p]=t(()=>m.get("search")||""),[h,x]=$n(f,bs.debounceDelay);s(()=>{if(!o)return;const e=new URLSearchParams(m);h?(e.set("search",h),e.set("page","1")):(e.delete("search"),e.delete("page")),u(e)},[h,u,o,m]);return ha.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:ha.jsxs("div",{className:"flex items-center justify-between gap-4",children:[ha.jsxs("div",{className:"flex items-center space-x-1 md:space-x-2 min-w-0",children:[ha.jsx(Fr,{className:"flex-shrink-0"}),ha.jsxs("div",{className:"min-w-0 flex flex-col md:flex-row md:items-center md:space-x-3 space-y-2 md:space-y-0",children:[ha.jsx("div",{className:"min-w-0",children:ha.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:a})}),o&&ha.jsxs("div",{className:"flex items-center space-x-1 w-full md:w-auto",children:[ha.jsxs("div",{className:"relative w-full md:w-48",children:[ha.jsx(k,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),ha.jsx(Ja,{placeholder:"Buscar...",value:f,onChange:e=>{return a=e.target.value,void p(a);var a},className:"w-full pl-10 pr-8"}),f&&ha.jsx(Na,{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:()=>{x(),p("");const e=new URLSearchParams(m);e.delete("search"),e.delete("page"),u(e)},title:"Limpar busca",children:ha.jsx(y,{size:14})})]}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:l,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:ha.jsx(Ee,{size:14})})]})]})]}),ha.jsxs("div",{className:"flex-shrink-0 flex items-center gap-3",children:[e&&ha.jsx("div",{className:"flex items-center gap-2",children:e}),ha.jsx("div",{className:"text-sm",children:ha.jsx(Fn,{variant:"dropdown",selectedUnit:c,onUnitChange:d})})]})]})})},Mn=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Ss();return Be({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=hs(),{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)throw s;return a||[]},enabled:a&&!!t})},Un=import.meta.env.VITE_SUPABASE_PROJECT_ID,Vn={logo:`https://${Un}.supabase.co/storage/v1/object/public/library-assets/logo.png`,smallLogo:`https://${Un}.supabase.co/storage/v1/object/public/library-assets/small.png`},Wn=Vn.logo,Bn=Vn.smallLogo;function qn({config:e}={}){const{state:a}=Or(),s=ea(),[r,n]=t(!1),{data:o,isLoading:i,error:l}=Mn({enabled:r}),d=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 ha.jsxs(zr,{collapsible:"icon",children:[ha.jsxs(Ur,{className:"p-0 gap-0",children:[ha.jsxs(Tt,{onOpenChange:n,children:[ha.jsx(Et,{asChild:!0,children:ha.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary hover:opacity-90 text-primary-foreground font-semibold text-sm flex items-center justify-center cursor-pointer transition-all duration-200 h-8 gap-2 shadow-lg rounded-b-2xl",children:["collapsed"!==a&&e?.appName,ha.jsx(re,{size:16})]})}),ha.jsx(Dt,{className:"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50",align:"collapsed"===a?"center":"start",children:i?ha.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[ha.jsx(Ce,{className:"h-4 w-4 animate-spin"}),ha.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):l?ha.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[ha.jsx(w,{className:"h-4 w-4"}),ha.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):o&&0!==o.length?ha.jsx("div",{className:"space-y-2",children:o.map((e,a)=>ha.jsx("div",{onClick:()=>(e=>{const a=o?.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 ${d(a)} transition-colors duration-200\n `,children:ha.jsxs("div",{className:"flex items-center justify-between",children:[ha.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&ha.jsx(_e,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):ha.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]}),ha.jsx("div",{className:"flex justify-center items-center h-20",children:ha.jsx("img",{src:"collapsed"===a?Vn.smallLogo:Vn.logo,alt:"Logo",className:"collapsed"===a?"h-8 w-8":"h-14 max-w-full"})})]}),ha.jsx(Br,{children:ha.jsx(qr,{children:ha.jsx(Kr,{children:ha.jsx(Xr,{children:e?.navigation?.map(e=>{return ha.jsx(Gr,{children:ha.jsx(Jr,{asChild:!0,isActive:(a=e.path,s.pathname===a),children:ha.jsxs(ta,{to:e.path,children:[ha.jsx(e.icon,{}),ha.jsx("span",{children:e.label})]})})},e.path);var a})})})})})]})}function Hn({children:e,sidebar:a,sidebarConfig:t,showHeader:s=!0}){const r=a||ha.jsx(qn,{config:t});return ha.jsx(On,{config:t,children:ha.jsx(Dr,{children:ha.jsxs("div",{className:"min-h-screen flex w-full h-screen overflow-hidden",children:[r,ha.jsxs("main",{className:"flex-1 flex flex-col h-full overflow-hidden",children:[s&&ha.jsx("div",{className:"flex-shrink-0",children:ha.jsx(Ln,{})}),ha.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e})]})]})})})}class Qn extends d{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,a){ls.handleError(e,!1),console.error("ErrorBoundary caught an error:",e,a)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ha.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsxs(Qa,{className:"text-center",children:[ha.jsx("div",{className:"flex justify-center mb-4",children:ha.jsx(Ae,{className:"h-12 w-12 text-destructive"})}),ha.jsx(Ka,{children:"Algo deu errado"})]}),ha.jsxs(Ga,{className:"text-center space-y-4",children:[ha.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),ha.jsx(Na,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function Kn(e,a,r,n){const[o,l]=t({}),[d,c]=t({}),m=i(()=>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(a){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 s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(a,t);if(e)return e}catch(e){}}};s(()=>{if(!n)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},t=e(m),s={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=f(e);s[e.name]=t}),t.forEach(e=>{const a=p(e,s);void 0!==a&&(s[e.name]=a)}),l(s),c({}),r&&r(s)},[m,a,r,n]);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,o[e.name],o);t&&(a[e.name]=t)}),c(a),0===Object.keys(a).length};return{formData:o,errors:d,updateField:(e,a)=>{l(t=>{const s={...t,[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,s);return r&&r(n),n}),d[e]&&c(a=>{const t={...a};return delete t[e],t});const t=x(m).find(a=>a.name===e);if(t){const s=h(t,a,o);s&&c(a=>({...a,[e]:s}))}},validateForm:g,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),g()&&e(o)}}}var Xn=Object.defineProperty,Gn=(e,a,t)=>((e,a,t)=>a in e?Xn(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Yn=new class{constructor(){Gn(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=Gt.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 ls.handleError("[QualiexApi] Unexpected response format",!1),[];s=t}if(!Array.isArray(s))return ls.handleError("[QualiexApi] Response is not an array",!1),[];return s.map(this.mapToQualiexUser)}catch(e){return ls.handleError(e instanceof Error?e:"[QualiexApi] Error fetching users"),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(e){return ls.handleError(e instanceof Error?e:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const a=Gt.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):(ls.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}},Jn=(e={})=>{const{user:a,alias:t}=Ss(),{enabled:s=!0}=e;return Be({queryKey:["qualiex-users",t],queryFn:()=>Yn.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},Zn=({value:e="",onChange:a,placeholder:t="Selecionar usuário",disabled:s,className:r})=>{const{data:n=[],isLoading:o,error:i}=Jn();return o?ha.jsx(nn,{className:xa("h-10 w-full",r)}):i?ha.jsxs("div",{className:`flex items-center gap-2 p-2 border border-destructive/20 rounded-md ${r}`,children:[ha.jsx(w,{className:"h-4 w-4 text-destructive"}),ha.jsx("span",{className:"text-sm text-destructive",children:"Erro ao carregar usuários"})]}):ha.jsxs(or,{value:e,onValueChange:a,disabled:s||0===n.length,children:[ha.jsx(dr,{className:r,children:ha.jsx(lr,{placeholder:t})}),ha.jsx(ur,{children:0===n.length?ha.jsx(pr,{value:"no-users",disabled:!0,children:"Nenhum usuário encontrado"}):n.map(e=>ha.jsx(pr,{value:e.userId,children:e.userName},e.userId))})]})},eo=({value:e,onChange:a,placeholder:t="Selecionar responsável",disabled:s,className:r})=>ha.jsxs(or,{value:e,onValueChange:a,disabled:s,children:[ha.jsx(dr,{className:r,children:ha.jsx(lr,{placeholder:t})}),ha.jsx(ur,{children:ha.jsx(pr,{value:"placeholder",children:"Responsável placeholder"})})]});function ao({title:e,sections:s,initialData:r,onSubmit:n,onCancel:l,open:d,submitButtonText:c="Salvar",isLoading:m=!1,usersData:u}){const[f,p]=t(s?.[0]?.id||""),h=i(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:x,errors:g,updateField:b,handleSubmit:v}=Kn(h,r,void 0,d),y=i(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(x):e.disabled||!1})):[],[s,x]),N=i(()=>{const e=y.find(e=>e.id===f);if(e&&!e.disabled)return f;const a=y.find(e=>!e.disabled);return a?.id||f},[y,f]);a.useEffect(()=>{N!==f&&p(N)},[N,f]);const j=y.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 ha.jsxs("div",{className:"space-y-2",children:[e.label,ha.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 ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Zn,{value:t||"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"textarea":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(wn,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"select":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsxs(or,{value:String(t),onValueChange:a=>{b(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[ha.jsx(dr,{className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:ha.jsx(lr,{placeholder:e.placeholder})}),ha.jsx(ur,{children:e.options?.map(e=>ha.jsx(pr,{value:e.value,children:e.label},e.value))})]}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"date":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{id:e.name,type:"date",value:String(t),onChange:a=>b(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:xa("w-full",s?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"single-responsible-select":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(eo,{value:String(t),onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"simple-qualiex-user-field":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Zn,{value:t??"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"color":return ha.jsxs("div",{children:[ha.jsxs(et,{htmlFor:e.name,children:[e.label," ",e.required&&ha.jsx("span",{className:"text-destructive",children:"*"})]}),ha.jsx(Ja,{id:e.name,type:"color",value:t||e.defaultValue||"#000000",onChange:a=>b(e.name,a.target.value),className:"h-10"}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return ha.jsxs("div",{children:[ha.jsx(nt,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"#3b82f6",onChange:a=>b(e.name,a)}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return ha.jsxs("div",{children:[ha.jsx(Ws,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"Star",onChange:a=>b(e.name,a)}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"number":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);default:return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name)}},k=o(()=>{if(!j)return null;if(j.disabled)return ha.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[ha.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:ha.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ha.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),ha.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),ha.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 ha.jsx(e,{formData:x,updateField:b,errors:g,users:u,disabled:j.disabled})}return ha.jsx("div",{className:"space-y-3",children:j.fields.map(w)})},[j,x,b,g,u,w]),S=ha.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&ha.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:ha.jsx("div",{className:"flex space-x-2",children:y.map(e=>ha.jsx(Na,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=y.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))})}),ha.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:m?ha.jsx("div",{className:"flex items-center justify-center py-12",children:ha.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):ha.jsxs("form",{onSubmit:v(n),className:"space-y-3 md:space-y-4",children:[k(),ha.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[ha.jsx(Na,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),ha.jsx(Na,{type:"submit",disabled:m,children:c})]})]})})]});return ha.jsx(gt,{open:d,onOpenChange:e=>{!1===e&&!0===d&&l()},children:ha.jsxs(jt,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[ha.jsxs(wt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[ha.jsx(St,{className:"text-white",children:e}),ha.jsx(Ct,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function to(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function so(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 ro(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 o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(i,e=>e.test(o)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(o.length)}}}const no={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"}},oo={date:to({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:to({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:to({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},io={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"};var lo;const co={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=no[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:oo,formatRelative:(e,a,t,s)=>{const r=io[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:so({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:so({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:so({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:so({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:so({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"})},match:{ordinalNumber:(lo={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,a={})=>{const t=e.match(lo.matchPattern);if(!t)return null;const s=t[0],r=e.match(lo.parsePattern);if(!r)return null;let n=lo.valueCallback?lo.valueCallback(r[0]):r[0];return n=a.valueCallback?a.valueCallback(n):n,{value:n,rest:e.slice(s.length)}}),era:ro({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:ro({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:ro({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:ro({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:ro({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},mo=({onEdit:e,onDelete:a,onToggleStatus:t,isActive:s=!0,canDelete:r=!0,renderAs:n})=>{const o=[];if(e){const a={icon:le,label:"Editar",onClick:e};o.push(a)}if(t){const e={icon:s?Ie:Oe,label:s?"Inativar":"Ativar",onClick:t};o.push(e)}if(r&&a){const e={icon:ie,label:"Remover",onClick:a,destructive:!0};o.push(e)}return"dropdown"===n?ha.jsx(ha.Fragment,{children:o.map((e,a)=>ha.jsxs(zt,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[ha.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},a))}):ha.jsx(ha.Fragment,{children:o.map((e,a)=>ha.jsxs(Na,{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:[ha.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},a))})},uo=({onEdit:e,onDelete:a,canDelete:t=!0,onToggleStatus:s,isActive:r=!0})=>ha.jsxs(Tt,{children:[ha.jsx(Et,{asChild:!0,children:ha.jsx(Na,{variant:"default",size:"sm",className:"h-7 px-2 text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:ha.jsx(De,{size:12})})}),ha.jsx(Dt,{align:"end",children:ha.jsx(mo,{onEdit:a=>{a?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),a?.()},onToggleStatus:e=>{e?.stopPropagation(),s?.()},isActive:r,canDelete:t,renderAs:"dropdown"})})]});function fo({manager:e,config:a,onEdit:t,onDelete:s}){return e.isLoading?ha.jsx(Ls,{children:Array.from({length:3}).map((e,a)=>ha.jsxs(Ha,{children:[ha.jsxs(Qa,{children:[ha.jsx(nn,{className:"h-4 w-3/4"}),ha.jsx(nn,{className:"h-3 w-1/2"})]}),ha.jsx(Ga,{children:ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(nn,{className:"h-3 w-full"}),ha.jsx(nn,{className:"h-3 w-2/3"})]})})]},a))}):ha.jsx(ht.Root,{children:e.entities.map(e=>ha.jsxs(ht.Item,{onClick:()=>t(e),children:[ha.jsx(Qa,{className:"pb-3",children:ha.jsxs("div",{className:"flex items-start justify-between",children:[ha.jsxs("div",{className:"flex-1 min-w-0",children:[ha.jsx(Ka,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),ha.jsx(Xa,{className:"text-sm",children:h(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:co})})]}),ha.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&ha.jsx(Na,{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),oa.info("Link copiado para a área de transferência"))}catch(a){window.location.href=e}})(e.link)},title:"Abrir link externo",children:ha.jsx(_e,{className:"h-4 w-4"})}),ha.jsx("div",{onClick:e=>e.stopPropagation(),children:ha.jsx(uo,{onEdit:()=>t(e),onDelete:s?()=>s(e):void 0,canDelete:!!s})})]})]})}),ha.jsx(Ga,{className:"pt-0",children:ha.jsx("div",{className:"space-y-2",children:a.cardFields?.map(a=>{const t=e[a.key];return t?ha.jsx(ht.Field,{label:a.label,value:a.render?a.render(t,e):String(t)},String(a.key)):null})})})]},e.id))})}const po=({manager:e,columns:a,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l})=>{const[d,c]=t(!1),[m,u]=t(null);s(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),s(()=>{const e=()=>u(null);if(m)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[m]);const f=(()=>{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?ha.jsx(ln,{count:3}):0===e.entities.length?ha.jsx(Wt,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):ha.jsxs("div",{className:"space-y-4",children:[e.entities.map(e=>ha.jsx(Ha,{className:"overflow-hidden cursor-pointer hover:bg-muted/50",onClick:a=>{a.stopPropagation(),r?.(e)},onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),u({x:a.clientX,y:a.clientY,item:e})},children:ha.jsxs(Ga,{className:"p-4",children:[a.map(a=>ha.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[ha.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),ha.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(e):e[a.key]})]},a.key)),(r||n||l)&&ha.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(e):ha.jsx(uo,{onEdit:r?()=>{r(e)}:void 0,onDelete:i?()=>i(e):void 0,onToggleStatus:o?()=>o(e):void 0,isActive:e.is_actived})})]})},e.id)),m&&ha.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:ha.jsx(mo,{onEdit:r?()=>{r(m.item),u(null)}:void 0,onDelete:i?()=>{i(m.item),u(null)}:void 0,onToggleStatus:o?()=>{o(m.item),u(null)}:void 0,isActive:m.item.is_actived,canDelete:!!i,renderAs:"context"})})]}):ha.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?ha.jsx(on,{rows:5,columns:a.length}):ha.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:ha.jsx("div",{className:"flex-1 overflow-auto",children:ha.jsxs(xn,{className:"table-fixed",children:[ha.jsxs("colgroup",{children:[f.map((e,a)=>ha.jsx("col",{style:e.style},a)),ha.jsx("col",{style:{width:"100px"}})]}),ha.jsx(gn,{children:ha.jsxs(vn,{children:[a.map(a=>{return ha.jsx(yn,{className:`${a.className||""} ${a.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:a.sortable?()=>e.handleSort(a.key):void 0,children:ha.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(t=a.key,e.sortField!==t?ha.jsx(ze,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?ha.jsx(ae,{size:14,className:"ml-1"}):ha.jsx(ee,{size:14,className:"ml-1"}))]})},a.key);var t}),ha.jsx(yn,{className:"w-[100px] text-center",children:"Ações"})]})}),ha.jsx(bn,{children:0===e.entities.length?ha.jsx(vn,{children:ha.jsx(Nn,{colSpan:a.length+1,className:"h-32",children:ha.jsx(Wt,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(e=>ha.jsxs(vn,{className:"cursor-pointer hover:bg-muted/50",onClick:a=>{a.stopPropagation(),r?.(e)},onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),u({x:a.clientX,y:a.clientY,item:e})},children:[a.map(a=>ha.jsx(Nn,{className:a.className,children:a.render?a.render(e):e[a.key]},a.key)),ha.jsx(Nn,{className:"text-center",children:l?l(e):ha.jsx(uo,{onEdit:r?()=>r(e):void 0,onDelete:i?()=>i(e):void 0,onToggleStatus:o?()=>o(e):void 0,isActive:e.is_actived})})]},e.id))})]})})}),m&&ha.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:ha.jsx(mo,{onEdit:r?()=>{r(m.item),u(null)}:void 0,onDelete:i?()=>{i(m.item),u(null)}:void 0,onToggleStatus:o?()=>{o(m.item),u(null)}:void 0,isActive:m.item.is_actived,canDelete:!!i,renderAs:"context"})})]})};function ho({open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:o=!1,submitButtonText:i="Salvar"}){return ha.jsx(ao,{open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:o,submitButtonText:i})}const xo=({manager:e})=>{const{pagination:a={totalItems:0,totalPages:1},currentPage:t=1,itemsPerPage:s=10,handlePageChange:r=()=>{},handleItemsPerPageChange:n=()=>{}}=e,{totalItems:o=0,totalPages:i=1}=a,l=o>0?(t-1)*s+1:0,d=Math.min(t*s,o);return ha.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:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx("span",{children:"Itens por página"}),ha.jsxs(or,{value:s.toString(),onValueChange:e=>n(Number(e)),children:[ha.jsx(dr,{className:"w-20 h-8 border-border",children:ha.jsx(lr,{})}),ha.jsxs(ur,{children:[ha.jsx(pr,{value:"10",children:"10"}),ha.jsx(pr,{value:"25",children:"25"}),ha.jsx(pr,{value:"50",children:"50"}),ha.jsx(pr,{value:"100",children:"100"})]})]})]}),ha.jsx("div",{className:"flex-1 flex justify-center",children:ha.jsx("span",{children:o>0?`${l}-${d} de ${o} itens (página ${t} de ${i})`:"0 itens"})}),ha.jsxs("div",{className:"flex items-center space-x-1",children:[ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(1),disabled:1===t,children:ha.jsx(Fe,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(Math.max(1,t-1)),disabled:1===t,children:ha.jsx(te,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(Math.min(i,t+1)),disabled:t===i,children:ha.jsx(b,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(i),disabled:t===i,children:ha.jsx($e,{className:"h-4 w-4"})})]})]})};function go({manager:e,config:a,formSections:s,onSave:r,FormComponent:n,TableComponent:o,onToggleStatus:i}){const[l,d]=t(!1),[c,m]=t(null),[u,f]=t({isOpen:!1,entityId:null,entityName:""}),p=e=>{m(e),d(!0)},h=()=>{d(!1),m(null)},x=e=>{r(e),d(!1),m(null)},g=e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})};return ha.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[ha.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b",children:ha.jsx("div",{className:"flex items-center gap-4",children:ha.jsxs(Na,{onClick:()=>{m(null),d(!0)},className:"flex items-center gap-2",children:[ha.jsx(oe,{size:16}),"Novo"]})})}),ha.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:o?ha.jsx(o,{manager:e,onEdit:p,onDelete:g,onToggleStatus:i}):ha.jsx(po,{manager:e,columns:a.columns,onEdit:p,onDelete:g,onToggleStatus:i})}),ha.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:ha.jsx(xo,{manager:e})}),n?ha.jsx(n,{open:l,onCancel:h,onSubmit:x,editingEntity:c,isLoading:e.isLoading}):ha.jsx(ho,{open:l,title:c?`Editar ${a.entityName}`:`Novo ${a.entityName}`,sections:s,initialData:c||void 0,onSubmit:x,onCancel:h,isLoading:e.isLoading,submitButtonText:c?"Atualizar":"Criar"}),ha.jsx(xt,{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})]})}function bo({manager:e,filters:a}){const{isSearchVisible:t}=Ss(),s=e.searchTerm;return ha.jsx(hn,{direction:"column",gap:"md",className:"mb-6",children:ha.jsxs(hn,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:[a.some(e=>"search"===e.type)&&!t&&ha.jsxs("div",{className:"relative flex-1",children:[ha.jsx(k,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),ha.jsx(Ja,{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 t=e.component;return ha.jsx("div",{className:"w-full sm:w-auto",children:ha.jsx(t,{...e.props})},a)}),s&&ha.jsxs(Na,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[ha.jsx(y,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]})})}function vo({queryKey:e,service:a,entityName:t,searchFields:s,additionalFilters:r={},onSuccess:n}){const[l,d]=aa(),c=We(),m=l.get("search")||"",u=l.get("sortField")||gs.sorting.defaultField,f=l.get("sortDirection")||gs.sorting.defaultDirection,p=parseInt(l.get("page")||"1"),h=parseInt(l.get("limit")||String(gs.pagination.defaultPageSize)),x=m,g=i(()=>({search:x,sortField:u,sortDirection:f,page:p,limit:h,...r}),[x,u,f,p,h,r]),b=o(()=>a.getAll(g),[a,g]),v=Be({queryKey:[e,g],queryFn:b}),y=qe({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),oa.success(Ns.success.created(t)),n?.()},onError:e=>{oa.error(`${Ns.error.create(t)}: ${e.message}`)}}),N=qe({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),oa.success(Ns.success.updated(t)),n?.()},onError:e=>{oa.error(`${Ns.error.update(t)}: ${e.message}`)}}),j=qe({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),oa.success(Ns.success.deleted(t))},onError:e=>{oa.error(`${Ns.error.delete(t)}: ${e.message}`)}}),w=o(e=>{const a={...Object.fromEntries(l)};Object.entries(e).forEach(([e,t])=>{""===t||0===t?delete a[e]:a[e]=String(t)}),d(a)},[l,d]),k=o(e=>{w({search:e,page:1})},[w]),S=o(e=>{w({sortField:e,sortDirection:u===e&&"asc"===f?"desc":"asc",page:1})},[u,f,w]),C=o(e=>{w({page:e})},[w]),T=o(e=>{w({limit:e,page:1})},[w]),E=o(()=>{d({})},[d]);return{entities:v.data?.data||[],pagination:{currentPage:v.data?.currentPage||1,totalPages:v.data?.totalPages||1,totalItems:v.data?.totalItems||0,itemsPerPage:v.data?.itemsPerPage||gs.pagination.defaultPageSize,hasNextPage:v.data?.hasNextPage||!1,hasPreviousPage:v.data?.hasPreviousPage||!1},isLoading:v.isLoading,isCreating:y.isPending,isUpdating:N.isPending,isDeleting:j.isPending,error:v.error,searchTerm:m,sortField:u,sortDirection:f,currentPage:p,itemsPerPage:h,createEntity:y.mutate,updateEntity:(e,a)=>N.mutate({id:e,data:a}),deleteEntity:j.mutate,handleSearch:k,handleSort:S,handlePageChange:C,handleItemsPerPageChange:T,clearFilters:E,refetch:v.refetch}}function yo({manager:e,config:a,formSections:t,onSave:r,FormComponent:n,TableComponent:o,onToggleStatus:i}){const{setSearchVisible:l,refreshData:d}=Ss();return s(()=>(l(!0),()=>{l(!1)}),[l]),ha.jsx(go,{manager:e,config:a,formSections:t,onSave:r,FormComponent:n,TableComponent:o,onToggleStatus:i})}function No({open:e,onCancel:a,onSubmit:t,editingEntity:s,isLoading:r=!1,title:n,editTitle:o,sections:i,transformData:l}){const{alias:d}=Ss();return ha.jsx(ho,{open:e,title:s?o:n,sections:i,initialData:s,onSubmit:e=>{if(l){const a=l(e,d||"");t(a)}else{const a={...e,alias:d||""};s?.id&&(a.id=s.id),t(a)}},onCancel:a,isLoading:r,submitButtonText:s?"Atualizar":"Salvar"})}const jo=({children:e})=>{const{isAuthenticated:t,isLoading:s}=Ss();if(s)return ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Carregando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!t){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Processando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):(a.useEffect(()=>{(async()=>{vs()?await js.loginDev():js.loginProd()})()},[]),ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Iniciando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:vs()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})}))}return ha.jsx(ha.Fragment,{children:e})},wo=()=>{const{processCallback:e}=Ss(),[a,r]=t(null),[n,o]=t(!1);s(()=>{(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 r("Falha na autenticação. Tente novamente.")}catch(e){console.error("❌ [CallbackPage] Erro no processamento:",e),r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const i=async()=>{o(!0),r(null);try{await e()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{o(!1)}},l=()=>{window.location.href="/"};return a?ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsxs(Ka,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[ha.jsx(w,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),ha.jsxs(Ga,{className:"space-y-4",children:[ha.jsx(Oa,{variant:"destructive",children:ha.jsx(za,{children:a})}),ha.jsx("div",{className:"text-sm text-muted-foreground",children:ha.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),ha.jsxs("div",{className:"flex gap-2",children:[ha.jsx(Na,{onClick:i,disabled:n,className:"flex-1",children:n?ha.jsxs(ha.Fragment,{children:[ha.jsx(Xs,{size:"sm",className:"mr-2"}),"Tentando..."]}):ha.jsxs(ha.Fragment,{children:[ha.jsx(Ee,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),ha.jsx(Na,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"flex justify-center mb-4",children:ha.jsx(Xs,{size:"lg"})}),ha.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})};class ko{static async extractTokenData(){const e=Gt.extractTokenData();return e||(ls.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,a){if(!e||0===e.length)return ls.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 ls.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 Yn.getUsers(s),o=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}});o.filter(e=>e.responsible_name&&!e.responsible_name.includes("ID não encontrado")&&!e.responsible_name.includes("Erro:")&&!e.responsible_name.includes("Token não encontrado")&&!e.responsible_name.includes("Configuração incompleta")).length;return o}catch(t){return ls.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 So=["responsible_name"];function Co(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,schemaName:o,entityName:i,enableQualiexEnrichment:l=!1}=s,d=()=>hs().schema(o).from(r);return{async getAll(e={}){const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:o=1,limit:c=25,...m}=e;let u=d().select("*",{count:"exact"});u=u.eq("is_removed",!1),Object.entries(m).forEach(([e,a])=>{null!=a&&""!==a&&(u=Array.isArray(a)?u.in(e,a):"object"==typeof a&&a&&"operator"in a&&"not_null"===a.operator?u.not(e,"is",null):u.eq(e,a))}),u=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(u,a),u=u.order(t,{ascending:"asc"===s}),u=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(u,o,c);const{data:f,error:p,count:h}=await u;if(p)throw new Error(`Error fetching ${r}: ${p.message}`);let x=((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}})(f||[],h,o,c);if(l&&i&&x.data.length>0){if(x.data.some(e=>e.id_user)){if(t&&(g=t,So.includes(g))){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},r=await this.getAll(a);if(!r?.data?.length)return r;const n=((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?o:-o}))(await ko.enrichWithResponsibleNames(r.data,{entityName:i}),t,s),l=((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}}})(n,o,c);return{data:l.data,currentPage:l.pagination.currentPage,totalPages:l.pagination.totalPages,totalItems:l.pagination.totalItems,itemsPerPage:l.pagination.itemsPerPage,hasNextPage:l.pagination.hasNextPage,hasPreviousPage:l.pagination.hasPreviousPage}}const a=await ko.enrichWithResponsibleNames(x.data,{entityName:i});x={...x,data:a}}}var g;return x},async getById(e){const{data:a,error:t}=await d().select("*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=ga(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={...ga(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}`)}}}function To(e){return{queryClient:e.queryClient||new He({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}export{xs as AUTH_CONFIG,mo as ActionMenuItems,Oa as Alert,za as AlertDescription,ja as AlertDialog,_a as AlertDialogAction,Aa as AlertDialogCancel,Ca as AlertDialogContent,Pa as AlertDialogDescription,Ea as AlertDialogFooter,Ta as AlertDialogHeader,Sa as AlertDialogOverlay,ka as AlertDialogPortal,Ra as AlertDialogTitle,wa as AlertDialogTrigger,Da as AlertTitle,Ln as AppHeader,Hn as AppLayout,qn as AppSidebar,ks as AuthProvider,js as AuthService,$a as Badge,yo as BaseCrudPage,La as Breadcrumb,qa as BreadcrumbEllipsis,Ua as BreadcrumbItem,Va as BreadcrumbLink,Ma as BreadcrumbList,Wa as BreadcrumbPage,Ba as BreadcrumbSeparator,Na as Button,gs as CRUD_CONFIG,wo as CallbackPage,Ha as Card,Ga as CardContent,Xa as CardDescription,Ya as CardFooter,Qa as CardHeader,ln as CardSkeleton,Ka as CardTitle,nt as ColorPicker,ot as Command,it as CommandDialog,ct as CommandEmpty,mt as CommandGroup,lt as CommandInput,ft as CommandItem,dt as CommandList,ut as CommandSeparator,pt as CommandShortcut,fo as CrudCards,ho as CrudForm,go as CrudPage,po as CrudTable,ht as DataList,gt as Dialog,yt as DialogClose,jt as DialogContent,Ct as DialogDescription,kt as DialogFooter,wt as DialogHeader,Nt as DialogOverlay,vt as DialogPortal,St as DialogTitle,bt as DialogTrigger,Tt as DropdownMenu,Ft as DropdownMenuCheckboxItem,Dt as DropdownMenuContent,Rt as DropdownMenuGroup,zt as DropdownMenuItem,Lt as DropdownMenuLabel,Pt as DropdownMenuPortal,At as DropdownMenuRadioGroup,$t as DropdownMenuRadioItem,Mt as DropdownMenuSeparator,Ut as DropdownMenuShortcut,_t as DropdownMenuSub,Ot as DropdownMenuSubContent,It as DropdownMenuSubTrigger,Et as DropdownMenuTrigger,Wt as EmptyState,Qn as ErrorBoundary,Cs as FeedbackDialog,bo as FilterBar,Ts as Form,Os as FormControl,Ds as FormDescription,Rs as FormField,As as FormItem,Is as FormLabel,zs as FormMessage,dn as FormSkeleton,No as GenericEntityForm,Ls as Grid,cn as HeaderSkeleton,Ws as IconPicker,Ja as Input,Bs as InputOTP,qs as InputOTPGroup,Qs as InputOTPSeparator,Hs as InputOTPSlot,et as Label,Gs as LoadingState,Ns as MESSAGES,On as NavigationProvider,Ys as PageBreadcrumb,Zs as Pagination,er as PaginationContent,nr as PaginationEllipsis,ar as PaginationItem,tr as PaginationLink,rr as PaginationNext,sr as PaginationPrevious,at as Popover,st as PopoverContent,tt as PopoverTrigger,jo as ProtectedRoute,ys as QUERY_KEYS,ko as QualiexEnrichmentService,eo as QualiexResponsibleSelectField,Zn as QualiexUserField,bs as SEARCH_CONFIG,Ms as ScrollArea,Us as ScrollBar,or as Select,ur as SelectContent,ir as SelectGroup,pr as SelectItem,fr as SelectLabel,mr as SelectScrollDownButton,cr as SelectScrollUpButton,hr as SelectSeparator,dr as SelectTrigger,lr as SelectValue,xr as Separator,gr as Sheet,vr as SheetClose,wr as SheetContent,Tr as SheetDescription,Sr as SheetFooter,kr as SheetHeader,Nr as SheetOverlay,yr as SheetPortal,Cr as SheetTitle,br as SheetTrigger,zr as Sidebar,Br as SidebarContent,Vr as SidebarFooter,qr as SidebarGroup,Qr as SidebarGroupAction,Kr as SidebarGroupContent,Hr as SidebarGroupLabel,Ur as SidebarHeader,Mr as SidebarInput,Lr as SidebarInset,Xr as SidebarMenu,Zr as SidebarMenuAction,en as SidebarMenuBadge,Jr as SidebarMenuButton,Gr as SidebarMenuItem,an as SidebarMenuSkeleton,tn as SidebarMenuSub,rn as SidebarMenuSubButton,sn as SidebarMenuSubItem,Dr as SidebarProvider,$r as SidebarRail,Wr as SidebarSeparator,mn as SidebarSkeleton,Fr as SidebarTrigger,nn as Skeleton,Xs as Spinner,hn as Stack,xn as Table,bn as TableBody,jn as TableCaption,Nn as TableCell,xo as TableFooter,yn as TableHead,gn as TableHeader,vn as TableRow,uo as TableRowActions,on as TableSkeleton,wn as Textarea,Tn as Toast,En as ToastAction,Rn as ToastClose,_n as ToastDescription,kn as ToastProvider,Pn as ToastTitle,Sn as ToastViewport,An as Toaster,Gt as TokenManager,Rr as Tooltip,_r as TooltipContent,Er as TooltipProvider,Pr as TooltipTrigger,Vn as assets,Fa as badgeVariants,ya as buttonVariants,xa as cn,Co as createService,va as debounce,ls as errorService,ba as formatDatetime,hs as getSupabaseClient,vs as isDevEnvironment,Wn as logoSrc,Yn as qualiexApi,To as setupQualiexCore,Bn as smallLogoSrc,rs as toast,ga as trimTextFields,Mn as useActiveModules,Ss as useAuth,Kn as useBaseForm,vo as useCrud,$n as useDebounce,Ps as useFormField,Dn as useNavigation,zn as usePageTitle,Jn as useQualiexUsers,Js as useRouteBreadcrumbs,Or as useSidebar,ns as useToast};
10
+ */function pa(){return ma||(ma=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"),d=Symbol.for("react.forward_ref"),c=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 v(e){return e.displayName||"Context"}function y(e){if(null==e)return null;if("number"==typeof e.tag&&g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case r:return"Fragment";case s:return"Portal";case i:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return v(e)+".Consumer";case o:return v(e._context)+".Provider";case d: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:y(e.type)||"Memo";case f:var t=e,p=t._payload,h=t._init;try{return y(h(p))}catch(e){return null}}return null}b=Symbol.for("react.module.reference");var N,j,w,k,S,C,T,E=Object.assign,R=0;function P(){}P.__reactDisabledLog=!0;var _,A=x.ReactCurrentDispatcher;function I(e,a,t){if(void 0===_)try{throw Error()}catch(e){var s=e.stack.trim().match(/\n( *(at )?)/);_=s&&s[1]||""}return"\n"+_+e}var O,D=!1,z="function"==typeof WeakMap?WeakMap:Map;function F(e,a){if(!e||D)return"";var t,s=O.get(e);if(void 0!==s)return s;D=!0;var r,n=Error.prepareStackTrace;Error.prepareStackTrace=void 0,r=A.current,A.current=null,function(){if(0===R){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})}R++}();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(e){t=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){t=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){t=e}e()}}catch(a){if(a&&t&&"string"==typeof a.stack){for(var o=a.stack.split("\n"),l=t.stack.split("\n"),d=o.length-1,c=l.length-1;d>=1&&c>=0&&o[d]!==l[c];)c--;for(;d>=1&&c>=0;d--,c--)if(o[d]!==l[c]){if(1!==d||1!==c)do{if(d--,--c<0||o[d]!==l[c]){var m="\n"+o[d].replace(" at new "," at ");return e.displayName&&m.includes("<anonymous>")&&(m=m.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,m),m}}while(d>=1&&c>=0);break}}}finally{D=!1,A.current=r,function(){if(0===--R){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},e,{value:N}),info:E({},e,{value:j}),warn:E({},e,{value:w}),error:E({},e,{value:k}),group:E({},e,{value:S}),groupCollapsed:E({},e,{value:C}),groupEnd:E({},e,{value:T})})}R<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?I(u):"";return"function"==typeof e&&O.set(e,f),f}function $(e,a,t){if(null==e)return"";if("function"==typeof e)return F(e,function(e){var a=e.prototype;return!(!a||!a.isReactComponent)}(e));if("string"==typeof e)return I(e);switch(e){case c:return I("Suspense");case m:return I("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return F(e.render,!1);case u:return $(e.type,a,t);case f:var s=e,r=s._payload,n=s._init;try{return $(n(r),a,t)}catch(e){}}return""}O=new z;var L=Object.prototype.hasOwnProperty,M={},U=x.ReactDebugCurrentFrame;function V(e){if(e){var a=e._owner,t=$(e.type,e._source,a?a.type:null);U.setExtraStackFrame(t)}else U.setExtraStackFrame(null)}var W=Array.isArray;function B(e){return W(e)}function q(e){return""+e}function H(e){if(function(e){try{return q(e),!1}catch(e){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,X=x.ReactCurrentOwner,G={key:!0,ref:!0,__self:!0,__source:!0};function Y(e,a,s,r,n){var i,o={},l=null,d=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)&&(d=a.ref,function(e){"string"==typeof e.ref&&X.current}(a)),a)L.call(a,i)&&!G.hasOwnProperty(i)&&(o[i]=a[i]);if(e&&e.defaultProps){var c=e.defaultProps;for(i in c)void 0===o[i]&&(o[i]=c[i])}if(l||d){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),d&&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,d,n,r,X.current,o)}var J,Z=x.ReactCurrentOwner,ee=x.ReactDebugCurrentFrame;function ae(e){if(e){var a=e._owner,t=$(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=y(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}J=!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 "+y(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(B(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!==d&&t.$$typeof!==u)return;a=t.propTypes}if(a){var s=y(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(e){o=e}!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&&!J){J=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y(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 de(e,a,s,h,x,v){var N=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===i||e===n||e===c||e===m||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===u||e.$$typeof===o||e.$$typeof===l||e.$$typeof===d||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":B(e)?w="array":void 0!==e&&e.$$typeof===t?(w="<"+(y(e.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,j)}var k=Y(e,a,s,x,v);if(null==k)return k;if(N){var S=a.children;if(void 0!==S)if(h)if(B(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=y(e),E=Object.keys(a).filter(function(e){return"key"!==e}),R=E.length>0?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}";if(!le[T+R])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} />',R,T,E.length>0?"{"+E.join(": ..., ")+": ...}":"{}",T),le[T+R]=!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 ce=function(e,a,t){return de(e,a,t,!1)},me=function(e,a,t){return de(e,a,t,!0)};fa.Fragment=r,fa.jsx=ce,fa.jsxs=me}()),fa}var ha=(ua||(ua=1,"production"===process.env.NODE_ENV?da.exports=function(){if(la)return ca;la=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={},d=null,c=null;for(o in void 0!==s&&(d=""+s),void 0!==a.key&&(d=""+a.key),void 0!==a.ref&&(c=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:d,ref:c,props:l,_owner:n.current}}return ca.Fragment=s,ca.jsx=o,ca.jsxs=o,ca}():da.exports=pa()),da.exports);function xa(...e){return u(m(e))}const ga=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(ga);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=ga(s);return a}return e},ba=e=>{if(!e)return"";const a=f(e);if(!p(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"})}`},va=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},ya=g("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","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"}}),Na=e.forwardRef(({className:e,variant:a,size:t,asChild:s=!1,...r},n)=>{const i=s?x:"button";return ha.jsx(i,{className:xa(ya({variant:a,size:t,className:e})),ref:n,...r})});Na.displayName="Button";const ja=c.Root,wa=c.Trigger,ka=c.Portal,Sa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Overlay,{className:xa("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}));Sa.displayName=c.Overlay.displayName;const Ca=e.forwardRef(({className:e,...a},t)=>ha.jsxs(ka,{children:[ha.jsx(Sa,{}),ha.jsx(c.Content,{ref:t,className:xa("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})]}));Ca.displayName=c.Content.displayName;const Ta=({className:e,...a})=>ha.jsx("div",{className:xa("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});Ta.displayName="AlertDialogHeader";const Ea=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Ea.displayName="AlertDialogFooter";const Ra=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Title,{ref:t,className:xa("text-lg font-semibold",e),...a}));Ra.displayName=c.Title.displayName;const Pa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Pa.displayName=c.Description.displayName;const _a=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Action,{ref:t,className:xa(ya(),e),...a}));_a.displayName=c.Action.displayName;const Aa=e.forwardRef(({className:e,...a},t)=>ha.jsx(c.Cancel,{ref:t,className:xa(ya({variant:"outline"}),"mt-2 sm:mt-0",e),...a}));Aa.displayName=c.Cancel.displayName;const Ia=g("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"}}),Oa=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx("div",{ref:s,role:"alert",className:xa(Ia({variant:a}),e),...t}));Oa.displayName="Alert";const Da=e.forwardRef(({className:e,...a},t)=>ha.jsx("h5",{ref:t,className:xa("mb-1 font-medium leading-none tracking-tight",e),...a}));Da.displayName="AlertTitle";const za=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("text-sm [&_p]:leading-relaxed",e),...a}));za.displayName="AlertDescription";const Fa=g("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"}}),$a=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx("div",{ref:s,className:xa(Fa({variant:a}),e),...t}));$a.displayName="Badge";const La=e.forwardRef(({...e},a)=>ha.jsx("nav",{ref:a,"aria-label":"breadcrumb",...e}));La.displayName="Breadcrumb";const Ma=e.forwardRef(({className:e,...a},t)=>ha.jsx("ol",{ref:t,className:xa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...a}));Ma.displayName="BreadcrumbList";const Ua=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,className:xa("inline-flex items-center gap-1.5",e),...a}));Ua.displayName="BreadcrumbItem";const Va=e.forwardRef(({asChild:a,className:t,...s},r)=>{const n=a?e.Fragment:"a";return ha.jsx(n,{ref:r,className:xa("transition-colors hover:text-foreground",t),...s})});Va.displayName="BreadcrumbLink";const Wa=e.forwardRef(({className:e,...a},t)=>ha.jsx("span",{ref:t,role:"link","aria-disabled":"true","aria-current":"page",className:xa("font-normal text-foreground",e),...a}));Wa.displayName="BreadcrumbPage";const Ba=({children:e,className:a,...t})=>ha.jsx("li",{role:"presentation","aria-hidden":"true",className:xa("[&>svg]:size-3.5",a),...t,children:e??ha.jsx(b,{})});Ba.displayName="BreadcrumbSeparator";const qa=({className:e,...a})=>ha.jsxs("span",{role:"presentation","aria-hidden":"true",className:xa("flex h-9 w-9 items-center justify-center",e),...a,children:[ha.jsx(v,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"More"})]});qa.displayName="BreadcrumbEllipsis";const Ha=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("rounded-lg border bg-card text-card-foreground shadow-sm",e),...a}));Ha.displayName="Card";const Qa=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex flex-col space-y-1.5 p-6",e),...a}));Qa.displayName="CardHeader";const Ka=e.forwardRef(({className:e,...a},t)=>ha.jsx("h3",{ref:t,className:xa("text-2xl font-semibold leading-none tracking-tight",e),...a}));Ka.displayName="CardTitle";const Xa=e.forwardRef(({className:e,...a},t)=>ha.jsx("p",{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Xa.displayName="CardDescription";const Ga=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("p-6 pt-0",e),...a}));Ga.displayName="CardContent";const Ya=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex items-center p-6 pt-0",e),...a}));Ya.displayName="CardFooter";const Ja=e.forwardRef(({className:e,type:a,...t},s)=>ha.jsx("input",{type:a,className:xa("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}));Ja.displayName="Input";const Za=g("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),et=e.forwardRef(({className:e,...a},t)=>ha.jsx(Le.Root,{ref:t,className:xa(Za(),e),...a}));et.displayName=Le.Root.displayName;const at=Me.Root,tt=Me.Trigger,st=e.forwardRef(({className:e,align:a="center",sideOffset:t=4,...s},r)=>ha.jsx(Me.Portal,{children:ha.jsx(Me.Content,{ref:r,align:a,sideOffset:t,className:xa("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})}));st.displayName=Me.Content.displayName;const rt=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],nt=({value:e="#3b82f6",onChange:a,label:t})=>ha.jsxs("div",{className:"space-y-2",children:[t&&ha.jsx(et,{children:t}),ha.jsxs(at,{children:[ha.jsx(tt,{asChild:!0,children:ha.jsxs(Na,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[ha.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),ha.jsx(st,{className:"w-64",children:ha.jsxs("div",{className:"space-y-3",children:[ha.jsxs("div",{children:[ha.jsx(et,{htmlFor:"color-input",children:"Cor personalizada"}),ha.jsx(Ja,{id:"color-input",type:"color",value:e,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),ha.jsxs("div",{children:[ha.jsx(et,{children:"Cores predefinidas"}),ha.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:rt.map(e=>ha.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))})]})]})})]})]}),it=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a}));it.displayName="Command";const ot=({children:e,...a})=>ha.jsx("div",{...a,children:ha.jsx(it,{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})}),lt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:ha.jsx("input",{ref:t,className:xa("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})}));lt.displayName="CommandInput";const dt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));dt.displayName="CommandList";const ct=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("py-6 text-center text-sm text-muted-foreground",e),...a}));ct.displayName="CommandEmpty";const mt=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("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}));mt.displayName="CommandGroup";const ut=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("-mx-1 h-px bg-border",e),...a}));ut.displayName="CommandSeparator";const ft=e.forwardRef(({className:e,disabled:a,onSelect:t,value:s,...r},n)=>ha.jsx("div",{ref:n,className:xa("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}));ft.displayName="CommandItem";const pt=({className:e,...a})=>ha.jsx("span",{className:xa("ml-auto text-xs tracking-widest text-muted-foreground",e),...a});pt.displayName="CommandShortcut";const ht={Root:function({children:e,className:a}){return ha.jsx("div",{className:xa("space-y-4",a),children:e})},Item:function({children:e,onClick:a,className:t}){return ha.jsx(Ha,{className:xa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",t),onClick:a,children:ha.jsx(Ga,{className:"p-4",children:e})})},Field:function({label:e,value:a,className:t}){return ha.jsxs("div",{className:xa("flex justify-between items-center text-sm",t),children:[ha.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),ha.jsx("span",{className:"text-foreground",children:a})]})}},xt=({open:e,onOpenChange:a,item:r,onConfirm:n,entityName:i="item",isDeleting:o=!1})=>{const[l,d]=t("");s(()=>{e||d("")},[e]);const c=()=>{d(""),a(!1)},m=l===r?.title;return r?ha.jsx(ja,{open:e,onOpenChange:c,children:ha.jsxs(Ca,{className:"sm:max-w-[500px]",children:[ha.jsx(Ta,{children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:ha.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),ha.jsx("div",{className:"flex-1",children:ha.jsx(Ra,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),ha.jsx(Pa,{asChild:!0,children:ha.jsxs("div",{className:"space-y-4",children:[ha.jsxs("div",{className:"text-sm text-muted-foreground",children:[ha.jsxs("p",{className:"mb-2",children:["Você está prestes a excluir permanentemente o ",i,":"]}),ha.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:ha.jsx("p",{className:"font-medium text-foreground",children:r.title})})]}),ha.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:ha.jsxs("div",{className:"flex items-start space-x-2",children:[ha.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:ha.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),ha.jsxs("div",{className:"text-sm text-orange-800",children:[ha.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),ha.jsxs("p",{children:["Esta ação não pode ser desfeita. O ",i," será removido permanentemente do sistema."]})]})]})}),ha.jsxs("div",{className:"space-y-2",children:[ha.jsxs(et,{htmlFor:"confirmation",className:"text-sm font-medium",children:["Para confirmar, digite ",ha.jsxs("strong",{children:['"',r.title,'"']})," abaixo:"]}),ha.jsx(Ja,{id:"confirmation",type:"text",value:l,onChange:e=>d(e.target.value),placeholder:`Digite: ${r.title}`,className:"w-full"})]})]})}),ha.jsxs(Ea,{children:[ha.jsx(Aa,{onClick:c,children:"Cancelar"}),ha.jsx(_a,{onClick:()=>{r&&l===r.title&&(n(r),d(""),a(!1))},disabled:!m||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${i}`})]})]})}):null},gt=Ue.Root,bt=Ue.Trigger,vt=Ue.Portal,yt=Ue.Close,Nt=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Overlay,{ref:t,className:xa("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}));Nt.displayName=Ue.Overlay.displayName;const jt=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(vt,{children:[ha.jsx(Nt,{}),ha.jsxs(Ue.Content,{ref:s,className:xa("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,ha.jsxs(Ue.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:[ha.jsx(y,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));jt.displayName=Ue.Content.displayName;const wt=({className:e,...a})=>ha.jsx("div",{className:xa("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});wt.displayName="DialogHeader";const kt=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});kt.displayName="DialogFooter";const St=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Title,{ref:t,className:xa("text-lg font-semibold leading-none tracking-tight",e),...a}));St.displayName=Ue.Title.displayName;const Ct=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Ct.displayName=Ue.Description.displayName;const Tt=Ve.Root,Et=Ve.Trigger,Rt=Ve.Group,Pt=Ve.Portal,_t=Ve.Sub,At=Ve.RadioGroup,It=e.forwardRef(({className:e,inset:a,children:t,...s},r)=>ha.jsxs(Ve.SubTrigger,{ref:r,className:xa("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,ha.jsx(b,{className:"ml-auto h-4 w-4"})]}));It.displayName=Ve.SubTrigger.displayName;const Ot=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ve.SubContent,{ref:t,className:xa("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}));Ot.displayName=Ve.SubContent.displayName;const Dt=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>ha.jsx(Ve.Portal,{children:ha.jsx(Ve.Content,{ref:s,sideOffset:a,className:xa("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})}));Dt.displayName=Ve.Content.displayName;const zt=e.forwardRef(({className:e,inset:a,...t},s)=>ha.jsx(Ve.Item,{ref:s,className:xa("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}));zt.displayName=Ve.Item.displayName;const Ft=e.forwardRef(({className:e,children:a,checked:t,...s},r)=>ha.jsxs(Ve.CheckboxItem,{ref:r,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(Ve.ItemIndicator,{children:ha.jsx(N,{className:"h-4 w-4"})})}),a]}));Ft.displayName=Ve.CheckboxItem.displayName;const $t=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(Ve.RadioItem,{ref:s,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(Ve.ItemIndicator,{children:ha.jsx(j,{className:"h-2 w-2 fill-current"})})}),a]}));$t.displayName=Ve.RadioItem.displayName;const Lt=e.forwardRef(({className:e,inset:a,...t},s)=>ha.jsx(Ve.Label,{ref:s,className:xa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",e),...t}));Lt.displayName=Ve.Label.displayName;const Mt=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ve.Separator,{ref:t,className:xa("-mx-1 my-1 h-px bg-muted",e),...a}));Mt.displayName=Ve.Separator.displayName;const Ut=({className:e,...a})=>ha.jsx("span",{className:xa("ml-auto text-xs tracking-widest opacity-60",e),...a});Ut.displayName="DropdownMenuShortcut";const Vt={default:S,search:k,error:w};function Wt({icon:e,title:a,description:t,action:s,className:r,variant:n="default"}){const i=e?()=>e:Vt[n];return ha.jsxs("div",{className:xa("flex flex-col items-center justify-center py-12 px-4 text-center",r),children:[ha.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:ha.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),ha.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),t&&ha.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:t}),s&&ha.jsx(Na,{onClick:s.onClick,variant:"outline",children:s.label})]})}const Bt="qualiex_access_token",qt="qualiex_id_token",Ht="supabase_token",Qt="oauth_state",Kt="oauth_nonce",Xt="selected_alias",Gt={setAccessToken:e=>localStorage.setItem(Bt,e),getAccessToken:()=>localStorage.getItem(Bt),setIdToken:e=>localStorage.setItem(qt,e),getIdToken:()=>localStorage.getItem(qt),setSupabaseToken:e=>localStorage.setItem(Ht,e),getSupabaseToken:()=>localStorage.getItem(Ht),setOAuthState:e=>sessionStorage.setItem(Qt,e),getOAuthState:()=>sessionStorage.getItem(Qt),clearOAuthState:()=>sessionStorage.removeItem(Qt),setOAuthNonce:e=>sessionStorage.setItem(Kt,e),getOAuthNonce:()=>sessionStorage.getItem(Kt),clearOAuthNonce:()=>sessionStorage.removeItem(Kt),setSelectedAlias:e=>localStorage.setItem(Xt,e),getSelectedAlias:()=>localStorage.getItem(Xt),clearSelectedAlias:()=>localStorage.removeItem(Xt),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Gt.getAccessToken()||!Gt.getIdToken()),clearAll:()=>{localStorage.removeItem(Bt),localStorage.removeItem(qt),localStorage.removeItem(Ht),localStorage.removeItem(Xt),sessionStorage.removeItem(Qt),sessionStorage.removeItem(Kt)},isTokenExpired:e=>{try{return 1e3*JSON.parse(atob(e.split(".")[1])).exp<Date.now()}catch{return!0}},isSupabaseTokenValid:()=>{const e=Gt.getSupabaseToken();return!!e&&!Gt.isTokenExpired(e)},getValidSupabaseToken:()=>{const e=Gt.getSupabaseToken();return!e||Gt.isTokenExpired(e)?null:e},extractTokenData:()=>{const e=Gt.getSupabaseToken();if(!e)return null;try{const a=JSON.parse(atob(e.split(".")[1])),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{return null}}};let Yt=0;const Jt=new Map,Zt=e=>{if(Jt.has(e))return;const a=setTimeout(()=>{Jt.delete(e),ss({type:"REMOVE_TOAST",toastId:e})},1e6);Jt.set(e,a)},es=(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?Zt(t):e.toasts.forEach(e=>{Zt(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)}}},as=[];let ts={toasts:[]};function ss(e){ts=es(ts,e),as.forEach(e=>{e(ts)})}function rs({...e}){const a=(Yt=(Yt+1)%Number.MAX_SAFE_INTEGER,Yt.toString()),t=()=>ss({type:"DISMISS_TOAST",toastId:a});return ss({type:"ADD_TOAST",toast:{...e,id:a,open:!0,onOpenChange:e=>{e||t()}}}),{id:a,dismiss:t,update:e=>ss({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function ns(){const[a,t]=e.useState(ts);return e.useEffect(()=>(as.push(t),()=>{const e=as.indexOf(t);e>-1&&as.splice(e,1)}),[a]),{...a,toast:rs,dismiss:e=>ss({type:"DISMISS_TOAST",toastId:e})}}var is=Object.defineProperty,os=(e,a,t)=>((e,a,t)=>a in e?is(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const ls=new class{constructor(){os(this,"errors",[]),os(this,"toastCount",0),os(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()&&rs({title:"Erro",description:t,variant:"destructive"})}success(e,a){rs({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 ds=Object.defineProperty,cs=(e,a,t)=>((e,a,t)=>a in e?ds(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const ms=import.meta.env.VITE_SUPABASE_URL,us=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,fs=class e{constructor(){cs(this,"client"),cs(this,"currentToken",null),cs(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:us};return e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`),Qe(ms,us,{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:a}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Gt.getSupabaseToken();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(e){return ls.handleError(e instanceof Error?e:"❌ Supabase - Error validating token",!1),!1}}};cs(fs,"instance");let ps=fs;const hs=()=>ps.getInstance().getClient(),xs={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"}},gs={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},bs={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},ys={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]};let Ns={enableUserEnrichment:!1,enableUsersApi:!1};const js=()=>Ns,ws=e=>{Ns={...Ns,...e}},ks={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}`}};class Ss{static async initialize(){try{if(!Gt.hasAllTokens())return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[]};const e=Gt.getAccessToken(),a=Gt.getIdToken(),t=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=Gt.getSelectedAlias(),i=n&&s.some(e=>e.alias===n)?n:r||s[0]?.alias||null;if(!Gt.isSupabaseTokenValid()&&i){const a=await this.generateSupabaseToken(e,i);a&&Gt.setSupabaseToken(a)}return{isAuthenticated:!0,isLoading:!1,user:t,alias:i,companies:s}}catch(e){return console.error("[Auth] Erro na inicialização:",e),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[]}}}static async loginDev(){try{const e=hs(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return console.error("[Auth] Erro na Edge Function dev-tokens:",t),!1;if(!a?.access_token||!a?.id_token)return console.error("[Auth] Tokens ausentes na resposta"),!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return console.error("[Auth] Erro no login dev:",e),!1}}static loginProd(){const e=Gt.generateOAuthState();Gt.setOAuthState(e);const a=Gt.generateOAuthNonce();Gt.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(xs.oauth.authUrl);s.searchParams.set("client_id",xs.oauth.clientId),s.searchParams.set("response_type",xs.oauth.responseType),s.searchParams.set("scope",xs.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(Gt.hasAllTokens()){if(!Gt.getValidSupabaseToken()){const e=Gt.getAccessToken(),a=this.extractAliasFromAccessToken(e),t=this.extractCompaniesFromIdToken(Gt.getIdToken())[0]?.alias,s=a||t;if(s){const a=await this.generateSupabaseToken(e,s);a&&Gt.setSupabaseToken(a)}}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");Gt.setAccessToken(s),Gt.setIdToken(r);const i=this.extractAliasFromAccessToken(s);if(i){const e=await this.generateSupabaseToken(s,i);if(!e)throw new Error("Falha ao gerar token Supabase");Gt.setSupabaseToken(e)}else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");const a=e[0].alias,t=await this.generateSupabaseToken(s,a);if(!t)throw new Error("Falha ao gerar token Supabase");Gt.setSupabaseToken(t)}return Gt.clearOAuthState(),Gt.clearOAuthNonce(),!0}catch(e){throw console.error("❌ [CallbackPage] Erro ao processar callback:",e),e}}static logout(){Gt.clearAll(),window.location.href="/"}static decodeToken(e){try{const a=e.split(".")[1],t=atob(a),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);const r=new TextDecoder("utf-8").decode(s);return JSON.parse(r)}catch{return null}}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({alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}static async generateSupabaseToken(e,a){try{const t=hs(),{data:s,error:r}=await t.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return r?(console.error("[Auth] Erro na Edge Function validate-token:",r),null):s?.access_token?s.access_token:(console.error("[Auth] Token Supabase ausente na resposta"),null)}catch(e){return console.error("[Auth] Erro ao gerar token Supabase:",e),null}}}const Cs=r(void 0),Ts=({children:e})=>{const[a,r]=t({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0}),n=We(),[l,d]=t(!1),[c,m]=t(0),u=i(e=>{r(a=>({...a,...e}))},[]),f=i(e=>{r(a=>({...a,isLoading:e}))},[]),p=i(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0})},[]),h=i(async e=>{try{f(!0);const a=Gt.getAccessToken();if(!a)return void console.error("[AuthContext] Access token não encontrado para trocar unidade");const t=await Ss.generateSupabaseToken(a,e.alias);if(!t)return void console.error("[AuthContext] Erro ao gerar token Supabase para nova unidade");Gt.setSupabaseToken(t),Gt.setSelectedAlias(e.alias),u({alias:e.alias}),await n.invalidateQueries()}catch(a){console.error("[AuthContext] Erro ao trocar unidade",a,e)}finally{f(!1)}},[u,n,f]),x=i(async()=>await Ss.processCallback(),[]),g=i(async()=>{Ss.logout(),p(),await n.clear()},[p,n]),b=i(e=>{d(e)},[]),v=i(()=>{m(e=>e+1)},[]),y=i(()=>{m(e=>e+1)},[]);s(()=>{(async()=>{try{await new Promise(e=>setTimeout(e,100));const e=await Ss.initialize();e&&e.isAuthenticated?u({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1}):f(!1)}catch(e){console.error("[AuthContext] Erro na inicialização da autenticação",e),f(!1)}})()},[u,f]);const N=o(()=>({...a,logout:g,processCallback:x,switchUnit:h,availableUnits:a.companies,isSearchVisible:l,setSearchVisible:b,clearSearch:v,refreshData:y}),[a,g,x,h,l,b,v,y]);return ha.jsx(Cs.Provider,{value:N,children:e})},Es=()=>{const e=n(Cs);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e},Rs=({variant:e="button",className:s="",children:r})=>{const[n,i]=t(!1),{user:o}=Es(),{companies:l,alias:d}=Es(),c=d?l?.find(e=>e.alias===d)||l?.[0]||null:l?.[0]||null,m=(()=>{if(!o?.email)return"";return`${`${import.meta.env.VITE_FEEDBACK_APP_URL}/`}?${new URLSearchParams({email:o.email,module:"OKR",alias:c?.alias||""}).toString()}`})();if(!o?.email||!c)return null;const u=a.forwardRef((a,t)=>"menuItem"===e?ha.jsxs("div",{ref:t,className:"flex items-center cursor-pointer w-full px-2 py-1.5 text-sm hover:bg-accent rounded-sm",...a,children:[ha.jsx(C,{className:"mr-2 h-4 w-4"}),"Feedback"]}):ha.jsxs(Na,{ref:t,variant:"default",size:"sm",className:`bg-primary hover:bg-primary/90 ${s}`,...a,children:[ha.jsx(C,{className:"mr-2 h-4 w-4"}),"Feedback"]}));return u.displayName="TriggerButton",ha.jsxs(gt,{open:n,onOpenChange:i,children:[ha.jsx(bt,{asChild:!0,children:ha.jsx(u,{})}),ha.jsxs(jt,{className:"max-w-4xl max-h-[90vh] w-full h-full p-0 overflow-hidden",children:[ha.jsxs(wt,{className:"sr-only",children:[ha.jsx(St,{children:"Feedback"}),ha.jsx(Ct,{children:"Formulário de feedback para melhorias no sistema"})]}),ha.jsx("div",{className:"w-full h-full",children:ha.jsx("iframe",{src:m,width:"100%",height:"600px",className:"feedback-iframe",title:"Formulário de Feedback",loading:"lazy"})})]})]})},Ps=Xe,_s=e.createContext({}),As=({...e})=>ha.jsx(_s.Provider,{value:{name:e.name},children:ha.jsx(Ge,{...e})}),Is=()=>{const a=e.useContext(_s),t=e.useContext(Os),{getFieldState:s,formState:r}=Ke(),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}},Os=e.createContext({}),Ds=e.forwardRef(({className:a,...t},s)=>{const r=e.useId();return ha.jsx(Os.Provider,{value:{id:r},children:ha.jsx("div",{ref:s,className:xa("space-y-2",a),...t})})});Ds.displayName="FormItem";const zs=e.forwardRef(({className:e,...a},t)=>{const{error:s,formItemId:r}=Is();return ha.jsx(et,{ref:t,className:xa(s&&"text-destructive",e),htmlFor:r,...a})});zs.displayName="FormLabel";const Fs=e.forwardRef(({...e},a)=>{const{error:t,formItemId:s,formDescriptionId:r,formMessageId:n}=Is();return ha.jsx(x,{ref:a,id:s,"aria-describedby":t?`${r} ${n}`:`${r}`,"aria-invalid":!!t,...e})});Fs.displayName="FormControl";const $s=e.forwardRef(({className:e,...a},t)=>{const{formDescriptionId:s}=Is();return ha.jsx("p",{ref:t,id:s,className:xa("text-sm text-muted-foreground",e),...a})});$s.displayName="FormDescription";const Ls=e.forwardRef(({className:e,children:a,...t},s)=>{const{error:r,formMessageId:n}=Is(),i=r?String(r?.message):a;return i?ha.jsx("p",{ref:s,id:n,className:xa("text-sm font-medium text-destructive",e),...t,children:i}):null});Ls.displayName="FormMessage";const Ms={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))]"},Us={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Vs({children:e,cols:a="auto-fit",gap:t="md",className:s}){return ha.jsx("div",{className:xa("grid",Ms[a],Us[t],s),children:e})}const Ws=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(Ye.Root,{ref:s,className:xa("relative overflow-hidden",e),...t,children:[ha.jsx(Ye.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),ha.jsx(Bs,{}),ha.jsx(Ye.Corner,{})]}));Ws.displayName=Ye.Root.displayName;const Bs=e.forwardRef(({className:e,orientation:a="vertical",...t},s)=>ha.jsx(Ye.ScrollAreaScrollbar,{ref:s,orientation:a,className:xa("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:ha.jsx(Ye.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Bs.displayName=Ye.ScrollAreaScrollbar.displayName;const qs={Star:ke,Heart:we,Home:je,User:Ne,Settings:ye,Mail:ve,Phone:be,Calendar:ge,MapPin:xe,Camera:he,Image:pe,Music:fe,Video:ue,Book:me,Bookmark:ce,Search:k,Filter:de,Edit:le,Trash2:oe,Plus:ie,Minus:ne,Check:N,X:y,ChevronDown:re,ChevronUp:se,ChevronLeft:te,ChevronRight:b,ArrowUp:ae,ArrowDown:ee,ArrowLeft:Z,ArrowRight:J,Clock:Y,Bell:G,AlertCircle:w,Info:X,HelpCircle:K,Download:Q,Upload:H,Share:q,Copy:B,Save:W,FileText:V,Folder:U,FolderOpen:M,Archive:L,Lock:$,Unlock:F,Eye:z,EyeOff:D,Shield:O,Key:I,Zap:A,Flame:_,Sparkles:P,Award:R,Trophy:E,Target:T},Hs=({value:e="Star",onChange:a,label:s})=>{const[r,n]=t(""),i=Object.entries(qs).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=qs[e]||ke;return ha.jsxs("div",{className:"space-y-2",children:[s&&ha.jsx(et,{children:s}),ha.jsxs(at,{children:[ha.jsx(tt,{asChild:!0,children:ha.jsxs(Na,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[ha.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),ha.jsx(st,{className:"w-80",children:ha.jsxs("div",{className:"space-y-3",children:[ha.jsxs("div",{children:[ha.jsx(et,{htmlFor:"icon-search",children:"Buscar ícone"}),ha.jsx(Ja,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>n(e.target.value)})]}),ha.jsx(Ws,{className:"h-48",children:ha.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([t,s])=>ha.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:ha.jsx(s,{className:"h-4 w-4"})},t))})})]})})]})]})},Qs=e.forwardRef(({className:e,containerClassName:a,...t},s)=>ha.jsx(Je,{ref:s,containerClassName:xa("flex items-center gap-2 has-[:disabled]:opacity-50",a),className:xa("disabled:cursor-not-allowed",e),...t}));Qs.displayName="InputOTP";const Ks=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,className:xa("flex items-center",e),...a}));Ks.displayName="InputOTPGroup";const Xs=e.forwardRef(({index:a,className:t,...s},r)=>{const n=e.useContext(Ze),{char:i,hasFakeCaret:o,isActive:l}=n.slots[a];return ha.jsxs("div",{ref:r,className:xa("relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",l&&"z-10 ring-2 ring-ring ring-offset-background",t),...s,children:[i,o&&ha.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:ha.jsx("div",{className:"h-4 w-px animate-caret-blink bg-foreground duration-1000"})})]})});Xs.displayName="InputOTPSlot";const Gs=e.forwardRef(({...e},a)=>ha.jsx("div",{ref:a,role:"separator",...e,children:ha.jsx(Se,{})}));Gs.displayName="InputOTPSeparator";const Ys={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Js({size:e="md",className:a}){return ha.jsx(Ce,{className:xa("animate-spin text-muted-foreground",Ys[e],a)})}function Zs({isLoading:e,children:a,className:t,type:s="spinner",size:r="md"}){return e?"overlay"===s?ha.jsxs("div",{className:xa("relative",t),children:[a,ha.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:ha.jsx(Js,{size:r})})]}):"skeleton"===s?ha.jsx("div",{className:xa("animate-pulse",t),children:ha.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):ha.jsx("div",{className:xa("flex items-center justify-center py-8",t),children:ha.jsx(Js,{size:r})}):ha.jsx(ha.Fragment,{children:a})}function er({items:e,maxItems:a=3,className:t}){const s=e.length>a?[e[0],...e.slice(-(a-1))]:e,r=e.length>a;return ha.jsx(La,{className:t,children:ha.jsx(Ma,{children:s.map((e,a)=>{const t=a===s.length-1,n=r&&1===a;return ha.jsxs("div",{className:"flex items-center",children:[n&&ha.jsxs(ha.Fragment,{children:[ha.jsx(Ua,{children:ha.jsx(qa,{})}),ha.jsx(Ba,{})]}),ha.jsx(Ua,{children:t||e.isCurrentPage?ha.jsx(Wa,{className:"font-bold text-lg",children:e.label}):ha.jsx(Va,{href:e.href,children:e.label})}),!t&&ha.jsx(Ba,{})]},`${e.label}-${a}`)})})})}function ar(){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 tr=({className:e,...a})=>ha.jsx("nav",{role:"navigation","aria-label":"pagination",className:xa("mx-auto flex w-full justify-center",e),...a});tr.displayName="Pagination";const sr=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,className:xa("flex flex-row items-center gap-1",e),...a}));sr.displayName="PaginationContent";const rr=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,className:xa("",e),...a}));rr.displayName="PaginationItem";const nr=({className:e,isActive:a,size:t="icon",...s})=>ha.jsx("a",{"aria-current":a?"page":void 0,className:xa(ya({variant:a?"outline":"ghost",size:t}),e),...s});nr.displayName="PaginationLink";const ir=({className:e,...a})=>ha.jsxs(nr,{"aria-label":"Go to previous page",size:"default",className:xa("gap-1 pl-2.5",e),...a,children:[ha.jsx(te,{className:"h-4 w-4"}),ha.jsx("span",{children:"Previous"})]});ir.displayName="PaginationPrevious";const or=({className:e,...a})=>ha.jsxs(nr,{"aria-label":"Go to next page",size:"default",className:xa("gap-1 pr-2.5",e),...a,children:[ha.jsx("span",{children:"Next"}),ha.jsx(b,{className:"h-4 w-4"})]});or.displayName="PaginationNext";const lr=({className:e,...a})=>ha.jsxs("span",{"aria-hidden":!0,className:xa("flex h-9 w-9 items-center justify-center",e),...a,children:[ha.jsx(v,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"More pages"})]});lr.displayName="PaginationEllipsis";const dr=sa.Root,cr=sa.Group,mr=sa.Value,ur=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(sa.Trigger,{ref:s,className:xa("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,ha.jsx(sa.Icon,{asChild:!0,children:ha.jsx(re,{className:"h-4 w-4 opacity-50"})})]}));ur.displayName=sa.Trigger.displayName;const fr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.ScrollUpButton,{ref:t,className:xa("flex cursor-default items-center justify-center py-1",e),...a,children:ha.jsx(se,{className:"h-4 w-4"})}));fr.displayName=sa.ScrollUpButton.displayName;const pr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.ScrollDownButton,{ref:t,className:xa("flex cursor-default items-center justify-center py-1",e),...a,children:ha.jsx(re,{className:"h-4 w-4"})}));pr.displayName=sa.ScrollDownButton.displayName;const hr=e.forwardRef(({className:e,children:a,position:t="popper",...s},r)=>ha.jsx(sa.Portal,{children:ha.jsxs(sa.Content,{ref:r,className:xa("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:[ha.jsx(fr,{}),ha.jsx(sa.Viewport,{className:xa("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),ha.jsx(pr,{})]})}));hr.displayName=sa.Content.displayName;const xr=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.Label,{ref:t,className:xa("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...a}));xr.displayName=sa.Label.displayName;const gr=e.forwardRef(({className:e,children:a,...t},s)=>ha.jsxs(sa.Item,{ref:s,className:xa("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:[ha.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ha.jsx(sa.ItemIndicator,{children:ha.jsx(N,{className:"h-4 w-4"})})}),ha.jsx(sa.ItemText,{children:a})]}));gr.displayName=sa.Item.displayName;const br=e.forwardRef(({className:e,...a},t)=>ha.jsx(sa.Separator,{ref:t,className:xa("-mx-1 my-1 h-px bg-muted",e),...a}));br.displayName=sa.Separator.displayName;const vr=e.forwardRef(({className:e,orientation:a="horizontal",decorative:t=!0,...s},r)=>ha.jsx(ra.Root,{ref:r,decorative:t,orientation:a,className:xa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...s}));vr.displayName=ra.Root.displayName;const yr=Ue.Root,Nr=Ue.Trigger,jr=Ue.Close,wr=Ue.Portal,kr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Overlay,{className:xa("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}));kr.displayName=Ue.Overlay.displayName;const Sr=g("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"}}),Cr=e.forwardRef(({side:e="right",className:a,children:t,...s},r)=>ha.jsxs(wr,{children:[ha.jsx(kr,{}),ha.jsxs(Ue.Content,{ref:r,className:xa(Sr({side:e}),a),...s,children:[t,ha.jsxs(Ue.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:[ha.jsx(y,{className:"h-4 w-4"}),ha.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Cr.displayName=Ue.Content.displayName;const Tr=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col space-y-2 text-center sm:text-left",e),...a});Tr.displayName="SheetHeader";const Er=({className:e,...a})=>ha.jsx("div",{className:xa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...a});Er.displayName="SheetFooter";const Rr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Title,{ref:t,className:xa("text-lg font-semibold text-foreground",e),...a}));Rr.displayName=Ue.Title.displayName;const Pr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ue.Description,{ref:t,className:xa("text-sm text-muted-foreground",e),...a}));Pr.displayName=Ue.Description.displayName;const _r=na.Provider,Ar=na.Root,Ir=na.Trigger,Or=e.forwardRef(({className:e,sideOffset:a=4,...t},s)=>ha.jsx(na.Content,{ref:s,sideOffset:a,className:xa("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}));Or.displayName=na.Content.displayName;const Dr="sidebar:state",zr=e.createContext(null);function Fr(){const a=e.useContext(zr);if(!a)throw new Error("useSidebar must be used within a SidebarProvider.");return a}const $r=e.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=e.useState(!1);e.useEffect(()=>{const e=()=>c(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(Dr);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(Dr,String(a))},[s,h]),g=e.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,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",v=e.useMemo(()=>({state:b,open:h,setOpen:x,isMobile:d,openMobile:m,setOpenMobile:u,toggleSidebar:g}),[b,h,x,d,m,u,g]);return ha.jsx(zr.Provider,{value:v,children:ha.jsx(_r,{delayDuration:0,children:ha.jsx("div",{className:xa("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":"3rem",...n},ref:l,...o,children:i})})})});$r.displayName="SidebarProvider";const Lr=e.forwardRef(({side:e="left",variant:a="sidebar",collapsible:t="offcanvas",className:s,children:r,...n},i)=>{const{isMobile:o,state:l,openMobile:d,setOpenMobile:c}=Fr();return"none"===t?ha.jsx("div",{className:xa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:i,...n,children:r}):o?ha.jsx(yr,{open:d,onOpenChange:c,...n,children:ha.jsxs(Cr,{"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:[ha.jsx(Rr,{className:"sr-only",children:"Menu de Navegação"}),ha.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):ha.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:[ha.jsx("div",{className:xa("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]")}),ha.jsx("div",{className:xa("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:ha.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:r})})]})});Lr.displayName="Sidebar";const Mr=e.forwardRef(({className:e,onClick:a,...t},s)=>{const{toggleSidebar:r}=Fr();return ha.jsxs(Na,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:xa("h-7 w-7",e),onClick:e=>{a?.(e),r()},...t,children:[ha.jsx(Te,{}),ha.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Mr.displayName="SidebarTrigger";const Ur=e.forwardRef(({className:e,...a},t)=>{const{toggleSidebar:s}=Fr();return ha.jsx("button",{ref:t,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:xa("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})});Ur.displayName="SidebarRail";const Vr=e.forwardRef(({className:e,...a},t)=>ha.jsx("main",{ref:t,className:xa("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}));Vr.displayName="SidebarInset";const Wr=e.forwardRef(({className:e,...a},t)=>ha.jsx(Ja,{ref:t,"data-sidebar":"input",className:xa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...a}));Wr.displayName="SidebarInput";const Br=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"header",className:xa("flex flex-col gap-2 p-2",e),...a}));Br.displayName="SidebarHeader";const qr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"footer",className:xa("flex flex-col gap-2 p-2",e),...a}));qr.displayName="SidebarFooter";const Hr=e.forwardRef(({className:e,...a},t)=>ha.jsx(vr,{ref:t,"data-sidebar":"separator",className:xa("mx-2 w-auto bg-sidebar-border",e),...a}));Hr.displayName="SidebarSeparator";const Qr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"content",className:xa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...a}));Qr.displayName="SidebarContent";const Kr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"group",className:xa("relative flex w-full min-w-0 flex-col p-2",e),...a}));Kr.displayName="SidebarGroup";const Xr=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?x:"div";return ha.jsx(r,{ref:s,"data-sidebar":"group-label",className:xa("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})});Xr.displayName="SidebarGroupLabel";const Gr=e.forwardRef(({className:e,asChild:a=!1,...t},s)=>{const r=a?x:"button";return ha.jsx(r,{ref:s,"data-sidebar":"group-action",className:xa("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})});Gr.displayName="SidebarGroupAction";const Yr=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"group-content",className:xa("w-full text-sm",e),...a}));Yr.displayName="SidebarGroupContent";const Jr=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,"data-sidebar":"menu",className:xa("flex w-full min-w-0 flex-col gap-1",e),...a}));Jr.displayName="SidebarMenu";const Zr=e.forwardRef(({className:e,...a},t)=>ha.jsx("li",{ref:t,"data-sidebar":"menu-item",className:xa("group/menu-item relative",e),...a}));Zr.displayName="SidebarMenuItem";const en=g("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",{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"}}),an=e.forwardRef(({asChild:e=!1,isActive:a=!1,variant:t="default",size:s="default",tooltip:r,className:n,...i},o)=>{const l=e?x:"button",{isMobile:d,state:c}=Fr(),m=ha.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":s,"data-active":a,className:xa(en({variant:t,size:s}),n),...i});return r?("string"==typeof r&&(r={children:r}),ha.jsxs(Ar,{children:[ha.jsx(Ir,{asChild:!0,children:m}),ha.jsx(Or,{side:"right",align:"center",hidden:"collapsed"!==c||d,...r})]})):m});an.displayName="SidebarMenuButton";const tn=e.forwardRef(({className:e,asChild:a=!1,showOnHover:t=!1,...s},r)=>{const n=a?x:"button";return ha.jsx(n,{ref:r,"data-sidebar":"menu-action",className:xa("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})});tn.displayName="SidebarMenuAction";const sn=e.forwardRef(({className:e,...a},t)=>ha.jsx("div",{ref:t,"data-sidebar":"menu-badge",className:xa("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}));sn.displayName="SidebarMenuBadge";const rn=e.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return ha.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:xa("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&ha.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),ha.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});rn.displayName="SidebarMenuSkeleton";const nn=e.forwardRef(({className:e,...a},t)=>ha.jsx("ul",{ref:t,"data-sidebar":"menu-sub",className:xa("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}));nn.displayName="SidebarMenuSub";const on=e.forwardRef(({...e},a)=>ha.jsx("li",{ref:a,...e}));on.displayName="SidebarMenuSubItem";const ln=e.forwardRef(({asChild:e=!1,size:a="md",isActive:t,className:s,...r},n)=>{const i=e?x:"a";return ha.jsx(i,{ref:n,"data-sidebar":"menu-sub-button","data-size":a,"data-active":t,className:xa("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})});function dn({className:e,...a}){return ha.jsx("div",{className:xa("animate-pulse rounded-md bg-muted",e),...a})}function cn({rows:e=5,columns:a=4}){return ha.jsx("div",{className:"w-full",children:ha.jsxs("div",{className:"rounded-md border",children:[ha.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:ha.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>ha.jsx(dn,{className:"h-4 w-24"},a))})}),ha.jsx("div",{children:Array.from({length:e}).map((e,t)=>ha.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:ha.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((e,a)=>ha.jsx(dn,{className:"h-4 w-20"},a))})},t))})]})})}function mn({count:e=3}){return ha.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,a)=>ha.jsxs(Ha,{children:[ha.jsxs(Qa,{children:[ha.jsx(dn,{className:"h-4 w-3/4"}),ha.jsx(dn,{className:"h-3 w-1/2"})]}),ha.jsx(Ga,{children:ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(dn,{className:"h-3 w-full"}),ha.jsx(dn,{className:"h-3 w-2/3"})]})})]},a))})}function un({fields:e=4}){return ha.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,a)=>ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(dn,{className:"h-4 w-24"}),ha.jsx(dn,{className:"h-10 w-full"})]},a)),ha.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[ha.jsx(dn,{className:"h-10 w-20"}),ha.jsx(dn,{className:"h-10 w-20"})]})]})}function fn(){return ha.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx(dn,{className:"h-8 w-8 rounded-full"}),ha.jsx(dn,{className:"h-6 w-32"})]}),ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx(dn,{className:"h-8 w-8"}),ha.jsx(dn,{className:"h-8 w-24"})]})]})}function pn(){return ha.jsx("div",{className:"w-64 border-r bg-muted/10",children:ha.jsxs("div",{className:"p-4",children:[ha.jsx(dn,{className:"h-8 w-32 mb-6"}),ha.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,a)=>ha.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[ha.jsx(dn,{className:"h-4 w-4"}),ha.jsx(dn,{className:"h-4 w-20"})]},a))})]})})}ln.displayName="SidebarMenuSubButton";const hn={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},xn={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},gn={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function bn({children:e,direction:a="column",gap:t="md",align:s="stretch",justify:r="start",wrap:n=!1,className:i}){return ha.jsx("div",{className:xa("flex","column"===a?"flex-col":"flex-row",hn[t],xn[s],gn[r],n&&"flex-wrap",i),children:e})}const vn=e.forwardRef(({className:e,...a},t)=>ha.jsx("table",{ref:t,className:xa("w-full caption-bottom text-sm",e),...a}));vn.displayName="Table";const yn=e.forwardRef(({className:e,...a},t)=>ha.jsx("thead",{ref:t,className:xa("[&_tr]:border-b sticky top-0 z-10 bg-background",e),...a}));yn.displayName="TableHeader";const Nn=e.forwardRef(({className:e,...a},t)=>ha.jsx("tbody",{ref:t,className:xa("[&_tr:last-child]:border-0",e),...a}));Nn.displayName="TableBody";e.forwardRef(({className:e,...a},t)=>ha.jsx("tfoot",{ref:t,className:xa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a})).displayName="TableFooter";const jn=e.forwardRef(({className:e,...a},t)=>ha.jsx("tr",{ref:t,className:xa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...a}));jn.displayName="TableRow";const wn=e.forwardRef(({className:e,...a},t)=>ha.jsx("th",{ref:t,className:xa("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}));wn.displayName="TableHead";const kn=e.forwardRef(({className:e,...a},t)=>ha.jsx("td",{ref:t,className:xa("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...a}));kn.displayName="TableCell";const Sn=e.forwardRef(({className:e,...a},t)=>ha.jsx("caption",{ref:t,className:xa("mt-4 text-sm text-muted-foreground",e),...a}));Sn.displayName="TableCaption";const Cn=e.forwardRef(({className:e,...a},t)=>ha.jsx("textarea",{className:xa("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}));Cn.displayName="Textarea";const Tn=oa.Provider,En=e.forwardRef(({className:e,...a},t)=>ha.jsx(oa.Viewport,{ref:t,className:xa("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}));En.displayName=oa.Viewport.displayName;const Rn=g("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"}}),Pn=e.forwardRef(({className:e,variant:a,...t},s)=>ha.jsx(oa.Root,{ref:s,className:xa(Rn({variant:a}),e),...t}));Pn.displayName=oa.Root.displayName;const _n=e.forwardRef(({className:e,...a},t)=>ha.jsx(oa.Action,{ref:t,className:xa("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}));_n.displayName=oa.Action.displayName;const An=e.forwardRef(({className:e,...a},t)=>ha.jsx(oa.Close,{ref:t,className:xa("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:ha.jsx(y,{className:"h-4 w-4"})}));An.displayName=oa.Close.displayName;const In=e.forwardRef(({className:e,...a},t)=>ha.jsx(oa.Title,{ref:t,className:xa("text-sm font-semibold",e),...a}));In.displayName=oa.Title.displayName;const On=e.forwardRef(({className:e,...a},t)=>ha.jsx(oa.Description,{ref:t,className:xa("text-sm opacity-90",e),...a}));function Dn(){const{toasts:e}=ns();return ha.jsxs(Tn,{children:[e.map(function({id:e,title:a,description:t,action:s,...r}){return ha.jsxs(Pn,{...r,children:[ha.jsxs("div",{className:"grid gap-1",children:[a&&ha.jsx(In,{children:a}),t&&ha.jsx(On,{children:t})]}),s,ha.jsx(An,{})]},e)}),ha.jsx(En,{})]})}On.displayName=oa.Description.displayName;const zn=r({});function Fn({children:e,config:a}){return ha.jsx(zn.Provider,{value:{navigation:a?.navigation},children:e})}function $n(){return n(zn)}function Ln(){const e=ea(),{navigation:a}=$n(),t=a?.find(a=>a.path===e.pathname);return t?.label||"Página"}const Mn=a.memo(({variant:e="card",className:t="",selectedUnit:s,onUnitChange:r})=>{const{user:n,companies:i,alias:o,isAuthenticated:l,logout:d,switchUnit:c}=Es(),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):c(e)},[r,c]),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=()=>ha.jsxs(ha.Fragment,{children:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx("div",{className:"flex-shrink-0",children:ha.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:ha.jsx(Ne,{className:"h-5 w-5 text-primary-foreground"})})}),ha.jsxs("div",{className:"flex-1 min-w-0",children:[ha.jsx("p",{className:"text-sm font-medium truncate",children:n.name}),ha.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&ha.jsx("div",{className:"mt-3",children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),ha.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),x.length>1&&ha.jsxs("div",{className:"mt-2",children:[ha.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",x.length]}),ha.jsxs("div",{className:"flex flex-wrap gap-1",children:[x.slice(0,3).map(e=>ha.jsx($a,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),x.length>3&&ha.jsxs($a,{variant:"outline",className:"text-xs",children:["+",x.length-3]})]})]})]});return"dropdown"===e?ha.jsxs(Tt,{children:[ha.jsx(Et,{asChild:!0,children:ha.jsx(Na,{variant:"ghost",className:`h-auto p-2 ${t}`,children:ha.jsxs("div",{className:"flex items-center space-x-2",children:[ha.jsxs("div",{className:"hidden md:block text-left",children:[ha.jsx("p",{className:"text-sm font-medium",children:n.name}),ha.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),ha.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:ha.jsx(Ne,{className:"h-4 w-4 text-primary-foreground"})}),ha.jsx(re,{className:"h-4 w-4"})]})})}),ha.jsxs(Dt,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[ha.jsxs(_t,{children:[ha.jsxs(It,{children:[ha.jsx(Ee,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),ha.jsx(Ot,{children:x.map(e=>ha.jsxs(zt,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[ha.jsx(Re,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&ha.jsx($a,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),ha.jsx(Mt,{}),ha.jsx(Rs,{variant:"menuItem"}),ha.jsxs(zt,{onClick:d,children:[ha.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):ha.jsxs(Ha,{className:t,children:[ha.jsx(Qa,{children:ha.jsx(Ka,{className:"text-lg",children:"Informações do Usuário"})}),ha.jsxs(Ga,{className:"space-y-4",children:[ha.jsx(g,{}),ha.jsx(vr,{}),ha.jsxs("div",{className:"flex space-x-2",children:[ha.jsx(Rs,{className:"flex-1"}),ha.jsxs(Na,{variant:"outline",onClick:d,size:"sm",className:"flex-1",children:[ha.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})});function Un(e,a){const[r,n]=t(e),o=l(),d=i(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return s(()=>(d(),o.current=setTimeout(()=>{n(e)},a),d),[e,a,d]),[r,d]}const Vn=({actions:e})=>{ea();const a=Ln(),{companies:r,alias:n,isSearchVisible:i,clearSearch:o,refreshData:l,switchUnit:d}=Es(),c=n?r?.find(e=>e.alias===n)||r?.[0]||null:r?.[0]||null,[m,u]=aa(),[f,p]=t(()=>m.get("search")||""),[h,x]=Un(f,bs.debounceDelay);s(()=>{if(!i)return;const e=new URLSearchParams(m);h?(e.set("search",h),e.set("page","1")):(e.delete("search"),e.delete("page")),u(e)},[h,u,i,m]);return ha.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:ha.jsxs("div",{className:"flex items-center justify-between gap-4",children:[ha.jsxs("div",{className:"flex items-center space-x-1 md:space-x-2 min-w-0",children:[ha.jsx(Mr,{className:"flex-shrink-0"}),ha.jsxs("div",{className:"min-w-0 flex flex-col md:flex-row md:items-center md:space-x-3 space-y-2 md:space-y-0",children:[ha.jsx("div",{className:"min-w-0",children:ha.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:a})}),i&&ha.jsxs("div",{className:"flex items-center space-x-1 w-full md:w-auto",children:[ha.jsxs("div",{className:"relative w-full md:w-48",children:[ha.jsx(k,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),ha.jsx(Ja,{placeholder:"Buscar...",value:f,onChange:e=>{return a=e.target.value,void p(a);var a},className:"w-full pl-10 pr-8"}),f&&ha.jsx(Na,{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:()=>{x(),p("");const e=new URLSearchParams(m);e.delete("search"),e.delete("page"),u(e)},title:"Limpar busca",children:ha.jsx(y,{size:14})})]}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:l,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:ha.jsx(Ee,{size:14})})]})]})]}),ha.jsxs("div",{className:"flex-shrink-0 flex items-center gap-3",children:[e&&ha.jsx("div",{className:"flex items-center gap-2",children:e}),ha.jsx("div",{className:"text-sm",children:ha.jsx(Mn,{variant:"dropdown",selectedUnit:c,onUnitChange:d})})]})]})})},Wn=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Es();return Be({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=hs(),{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)throw s;return a||[]},enabled:a&&!!t})},Bn=import.meta.env.VITE_SUPABASE_PROJECT_ID,qn={logo:`https://${Bn}.supabase.co/storage/v1/object/public/library-assets/logo.png`,smallLogo:`https://${Bn}.supabase.co/storage/v1/object/public/library-assets/small.png`},Hn=qn.logo,Qn=qn.smallLogo;function Kn({config:e}={}){const{state:a}=Fr(),s=ea(),[r,n]=t(!1),{data:i,isLoading:o,error:l}=Wn({enabled:r}),d=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 ha.jsxs(Lr,{collapsible:"icon",children:[ha.jsxs(Br,{className:"p-0 gap-0",children:[ha.jsxs(Tt,{onOpenChange:n,children:[ha.jsx(Et,{asChild:!0,children:ha.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary hover:opacity-90 text-primary-foreground font-semibold text-sm flex items-center justify-center cursor-pointer transition-all duration-200 h-8 gap-2 shadow-lg rounded-b-2xl",children:["collapsed"!==a&&e?.appName,ha.jsx(re,{size:16})]})}),ha.jsx(Dt,{className:"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50",align:"collapsed"===a?"center":"start",children:o?ha.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[ha.jsx(Ce,{className:"h-4 w-4 animate-spin"}),ha.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):l?ha.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[ha.jsx(w,{className:"h-4 w-4"}),ha.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):i&&0!==i.length?ha.jsx("div",{className:"space-y-2",children:i.map((e,a)=>ha.jsx("div",{onClick:()=>(e=>{const a=i?.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 ${d(a)} transition-colors duration-200\n `,children:ha.jsxs("div",{className:"flex items-center justify-between",children:[ha.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&ha.jsx(_e,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):ha.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]}),ha.jsx("div",{className:"flex justify-center items-center h-20",children:ha.jsx("img",{src:"collapsed"===a?qn.smallLogo:qn.logo,alt:"Logo",className:"collapsed"===a?"h-8 w-8":"h-14 max-w-full"})})]}),ha.jsx(Qr,{children:ha.jsx(Kr,{children:ha.jsx(Yr,{children:ha.jsx(Jr,{children:e?.navigation?.map(e=>{return ha.jsx(Zr,{children:ha.jsx(an,{asChild:!0,isActive:(a=e.path,s.pathname===a),children:ha.jsxs(ta,{to:e.path,children:[ha.jsx(e.icon,{}),ha.jsx("span",{children:e.label})]})})},e.path);var a})})})})})]})}function Xn({children:e,sidebar:a,sidebarConfig:t,showHeader:s=!0}){const r=a||ha.jsx(Kn,{config:t});return ha.jsx(Fn,{config:t,children:ha.jsx($r,{children:ha.jsxs("div",{className:"min-h-screen flex w-full h-screen overflow-hidden",children:[r,ha.jsxs("main",{className:"flex-1 flex flex-col h-full overflow-hidden",children:[s&&ha.jsx("div",{className:"flex-shrink-0",children:ha.jsx(Vn,{})}),ha.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e})]})]})})})}class Gn extends d{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,a){ls.handleError(e,!1),console.error("ErrorBoundary caught an error:",e,a)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ha.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsxs(Qa,{className:"text-center",children:[ha.jsx("div",{className:"flex justify-center mb-4",children:ha.jsx(Ae,{className:"h-12 w-12 text-destructive"})}),ha.jsx(Ka,{children:"Algo deu errado"})]}),ha.jsxs(Ga,{className:"text-center space-y-4",children:[ha.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),ha.jsx(Na,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function Yn(e,a,r,n){const[i,l]=t({}),[d,c]=t({}),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(a){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 s;if("function"==typeof e.validation?s=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(s=e.validation.custom),s)try{const e=s(a,t);if(e)return e}catch(e){}}};s(()=>{if(!n)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},t=e(m),s={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);u(e)&&(t=e.toISOString().split("T")[0])}else u(t)&&(t=t.toISOString().split("T")[0])}else t=f(e);s[e.name]=t}),t.forEach(e=>{const a=p(e,s);void 0!==a&&(s[e.name]=a)}),l(s),c({}),r&&r(s)},[m,a,r,n]);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,i[e.name],i);t&&(a[e.name]=t)}),c(a),0===Object.keys(a).length};return{formData:i,errors:d,updateField:(e,a)=>{l(t=>{const s={...t,[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,s);return r&&r(n),n}),d[e]&&c(a=>{const t={...a};return delete t[e],t});const t=x(m).find(a=>a.name===e);if(t){const s=h(t,a,i);s&&c(a=>({...a,[e]:s}))}},validateForm:g,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),g()&&e(i)}}}var Jn=Object.defineProperty,Zn=(e,a,t)=>((e,a,t)=>a in e?Jn(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ei=new class{constructor(){Zn(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=Gt.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 ls.handleError("[QualiexApi] Unexpected response format",!1),[];s=t}if(!Array.isArray(s))return ls.handleError("[QualiexApi] Response is not an array",!1),[];return s.map(this.mapToQualiexUser)}catch(e){return ls.handleError(e instanceof Error?e:"[QualiexApi] Error fetching users"),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(e){return ls.handleError(e instanceof Error?e:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const a=Gt.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):(ls.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}},ai=(e={})=>{const{user:a,alias:t}=Es(),s=js(),{enabled:r=s.enableUsersApi}=e;return Be({queryKey:["qualiex-users",t],queryFn:()=>ei.getUsers(t),enabled:r&&!!t&&!!a,retry:2,retryDelay:1e3})},ti=({value:e="",onChange:a,placeholder:t="Selecionar usuário",disabled:s,className:r,enabled:n})=>{const{data:i=[],isLoading:o,error:l}=ai({enabled:n});return o?ha.jsx(dn,{className:xa("h-10 w-full",r)}):l?ha.jsxs("div",{className:`flex items-center gap-2 p-2 border border-destructive/20 rounded-md ${r}`,children:[ha.jsx(w,{className:"h-4 w-4 text-destructive"}),ha.jsx("span",{className:"text-sm text-destructive",children:"Erro ao carregar usuários"})]}):ha.jsxs(dr,{value:e,onValueChange:a,disabled:s||0===i.length,children:[ha.jsx(ur,{className:r,children:ha.jsx(mr,{placeholder:t})}),ha.jsx(hr,{children:0===i.length?ha.jsx(gr,{value:"no-users",disabled:!0,children:"Nenhum usuário encontrado"}):i.map(e=>ha.jsx(gr,{value:e.userId,children:e.userName},e.userId))})]})},si=({value:e,onChange:a,placeholder:t="Selecionar responsável",disabled:s,className:r})=>ha.jsxs(dr,{value:e,onValueChange:a,disabled:s,children:[ha.jsx(ur,{className:r,children:ha.jsx(mr,{placeholder:t})}),ha.jsx(hr,{children:ha.jsx(gr,{value:"placeholder",children:"Responsável placeholder"})})]});function ri({title:e,sections:s,initialData:r,onSubmit:n,onCancel:l,open:d,submitButtonText:c="Salvar",isLoading:m=!1,usersData:u}){const[f,p]=t(s?.[0]?.id||""),h=o(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:x,errors:g,updateField:b,handleSubmit:v}=Yn(h,r,void 0,d),y=o(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(x):e.disabled||!1})):[],[s,x]),N=o(()=>{const e=y.find(e=>e.id===f);if(e&&!e.disabled)return f;const a=y.find(e=>!e.disabled);return a?.id||f},[y,f]);a.useEffect(()=>{N!==f&&p(N)},[N,f]);const j=y.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 ha.jsxs("div",{className:"space-y-2",children:[e.label,ha.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 ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(ti,{value:t||"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"textarea":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Cn,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"select":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsxs(dr,{value:String(t),onValueChange:a=>{b(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[ha.jsx(ur,{className:`${s?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:ha.jsx(mr,{placeholder:e.placeholder})}),ha.jsx(hr,{children:e.options?.map(e=>ha.jsx(gr,{value:e.value,children:e.label},e.value))})]}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"date":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{id:e.name,type:"date",value:String(t),onChange:a=>b(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:xa("w-full",s?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"single-responsible-select":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(si,{value:String(t),onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":""}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"simple-qualiex-user-field":const a=js();return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(ti,{value:t??"",onChange:a=>b(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:s?"border-red-500":"",enabled:a.enableUsersApi}),s&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);case"color":return ha.jsxs("div",{children:[ha.jsxs(et,{htmlFor:e.name,children:[e.label," ",e.required&&ha.jsx("span",{className:"text-destructive",children:"*"})]}),ha.jsx(Ja,{id:e.name,type:"color",value:t||e.defaultValue||"#000000",onChange:a=>b(e.name,a.target.value),className:"h-10"}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"color-picker":return ha.jsxs("div",{children:[ha.jsx(nt,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"#3b82f6",onChange:a=>b(e.name,a)}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"icon-picker":return ha.jsxs("div",{children:[ha.jsx(Hs,{label:`${e.label} ${e.required?"*":""}`,value:t||e.defaultValue||"Star",onChange:a=>b(e.name,a)}),s&&ha.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},e.name);case"number":return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name);default:return ha.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[ha.jsx(et,{htmlFor:e.name,children:e.label}),ha.jsx(Ja,{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&&ha.jsx("p",{className:"text-sm text-red-500",children:s})]},e.name)}},k=i(()=>{if(!j)return null;if(j.disabled)return ha.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[ha.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:ha.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ha.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),ha.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),ha.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 ha.jsx(e,{formData:x,updateField:b,errors:g,users:u,disabled:j.disabled})}return ha.jsx("div",{className:"space-y-3",children:j.fields.map(w)})},[j,x,b,g,u,w]),S=ha.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&ha.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:ha.jsx("div",{className:"flex space-x-2",children:y.map(e=>ha.jsx(Na,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=y.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))})}),ha.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:m?ha.jsx("div",{className:"flex items-center justify-center py-12",children:ha.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):ha.jsxs("form",{onSubmit:v(n),className:"space-y-3 md:space-y-4",children:[k(),ha.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[ha.jsx(Na,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),ha.jsx(Na,{type:"submit",disabled:m,children:c})]})]})})]});return ha.jsx(gt,{open:d,onOpenChange:e=>{!1===e&&!0===d&&l()},children:ha.jsxs(jt,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[ha.jsxs(wt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[ha.jsx(St,{className:"text-white",children:e}),ha.jsx(Ct,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function ni(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function ii(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 oi(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 d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}const li={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"}},di={date:ni({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:ni({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ni({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ci={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"};var mi;const ui={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=li[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:di,formatRelative:(e,a,t,s)=>{const r=ci[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:ii({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:ii({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:ii({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:ii({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:ii({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"})},match:{ordinalNumber:(mi={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,a={})=>{const t=e.match(mi.matchPattern);if(!t)return null;const s=t[0],r=e.match(mi.parsePattern);if(!r)return null;let n=mi.valueCallback?mi.valueCallback(r[0]):r[0];return n=a.valueCallback?a.valueCallback(n):n,{value:n,rest:e.slice(s.length)}}),era:oi({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:oi({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:oi({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:oi({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:oi({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},fi=({onEdit:e,onDelete:a,onToggleStatus:t,isActive:s=!0,canDelete:r=!0,renderAs:n})=>{const i=[];if(e){const a={icon:le,label:"Editar",onClick:e};i.push(a)}if(t){const e={icon:s?Ie:Oe,label:s?"Inativar":"Ativar",onClick:t};i.push(e)}if(r&&a){const e={icon:oe,label:"Remover",onClick:a,destructive:!0};i.push(e)}return"dropdown"===n?ha.jsx(ha.Fragment,{children:i.map((e,a)=>ha.jsxs(zt,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[ha.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},a))}):ha.jsx(ha.Fragment,{children:i.map((e,a)=>ha.jsxs(Na,{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:[ha.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},a))})},pi=({onEdit:e,onDelete:a,canDelete:t=!0,onToggleStatus:s,isActive:r=!0})=>ha.jsxs(Tt,{children:[ha.jsx(Et,{asChild:!0,children:ha.jsx(Na,{variant:"default",size:"sm",className:"h-7 px-2 text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:ha.jsx(De,{size:12})})}),ha.jsx(Dt,{align:"end",children:ha.jsx(fi,{onEdit:a=>{a?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),a?.()},onToggleStatus:e=>{e?.stopPropagation(),s?.()},isActive:r,canDelete:t,renderAs:"dropdown"})})]});function hi({manager:e,config:a,onEdit:t,onDelete:s}){return e.isLoading?ha.jsx(Vs,{children:Array.from({length:3}).map((e,a)=>ha.jsxs(Ha,{children:[ha.jsxs(Qa,{children:[ha.jsx(dn,{className:"h-4 w-3/4"}),ha.jsx(dn,{className:"h-3 w-1/2"})]}),ha.jsx(Ga,{children:ha.jsxs("div",{className:"space-y-2",children:[ha.jsx(dn,{className:"h-3 w-full"}),ha.jsx(dn,{className:"h-3 w-2/3"})]})})]},a))}):ha.jsx(ht.Root,{children:e.entities.map(e=>ha.jsxs(ht.Item,{onClick:()=>t(e),children:[ha.jsx(Qa,{className:"pb-3",children:ha.jsxs("div",{className:"flex items-start justify-between",children:[ha.jsxs("div",{className:"flex-1 min-w-0",children:[ha.jsx(Ka,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),ha.jsx(Xa,{className:"text-sm",children:h(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:ui})})]}),ha.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&ha.jsx(Na,{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),ia.info("Link copiado para a área de transferência"))}catch(a){window.location.href=e}})(e.link)},title:"Abrir link externo",children:ha.jsx(_e,{className:"h-4 w-4"})}),ha.jsx("div",{onClick:e=>e.stopPropagation(),children:ha.jsx(pi,{onEdit:()=>t(e),onDelete:s?()=>s(e):void 0,canDelete:!!s})})]})]})}),ha.jsx(Ga,{className:"pt-0",children:ha.jsx("div",{className:"space-y-2",children:a.cardFields?.map(a=>{const t=e[a.key];return t?ha.jsx(ht.Field,{label:a.label,value:a.render?a.render(t,e):String(t)},String(a.key)):null})})})]},e.id))})}const xi=({manager:e,columns:a,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l})=>{const[d,c]=t(!1),[m,u]=t(null);s(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),s(()=>{const e=()=>u(null);if(m)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[m]);const f=(()=>{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?ha.jsx(mn,{count:3}):0===e.entities.length?ha.jsx(Wt,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):ha.jsxs("div",{className:"space-y-4",children:[e.entities.map(e=>ha.jsx(Ha,{className:"overflow-hidden cursor-pointer hover:bg-muted/50",onClick:a=>{a.stopPropagation(),r?.(e)},onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),u({x:a.clientX,y:a.clientY,item:e})},children:ha.jsxs(Ga,{className:"p-4",children:[a.map(a=>ha.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[ha.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),ha.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(e):e[a.key]})]},a.key)),(r||n||l)&&ha.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(e):ha.jsx(pi,{onEdit:r?()=>{r(e)}:void 0,onDelete:o?()=>o(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived})})]})},e.id)),m&&ha.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:ha.jsx(fi,{onEdit:r?()=>{r(m.item),u(null)}:void 0,onDelete:o?()=>{o(m.item),u(null)}:void 0,onToggleStatus:i?()=>{i(m.item),u(null)}:void 0,isActive:m.item.is_actived,canDelete:!!o,renderAs:"context"})})]}):ha.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?ha.jsx(cn,{rows:5,columns:a.length}):ha.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:ha.jsx("div",{className:"flex-1 overflow-auto",children:ha.jsxs(vn,{className:"table-fixed",children:[ha.jsxs("colgroup",{children:[f.map((e,a)=>ha.jsx("col",{style:e.style},a)),ha.jsx("col",{style:{width:"100px"}})]}),ha.jsx(yn,{children:ha.jsxs(jn,{children:[a.map(a=>{return ha.jsx(wn,{className:`${a.className||""} ${a.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:a.sortable?()=>e.handleSort(a.key):void 0,children:ha.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(t=a.key,e.sortField!==t?ha.jsx(ze,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?ha.jsx(ae,{size:14,className:"ml-1"}):ha.jsx(ee,{size:14,className:"ml-1"}))]})},a.key);var t}),ha.jsx(wn,{className:"w-[100px] text-center",children:"Ações"})]})}),ha.jsx(Nn,{children:0===e.entities.length?ha.jsx(jn,{children:ha.jsx(kn,{colSpan:a.length+1,className:"h-32",children:ha.jsx(Wt,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(e=>ha.jsxs(jn,{className:"cursor-pointer hover:bg-muted/50",onClick:a=>{a.stopPropagation(),r?.(e)},onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),u({x:a.clientX,y:a.clientY,item:e})},children:[a.map(a=>ha.jsx(kn,{className:a.className,children:a.render?a.render(e):e[a.key]},a.key)),ha.jsx(kn,{className:"text-center",children:l?l(e):ha.jsx(pi,{onEdit:r?()=>r(e):void 0,onDelete:o?()=>o(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived})})]},e.id))})]})})}),m&&ha.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:m.x,top:m.y},onClick:e=>e.stopPropagation(),children:ha.jsx(fi,{onEdit:r?()=>{r(m.item),u(null)}:void 0,onDelete:o?()=>{o(m.item),u(null)}:void 0,onToggleStatus:i?()=>{i(m.item),u(null)}:void 0,isActive:m.item.is_actived,canDelete:!!o,renderAs:"context"})})]})};function gi({open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:i=!1,submitButtonText:o="Salvar"}){return ha.jsx(ri,{open:e,title:a,sections:t,initialData:s,onSubmit:r,onCancel:n,isLoading:i,submitButtonText:o})}const bi=({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,d=Math.min(t*s,i);return ha.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:[ha.jsxs("div",{className:"flex items-center space-x-3",children:[ha.jsx("span",{children:"Itens por página"}),ha.jsxs(dr,{value:s.toString(),onValueChange:e=>n(Number(e)),children:[ha.jsx(ur,{className:"w-20 h-8 border-border",children:ha.jsx(mr,{})}),ha.jsxs(hr,{children:[ha.jsx(gr,{value:"10",children:"10"}),ha.jsx(gr,{value:"25",children:"25"}),ha.jsx(gr,{value:"50",children:"50"}),ha.jsx(gr,{value:"100",children:"100"})]})]})]}),ha.jsx("div",{className:"flex-1 flex justify-center",children:ha.jsx("span",{children:i>0?`${l}-${d} de ${i} itens (página ${t} de ${o})`:"0 itens"})}),ha.jsxs("div",{className:"flex items-center space-x-1",children:[ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(1),disabled:1===t,children:ha.jsx(Fe,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(Math.max(1,t-1)),disabled:1===t,children:ha.jsx(te,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(Math.min(o,t+1)),disabled:t===o,children:ha.jsx(b,{className:"h-4 w-4"})}),ha.jsx(Na,{variant:"outline",size:"sm",onClick:()=>r(o),disabled:t===o,children:ha.jsx($e,{className:"h-4 w-4"})})]})]})};function vi({manager:e,config:a,formSections:s,onSave:r,FormComponent:n,TableComponent:i,onToggleStatus:o}){const[l,d]=t(!1),[c,m]=t(null),[u,f]=t({isOpen:!1,entityId:null,entityName:""}),p=e=>{m(e),d(!0)},h=()=>{d(!1),m(null)},x=e=>{r(e),d(!1),m(null)},g=e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})};return ha.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[ha.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b",children:ha.jsx("div",{className:"flex items-center gap-4",children:ha.jsxs(Na,{onClick:()=>{m(null),d(!0)},className:"flex items-center gap-2",children:[ha.jsx(ie,{size:16}),"Novo"]})})}),ha.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:i?ha.jsx(i,{manager:e,onEdit:p,onDelete:g,onToggleStatus:o}):ha.jsx(xi,{manager:e,columns:a.columns,onEdit:p,onDelete:g,onToggleStatus:o})}),ha.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:ha.jsx(bi,{manager:e})}),n?ha.jsx(n,{open:l,onCancel:h,onSubmit:x,editingEntity:c,isLoading:e.isLoading}):ha.jsx(gi,{open:l,title:c?`Editar ${a.entityName}`:`Novo ${a.entityName}`,sections:s,initialData:c||void 0,onSubmit:x,onCancel:h,isLoading:e.isLoading,submitButtonText:c?"Atualizar":"Criar"}),ha.jsx(xt,{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})]})}function yi({manager:e,filters:a}){const{isSearchVisible:t}=Es(),s=e.searchTerm;return ha.jsx(bn,{direction:"column",gap:"md",className:"mb-6",children:ha.jsxs(bn,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:[a.some(e=>"search"===e.type)&&!t&&ha.jsxs("div",{className:"relative flex-1",children:[ha.jsx(k,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),ha.jsx(Ja,{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 t=e.component;return ha.jsx("div",{className:"w-full sm:w-auto",children:ha.jsx(t,{...e.props})},a)}),s&&ha.jsxs(Na,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[ha.jsx(y,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]})})}function Ni({queryKey:e,service:a,entityName:t,searchFields:s,additionalFilters:r={},onSuccess:n}){const[l,d]=aa(),c=We(),m=l.get("search")||"",u=l.get("sortField")||gs.sorting.defaultField,f=l.get("sortDirection")||gs.sorting.defaultDirection,p=parseInt(l.get("page")||"1"),h=parseInt(l.get("limit")||String(gs.pagination.defaultPageSize)),x=m,g=o(()=>({search:x,sortField:u,sortDirection:f,page:p,limit:h,...r}),[x,u,f,p,h,r]),b=i(()=>a.getAll(g),[a,g]),v=Be({queryKey:[e,g],queryFn:b}),y=qe({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),ia.success(ks.success.created(t)),n?.()},onError:e=>{ia.error(`${ks.error.create(t)}: ${e.message}`)}}),N=qe({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),ia.success(ks.success.updated(t)),n?.()},onError:e=>{ia.error(`${ks.error.update(t)}: ${e.message}`)}}),j=qe({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),ia.success(ks.success.deleted(t))},onError:e=>{ia.error(`${ks.error.delete(t)}: ${e.message}`)}}),w=i(e=>{const a={...Object.fromEntries(l)};Object.entries(e).forEach(([e,t])=>{""===t||0===t?delete a[e]:a[e]=String(t)}),d(a)},[l,d]),k=i(e=>{w({search:e,page:1})},[w]),S=i(e=>{w({sortField:e,sortDirection:u===e&&"asc"===f?"desc":"asc",page:1})},[u,f,w]),C=i(e=>{w({page:e})},[w]),T=i(e=>{w({limit:e,page:1})},[w]),E=i(()=>{d({})},[d]);return{entities:v.data?.data||[],pagination:{currentPage:v.data?.currentPage||1,totalPages:v.data?.totalPages||1,totalItems:v.data?.totalItems||0,itemsPerPage:v.data?.itemsPerPage||gs.pagination.defaultPageSize,hasNextPage:v.data?.hasNextPage||!1,hasPreviousPage:v.data?.hasPreviousPage||!1},isLoading:v.isLoading,isCreating:y.isPending,isUpdating:N.isPending,isDeleting:j.isPending,error:v.error,searchTerm:m,sortField:u,sortDirection:f,currentPage:p,itemsPerPage:h,createEntity:y.mutate,updateEntity:(e,a)=>N.mutate({id:e,data:a}),deleteEntity:j.mutate,handleSearch:k,handleSort:S,handlePageChange:C,handleItemsPerPageChange:T,clearFilters:E,refetch:v.refetch}}function ji({manager:e,config:a,formSections:t,onSave:r,FormComponent:n,TableComponent:i,onToggleStatus:o}){const{setSearchVisible:l,refreshData:d}=Es();return s(()=>(l(!0),()=>{l(!1)}),[l]),ha.jsx(vi,{manager:e,config:a,formSections:t,onSave:r,FormComponent:n,TableComponent:i,onToggleStatus:o})}function wi({open:e,onCancel:a,onSubmit:t,editingEntity:s,isLoading:r=!1,title:n,editTitle:i,sections:o,transformData:l}){const{alias:d}=Es();return ha.jsx(gi,{open:e,title:s?i:n,sections:o,initialData:s,onSubmit:e=>{if(l){const a=l(e,d||"");t(a)}else{const a={...e,alias:d||""};s?.id&&(a.id=s.id),t(a)}},onCancel:a,isLoading:r,submitButtonText:s?"Atualizar":"Salvar"})}const ki=({children:e})=>{const{isAuthenticated:t,isLoading:s}=Es();if(s)return ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Carregando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!t){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Processando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):(a.useEffect(()=>{(async()=>{vs()?await Ss.loginDev():Ss.loginProd()})()},[]),ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Iniciando..."})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),ha.jsx("p",{className:"text-muted-foreground",children:vs()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})}))}return ha.jsx(ha.Fragment,{children:e})},Si=()=>{const{processCallback:e}=Es(),[a,r]=t(null),[n,i]=t(!1);s(()=>{(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 r("Falha na autenticação. Tente novamente.")}catch(e){console.error("❌ [CallbackPage] Erro no processamento:",e),r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const o=async()=>{i(!0),r(null);try{await e()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return a?ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsxs(Ka,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[ha.jsx(w,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),ha.jsxs(Ga,{className:"space-y-4",children:[ha.jsx(Oa,{variant:"destructive",children:ha.jsx(za,{children:a})}),ha.jsx("div",{className:"text-sm text-muted-foreground",children:ha.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),ha.jsxs("div",{className:"flex gap-2",children:[ha.jsx(Na,{onClick:o,disabled:n,className:"flex-1",children:n?ha.jsxs(ha.Fragment,{children:[ha.jsx(Js,{size:"sm",className:"mr-2"}),"Tentando..."]}):ha.jsxs(ha.Fragment,{children:[ha.jsx(Ee,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),ha.jsx(Na,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):ha.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:ha.jsxs(Ha,{className:"w-full max-w-md",children:[ha.jsx(Qa,{className:"text-center",children:ha.jsx(Ka,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),ha.jsxs(Ga,{className:"text-center",children:[ha.jsx("div",{className:"flex justify-center mb-4",children:ha.jsx(Js,{size:"lg"})}),ha.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})};class Ci{static async extractTokenData(){const e=Gt.extractTokenData();return e||(ls.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,a){if(!e||0===e.length)return ls.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 ls.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 ei.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 ls.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 Ti=["responsible_name"];function Ei(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:d=!1}=s,c=()=>hs().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=c().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),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=js();if(d&&b.enableUserEnrichment&&l&&g.data.length>0){if(g.data.some(e=>e.id_user)){if(t&&(v=t,Ti.includes(v))){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},r=await this.getAll(a);if(!r?.data?.length)return r;const n=((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}))(await Ci.enrichWithResponsibleNames(r.data,{entityName:l}),t,s),i=((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}}})(n,o,m);return{data:i.data,currentPage:i.pagination.currentPage,totalPages:i.pagination.totalPages,totalItems:i.pagination.totalItems,itemsPerPage:i.pagination.itemsPerPage,hasNextPage:i.pagination.hasNextPage,hasPreviousPage:i.pagination.hasPreviousPage}}const a=await Ci.enrichWithResponsibleNames(g.data,{entityName:l});g={...g,data:a}}}var v;return g},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=ga(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().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={...ga(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().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 c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}}}function Ri(e){return{queryClient:e.queryClient||new He({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}export{xs as AUTH_CONFIG,fi as ActionMenuItems,Oa as Alert,za as AlertDescription,ja as AlertDialog,_a as AlertDialogAction,Aa as AlertDialogCancel,Ca as AlertDialogContent,Pa as AlertDialogDescription,Ea as AlertDialogFooter,Ta as AlertDialogHeader,Sa as AlertDialogOverlay,ka as AlertDialogPortal,Ra as AlertDialogTitle,wa as AlertDialogTrigger,Da as AlertTitle,Vn as AppHeader,Xn as AppLayout,Kn as AppSidebar,Ts as AuthProvider,Ss as AuthService,$a as Badge,ji as BaseCrudPage,La as Breadcrumb,qa as BreadcrumbEllipsis,Ua as BreadcrumbItem,Va as BreadcrumbLink,Ma as BreadcrumbList,Wa as BreadcrumbPage,Ba as BreadcrumbSeparator,Na as Button,gs as CRUD_CONFIG,Si as CallbackPage,Ha as Card,Ga as CardContent,Xa as CardDescription,Ya as CardFooter,Qa as CardHeader,mn as CardSkeleton,Ka as CardTitle,nt as ColorPicker,it as Command,ot as CommandDialog,ct as CommandEmpty,mt as CommandGroup,lt as CommandInput,ft as CommandItem,dt as CommandList,ut as CommandSeparator,pt as CommandShortcut,hi as CrudCards,gi as CrudForm,vi as CrudPage,xi as CrudTable,ht as DataList,gt as Dialog,yt as DialogClose,jt as DialogContent,Ct as DialogDescription,kt as DialogFooter,wt as DialogHeader,Nt as DialogOverlay,vt as DialogPortal,St as DialogTitle,bt as DialogTrigger,Tt as DropdownMenu,Ft as DropdownMenuCheckboxItem,Dt as DropdownMenuContent,Rt as DropdownMenuGroup,zt as DropdownMenuItem,Lt as DropdownMenuLabel,Pt as DropdownMenuPortal,At as DropdownMenuRadioGroup,$t as DropdownMenuRadioItem,Mt as DropdownMenuSeparator,Ut as DropdownMenuShortcut,_t as DropdownMenuSub,Ot as DropdownMenuSubContent,It as DropdownMenuSubTrigger,Et as DropdownMenuTrigger,Wt as EmptyState,Gn as ErrorBoundary,Rs as FeedbackDialog,yi as FilterBar,Ps as Form,Fs as FormControl,$s as FormDescription,As as FormField,Ds as FormItem,zs as FormLabel,Ls as FormMessage,un as FormSkeleton,wi as GenericEntityForm,Vs as Grid,fn as HeaderSkeleton,Hs as IconPicker,Ja as Input,Qs as InputOTP,Ks as InputOTPGroup,Gs as InputOTPSeparator,Xs as InputOTPSlot,et as Label,Zs as LoadingState,ks as MESSAGES,Fn as NavigationProvider,er as PageBreadcrumb,tr as Pagination,sr as PaginationContent,lr as PaginationEllipsis,rr as PaginationItem,nr as PaginationLink,or as PaginationNext,ir as PaginationPrevious,at as Popover,st as PopoverContent,tt as PopoverTrigger,ki as ProtectedRoute,ys as QUERY_KEYS,Ci as QualiexEnrichmentService,si as QualiexResponsibleSelectField,ti as QualiexUserField,bs as SEARCH_CONFIG,Ws as ScrollArea,Bs as ScrollBar,dr as Select,hr as SelectContent,cr as SelectGroup,gr as SelectItem,xr as SelectLabel,pr as SelectScrollDownButton,fr as SelectScrollUpButton,br as SelectSeparator,ur as SelectTrigger,mr as SelectValue,vr as Separator,yr as Sheet,jr as SheetClose,Cr as SheetContent,Pr as SheetDescription,Er as SheetFooter,Tr as SheetHeader,kr as SheetOverlay,wr as SheetPortal,Rr as SheetTitle,Nr as SheetTrigger,Lr as Sidebar,Qr as SidebarContent,qr as SidebarFooter,Kr as SidebarGroup,Gr as SidebarGroupAction,Yr as SidebarGroupContent,Xr as SidebarGroupLabel,Br as SidebarHeader,Wr as SidebarInput,Vr as SidebarInset,Jr as SidebarMenu,tn as SidebarMenuAction,sn as SidebarMenuBadge,an as SidebarMenuButton,Zr as SidebarMenuItem,rn as SidebarMenuSkeleton,nn as SidebarMenuSub,ln as SidebarMenuSubButton,on as SidebarMenuSubItem,$r as SidebarProvider,Ur as SidebarRail,Hr as SidebarSeparator,pn as SidebarSkeleton,Mr as SidebarTrigger,dn as Skeleton,Js as Spinner,bn as Stack,vn as Table,Nn as TableBody,Sn as TableCaption,kn as TableCell,bi as TableFooter,wn as TableHead,yn as TableHeader,jn as TableRow,pi as TableRowActions,cn as TableSkeleton,Cn as Textarea,Pn as Toast,_n as ToastAction,An as ToastClose,On as ToastDescription,Tn as ToastProvider,In as ToastTitle,En as ToastViewport,Dn as Toaster,Gt as TokenManager,Ar as Tooltip,Or as TooltipContent,_r as TooltipProvider,Ir as TooltipTrigger,qn as assets,Fa as badgeVariants,ya as buttonVariants,xa as cn,Ei as createService,va as debounce,ls as errorService,ba as formatDatetime,js as getQualiexConfig,hs as getSupabaseClient,vs as isDevEnvironment,Hn as logoSrc,ei as qualiexApi,ws as setQualiexConfig,Ri as setupQualiexCore,Qn as smallLogoSrc,rs as toast,ga as trimTextFields,Wn as useActiveModules,Es as useAuth,Yn as useBaseForm,Ni as useCrud,Un as useDebounce,Is as useFormField,$n as useNavigation,Ln as usePageTitle,ai as useQualiexUsers,ar as useRouteBreadcrumbs,Fr as useSidebar,ns as useToast};
11
11
  //# sourceMappingURL=index.esm.js.map