forlogic-core 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -20
- package/dist/README.md +38 -20
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import*as r from"react";import s,{createContext as n,useContext as i,useMemo as o,useRef as l,useCallback as d,useState as c,useEffect as u,createElement as m,memo as h,Component as p}from"react";import{Slot as f}from"@radix-ui/react-slot";import{cva as g}from"class-variance-authority";import{clsx as b}from"clsx";import{twMerge as v}from"tailwind-merge";import{parseISO as y,isValid as x,format as N}from"date-fns";import{toast as w,Toaster as k}from"sonner";export{toast as sonnerToast}from"sonner";import{EllipsisVertical as S,X as C,ChevronDown as _,ChevronUp as P,Check as E,Loader2 as T,AlertCircle as I,AlertTriangle as A,Search as R,FileX as O,ChevronRight as L,Circle as j,Edit as F,PowerOff as M,Power as D,Trash2 as z,Plus as $,ArrowUpDown as U,ArrowUp as V,ArrowDown as q,Target as B,Trophy as W,Award as H,Sparkles as K,Flame as Q,Zap as G,Key as J,Shield as X,EyeOff as Y,Eye as Z,Unlock as ee,Lock as te,Archive as ae,FolderOpen as re,Folder as se,FileText as ne,Save as ie,Copy as oe,Share as le,Upload as de,Download as ce,HelpCircle as ue,Info as me,Bell as he,Clock as pe,ArrowRight as fe,ArrowLeft as ge,ChevronLeft as be,Minus as ve,Filter as ye,Bookmark as xe,Book as Ne,Video as we,Music as ke,Image as Se,Camera as Ce,MapPin as _e,Calendar as Pe,Phone as Ee,Mail as Te,Settings as Ie,User as Ae,Home as Re,Heart as Oe,Star as Le,ChevronsLeft as je,ChevronsRight as Fe,RefreshCw as Me,MoreHorizontal as De,PanelLeft as ze,ExternalLink as $e,Globe as Ue,Building2 as Ve,LogOut as qe,MessageCircle as Be,Send as We,Users as He,Crown as Ke,UserPlus as Qe}from"lucide-react";import*as Ge from"@radix-ui/react-label";import*as Je from"@radix-ui/react-dialog";import{useFormContext as Xe,FormProvider as Ye,Controller as Ze,appendErrors as et,useForm as tt}from"react-hook-form";import*as at from"@radix-ui/react-select";import*as rt from"@radix-ui/react-checkbox";import*as st from"@radix-ui/react-toast";import*as nt from"@radix-ui/react-popover";import{createClient as it}from"@supabase/supabase-js";import{useQueryClient as ot,useQuery as lt,useMutation as dt,QueryClient as ct}from"@tanstack/react-query";import{useSearchParams as ut,useLocation as mt,useNavigate as ht,Link as pt}from"react-router-dom";import*as ft from"@radix-ui/react-alert-dialog";import*as gt from"@radix-ui/react-dropdown-menu";import*as bt from"@radix-ui/react-context-menu";import*as vt from"@radix-ui/react-scroll-area";import*as yt from"@radix-ui/react-switch";import*as xt from"@radix-ui/react-progress";import*as Nt from"@radix-ui/react-accordion";import*as wt from"@radix-ui/react-aspect-ratio";import*as kt from"@radix-ui/react-avatar";import{DayPicker as St}from"react-day-picker";import*as Ct from"@radix-ui/react-collapsible";import{Drawer as _t}from"vaul";import*as Pt from"@radix-ui/react-radio-group";import*as Et from"@radix-ui/react-separator";import*as Tt from"@radix-ui/react-tooltip";import*as It from"@radix-ui/react-slider";import{useTheme as At}from"next-themes";import*as Rt from"@radix-ui/react-tabs";import*as Ot from"@radix-ui/react-toggle";import*as Lt from"@radix-ui/react-toggle-group";import jt from"react-markdown";import Ft from"remark-gfm";import{z as Mt}from"zod";import{validateFieldsNatively as Dt,toNestErrors as zt}from"@hookform/resolvers";const $t=e=>"string"==typeof e,Ut=()=>{let e,t;const a=new Promise((a,r)=>{e=a,t=r});return a.resolve=e,a.reject=t,a},Vt=e=>null==e?"":""+e,qt=/###/g,Bt=e=>e&&e.indexOf("###")>-1?e.replace(qt,"."):e,Wt=e=>!e||$t(e),Ht=(e,t,a)=>{const r=$t(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Wt(e))return{};const t=Bt(r[s]);!e[t]&&a&&(e[t]=new a),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++s}return Wt(e)?{}:{obj:e,k:Bt(r[s])}},Kt=(e,t,a)=>{const{obj:r,k:s}=Ht(e,t,Object);if(void 0!==r||1===t.length)return void(r[s]=a);let n=t[t.length-1],i=t.slice(0,t.length-1),o=Ht(e,i,Object);for(;void 0===o.obj&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),o=Ht(e,i,Object),o?.obj&&void 0!==o.obj[`${o.k}.${n}`]&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=a},Qt=(e,t)=>{const{obj:a,k:r}=Ht(e,t);if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r]},Gt=(e,t,a)=>{for(const r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?$t(e[r])||e[r]instanceof String||$t(t[r])||t[r]instanceof String?a&&(e[r]=t[r]):Gt(e[r],t[r],a):e[r]=t[r]);return e},Jt=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Yt=e=>$t(e)?e.replace(/[&<>"'\/]/g,e=>Xt[e]):e;const Zt=[" ",",","?","!",";"],ea=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const a=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,a),this.regExpQueue.push(e),a}}(20),ta=(e,t,a=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const r=t.split(a);let s=e;for(let n=0;n<r.length;){if(!s||"object"!=typeof s)return;let e,t="";for(let i=n;i<r.length;++i)if(i!==n&&(t+=a),t+=r[i],e=s[t],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&i<r.length-1)continue;n+=i-n+1;break}s=e}return s},aa=e=>e?.replace("_","-"),ra={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){}};class sa{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||ra,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,a,r){return r&&!this.debug?null:($t(e[0])&&(e[0]=`${a}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new sa(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new sa(this.logger,e)}}var na=new sa;class ia{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const a=this.observers[e].get(t)||0;this.observers[e].set(t,a+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,a])=>{for(let r=0;r<a;r++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([a,r])=>{for(let s=0;s<r;s++)a.apply(a,[e,...t])})}}}class oa extends ia{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,a,r={}){const s=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,n=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let i;e.indexOf(".")>-1?i=e.split("."):(i=[e,t],a&&(Array.isArray(a)?i.push(...a):$t(a)&&s?i.push(...a.split(s)):i.push(a)));const o=Qt(this.data,i);return!o&&!t&&!a&&e.indexOf(".")>-1&&(e=i[0],t=i[1],a=i.slice(2).join(".")),!o&&n&&$t(a)?ta(this.data?.[e]?.[t],a,s):o}addResource(e,t,a,r,s={silent:!1}){const n=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let i=[e,t];a&&(i=i.concat(n?a.split(n):a)),e.indexOf(".")>-1&&(i=e.split("."),r=t,t=i[1]),this.addNamespaces(t),Kt(this.data,i,r),s.silent||this.emit("added",e,t,a,r)}addResources(e,t,a,r={silent:!1}){for(const s in a)($t(a[s])||Array.isArray(a[s]))&&this.addResource(e,t,s,a[s],{silent:!0});r.silent||this.emit("added",e,t,a)}addResourceBundle(e,t,a,r,s,n={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),r=a,a=t,t=i[1]),this.addNamespaces(t);let o=Qt(this.data,i)||{};n.skipCopy||(a=JSON.parse(JSON.stringify(a))),r?Gt(o,a,s):o={...o,...a},Kt(this.data,i,o),n.silent||this.emit("added",e,t,a)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var la={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,a,r,s){return e.forEach(e=>{t=this.processors[e]?.process(t,a,r,s)??t}),t}};const da=Symbol("i18next/PATH_KEY");function ca(e,t){const{[da]:a}=e(function(){const e=[],t=Object.create(null);let a;return t.get=(r,s)=>(a?.revoke?.(),s===da?e:(e.push(s),a=Proxy.revocable(r,t),a.proxy)),Proxy.revocable(Object.create(null),t).proxy}());return a.join(t?.keySeparator??".")}const ua={},ma=e=>!$t(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ha extends ia{constructor(e,t={}){super(),((e,t,a)=>{e.forEach(e=>{t[e]&&(a[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=na.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const a={...t};if(null==e)return!1;const r=this.resolve(e,a);if(void 0===r?.res)return!1;const s=ma(r.res);return!1!==a.returnObjects||!s}extractFromKey(e,t){let a=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===a&&(a=":");const r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const n=a&&e.indexOf(a)>-1,i=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,a)=>{t=t||"",a=a||"";const r=Zt.filter(e=>t.indexOf(e)<0&&a.indexOf(e)<0);if(0===r.length)return!0;const s=ea.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!s.test(e);if(!n){const t=e.indexOf(a);t>0&&!s.test(e.substring(0,t))&&(n=!0)}return n})(e,a,r));if(n&&!i){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:$t(s)?[s]:s};const n=e.split(a);(a!==r||a===r&&this.options.ns.indexOf(n[0])>-1)&&(s=n.shift()),e=n.join(r)}return{key:e,namespaces:$t(s)?[s]:s}}translate(e,t,a){let r="object"==typeof t?{...t}:t;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=ca(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);const s=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,n=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:i,namespaces:o}=this.extractFromKey(e[e.length-1],r),l=o[o.length-1];let d=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===d&&(d=":");const c=r.lng||this.language,u=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===c?.toLowerCase())return u?s?{res:`${l}${d}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${d}${i}`:s?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i;const m=this.resolve(e,r);let h=m?.res;const p=m?.usedKey||i,f=m?.exactUsedKey||i,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==r.count&&!$t(r.count),y=ha.hasDefaultValue(r),x=v?this.pluralResolver.getSuffix(c,r.count,r):"",N=r.ordinal&&v?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",w=v&&!r.ordinal&&0===r.count,k=w&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${x}`]||r[`defaultValue${N}`]||r.defaultValue;let S=h;b&&!h&&y&&(S=k);const C=ma(S),_=Object.prototype.toString.apply(S);if(!(b&&S&&C&&["[object Number]","[object Function]","[object RegExp]"].indexOf(_)<0)||$t(g)&&Array.isArray(S))if(b&&$t(g)&&Array.isArray(h))h=h.join(g),h&&(h=this.extendTranslation(h,e,r,a));else{let t=!1,s=!1;!this.isValidLookup(h)&&y&&(t=!0,h=k),this.isValidLookup(h)||(s=!0,h=i);const o=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:h,u=y&&k!==h&&this.options.updateMissing;if(s||t||u){if(this.logger.log(u?"updateKey":"missingKey",c,l,i,u?k:h),n){const e=this.resolve(i,{...r,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);const a=(e,t,a)=>{const s=y&&a!==h?a:o;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,s,u,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,s,u,r),this.emit("missingKey",e,l,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,r);w&&r[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{a([e],i+t,r[`defaultValue${t}`]||k)})}):a(e,i,k))}h=this.extendTranslation(h,e,r,m,a),s&&h===i&&this.options.appendNamespaceToMissingKey&&(h=`${l}${d}${i}`),(s||t)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${d}${i}`:i,t?h:void 0,r))}else{if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(p,S,{...r,ns:o}):`key '${i} (${this.language})' returned an object instead of string.`;return s?(m.res=e,m.usedParams=this.getUsedParamsDetails(r),m):e}if(n){const e=Array.isArray(S),t=e?[]:{},a=e?f:p;for(const s in S)if(Object.prototype.hasOwnProperty.call(S,s)){const e=`${a}${n}${s}`;t[s]=y&&!h?this.translate(e,{...r,defaultValue:ma(k)?k[s]:void 0,joinArrays:!1,ns:o}):this.translate(e,{...r,joinArrays:!1,ns:o}),t[s]===e&&(t[s]=S[s])}h=t}}return s?(m.res=h,m.usedParams=this.getUsedParamsDetails(r),m):h}extendTranslation(e,t,a,r,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...a},a.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!a.skipInterpolation){a.interpolation&&this.interpolator.init({...a,interpolation:{...this.options.interpolation,...a.interpolation}});const n=$t(e)&&(void 0!==a?.interpolation?.skipOnVariables?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let i;if(n){const t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let o=a.replace&&!$t(a.replace)?a.replace:a;if(this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),e=this.interpolator.interpolate(e,o,a.lng||this.language||r.usedLng,a),n){const t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(a.nest=!1)}!a.lng&&r&&r.res&&(a.lng=this.language||r.usedLng),!1!==a.nest&&(e=this.interpolator.nest(e,(...e)=>s?.[0]!==e[0]||a.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),a)),a.interpolation&&this.interpolator.reset()}const n=a.postProcess||this.options.postProcess,i=$t(n)?[n]:n;return null!=e&&i?.length&&!1!==a.applyPostProcessor&&(e=la.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(a)},...a}:a,this)),e}resolve(e,t={}){let a,r,s,n,i;return $t(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(a))return;const o=this.extractFromKey(e,t),l=o.key;r=l;let d=o.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const c=void 0!==t.count&&!$t(t.count),u=c&&!t.ordinal&&0===t.count,m=void 0!==t.context&&($t(t.context)||"number"==typeof t.context)&&""!==t.context,h=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(e=>{this.isValidLookup(a)||(i=e,ua[`${h[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(i)||(ua[`${h[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${h.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(r=>{if(this.isValidLookup(a))return;n=r;const i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,r,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(r,t.count,t));const a=`${this.options.pluralSeparator}zero`,s=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(s)&&i.push(l+e.replace(s,this.options.pluralSeparator)),i.push(l+e),u&&i.push(l+a)),m){const r=`${l}${this.options.contextSeparator||"_"}${t.context}`;i.push(r),c&&(t.ordinal&&0===e.indexOf(s)&&i.push(r+e.replace(s,this.options.pluralSeparator)),i.push(r+e),u&&i.push(r+a))}}let o;for(;o=i.pop();)this.isValidLookup(a)||(s=o,a=this.getResource(r,e,o,t))}))})}),{res:a,usedKey:r,exactUsedKey:s,usedLng:n,usedNS:i}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,a,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,a,r):this.resourceStore.getResource(e,t,a,r)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],a=e.replace&&!$t(e.replace);let r=a?e.replace:e;if(a&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!a){r={...r};for(const e of t)delete r[e]}return r}static hasDefaultValue(e){const t="defaultValue";for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t===a.substring(0,12)&&void 0!==e[a])return!0;return!1}}class pa{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=na.create("languageUtils")}getScriptPartFromCode(e){if(!(e=aa(e))||e.indexOf("-")<0)return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=aa(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if($t(e)&&e.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(e)[0]}catch(t){}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const a=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(a)||(t=a)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const a=this.getScriptPartFromCode(e);if(this.isSupportedCode(a))return t=a;const r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?e:e.indexOf("-")<0&&r.indexOf("-")<0?void 0:e.indexOf("-")>0&&r.indexOf("-")<0&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1?e:void 0)}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),$t(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let a=e[t];return a||(a=e[this.getScriptPartFromCode(t)]),a||(a=e[this.formatLanguageCode(t)]),a||(a=e[this.getLanguagePartFromCode(t)]),a||(a=e.default),a||[]}toResolveHierarchy(e,t){const a=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),r=[],s=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return $t(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&s(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&s(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&s(this.getLanguagePartFromCode(e))):$t(e)&&s(this.formatLanguageCode(e)),a.forEach(e=>{r.indexOf(e)<0&&s(this.formatLanguageCode(e))}),r}}const fa={zero:0,one:1,two:2,few:3,many:4,other:5},ga={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ba{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=na.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const a=aa("dev"===e?"en":e),r=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:a,type:r});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let n;try{n=new Intl.PluralRules(a,{type:r})}catch(i){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ga;if(!e.match(/-|_/))return ga;const a=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(a,t)}return this.pluralRulesCache[s]=n,n}needsPlural(e,t={}){let a=this.getRule(e,t);return a||(a=this.getRule("dev",t)),a?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,a={}){return this.getSuffixes(e,a).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let a=this.getRule(e,t);return a||(a=this.getRule("dev",t)),a?a.resolvedOptions().pluralCategories.sort((e,t)=>fa[e]-fa[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,a={}){const r=this.getRule(e,a);return r?`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,a))}}const va=(e,t,a,r=".",s=!0)=>{let n=((e,t,a)=>{const r=Qt(e,a);return void 0!==r?r:Qt(t,a)})(e,t,a);return!n&&s&&$t(a)&&(n=ta(e,a,r),void 0===n&&(n=ta(t,a,r))),n},ya=e=>e.replace(/\$/g,"$$$$");class xa{constructor(e={}){this.logger=na.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:a,useRawValueToEscape:r,prefix:s,prefixEscaped:n,suffix:i,suffixEscaped:o,formatSeparator:l,unescapeSuffix:d,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:m,nestingSuffix:h,nestingSuffixEscaped:p,nestingOptionsSeparator:f,maxReplaces:g,alwaysFormat:b}=e.interpolation;this.escape=void 0!==t?t:Yt,this.escapeValue=void 0===a||a,this.useRawValueToEscape=void 0!==r&&r,this.prefix=s?Jt(s):n||"{{",this.suffix=i?Jt(i):o||"}}",this.formatSeparator=l||",",this.unescapePrefix=d?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=u?Jt(u):m||Jt("$t("),this.nestingSuffix=h?Jt(h):p||Jt(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,a,r){let s,n,i;const o=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(e.indexOf(this.formatSeparator)<0){const s=va(t,o,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(s,void 0,a,{...r,...t,interpolationkey:e}):s}const s=e.split(this.formatSeparator),n=s.shift().trim(),i=s.join(this.formatSeparator).trim();return this.format(va(t,o,n,this.options.keySeparator,this.options.ignoreJSONStructure),i,a,{...r,...t,interpolationkey:n})};this.resetRegExp();const d=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=void 0!==r?.interpolation?.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>ya(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?ya(this.escape(e)):ya(e)}].forEach(t=>{for(i=0;s=t.regex.exec(e);){const a=s[1].trim();if(n=l(a),void 0===n)if("function"==typeof d){const t=d(e,s,r);n=$t(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,a))n="";else{if(c){n=s[0];continue}this.logger.warn(`missed to pass in variable ${a} for interpolating ${e}`),n=""}else $t(n)||this.useRawValueToEscape||(n=Vt(n));const o=t.safeValue(n);if(e=e.replace(s[0],o),c?(t.regex.lastIndex+=n.length,t.regex.lastIndex-=s[0].length):t.regex.lastIndex=0,i++,i>=this.maxReplaces)break}}),e}nest(e,t,a={}){let r,s,n;const i=(e,t)=>{const a=this.nestingOptionsSeparator;if(e.indexOf(a)<0)return e;const r=e.split(new RegExp(`${a}[ ]*{`));let s=`{${r[1]}`;e=r[0],s=this.interpolate(s,n);const i=s.match(/'/g),o=s.match(/"/g);((i?.length??0)%2==0&&!o||o.length%2!=0)&&(s=s.replace(/'/g,'"'));try{n=JSON.parse(s),t&&(n={...t,...n})}catch(l){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,l),`${e}${a}${s}`}return n.defaultValue&&n.defaultValue.indexOf(this.prefix)>-1&&delete n.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let o=[];n={...a},n=n.replace&&!$t(n.replace)?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;const l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(o=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),s=t(i.call(this,r[1].trim(),n),n),s&&r[0]===e&&!$t(s))return s;$t(s)||(s=Vt(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),o.length&&(s=o.reduce((e,t)=>this.format(e,t,a.lng,{...a,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const Na=e=>{const t={};return(a,r,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n={...n,[s.interpolationkey]:void 0});const i=r+JSON.stringify(n);let o=t[i];return o||(o=e(aa(r),s),t[i]=o),o(a)}},wa=e=>(t,a,r)=>e(aa(a),r)(t);class ka{constructor(e={}){this.logger=na.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const a=t.cacheInBuiltFormats?Na:wa;this.formats={number:a((e,t)=>{const a=new Intl.NumberFormat(e,{...t});return e=>a.format(e)}),currency:a((e,t)=>{const a=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>a.format(e)}),datetime:a((e,t)=>{const a=new Intl.DateTimeFormat(e,{...t});return e=>a.format(e)}),relativetime:a((e,t)=>{const a=new Intl.RelativeTimeFormat(e,{...t});return e=>a.format(e,t.range||"day")}),list:a((e,t)=>{const a=new Intl.ListFormat(e,{...t});return e=>a.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Na(t)}format(e,t,a,r={}){const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(e=>e.indexOf(")")>-1)){const e=s.findIndex(e=>e.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,e)].join(this.formatSeparator)}return s.reduce((e,t)=>{const{formatName:s,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);"currency"===t&&s.indexOf(":")<0?a.currency||(a.currency=s.trim()):"relativetime"===t&&s.indexOf(":")<0?a.range||(a.range=s.trim()):s.split(";").forEach(e=>{if(e){const[t,...r]=e.split(":"),s=r.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();a[n]||(a[n]=s),"false"===s&&(a[n]=!1),"true"===s&&(a[n]=!0),isNaN(s)||(a[n]=parseInt(s,10))}})}return{formatName:t,formatOptions:a}})(t);if(this.formats[s]){let t=e;try{const i=r?.formatParams?.[r.interpolationkey]||{},o=i.locale||i.lng||r.locale||r.lng||a;t=this.formats[s](e,o,{...n,...r,...i})}catch(i){this.logger.warn(i)}return t}return this.logger.warn(`there was no format function for ${s}`),e},e)}}class Sa extends ia{constructor(e,t,a,r={}){super(),this.backend=e,this.store=t,this.services=a,this.languageUtils=a.languageUtils,this.options=r,this.logger=na.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(a,r.backend,r)}queueLoad(e,t,a,r){const s={},n={},i={},o={};return e.forEach(e=>{let r=!0;t.forEach(t=>{const i=`${e}|${t}`;!a.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===n[i]&&(n[i]=!0):(this.state[i]=1,r=!1,void 0===n[i]&&(n[i]=!0),void 0===s[i]&&(s[i]=!0),void 0===o[t]&&(o[t]=!0)))}),r||(i[e]=!0)}),(Object.keys(s).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(n),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(o)}}loaded(e,t,a){const r=e.split("|"),s=r[0],n=r[1];t&&this.emit("failedLoading",s,n,t),!t&&a&&this.store.addResourceBundle(s,n,a,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&a&&(this.state[e]=0);const i={};this.queue.forEach(a=>{((e,t,a)=>{const{obj:r,k:s}=Ht(e,t,Object);r[s]=r[s]||[],r[s].push(a)})(a.loaded,[s],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(a,e),t&&a.errors.push(t),0!==a.pendingCount||a.done||(Object.keys(a.loaded).forEach(e=>{i[e]||(i[e]={});const t=a.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),a.done=!0,a.errors.length?a.callback(a.errors):a.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,a,r=0,s=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:a,tried:r,wait:s,callback:n});this.readingCalls++;const i=(i,o)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&o&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,a,r+1,2*s,n)},s):n(i,o)},o=this.backend[a].bind(this.backend);if(2!==o.length)return o(e,t,i);try{const a=o(e,t);a&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(l){i(l)}}prepareLoading(e,t,a={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();$t(e)&&(e=this.languageUtils.toResolveHierarchy(e)),$t(t)&&(t=[t]);const s=this.queueLoad(e,t,a,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,a){this.prepareLoading(e,t,{},a)}reload(e,t,a){this.prepareLoading(e,t,{reload:!0},a)}loadOne(e,t=""){const a=e.split("|"),r=a[0],s=a[1];this.read(r,s,"read",void 0,void 0,(a,n)=>{a&&this.logger.warn(`${t}loading namespace ${s} for language ${r} failed`,a),!a&&n&&this.logger.log(`${t}loaded namespace ${s} for language ${r}`,n),this.loaded(e,a,n)})}saveMissing(e,t,a,r,s,n={},i=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=a&&""!==a){if(this.backend?.create){const l={...n,isUpdate:s},d=this.backend.create.bind(this.backend);if(d.length<6)try{let s;s=5===d.length?d(e,t,a,r,l):d(e,t,a,r),s&&"function"==typeof s.then?s.then(e=>i(null,e)).catch(i):i(null,s)}catch(o){i(o)}else d(e,t,a,r,i,l)}e&&e[0]&&this.store.addResource(e[0],t,a,r)}}else this.logger.warn(`did not save key "${a}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const Ca=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),$t(e[1])&&(t.defaultValue=e[1]),$t(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){const a=e[3]||e[2];Object.keys(a).forEach(e=>{t[e]=a[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),_a=e=>($t(e.ns)&&(e.ns=[e.ns]),$t(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),$t(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),Pa=()=>{};class Ea extends ia{constructor(e={},t){var a;if(super(),this.options=_a(e),this.services={},this.logger=na,this.modules={external:[]},a=this,Object.getOwnPropertyNames(Object.getPrototypeOf(a)).forEach(e=>{"function"==typeof a[e]&&(a[e]=a[e].bind(a))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&($t(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const a=Ca();this.options={...a,...this.options,..._a(e)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?na.init(r(this.modules.logger),this.options):na.init(null,this.options),e=this.modules.formatter?this.modules.formatter:ka;const t=new pa(this.options);this.store=new oa(this.options.resources,this.options);const s=this.services;s.logger=na,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new ba(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix});this.options.interpolation.format&&this.options.interpolation.format!==a.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!e||this.options.interpolation.format&&this.options.interpolation.format!==a.interpolation.format||(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new xa(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new Sa(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new ha(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Pa),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const s=Ut(),n=()=>{const e=(e,a)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),s.resolve(a),t(e,a)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?n():setTimeout(n,0),s}loadResources(e,t=Pa){let a=t;const r=$t(e)?e:this.language;if("function"==typeof e&&(a=e),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===r?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return a();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&e.indexOf(t)<0&&e.push(t)})};if(r)t(r);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),a(e)})}else a(null)}reloadResources(e,t,a){const r=Ut();return"function"==typeof e&&(a=e,e=void 0),"function"==typeof t&&(a=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),a||(a=Pa),this.services.backendConnector.reload(e,t,e=>{r.resolve(),a(e)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&la.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const a=Ut();this.emit("languageChanging",e);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},s=(s,n)=>{n?this.isLanguageChangingTo===e&&(r(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),t&&t(s,(...e)=>this.t(...e))},n=t=>{e||t||!this.services.languageDetector||(t=[]);const a=$t(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(a)?a:this.services.languageUtils.getBestMatchFromCodes($t(t)?[t]:t);n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{s(e,n)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(n):this.services.languageDetector.detect(n):n(e):n(this.services.languageDetector.detect()),a}getFixedT(e,t,a){const r=(e,t,...s)=>{let n;n="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},n.lng=n.lng||r.lng,n.lngs=n.lngs||r.lngs,n.ns=n.ns||r.ns,""!==n.keyPrefix&&(n.keyPrefix=n.keyPrefix||a||r.keyPrefix);const i=this.options.keySeparator||".";let o;return n.keyPrefix&&Array.isArray(e)?o=e.map(e=>("function"==typeof e&&(e=ca(e,{...this.options,...t})),`${n.keyPrefix}${i}${e}`)):("function"==typeof e&&(e=ca(e,{...this.options,...t})),o=n.keyPrefix?`${n.keyPrefix}${i}${e}`:e),this.t(o,n)};return $t(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=a,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const a=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,s=this.languages[this.languages.length-1];if("cimode"===a.toLowerCase())return!0;const n=(e,t)=>{const a=this.services.backendConnector.state[`${e}|${t}`];return-1===a||0===a||2===a};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}return!!this.hasResourceBundle(a,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!n(a,e)||r&&!n(s,e)))}loadNamespaces(e,t){const a=Ut();return this.options.ns?($t(e)&&(e=[e]),e.forEach(e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}),this.loadResources(e=>{a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}loadLanguages(e,t){const a=Ut();$t(e)&&(e=[e]);const r=this.options.preload||[],s=e.filter(e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e));return s.length?(this.options.preload=r.concat(s),this.loadResources(e=>{a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(a){}const t=this.services?.languageUtils||new pa(Ca());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const a=new Ea(e,t);return a.createInstance=Ea.createInstance,a}cloneInstance(e={},t=Pa){const a=e.forkResourceStore;a&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new Ea(r);void 0===e.debug&&void 0===e.prefix||(s.logger=s.logger.clone(e));if(["store","services","language"].forEach(e=>{s[e]=this[e]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},a){const e=Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((a,r)=>(a[r]={...e[t][r]},a),e[t]),e),{});s.store=new oa(e,r),s.services.resourceStore=s.store}return s.translator=new ha(s.services,r),s.translator.on("*",(e,...t)=>{s.emit(e,...t)}),s.init(r,t),s.translator.options=r,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ta=Ea.createInstance();function Ia(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{w.info(Ta.t("link_copied"))})}function Aa(...e){return v(b(e))}Ta.createInstance,Ta.dir,Ta.init,Ta.loadResources,Ta.reloadResources,Ta.use,Ta.changeLanguage,Ta.getFixedT,Ta.t,Ta.exists,Ta.setDefaultNamespace,Ta.hasLoadedNamespace,Ta.loadNamespaces,Ta.loadLanguages;const Ra=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Ra);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,r]of Object.entries(e))t[a]=Ra(r);return t}return e},Oa=e=>{if(!e)return"";const t=y(e);if(!x(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},La=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),ja=(e,t)=>{let a;return(...r)=>{clearTimeout(a),a=setTimeout(()=>e(...r),t)}},Fa=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),Ma=g("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 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:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Da=r.forwardRef(({className:t,variant:a,size:r,asChild:s=!1,...n},i)=>e(s?f:"button",{className:Aa(Ma({variant:a,size:r,className:t})),ref:i,...n}));Da.displayName="Button";const za=s.forwardRef(({variant:t="default",className:a,children:r,...s},n)=>e(Da,{ref:n,variant:"action",size:"sm",className:Aa("h-7 px-2 text-xs",a),...s,children:r||e(S,{size:12})}));za.displayName="ActionButton";const $a=r.forwardRef(({className:t,type:a,...r},s)=>e("input",{type:a,className:Aa("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...r}));$a.displayName="Input";const Ua=g("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Va=r.forwardRef(({className:t,...a},r)=>e(Ge.Root,{ref:r,className:Aa(Ua(),t),...a}));Va.displayName=Ge.Root.displayName;const qa=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));qa.displayName="Card";const Ba=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("flex flex-col space-y-1.5 p-6",t),...a}));Ba.displayName="CardHeader";const Wa=r.forwardRef(({className:t,...a},r)=>e("h3",{ref:r,className:Aa("text-2xl font-semibold leading-none tracking-tight",t),...a}));Wa.displayName="CardTitle";const Ha=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));Ha.displayName="CardDescription";const Ka=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("p-6 pt-0",t),...a}));Ka.displayName="CardContent";const Qa=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("flex items-center p-6 pt-0",t),...a}));Qa.displayName="CardFooter";const Ga=Je.Root,Ja=Je.Trigger,Xa=Je.Portal,Ya=Je.Close,Za=r.forwardRef(({className:t,...a},r)=>e(Je.Overlay,{ref:r,className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));Za.displayName=Je.Overlay.displayName;const er=r.forwardRef(({className:a,children:r,...s},n)=>t(Xa,{children:[e(Za,{}),t(Je.Content,{ref:n,className:Aa("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...s,children:[r,t(Je.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-accent data-[state=open]:text-muted-foreground",children:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));er.displayName=Je.Content.displayName;const tr=({className:t,...a})=>e("div",{className:Aa("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});tr.displayName="DialogHeader";const ar=({className:t,...a})=>e("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});ar.displayName="DialogFooter";const rr=r.forwardRef(({className:t,...a},r)=>e(Je.Title,{ref:r,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));rr.displayName=Je.Title.displayName;const sr=r.forwardRef(({className:t,...a},r)=>e(Je.Description,{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));sr.displayName=Je.Description.displayName;const nr=Ye,ir=r.createContext({}),or=({...t})=>e(ir.Provider,{value:{name:t.name},children:e(Ze,{...t})}),lr=()=>{const e=r.useContext(ir),t=r.useContext(dr),{getFieldState:a,formState:s}=Xe(),n=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},dr=r.createContext({}),cr=r.forwardRef(({className:t,...a},s)=>{const n=r.useId();return e(dr.Provider,{value:{id:n},children:e("div",{ref:s,className:Aa("space-y-2",t),...a})})});cr.displayName="FormItem";const ur=r.forwardRef(({className:t,...a},r)=>{const{error:s,formItemId:n}=lr();return e(Va,{ref:r,className:Aa(s&&"text-destructive",t),htmlFor:n,...a})});ur.displayName="FormLabel";const mr=r.forwardRef(({...t},a)=>{const{error:r,formItemId:s,formDescriptionId:n,formMessageId:i}=lr();return e(f,{ref:a,id:s,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...t})});mr.displayName="FormControl";const hr=r.forwardRef(({className:t,...a},r)=>{const{formDescriptionId:s}=lr();return e("p",{ref:r,id:s,className:Aa("text-sm text-muted-foreground",t),...a})});hr.displayName="FormDescription";const pr=r.forwardRef(({className:t,children:a,...r},s)=>{const{error:n,formMessageId:i}=lr(),o=n?String(n?.message):a;return o?e("p",{ref:s,id:i,className:Aa("text-sm font-medium text-destructive",t),...r,children:o}):null});pr.displayName="FormMessage";const fr=at.Root,gr=at.Group,br=at.Value,vr=r.forwardRef(({className:a,children:r,...s},n)=>t(at.Trigger,{ref:n,className:Aa("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...s,children:[r,e(at.Icon,{asChild:!0,children:e(_,{className:"h-4 w-4 opacity-50"})})]}));vr.displayName=at.Trigger.displayName;const yr=r.forwardRef(({className:t,...a},r)=>e(at.ScrollUpButton,{ref:r,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e(P,{className:"h-4 w-4"})}));yr.displayName=at.ScrollUpButton.displayName;const xr=r.forwardRef(({className:t,...a},r)=>e(at.ScrollDownButton,{ref:r,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e(_,{className:"h-4 w-4"})}));xr.displayName=at.ScrollDownButton.displayName;const Nr=r.forwardRef(({className:a,children:r,position:s="popper",container:n,collisionBoundary:i,...o},l)=>e(at.Portal,{container:n,children:t(at.Content,{ref:l,className:Aa("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:s,collisionBoundary:i,...o,children:[e(yr,{}),e(at.Viewport,{className:Aa("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e(xr,{})]})}));Nr.displayName=at.Content.displayName;const wr=r.forwardRef(({className:t,...a},r)=>e(at.Label,{ref:r,className:Aa("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));wr.displayName=at.Label.displayName;const kr=r.forwardRef(({className:a,children:r,...s},n)=>t(at.Item,{ref:n,className:Aa("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(at.ItemIndicator,{children:e(E,{className:"h-4 w-4"})})}),e(at.ItemText,{children:r})]}));kr.displayName=at.Item.displayName;const Sr=r.forwardRef(({className:t,...a},r)=>e(at.Separator,{ref:r,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Sr.displayName=at.Separator.displayName;const Cr=r.forwardRef(({className:t,...a},r)=>e(rt.Root,{ref:r,className:Aa("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e(rt.Indicator,{className:Aa("flex items-center justify-center text-current"),children:e(E,{className:"h-4 w-4"})})}));Cr.displayName=rt.Root.displayName;const _r=r.forwardRef(({className:t,...a},r)=>e("textarea",{className:Aa("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...a}));_r.displayName="Textarea";const Pr=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",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-white hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Er=r.forwardRef(({className:t,variant:a,...r},s)=>e("div",{ref:s,className:Aa(Pr({variant:a}),t),...r}));Er.displayName="Badge";const Tr={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ir({size:t="md",className:a}){return e(T,{className:Aa("animate-spin text-muted-foreground",Tr[t],a)})}function Ar({isLoading:r,children:s,className:n,type:i="spinner",size:o="md"}){return r?"overlay"===i?t("div",{className:Aa("relative",n),children:[s,e("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e(Ir,{size:o})})]}):e("div","skeleton"===i?{className:Aa("animate-pulse",n),children:e("div",{className:"bg-muted rounded-md h-full w-full"})}:{className:Aa("flex items-center justify-center py-8",n),children:e(Ir,{size:o})}):e(a,{children:s})}let Rr=0;const Or=new Map,Lr=e=>{if(Or.has(e))return;const t=setTimeout(()=>{Or.delete(e),Dr({type:"REMOVE_TOAST",toastId:e})},1e6);Or.set(e,t)},jr=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:a}=t;return a?Lr(a):e.toasts.forEach(e=>{Lr(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},Fr=[];let Mr={toasts:[]};function Dr(e){Mr=jr(Mr,e),Fr.forEach(e=>{e(Mr)})}function zr({...e}){const t=(Rr=(Rr+1)%Number.MAX_SAFE_INTEGER,Rr.toString()),a=()=>Dr({type:"DISMISS_TOAST",toastId:t});return Dr({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||a()}}}),{id:t,dismiss:a,update:e=>Dr({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function $r(){const[e,t]=r.useState(Mr);return r.useEffect(()=>(Fr.push(t),()=>{const e=Fr.indexOf(t);e>-1&&Fr.splice(e,1)}),[e]),{...e,toast:zr,dismiss:e=>Dr({type:"DISMISS_TOAST",toastId:e})}}const Ur=st.Provider,Vr=r.forwardRef(({className:t,...a},r)=>e(st.Viewport,{ref:r,className:Aa("fixed top-4 left-1/2 transform -translate-x-1/2 z-[100] flex max-h-screen w-full max-w-[420px] flex-col p-4",t),...a}));Vr.displayName=st.Viewport.displayName;const qr=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"}}),Br=r.forwardRef(({className:t,variant:a,...r},s)=>e(st.Root,{ref:s,className:Aa(qr({variant:a}),t),...r}));Br.displayName=st.Root.displayName;const Wr=r.forwardRef(({className:t,...a},r)=>e(st.Action,{ref:r,className:Aa("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...a}));Wr.displayName=st.Action.displayName;const Hr=r.forwardRef(({className:t,...a},r)=>e(st.Close,{ref:r,className:Aa("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...a,children:e(C,{className:"h-4 w-4"})}));Hr.displayName=st.Close.displayName;const Kr=r.forwardRef(({className:t,...a},r)=>e(st.Title,{ref:r,className:Aa("text-sm font-semibold",t),...a}));Kr.displayName=st.Title.displayName;const Qr=r.forwardRef(({className:t,...a},r)=>e(st.Description,{ref:r,className:Aa("text-sm opacity-90",t),...a}));function Gr(){const{toasts:a}=$r();return t(Ur,{children:[a.map(function({id:a,title:r,description:s,action:n,...i}){return t(Br,{...i,children:[t("div",{className:"grid gap-1",children:[r&&e(Kr,{children:r}),s&&e(Qr,{children:s})]}),n,e(Hr,{})]},a)}),e(Vr,{})]})}Qr.displayName=st.Description.displayName;const Jr=nt.Root,Xr=nt.Trigger,Yr=r.forwardRef(({className:t,align:a="center",sideOffset:r=4,container:s,...n},i)=>e(nt.Portal,{container:s,children:e(nt.Content,{ref:i,align:a,sideOffset:r,className:Aa("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Yr.displayName=nt.Content.displayName;const Zr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));Zr.displayName="Command";const es=({children:t,...a})=>e("div",{...a,children:e(Zr,{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:t})}),ts=r.forwardRef(({className:t,...a},r)=>e("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e("input",{ref:r,className:Aa("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})}));ts.displayName="CommandInput";const as=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));as.displayName="CommandList";const rs=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("py-6 text-center text-sm text-muted-foreground",t),...a}));rs.displayName="CommandEmpty";const ss=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));ss.displayName="CommandGroup";const ns=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("-mx-1 h-px bg-border",t),...a}));ns.displayName="CommandSeparator";const is=r.forwardRef(({className:t,disabled:a,onSelect:r,value:s,...n},i)=>e("div",{ref:i,className:Aa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),"data-disabled":a,onClick:()=>!a&&r?.(s||""),...n}));is.displayName="CommandItem";const os=({className:t,...a})=>e("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function ls({className:t,...a}){return e("div",{className:Aa("animate-pulse rounded-md bg-muted",t),...a})}os.displayName="CommandShortcut";const ds={},cs=(e,t,a,r)=>{ps(a)&&ds[a]||(ps(a)&&(ds[a]=new Date),((e,t,a,r)=>{const s=[a,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);ps(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console})(e,t,a,r))},us=(e,t)=>()=>{if(e.isInitialized)t();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),t()};e.on("initialized",a)}},ms=(e,t,a)=>{e.loadNamespaces(t,us(e,a))},hs=(e,t,a,r)=>{if(ps(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(t)>-1)return ms(e,a,r);a.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,us(e,r))},ps=e=>"string"==typeof e,fs=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,gs={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},bs=e=>gs[e];let vs={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(fs,bs)};let ys;const xs={type:"3rdParty",init(e){((e={})=>{vs={...vs,...e}})(e.options.react),(e=>{ys=e})(e)}},Ns=n();class ws{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var ks,Ss={exports:{}},Cs={};var _s,Ps,Es={};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import*as r from"react";import s,{createContext as n,useContext as i,useMemo as o,useRef as l,useCallback as d,useState as c,useEffect as u,createElement as m,memo as h,Component as p}from"react";import{Slot as f}from"@radix-ui/react-slot";import{cva as g}from"class-variance-authority";import{clsx as b}from"clsx";import{twMerge as v}from"tailwind-merge";import{parseISO as y,isValid as x,format as N}from"date-fns";import{toast as w,Toaster as k}from"sonner";export{toast as sonnerToast,toast}from"sonner";import{EllipsisVertical as S,X as C,ChevronDown as _,ChevronUp as E,Check as P,Loader2 as I,Loader2Icon as T,OctagonXIcon as A,TriangleAlertIcon as R,InfoIcon as O,CircleCheckIcon as L,AlertCircle as F,AlertTriangle as j,Search as D,FileX as M,ChevronRight as z,Circle as $,Edit as U,PowerOff as V,Power as q,Trash2 as B,Plus as W,ArrowUpDown as H,ArrowUp as K,ArrowDown as Q,Target as G,Trophy as J,Award as X,Sparkles as Y,Flame as Z,Zap as ee,Key as te,Shield as ae,EyeOff as re,Eye as se,Unlock as ne,Lock as ie,Archive as oe,FolderOpen as le,Folder as de,FileText as ce,Save as ue,Copy as me,Share as he,Upload as pe,Download as fe,HelpCircle as ge,Info as be,Bell as ve,Clock as ye,ArrowRight as xe,ArrowLeft as Ne,ChevronLeft as we,Minus as ke,Filter as Se,Bookmark as Ce,Book as _e,Video as Ee,Music as Pe,Image as Ie,Camera as Te,MapPin as Ae,Calendar as Re,Phone as Oe,Mail as Le,Settings as Fe,User as je,Home as De,Heart as Me,Star as ze,ChevronsLeft as $e,ChevronsRight as Ue,RefreshCw as Ve,MoreHorizontal as qe,PanelLeft as Be,ExternalLink as We,Globe as He,Building2 as Ke,LogOut as Qe,MessageCircle as Ge,Send as Je,Users as Xe,Crown as Ye,UserPlus as Ze}from"lucide-react";import*as et from"@radix-ui/react-label";import*as tt from"@radix-ui/react-dialog";import*as at from"@radix-ui/react-separator";import{useFormContext as rt,FormProvider as st,Controller as nt,appendErrors as it,useForm as ot}from"react-hook-form";import*as lt from"@radix-ui/react-select";import*as dt from"@radix-ui/react-checkbox";import*as ct from"@radix-ui/react-popover";import{createClient as ut}from"@supabase/supabase-js";import{useQueryClient as mt,useQuery as ht,useMutation as pt,QueryClient as ft}from"@tanstack/react-query";import{useSearchParams as gt,useLocation as bt,useNavigate as vt,Link as yt}from"react-router-dom";import*as xt from"@radix-ui/react-alert-dialog";import*as Nt from"@radix-ui/react-dropdown-menu";import*as wt from"@radix-ui/react-context-menu";import*as kt from"@radix-ui/react-scroll-area";import*as St from"@radix-ui/react-switch";import*as Ct from"@radix-ui/react-progress";import*as _t from"@radix-ui/react-accordion";import*as Et from"@radix-ui/react-aspect-ratio";import*as Pt from"@radix-ui/react-avatar";import{DayPicker as It}from"react-day-picker";import*as Tt from"@radix-ui/react-collapsible";import{Drawer as At}from"vaul";import*as Rt from"@radix-ui/react-radio-group";import*as Ot from"@radix-ui/react-tooltip";import*as Lt from"@radix-ui/react-slider";import*as Ft from"@radix-ui/react-tabs";import*as jt from"@radix-ui/react-toast";import*as Dt from"@radix-ui/react-toggle";import*as Mt from"@radix-ui/react-toggle-group";import zt from"react-markdown";import $t from"remark-gfm";import{z as Ut}from"zod";import{validateFieldsNatively as Vt,toNestErrors as qt}from"@hookform/resolvers";const Bt=e=>"string"==typeof e,Wt=()=>{let e,t;const a=new Promise((a,r)=>{e=a,t=r});return a.resolve=e,a.reject=t,a},Ht=e=>null==e?"":""+e,Kt=/###/g,Qt=e=>e&&e.indexOf("###")>-1?e.replace(Kt,"."):e,Gt=e=>!e||Bt(e),Jt=(e,t,a)=>{const r=Bt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Gt(e))return{};const t=Qt(r[s]);!e[t]&&a&&(e[t]=new a),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++s}return Gt(e)?{}:{obj:e,k:Qt(r[s])}},Xt=(e,t,a)=>{const{obj:r,k:s}=Jt(e,t,Object);if(void 0!==r||1===t.length)return void(r[s]=a);let n=t[t.length-1],i=t.slice(0,t.length-1),o=Jt(e,i,Object);for(;void 0===o.obj&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),o=Jt(e,i,Object),o?.obj&&void 0!==o.obj[`${o.k}.${n}`]&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=a},Yt=(e,t)=>{const{obj:a,k:r}=Jt(e,t);if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r]},Zt=(e,t,a)=>{for(const r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?Bt(e[r])||e[r]instanceof String||Bt(t[r])||t[r]instanceof String?a&&(e[r]=t[r]):Zt(e[r],t[r],a):e[r]=t[r]);return e},ea=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ta={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const aa=e=>Bt(e)?e.replace(/[&<>"'\/]/g,e=>ta[e]):e;const ra=[" ",",","?","!",";"],sa=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const a=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,a),this.regExpQueue.push(e),a}}(20),na=(e,t,a=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const r=t.split(a);let s=e;for(let n=0;n<r.length;){if(!s||"object"!=typeof s)return;let e,t="";for(let i=n;i<r.length;++i)if(i!==n&&(t+=a),t+=r[i],e=s[t],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&i<r.length-1)continue;n+=i-n+1;break}s=e}return s},ia=e=>e?.replace("_","-"),oa={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){}};class la{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||oa,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,a,r){return r&&!this.debug?null:(Bt(e[0])&&(e[0]=`${a}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new la(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new la(this.logger,e)}}var da=new la;class ca{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const a=this.observers[e].get(t)||0;this.observers[e].set(t,a+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,a])=>{for(let r=0;r<a;r++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([a,r])=>{for(let s=0;s<r;s++)a.apply(a,[e,...t])})}}}class ua extends ca{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,a,r={}){const s=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,n=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let i;e.indexOf(".")>-1?i=e.split("."):(i=[e,t],a&&(Array.isArray(a)?i.push(...a):Bt(a)&&s?i.push(...a.split(s)):i.push(a)));const o=Yt(this.data,i);return!o&&!t&&!a&&e.indexOf(".")>-1&&(e=i[0],t=i[1],a=i.slice(2).join(".")),!o&&n&&Bt(a)?na(this.data?.[e]?.[t],a,s):o}addResource(e,t,a,r,s={silent:!1}){const n=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let i=[e,t];a&&(i=i.concat(n?a.split(n):a)),e.indexOf(".")>-1&&(i=e.split("."),r=t,t=i[1]),this.addNamespaces(t),Xt(this.data,i,r),s.silent||this.emit("added",e,t,a,r)}addResources(e,t,a,r={silent:!1}){for(const s in a)(Bt(a[s])||Array.isArray(a[s]))&&this.addResource(e,t,s,a[s],{silent:!0});r.silent||this.emit("added",e,t,a)}addResourceBundle(e,t,a,r,s,n={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),r=a,a=t,t=i[1]),this.addNamespaces(t);let o=Yt(this.data,i)||{};n.skipCopy||(a=JSON.parse(JSON.stringify(a))),r?Zt(o,a,s):o={...o,...a},Xt(this.data,i,o),n.silent||this.emit("added",e,t,a)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var ma={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,a,r,s){return e.forEach(e=>{t=this.processors[e]?.process(t,a,r,s)??t}),t}};const ha=Symbol("i18next/PATH_KEY");function pa(e,t){const{[ha]:a}=e(function(){const e=[],t=Object.create(null);let a;return t.get=(r,s)=>(a?.revoke?.(),s===ha?e:(e.push(s),a=Proxy.revocable(r,t),a.proxy)),Proxy.revocable(Object.create(null),t).proxy}());return a.join(t?.keySeparator??".")}const fa={},ga=e=>!Bt(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ba extends ca{constructor(e,t={}){super(),((e,t,a)=>{e.forEach(e=>{t[e]&&(a[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=da.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const a={...t};if(null==e)return!1;const r=this.resolve(e,a);if(void 0===r?.res)return!1;const s=ga(r.res);return!1!==a.returnObjects||!s}extractFromKey(e,t){let a=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===a&&(a=":");const r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const n=a&&e.indexOf(a)>-1,i=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,a)=>{t=t||"",a=a||"";const r=ra.filter(e=>t.indexOf(e)<0&&a.indexOf(e)<0);if(0===r.length)return!0;const s=sa.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!s.test(e);if(!n){const t=e.indexOf(a);t>0&&!s.test(e.substring(0,t))&&(n=!0)}return n})(e,a,r));if(n&&!i){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:Bt(s)?[s]:s};const n=e.split(a);(a!==r||a===r&&this.options.ns.indexOf(n[0])>-1)&&(s=n.shift()),e=n.join(r)}return{key:e,namespaces:Bt(s)?[s]:s}}translate(e,t,a){let r="object"==typeof t?{...t}:t;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=pa(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);const s=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,n=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:i,namespaces:o}=this.extractFromKey(e[e.length-1],r),l=o[o.length-1];let d=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===d&&(d=":");const c=r.lng||this.language,u=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===c?.toLowerCase())return u?s?{res:`${l}${d}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${d}${i}`:s?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i;const m=this.resolve(e,r);let h=m?.res;const p=m?.usedKey||i,f=m?.exactUsedKey||i,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==r.count&&!Bt(r.count),y=ba.hasDefaultValue(r),x=v?this.pluralResolver.getSuffix(c,r.count,r):"",N=r.ordinal&&v?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",w=v&&!r.ordinal&&0===r.count,k=w&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${x}`]||r[`defaultValue${N}`]||r.defaultValue;let S=h;b&&!h&&y&&(S=k);const C=ga(S),_=Object.prototype.toString.apply(S);if(!(b&&S&&C&&["[object Number]","[object Function]","[object RegExp]"].indexOf(_)<0)||Bt(g)&&Array.isArray(S))if(b&&Bt(g)&&Array.isArray(h))h=h.join(g),h&&(h=this.extendTranslation(h,e,r,a));else{let t=!1,s=!1;!this.isValidLookup(h)&&y&&(t=!0,h=k),this.isValidLookup(h)||(s=!0,h=i);const o=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:h,u=y&&k!==h&&this.options.updateMissing;if(s||t||u){if(this.logger.log(u?"updateKey":"missingKey",c,l,i,u?k:h),n){const e=this.resolve(i,{...r,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);const a=(e,t,a)=>{const s=y&&a!==h?a:o;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,s,u,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,s,u,r),this.emit("missingKey",e,l,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,r);w&&r[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{a([e],i+t,r[`defaultValue${t}`]||k)})}):a(e,i,k))}h=this.extendTranslation(h,e,r,m,a),s&&h===i&&this.options.appendNamespaceToMissingKey&&(h=`${l}${d}${i}`),(s||t)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${d}${i}`:i,t?h:void 0,r))}else{if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(p,S,{...r,ns:o}):`key '${i} (${this.language})' returned an object instead of string.`;return s?(m.res=e,m.usedParams=this.getUsedParamsDetails(r),m):e}if(n){const e=Array.isArray(S),t=e?[]:{},a=e?f:p;for(const s in S)if(Object.prototype.hasOwnProperty.call(S,s)){const e=`${a}${n}${s}`;t[s]=y&&!h?this.translate(e,{...r,defaultValue:ga(k)?k[s]:void 0,joinArrays:!1,ns:o}):this.translate(e,{...r,joinArrays:!1,ns:o}),t[s]===e&&(t[s]=S[s])}h=t}}return s?(m.res=h,m.usedParams=this.getUsedParamsDetails(r),m):h}extendTranslation(e,t,a,r,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...a},a.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!a.skipInterpolation){a.interpolation&&this.interpolator.init({...a,interpolation:{...this.options.interpolation,...a.interpolation}});const n=Bt(e)&&(void 0!==a?.interpolation?.skipOnVariables?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let i;if(n){const t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let o=a.replace&&!Bt(a.replace)?a.replace:a;if(this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),e=this.interpolator.interpolate(e,o,a.lng||this.language||r.usedLng,a),n){const t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(a.nest=!1)}!a.lng&&r&&r.res&&(a.lng=this.language||r.usedLng),!1!==a.nest&&(e=this.interpolator.nest(e,(...e)=>s?.[0]!==e[0]||a.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),a)),a.interpolation&&this.interpolator.reset()}const n=a.postProcess||this.options.postProcess,i=Bt(n)?[n]:n;return null!=e&&i?.length&&!1!==a.applyPostProcessor&&(e=ma.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(a)},...a}:a,this)),e}resolve(e,t={}){let a,r,s,n,i;return Bt(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(a))return;const o=this.extractFromKey(e,t),l=o.key;r=l;let d=o.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const c=void 0!==t.count&&!Bt(t.count),u=c&&!t.ordinal&&0===t.count,m=void 0!==t.context&&(Bt(t.context)||"number"==typeof t.context)&&""!==t.context,h=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(e=>{this.isValidLookup(a)||(i=e,fa[`${h[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(i)||(fa[`${h[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${h.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(r=>{if(this.isValidLookup(a))return;n=r;const i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,r,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(r,t.count,t));const a=`${this.options.pluralSeparator}zero`,s=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(s)&&i.push(l+e.replace(s,this.options.pluralSeparator)),i.push(l+e),u&&i.push(l+a)),m){const r=`${l}${this.options.contextSeparator||"_"}${t.context}`;i.push(r),c&&(t.ordinal&&0===e.indexOf(s)&&i.push(r+e.replace(s,this.options.pluralSeparator)),i.push(r+e),u&&i.push(r+a))}}let o;for(;o=i.pop();)this.isValidLookup(a)||(s=o,a=this.getResource(r,e,o,t))}))})}),{res:a,usedKey:r,exactUsedKey:s,usedLng:n,usedNS:i}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,a,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,a,r):this.resourceStore.getResource(e,t,a,r)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],a=e.replace&&!Bt(e.replace);let r=a?e.replace:e;if(a&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!a){r={...r};for(const e of t)delete r[e]}return r}static hasDefaultValue(e){const t="defaultValue";for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t===a.substring(0,12)&&void 0!==e[a])return!0;return!1}}class va{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=da.create("languageUtils")}getScriptPartFromCode(e){if(!(e=ia(e))||e.indexOf("-")<0)return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=ia(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(Bt(e)&&e.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(e)[0]}catch(t){}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const a=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(a)||(t=a)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const a=this.getScriptPartFromCode(e);if(this.isSupportedCode(a))return t=a;const r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?e:e.indexOf("-")<0&&r.indexOf("-")<0?void 0:e.indexOf("-")>0&&r.indexOf("-")<0&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1?e:void 0)}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),Bt(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let a=e[t];return a||(a=e[this.getScriptPartFromCode(t)]),a||(a=e[this.formatLanguageCode(t)]),a||(a=e[this.getLanguagePartFromCode(t)]),a||(a=e.default),a||[]}toResolveHierarchy(e,t){const a=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),r=[],s=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return Bt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&s(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&s(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&s(this.getLanguagePartFromCode(e))):Bt(e)&&s(this.formatLanguageCode(e)),a.forEach(e=>{r.indexOf(e)<0&&s(this.formatLanguageCode(e))}),r}}const ya={zero:0,one:1,two:2,few:3,many:4,other:5},xa={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Na{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=da.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const a=ia("dev"===e?"en":e),r=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:a,type:r});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let n;try{n=new Intl.PluralRules(a,{type:r})}catch(i){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),xa;if(!e.match(/-|_/))return xa;const a=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(a,t)}return this.pluralRulesCache[s]=n,n}needsPlural(e,t={}){let a=this.getRule(e,t);return a||(a=this.getRule("dev",t)),a?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,a={}){return this.getSuffixes(e,a).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let a=this.getRule(e,t);return a||(a=this.getRule("dev",t)),a?a.resolvedOptions().pluralCategories.sort((e,t)=>ya[e]-ya[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,a={}){const r=this.getRule(e,a);return r?`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,a))}}const wa=(e,t,a,r=".",s=!0)=>{let n=((e,t,a)=>{const r=Yt(e,a);return void 0!==r?r:Yt(t,a)})(e,t,a);return!n&&s&&Bt(a)&&(n=na(e,a,r),void 0===n&&(n=na(t,a,r))),n},ka=e=>e.replace(/\$/g,"$$$$");class Sa{constructor(e={}){this.logger=da.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:a,useRawValueToEscape:r,prefix:s,prefixEscaped:n,suffix:i,suffixEscaped:o,formatSeparator:l,unescapeSuffix:d,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:m,nestingSuffix:h,nestingSuffixEscaped:p,nestingOptionsSeparator:f,maxReplaces:g,alwaysFormat:b}=e.interpolation;this.escape=void 0!==t?t:aa,this.escapeValue=void 0===a||a,this.useRawValueToEscape=void 0!==r&&r,this.prefix=s?ea(s):n||"{{",this.suffix=i?ea(i):o||"}}",this.formatSeparator=l||",",this.unescapePrefix=d?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=u?ea(u):m||ea("$t("),this.nestingSuffix=h?ea(h):p||ea(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,a,r){let s,n,i;const o=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(e.indexOf(this.formatSeparator)<0){const s=wa(t,o,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(s,void 0,a,{...r,...t,interpolationkey:e}):s}const s=e.split(this.formatSeparator),n=s.shift().trim(),i=s.join(this.formatSeparator).trim();return this.format(wa(t,o,n,this.options.keySeparator,this.options.ignoreJSONStructure),i,a,{...r,...t,interpolationkey:n})};this.resetRegExp();const d=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=void 0!==r?.interpolation?.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>ka(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?ka(this.escape(e)):ka(e)}].forEach(t=>{for(i=0;s=t.regex.exec(e);){const a=s[1].trim();if(n=l(a),void 0===n)if("function"==typeof d){const t=d(e,s,r);n=Bt(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,a))n="";else{if(c){n=s[0];continue}this.logger.warn(`missed to pass in variable ${a} for interpolating ${e}`),n=""}else Bt(n)||this.useRawValueToEscape||(n=Ht(n));const o=t.safeValue(n);if(e=e.replace(s[0],o),c?(t.regex.lastIndex+=n.length,t.regex.lastIndex-=s[0].length):t.regex.lastIndex=0,i++,i>=this.maxReplaces)break}}),e}nest(e,t,a={}){let r,s,n;const i=(e,t)=>{const a=this.nestingOptionsSeparator;if(e.indexOf(a)<0)return e;const r=e.split(new RegExp(`${a}[ ]*{`));let s=`{${r[1]}`;e=r[0],s=this.interpolate(s,n);const i=s.match(/'/g),o=s.match(/"/g);((i?.length??0)%2==0&&!o||o.length%2!=0)&&(s=s.replace(/'/g,'"'));try{n=JSON.parse(s),t&&(n={...t,...n})}catch(l){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,l),`${e}${a}${s}`}return n.defaultValue&&n.defaultValue.indexOf(this.prefix)>-1&&delete n.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let o=[];n={...a},n=n.replace&&!Bt(n.replace)?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;const l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(o=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),s=t(i.call(this,r[1].trim(),n),n),s&&r[0]===e&&!Bt(s))return s;Bt(s)||(s=Ht(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),o.length&&(s=o.reduce((e,t)=>this.format(e,t,a.lng,{...a,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const Ca=e=>{const t={};return(a,r,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n={...n,[s.interpolationkey]:void 0});const i=r+JSON.stringify(n);let o=t[i];return o||(o=e(ia(r),s),t[i]=o),o(a)}},_a=e=>(t,a,r)=>e(ia(a),r)(t);class Ea{constructor(e={}){this.logger=da.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const a=t.cacheInBuiltFormats?Ca:_a;this.formats={number:a((e,t)=>{const a=new Intl.NumberFormat(e,{...t});return e=>a.format(e)}),currency:a((e,t)=>{const a=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>a.format(e)}),datetime:a((e,t)=>{const a=new Intl.DateTimeFormat(e,{...t});return e=>a.format(e)}),relativetime:a((e,t)=>{const a=new Intl.RelativeTimeFormat(e,{...t});return e=>a.format(e,t.range||"day")}),list:a((e,t)=>{const a=new Intl.ListFormat(e,{...t});return e=>a.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ca(t)}format(e,t,a,r={}){const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(e=>e.indexOf(")")>-1)){const e=s.findIndex(e=>e.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,e)].join(this.formatSeparator)}return s.reduce((e,t)=>{const{formatName:s,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);"currency"===t&&s.indexOf(":")<0?a.currency||(a.currency=s.trim()):"relativetime"===t&&s.indexOf(":")<0?a.range||(a.range=s.trim()):s.split(";").forEach(e=>{if(e){const[t,...r]=e.split(":"),s=r.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();a[n]||(a[n]=s),"false"===s&&(a[n]=!1),"true"===s&&(a[n]=!0),isNaN(s)||(a[n]=parseInt(s,10))}})}return{formatName:t,formatOptions:a}})(t);if(this.formats[s]){let t=e;try{const i=r?.formatParams?.[r.interpolationkey]||{},o=i.locale||i.lng||r.locale||r.lng||a;t=this.formats[s](e,o,{...n,...r,...i})}catch(i){this.logger.warn(i)}return t}return this.logger.warn(`there was no format function for ${s}`),e},e)}}class Pa extends ca{constructor(e,t,a,r={}){super(),this.backend=e,this.store=t,this.services=a,this.languageUtils=a.languageUtils,this.options=r,this.logger=da.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(a,r.backend,r)}queueLoad(e,t,a,r){const s={},n={},i={},o={};return e.forEach(e=>{let r=!0;t.forEach(t=>{const i=`${e}|${t}`;!a.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===n[i]&&(n[i]=!0):(this.state[i]=1,r=!1,void 0===n[i]&&(n[i]=!0),void 0===s[i]&&(s[i]=!0),void 0===o[t]&&(o[t]=!0)))}),r||(i[e]=!0)}),(Object.keys(s).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(n),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(o)}}loaded(e,t,a){const r=e.split("|"),s=r[0],n=r[1];t&&this.emit("failedLoading",s,n,t),!t&&a&&this.store.addResourceBundle(s,n,a,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&a&&(this.state[e]=0);const i={};this.queue.forEach(a=>{((e,t,a)=>{const{obj:r,k:s}=Jt(e,t,Object);r[s]=r[s]||[],r[s].push(a)})(a.loaded,[s],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(a,e),t&&a.errors.push(t),0!==a.pendingCount||a.done||(Object.keys(a.loaded).forEach(e=>{i[e]||(i[e]={});const t=a.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),a.done=!0,a.errors.length?a.callback(a.errors):a.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,a,r=0,s=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:a,tried:r,wait:s,callback:n});this.readingCalls++;const i=(i,o)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&o&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,a,r+1,2*s,n)},s):n(i,o)},o=this.backend[a].bind(this.backend);if(2!==o.length)return o(e,t,i);try{const a=o(e,t);a&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(l){i(l)}}prepareLoading(e,t,a={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();Bt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Bt(t)&&(t=[t]);const s=this.queueLoad(e,t,a,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,a){this.prepareLoading(e,t,{},a)}reload(e,t,a){this.prepareLoading(e,t,{reload:!0},a)}loadOne(e,t=""){const a=e.split("|"),r=a[0],s=a[1];this.read(r,s,"read",void 0,void 0,(a,n)=>{a&&this.logger.warn(`${t}loading namespace ${s} for language ${r} failed`,a),!a&&n&&this.logger.log(`${t}loaded namespace ${s} for language ${r}`,n),this.loaded(e,a,n)})}saveMissing(e,t,a,r,s,n={},i=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=a&&""!==a){if(this.backend?.create){const l={...n,isUpdate:s},d=this.backend.create.bind(this.backend);if(d.length<6)try{let s;s=5===d.length?d(e,t,a,r,l):d(e,t,a,r),s&&"function"==typeof s.then?s.then(e=>i(null,e)).catch(i):i(null,s)}catch(o){i(o)}else d(e,t,a,r,i,l)}e&&e[0]&&this.store.addResource(e[0],t,a,r)}}else this.logger.warn(`did not save key "${a}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const Ia=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),Bt(e[1])&&(t.defaultValue=e[1]),Bt(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){const a=e[3]||e[2];Object.keys(a).forEach(e=>{t[e]=a[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Ta=e=>(Bt(e.ns)&&(e.ns=[e.ns]),Bt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Bt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),Aa=()=>{};class Ra extends ca{constructor(e={},t){var a;if(super(),this.options=Ta(e),this.services={},this.logger=da,this.modules={external:[]},a=this,Object.getOwnPropertyNames(Object.getPrototypeOf(a)).forEach(e=>{"function"==typeof a[e]&&(a[e]=a[e].bind(a))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(Bt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const a=Ia();this.options={...a,...this.options,...Ta(e)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?da.init(r(this.modules.logger),this.options):da.init(null,this.options),e=this.modules.formatter?this.modules.formatter:Ea;const t=new va(this.options);this.store=new ua(this.options.resources,this.options);const s=this.services;s.logger=da,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new Na(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix});this.options.interpolation.format&&this.options.interpolation.format!==a.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!e||this.options.interpolation.format&&this.options.interpolation.format!==a.interpolation.format||(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new Sa(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new Pa(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new ba(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Aa),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const s=Wt(),n=()=>{const e=(e,a)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),s.resolve(a),t(e,a)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?n():setTimeout(n,0),s}loadResources(e,t=Aa){let a=t;const r=Bt(e)?e:this.language;if("function"==typeof e&&(a=e),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===r?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return a();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&e.indexOf(t)<0&&e.push(t)})};if(r)t(r);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),a(e)})}else a(null)}reloadResources(e,t,a){const r=Wt();return"function"==typeof e&&(a=e,e=void 0),"function"==typeof t&&(a=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),a||(a=Aa),this.services.backendConnector.reload(e,t,e=>{r.resolve(),a(e)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&ma.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const a=Wt();this.emit("languageChanging",e);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},s=(s,n)=>{n?this.isLanguageChangingTo===e&&(r(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),t&&t(s,(...e)=>this.t(...e))},n=t=>{e||t||!this.services.languageDetector||(t=[]);const a=Bt(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(a)?a:this.services.languageUtils.getBestMatchFromCodes(Bt(t)?[t]:t);n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{s(e,n)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(n):this.services.languageDetector.detect(n):n(e):n(this.services.languageDetector.detect()),a}getFixedT(e,t,a){const r=(e,t,...s)=>{let n;n="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},n.lng=n.lng||r.lng,n.lngs=n.lngs||r.lngs,n.ns=n.ns||r.ns,""!==n.keyPrefix&&(n.keyPrefix=n.keyPrefix||a||r.keyPrefix);const i=this.options.keySeparator||".";let o;return n.keyPrefix&&Array.isArray(e)?o=e.map(e=>("function"==typeof e&&(e=pa(e,{...this.options,...t})),`${n.keyPrefix}${i}${e}`)):("function"==typeof e&&(e=pa(e,{...this.options,...t})),o=n.keyPrefix?`${n.keyPrefix}${i}${e}`:e),this.t(o,n)};return Bt(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=a,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const a=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,s=this.languages[this.languages.length-1];if("cimode"===a.toLowerCase())return!0;const n=(e,t)=>{const a=this.services.backendConnector.state[`${e}|${t}`];return-1===a||0===a||2===a};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}return!!this.hasResourceBundle(a,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!n(a,e)||r&&!n(s,e)))}loadNamespaces(e,t){const a=Wt();return this.options.ns?(Bt(e)&&(e=[e]),e.forEach(e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}),this.loadResources(e=>{a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}loadLanguages(e,t){const a=Wt();Bt(e)&&(e=[e]);const r=this.options.preload||[],s=e.filter(e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e));return s.length?(this.options.preload=r.concat(s),this.loadResources(e=>{a.resolve(),t&&t(e)}),a):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(a){}const t=this.services?.languageUtils||new va(Ia());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const a=new Ra(e,t);return a.createInstance=Ra.createInstance,a}cloneInstance(e={},t=Aa){const a=e.forkResourceStore;a&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new Ra(r);void 0===e.debug&&void 0===e.prefix||(s.logger=s.logger.clone(e));if(["store","services","language"].forEach(e=>{s[e]=this[e]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},a){const e=Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((a,r)=>(a[r]={...e[t][r]},a),e[t]),e),{});s.store=new ua(e,r),s.services.resourceStore=s.store}return s.translator=new ba(s.services,r),s.translator.on("*",(e,...t)=>{s.emit(e,...t)}),s.init(r,t),s.translator.options=r,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Oa=Ra.createInstance();function La(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{w.info(Oa.t("link_copied"))})}function Fa(...e){return v(b(e))}Oa.createInstance,Oa.dir,Oa.init,Oa.loadResources,Oa.reloadResources,Oa.use,Oa.changeLanguage,Oa.getFixedT,Oa.t,Oa.exists,Oa.setDefaultNamespace,Oa.hasLoadedNamespace,Oa.loadNamespaces,Oa.loadLanguages;const ja=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(ja);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,r]of Object.entries(e))t[a]=ja(r);return t}return e},Da=e=>{if(!e)return"";const t=y(e);if(!x(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},Ma=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),za=(e,t)=>{let a;return(...r)=>{clearTimeout(a),a=setTimeout(()=>e(...r),t)}},$a=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),Ua=g("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 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:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Va=r.forwardRef(({className:t,variant:a,size:r,asChild:s=!1,...n},i)=>e(s?f:"button",{className:Fa(Ua({variant:a,size:r,className:t})),ref:i,...n}));Va.displayName="Button";const qa=s.forwardRef(({variant:t="default",className:a,children:r,...s},n)=>e(Va,{ref:n,variant:"action",size:"sm",className:Fa("h-7 px-2 text-xs",a),...s,children:r||e(S,{size:12})}));qa.displayName="ActionButton";const Ba=r.forwardRef(({className:t,type:a,...r},s)=>e("input",{type:a,className:Fa("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",t),ref:s,...r}));Ba.displayName="Input";const Wa=g("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ha=r.forwardRef(({className:t,...a},r)=>e(et.Root,{ref:r,className:Fa(Wa(),t),...a}));Ha.displayName=et.Root.displayName;const Ka=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));Ka.displayName="Card";const Qa=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("flex flex-col space-y-1.5 p-6",t),...a}));Qa.displayName="CardHeader";const Ga=r.forwardRef(({className:t,...a},r)=>e("h3",{ref:r,className:Fa("text-2xl font-semibold leading-none tracking-tight",t),...a}));Ga.displayName="CardTitle";const Ja=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));Ja.displayName="CardDescription";const Xa=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("p-6 pt-0",t),...a}));Xa.displayName="CardContent";const Ya=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("flex items-center p-6 pt-0",t),...a}));Ya.displayName="CardFooter";const Za=r.forwardRef(({className:t,orientation:a="horizontal",decorative:r=!0,...s},n)=>e(at.Root,{ref:n,decorative:r,orientation:a,className:Fa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...s}));Za.displayName=at.Root.displayName;const er=tt.Root,tr=tt.Trigger,ar=tt.Portal,rr=tt.Close,sr=r.forwardRef(({className:t,...a},r)=>e(tt.Overlay,{ref:r,className:Fa("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",t),...a}));sr.displayName=tt.Overlay.displayName;const nr=r.forwardRef(({className:a,children:r,...s},n)=>t(ar,{children:[e(sr,{}),t(tt.Content,{ref:n,className:Fa("fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-[85vw] max-h-[85vh] translate-x-[-50%] translate-y-[-50%] 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",a),...s,children:[r,t(tt.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));nr.displayName=tt.Content.displayName;const ir=({className:a,showSeparator:r=!1,children:s,...n})=>t("div",{className:Fa("flex flex-col flex-shrink-0",a),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e(Za,{className:"mt-2"})]});ir.displayName="DialogHeader";const or=({className:t,...a})=>e("div",{className:Fa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});or.displayName="DialogBody";const lr=({className:a,children:r,...s})=>t("div",{className:"flex-shrink-0 pt-4",children:[e(Za,{className:"mb-4"}),e("div",{className:Fa("flex flex-row justify-end gap-2",a),...s,children:r})]});lr.displayName="DialogFooter";const dr=r.forwardRef(({className:t,...a},r)=>e(tt.Title,{ref:r,className:Fa("text-lg font-semibold leading-none tracking-tight",t),...a}));dr.displayName=tt.Title.displayName;const cr=r.forwardRef(({className:t,...a},r)=>e(tt.Description,{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));cr.displayName=tt.Description.displayName;const ur=st,mr=r.createContext({}),hr=({...t})=>e(mr.Provider,{value:{name:t.name},children:e(nt,{...t})}),pr=()=>{const e=r.useContext(mr),t=r.useContext(fr),{getFieldState:a,formState:s}=rt(),n=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},fr=r.createContext({}),gr=r.forwardRef(({className:t,...a},s)=>{const n=r.useId();return e(fr.Provider,{value:{id:n},children:e("div",{ref:s,className:Fa("space-y-2",t),...a})})});gr.displayName="FormItem";const br=r.forwardRef(({className:t,...a},r)=>{const{error:s,formItemId:n}=pr();return e(Ha,{ref:r,className:Fa(s&&"text-destructive",t),htmlFor:n,...a})});br.displayName="FormLabel";const vr=r.forwardRef(({...t},a)=>{const{error:r,formItemId:s,formDescriptionId:n,formMessageId:i}=pr();return e(f,{ref:a,id:s,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...t})});vr.displayName="FormControl";const yr=r.forwardRef(({className:t,...a},r)=>{const{formDescriptionId:s}=pr();return e("p",{ref:r,id:s,className:Fa("text-sm text-muted-foreground",t),...a})});yr.displayName="FormDescription";const xr=r.forwardRef(({className:t,children:a,...r},s)=>{const{error:n,formMessageId:i}=pr(),o=n?String(n?.message):a;return o?e("p",{ref:s,id:i,className:Fa("text-sm font-medium text-destructive",t),...r,children:o}):null});xr.displayName="FormMessage";const Nr=lt.Root,wr=lt.Group,kr=lt.Value,Sr=r.forwardRef(({className:a,children:r,...s},n)=>t(lt.Trigger,{ref:n,className:Fa("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",a),...s,children:[r,e(lt.Icon,{asChild:!0,children:e(_,{className:"h-4 w-4 opacity-50"})})]}));Sr.displayName=lt.Trigger.displayName;const Cr=r.forwardRef(({className:t,...a},r)=>e(lt.ScrollUpButton,{ref:r,className:Fa("flex cursor-default items-center justify-center py-1",t),...a,children:e(E,{className:"h-4 w-4"})}));Cr.displayName=lt.ScrollUpButton.displayName;const _r=r.forwardRef(({className:t,...a},r)=>e(lt.ScrollDownButton,{ref:r,className:Fa("flex cursor-default items-center justify-center py-1",t),...a,children:e(_,{className:"h-4 w-4"})}));_r.displayName=lt.ScrollDownButton.displayName;const Er=r.forwardRef(({className:a,children:r,position:s="popper",container:n,collisionBoundary:i,...o},l)=>e(lt.Portal,{container:n,children:t(lt.Content,{ref:l,className:Fa("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"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:s,collisionBoundary:i,...o,children:[e(Cr,{}),e(lt.Viewport,{className:Fa("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e(_r,{})]})}));Er.displayName=lt.Content.displayName;const Pr=r.forwardRef(({className:t,...a},r)=>e(lt.Label,{ref:r,className:Fa("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));Pr.displayName=lt.Label.displayName;const Ir=r.forwardRef(({className:a,children:r,...s},n)=>t(lt.Item,{ref:n,className:Fa("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",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(lt.ItemIndicator,{children:e(P,{className:"h-4 w-4"})})}),e(lt.ItemText,{children:r})]}));Ir.displayName=lt.Item.displayName;const Tr=r.forwardRef(({className:t,...a},r)=>e(lt.Separator,{ref:r,className:Fa("-mx-1 my-1 h-px bg-muted",t),...a}));Tr.displayName=lt.Separator.displayName;const Ar=r.forwardRef(({className:t,...a},r)=>e(dt.Root,{ref:r,className:Fa("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e(dt.Indicator,{className:Fa("flex items-center justify-center text-current"),children:e(P,{className:"h-4 w-4"})})}));Ar.displayName=dt.Root.displayName;const Rr=r.forwardRef(({className:t,...a},r)=>e("textarea",{className:Fa("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",t),ref:r,...a}));Rr.displayName="Textarea";const Or=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",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-white hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Lr=r.forwardRef(({className:t,variant:a,...r},s)=>e("div",{ref:s,className:Fa(Or({variant:a}),t),...r}));Lr.displayName="Badge";const Fr={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function jr({size:t="md",className:a}){return e(I,{className:Fa("animate-spin text-muted-foreground",Fr[t],a)})}function Dr({isLoading:r,children:s,className:n,type:i="spinner",size:o="md"}){return r?"overlay"===i?t("div",{className:Fa("relative",n),children:[s,e("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e(jr,{size:o})})]}):e("div","skeleton"===i?{className:Fa("animate-pulse",n),children:e("div",{className:"bg-muted rounded-md h-full w-full"})}:{className:Fa("flex items-center justify-center py-8",n),children:e(jr,{size:o})}):e(a,{children:s})}const Mr=({...t})=>e(k,{className:"toaster group",position:"top-center",expand:!1,closeButton:!0,icons:{success:e(L,{className:"h-4 w-4"}),info:e(O,{className:"h-4 w-4"}),warning:e(R,{className:"h-4 w-4"}),error:e(A,{className:"h-4 w-4"}),loading:e(T,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-[#E0FBE8] !border-[#E0FBE8]",error:"!bg-[#FEE1E1] !border-[#FEE1E1]",warning:"!bg-[#FEF3C8] !border-[#FEF3C8]",info:"!bg-[#FFFFFF] !border-border"}},...t}),zr=ct.Root,$r=ct.Trigger,Ur=r.forwardRef(({className:t,align:a="center",sideOffset:r=4,container:s,...n},i)=>e(ct.Portal,{container:s,children:e(ct.Content,{ref:i,align:a,sideOffset:r,className:Fa("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",t),...n})}));Ur.displayName=ct.Content.displayName;const Vr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));Vr.displayName="Command";const qr=({children:t,...a})=>e("div",{...a,children:e(Vr,{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:t})}),Br=r.forwardRef(({className:t,...a},r)=>e("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e("input",{ref:r,className:Fa("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",t),...a})}));Br.displayName="CommandInput";const Wr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));Wr.displayName="CommandList";const Hr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("py-6 text-center text-sm text-muted-foreground",t),...a}));Hr.displayName="CommandEmpty";const Kr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("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",t),...a}));Kr.displayName="CommandGroup";const Qr=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("-mx-1 h-px bg-border",t),...a}));Qr.displayName="CommandSeparator";const Gr=r.forwardRef(({className:t,disabled:a,onSelect:r,value:s,...n},i)=>e("div",{ref:i,className:Fa("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",t),"data-disabled":a,onClick:()=>!a&&r?.(s||""),...n}));Gr.displayName="CommandItem";const Jr=({className:t,...a})=>e("span",{className:Fa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function Xr({className:t,...a}){return e("div",{className:Fa("animate-pulse rounded-md bg-muted",t),...a})}Jr.displayName="CommandShortcut";const Yr={},Zr=(e,t,a,r)=>{rs(a)&&Yr[a]||(rs(a)&&(Yr[a]=new Date),((e,t,a,r)=>{const s=[a,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);rs(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console})(e,t,a,r))},es=(e,t)=>()=>{if(e.isInitialized)t();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),t()};e.on("initialized",a)}},ts=(e,t,a)=>{e.loadNamespaces(t,es(e,a))},as=(e,t,a,r)=>{if(rs(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(t)>-1)return ts(e,a,r);a.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,es(e,r))},rs=e=>"string"==typeof e,ss=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ns={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},is=e=>ns[e];let os={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(ss,is)};let ls;const ds={type:"3rdParty",init(e){((e={})=>{os={...os,...e}})(e.options.react),(e=>{ls=e})(e)}},cs=n();class us{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var ms,hs={exports:{}},ps={};var fs,gs,bs={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.development.js
|
|
@@ -7,4 +7,4 @@ import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import*as r from
|
|
|
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
|
-
*/var Ts=(Ps||(Ps=1,"production"===process.env.NODE_ENV?Ss.exports=function(){if(ks)return Cs;ks=1;var e=s,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=e.useState,r=e.useEffect,n=e.useLayoutEffect,i=e.useDebugValue;function o(e){var a=e.getSnapshot;e=e.value;try{var r=a();return!t(e,r)}catch(s){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var s=t(),l=a({inst:{value:s,getSnapshot:t}}),d=l[0].inst,c=l[1];return n(function(){d.value=s,d.getSnapshot=t,o(d)&&c({inst:d})},[e,s,t]),r(function(){return o(d)&&c({inst:d}),e(function(){o(d)&&c({inst:d})})},[e]),i(s),s};return Cs.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,Cs}():Ss.exports=(_s||(_s=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!a(e,r)}catch(s){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=s,a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useState,n=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue,l=!1,d=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(s,c){l||void 0===t.startTransition||(l=!0);var u=c();if(!d){var m=c();a(u,m)||(d=!0)}var h=(m=r({inst:{value:u,getSnapshot:c}}))[0].inst,p=m[1];return i(function(){h.value=u,h.getSnapshot=c,e(h)&&p({inst:h})},[s,u,c]),n(function(){return e(h)&&p({inst:h}),s(function(){e(h)&&p({inst:h})})},[s]),o(u),u};Es.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Es)),Ss.exports);const Is={t:(e,t)=>{return ps(t)?t:"object"==typeof(a=t)&&null!==a&&ps(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e;var a},ready:!1},As=()=>()=>{},Rs=(e,t={})=>{const{i18n:a}=t,{i18n:r,defaultNS:s}=i(Ns)||{},n=a||r||ys;n&&!n.reportNamespaces&&(n.reportNamespaces=new ws),n||cs(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const m=o(()=>({...vs,...n?.options?.react,...t}),[n,t]),{useSuspense:h,keyPrefix:p}=m,f=e||s||n?.options?.defaultNS,g=ps(f)?[f]:f||["translation"],b=o(()=>g,g);n?.reportNamespaces?.addUsedNamespaces?.(b);const v=l(0),y=d(e=>{if(!n)return As;const{bindI18n:t,bindI18nStore:a}=m,r=()=>{v.current+=1,e()};return t&&n.on(t,r),a&&n.store.on(a,r),()=>{t&&t.split(" ").forEach(e=>n.off(e,r)),a&&a.split(" ").forEach(e=>n.store.off(e,r))}},[n,m]),x=l(),N=d(()=>{if(!n)return Is;const e=!(!n.isInitialized&&!n.initializedStoreOnce)&&b.every(e=>((e,t,a={})=>t.languages&&t.languages.length?t.hasLoadedNamespace(e,{lng:a.lng,precheck:(t,r)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):(cs(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0))(e,n,m)),a=t.lng||n.language,r=v.current,s=x.current;if(s&&s.ready===e&&s.lng===a&&s.keyPrefix===p&&s.revision===r)return s;const i={t:n.getFixedT(a,"fallback"===m.nsMode?b:b[0],p),ready:e,lng:a,keyPrefix:p,revision:r};return x.current=i,i},[n,b,p,m,t.lng]),[w,k]=c(0),{t:S,ready:C}=Ts.useSyncExternalStore(y,N,N);u(()=>{if(n&&!C&&!h){const e=()=>k(e=>e+1);t.lng?hs(n,t.lng,b,e):ms(n,b,e)}},[n,t.lng,b,C,h,w]);const _=n||{},P=l(null),E=l(),T=e=>{const t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;const a=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(a,"__original"))try{Object.defineProperty(a,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch(r){}return a},I=o(()=>{const e=_,t=e?.language;let a=e;e&&(P.current&&P.current.__original===e?E.current!==t?(a=T(e),P.current=a,E.current=t):a=P.current:(a=T(e),P.current=a,E.current=t));const r=[S,a,C];return r.t=S,r.i18n=a,r.ready=C,r},[S,_,C,_.resolvedLanguage,_.language,_.languages]);if(n&&h&&!C)throw new Promise(e=>{const a=()=>e();t.lng?hs(n,t.lng,b,a):ms(n,b,a)});return I};function Os({i18n:e,defaultNS:t,children:a}){const r=o(()=>({i18n:e,defaultNS:t}),[e,t]);return m(Ns.Provider,{value:r},a)}const Ls=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function js({multiple:a,options:r,value:s,onChange:n,getOptionValue:i,getOptionLabel:l,placeholder:d,label:u,icon:m,emptyMessage:h,searchPlaceholder:p,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:y,popoverContainer:x,onOpen:N,onClose:w}){const{t:k}=Rs(),[S,P]=c(!1),[T,I]=c(""),A=o(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=o(()=>{if(!x)return;let e=x,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[x]),O=o(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),L=o(()=>{if(!T)return O;const e=Ls(T);return O.filter(t=>Ls(t.label).includes(e))},[O,T]),j=o(()=>O.filter(e=>A.includes(e.value)),[O,A]),F=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?A.filter(t=>t!==e):"")},M=y?j.slice(0,y):j,D=y&&j.length>y?j.length-y:0;return t("div",{className:Aa("space-y-2",b),children:[u&&t(Va,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t(Jr,{open:S,onOpenChange:e=>{P(e),e?N?.():(I(""),w?.())},modal:!1,children:[e(Xr,{asChild:!0,children:t(Da,{variant:"outline",role:"combobox","aria-expanded":S,disabled:f,className:Aa("w-full justify-between min-h-10 h-auto",0===j.length&&"text-muted-foreground"),children:[0===j.length?t("span",{className:"flex items-center gap-2",children:[m&&e(m,{className:"h-4 w-4"}),d]}):a?t("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[M.map(a=>t(Er,{variant:"secondary",className:"gap-1 pr-1",children:[a.label,e("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&F(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>F(a.value,e),children:e(C,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),D>0&&t(Er,{variant:"outline",className:"gap-1",children:["+",D]})]}):t("span",{className:"flex items-center gap-2",children:[m&&e(m,{className:"h-4 w-4"}),j[0]?.label]}),e(_,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e(Yr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:t(Zr,{children:[e(ts,{placeholder:p,value:T,onChange:e=>I(e.target.value)}),e(as,{children:0===r.length?e(rs,{children:h}):0===L.length?e(rs,{children:k("no_results")}):e(ss,{children:L.map(r=>t(is,{value:r.value,onSelect:()=>(e=>{if(n)if(a){const t=A.includes(e)?A.filter(t=>t!==e):[...A,e];n(t)}else n(e),P(!1)})(r.value),className:"cursor-pointer",children:[e(E,{className:Aa("mr-2 h-4 w-4",A.includes(r.value)?"opacity-100":"opacity-0")}),r.label]},r.value))})})]})})]})]})}function Fs({multiple:a=!1,options:r,items:s,value:n,onChange:i,onValueChange:o,getOptionValue:l=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:h,searchPlaceholder:p,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:y,sortOptions:x=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:k,onClose:S}){const{t:C}=Rs(),_=s||r||[],P=o||i,E=c||C("select_placeholder"),T=h||C("no_results"),A=p||C("search_placeholder");if(b)return t("div",{className:Aa("space-y-2",y),children:[u&&t(Va,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ls,{className:"h-10 w-full"})]});const R="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return R?t("div",{className:Aa("space-y-2",y),children:[u&&t(Va,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e(I,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:R})]})]}):e(js,{multiple:a,options:_,value:n||(a?[]:""),onChange:P,getOptionValue:l,getOptionLabel:d,placeholder:E,label:u,icon:m,emptyMessage:T,searchPlaceholder:A,disabled:f,required:g,className:y,sortOptions:x,maxDisplayedBadges:N,popoverContainer:w,onOpen:k,onClose:S})}var Ms=Object.defineProperty;class Ds{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let s=0;s<t.length;s++)a[s]=t.charCodeAt(s);const r=new TextDecoder("utf-8").decode(a);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,t){const a=[],r=[];try{t.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";a.push(e),i=!1}if(s.exp&&s.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:a,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:a,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,a)=>{t in e?Ms(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(Ds,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const zs="qualiex_access_token",$s="qualiex_id_token",Us="supabase_token",Vs="oauth_state",qs="oauth_nonce",Bs="selected_alias",Ws="manual_logout",Hs={setAccessToken:e=>localStorage.setItem(zs,e),getAccessToken:()=>localStorage.getItem(zs),setIdToken:e=>localStorage.setItem($s,e),getIdToken:()=>localStorage.getItem($s),getSupabaseToken:()=>localStorage.getItem(Us),setOAuthState:e=>sessionStorage.setItem(Vs,e),getOAuthState:()=>sessionStorage.getItem(Vs),clearOAuthState:()=>sessionStorage.removeItem(Vs),setOAuthNonce:e=>sessionStorage.setItem(qs,e),getOAuthNonce:()=>sessionStorage.getItem(qs),clearOAuthNonce:()=>sessionStorage.removeItem(qs),setSelectedAlias:e=>localStorage.setItem(Bs,e),getSelectedAlias:()=>localStorage.getItem(Bs),clearSelectedAlias:()=>localStorage.removeItem(Bs),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Hs.getAccessToken()||!Hs.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Us,e),Hs._clearValidationCache()},areAllTokensValid:()=>{const e=Hs.getAccessToken(),t=Hs.getIdToken();if(!e||!t)return!1;try{const a=Ds.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Hs.getAccessToken(),a=Hs.getIdToken(),r=Hs.getSupabaseToken();return t&&Hs.isTokenExpired(t)&&(localStorage.removeItem(zs),e=!0),a&&Hs.isTokenExpired(a)&&(localStorage.removeItem($s),e=!0),r&&Hs.isTokenExpired(r)&&(localStorage.removeItem(Us),e=!0),e},clearAll:()=>{localStorage.removeItem(zs),localStorage.removeItem($s),localStorage.removeItem(Us),localStorage.removeItem(Bs),localStorage.removeItem(Ws),sessionStorage.removeItem(Vs),sessionStorage.removeItem(qs)},setManualLogout:()=>localStorage.setItem(Ws,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ws),clearManualLogout:()=>localStorage.removeItem(Ws),isTokenExpired:e=>{try{return Ds.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Hs._validationCache.isValid=!1,Hs._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Hs.getSupabaseToken();if(!e)return!1;if(Hs.isTokenExpired(e))return Hs._clearValidationCache(),Hs._handleExpiredToken(),!1;const t=Date.now();return t-Hs._validationCache.timestamp<Hs._validationCache.cacheValidityMs?Hs._validationCache.isValid:(Hs._validationCache.isValid=!0,Hs._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Hs.isSupabaseTokenValid()?Hs.getSupabaseToken():null,_handleExpiredToken:()=>{Hs.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Hs.isSupabaseTokenValid())return null;const e=Hs.getSupabaseToken();if(!e)return null;try{const t=Ds.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,r=t.place_id||null,s=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:r,placeName:s,payload:t}}catch(t){return Hs._handleExpiredToken(),null}},getCompanyId:e=>{const t=Hs.getAccessToken();if(t)try{const a=Ds.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}const a=Hs.extractTokenData();if(a?.companyId)return a.companyId;const r=Hs.getIdToken();if(r)try{const t=Ds.parseJwtPayload(r);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}return null},getCurrentCompanyId:()=>{const e=Hs.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Hs.getIdToken();if(!e)return[];try{const t=Ds.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var Ks=Object.defineProperty,Qs=(e,t,a)=>((e,t,a)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Gs=new class{constructor(){Qs(this,"errors",[]),Qs(this,"toastCount",0),Qs(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){zr({title:this.getErrorTitle(a),description:a,variant:"destructive"})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){zr({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Js=Object.defineProperty,Xs=(e,t,a)=>((e,t,a)=>t in e?Js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Ys=import.meta.env.VITE_SUPABASE_URL,Zs=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,en=class e{constructor(){Xs(this,"client"),Xs(this,"currentToken",null),Xs(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Zs};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return it(Ys,Zs,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Hs.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),a=Math.floor(Date.now()/1e3);return t.exp>a}catch(t){return Gs.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};Xs(en,"instance");let tn=en;function an(){return tn.getInstance().getClient()}class rn{static async generateToken(e,t,a,r=!1){try{if(!r){const e=Hs.getSupabaseToken();if(e&&Hs.isSupabaseTokenValid())return e}const s=an(),{data:n,error:i}=await s.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(Hs.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&a?.(),null}}}var sn=Object.defineProperty,nn=(e,t,a)=>((e,t,a)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class on{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Hs.getAccessToken(),t=Hs.getSelectedAlias();if(!e||!t)return null;const a=await rn.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(Hs.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}nn(on,"isRegenerating",!1),nn(on,"onLogoutCallback",null);class ln{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Hs.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var dn=Object.defineProperty;class cn{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await on.attemptRegeneration()?(this.isRetrying=!1,!0):(ln.handleError(e),this.isRetrying=!1,!1)}catch(r){return ln.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Hs.getAccessToken();return e?Hs.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(cn,"isRetrying",!1);var un=Object.defineProperty,mn=(e,t,a)=>((e,t,a)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const hn=new class{constructor(){mn(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=cn.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Hs.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){const t=e.status||e.userStatus||"",a=void 0!==e.isActive?e.isActive:"active"===t.toLowerCase()||"ACTIVE"===t.toUpperCase();return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0,isActive:a,status:t||void 0}}async fetchUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Gs.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=a}if(!Array.isArray(r))return Gs.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(a){if(await cn.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Gs.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Gs.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Gs.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const s=a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex";return Gs.handleError(s,!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(r){return Gs.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),r=new Map;return a.forEach(e=>{r.set(e.userId,e)}),r}async fetchAllUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"all"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Gs.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Gs.handleError("[QualiexApi] Resposta não é um array",!1),[])}catch(a){if(await cn.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"all"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Gs.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Gs.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Gs.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Gs.handleError(a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async getUsers(e){const t=Hs.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async getAllUsers(e){const t=Hs.extractTokenData();return t&&t.companyId?this.fetchAllUsers(e,t.companyId):[]}},pn={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"}},fn={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},gn={debounceDelay:500},bn=()=>{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},vn={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},yn={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},xn=()=>yn,Nn={isQualiex:"true"===import.meta.env.VITE_IS_QUALIEX},wn={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}`}};function kn(e,t){const a=xn(),r=t||a.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Sn(e,t){const a=xn(),r=t||a.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Cn(e,t){const a=xn(),r=t||a.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function _n(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||kn(e.idField),emailField:e.emailField||Sn(e.idField),usernameField:e.usernameField||Cn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:kn(e),emailField:Sn(e),usernameField:Cn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Pn=new Map;class En{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,r=Pn.get(a);if(r&&Date.now()-r.timestamp<3e5)return r.users;const s=await hn.fetchUsers(e,t);return Pn.set(a,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const a=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const r={...e};for(const s of t){const t=e[s.idField];if(!t)continue;const n=a.get(t);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||n.displayName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!Hs.areAllTokensValid())return e;const a=Hs.extractTokenData();if(!a)return e;const{alias:r,companyId:s}=a;if(!r||!s)return e;const n=_n(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(r,s),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(a){return Gs.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const Tn=["responsible_name"],In=e=>Tn.includes(e);function An(e,t,a){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=r,c=()=>{if(!Hs.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return an().schema(o).from(s)},u=(e,t,a,r)=>{let s=c().select(i||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?s=s.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?s=s.not(e,"is",null):"is_null"===t.operator&&(s=s.is(e,null)):null!==t&&(s=s.eq(e,t)))}),s=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(s,e);const o=t.includes(".");return o||In(t)||(s=s.order(t,{ascending:"asc"===a})),{query:s,isForeignKey:o}},m=async(e,t,a,s,n)=>{const i=_n(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),o=t.includes(".");if(In(t)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const d=await En.enrichWithUserData(i.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let c;c=o?d.sort((e,r)=>{const s=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],r)||"",i=String(s).localeCompare(String(n),"pt-BR");return"asc"===a?i:-i}):((e,t,a)=>[...e].sort((e,r)=>{const s=e[t]||"",n=r[t]||"",i=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?i:-i}))(d,t,a);const u=((e,t=1,a=25)=>{const r=(t-1)*a,s=r+a,n=e.slice(r,s);return{data:n,pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:n.length,totalCount:e.length,itemsPerPage:a,hasNextPage:s<e.length,hasPreviousPage:t>1}}})(c,s,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await En.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...i}=e;return{search:t,sortField:a,sortDirection:r,page:s,limit:n,additionalFilters:i}})(e),{query:h}=u(t,a,n,c),p=((e,t,a)=>{const r=(t-1)*a,s=r+a-1;return e.range(r,s)})(h,i,o),{data:f,error:g,count:b}=await p;if(g)throw new Error(`Error fetching ${s}: ${g.message}`);let v=((e,t,a,r)=>{const s=Math.ceil((t||0)/r);return{data:e,currentPage:a,totalPages:s,totalItems:t||0,itemsPerPage:r,hasNextPage:a<s,hasPreviousPage:a>1}})(f||[],b,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const t=_n(r.userIdFields,r.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(v.data)){const e=await m(v.data,a,n,i,o);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:t,error:a}=await c().select(i||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${s}: ${a.message}`);return t},async create(e){const t=Ra(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:r,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,t){const a={...Ra(t),updated_at:(new Date).toISOString()},{data:r,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${s}: ${a.message}`)}}}const Rn=()=>{Hs.clearManualLogout()},On=e=>e?.placeId||null,Ln=e=>e?.placeName||null,jn=e=>({placeId:On(e),placeName:Ln(e)}),Fn=class{static async initialize(){try{if(!Hs.hasAllTokens()||!Hs.areAllTokensValid())return Hs.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=Hs.getAccessToken(),a=Hs.getIdToken();Rn();const r=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),n=this.extractAliasFromAccessToken(t),i=Hs.extractTokenData(),o=i?.alias;let l=null;if(o&&s.some(e=>e.alias===o))l=o;else{const e=Hs.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);l=t?e:n||s[0]?.alias||null}!Hs.isSupabaseTokenValid()&&l&&await on.attemptRegeneration();let d=null;if(l){const e=Hs.getCompanyId(l),t=s.find(e=>e.alias===l);t&&(d={id:e||t.id,name:t.name,alias:t.alias})}let c=null,u=null;if(r?.id&&l){const t=Hs.getCompanyId(l);if(t)try{const e=(await hn.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=jn(e);c=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:s,selectedUnit:d,userId:r?.id||null,userAlias:r?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=an(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=Hs.generateOAuthState();Hs.setOAuthState(e);const t=Hs.generateOAuthNonce();Hs.setOAuthNonce(t);const a=`${window.location.origin}/callback`,r=new URL(pn.oauth.authUrl);r.searchParams.set("client_id",pn.oauth.clientId),r.searchParams.set("response_type",pn.oauth.responseType),r.searchParams.set("scope",pn.oauth.scope),r.searchParams.set("redirect_uri",a),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),bn(),window.location.href=r.toString()}static async processCallback(){try{if(Hs.hasAllTokens()){if(!Hs.getValidSupabaseToken()){Hs.getAccessToken();await on.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),r=a("access_token"),s=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!r||!s)throw new Error("Tokens não encontrados na URL de callback");Hs.setAccessToken(r),Hs.setIdToken(s),Rn();const i=this.extractAliasFromAccessToken(r);if(i)Hs.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(s);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Hs.setSelectedAlias(e[0].alias)}if(!await on.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Hs.clearOAuthState(),Hs.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Hs.setManualLogout(),Hs.clearAll(),window.location.href="/login"}static decodeToken(e){return Ds.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)a.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=t[e].split("|");r&&s&&a.push({id:"",alias:r.trim(),name:s.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};on.setLogoutCallback(()=>{Fn.logout()});let Mn=Fn;const Dn=n(void 0),zn=({children:t})=>{const[a,r]=c({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=ot()}catch{}const[n,i]=c(!1),[l,m]=c(0),h=d(e=>{r(t=>({...t,...e}))},[]),p=d(e=>{r(t=>({...t,isLoading:e}))},[]),f=d(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),g=d(async e=>{try{p(!0);const r=Hs.getAccessToken();if(!r)return;const n=await rn.generateToken(r,e.alias,void 0,!0);if(!n)return;Hs.setSupabaseToken(n),Hs.setSelectedAlias(e.alias);const i=Hs.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Hs.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let c=null,u=null;if(a.user?.id&&o&&l)try{const e=(await hn.fetchActiveUsersMap(o,l)).get(a.user.id);if(e){const t=jn(e);c=t.placeId,u=t.placeName}}catch(t){}h({alias:o,selectedUnit:d,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{p(!1)}},[h,s,p,a.user]),b=d(async()=>await Mn.processCallback(),[]),v=d(async()=>{Mn.logout(),f(),s&&await s.clear()},[f,s]),y=d(e=>{i(e)},[]),x=d(()=>{m(e=>e+1)},[]),N=d(()=>{m(e=>e+1)},[]);u(()=>{if(!a.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Hs.areAllTokensValid()||e&&v())},6e5);return()=>{e=!1,clearInterval(t)}},[a.isAuthenticated,v]),u(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Mn.initialize();if(!e)return;t&&t.isAuthenticated?h({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&p(!1)}catch(t){e&&(ln.handleError(t),p(!1))}})(),()=>{e=!1}},[h,p,v]);const w=o(()=>({...a,logout:v,processCallback:b,switchUnit:g,availableUnits:a.companies,isSearchVisible:n,setSearchVisible:y,clearSearch:x,refreshData:N}),[a.user,a.companies,a.alias,a.isAuthenticated,a.isLoading,a.selectedUnit,a.userId,a.userAlias,a.placeId,a.placeName,a.activePlaceId,a.activePlaceName,v,b,g,n,y,x,N]);return e(Dn.Provider,{value:w,children:t})},$n=()=>{const e=i(Dn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Un({queryKey:e,service:t,entityName:a,searchFields:r,additionalFilters:s={},onSuccess:n}){const[i,l]=ut(),u=ot(),{alias:m,userId:h,isAuthenticated:p}=$n(),f=d(t=>{const a=`${e}_${t}`,r=i.get(a);return r||(i.get(t)||"")},[i,e]),g=f("search"),b=f("sortField")||fn.sorting.defaultField,v=f("sortDirection")||fn.sorting.defaultDirection,y=parseInt(f("page")||"1"),x=parseInt(f("limit")||String(fn.pagination.defaultPageSize)),N=g,k=o(()=>({search:N,sortField:b,sortDirection:v,page:y,limit:x,...s}),[N,b,v,y,x,s]),S=d(()=>t.getAll(k),[t,k]),C=lt({queryKey:[e,m,h,k],queryFn:S,enabled:!!m&&p});if(!C)throw new Error(`useCrud: Query initialization failed for "${a}". Ensure QueryClientProvider is configured in your app root.`);const _=dt({mutationFn:t.create,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(wn.success.created(a)),n?.()},onError:e=>{w.error(`${wn.error.create(a)}: ${e.message}`)}}),P=dt({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(wn.success.updated(a)),n?.()},onError:e=>{w.error(`${wn.error.update(a)}: ${e.message}`)}}),E=dt({mutationFn:t.delete,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(wn.success.deleted(a))},onError:e=>{w.error(`${wn.error.delete(a)}: ${e.message}`)}}),T=d(t=>{const a={...Object.fromEntries(i)};Object.entries(t).forEach(([t,r])=>{const s=`${e}_${t}`;""===r||0===r?delete a[s]:a[s]=String(r)}),delete a.sortField,delete a.sortDirection,l(a)},[i,l,e]),I=d(e=>{T({search:e,page:1})},[T]),A=d(e=>{T({sortField:e,sortDirection:b===e&&"asc"===v?"desc":"asc",page:1})},[b,v,T]),R=d(e=>{T({page:e})},[T]),O=d(e=>{T({limit:e,page:1})},[T]),L=d(()=>{const t=Object.fromEntries(i),a=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));l(r)},[l,i,e]),[j,F]=c([]),M=d(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),D=d(()=>{const e=C?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[C?.data?.data]),z=d(()=>{F([])},[]),$=o(()=>{const e=C?.data?.data.map(e=>e.id)||[];return e.length>0&&j.length===e.length},[j,C?.data?.data]),U=dt({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,r)=>{u.invalidateQueries({queryKey:[e]}),w.success(`${r.length} ${a}(s) deletado(s) com sucesso`),z()},onError:e=>{w.error(`Erro ao deletar itens: ${e.message}`)}}),V=d((e,t)=>{const a=t?t(e):e;e.id?P.mutate({id:e.id,data:a}):_.mutate({...a,alias:m})},[m,_,P]);return{entities:C?.data?.data||[],pagination:{data:C?.data?.data||[],currentPage:C?.data?.currentPage||1,totalPages:C?.data?.totalPages||1,totalItems:C?.data?.totalItems||0,itemsPerPage:C?.data?.itemsPerPage||fn.pagination.defaultPageSize,hasNextPage:C?.data?.hasNextPage||!1,hasPreviousPage:C?.data?.hasPreviousPage||!1},isLoading:C?.isLoading??!0,isCreating:_?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:E?.isPending??!1,error:C?.error||null,searchTerm:g,sortField:b,sortDirection:v,currentPage:y,itemsPerPage:x,queryKey:e,createEntity:_.mutate,updateEntity:(e,t)=>P.mutate({id:e,data:t}),deleteEntity:E.mutate,save:V,handleSearch:I,handleSort:A,handlePageChange:R,handleItemsPerPageChange:O,clearFilters:L,refetch:C.refetch,selectedIds:j,selectItem:M,selectAll:D,clearSelection:z,isAllSelected:$,bulkDelete:e=>U.mutateAsync(e),isBulkDeleting:U.isPending}}function Vn(e){const t=An({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,r)=>Un({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:r})}}const qn=ft.Root,Bn=ft.Trigger,Wn=ft.Portal,Hn=r.forwardRef(({className:t,...a},r)=>e(ft.Overlay,{className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:r}));Hn.displayName=ft.Overlay.displayName;const Kn=r.forwardRef(({className:a,...r},s)=>t(Wn,{children:[e(Hn,{}),e(ft.Content,{ref:s,className:Aa("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 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",a),...r})]}));Kn.displayName=ft.Content.displayName;const Qn=({className:t,...a})=>e("div",{className:Aa("flex flex-col space-y-2 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-6 rounded-t-lg",t),...a});Qn.displayName="AlertDialogHeader";const Gn=({className:t,...a})=>e("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Gn.displayName="AlertDialogFooter";const Jn=r.forwardRef(({className:t,...a},r)=>e(ft.Title,{ref:r,className:Aa("text-lg font-semibold",t),...a}));Jn.displayName=ft.Title.displayName;const Xn=r.forwardRef(({className:t,...a},r)=>e(ft.Description,{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));Xn.displayName=ft.Description.displayName;const Yn=r.forwardRef(({className:t,...a},r)=>e(ft.Action,{ref:r,className:Aa(Ma(),t),...a}));Yn.displayName=ft.Action.displayName;const Zn=r.forwardRef(({className:t,...a},r)=>e(ft.Cancel,{ref:r,className:Aa(Ma({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));Zn.displayName=ft.Cancel.displayName;const ei=({open:a,onOpenChange:r,item:s,onConfirm:n,entityName:i="item",isDeleting:o=!1})=>{const{t:l}=Rs(),d=()=>{r(!1)};return s?e(qn,{open:a,onOpenChange:d,children:t(Kn,{className:"sm:max-w-[420px] bg-white",children:[t("button",{onClick:d,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",children:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Fechar"})]}),t("div",{className:"flex flex-col items-center text-center space-y-3 py-2",children:[e("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e(A,{className:"w-8 h-8 text-destructive"})}),e(Jn,{className:"text-xl font-semibold",children:"Tem certeza?"}),e(Xn,{asChild:!0,children:t("div",{className:"text-sm text-muted-foreground",children:[e("p",{children:"Você está prestes a excluir este registro."}),e("p",{children:"Esta ação não pode ser desfeita."})]})})]}),t("div",{className:"flex flex-row gap-2 justify-center mt-6",children:[e(Yn,{onClick:()=>{s&&(n(s),r(!1))},disabled:o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:l(o?"deleting":"confirm_delete")}),e(Zn,{onClick:d,className:"mt-0 border-none bg-transparent hover:bg-muted text-foreground shadow-none",children:"Cancelar"})]})]})}):null},ti=r.forwardRef(({className:t,...a},r)=>e("table",{ref:r,className:Aa("w-full caption-bottom text-sm",t),...a}));ti.displayName="Table";const ai=r.forwardRef(({className:t,...a},r)=>e("thead",{ref:r,className:Aa("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));ai.displayName="TableHeader";const ri=r.forwardRef(({className:t,...a},r)=>e("tbody",{ref:r,className:Aa("[&_tr:last-child]:border-0",t),...a}));ri.displayName="TableBody";const si=r.forwardRef(({className:t,...a},r)=>e("tfoot",{ref:r,className:Aa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));si.displayName="TableFooter";const ni=r.forwardRef(({className:t,...a},r)=>e("tr",{ref:r,className:Aa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",t),...a}));ni.displayName="TableRow";const ii=r.forwardRef(({className:t,...a},r)=>e("th",{ref:r,className:Aa("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));ii.displayName="TableHead";const oi=r.forwardRef(({className:t,...a},r)=>e("td",{ref:r,className:Aa("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",t),...a}));oi.displayName="TableCell";const li=r.forwardRef(({className:t,...a},r)=>e("caption",{ref:r,className:Aa("mt-4 text-sm text-muted-foreground",t),...a}));function di({rows:a=5,columns:r=4}){return e("div",{className:"w-full",children:t("div",{className:"rounded-md border",children:[e("div",{className:"border-b bg-muted/50 px-4 py-3",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((t,a)=>e(ls,{className:"h-4 w-24"},a))})}),e("div",{children:Array.from({length:a}).map((t,a)=>e("div",{className:"border-b px-4 py-3 last:border-0",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((t,a)=>e(ls,{className:"h-4 w-20"},a))})},a))})]})})}function ci({count:a=3}){return e("div",{className:"space-y-4",children:Array.from({length:a}).map((a,r)=>t(qa,{children:[t(Ba,{children:[e(ls,{className:"h-4 w-3/4"}),e(ls,{className:"h-3 w-1/2"})]}),e(Ka,{children:t("div",{className:"space-y-2",children:[e(ls,{className:"h-3 w-full"}),e(ls,{className:"h-3 w-2/3"})]})})]},r))})}function ui({fields:a=4}){return t("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,r)=>t("div",{className:"space-y-2",children:[e(ls,{className:"h-4 w-24"}),e(ls,{className:"h-10 w-full"})]},r)),t("div",{className:"flex justify-end space-x-2 pt-4",children:[e(ls,{className:"h-10 w-20"}),e(ls,{className:"h-10 w-20"})]})]})}function mi(){return t("div",{className:"flex items-center justify-between p-4 border-b",children:[t("div",{className:"flex items-center space-x-3",children:[e(ls,{className:"h-8 w-8 rounded-full"}),e(ls,{className:"h-6 w-32"})]}),t("div",{className:"flex items-center space-x-2",children:[e(ls,{className:"h-8 w-8"}),e(ls,{className:"h-8 w-24"})]})]})}function hi(){return e("div",{className:"w-64 border-r bg-muted/10",children:t("div",{className:"p-4",children:[e(ls,{className:"h-8 w-32 mb-6"}),e("div",{className:"space-y-2",children:Array.from({length:6}).map((a,r)=>t("div",{className:"flex items-center space-x-3 p-2",children:[e(ls,{className:"h-4 w-4"}),e(ls,{className:"h-4 w-20"})]},r))})]})})}li.displayName="TableCaption";const pi={default:O,search:R,error:I};function fi({icon:a,title:r,description:s,action:n,className:i,variant:o="default"}){const l=a?()=>a:pi[o];return t("div",{className:Aa("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[e("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e(l,{className:"h-8 w-8 text-muted-foreground"})}),e("h3",{className:"text-lg font-semibold mb-2",children:r}),s&&e("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),n&&e(Da,{onClick:n.onClick,variant:"outline",children:n.label})]})}const gi=gt.Root,bi=gt.Trigger,vi=gt.Group,yi=gt.Portal,xi=gt.Sub,Ni=gt.RadioGroup,wi=r.forwardRef(({className:a,inset:r,children:s,...n},i)=>t(gt.SubTrigger,{ref:i,className:Aa("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",a),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));wi.displayName=gt.SubTrigger.displayName;const ki=r.forwardRef(({className:t,...a},r)=>e(gt.SubContent,{ref:r,className:Aa("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));ki.displayName=gt.SubContent.displayName;const Si=r.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e(gt.Portal,{children:e(gt.Content,{ref:s,sideOffset:a,className:Aa("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-white shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-gray-800 dark:border-gray-700",t),...r})}));Si.displayName=gt.Content.displayName;const Ci=r.forwardRef(({className:t,inset:a,...r},s)=>e(gt.Item,{ref:s,className:Aa("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...r}));Ci.displayName=gt.Item.displayName;const _i=r.forwardRef(({className:a,children:r,checked:s,...n},i)=>t(gt.CheckboxItem,{ref:i,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(gt.ItemIndicator,{children:e(E,{className:"h-4 w-4"})})}),r]}));_i.displayName=gt.CheckboxItem.displayName;const Pi=r.forwardRef(({className:a,children:r,...s},n)=>t(gt.RadioItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(gt.ItemIndicator,{children:e(j,{className:"h-2 w-2 fill-current"})})}),r]}));Pi.displayName=gt.RadioItem.displayName;const Ei=r.forwardRef(({className:t,inset:a,...r},s)=>e(gt.Label,{ref:s,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...r}));Ei.displayName=gt.Label.displayName;const Ti=r.forwardRef(({className:t,...a},r)=>e(gt.Separator,{ref:r,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Ti.displayName=gt.Separator.displayName;const Ii=({className:t,...a})=>e("span",{className:Aa("ml-auto text-xs tracking-widest opacity-60",t),...a});Ii.displayName="DropdownMenuShortcut";const Ai=({onEdit:r,onDelete:s,onToggleStatus:n,isActive:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d})=>{const{t:c}=Rs(),u=[];if(r){const e={icon:F,label:c("edit"),onClick:r};u.push(e)}if(l.forEach(e=>{u.push(e)}),n){const e={icon:i?M:D,label:c(i?"deactivate":"activate"),onClick:n};u.push(e)}if(o&&s){const e={icon:z,label:c("delete"),onClick:s,destructive:!0};u.push(e)}return e(a,"dropdown"===d?{children:u.map((a,r)=>t(Ci,{onClick:a.onClick,className:a.destructive?"text-destructive":"",children:[e(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},r))}:{children:u.map((a,r)=>t(Da,{variant:"ghost",size:"sm",onClick:a.onClick,className:"w-full justify-start px-2 py-1.5 text-sm font-normal h-7 "+(a.destructive?"text-destructive hover:text-destructive":""),children:[e(a.icon,{className:"h-4 w-4 mr-2"}),a.label]},r))})},Ri=({onEdit:a,onDelete:r,canDelete:s=!0,onToggleStatus:n,isActive:i=!0,customActions:o=[]})=>t(gi,{children:[e(bi,{asChild:!0,children:e(Da,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e(S,{size:12})})}),e(Si,{align:"end",className:"bg-background border border-border shadow-lg w-[160px]",children:e(Ai,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:r?e=>{e?.stopPropagation(),r?.()}:void 0,onToggleStatus:n?e=>{e?.stopPropagation(),n?.()}:void 0,isActive:i,canDelete:s&&!!r,customActions:o,renderAs:"dropdown"})})]}),Oi=bt.Root,Li=bt.Trigger,ji=bt.Group,Fi=bt.Portal,Mi=bt.Sub,Di=bt.RadioGroup,zi=r.forwardRef(({className:a,inset:r,children:s,...n},i)=>t(bt.SubTrigger,{ref:i,className:Aa("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",a),...n,children:[s,e(L,{className:"ml-auto h-4 w-4"})]}));zi.displayName=bt.SubTrigger.displayName;const $i=r.forwardRef(({className:t,...a},r)=>e(bt.SubContent,{ref:r,className:Aa("z-50 min-w-[8rem] overflow-hidden rounded-md 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",t),...a}));$i.displayName=bt.SubContent.displayName;const Ui=r.forwardRef(({className:t,...a},r)=>e(bt.Portal,{children:e(bt.Content,{ref:r,className:Aa("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",t),...a})}));Ui.displayName=bt.Content.displayName;const Vi=r.forwardRef(({className:t,inset:a,...r},s)=>e(bt.Item,{ref:s,className:Aa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...r}));Vi.displayName=bt.Item.displayName;const qi=r.forwardRef(({className:a,children:r,checked:s,...n},i)=>t(bt.CheckboxItem,{ref:i,className:Aa("relative flex 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",a),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(bt.ItemIndicator,{children:e(E,{className:"h-4 w-4"})})}),r]}));qi.displayName=bt.CheckboxItem.displayName;const Bi=r.forwardRef(({className:a,children:r,...s},n)=>t(bt.RadioItem,{ref:n,className:Aa("relative flex 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",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(bt.ItemIndicator,{children:e(j,{className:"h-2 w-2 fill-current"})})}),r]}));Bi.displayName=bt.RadioItem.displayName;const Wi=r.forwardRef(({className:t,inset:a,...r},s)=>e(bt.Label,{ref:s,className:Aa("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...r}));Wi.displayName=bt.Label.displayName;const Hi=r.forwardRef(({className:t,...a},r)=>e(bt.Separator,{ref:r,className:Aa("-mx-1 my-1 h-px bg-border",t),...a}));Hi.displayName=bt.Separator.displayName;const Ki=({className:t,...a})=>e("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Ki.displayName="ContextMenuShortcut";const Qi=h(({checked:t,onCheckedChange:a})=>e(Cr,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),Gi=({manager:a,columns:r,onEdit:s,onView:n,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:m,enableBulkActions:h=!1,onNew:p,newButtonLabel:f,showNewButton:g=!0,customActions:b=[],hideActionBar:v=!1})=>{const{t:y}=Rs(),{setSearchVisible:x}=$n(),[N,w]=c(!1);u(()=>(x(!0),()=>x(!1)),[x]),u(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const k=o(()=>(()=>{r.length;let e=0;const t=r.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,r=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:r,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[r]),S=!v&&(p||b.length>0);return N?a.isLoading?e(ci,{count:3}):0===a.entities.length?e(fi,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):t("div",{className:"flex flex-col h-full",children:[S&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:t("div",{className:"flex items-center gap-2",children:[p&&g&&t(Da,{onClick:p,children:[e($,{size:16,className:"mr-2"}),f||y("new")]}),b.map((a,r)=>{const s=a.icon;return t(Da,{onClick:a.action,variant:a.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),a.label]},r)})]})}),e("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(o=>t(Oi,{children:[e(Li,{asChild:!0,children:e(qa,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50",h&&a.selectedIds.includes(o.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?a.selectItem(o.id):s?.(o)},children:e(Ka,{className:"p-4",children:t("div",{className:"flex items-start gap-3",children:[h&&e("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e(Qi,{checked:a.selectedIds.includes(o.id),onCheckedChange:()=>a.selectItem(o.id)})}),t("div",{className:"flex-1",children:[r.map(a=>t("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[t("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(o):String(o[a.key]??"")})]},String(a.key))),(s||n||d)&&e("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(o):e(Ri,{onEdit:s?()=>{s(o)}:void 0,onDelete:l?()=>l(o):void 0,onToggleStatus:i?()=>i(o):void 0,isActive:o.is_actived,customActions:m?m(o):[]})})]})]})})})}),e(Ui,{className:"w-[160px]",children:e(Ai,{onEdit:s?()=>s(o):void 0,onDelete:l?()=>l(o):void 0,onToggleStatus:i?()=>i(o):void 0,isActive:o.is_actived,canDelete:!!l,customActions:m?m(o):[],renderAs:"context"})})]},o.id))})]}):t("div",{className:"flex flex-col h-full",children:[S&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:t("div",{className:"flex items-center gap-2",children:[p&&g&&t(Da,{onClick:p,children:[e($,{size:16,className:"mr-2"}),f||y("new")]}),b.map((a,r)=>{const s=a.icon;return t(Da,{onClick:a.action,variant:a.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),a.label]},r)})]})}),a.isLoading?e(di,{rows:5,columns:r.length}):e("div",{className:"flex flex-col h-full overflow-hidden",children:e("div",{className:"flex-1 overflow-auto",children:t(ti,{className:"table-auto",children:[t("colgroup",{children:[h&&e("col",{style:{width:"50px"}}),k.map((t,a)=>e("col",{style:t.style},a)),e("col",{style:{width:"50px"}})]}),e(ai,{children:t(ni,{children:[h&&e(ii,{className:"w-[50px]",children:e(Qi,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),r.map(r=>{return e(ii,{className:`${r.className||""} ${r.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:r.sortable?()=>a.handleSort(String(r.key)):void 0,children:t("div",{className:"flex items-center "+(r.className?.includes("text-center")?"justify-center":""),children:[r.header,r.sortable&&(s=String(r.key),a.sortField!==s?e(U,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e(V,{size:14,className:"ml-1"}):e(q,{size:14,className:"ml-1"}))]})},String(r.key));var s}),e(ii,{className:"w-[50px] text-center",children:y("actions")})]})}),e(ri,{children:0===a.entities.length?e(ni,{children:e(oi,{colSpan:h?r.length+2:r.length+1,className:"h-32",children:e(fi,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):a.entities.map(n=>t(Oi,{children:[e(Li,{asChild:!0,children:t(ni,{className:Aa("cursor-pointer hover:bg-muted/50",h&&a.selectedIds.includes(n.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?a.selectItem(n.id):s?.(n)},children:[h&&e(oi,{onClick:e=>e.stopPropagation(),children:e(Qi,{checked:a.selectedIds.includes(n.id),onCheckedChange:()=>a.selectItem(n.id)})}),r.map(t=>e(oi,{className:t.className,children:t.render?t.render(n):String(n[t.key]??"")},String(t.key))),e(oi,{className:"text-center",children:d?d(n):e(Ri,{onEdit:s?()=>s(n):void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,customActions:m?m(n):[]})})]})}),e(Ui,{className:"w-[160px]",children:e(Ai,{onEdit:s?()=>s(n):void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,canDelete:!!l,customActions:m?m(n):[],renderAs:"context"})})]},n.id))})]})})})]})};function Ji(e,t,a,r){const[s,n]=c({}),[i,l]=c({}),d=o(()=>e,[e]),m=e=>e instanceof Date&&!isNaN(e.getTime()),h=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return h(e)}},f=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.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(t,a);if(e)return e}catch(r){}}};u(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},s=e(d),i={};s.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);m(e)&&(a=e.toISOString().split("T")[0])}else m(a)&&(a=a.toISOString().split("T")[0])}else a=h(e);i[e.name]=a}),s.forEach(e=>{const t=p(e,i);void 0!==t&&(i[e.name]=t)}),t&&Object.keys(t).forEach(e=>{s.find(t=>t.name===e)||void 0===t[e]||(i[e]=t[e])}),n(i),l({}),a&&a(i)},[d,t,a,r]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},b=()=>{const e=g(d),t={};return e.forEach(e=>{const a=f(e,s[e.name],s);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:s,errors:i,updateField:(e,t)=>{n(r=>{const s={...r,[e]:t},n=((e,t)=>{let a={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,s);return a&&a(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const r=g(d).find(t=>t.name===e);if(r){const a=f(r,t,s);a&&l(t=>({...t,[e]:a}))}},validateForm:b,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),b()&&e(s)}}}const Xi=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Yi=({value:a="#3b82f6",onChange:r,label:s})=>t("div",{className:"space-y-2",children:[s&&e(Va,{children:s}),t(Jr,{children:[e(Xr,{asChild:!0,children:t(Da,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:a}}),a]})}),e(Yr,{className:"w-64",children:t("div",{className:"space-y-3",children:[t("div",{children:[e(Va,{htmlFor:"color-input",children:"Cor personalizada"}),e($a,{id:"color-input",type:"color",value:a,onChange:e=>r?.(e.target.value),className:"h-10 w-full"})]}),t("div",{children:[e(Va,{children:"Cores predefinidas"}),e("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Xi.map(t=>e("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>r?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),Zi=r.forwardRef(({className:a,children:r,...s},n)=>t(vt.Root,{ref:n,className:Aa("relative overflow-hidden",a),...s,children:[e(vt.Viewport,{className:"h-full w-full rounded-[inherit]",children:r}),e(eo,{}),e(vt.Corner,{})]}));Zi.displayName=vt.Root.displayName;const eo=r.forwardRef(({className:t,orientation:a="vertical",...r},s)=>e(vt.ScrollAreaScrollbar,{ref:s,orientation:a,className:Aa("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e(vt.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));eo.displayName=vt.ScrollAreaScrollbar.displayName;const to={Star:Le,Heart:Oe,Home:Re,User:Ae,Settings:Ie,Mail:Te,Phone:Ee,Calendar:Pe,MapPin:_e,Camera:Ce,Image:Se,Music:ke,Video:we,Book:Ne,Bookmark:xe,Search:R,Filter:ye,Edit:F,Trash2:z,Plus:$,Minus:ve,Check:E,X:C,ChevronDown:_,ChevronUp:P,ChevronLeft:be,ChevronRight:L,ArrowUp:V,ArrowDown:q,ArrowLeft:ge,ArrowRight:fe,Clock:pe,Bell:he,AlertCircle:I,Info:me,HelpCircle:ue,Download:ce,Upload:de,Share:le,Copy:oe,Save:ie,FileText:ne,Folder:se,FolderOpen:re,Archive:ae,Lock:te,Unlock:ee,Eye:Z,EyeOff:Y,Shield:X,Key:J,Zap:G,Flame:Q,Sparkles:K,Award:H,Trophy:W,Target:B},ao=({value:a="Star",onChange:r,label:s})=>{const{t:n}=Rs(),[i,o]=c(""),l=Object.entries(to).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),d=to[a]||Le;return t("div",{className:"space-y-2",children:[s&&e(Va,{children:s}),t(Jr,{children:[e(Xr,{asChild:!0,children:t(Da,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e(d,{className:"h-4 w-4 mr-2"}),a]})}),e(Yr,{className:"w-80",children:t("div",{className:"space-y-3",children:[t("div",{children:[e(Va,{htmlFor:"icon-search",children:n("search")}),e($a,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e(Zi,{className:"h-48",children:e("div",{className:"grid grid-cols-6 gap-2",children:l.map(([t,s])=>e("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>r?.(t),title:t,children:e(s,{className:"h-4 w-4"})},t))})})]})})]})]})},ro=r.forwardRef(({className:t,...a},r)=>e(yt.Root,{className:Aa("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:r,children:e(yt.Thumb,{className:Aa("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));ro.displayName=yt.Root.displayName;const so=(e={})=>{const{user:t,alias:a}=$n(),{enabled:r=!0}=e;return lt({queryKey:["qualiex-users",a],queryFn:()=>hn.getUsers(a),enabled:r&&!!a&&!!t,retry:2,retryDelay:1e3})},no=({value:t="",onChange:a,placeholder:r,disabled:s,className:n,enabled:i})=>{const{t:o}=Rs(),{data:l=[],isLoading:d,error:c}=so({enabled:i});return e(Fs,{value:t,onChange:a,options:l,isLoading:d,error:c,getOptionValue:e=>e.userId,getOptionLabel:e=>e.userName,placeholder:r||o("search_placeholder"),searchPlaceholder:o("search_placeholder"),emptyMessage:o("no_results"),disabled:s,className:n})};function io({title:a,sections:r,initialData:n,onSubmit:i,onCancel:u,open:m,submitButtonText:h,isLoading:p=!1,usersData:f}){const{t:g}=Rs(),[b,v]=c(r?.[0]?.id||""),y=l(null),[x,N]=c(null),w=d(e=>{y.current=e,N(e)},[]),k=o(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:S,errors:C,updateField:_,handleSubmit:P}=Ji(k,n,void 0,m),E=o(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(S):e.disabled||!1})):[],[r,S]),T=o(()=>{const e=E.find(e=>e.id===b);if(e&&!e.disabled)return b;const t=E.find(e=>!e.disabled);return t?.id||b},[E,b]);s.useEffect(()=>{T!==b&&v(T)},[T,b]);const I=E.find(e=>e.id===T),A=a=>{const r=(a.computedValue,S[a.name]),s=void 0!==r?r:"",n=C[a.name];switch(a.type){case"group":const r="horizontal"===a.layout,i=r?`flex gap-3 w-full ${a.className||""}`:"space-y-3",o=r?Aa("space-y-2 w-full",a.wrapperClassName):Aa("space-y-2",a.className,a.wrapperClassName);return t("div",{className:o,children:[a.label,e("div",{className:i,children:a.fields?.map(e=>A(e))})]},a.name);case"user-select":return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e(no,{value:s||"",onChange:e=>_(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:n?"border-red-500":""}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"textarea":return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e(_r,{id:a.name,value:s||"",onChange:e=>{_(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"select":return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),t(fr,{value:String(s),onValueChange:e=>{_(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e(vr,{className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:e(br,{placeholder:a.placeholder})}),e(Nr,{children:a.options?.map(t=>e(kr,{value:t.value,children:t.label},t.value))})]}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"multiselect":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-red-500 ml-1",children:"*"})]}),e(Fs,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>_(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:n,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"date":return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e($a,{id:a.name,type:"date",value:String(s),onChange:e=>_(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Aa("w-full",n?"border-red-500":"",a.disabled?"bg-gray-100 cursor-not-allowed":"")}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"color":return t("div",{children:[t(Va,{htmlFor:a.name,children:[a.label," ",a.required&&e("span",{className:"text-destructive",children:"*"})]}),e($a,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>_(a.name,e.target.value),className:"h-10"}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"color-picker":return t("div",{children:[e(Yi,{label:`${a.label} ${a.required?"*":""}`,value:s||a.defaultValue||"#3b82f6",onChange:e=>_(a.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"icon-picker":return t("div",{children:[e(ao,{label:`${a.label} ${a.required?"*":""}`,value:s||a.defaultValue||"Star",onChange:e=>_(a.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"custom":if(!a.component)return null;const l=a.component,d="function"==typeof a.componentProps?a.componentProps(S):a.componentProps||{};return t("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e(Va,{htmlFor:a.name,children:a.label}),e(l,{value:s,onChange:e=>{_(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:n,popoverContainer:x,...d}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"number":return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e($a,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,r=""===t?null:Number(t);_(a.name,r)},placeholder:a.placeholder,disabled:a.disabled,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"checkbox":return t("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e(Cr,{id:a.name,checked:!!s,onCheckedChange:e=>_(a.name,e),disabled:a.disabled}),e(Va,{htmlFor:a.name,className:"cursor-pointer",children:a.label}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"switch":return t("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e(ro,{id:a.name,checked:!!s,onCheckedChange:e=>_(a.name,e),disabled:a.disabled}),n&&e("p",{className:"text-sm text-red-500 mt-2",children:n})]},a.name);default:return t("div",{className:`space-y-2 ${a.className||""}`,children:[e(Va,{htmlFor:a.name,children:a.label}),e($a,{id:a.name,type:"text",value:s||"",onChange:e=>{_(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:a.disabled}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name)}},R=d(()=>{if(!I)return null;if(I.disabled)return t("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e("div",{className:"rounded-full bg-muted p-3 mb-4",children:e("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e("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(I.component){const t=I.component;return e(t,{formData:S,updateField:_,errors:C,users:f,disabled:I.disabled})}return e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:I.fields.map(A)})},[I,S,_,C,f,A]),O=t("div",{className:"flex flex-col max-h-[80vh]",children:[E.length>1&&e("div",{className:"flex-shrink-0 p-4 border-b",children:e("div",{className:"flex space-x-2",children:E.map(t=>e(Da,{variant:T===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=E.find(t=>t.id===e);t&&!t.disabled&&v(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:p?e("div",{className:"flex items-center justify-center py-12",children:e("div",{className:"text-muted-foreground",children:g("loading")})}):t("form",{onSubmit:P(i),className:"space-y-3 md:space-y-4",children:[R(),t("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Da,{type:"button",variant:"outline",onClick:u,children:g("cancel")}),e(Da,{type:"submit",disabled:p,children:h||g("save")})]})]})})]});return e(Ga,{open:m,onOpenChange:e=>{!1===e&&!0===m&&u()},children:t(er,{ref:w,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[t(tr,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e(rr,{className:"text-white",children:a}),e(sr,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),O]})})}function oo({currentPage:r,totalPages:s,totalItems:n,itemsPerPage:i,onPageChange:o,onItemsPerPageChange:l,variant:d="full"}){const c=(r-1)*i+1,u=Math.min(r*i,n);return t("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e("div",{className:"flex items-center gap-2",children:"full"===d&&t(a,{children:[e("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),t(fr,{value:String(i),onValueChange:e=>l(Number(e)),children:[e(vr,{className:"h-8 w-[70px]",children:e(br,{})}),t(Nr,{children:[e(kr,{value:"10",children:"10"}),e(kr,{value:"25",children:"25"}),e(kr,{value:"50",children:"50"}),e(kr,{value:"100",children:"100"})]})]})]})}),t("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," de ",n," itens"]}),t("div",{className:"flex items-center gap-1",children:[e(Da,{variant:"outline",size:"sm",onClick:()=>o(1),disabled:1===r,className:"h-8 w-8 p-0",children:e(je,{size:16})}),e(Da,{variant:"outline",size:"sm",onClick:()=>o(r-1),disabled:1===r,className:"h-8 w-8 p-0",children:e(be,{size:16})}),t("div",{className:"flex items-center gap-1 px-2",children:[e("span",{className:"text-sm font-medium",children:r}),e("span",{className:"text-sm text-muted-foreground",children:"de"}),e("span",{className:"text-sm font-medium",children:s})]}),e(Da,{variant:"outline",size:"sm",onClick:()=>o(r+1),disabled:r===s,className:"h-8 w-8 p-0",children:e(L,{size:16})}),e(Da,{variant:"outline",size:"sm",onClick:()=>o(s),disabled:r===s,className:"h-8 w-8 p-0",children:e(Fe,{size:16})})]})]})}function lo({manager:t}){return e(oo,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const co=({selectedCount:a,onClearSelection:r,onBulkDelete:s,customActions:n=[],isLoading:i=!1})=>{const{t:o}=Rs();return t("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[t("div",{className:"flex items-center gap-3",children:[e("span",{className:"text-sm font-medium",children:o("selected",{count:a})}),t(Da,{variant:"ghost",size:"sm",onClick:r,className:"h-7 px-2",children:[e(C,{size:14,className:"mr-1"}),o("clear")]})]}),t("div",{className:"flex items-center gap-2",children:[n.map((a,r)=>{const s=a.icon;return t(Da,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:i,className:"h-7",children:[s&&e(s,{size:14,className:"mr-1"}),a.label]},r)}),s&&t(Da,{variant:"destructive",size:"sm",onClick:s,disabled:i,className:"h-7",children:[e(z,{size:14,className:"mr-1"}),o("delete")]})]})]})},uo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},mo={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},ho={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function po({children:t,direction:a="column",gap:r="md",align:s="stretch",justify:n="start",wrap:i=!1,className:o}){return e("div",{className:Aa("flex","column"===a?"flex-col":"flex-row",uo[r],mo[s],ho[n],i&&"flex-wrap",o),children:t})}function fo({manager:r,filters:s,inline:n=!1}){const{t:i}=Rs(),{isSearchVisible:o}=$n(),l=r.searchTerm,d=t(a,{children:[s.some(e=>"search"===e.type)&&!o&&t("div",{className:"relative flex-1",children:[e(R,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e($a,{placeholder:i("search"),value:r.searchTerm,onChange:e=>r.handleSearch(e.target.value),className:"pl-10"})]}),s.filter(e=>"select"===e.type&&e.options).map((a,r)=>t("select",{value:a.value||"",onChange:e=>a.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[a.placeholder&&e("option",{value:"",children:a.placeholder}),a.options.map(t=>e("option",{value:t.value,children:t.label},t.value))]},`select-${r}`)),s.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e("div",{className:n?"":"w-full sm:w-auto",children:e(r,{...t.props})},`custom-${a}`)}),l&&t(Da,{variant:"outline",onClick:r.clearFilters,className:"whitespace-nowrap",children:[e(C,{className:"h-4 w-4 mr-2"}),i("clear")]})]});return n?e("div",{className:"flex items-center gap-2",children:d}):e(po,{direction:"column",gap:"md",className:"mb-6",children:e(po,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:d})})}function go({manager:a,config:r,formSections:s,onSave:n,onToggleStatus:i,defaultSort:o}){a&&a.queryKey;const{t:l}=Rs(),{setSearchVisible:d}=$n(),[m,h]=ut(),[p,f]=c(!1),[g,b]=c(null),[v,y]=c({isOpen:!1,entityId:null,entityName:""}),[x,N]=c({isOpen:!1,count:0});u(()=>(d(!0),()=>{d(!1)}),[d]),u(()=>{if(o&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!m.has(e)&&!m.has(t)){const a=Object.fromEntries(m);a[e]=o.column,a[t]=o.direction,h(a)}}},[]);return t("div",{className:"flex-1 flex flex-col h-full",children:[r.enableBulkActions&&a.selectedIds.length>0&&e(co,{selectedCount:a.selectedIds.length,onClearSelection:a.clearSelection,onBulkDelete:r.bulkActions&&r.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:a.selectedIds.length})},customActions:r.bulkActions,isLoading:a.isBulkDeleting}),t("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[t("div",{className:"flex items-center gap-2",children:[t(Da,{onClick:()=>{r.onNew?r.onNew():(b(null),f(!0))},children:[e($,{size:16,className:"mr-2"}),l("new")]}),r.customActions?.map((a,r)=>t(Da,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e(a.icon,{size:16,className:"mr-2"}),a.label]},r))]}),r.filters&&r.filters.length>0&&e("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e(fo,{manager:a,filters:r.filters,inline:!0})})]}),e("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?e("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(a.entities,a)}):e(Gi,{manager:a,columns:r.columns,onEdit:e=>{r.onEdit?r.onEdit(e):(b(e),f(!0))},onDelete:e=>{y({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions})}),e("div",{className:"flex-shrink-0 border-t bg-background",children:e(lo,{manager:a})}),!r.useCustomRouting&&e(io,{open:p,title:g?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:g||void 0,onSubmit:e=>{n(e),f(!1),b(null)},onCancel:()=>{f(!1),b(null)},isLoading:a.isLoading,submitButtonText:l(g?"update":"create")}),e(ei,{open:v.isOpen,onOpenChange:()=>{y({isOpen:!1,entityId:null,entityName:""})},onConfirm:e=>{v.entityId&&(a.deleteEntity(v.entityId),y({isOpen:!1,entityId:null,entityName:""}))},item:v.entityId?{id:v.entityId,title:v.entityName}:void 0,entityName:r.entityName,isDeleting:a.isDeleting}),e(ei,{open:x.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),onConfirm:()=>(a.bulkDelete?.(a.selectedIds),void N({isOpen:!1,count:0})),item:{id:"bulk",title:`${x.count} ${1===x.count?r.entityName:r.entityNamePlural}`},entityName:r.entityNamePlural,isDeleting:a.isBulkDeleting,isBulk:!0,bulkCount:x.count})]})}function bo(t){return({manager:a})=>{const{manager:r,config:s,onSave:n,onEdit:i,onToggleStatus:o}=t,l=a??r,d={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:i||s.onEdit};return e(go,{manager:l,config:d,formSections:s.formSections,onSave:n,onToggleStatus:o,defaultSort:s.defaultSort})}}function vo(e,t,a){return r=>{if(r.id){const t=a(r);e.updateEntity(r.id,t)}else{const a=t(r);e.createEntity(a)}}}function yo(e,t,a={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],s={key:e,header:No(e),label:No(e),...xo(e,a),sortable:!0,searchable:"string"==typeof a};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}}function xo(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function No(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const wo=r.forwardRef(({className:t,value:a,...r},s)=>e(xt.Root,{ref:s,className:Aa("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...r,children:e(xt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));function ko({steps:a,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:Aa("flex items-center justify-between mb-6",n),children:a.map((r,n)=>t("div",{className:"flex items-center flex-1",children:[e("div",{className:Aa("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",r.isActive&&"border-primary bg-primary text-primary-foreground",r.isCompleted&&"border-primary bg-primary text-primary-foreground",!r.isActive&&!r.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!r.isDisabled&&"cursor-pointer hover:border-primary/50",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:r.isCompleted?e(E,{className:"w-5 h-5"}):n+1}),n<a.length-1&&e("div",{className:Aa("flex-1 h-0.5 mx-2 transition-colors",r.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},r.id))})}function So({steps:a,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:Aa("flex items-center gap-2 mb-6 overflow-x-auto",n),children:a.map((r,n)=>t("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[t("div",{className:Aa("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",r.isActive&&"bg-primary text-primary-foreground font-medium",r.isCompleted&&"bg-primary/10 text-primary",!r.isActive&&!r.isCompleted&&"bg-muted text-muted-foreground",s&&!r.isDisabled&&"cursor-pointer hover:bg-primary/20",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:[e("span",{className:"text-sm font-medium",children:n+1}),e("span",{className:"text-sm",children:r.label}),r.isCompleted&&e(E,{className:"w-4 h-4 ml-1"})]}),n<a.length-1&&e("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},r.id))})}function Co({steps:a,currentStepIndex:r,className:s}){const n=a[r],i=(r+1)/a.length*100;return t("div",{className:Aa("mb-6 space-y-2",s),children:[t("div",{className:"flex items-center justify-between text-sm",children:[t("span",{className:"text-muted-foreground",children:["Etapa ",r+1," de ",a.length]}),e("span",{className:"font-medium",children:n?.label})]}),e(wo,{value:i,className:"h-2"})]})}function _o({isFirstStep:r,isLastStep:s,canGoNext:n,canGoPrevious:i,isLoading:o,onPrevious:l,onNext:d,onSubmit:c,previousButtonText:u,nextButtonText:m,submitButtonText:h}){const{t:p}=Rs();return t(a,{children:[e("div",{children:i&&!r&&e(Da,{type:"button",variant:"outline",onClick:l,disabled:o,children:u||p("previous")})}),t("div",{className:"flex gap-2",children:[n&&!s&&e(Da,{type:"button",onClick:d,disabled:o,children:m||p("next")}),s&&e(Da,{type:"button",onClick:c,disabled:o,children:o?p("saving"):h||p("save")})]})]})}function Po({title:a,sections:r,initialData:n,onSubmit:i,onCancel:u,open:m,submitButtonText:h,isLoading:p=!1,usersData:f,showProgressIndicator:g=!0,progressType:b="stepper",validateOnNext:v=!0,allowSkipSections:y=!1,previousButtonText:x,nextButtonText:N,onStepChange:w,onStepValidationFail:k,renderProgressIndicator:S,renderButtons:C,currentStepIndex:_,onCurrentStepChange:P}){const[E,T]=c(0),I=_??E,A=P??T,R=l(null),[O,L]=c(null),j=d(e=>{R.current=e,L(e)},[]),F=o(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:M,errors:D,updateField:z,handleSubmit:$}=Ji(F,n,void 0,m);s.useEffect(()=>{m&&A(0)},[m,A]);const U=d(()=>{const e=r[I];if(!e)return!0;const t=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),a={};let s=!0;return t.forEach(e=>{const t=M[e.name];if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(a[e.name]=`${e.label} é obrigatório`,s=!1),e.validation&&"function"==typeof e.validation){const r=e.validation(t,M);r&&(a[e.name]=r,s=!1)}}),!s&&k&&k(I,a),s},[r,I,M,k]),V=d(()=>{if(v&&!U())return;const e=I+1;e<r.length&&(A(e),w?.(e,r[e].id))},[I,r,v,U,A,w]),q=d(()=>{const e=I-1;e>=0&&(A(e),w?.(e,r[e].id))},[I,r,A,w]),B=d(()=>{let e=!0;for(let t=0;t<r.length;t++){r[t].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(t=>{const a=M[t.name];t.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(e=!1)})}e&&$(i)()},[r,M,$,i]),W=o(()=>r.map((e,t)=>({index:t,id:e.id,label:e.label||e.id,isActive:t===I,isCompleted:t<I,isDisabled:e.disabled||!1})),[r,I]),H=0===I,K=I===r.length-1,Q=o(()=>{if(!g)return null;if(S)return S(I,r.length,r);const t=y?e=>{A(e),w?.(e,r[e].id)}:void 0;switch(b){case"breadcrumb":return e(So,{steps:W,currentStepIndex:I,onStepClick:t});case"progressbar":return e(Co,{steps:W,currentStepIndex:I});default:return e(ko,{steps:W,currentStepIndex:I,onStepClick:t})}},[g,S,b,W,I,r,y,A,w]),G=o(()=>{const t={isFirstStep:H,isLastStep:K,canGoNext:I<r.length-1,canGoPrevious:I>0,isLoading:p,onPrevious:q,onNext:V,onSubmit:B,previousButtonText:x,nextButtonText:N,submitButtonText:h};return C?C(t):e(_o,{...t})},[H,K,I,r.length,p,q,V,B,x,N,h,C]),J=a=>{const r=(a.computedValue,M[a.name]),s=void 0!==r?r:"",n=D[a.name];switch(a.type){case"group":return t("div",{className:"space-y-2",children:[a.label&&e(Va,{className:"text-sm font-medium",children:a.label}),e("div",{className:Aa("grid gap-4",1===a.columns&&"grid-cols-1",2===a.columns&&"grid-cols-1 md:grid-cols-2",3===a.columns&&"grid-cols-1 md:grid-cols-3",4===a.columns&&"grid-cols-1 md:grid-cols-4",!a.columns&&"grid-cols-1"),children:a.fields?.map(e=>J(e))})]},a.name);case"number":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e($a,{id:a.name,type:"number",value:s,onChange:e=>z(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"textarea":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(_r,{id:a.name,value:s,onChange:e=>z(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"select":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t(fr,{value:s,onValueChange:e=>z(a.name,e),children:[e(vr,{className:n?"border-destructive":"",children:e(br,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e(Nr,{children:a.options?.map(t=>e(kr,{value:String(t.value),children:t.label},t.value))})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"multiselect":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Fs,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>z(a.name,e),placeholder:a.placeholder,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"color":case"color-picker":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Yi,{value:s,onChange:e=>z(a.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"icon-picker":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ao,{value:s,onChange:e=>z(a.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"user-select":return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(no,{value:s,onChange:e=>z(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"custom":return a.render?t("div",{className:"space-y-2",children:[a.label&&t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>z(a.name,e),error:n,disabled:a.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name):null;default:return t("div",{className:"space-y-2",children:[t(Va,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e($a,{id:a.name,type:a.type||"text",value:s,onChange:e=>z(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name)}},X=r[I];return e(Ga,{open:m,onOpenChange:u,children:t(er,{ref:j,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e(tr,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e(rr,{className:"text-white",children:a})}),Q,e("div",{className:"space-y-4 py-4",children:X?.fields.map(e=>J(e))}),e("div",{className:"flex justify-between pt-4 border-t",children:G})]})})}wo.displayName=xt.Root.displayName;const Eo=({children:r})=>{const{isAuthenticated:n,isLoading:i}=$n();if(s.useEffect(()=>{if(!n)return;const e=()=>{Hs.areAllTokensValid()||Mn.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),s.useEffect(()=>{if(i)return;if(n)return;if(Hs.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const r=bn();(async()=>{r?await Mn.loginDev():Mn.loginProd()})()},[n,i]),i)return e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:e(Wa,{className:"text-xl font-semibold",children:"Carregando..."})}),t(Ka,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){const a=new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token");return e("div",a?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:e(Wa,{className:"text-xl font-semibold",children:"Processando..."})}),t(Ka,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:e(Wa,{className:"text-xl font-semibold",children:"Iniciando..."})}),t(Ka,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:bn()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e(a,{children:r})},To=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"}}),Io=r.forwardRef(({className:t,variant:a,...r},s)=>e("div",{ref:s,role:"alert",className:Aa(To({variant:a}),t),...r}));Io.displayName="Alert";const Ao=r.forwardRef(({className:t,...a},r)=>e("h5",{ref:r,className:Aa("mb-1 font-medium leading-none tracking-tight",t),...a}));Ao.displayName="AlertTitle";const Ro=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("text-sm [&_p]:leading-relaxed",t),...a}));Ro.displayName="AlertDescription";const Oo=()=>{const{processCallback:r}=$n(),[s,n]=c(null),[i,o]=c(!1);u(()=>{(async()=>{try{if(await r()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[r]);const l=async()=>{o(!0),n(null);try{await r()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{o(!1)}},d=()=>{window.location.href="/"};return e("div",s?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:t(Wa,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e(I,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),t(Ka,{className:"space-y-4",children:[e(Io,{variant:"destructive",children:e(Ro,{children:s})}),e("div",{className:"text-sm text-muted-foreground",children:e("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),t("div",{className:"flex gap-2",children:[e(Da,{onClick:l,disabled:i,className:"flex-1",children:t(a,i?{children:[e(Ir,{size:"sm",className:"mr-2"}),"Tentando..."]}:{children:[e(Me,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e(Da,{onClick:d,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:e(Wa,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),t(Ka,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(Ir,{size:"lg"})}),e("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Lo=()=>e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(qa,{className:"w-full max-w-md",children:[e(Ba,{className:"text-center",children:e(Wa,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),t(Ka,{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e(Da,{onClick:async()=>{bn()?await Mn.loginDev():Mn.loginProd()},className:"w-full",size:"lg",children:bn()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),jo=n(void 0);function Fo({children:t,actions:a}){const[r,s]=c({}),[n,i]=c(a);return u(()=>{i(a)},[a]),e(jo.Provider,{value:{metadata:r,setMetadata:s,clearMetadata:()=>s({}),headerActions:n,setHeaderActions:i},children:t})}function Mo(){const e=i(jo);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function Do(e){const{setMetadata:t,clearMetadata:a}=Mo();u(()=>(t(e),()=>a()),[e.title,e.subtitle,t,a])}function zo(e){return{queryClient:e.queryClient||new ct({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const $o=Nt.Root,Uo=r.forwardRef(({className:t,...a},r)=>e(Nt.Item,{ref:r,className:Aa("border-b",t),...a}));Uo.displayName="AccordionItem";const Vo=r.forwardRef(({className:a,children:r,...s},n)=>e(Nt.Header,{className:"flex",children:t(Nt.Trigger,{ref:n,className:Aa("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[r,e(_,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Vo.displayName=Nt.Trigger.displayName;const qo=r.forwardRef(({className:t,children:a,...r},s)=>e(Nt.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:e("div",{className:Aa("pb-4 pt-0",t),children:a})}));qo.displayName=Nt.Content.displayName;const Bo=wt.Root,Wo=r.forwardRef(({className:t,...a},r)=>e(kt.Root,{ref:r,className:Aa("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Wo.displayName=kt.Root.displayName;const Ho=r.forwardRef(({className:t,...a},r)=>e(kt.Image,{ref:r,className:Aa("aspect-square h-full w-full",t),...a}));Ho.displayName=kt.Image.displayName;const Ko=r.forwardRef(({className:t,...a},r)=>e(kt.Fallback,{ref:r,className:Aa("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Ko.displayName=kt.Fallback.displayName;const Qo=r.forwardRef(({...t},a)=>e("nav",{ref:a,"aria-label":"breadcrumb",...t}));Qo.displayName="Breadcrumb";const Go=r.forwardRef(({className:t,...a},r)=>e("ol",{ref:r,className:Aa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));Go.displayName="BreadcrumbList";const Jo=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,className:Aa("inline-flex items-center gap-1.5",t),...a}));Jo.displayName="BreadcrumbItem";const Xo=r.forwardRef(({asChild:t,className:a,...s},n)=>{const i=t?r.Fragment:"a";return e(i,{ref:n,className:Aa("transition-colors hover:text-foreground",a),...s})});Xo.displayName="BreadcrumbLink";const Yo=r.forwardRef(({className:t,...a},r)=>e("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Aa("font-normal text-foreground",t),...a}));Yo.displayName="BreadcrumbPage";const Zo=({children:t,className:a,...r})=>e("li",{role:"presentation","aria-hidden":"true",className:Aa("[&>svg]:size-3.5",a),...r,children:t??e(L,{})});Zo.displayName="BreadcrumbSeparator";const el=({className:a,...r})=>t("span",{role:"presentation","aria-hidden":"true",className:Aa("flex h-9 w-9 items-center justify-center",a),...r,children:[e(De,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"More"})]});el.displayName="BreadcrumbEllipsis";const tl=g("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),al=r.forwardRef(({className:t,orientation:a,...r},s)=>e("div",{ref:s,className:Aa(tl({orientation:a}),t),...r}));function rl(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function sl(e){return(t,a)=>{let r;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;r=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;r=e.values[s]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function nl(e){return(t,a={})=>{const r=a.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const i=n[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(o,e=>e.test(i)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(i.length)}}}function il(e){return(t,a={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],n=t.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=a.valueCallback?a.valueCallback(i):i;return{value:i,rest:t.slice(s.length)}}}al.displayName="ButtonGroup";const ol={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ll={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},dl={ordinalNumber:(e,t)=>{const a=Number(e),r=a%100;if(r>20||r<10)switch(r%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:sl({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:sl({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:sl({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:sl({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:sl({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},cl={ordinalNumber:il({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:nl({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:nl({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:nl({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/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,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:nl({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:nl({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},ul={code:"en-US",formatDistance:(e,t,a)=>{let r;const s=ol[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+r:r+" ago":r},formatLong:{date:rl({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:rl({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:rl({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,t,a,r)=>ll[e],localize:dl,match:cl,options:{weekStartsOn:0,firstWeekContainsDate:1}},ml={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},hl={date:rl({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:rl({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:rl({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},pl={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},fl={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},gl={ordinalNumber:(e,t)=>Number(e)+"º",era:sl({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:sl({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:sl({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:sl({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:sl({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},bl={ordinalNumber:il({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:nl({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:nl({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:nl({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:nl({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:nl({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},vl={code:"es",formatDistance:(e,t,a)=>{let r;const s=ml[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+r:"hace "+r:r},formatLong:hl,formatRelative:(e,t,a,r)=>1!==t.getHours()?fl[e]:pl[e],localize:gl,match:bl,options:{weekStartsOn:1,firstWeekContainsDate:1}},yl={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"}},xl={date:rl({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:rl({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:rl({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Nl={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},wl={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:sl({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:sl({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:sl({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:sl({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:sl({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"})},kl={ordinalNumber:il({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:nl({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:nl({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:nl({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:nl({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:nl({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"})},Sl={code:"pt-BR",formatDistance:(e,t,a)=>{let r;const s=yl[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+r:"há "+r:r},formatLong:xl,formatRelative:(e,t,a,r)=>{const s=Nl[e];return"function"==typeof s?s(t):s},localize:wl,match:kl,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Cl({className:t,classNames:a,showOutsideDays:r=!0,...s}){return e(St,{showOutsideDays:r,className:Aa("p-3 pointer-events-auto",t),locale:Sl,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Aa(Ma({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Aa(Ma({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:({...t})=>e(be,{className:"h-4 w-4"}),IconRight:({...t})=>e(L,{className:"h-4 w-4"})},...s})}Cl.displayName="Calendar";const _l=Ct.Root,Pl=Ct.CollapsibleTrigger,El=Ct.CollapsibleContent;const Tl={Root:function({children:t,className:a}){return e("div",{className:Aa("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:r}){return e(qa,{className:Aa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",r),onClick:a,children:e(Ka,{className:"p-4",children:t})})},Field:function({label:a,value:r,className:s}){return t("div",{className:Aa("flex justify-between items-center text-sm",s),children:[t("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e("span",{className:"text-foreground",children:r})]})}};function Il({date:a,onDateChange:r,placeholder:s="Pick a date",disabled:n=!1,className:i,disabledDates:o}){return t(Jr,{children:[e(Xr,{asChild:!0,children:t(Da,{variant:"outline",disabled:n,className:Aa("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",i),children:[e(Pe,{className:"mr-2 h-4 w-4"}),a?N(a,"PPP"):e("span",{children:s})]})}),e(Yr,{className:"w-auto p-0",align:"start",children:e(Cl,{mode:"single",selected:a,onSelect:r,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const Al=({shouldScaleBackground:t=!0,...a})=>e(_t.Root,{shouldScaleBackground:t,...a});Al.displayName="Drawer";const Rl=_t.Trigger,Ol=_t.Portal,Ll=_t.Close,jl=r.forwardRef(({className:t,...a},r)=>e(_t.Overlay,{ref:r,className:Aa("fixed inset-0 z-50 bg-black/80",t),...a}));jl.displayName=_t.Overlay.displayName;const Fl=r.forwardRef(({className:a,children:r,...s},n)=>t(Ol,{children:[e(jl,{}),t(_t.Content,{ref:n,className:Aa("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),r]})]}));Fl.displayName="DrawerContent";const Ml=({className:t,...a})=>e("div",{className:Aa("grid gap-1.5 p-4 text-center sm:text-left",t),...a});Ml.displayName="DrawerHeader";const Dl=({className:t,...a})=>e("div",{className:Aa("mt-auto flex flex-col gap-2 p-4",t),...a});Dl.displayName="DrawerFooter";const zl=r.forwardRef(({className:t,...a},r)=>e(_t.Title,{ref:r,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));zl.displayName=_t.Title.displayName;const $l=r.forwardRef(({className:t,...a},r)=>e(_t.Description,{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));function Ul({value:t,onChange:a,activeLabel:r,inactiveLabel:s,allLabel:n,placeholder:i,className:o="w-full sm:w-[180px]"}){const{t:l}=Rs(),d=[{id:"active",name:r||l("active")},{id:"inactive",name:s||l("inactive")},{id:"all",name:n||l("all")}];return e(Fs,{value:t,onChange:e=>a(e),options:d,getOptionValue:e=>e.id,getOptionLabel:e=>e.name,placeholder:i||l("select"),className:o})}$l.displayName=_t.Description.displayName;const Vl={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))]"},ql={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Bl({children:t,cols:a="auto-fit",gap:r="md",className:s}){return e("div",{className:Aa("grid",Vl[a],ql[r],s),children:t})}const Wl=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-slot":"input-group",className:Aa("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));Wl.displayName="InputGroup";const Hl=g("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),Kl=r.forwardRef(({className:t,align:a,...r},s)=>e("div",{ref:s,"data-slot":"input-group-addon",className:Aa(Hl({align:a}),t),...r}));Kl.displayName="InputGroupAddon";const Ql=g("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),Gl=r.forwardRef(({className:t,size:a,variant:r="ghost",...s},n)=>e(Da,{ref:n,"data-slot":"input-group-button",variant:r,className:Aa(Ql({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...s}));Gl.displayName="InputGroupButton";const Jl=r.forwardRef(({className:t,...a},r)=>e($a,{ref:r,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Jl.displayName="InputGroupInput";const Xl=r.forwardRef(({className:t,...a},r)=>e(_r,{ref:r,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Xl.displayName="InputGroupTextarea";const Yl=r.forwardRef(({className:a,keys:r,children:s,...n},i)=>r&&r.length>0?t("span",{className:Aa("inline-flex items-center gap-1",a),children:[r.map((t,a)=>e("kbd",{className:Aa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100"),children:t},a)),s&&e("kbd",{ref:i,className:Aa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100"),...n,children:s})]}):e("kbd",{ref:i,className:Aa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",a),...n,children:s}));Yl.displayName="Kbd";const Zl=r.forwardRef(({className:t,children:a,...r},s)=>e("select",{ref:s,className:Aa("flex h-10 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",t),...r,children:a}));Zl.displayName="NativeSelect";const ed=r.forwardRef(({className:t,...a},r)=>e("h1",{ref:r,className:Aa("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));ed.displayName="H1";const td=r.forwardRef(({className:t,...a},r)=>e("h2",{ref:r,className:Aa("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));td.displayName="H2";const ad=r.forwardRef(({className:t,...a},r)=>e("h3",{ref:r,className:Aa("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));ad.displayName="H3";const rd=r.forwardRef(({className:t,...a},r)=>e("h4",{ref:r,className:Aa("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));rd.displayName="H4";const sd=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Aa("leading-7 [&:not(:first-child)]:mt-6",t),...a}));sd.displayName="P";const nd=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Aa("text-xl text-muted-foreground",t),...a}));nd.displayName="Lead";const id=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Aa("text-lg font-semibold",t),...a}));id.displayName="Large";const od=r.forwardRef(({className:t,...a},r)=>e("small",{ref:r,className:Aa("text-sm font-medium leading-none",t),...a}));od.displayName="Small";const ld=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));ld.displayName="Muted";const dd=r.forwardRef(({className:t,...a},r)=>e("code",{ref:r,className:Aa("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));dd.displayName="InlineCode";const cd=r.forwardRef(({className:t,...a},r)=>e("blockquote",{ref:r,className:Aa("mt-6 border-l-2 pl-6 italic",t),...a}));cd.displayName="Blockquote";const ud=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,className:Aa("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));function md({items:t,maxItems:a=3,className:r}){return t.length>a&&(t[0],t.slice(-(a-1))),t.length,e(Qo,{className:r})}function hd(){const e=mt();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,s)=>{r+=`/${e}`;const n=s===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:i,href:n?void 0:r,isCurrentPage:n})}),a})()}ud.displayName="List";const pd=({className:t,...a})=>e("nav",{role:"navigation","aria-label":"pagination",className:Aa("mx-auto flex w-full justify-center",t),...a});pd.displayName="Pagination";const fd=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,className:Aa("flex flex-row items-center gap-1",t),...a}));fd.displayName="PaginationContent";const gd=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,className:Aa("",t),...a}));gd.displayName="PaginationItem";const bd=({className:t,isActive:a,size:r="icon",...s})=>e("a",{"aria-current":a?"page":void 0,className:Aa(Ma({variant:a?"outline":"ghost",size:r}),t),...s});bd.displayName="PaginationLink";const vd=({className:a,...r})=>t(bd,{"aria-label":"Go to previous page",size:"default",className:Aa("gap-1 pl-2.5",a),...r,children:[e(be,{className:"h-4 w-4"}),e("span",{children:"Previous"})]});vd.displayName="PaginationPrevious";const yd=({className:a,...r})=>t(bd,{"aria-label":"Go to next page",size:"default",className:Aa("gap-1 pr-2.5",a),...r,children:[e("span",{children:"Next"}),e(L,{className:"h-4 w-4"})]});yd.displayName="PaginationNext";const xd=({className:a,...r})=>t("span",{"aria-hidden":!0,className:Aa("flex h-9 w-9 items-center justify-center",a),...r,children:[e(De,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"More pages"})]});xd.displayName="PaginationEllipsis";const Nd=r.forwardRef(({className:t,...a},r)=>e(Pt.Root,{className:Aa("grid gap-2",t),...a,ref:r}));Nd.displayName=Pt.Root.displayName;const wd=r.forwardRef(({className:t,...a},r)=>e(Pt.Item,{ref:r,className:Aa("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e(Pt.Indicator,{className:"flex items-center justify-center",children:e(j,{className:"h-2.5 w-2.5 fill-current text-current"})})}));wd.displayName=Pt.Item.displayName;const kd=g("flex h-10 w-full items-center rounded-md border border-input bg-background text-sm ring-offset-background transition-colors focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",{variants:{variant:{default:"",filled:"bg-muted border-transparent",outline:"border-2"},size:{default:"h-10",sm:"h-8",lg:"h-12"}},defaultVariants:{variant:"default",size:"default"}}),Sd=r.forwardRef(({className:a,variant:r,size:s,onClear:n,showClearButton:i=!0,value:o,...l},d)=>{const c=null!=o&&""!==o;return t("div",{className:Aa(kd({variant:r,size:s,className:a})),children:[e(R,{className:"ml-3 h-4 w-4 shrink-0 text-muted-foreground"}),e("input",{type:"text",className:Aa("flex-1 bg-transparent px-3 py-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50","sm"===s&&"py-1 text-xs","lg"===s&&"py-3"),ref:d,value:o,...l}),i&&c&&n&&e("button",{type:"button",onClick:n,className:"mr-2 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","aria-label":"Clear search",children:e(C,{className:"h-4 w-4"})})]})});Sd.displayName="Searchbar";const Cd=r.forwardRef(({className:t,orientation:a="horizontal",decorative:r=!0,...s},n)=>e(Et.Root,{ref:n,decorative:r,orientation:a,className:Aa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...s}));Cd.displayName=Et.Root.displayName;const _d=Je.Root,Pd=Je.Trigger,Ed=Je.Close,Td=Je.Portal,Id=r.forwardRef(({className:t,...a},r)=>e(Je.Overlay,{className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:r}));Id.displayName=Je.Overlay.displayName;const Ad=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"}}),Rd=r.forwardRef(({side:a="right",className:r,children:s,...n},i)=>t(Td,{children:[e(Id,{}),t(Je.Content,{ref:i,className:Aa(Ad({side:a}),r),...n,children:[s,t(Je.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:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));Rd.displayName=Je.Content.displayName;const Od=({className:t,...a})=>e("div",{className:Aa("flex flex-col space-y-2 text-center sm:text-left",t),...a});Od.displayName="SheetHeader";const Ld=({className:t,...a})=>e("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Ld.displayName="SheetFooter";const jd=r.forwardRef(({className:t,...a},r)=>e(Je.Title,{ref:r,className:Aa("text-lg font-semibold text-foreground",t),...a}));jd.displayName=Je.Title.displayName;const Fd=r.forwardRef(({className:t,...a},r)=>e(Je.Description,{ref:r,className:Aa("text-sm text-muted-foreground",t),...a}));Fd.displayName=Je.Description.displayName;const Md=Tt.Provider,Dd=Tt.Root,zd=Tt.Trigger,$d=r.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e(Tt.Content,{ref:s,sideOffset:a,className:Aa("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));$d.displayName=Tt.Content.displayName;const Ud="sidebar:state",Vd=r.createContext(null);function qd(){const e=r.useContext(Vd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Bd=r.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:n,style:i,children:o,...l},d)=>{const[c,u]=r.useState(!1);r.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[m,h]=r.useState(!1),[p,f]=r.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Ud);return null!==e?"true"===e:t}return t}),g=a??p,b=r.useCallback(e=>{const t="function"==typeof e?e(g):e;s?s(t):f(t),"undefined"!=typeof window&&localStorage.setItem(Ud,String(t))},[s,g]),v=r.useCallback(()=>c?h(e=>!e):b(e=>!e),[c,b,h]);r.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);const y=g?"expanded":"collapsed",x=r.useMemo(()=>({state:y,open:g,setOpen:b,isMobile:c,openMobile:m,setOpenMobile:h,toggleSidebar:v}),[y,g,b,c,m,h,v]);return e(Vd.Provider,{value:x,children:e(Md,{delayDuration:0,children:e("div",{className:Aa("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",n),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...i},ref:d,...l,children:o})})})});Bd.displayName="SidebarProvider";const Wd=r.forwardRef(({side:a="left",variant:r="sidebar",collapsible:s="offcanvas",className:n,children:i,...o},l)=>{const{isMobile:d,state:c,openMobile:u,setOpenMobile:m}=qd();return"none"===s?e("div",{className:Aa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:l,...o,children:i}):d?e(_d,{open:u,onOpenChange:m,...o,children:t(Rd,{"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:a,children:[e(jd,{className:"sr-only",children:"Menu de Navegação"}),e("div",{className:"flex h-full w-full flex-col",children:i})]})}):t("div",{ref:l,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":r,"data-side":a,children:[e("div",{className:Aa("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e("div",{className:Aa("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===r||"inset"===r?"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",n),...o,children:e("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:i})})]})});Wd.displayName="Sidebar";const Hd=r.forwardRef(({className:a,onClick:r,...s},n)=>{const{toggleSidebar:i}=qd();return t(Da,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Aa("h-7 w-7",a),onClick:e=>{r?.(e),i()},...s,children:[e(ze,{}),e("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Hd.displayName="SidebarTrigger";const Kd=r.forwardRef(({className:t,...a},r)=>{const{toggleSidebar:s}=qd();return e("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:Aa("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});Kd.displayName="SidebarRail";const Qd=r.forwardRef(({className:t,...a},r)=>e("main",{ref:r,className:Aa("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));Qd.displayName="SidebarInset";const Gd=r.forwardRef(({className:t,...a},r)=>e($a,{ref:r,"data-sidebar":"input",className:Aa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));Gd.displayName="SidebarInput";const Jd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"header",className:Aa("flex flex-col gap-2 p-2",t),...a}));Jd.displayName="SidebarHeader";const Xd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"footer",className:Aa("flex flex-col gap-2 p-2",t),...a}));Xd.displayName="SidebarFooter";const Yd=r.forwardRef(({className:t,...a},r)=>e(Cd,{ref:r,"data-sidebar":"separator",className:Aa("mx-2 w-auto bg-sidebar-border",t),...a}));Yd.displayName="SidebarSeparator";const Zd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"content",className:Aa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));Zd.displayName="SidebarContent";const ec=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"group",className:Aa("relative flex w-full min-w-0 flex-col p-2",t),...a}));ec.displayName="SidebarGroup";const tc=r.forwardRef(({className:t,asChild:a=!1,...r},s)=>e(a?f:"div",{ref:s,"data-sidebar":"group-label",className:Aa("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r}));tc.displayName="SidebarGroupLabel";const ac=r.forwardRef(({className:t,asChild:a=!1,...r},s)=>e(a?f:"button",{ref:s,"data-sidebar":"group-action",className:Aa("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r}));ac.displayName="SidebarGroupAction";const rc=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"group-content",className:Aa("w-full text-sm",t),...a}));rc.displayName="SidebarGroupContent";const sc=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,"data-sidebar":"menu",className:Aa("flex w-full min-w-0 flex-col gap-1",t),...a}));sc.displayName="SidebarMenu";const nc=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,"data-sidebar":"menu-item",className:Aa("group/menu-item relative",t),...a}));nc.displayName="SidebarMenuItem";const ic=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 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),oc=r.forwardRef(({asChild:a=!1,isActive:r=!1,variant:s="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?f:"button",{isMobile:u,state:m}=qd(),h=e(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":r,className:Aa(ic({variant:s,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),t(Dd,{children:[e(zd,{asChild:!0,children:h}),e($d,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):h});oc.displayName="SidebarMenuButton";const lc=r.forwardRef(({className:t,asChild:a=!1,showOnHover:r=!1,...s},n)=>e(a?f:"button",{ref:n,"data-sidebar":"menu-action",className:Aa("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...s}));lc.displayName="SidebarMenuAction";const dc=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"menu-badge",className:Aa("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));dc.displayName="SidebarMenuBadge";const cc=r.forwardRef(({className:a,showIcon:s=!1,...n},i)=>{const o=r.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return t("div",{ref:i,"data-sidebar":"menu-skeleton",className:Aa("rounded-md h-8 flex gap-2 px-2 items-center",a),...n,children:[s&&e("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});cc.displayName="SidebarMenuSkeleton";const uc=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,"data-sidebar":"menu-sub",className:Aa("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));uc.displayName="SidebarMenuSub";const mc=r.forwardRef(({...t},a)=>e("li",{ref:a,...t}));mc.displayName="SidebarMenuSubItem";const hc=r.forwardRef(({asChild:t=!1,size:a="md",isActive:r,className:s,...n},i)=>e(t?f:"a",{ref:i,"data-sidebar":"menu-sub-button","data-size":a,"data-active":r,className:Aa("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",s),...n}));hc.displayName="SidebarMenuSubButton";const pc=r.forwardRef(({className:a,...r},s)=>t(It.Root,{ref:s,className:Aa("relative flex w-full touch-none select-none items-center",a),...r,children:[e(It.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e(It.Range,{className:"absolute h-full bg-primary"})}),e(It.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));pc.displayName=It.Root.displayName;const fc=({...t})=>{const{theme:a="system"}=At();return e(k,{theme:a,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})},gc=Rt.Root,bc=r.forwardRef(({className:t,...a},r)=>e(Rt.List,{ref:r,className:Aa("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));bc.displayName=Rt.List.displayName;const vc=r.forwardRef(({className:t,...a},r)=>e(Rt.Trigger,{ref:r,className:Aa("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));vc.displayName=Rt.Trigger.displayName;const yc=r.forwardRef(({className:t,...a},r)=>e(Rt.Content,{ref:r,className:Aa("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));function xc({children:t,className:a}){return e("div",{className:Aa("flex flex-col h-full",a),children:e(Zi,{className:"flex-1",children:e("div",{className:"space-y-6 p-6",children:t})})})}function Nc({title:a,description:r,actions:s,className:n}){return t("div",{className:Aa("space-y-4",n),children:[t("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[t("div",{className:"space-y-1",children:[e("h2",{className:"text-2xl font-bold tracking-tight",children:a}),r&&e("p",{className:"text-muted-foreground text-sm",children:r})]}),s&&e("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e(Cd,{})]})}function wc({children:t,className:a}){return e("div",{className:Aa("space-y-6",a),children:t})}yc.displayName=Rt.Content.displayName;const kc=g("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Sc=r.forwardRef(({className:t,variant:a,size:r,...s},n)=>e(Ot.Root,{ref:n,className:Aa(kc({variant:a,size:r,className:t})),...s}));Sc.displayName=Ot.Root.displayName;const Cc=r.createContext({size:"default",variant:"default"}),_c=r.forwardRef(({className:t,variant:a,size:r,children:s,...n},i)=>e(Lt.Root,{ref:i,className:Aa("flex items-center justify-center gap-1",t),...n,children:e(Cc.Provider,{value:{variant:a,size:r},children:s})}));_c.displayName=Lt.Root.displayName;const Pc=r.forwardRef(({className:t,children:a,variant:s,size:n,...i},o)=>{const l=r.useContext(Cc);return e(Lt.Item,{ref:o,className:Aa(kc({variant:l.variant||s,size:l.size||n}),t),...i,children:a})});function Ec({manager:a,config:r,onEdit:s,onDelete:n}){const{t:i}=Rs();return a.isLoading?e(Bl,{children:Array.from({length:3}).map((a,r)=>t(qa,{children:[t(Ba,{children:[e(ls,{className:"h-4 w-3/4"}),e(ls,{className:"h-3 w-1/2"})]}),e(Ka,{children:t("div",{className:"space-y-2",children:[e(ls,{className:"h-3 w-full"}),e(ls,{className:"h-3 w-2/3"})]})})]},r))}):e(Tl.Root,{children:a.entities.map(a=>t(Tl.Item,{onClick:()=>s(a),children:[e(Ba,{className:"pb-3",children:t("div",{className:"flex items-start justify-between",children:[t("div",{className:"flex-1 min-w-0",children:[e(Wa,{className:"text-base leading-6 truncate",children:a.title||a.name||i("no_title")}),e(Ha,{className:"text-sm",children:N(new Date(a.created_at),"dd/MM/yyyy HH:mm",{locale:Sl})})]}),t("div",{className:"flex items-center gap-2 ml-2",children:[a.link&&e(Da,{variant:"external-link",size:"icon-xs",onClick:e=>{e.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),w.info(i("link_copied")))}catch(t){window.location.href=e}})(a.link)},title:i("open_external_link"),children:e($e,{className:"h-4 w-4"})}),e("div",{onClick:e=>e.stopPropagation(),children:e(Ri,{onEdit:()=>s(a),onDelete:n?()=>n(a):void 0,canDelete:!!n})})]})]})}),e(Ka,{className:"pt-0",children:e("div",{className:"space-y-2",children:r.cardFields?.map(t=>{const r=a[t.key];return r?e(Tl.Field,{label:t.label,value:t.render?t.render(r,a):String(r)},String(t.key)):null})})})]},a.id))})}function Tc({data:a,columns:r,sortField:s,sortDirection:n,onSort:i,onRowClick:l,renderActions:d,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:h=!1,selectedIds:p=[],onSelectItem:f,onSelectAll:g,isAllSelected:b=!1}){const v=o(()=>{const e=r.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return r.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[r]);return c?e("div",{className:"flex-1 overflow-auto",children:e("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e(ls,{className:"h-12 w-full"},a))})}):0===a.length?e("div",{className:"flex-1 flex items-center justify-center",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:u})})}):e("div",{className:"flex-1 overflow-auto",children:t(ti,{className:m,children:[e(ai,{className:"sticky top-0 bg-background z-10",children:t(ni,{children:[h&&e(ii,{className:"w-[40px]",children:e(Cr,{checked:b,onCheckedChange:g,"aria-label":"Selecionar todos"})}),r.map((a,r)=>{return e(ii,{className:a.className,style:{width:v[r]},children:a.sortable&&i?t("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(o=String(a.key),s!==o?e(U,{size:14,className:"ml-1 opacity-50"}):e("asc"===n?V:q,{size:14,className:"ml-1"}))]}):e("span",{className:"font-medium",children:a.header})},String(a.key));var o}),d&&e(ii,{className:"w-[80px] text-right",children:"Ações"})]})}),e(ri,{children:a.map(a=>t(ni,{onClick:()=>l?.(a),className:l?"cursor-pointer":"",children:[h&&e(oi,{children:e(Cr,{checked:p.includes(a.id),onCheckedChange:()=>f?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),r.map(t=>e(oi,{className:t.className,children:t.render?t.render(a):String(a[t.key]??"-")},String(t.key))),d&&e(oi,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(a)})]},a.id))})]})})}function Ic({onEdit:a,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d="dropdown",variant:c="default"}){const{t:u}=Rs(),m=[];return a&&i&&m.push({icon:F,label:u("edit"),onClick:a,variant:"default"}),s&&m.push({icon:n?M:D,label:u(n?"deactivate":"activate"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),r&&o&&m.push({icon:z,label:u("remove"),onClick:r,variant:"destructive"}),0===m.length?null:"dropdown"===d?t(gi,{children:[e(bi,{asChild:!0,children:e(Da,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e(S,{size:"compact"===c?14:16})})}),e(Si,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,r)=>t(Ci,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},r))})]}):e("div",{className:"flex items-center gap-1",children:m.map((a,r)=>t(Da,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e("span",{className:"ml-1",children:a.label})]},r))})}function Ac({searchValue:a="",onSearchChange:r,customFilters:s=[],onClearFilters:n,showClearButton:i=!0,layout:o="horizontal"}){const{t:l}=Rs(),d=a||s.length>0;return t("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[r&&t("div",{className:"relative flex-1 min-w-[200px]",children:[e(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e($a,{type:"text",placeholder:l("search"),value:a,onChange:e=>r(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e("div",{className:"vertical"===o?"w-full":"",children:t},a)),i&&d&&n&&t(Da,{variant:"ghost",size:"sm",onClick:n,className:"h-9 px-3 whitespace-nowrap",children:[e(C,{size:14,className:"mr-1"}),l("clear_filters")]})]})}function Rc({data:t,renderCard:a,isLoading:r=!1,emptyMessage:s="Nenhum item encontrado",columns:n,gap:i="md",className:o}){return r?e(Bl,{cols:n?String(n):"auto-fit",gap:i,className:o,children:[...Array(6)].map((t,a)=>e(ls,{className:"h-48 w-full"},a))}):0===t.length?e("div",{className:"flex items-center justify-center p-8",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:s})})}):e(Bl,{cols:n?String(n):"auto-fit",gap:i,className:o,children:t.map(a)})}function Oc(e){const t=ht();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const r=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(r)}}}function Lc(e,t){const a=Oc({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}}Pc.displayName=Lt.Item.displayName;const jc=(e={})=>{const{alias:t}=$n(),{enabled:a=!0}=e;return lt({queryKey:["qualiex-all-users",t],queryFn:async()=>t?hn.getAllUsers(t):[],enabled:a&&!!t,staleTime:3e5,retry:2})};const Fc=new class{async getUserPreferences(e,t){if(!Hs.areAllTokensValid())return null;const a=an();try{const{data:r,error:s}=await a.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",t).maybeSingle();if(s)return"PGRST116"===s.code?this.createDefaultPreferences(e,t):("42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied"),null);if(!r)return this.createDefaultPreferences(e,t);const n=r;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(r){return null}}async createDefaultPreferences(e,t){const a=an(),r={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:t};try{const{data:e,error:t}=await a.schema("common").from("user_preferences").insert(r).select().single();if(t)throw t;const s=e;return{locale:s.locale,timezone:s.timezone,datetimeFormat:s.datetime_format}}catch(s){throw s}}async updatePreferences(e,t,a){const r=an();try{const{error:s}=await r.schema("common").from("user_preferences").update(a).eq("id_user",e).eq("alias",t);if(s)throw s}catch(s){throw s}}};var Mc=Object.defineProperty,Dc=(e,t,a)=>((e,t,a)=>t in e?Mc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const zc=new class{constructor(){Dc(this,"cache",{}),Dc(this,"cacheTimestamps",new Map),Dc(this,"CACHE_TTL",3e5),Dc(this,"loadingPromises",new Map)}isCacheValid(e){const t=this.cacheTimestamps.get(e);return!!t&&Date.now()-t<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const t=this.loadingPromises.get(e);if(t)return t;const a=this.fetchTranslations(e);this.loadingPromises.set(e,a);try{return await a}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{if(!Hs.areAllTokensValid())return{};const t=an(),{data:a,error:r}=await t.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(r)return"42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied")||r.message?.includes("No suitable key"),{};const s={};return a?.forEach(t=>{let a;a="pt-BR"===e?t.pt:"en-US"===e?t.en||t.pt:"es-ES"===e&&t.es||t.pt,a&&(s[t.key]=a)}),this.cache[e]=s,this.cacheTimestamps.set(e,Date.now()),s}catch(t){return{}}}async upsertTranslation(e,t,a,r){const s=an(),{error:n}=await s.schema("common").from("translations").upsert({key:e,pt:t,en:a,es:r},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const t=an(),{error:a}=await t.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(a)throw a;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var $c=Object.defineProperty,Uc=(e,t,a)=>((e,t,a)=>t in e?$c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Vc="true"===import.meta.env.VITE_I18N_DEBUG_MODE;Ta.use(new class{constructor(e=!1){Uc(this,"type","backend"),Uc(this,"isDebugMode"),Uc(this,"cache",new Map),Uc(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,t,a){if(!Hs.areAllTokensValid())return void a(null,{});if(this.cache.has(e))return void a(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{a(null,this.cache.get(e)||{})});const r=zc.loadTranslations(e).then(t=>{if(this.isDebugMode){const a={};Object.keys(t).forEach(e=>{a[e]=`[${e} ✅]`}),this.cache.set(e,a)}else this.cache.set(e,t)}).catch(t=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,r),r.then(()=>{a(null,this.cache.get(e)||{})})}create(e,t,a,r){}}(Vc)).use(xs).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,t)=>Vc?`[${e} ❌]`:`[⚠️ ${e}]`});const qc=n(void 0),Bc=({children:t})=>{const{user:a,alias:r}=$n(),[s,n]=c({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[i,o]=c(!0);u(()=>{(async()=>{if(a?.id&&r)try{const e=await Fc.getUserPreferences(a.id,r);e&&(n({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await Ta.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{o(!1)}else o(!1)})()},[a?.id,r]);const l=d(async e=>{if(a?.id&&r)try{await Fc.updatePreferences(a.id,r,{locale:e}),n(t=>({...t,locale:e})),await Ta.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(t){throw t}},[a?.id,r]),m=d(async e=>{if(a?.id&&r)try{await Fc.updatePreferences(a.id,r,{timezone:e}),n(t=>({...t,timezone:e}))}catch(t){throw t}},[a?.id,r]),h=d(async e=>{if(a?.id&&r)try{await Fc.updatePreferences(a.id,r,{datetime_format:e}),n(t=>({...t,datetimeFormat:e}))}catch(t){throw t}},[a?.id,r]);return e(qc.Provider,{value:{...s,setLocale:l,setTimezone:m,setDatetimeFormat:h,isLoading:i},children:t})},Wc=()=>{const e=i(qc);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},Hc=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Kc=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],Qc=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/New_York",label:"New York (UTC-5/-4)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6/-5)",offset:"-06:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8/-7)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0/+1)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1/+2)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1/+2)",offset:"+01:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10/+11)",offset:"+10:00"}],Gc=()=>{const{locale:a,datetimeFormat:r,timezone:s,setLocale:n,setDatetimeFormat:i,setTimezone:o}=Wc(),{t:l}=Rs();return t("div",{className:"space-y-4 p-4",children:[t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(Ue,{className:"h-4 w-4"}),l("language")]}),t(fr,{value:a,onValueChange:n,children:[e(vr,{children:e(br,{})}),e(Nr,{children:Hc.map(e=>t(kr,{value:e.value,children:[e.flag," ",e.label]},e.value))})]})]}),t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(pe,{className:"h-4 w-4"}),l("timezone")||"Fuso Horário"]}),t(fr,{value:s,onValueChange:o,children:[e(vr,{children:e(br,{})}),e(Nr,{children:Qc.map(t=>e(kr,{value:t.value,children:t.label},t.value))})]})]}),t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(Pe,{className:"h-4 w-4"}),l("dateTimeFormat")||"Formato de Data/Hora"]}),t(fr,{value:r,onValueChange:i,children:[e(vr,{children:e(br,{})}),e(Nr,{children:Kc.map(a=>e(kr,{value:a.value,children:t("div",{className:"flex flex-col items-start",children:[e("span",{children:a.label}),t("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},Jc=s.memo(({variant:r="card",className:n="",selectedUnit:i,onUnitChange:o})=>{const{user:l,companies:d,alias:u,isAuthenticated:m,logout:h,switchUnit:p}=$n(),[f,g]=c(!1),b=d?.[0]||null,v=u?d?.find(e=>e.alias===u):b,y=d||[],x=i||v||b||b,N=s.useCallback(e=>{o?o(e):p(e)},[o,p]),w=s.useMemo(()=>{if(!y?.length)return[];const e=new Map;y.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===x?.alias),r=t.filter(e=>e.alias!==x?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...r]:r},[y,x?.alias]);if(!m||!l)return null;const k=()=>t(a,{children:[t("div",{className:"flex items-center space-x-3",children:[e("div",{className:"flex-shrink-0",children:e("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e(Ae,{className:"h-5 w-5 text-primary-foreground"})})}),t("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:l.name}),t("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e("div",{className:"mt-3",children:t("div",{className:"flex items-center space-x-2",children:[e(Ve,{className:"h-4 w-4 text-muted-foreground"}),e("span",{className:"text-sm font-medium",children:x.name})]})}),w.length>1&&t("div",{className:"mt-2",children:[t("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",w.length]}),t("div",{className:"flex flex-wrap gap-1",children:[w.slice(0,3).map(t=>e(Er,{variant:t.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>N(t),children:t.name},t.alias)),w.length>3&&t(Er,{variant:"outline",className:"text-xs",children:["+",w.length-3]})]})]})]});return"dropdown"===r?t(gi,{children:[e(bi,{asChild:!0,children:e(Da,{variant:"ghost",className:`h-auto p-2 ${n}`,children:t("div",{className:"flex items-center space-x-2",children:[t("div",{className:"hidden md:block text-left",children:[e("p",{className:"text-sm font-medium",children:l.name}),e("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e(Ae,{className:"h-4 w-4 text-primary-foreground"})}),e(_,{className:"h-4 w-4"})]})})}),t(Si,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[t(xi,{children:[t(wi,{children:[e(Me,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e(ki,{children:w.map(a=>t(Ci,{onClick:()=>N(a),className:a.alias===x?.alias?"bg-muted":"",children:[e(Ve,{className:"mr-2 h-4 w-4"}),a.name,a.alias===x?.alias&&e(Er,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),e(Ti,{}),t(Ci,{onClick:()=>g(!0),children:[e(Ie,{className:"mr-2 h-4 w-4"}),"Preferências"]}),t(Ci,{onClick:h,children:[e(qe,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),e(Ga,{open:f,onOpenChange:g,children:t(er,{children:[e(tr,{children:e(rr,{children:"Preferências de Internacionalização"})}),e(Gc,{})]})})]}):t(qa,{className:n,children:[e(Ba,{children:e(Wa,{className:"text-lg",children:"Informações do Usuário"})}),t(Ka,{className:"space-y-4",children:[e(k,{}),e(Cd,{}),t(Da,{variant:"outline",onClick:()=>g(!0),size:"sm",className:"w-full",children:[e(Ie,{className:"mr-2 h-4 w-4"}),"Preferências"]}),t(Da,{variant:"outline",onClick:h,size:"sm",className:"w-full",children:[e(qe,{className:"mr-2 h-4 w-4"}),"Sair"]}),e(Ga,{open:f,onOpenChange:g,children:t(er,{children:[e(tr,{children:e(rr,{children:"Preferências de Internacionalização"})}),e(Gc,{})]})})]})]})}),Xc=n({});function Yc({children:t,config:a}){const r=o(()=>({navigation:a?.navigation,appName:a?.appName}),[a?.navigation,a?.appName]);return e(Xc.Provider,{value:r,children:t})}function Zc(){return i(Xc)}function eu(){const e=mt(),{navigation:t}=Zc(),{t:a}=Rs();if(!t)return a("page");const r=t.find(t=>t.path===e.pathname);if(r)return r.label;const s=t.find(t=>e.pathname.startsWith(t.path+"/"));return s?.label||a("page")}function tu(e,t){const[a,r]=c(e),s=l(),n=d(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return u(()=>(n(),s.current=setTimeout(()=>{r(e)},t),n),[e,t,n]),[a,n]}const au=h(function({actions:a}){const r=mt(),s=eu(),{navigation:n,appName:i}=Zc(),{metadata:o,headerActions:l}=Mo(),{t:d}=Rs(),{companies:m,alias:h,isSearchVisible:p,clearSearch:f,refreshData:g,switchUnit:b}=$n(),v=h?m?.find(e=>e.alias===h)||m?.[0]||null:m?.[0]||null,[y,x]=ut(),[N,w]=c(()=>y.get("search")||""),[k,S]=tu(N,gn.debounceDelay);u(()=>{if(!p)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),x(e)},[k,x,p]);const _=n?.find(e=>e.path===r.pathname)||n?.find(e=>r.pathname.startsWith(e.path+"/")),P=o.title||s,E=o.subtitle||_?.complementaryText||d("item_details");return e("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:t("div",{className:"flex items-center gap-4",children:[t("div",{className:"flex-shrink-0",children:[t("div",{className:"flex items-center gap-2 mb-1",children:[e("h1",{className:"text-lg font-semibold text-foreground truncate",children:P}),e(Er,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||d("module")})]}),E&&e("p",{className:"text-sm text-muted-foreground truncate",children:E})]}),p&&t("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[t("div",{className:"relative flex-1",children:[e(R,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e($a,{placeholder:d("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e(Da,{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:()=>{S(),w("");const e=new URLSearchParams(y);e.delete("search"),e.delete("page"),x(e)},title:d("clear_search"),children:e(C,{size:14})})]}),e(Da,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0",title:d("refresh_data"),children:e(Me,{size:14})})]}),t("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||a)&&e("div",{className:"flex items-center gap-2",children:l||a}),import.meta.env.VITE_WIKI_URL&&e(Da,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Ia(import.meta.env.VITE_WIKI_URL,e),title:d("open_wiki"),children:"Wiki"}),e("div",{className:"text-sm",children:e(Jc,{variant:"dropdown",selectedUnit:v,onUnitChange:b})})]})]})})}),ru=({key:e,enabled:t,checkFn:a,staleTime:r=3e5,gcTime:s=6e5})=>lt({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1}),su=(e={})=>{const{enabled:t=!0}=e,{alias:a}=$n();return lt({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=an(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(r){if(!ln.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!a})},nu="forlogic-sidebar-pinned",iu=()=>{try{const e=localStorage.getItem(nu);return!!e&&JSON.parse(e)}catch{return!1}},ou=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]},lu=`https://${import.meta.env.VITE_SUPABASE_PROJECT_ID_STORAGE??import.meta.env.VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,du={logo:`${lu}/${Nn.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${lu}/${Nn.isQualiex?"small-forlogic.svg":"small.svg"}`},cu=du.logo,uu=du.smallLogo;function mu({appName:r,isPinned:s,onPinToggle:n,open:i,dropdownOpen:o,onDropdownChange:l}){const{t:d}=Rs(),{data:c,isLoading:u,error:m}=su({enabled:o}),h=e=>{((e,t)=>{const a=e?.find(e=>e.url===t);a?.url&&window.open(a.url,"_blank")})(c,e)};return t(Jd,{className:"p-0 gap-0",children:[e("div",{className:"flex items-center justify-between h-[34px]",children:i?t(a,{children:[e("div",{className:"flex items-center pl-[12px]",children:e("img",{src:du.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(s?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e(ze,{className:"h-4 w-4"})})]}):e("div",{className:"flex items-center justify-center w-full h-[34px]",children:e("img",{src:du.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e("div",{className:"mt-2 pt-0",children:t(gi,{onOpenChange:l,children:[e(bi,{asChild:!0,children:i?t("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[t("div",{className:"flex items-center gap-2 min-w-0",children:[e("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:r})]}),e(_,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e(_,{className:"h-6 w-6 text-muted-foreground"})})}),e(Si,{className:i?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:i?"start":"center",children:u?t("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e(T,{className:"h-4 w-4 animate-spin"}),e("span",{className:"text-sm",children:d("loading")})]}):m?t("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e(I,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:d("error")})]}):c&&0!==c.length?e("div",{className:"space-y-2",children:c.map((a,r)=>e("div",{onClick:()=>h(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${ou(r)} transition-colors duration-200\n `,children:t("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-medium text-foreground text-sm",children:a.name}),a.url&&e($e,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:d("no_results")})})]})})]})}function hu({direction:e="right",minWidth:t=224,maxWidth:a=384,defaultWidth:r=240,storageKey:s="sidebar-width",onResize:n,isOpen:i=!0}={}){const[o,m]=c(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(s);return e?parseInt(e):r}),[h,p]=c(!1),f=l(null);u(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${o}px`):e.style.setProperty("--sidebar-width","240px"))},[o,i]);const g=d(e=>{e.preventDefault(),p(!0)},[]);return u(()=>{if(!h)return;const r=r=>{let s;s="left"===e?window.innerWidth-r.clientX:r.clientX,s=Math.max(t,Math.min(a,s)),m(s),n?.(s)},i=()=>{p(!1),localStorage.setItem(s,o.toString())};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)}},[h,e,t,a,o,s,n]),u(()=>{h?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h,e]),{width:o,isDragging:h,dragRef:f,handleMouseDown:g}}const pu=s.forwardRef(({className:t,onMouseDown:a,isDragging:r,...s},n)=>e("div",{ref:n,onMouseDown:a,className:Aa("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",r&&"bg-primary/40",t),...s}));function fu({config:a,customContent:r,resizable:s=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=Rs(),{open:d,setOpen:m}=qd(),h=mt(),{alias:p,user:f}=$n(),[g,b]=c(!1),[v,y]=c(iu),[x,N]=c(!1),w=l(!1),k=s?hu({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:d}):null;u(()=>{m(!!v||!(!x&&!g))},[v,x,g,m]);return t(Wd,{collapsible:"icon",onMouseEnter:()=>{v||w.current||N(!0)},onMouseLeave:()=>{v||N(!1)},className:"app-sidebar bg-white border-r border-gray-200 py-6 px-3",style:k&&d?{width:`${k.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e(mu,{appName:a?.appName||o("module_title"),isPinned:v,onPinToggle:()=>{const e=!v;y(e),(e=>{try{localStorage.setItem(nu,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),m(!1),setTimeout(()=>{w.current=!1},300))},open:d,dropdownOpen:g,onDropdownChange:b}),e(Zd,{children:r||e(ec,{className:"p-0 mt-6",children:e(rc,{children:e(sc,{className:"space-y-2",children:e(Md,{children:a?.navigation?.map((a,r)=>{const s=({item:a,index:r})=>{const n=`${a.path}-${r}-${p??"noalias"}-${f?.id??"nouser"}`,{data:i=!0,isLoading:l}=ru({key:n,enabled:Boolean(a.permissionCheck&&p&&f?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),d=a.permissionCheck&&!i;if(d&&"Admin"===a.label)return null;const c=l?T:d?te:a.icon;d?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e(_l,{defaultOpen:!0,className:"group/collapsible",children:t(nc,{children:[e(Pl,{asChild:!0,children:e(oc,{size:"lg",className:"h-10",children:t("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label}),e(L,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e(El,{children:e(uc,{children:a.children.map((t,a)=>e(s,{item:t,index:a},t.path))})})]})},a.path):e(nc,{children:d||l?t(Dd,{children:[e(zd,{asChild:!0,children:e(oc,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:t("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-4 w-4 "+(l?"animate-spin":"")})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})}),e($d,{children:e("p",{children:o(l?"checking_access":"restricted_access")})})]}):e(oc,{asChild:!0,isActive:(u=a.path,h.pathname===u||h.pathname.startsWith(u+"/")),size:"lg",className:"h-10",children:t(pt,{to:a.path,className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})},a.path);var u};return e(s,{item:a,index:r},a.path)})})})})})}),s&&k&&d&&e(pu,{ref:k.dragRef,onMouseDown:k.handleMouseDown,isDragging:k.isDragging})]})}pu.displayName="ResizableRail";const gu=h(function({children:a,sidebar:r,sidebarConfig:s,showHeader:n=!0}){const i=o(()=>r||e(fu,{config:s}),[r,s]),l=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e(Yc,{config:s,children:e(Fo,{children:e(Bd,{defaultOpen:!1,style:l,children:t("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,t("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e(au,{})}),e("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:a})]})]})})})})});var bu=Object.defineProperty,vu=(e,t,a)=>((e,t,a)=>t in e?bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class yu extends p{constructor(e){super(e),vu(this,"copyErrorDetails",()=>{const e=Gs.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),zr({title:"Detalhes copiados!",description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if(import.meta.env.DEV)throw e;Gs.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Gs.getErrors().slice(0,2);return e("div",{className:"flex items-center justify-center min-h-screen p-4",children:t(qa,{className:"w-full max-w-2xl",children:[t(Ba,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(A,{className:"h-12 w-12 text-destructive"})}),e(Wa,{children:"Algo deu errado"})]}),t(Ka,{className:"space-y-4",children:[e("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),t(_l,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e(Pl,{asChild:!0,children:t(Da,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e(_,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),t(El,{className:"mt-4 space-y-4",children:[t("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[t("div",{children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),t("div",{className:"text-sm space-y-2",children:[e("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e(Zi,{className:"h-32 w-full rounded border bg-muted p-2",children:e("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&t("div",{className:"pt-3 border-t",children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e("div",{className:"space-y-2",children:a.map((a,r)=>e("div",{className:"text-sm p-2 rounded bg-muted/50",children:t("div",{className:"flex items-start gap-2",children:[t("span",{className:"font-medium text-muted-foreground shrink-0",children:[r+1,"."]}),t("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 flex-wrap",children:t("span",{className:"text-xs text-muted-foreground",children:["[",new Date(a.timestamp).toLocaleTimeString(),"]"]})}),e("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),t(Da,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e(oe,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e(Da,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}function xu({children:r}){const{ready:s}=Rs(),[n,i]=c(!0);return u(()=>{s&&n&&i(!1)},[s,n]),n&&!s?e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:t("div",{className:"flex flex-col items-center gap-4",children:[e(Ir,{size:"lg"}),e("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e(a,{children:r})}const Nu={"pt-BR":Sl,"en-US":ul,"es-ES":vl},wu=(e,t="pt-BR")=>{if(!e)return"";const a=y(e);if(!x(a))return"Invalid date";return N(a,"PP",{locale:Nu[t]||Sl})},ku=()=>{const{locale:e,timezone:t,datetimeFormat:a}=Wc();return{formatDatetime:e=>((e,t="dd/MM/yyyy HH:mm")=>{if(!e)return"";const a=y(e);return x(a)?N(a,t):"Invalid date"})(e,a,t),formatDate:t=>wu(t,e),locale:e,timezone:t,datetimeFormat:a}};class Su{static async sendEmail(e){const t=an(),{data:a,error:r}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return a}}const Cu=Su;function _u(){const[e,t]=c([]),[a,r]=c(!1),[s,n]=c(null),[i,o]=c(null);u(()=>{l()},[]);const l=async()=>{try{const e=an(),{data:a,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;n(a.threadId),t([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){o("Erro ao inicializar conversa"),w.error("Erro ao inicializar conversa")}};return{messages:e,isLoading:a,error:i,sendMessage:d(async e=>{if(!s||!e.trim())return;const a={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,a]),r(!0),o(null);try{const a=an(),{data:r,error:n}=await a.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:s,message:e}});if(n)throw n;const{runId:i}=r,o=await(async e=>{if(!s)return!1;for(let a=0;a<60;a++)try{const t=an(),{data:a,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:s,runId:e}});if(r)throw r;const{status:n}=a;if("completed"===n)return!0;if("failed"===n||"cancelled"===n)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(i);o&&await(async()=>{if(s)try{const e=an(),{data:a,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:s}});if(r)throw r;const n=a.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));t(n)}catch(e){throw e}})()}catch(n){const e=n instanceof Error?n.message:"Erro ao enviar mensagem";o(e),w.error(e),t(e=>e.filter(e=>e.id!==a.id))}finally{r(!1)}},[s]),threadId:s}}function Pu({content:t,className:a}){return e("div",{className:Aa("prose prose-sm max-w-none",a),children:e(jt,{remarkPlugins:[Ft],components:{h1:({children:t})=>e("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:t}),h2:({children:t})=>e("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:t}),h3:({children:t})=>e("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:t}),p:({children:t})=>e("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:t}),ul:({children:t})=>e("ul",{className:"list-disc list-inside mb-2 space-y-1",children:t}),ol:({children:t})=>e("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:t}),li:({children:t})=>e("li",{className:"text-sm text-foreground",children:t}),code:({inline:t,children:a,...r})=>e("code",t?{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...r,children:a}:{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...r,children:a}),pre:({children:t})=>e("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:t}),a:({children:t,href:a})=>e("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:t}),blockquote:({children:t})=>e("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:t}),strong:({children:t})=>e("strong",{className:"font-bold text-foreground",children:t}),em:({children:t})=>e("em",{className:"italic text-foreground",children:t})},children:t})})}function Eu(){const{t:r}=Rs(),[s,n]=c(!1),[i,o]=c(""),{messages:d,isLoading:m,error:h,sendMessage:p}=_u(),f=l(null),g=l(null);u(()=>{if(f.current){const e=f.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[d]),u(()=>{s&&g.current&&g.current.focus()},[s]),u(()=>{const e=e=>{"Escape"===e.key&&s&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]);const b=()=>{i.trim()&&!m&&(p(i),o(""))};return t(a,{children:[e(Da,{onClick:()=>n(!s),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e(s?C:Be,{className:"h-6 w-6"})}),s&&t(qa,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[t(Ba,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e(Wa,{className:"text-lg font-semibold",children:r("title")}),e(Da,{variant:"ghost",size:"icon",onClick:()=>n(!1),className:"h-8 w-8",children:e(C,{className:"h-4 w-4"})})]}),t(Ka,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[e(Zi,{ref:f,className:"flex-1 px-4",children:t("div",{className:"space-y-4 py-4",children:[d.map(t=>e("div",{className:"flex "+("user"===t.role?"justify-end":"justify-start"),children:e("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===t.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===t.role?e(Pu,{content:t.content}):e("p",{className:"text-sm whitespace-pre-wrap",children:t.content})})},t.id)),m&&e("div",{className:"flex justify-start",children:e("div",{className:"bg-muted rounded-lg px-4 py-2",children:t("div",{className:"flex space-x-2",children:[e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),h&&e("div",{className:"text-center text-sm text-destructive py-2",children:h})]})}),e("div",{className:"border-t p-4",children:t("div",{className:"flex space-x-2",children:[e($a,{ref:g,value:i,onChange:e=>o(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:r("placeholder"),disabled:m,className:"flex-1"}),e(Da,{onClick:b,disabled:m||!i.trim(),size:"icon",children:e(We,{className:"h-4 w-4"})})]})})]})]})]})}function Tu({open:a,onOpenChange:r,placeId:s,placeName:n,onMakeManager:i,onMakeMembers:l,currentManagerId:d,currentMemberIds:u=[]}){const{t:m}=Rs(),[h,p]=c([]),[f,g]=c(!1),[b,v]=c(""),{data:y=[],isLoading:x}=so({enabled:a}),N=o(()=>{let e=[...y];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",r=t.userName?.toLowerCase()||"";return a.localeCompare(r)}),b){const t=b.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[y,b]),w=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},k=1===h.length,S=h.length>0;return e(Ga,{open:a,onOpenChange:r,children:t(er,{className:"max-w-2xl",children:[e(tr,{children:t(rr,{className:"flex items-center gap-2",children:[e(He,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),t("div",{className:"relative",children:[e(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e($a,{placeholder:m("search_placeholder"),value:b,onChange:e=>v(e.target.value),className:"pl-9"})]}),e(Zi,{className:"h-[400px] pr-4",children:x?e("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e(ls,{className:"h-16 w-full"},a))}):0===N.length?t("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e(He,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e("p",{className:"text-sm text-muted-foreground",children:b?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e("div",{className:"space-y-2",children:N.map(a=>{const r=a.userId===d,s=u.includes(a.userId||""),n=h.includes(a.userId||"");return t("div",{className:Aa("flex items-center gap-3 p-3 rounded-lg border transition-colors",n&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(a.userId||""),children:[e(Cr,{checked:n,onCheckedChange:()=>w(a.userId||""),onClick:e=>e.stopPropagation()}),t("div",{className:"flex-1",children:[t("div",{className:"flex items-center gap-2",children:[e("p",{className:"font-medium",children:a.userName}),r&&e(Ke,{className:"h-4 w-4 text-yellow-500"})]}),e("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(r||s)&&e("div",{className:"text-xs text-muted-foreground",children:r?"Gestor":"Membro"})]},a.userId)})})}),t(ar,{className:"flex gap-2 sm:gap-2",children:[e("div",{className:"flex-1 text-sm text-muted-foreground",children:h.length>0&&t("span",{children:[h.length," selecionado(s)"]})}),k&&i&&t(Da,{onClick:async()=>{if(i&&1===h.length){g(!0);try{await i(h[0],s),p([])}finally{g(!1)}}},disabled:f,variant:"outline",children:[e(Ke,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),S&&l&&t(Da,{onClick:async()=>{if(l&&0!==h.length){g(!0);try{await l(h,s),p([])}finally{g(!1)}}},disabled:f,children:[e(Qe,{className:"h-4 w-4 mr-2"}),"Tornar ",h.length>1?"Membros":"Membro"]})]})]})})}function Iu({place:a,level:r=0,manageAccessConfig:s}){const[n,i]=c(!1),[o,l]=c(!1),d=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return t("div",{children:[t(_l,{open:n,onOpenChange:i,children:[t("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*r+1+"rem"},children:[d?t(Pl,{className:"flex items-center gap-2 flex-1",children:[e(L,{className:Aa("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e(Ve,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:a.name}),t("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):t("div",{className:"flex items-center gap-2 flex-1",children:[e("div",{className:"w-4 shrink-0"}),e(Ve,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:a.name})]}),t("div",{className:"flex items-center gap-3 ml-auto",children:[t("div",{className:"flex items-center gap-1.5",children:[e(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e("span",{className:"text-sm text-muted-foreground",children:m})]}),e(Er,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),s&&e(Ic,{customActions:[{label:"Gerenciar Acessos",icon:Ie,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),d&&e(El,{children:a.subPlaces.map(t=>e(Iu,{place:t,level:r+1,manageAccessConfig:s},t.id))})]}),0===r&&e(Cd,{}),s&&e(Tu,{open:o,onOpenChange:l,placeId:a.id,placeName:a.name,onMakeManager:s.onMakeManager,onMakeMembers:s.onMakeMembers,currentManagerId:s.getCurrentManagerId?.(a.id),currentMemberIds:s.getCurrentMemberIds?.(a.id)})]})}function Au({places:a,isLoading:r,manageAccessConfig:s}){const{t:n}=Rs();return r?e("div",{className:"flex items-center justify-center py-12",children:t("div",{className:"text-center space-y-2",children:[e("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e("p",{className:"text-sm text-muted-foreground",children:n("loading_data")})]})}):a&&0!==a.length?t("div",{className:"space-y-1",children:[e("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(t=>e(Iu,{place:t,manageAccessConfig:s},t.id))]}):t("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e(Ve,{className:"h-12 w-12 text-muted-foreground/50"}),t("div",{children:[e("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var Ru=Object.defineProperty,Ou=(e,t,a)=>((e,t,a)=>t in e?Ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const Lu=new class{constructor(){Ou(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=cn.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Hs.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=t.get(e.id);if(e.parentId){const s=t.get(e.parentId);s?(s.subPlaces=s.subPlaces||[],s.subPlaces.push(r)):a.push(r)}else a.push(r)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=a.data||a||[];return this.buildHierarchy(r)}catch(a){if(await cn.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=a.data||a||[];return this.buildHierarchy(r)}catch(r){return Gs.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return Gs.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function ju(e,t){const a=e.map(e=>({...e})),r=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&r.has(e.id_leader)){let t=e.id_leader;for(;t&&r.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))}function Fu(e){const t=new Map,a=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};t.set(e.id,r),a.set(e.id_user,r)}),e.forEach(e=>{const s=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(s)}r.push(s)});const s=(e,t)=>{e.level=t,e.children.forEach(e=>s(e,t+1))};r.forEach(e=>s(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",r=t.name||t.id_user||t.email||"";return a.localeCompare(r)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(r),r}function Mu(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Du(){const{alias:e,isAuthenticated:t}=$n(),a=Hs.getAccessToken(),{data:r=[]}=so({enabled:!0});return lt({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=an(),{data:s,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!s||0===s.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=s.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:s.filter(t=>t.id_leader===e.id_user).length})),l=new Set(s.map(e=>e.id_user));return new Set(s.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=i[e];o.push({id:`virtual-${e}`,alias:s[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:s.filter(t=>t.id_leader===e).length})}),Fu(o)},enabled:!!a&&!!e&&t&&r.length>0})}function zu(){const e="common",{alias:t}=$n(),a=ot(),r=an();return dt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",a.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");a.id_leader&&await Wu(r,t,e,a.id_user,a.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder adicionado com sucesso")},onError:e=>{w.error(e.message||"Erro ao adicionar líder")}})}function $u(){const e="common",{alias:t}=$n(),a=ot(),r=an();return dt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Wu(r,t,e,a.id_user,a.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder virtual promovido com sucesso")},onError:e=>{w.error(e.message||"Erro ao criar líder")}})}function Uu(){const e="common",{alias:t}=$n(),a=ot(),r=an();return dt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(!a.users.length)throw new Error("Selecione pelo menos um liderado");const s=a.users.map(e=>e.id_user),{data:n}=await r.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",s).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Wu(r,t,e,d.id_user,a.id_leader)}const i=a.users.map(e=>({alias:t,id_user:e.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{w.error(e.message||"Erro ao adicionar liderados")}})}function Vu(){const e="common",{alias:t}=$n(),a=ot(),r=an();return dt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");const{data:s}=await r.schema(e).from("leaders").select("id_user").eq("id",a.id).eq("alias",t).single();if(!s)throw new Error("Líder não encontrado");if(s.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Wu(r,t,e,s.id_user,a.id_leader,a.id);const{data:n,error:i}=await r.schema(e).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",t).select().single();if(i)throw i;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder atualizado com sucesso")},onError:e=>{w.error(e.message||"Erro ao atualizar líder")}})}function qu(){const{alias:e}=$n(),t=ot(),a=an();return dt({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await a.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),w.success("Líder removido com sucesso")},onError:e=>{w.error(e.message||"Erro ao remover líder")}})}function Bu(){const e="common",{alias:t}=$n(),a=ot(),r=an();return dt({mutationFn:async({leaderUserId:a,selectedUsers:s})=>{if(!t)throw new Error("Unidade não selecionada");const n=s.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",a),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:o,error:l},{data:d,error:c}]=i;if(l)throw l;if(c)throw c;const u=o||[],m=d||[],h=new Set(n),p=u.filter(e=>!h.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),g=new Set(m.map(e=>e.id_user)),b=s.filter(e=>!g.has(e.id_user));for(const x of f)await Wu(r,t,e,x.id_user,a,x.id);for(const x of b){if(x.id_user===a)throw new Error("Usuário não pode ser seu próprio líder");await Wu(r,t,e,x.id_user,a)}const v=[];if(p.length){const a=p.map(e=>e.id);v.push(r.schema(e).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",t))}if(f.length){const s=f.map(e=>e.id);v.push(r.schema(e).from("leaders").update({id_leader:a}).in("id",s).eq("alias",t))}if(b.length){const s=b.map(e=>({alias:t,id_user:e.id_user,id_leader:a,is_active:!0,is_removed:!1}));v.push(r.schema(e).from("leaders").insert(s))}const y=(await Promise.all(v)).find(e=>e?.error);if(y?.error)throw y.error;return{unlinked:p.length,updated:f.length,created:b.length}},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{w.error(e.message||"Erro ao sincronizar subordinados")}})}async function Wu(e,t,a,r,s,n){const{data:i,error:o}=await e.schema(a).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=s;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===r)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function Hu({leader:r,expandedIds:s,onToggleExpand:n,onEdit:i}){const o=s.has(r.id),l=r.children.length>0,d=32*r.level;return t(a,{children:[t("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e("td",{className:"py-3 px-4",children:t("div",{className:"flex items-center gap-2",style:{paddingLeft:`${d}px`},children:[l?e("button",{onClick:()=>n(r.id),className:"p-1 hover:bg-accent rounded",children:e(o?_:L,{className:"h-4 w-4"})}):e("div",{className:"w-6"}),e(Ae,{className:"h-4 w-4 text-muted-foreground"}),e("button",{onClick:()=>{i(r)},className:"font-medium hover:text-primary hover:underline text-left",children:r.name||r.id_user||r.email})]})}),e("td",{className:"py-3 px-4 text-center",children:e("span",{className:"text-sm",children:r.subordinatesCount||0})})]}),l&&o&&r.children.map(t=>e(Hu,{leader:t,expandedIds:s,onToggleExpand:n,onEdit:i},t.id))]})}var Ku=function(e,t){for(var a={};e.length;){var r=e[0],s=r.code,n=r.message,i=r.path.join(".");if(!a[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];a[i]={message:o.message,type:o.code}}else a[i]={message:n,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[i].types,d=l&&l[r.code];a[i]=et(i,t,a,s,d?[].concat(d,r.message):r.message)}e.shift()}return a},Qu=function(e,t,a){return void 0===a&&(a={}),function(r,s,n){try{return Promise.resolve(function(s,i){try{var o=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](r,t)).then(function(e){return n.shouldUseNativeValidation&&Dt({},n),{errors:{},values:a.raw?r:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:zt(Ku(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const Gu=Mt.object({id_leader:Mt.string().nullable(),id_users:Mt.array(Mt.string()).min(1,"Selecione pelo menos um liderado")}),Ju=Mt.object({id_leader:Mt.string().nullable(),id_users:Mt.array(Mt.string())});function Xu({value:a,onChange:r,excludeUserIds:s=[],error:n}){const{data:i=[],isLoading:o}=so(),[d,m]=c(""),h=l(null),p=l(0),{t:f}=Rs(),g=i.filter(e=>!s.includes(e.userId||"")).filter(e=>{const t=d.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const r=a.includes(e.userId),s=a.includes(t.userId);if(r&&!s)return-1;if(!r&&s)return 1;const n=e.userName||e.userEmail||"",i=t.userName||t.userEmail||"";return n.localeCompare(i)});return u(()=>{h.current&&p.current>0&&(h.current.scrollTop=p.current)},[g]),t("div",o?{className:"flex items-center justify-center p-4",children:[e(T,{className:"h-6 w-6 animate-spin"}),e("span",{className:"ml-2",children:f("loading_data")})]}:{className:"space-y-2",children:[e($a,{placeholder:f("search_user"),value:d,onChange:e=>m(e.target.value)}),e("div",{ref:h,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===g.length?e("p",{className:"text-sm text-muted-foreground",children:f("search_user")}):e("div",{className:"space-y-2",children:g.map(s=>t("div",{className:"flex items-center space-x-2",children:[e(Cr,{id:s.userId,checked:a.includes(s.userId),onCheckedChange:()=>{return e=s.userId,h.current&&(p.current=h.current.scrollTop),void(a.includes(e)?r(a.filter(t=>t!==e)):r([...a,e]));var e}}),e(Va,{htmlFor:s.userId,className:"flex-1 cursor-pointer",children:s.userName||s.userEmail})]},s.userId))})}),a.length>0&&e("p",{className:"text-sm text-muted-foreground",children:f("selected_count",{count:a.length})}),n&&e("p",{className:"text-sm text-destructive",children:n})]})}function Yu({leader:r,prefilledLeaderId:s,onSuccess:n}){const{t:i}=Rs(),{alias:o}=$n(),l=!!r,d=r?.id.startsWith("virtual-"),m=Uu(),h=$u(),p=Vu(),f=Bu(),g=qu(),{data:b=[]}=Du(),{data:v=[]}=so(),[y,x]=c(""),N=Mu(b).map(e=>e.id_user),w=l?Mu(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user):[],k=tt({resolver:Qu(l?Ju:Gu),defaultValues:{id_leader:s||(l?r?.id_leader:null)||null,id_users:l?w:[]}});u(()=>{if(r){const e=Mu(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user);k.reset({id_leader:r.id_leader||null,id_users:e})}else s?k.reset({id_leader:s,id_users:[]}):k.reset({id_leader:null,id_users:[]})},[o,r?.id,r?.id_user,r?.id_leader,s,b]);const S=m.isPending||h.isPending||p.isPending||f.isPending||g.isPending,C=k.watch("id_leader"),_=k.watch("id_users"),P=l?[r.id_user,...N.filter(e=>e!==r.id_user&&!_.includes(e)&&!w.includes(e))]:[C,...N.filter(e=>!_.includes(e))].filter(Boolean);return t("form",{onSubmit:k.handleSubmit(async e=>{try{if(l)if(d){await h.mutateAsync({id_user:r.id_user,id_leader:e.id_leader});const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:t})}else{await p.mutateAsync({id:r.id,id_leader:e.id_leader});const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:t})}else{const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({id_leader:e.id_leader,users:t})}n?.()}catch(t){}}),className:"space-y-4",children:[l&&t("div",{children:[e(Va,{children:i("leader")}),e($a,{value:v.find(e=>e.userId===r.id_user)?.userName||r.name||r.id_user,disabled:!0,className:"bg-muted"})]}),t("div",{children:[e(Va,{children:i("superior")}),t(fr,{value:C||"none",onValueChange:e=>k.setValue("id_leader","none"===e?null:e),children:[e(vr,{children:e(br,{placeholder:i("select_placeholder")})}),t(Nr,{children:[e("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e($a,{placeholder:i("superior_search"),value:y,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),t(Zi,{className:"h-[200px]",children:[e(kr,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const t=l?e.userId!==r.id_user:!_.includes(e.userId),a=!y||e.userName?.toLowerCase().includes(y.toLowerCase());return t&&a}).sort((e,t)=>{const a=e.userName||e.userEmail||"",r=t.userName||t.userEmail||"";return a.localeCompare(r)}).map(t=>e(kr,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${o}`),k.formState.errors.id_leader&&e("p",{className:"text-sm text-destructive mt-1",children:k.formState.errors.id_leader.message})]}),t("div",{children:[t(Va,{children:[i("subordinates")," *"]}),e(Xu,{value:_,onChange:e=>k.setValue("id_users",e),excludeUserIds:P,error:k.formState.errors.id_users?.message},`users-multiselect-${o}`)]}),t("div",{className:"flex items-center justify-between gap-2",children:[e(Da,{type:"submit",disabled:S||!l&&0===_.length,children:S&&!g.isPending?t(a,{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),i(l?"updating":"saving")]}):l?_.length>0?i("update_success",{count:_.length}):i("update"):i("create_success",{count:_.length})}),l&&!C&&0===_.length&&e(Da,{type:"button",variant:"destructive",disabled:S,onClick:async()=>{if(r&&window.confirm(i("remove_confirm")))try{await g.mutateAsync(r.id),n?.()}catch(e){}},className:"ml-auto",children:g.isPending?t(a,{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),i("removing")]}):t(a,{children:[e(z,{className:"mr-2 h-4 w-4"}),i("remove")]})})]})]})}function Zu({open:a,onOpenChange:r,leader:s,prefilledLeaderId:n,title:i}){return e(Ga,{open:a,onOpenChange:r,children:t(er,{className:"sm:max-w-[500px]",children:[e(tr,{children:e(rr,{children:i})}),e(Yu,{leader:s,prefilledLeaderId:n,onSuccess:()=>r(!1)})]})})}const em="leadership-expanded-nodes",tm=(e,t)=>{try{localStorage.setItem(`${em}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function am(){const{alias:a}=$n(),{t:r}=Rs(),{data:s,isLoading:n,error:i,refetch:o}=Du(),{data:l=[]}=so({enabled:!0}),[d,m]=c(()=>a?(e=>{try{const t=localStorage.getItem(`${em}-${e}`);if(t)return new Set(JSON.parse(t))}catch(i){}return new Set})(a):new Set),[h,p]=c(!1),[f,g]=c(),[b,v]=c(null),y=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),x=new Set(y.map(e=>e.userId)),N=y.length-(s?Mu(s).filter(e=>x.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);u(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${em}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);m(t),tm(a,t)}}},[s,a]);const w=e=>{m(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),a&&tm(a,r),r})},k=e=>{g(e),v(null),p(!0)};return n?e("div",{className:"flex items-center justify-center h-full",children:t("div",{className:"text-center",children:[e(Me,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e("p",{className:"text-muted-foreground",children:r("loading")})]})}):i?e("div",{className:"flex items-center justify-center h-full",children:t("div",{className:"text-center",children:[e("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e(Da,{onClick:()=>o(),children:"Tentar novamente"})]})}):t("div",{className:"flex flex-col h-full",children:[e("div",{className:"flex items-center justify-between p-4 border-b",children:t("div",{className:"flex gap-2 items-center",children:[t(Da,{size:"sm",onClick:()=>{g(void 0),v(null),p(!0)},children:[e($,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),t(Da,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Mu(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);m(t),a&&tm(a,t)},disabled:!s||0===s.length,children:[e(_,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),t(Da,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;m(e),a&&tm(a,e)},disabled:!s||0===s.length,children:[e(L,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e("div",{className:"flex items-center gap-2 ml-4",children:t("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e(He,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-sm font-medium",children:[N," usuário",1!==N?"s":""," não associado",1!==N?"s":""]})]})})]})}),s&&0!==s.length?e(Zi,{className:"flex-1",children:e("div",{children:t("table",{className:"w-full",children:[e("thead",{children:t("tr",{className:"border-b bg-muted/50",children:[e("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e("tbody",{children:s.map(t=>e(Hu,{leader:t,expandedIds:d,onToggleExpand:w,onEdit:k},t.id))})]})})}):e("div",{className:"flex items-center justify-center flex-1",children:t("div",{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e(Zu,{open:h,onOpenChange:()=>{p(!1),g(void 0),v(null)},leader:f,prefilledLeaderId:b,title:f?r("edit")+" "+r("name"):b?r("add")+" Liderado":r("add")+" Líder Raiz"},`leadership-dialog-${a}`)]})}function rm(e){const[t,a]=c(!1),[r,s]=c(0),{t:n}=Rs(),{uploadFunction:i,deleteFunction:o,defaultOptions:l,onSuccess:d,onError:u}=e||{};return{upload:async(e,t)=>{if(!i){const e=new Error("uploadFunction não fornecida");throw zr({title:"Erro de configuração",description:"Função de upload não configurada. Verifique a documentação.",variant:"destructive"}),e}a(!0),s(0);try{const a={...l,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){if(!a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const r=await i(e,a);return s(100),zr({title:"Sucesso",description:n("file_upload_success")}),d?.(r),r}catch(r){const e=r instanceof Error?r:new Error("Erro ao fazer upload");throw zr({title:"Erro",description:e.message,variant:"destructive"}),u?.(e),e}finally{a(!1)}},deleteMedia:async(e,t)=>{if(!o){const e=new Error("deleteFunction não fornecida");throw zr({title:"Erro de configuração",description:"Função de delete não configurada.",variant:"destructive"}),e}try{await o(e,t),zr({title:"Sucesso",description:"Arquivo removido com sucesso"})}catch(a){throw zr({title:"Erro",description:"Erro ao remover o arquivo",variant:"destructive"}),a}},uploading:t,progress:r}}function sm(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function nm(e,t){const a=sm(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function im(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function om(e,t){const a=im(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function lm(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function dm(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function cm(e,t,a){switch(t||dm(e)){case"youtube":return nm(e,a);case"vimeo":return om(e,a);default:return e}}function um({value:r,onChange:s,onSubmit:n,onCancel:i,uploadFunction:d,deleteFunction:u,uploadOptions:m}){const{t:h}=Rs(),[p,f]=c(r||{inputType:"url",controls:!0}),g=l(null),b=l(null),{upload:v,uploading:y}=rm({uploadFunction:d,deleteFunction:u,defaultOptions:{...m,allowedTypes:["video/*"],maxSize:104857600}}),{upload:x,uploading:N}=rm({uploadFunction:d,deleteFunction:u,defaultOptions:{...m,allowedTypes:["image/*"],maxSize:5242880}}),w=o(()=>dm(p.videoUrl||lm(p.embedCode)||""),[p.videoUrl,p.embedCode]),k=(e,t)=>{const a={...p,[e]:t};f(a),s(a)};return t("div",{className:"space-y-6",children:[t("div",{className:"space-y-2",children:[e(Va,{children:h("input_type")}),t(fr,{value:p.inputType||"url",onValueChange:e=>k("inputType",e),children:[e(vr,{children:e(br,{})}),t(Nr,{children:[e(kr,{value:"url",children:h("url")}),e(kr,{value:"upload",children:h("input_type_upload")}),e(kr,{value:"embed",children:h("input_type_embed")})]})]})]}),"upload"===p.inputType&&d&&t("div",{className:"space-y-2",children:[e(Va,{children:h("file")}),t("div",{className:"flex gap-2",children:[e("input",{ref:g,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await v(t),a={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||t.name.replace(/\.[^/.]+$/,"")};f(a),s(a)}catch(a){}finally{g.current&&(g.current.value="")}},className:"hidden"}),e(Da,{type:"button",variant:"outline",onClick:()=>g.current?.click(),disabled:y,children:t(a,y?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),h("uploading")]}:{children:[e(de,{className:"mr-2 h-4 w-4"}),h("select_video")]})}),p.videoFile&&e("span",{className:"text-xs text-muted-foreground truncate self-center",children:h("video.fileInfo",{name:p.videoFile,size:Math.round((p.videoSize||0)/1024/1024)})})]})]}),"embed"===p.inputType&&t("div",{className:"space-y-2",children:[e(Va,{children:h("embed")}),e(_r,{placeholder:h("embed"),value:p.embedCode||"",onChange:e=>k("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),d&&t("div",{className:"space-y-2",children:[e(Va,{children:h("thumbnail")}),t("div",{className:"flex gap-2",children:[e($a,{type:"url",placeholder:h("thumbnail"),value:p.thumbnail||"",onChange:e=>k("thumbnail",e.target.value),className:"flex-1"}),e("input",{ref:b,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await x(t),a={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};f(a),s(a)}catch(a){}finally{b.current&&(b.current.value="")}},className:"hidden"}),e(Da,{type:"button",variant:"outline",onClick:()=>b.current?.click(),disabled:N,children:t(a,N?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),h("video.uploading")]}:{children:[e(de,{className:"mr-2 h-4 w-4"}),h("upload")]})})]}),p.thumbnailFile&&e("p",{className:"text-xs text-muted-foreground",children:h("video.thumbnailFileInfo",{name:p.thumbnailFile})})]}),t("div",{className:"space-y-2",children:[e(Va,{htmlFor:"title",children:h("title")}),e($a,{id:"title",placeholder:h("title"),value:p.title||"",onChange:e=>k("title",e.target.value)})]}),t("div",{className:"flex gap-6",children:[t("div",{className:"flex items-center gap-2",children:[e("input",{id:"autoplay",type:"checkbox",checked:p.autoplay||!1,onChange:e=>k("autoplay",e.target.checked),className:"h-4 w-4"}),e(Va,{htmlFor:"autoplay",className:"cursor-pointer",children:h("video.autoplay")})]}),t("div",{className:"flex items-center gap-2",children:[e("input",{id:"controls",type:"checkbox",checked:!1!==p.controls,onChange:e=>k("controls",e.target.checked),className:"h-4 w-4"}),e(Va,{htmlFor:"controls",className:"cursor-pointer",children:h("video.controls")})]})]}),t("div",{className:"space-y-2",children:[e(Va,{children:h("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=p.videoUrl||lm(p.embedCode)||"";if(!a)return e("div",{className:"text-center py-8 text-muted-foreground",children:h("no_content_preview")});if("file"===w)return t("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e("source",{src:a}),h("unsupported")]});const r="youtube"===w?nm(a,p.autoplay):om(a,p.autoplay);return e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:p.title||h("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),t("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Da,{variant:"outline",onClick:i,children:h("cancel")}),e(Da,{onClick:()=>{p.videoUrl||p.embedCode?n(p):zr({title:h("error"),description:h("error_no_video"),variant:"destructive"})},disabled:!(p.videoUrl||p.embedCode),children:h("save")})]})]})}function mm({content:a,className:r="",style:s}){const n=a.videoUrl||lm(a.embedCode)||"";if(!n)return null;const i=dm(n),{t:o}=Rs();return e(qa,{className:`overflow-hidden my-4 ${r}`,style:s,children:t(Ka,{className:"p-0",children:["file"===i?t("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[e("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:a.title||o("video"),src:"youtube"===i?nm(n,a.autoplay):om(n,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e("div",{className:"p-4",children:e("p",{className:"text-sm font-medium",children:a.title})})]})})}function hm({value:r,onChange:s,onSubmit:n,onCancel:i,uploadFunction:o,deleteFunction:d,uploadOptions:u}){const{t:m}=Rs(),[h,p]=c(r||{alignment:"center",allowDownload:!1}),f=l(null),{upload:g,uploading:b}=rm({uploadFunction:o,deleteFunction:d,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),v=(e,t)=>{const a={...h,[e]:t};p(a),s(a)};return t("div",{className:"space-y-6",children:[t("div",{className:"space-y-2",children:[e(Va,{children:m("url")}),t("div",{className:"flex gap-2",children:[e($a,{type:"url",placeholder:m("url_placeholder"),value:h.imageUrl||"",onChange:e=>v("imageUrl",e.target.value),className:"flex-1"}),o&&t(a,{children:[e("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...h,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(a),s(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e(Da,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:b,children:t(a,b?{children:[e(T,{className:"mr-2 h-4 w-4 animate-spin"}),m("uploading")]}:{children:[e(de,{className:"mr-2 h-4 w-4"}),m("upload")]})})]})]}),h.imageFile&&e("p",{className:"text-xs text-muted-foreground",children:m("image.fileInfo",{name:h.imageFile,size:Math.round((h.imageSize||0)/1024)})})]}),h.imageUrl&&t("div",{className:"space-y-2",children:[e(Va,{children:m("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:e("div",{className:"flex "+("left"===h.alignment?"justify-start":"right"===h.alignment?"justify-end":"justify-center"),children:e("img",{src:h.imageUrl,alt:h.alt||"Preview",style:{width:h.width?`${h.width}px`:"auto",height:h.height?`${h.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),t("div",{className:"space-y-2",children:[e(Va,{htmlFor:"caption",children:m("caption")}),e(_r,{id:"caption",placeholder:m("caption"),value:h.caption||"",onChange:e=>v("caption",e.target.value),rows:2})]}),t("div",{className:"space-y-2",children:[e(Va,{htmlFor:"alt",children:m("alt")}),e($a,{id:"alt",placeholder:m("alt"),value:h.alt||"",onChange:e=>v("alt",e.target.value)})]}),t("div",{className:"space-y-2",children:[e(Va,{children:m("alignment")}),t(fr,{value:h.alignment||"center",onValueChange:e=>v("alignment",e),children:[e(vr,{children:e(br,{})}),t(Nr,{children:[e(kr,{value:"left",children:m("left")}),e(kr,{value:"center",children:m("center")}),e(kr,{value:"right",children:m("right")})]})]})]}),t("div",{className:"grid grid-cols-2 gap-4",children:[t("div",{className:"space-y-2",children:[e(Va,{htmlFor:"width",children:m("width")}),e($a,{id:"width",type:"number",placeholder:"px",value:h.width||"",onChange:e=>v("width",e.target.value?Number(e.target.value):void 0)})]}),t("div",{className:"space-y-2",children:[e(Va,{htmlFor:"height",children:m("height")}),e($a,{id:"height",type:"number",placeholder:"px",value:h.height||"",onChange:e=>v("height",e.target.value?Number(e.target.value):void 0)})]})]}),t("div",{className:"flex items-center gap-2",children:[e("input",{id:"allowDownload",type:"checkbox",checked:h.allowDownload||!1,onChange:e=>v("allowDownload",e.target.checked),className:"h-4 w-4"}),e(Va,{htmlFor:"allowDownload",className:"cursor-pointer",children:m("allow_download")})]}),t("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Da,{variant:"outline",onClick:i,children:m("cancel")}),e(Da,{onClick:()=>{h.imageUrl?n(h):zr({title:m("error"),description:m("error_no_image"),variant:"destructive"})},disabled:!h.imageUrl,children:m("save")})]})]})}function pm({content:a,className:r="",style:s}){if(!a.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e("div",{className:`flex ${n} my-4 ${r}`,style:s,children:t("div",{className:"space-y-2 max-w-full",children:[e("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&t("a",{href:a.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e(ce,{className:"h-4 w-4"}),"Baixar imagem"]})]})})}function fm(e,t){return e/t}function gm(e,t,a,r){const s=fm(e,t);return a&&!r?{width:a,height:Math.round(a/s)}:r&&!a?{width:Math.round(r*s),height:r}:{width:e,height:t}}function bm(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))}function vm(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}}function ym(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`}export{pn as AUTH_CONFIG,$o as Accordion,qo as AccordionContent,Uo as AccordionItem,Vo as AccordionTrigger,za as ActionButton,Ic as ActionMenu,Ai as ActionMenuItems,Io as Alert,Ro as AlertDescription,qn as AlertDialog,Yn as AlertDialogAction,Zn as AlertDialogCancel,Kn as AlertDialogContent,Xn as AlertDialogDescription,Gn as AlertDialogFooter,Qn as AlertDialogHeader,Hn as AlertDialogOverlay,Wn as AlertDialogPortal,Jn as AlertDialogTitle,Bn as AlertDialogTrigger,Ao as AlertTitle,au as AppHeader,gu as AppLayout,fu as AppSidebar,Bo as AspectRatio,ln as AuthErrorInterceptor,zn as AuthProvider,Mn as AuthService,Wo as Avatar,Ko as AvatarFallback,Ho as AvatarImage,Er as Badge,io as BaseForm,cd as Blockquote,Qo as Breadcrumb,el as BreadcrumbEllipsis,Jo as BreadcrumbItem,Xo as BreadcrumbLink,Go as BreadcrumbList,Yo as BreadcrumbPage,Zo as BreadcrumbSeparator,co as BulkActionBar,Da as Button,al as ButtonGroup,fn as CRUD_CONFIG,Cl as Calendar,Oo as CallbackPage,qa as Card,Ka as CardContent,Ha as CardDescription,Qa as CardFooter,Ba as CardHeader,ci as CardSkeleton,Wa as CardTitle,Rc as Cards,Eu as ChatbotPage,Cr as Checkbox,_l as Collapsible,El as CollapsibleContent,Pl as CollapsibleTrigger,Yi as ColorPicker,Fs as Combobox,Zr as Command,es as CommandDialog,rs as CommandEmpty,ss as CommandGroup,ts as CommandInput,is as CommandItem,as as CommandList,ns as CommandSeparator,os as CommandShortcut,Oi as ContextMenu,qi as ContextMenuCheckboxItem,Ui as ContextMenuContent,ji as ContextMenuGroup,Vi as ContextMenuItem,Wi as ContextMenuLabel,Fi as ContextMenuPortal,Di as ContextMenuRadioGroup,Bi as ContextMenuRadioItem,Hi as ContextMenuSeparator,Ki as ContextMenuShortcut,Mi as ContextMenuSub,$i as ContextMenuSubContent,zi as ContextMenuSubTrigger,Li as ContextMenuTrigger,Ec as CrudCards,go as CrudPageInternal,lo as CrudPagination,Ac as CrudPrimitiveFilterBar,oo as CrudPrimitivePagination,Tc as CrudPrimitiveTable,Gi as CrudTable,Tl as DataList,Il as DatePicker,ei as DeleteConfirmationDialog,Ga as Dialog,Ya as DialogClose,er as DialogContent,sr as DialogDescription,ar as DialogFooter,tr as DialogHeader,Za as DialogOverlay,Xa as DialogPortal,rr as DialogTitle,Ja as DialogTrigger,Al as Drawer,Ll as DrawerClose,Fl as DrawerContent,$l as DrawerDescription,Dl as DrawerFooter,Ml as DrawerHeader,jl as DrawerOverlay,Ol as DrawerPortal,zl as DrawerTitle,Rl as DrawerTrigger,gi as DropdownMenu,_i as DropdownMenuCheckboxItem,Si as DropdownMenuContent,vi as DropdownMenuGroup,Ci as DropdownMenuItem,Ei as DropdownMenuLabel,yi as DropdownMenuPortal,Ni as DropdownMenuRadioGroup,Pi as DropdownMenuRadioItem,Ti as DropdownMenuSeparator,Ii as DropdownMenuShortcut,xi as DropdownMenuSub,ki as DropdownMenuSubContent,wi as DropdownMenuSubTrigger,bi as DropdownMenuTrigger,Su as EmailService,fi as EmptyState,Fs as EntitySelect,yu as ErrorBoundary,fo as FilterBar,nr as Form,mr as FormControl,hr as FormDescription,or as FormField,cr as FormItem,ur as FormLabel,pr as FormMessage,ui as FormSkeleton,Bl as Grid,ed as H1,td as H2,ad as H3,rd as H4,mi as HeaderSkeleton,Os as I18nextProvider,ao as IconPicker,hm as ImageEditor,pm as ImageRenderer,dd as InlineCode,$a as Input,Wl as InputGroup,Kl as InputGroupAddon,Gl as InputGroupButton,Jl as InputGroupInput,Xl as InputGroupTextarea,Yl as Kbd,Nn as LOGO_CONFIG,Va as Label,id as Large,nd as Lead,Hu as LeaderRow,Zu as LeadershipDialog,Yu as LeadershipForm,am as LeadershipPage,ud as List,Ar as LoadingState,Bc as LocaleProvider,Gc as LocaleSelector,Lo as LoginPage,wn as MESSAGES,Tu as ManageAccessModal,Pu as MarkdownMessage,Fs as MultiSelect,ld as Muted,Zl as NativeSelect,Yc as NavigationProvider,sd as P,md as PageBreadcrumb,Fo as PageMetadataProvider,pd as Pagination,fd as PaginationContent,xd as PaginationEllipsis,gd as PaginationItem,bd as PaginationLink,yd as PaginationNext,vd as PaginationPrevious,Iu as PlaceCard,Au as PlacesList,Jr as Popover,Yr as PopoverContent,Xr as PopoverTrigger,wo as Progress,Eo as ProtectedRoute,yn as QUALIEX_CONFIG,vn as QUERY_KEYS,En as QualiexEnrichmentService,cn as QualiexErrorInterceptor,no as QualiexUserField,Nd as RadioGroup,wd as RadioGroupItem,pu as ResizableRail,gn as SEARCH_CONFIG,Zi as ScrollArea,eo as ScrollBar,Sd as Searchbar,fr as Select,Nr as SelectContent,gr as SelectGroup,kr as SelectItem,wr as SelectLabel,xr as SelectScrollDownButton,yr as SelectScrollUpButton,Fs as SelectSearch,Sr as SelectSeparator,vr as SelectTrigger,br as SelectValue,Cd as Separator,_d as Sheet,Ed as SheetClose,Rd as SheetContent,Fd as SheetDescription,Ld as SheetFooter,Od as SheetHeader,Id as SheetOverlay,Td as SheetPortal,jd as SheetTitle,Pd as SheetTrigger,Wd as Sidebar,Zd as SidebarContent,Xd as SidebarFooter,ec as SidebarGroup,ac as SidebarGroupAction,rc as SidebarGroupContent,tc as SidebarGroupLabel,mu as SidebarHeader,Gd as SidebarInput,Qd as SidebarInset,sc as SidebarMenu,lc as SidebarMenuAction,dc as SidebarMenuBadge,oc as SidebarMenuButton,nc as SidebarMenuItem,cc as SidebarMenuSkeleton,uc as SidebarMenuSub,hc as SidebarMenuSubButton,mc as SidebarMenuSubItem,Bd as SidebarProvider,Kd as SidebarRail,Yd as SidebarSeparator,hi as SidebarSkeleton,Hd as SidebarTrigger,ls as Skeleton,pc as Slider,od as Small,fc as SonnerToaster,Ir as Spinner,po as Stack,Ul as StatusSelect,ro as Switch,wc as TabPageContent,Nc as TabPageHeader,xc as TabPageLayout,ti as Table,ri as TableBody,li as TableCaption,oi as TableCell,si as TableFooter,ii as TableHead,ai as TableHeader,ni as TableRow,Ri as TableRowActions,di as TableSkeleton,gc as Tabs,yc as TabsContent,bc as TabsList,vc as TabsTrigger,_r as Textarea,Br as Toast,Wr as ToastAction,Hr as ToastClose,Qr as ToastDescription,Ur as ToastProvider,Kr as ToastTitle,Vr as ToastViewport,Gr as Toaster,Sc as Toggle,_c as ToggleGroup,Pc as ToggleGroupItem,Hs as TokenManager,Ds as TokenService,Dd as Tooltip,$d as TooltipContent,Md as TooltipProvider,zd as TooltipTrigger,xu as TranslationLoader,um as VideoEditor,mm as VideoRenderer,So as WizardBreadcrumb,_o as WizardButtons,Po as WizardForm,Co as WizardProgressBar,ko as WizardStepper,du as assets,Pr as badgeVariants,Fu as buildHierarchy,tl as buttonGroupVariants,Ma as buttonVariants,fm as calculateAspectRatio,Aa as cn,bo as createCrudPage,Lc as createCrudRoutingConfig,Oc as createRoutingHandlers,An as createService,vo as createSimpleSaveHandler,Vn as createSimpleService,ja as debounce,Sn as deriveEmailField,kn as deriveNameField,Cn as deriveUsernameField,dm as detectVideoProvider,Cu as emailService,Gs as errorService,vm as extractImageFileName,im as extractVimeoId,sm as extractYouTubeId,ju as filterAndPromoteOrphans,Mu as flattenTree,La as formatCurrency,wu as formatDate,Oa as formatDatetime,ym as formatFileSize,yo as generateCrudConfig,xn as getQualiexConfig,an as getSupabaseClient,Ia as handleExternalLink,Ta as i18n,Hl as inputGroupAddonVariants,Ql as inputGroupButtonVariants,bn as isDevEnvironment,bm as isImageUrl,cu as logoSrc,cm as normalizeVideoUrl,om as normalizeVimeoUrl,nm as normalizeYouTubeUrl,lm as parseIframeSrc,Lu as placeService,hn as qualiexApi,gm as resizeKeepingAspect,_n as resolveFieldMappings,kd as searchbarVariants,zo as setupQualiexCore,Fa as slugify,uu as smallLogoSrc,zr as toast,kc as toggleVariants,zc as translationService,Ra as trimTextFields,su as useActiveModules,jc as useAllQualiexUsers,$n as useAuth,Ji as useBaseForm,zu as useCreateLeaderMutation,Uu as useCreateMultipleLeadersMutation,$u as useCreateSingleLeaderMutation,Un as useCrud,tu as useDebounce,lr as useFormField,ku as useI18nFormatters,Du as useLeadershipApi,Wc as useLocale,rm as useMediaUpload,Zc as useNavigation,_u as useOpenAIChat,Do as usePageMetadata,Mo as usePageMetadataContext,eu as usePageTitle,ru as usePermissionQuery,so as useQualiexUsers,qu as useRemoveLeaderMutation,hd as useRouteBreadcrumbs,qd as useSidebar,hu as useSidebarResize,Bu as useSyncSubordinatesMutation,$r as useToast,Rs as useTranslation,Vu as useUpdateLeaderMutation};
|
|
10
|
+
*/var vs=(gs||(gs=1,"production"===process.env.NODE_ENV?hs.exports=function(){if(ms)return ps;ms=1;var e=s,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=e.useState,r=e.useEffect,n=e.useLayoutEffect,i=e.useDebugValue;function o(e){var a=e.getSnapshot;e=e.value;try{var r=a();return!t(e,r)}catch(s){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var s=t(),l=a({inst:{value:s,getSnapshot:t}}),d=l[0].inst,c=l[1];return n(function(){d.value=s,d.getSnapshot=t,o(d)&&c({inst:d})},[e,s,t]),r(function(){return o(d)&&c({inst:d}),e(function(){o(d)&&c({inst:d})})},[e]),i(s),s};return ps.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,ps}():hs.exports=(fs||(fs=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!a(e,r)}catch(s){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=s,a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useState,n=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue,l=!1,d=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(s,c){l||void 0===t.startTransition||(l=!0);var u=c();if(!d){var m=c();a(u,m)||(d=!0)}var h=(m=r({inst:{value:u,getSnapshot:c}}))[0].inst,p=m[1];return i(function(){h.value=u,h.getSnapshot=c,e(h)&&p({inst:h})},[s,u,c]),n(function(){return e(h)&&p({inst:h}),s(function(){e(h)&&p({inst:h})})},[s]),o(u),u};bs.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),bs)),hs.exports);const ys={t:(e,t)=>{return rs(t)?t:"object"==typeof(a=t)&&null!==a&&rs(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e;var a},ready:!1},xs=()=>()=>{},Ns=(e,t={})=>{const{i18n:a}=t,{i18n:r,defaultNS:s}=i(cs)||{},n=a||r||ls;n&&!n.reportNamespaces&&(n.reportNamespaces=new us),n||Zr(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const m=o(()=>({...os,...n?.options?.react,...t}),[n,t]),{useSuspense:h,keyPrefix:p}=m,f=e||s||n?.options?.defaultNS,g=rs(f)?[f]:f||["translation"],b=o(()=>g,g);n?.reportNamespaces?.addUsedNamespaces?.(b);const v=l(0),y=d(e=>{if(!n)return xs;const{bindI18n:t,bindI18nStore:a}=m,r=()=>{v.current+=1,e()};return t&&n.on(t,r),a&&n.store.on(a,r),()=>{t&&t.split(" ").forEach(e=>n.off(e,r)),a&&a.split(" ").forEach(e=>n.store.off(e,r))}},[n,m]),x=l(),N=d(()=>{if(!n)return ys;const e=!(!n.isInitialized&&!n.initializedStoreOnce)&&b.every(e=>((e,t,a={})=>t.languages&&t.languages.length?t.hasLoadedNamespace(e,{lng:a.lng,precheck:(t,r)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):(Zr(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0))(e,n,m)),a=t.lng||n.language,r=v.current,s=x.current;if(s&&s.ready===e&&s.lng===a&&s.keyPrefix===p&&s.revision===r)return s;const i={t:n.getFixedT(a,"fallback"===m.nsMode?b:b[0],p),ready:e,lng:a,keyPrefix:p,revision:r};return x.current=i,i},[n,b,p,m,t.lng]),[w,k]=c(0),{t:S,ready:C}=vs.useSyncExternalStore(y,N,N);u(()=>{if(n&&!C&&!h){const e=()=>k(e=>e+1);t.lng?as(n,t.lng,b,e):ts(n,b,e)}},[n,t.lng,b,C,h,w]);const _=n||{},E=l(null),P=l(),I=e=>{const t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;const a=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(a,"__original"))try{Object.defineProperty(a,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch(r){}return a},T=o(()=>{const e=_,t=e?.language;let a=e;e&&(E.current&&E.current.__original===e?P.current!==t?(a=I(e),E.current=a,P.current=t):a=E.current:(a=I(e),E.current=a,P.current=t));const r=[S,a,C];return r.t=S,r.i18n=a,r.ready=C,r},[S,_,C,_.resolvedLanguage,_.language,_.languages]);if(n&&h&&!C)throw new Promise(e=>{const a=()=>e();t.lng?as(n,t.lng,b,a):ts(n,b,a)});return T};function ws({i18n:e,defaultNS:t,children:a}){const r=o(()=>({i18n:e,defaultNS:t}),[e,t]);return m(cs.Provider,{value:r},a)}const ks=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Ss({multiple:a,options:r,value:s,onChange:n,getOptionValue:i,getOptionLabel:l,placeholder:d,label:u,icon:m,emptyMessage:h,searchPlaceholder:p,disabled:f,required:g,className:b,sortOptions:v,maxDisplayedBadges:y,popoverContainer:x,onOpen:N,onClose:w}){const{t:k}=Ns(),[S,E]=c(!1),[I,T]=c(""),A=o(()=>s?Array.isArray(s)?s:[s]:[],[s]),R=o(()=>{if(!x)return;let e=x,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),r=a.overflowY||a.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[x]),O=o(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),L=o(()=>{if(!I)return O;const e=ks(I);return O.filter(t=>ks(t.label).includes(e))},[O,I]),F=o(()=>O.filter(e=>A.includes(e.value)),[O,A]),j=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?A.filter(t=>t!==e):"")},D=y?F.slice(0,y):F,M=y&&F.length>y?F.length-y:0;return t("div",{className:Fa("space-y-2",b),children:[u&&t(Ha,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t(zr,{open:S,onOpenChange:e=>{E(e),e?N?.():(T(""),w?.())},modal:!1,children:[e($r,{asChild:!0,children:t(Va,{variant:"outline",role:"combobox","aria-expanded":S,disabled:f,className:Fa("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?t("span",{className:"flex items-center gap-2",children:[m&&e(m,{className:"h-4 w-4"}),d]}):a?t("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[D.map(a=>t(Lr,{variant:"secondary",className:"gap-1 pr-1",children:[a.label,e("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&j(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>j(a.value,e),children:e(C,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),M>0&&t(Lr,{variant:"outline",className:"gap-1",children:["+",M]})]}):t("span",{className:"flex items-center gap-2",children:[m&&e(m,{className:"h-4 w-4"}),F[0]?.label]}),e(_,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e(Ur,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:R,collisionBoundary:R,children:t(Vr,{children:[e(Br,{placeholder:p,value:I,onChange:e=>T(e.target.value)}),e(Wr,{children:0===r.length?e(Hr,{children:h}):0===L.length?e(Hr,{children:k("no_results")}):e(Kr,{children:L.map(r=>t(Gr,{value:r.value,onSelect:()=>(e=>{if(n)if(a){const t=A.includes(e)?A.filter(t=>t!==e):[...A,e];n(t)}else n(e),E(!1)})(r.value),className:"cursor-pointer",children:[e(P,{className:Fa("mr-2 h-4 w-4",A.includes(r.value)?"opacity-100":"opacity-0")}),r.label]},r.value))})})]})})]})]})}function Cs({multiple:a=!1,options:r,items:s,value:n,onChange:i,onValueChange:o,getOptionValue:l=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:h,searchPlaceholder:p,disabled:f=!1,required:g=!1,isLoading:b=!1,error:v,className:y,sortOptions:x=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:k,onClose:S}){const{t:C}=Ns(),_=s||r||[],E=o||i,P=c||C("select_placeholder"),I=h||C("no_results"),T=p||C("search_placeholder");if(b)return t("div",{className:Fa("space-y-2",y),children:[u&&t(Ha,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Xr,{className:"h-10 w-full"})]});const A="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return A?t("div",{className:Fa("space-y-2",y),children:[u&&t(Ha,{children:[u,g&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e(F,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:A})]})]}):e(Ss,{multiple:a,options:_,value:n||(a?[]:""),onChange:E,getOptionValue:l,getOptionLabel:d,placeholder:P,label:u,icon:m,emptyMessage:I,searchPlaceholder:T,disabled:f,required:g,className:y,sortOptions:x,maxDisplayedBadges:N,popoverContainer:w,onOpen:k,onClose:S})}var _s=Object.defineProperty;class Es{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const s=e.split(".");if(3!==s.length)return null;const n=s[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let s=0;s<t.length;s++)a[s]=t.charCodeAt(s);const r=new TextDecoder("utf-8").decode(a);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(s){return null}}static validateTokens(e,t){const a=[],r=[];try{t.split(".")[1],e.split(".")[1];const s=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!s){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";a.push(e),i=!1}if(s.exp&&s.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:a,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:a,errors:r}}catch(s){const e=`Erro na validação de tokens: ${s}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,a)=>{t in e?_s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(Es,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Ps="qualiex_access_token",Is="qualiex_id_token",Ts="supabase_token",As="oauth_state",Rs="oauth_nonce",Os="selected_alias",Ls="manual_logout",Fs={setAccessToken:e=>localStorage.setItem(Ps,e),getAccessToken:()=>localStorage.getItem(Ps),setIdToken:e=>localStorage.setItem(Is,e),getIdToken:()=>localStorage.getItem(Is),getSupabaseToken:()=>localStorage.getItem(Ts),setOAuthState:e=>sessionStorage.setItem(As,e),getOAuthState:()=>sessionStorage.getItem(As),clearOAuthState:()=>sessionStorage.removeItem(As),setOAuthNonce:e=>sessionStorage.setItem(Rs,e),getOAuthNonce:()=>sessionStorage.getItem(Rs),clearOAuthNonce:()=>sessionStorage.removeItem(Rs),setSelectedAlias:e=>localStorage.setItem(Os,e),getSelectedAlias:()=>localStorage.getItem(Os),clearSelectedAlias:()=>localStorage.removeItem(Os),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Fs.getAccessToken()||!Fs.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Ts,e),Fs._clearValidationCache()},areAllTokensValid:()=>{const e=Fs.getAccessToken(),t=Fs.getIdToken();if(!e||!t)return!1;try{const a=Es.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Fs.getAccessToken(),a=Fs.getIdToken(),r=Fs.getSupabaseToken();return t&&Fs.isTokenExpired(t)&&(localStorage.removeItem(Ps),e=!0),a&&Fs.isTokenExpired(a)&&(localStorage.removeItem(Is),e=!0),r&&Fs.isTokenExpired(r)&&(localStorage.removeItem(Ts),e=!0),e},clearAll:()=>{localStorage.removeItem(Ps),localStorage.removeItem(Is),localStorage.removeItem(Ts),localStorage.removeItem(Os),localStorage.removeItem(Ls),sessionStorage.removeItem(As),sessionStorage.removeItem(Rs)},setManualLogout:()=>localStorage.setItem(Ls,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ls),clearManualLogout:()=>localStorage.removeItem(Ls),isTokenExpired:e=>{try{return Es.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Fs._validationCache.isValid=!1,Fs._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Fs.getSupabaseToken();if(!e)return!1;if(Fs.isTokenExpired(e))return Fs._clearValidationCache(),Fs._handleExpiredToken(),!1;const t=Date.now();return t-Fs._validationCache.timestamp<Fs._validationCache.cacheValidityMs?Fs._validationCache.isValid:(Fs._validationCache.isValid=!0,Fs._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Fs.isSupabaseTokenValid()?Fs.getSupabaseToken():null,_handleExpiredToken:()=>{Fs.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Fs.isSupabaseTokenValid())return null;const e=Fs.getSupabaseToken();if(!e)return null;try{const t=Es.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,r=t.place_id||null,s=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:r,placeName:s,payload:t}}catch(t){return Fs._handleExpiredToken(),null}},getCompanyId:e=>{const t=Fs.getAccessToken();if(t)try{const a=Es.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=a[t];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}const a=Fs.extractTokenData();if(a?.companyId)return a.companyId;const r=Fs.getIdToken();if(r)try{const t=Es.parseJwtPayload(r);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const r=t[a];if(r&&"string"==typeof r){const t=r.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(s){}return null},getCurrentCompanyId:()=>{const e=Fs.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Fs.getIdToken();if(!e)return[];try{const t=Es.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};let js=0;const Ds=new Map,Ms=e=>{if(Ds.has(e))return;const t=setTimeout(()=>{Ds.delete(e),Vs({type:"REMOVE_TOAST",toastId:e})},1e6);Ds.set(e,t)},zs=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:a}=t;return a?Ms(a):e.toasts.forEach(e=>{Ms(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},$s=[];let Us={toasts:[]};function Vs(e){Us=zs(Us,e),$s.forEach(e=>{e(Us)})}function qs({...e}){const t=(js=(js+1)%Number.MAX_SAFE_INTEGER,js.toString()),a=()=>Vs({type:"DISMISS_TOAST",toastId:t});return Vs({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||a()}}}),{id:t,dismiss:a,update:e=>Vs({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Bs(){const[e,t]=r.useState(Us);return r.useEffect(()=>($s.push(t),()=>{const e=$s.indexOf(t);e>-1&&$s.splice(e,1)}),[e]),{...e,toast:qs,dismiss:e=>Vs({type:"DISMISS_TOAST",toastId:e})}}var Ws=Object.defineProperty,Hs=(e,t,a)=>((e,t,a)=>t in e?Ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Ks=new class{constructor(){Hs(this,"errors",[]),Hs(this,"toastCount",0),Hs(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){qs({title:this.getErrorTitle(a),description:a,variant:"destructive"})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){qs({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Qs=Object.defineProperty,Gs=(e,t,a)=>((e,t,a)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Js=import.meta.env.VITE_SUPABASE_URL,Xs=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,Ys=class e{constructor(){Gs(this,"client"),Gs(this,"currentToken",null),Gs(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Xs};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return ut(Js,Xs,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Fs.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),a=Math.floor(Date.now()/1e3);return t.exp>a}catch(t){return Ks.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};Gs(Ys,"instance");let Zs=Ys;function en(){return Zs.getInstance().getClient()}class tn{static async generateToken(e,t,a,r=!1){try{if(!r){const e=Fs.getSupabaseToken();if(e&&Fs.isSupabaseTokenValid())return e}const s=en(),{data:n,error:i}=await s.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(Fs.setSupabaseToken(n.access_token),n.access_token):null}catch(s){return s instanceof Error&&(s.message.includes("401")||s.message.includes("Unauthorized"))&&a?.(),null}}}var an=Object.defineProperty,rn=(e,t,a)=>((e,t,a)=>t in e?an(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class sn{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Fs.getAccessToken(),t=Fs.getSelectedAlias();if(!e||!t)return null;const a=await tn.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(Fs.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}rn(sn,"isRegenerating",!1),rn(sn,"onLogoutCallback",null);class nn{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Fs.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var on=Object.defineProperty;class ln{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await sn.attemptRegeneration()?(this.isRetrying=!1,!0):(nn.handleError(e),this.isRetrying=!1,!1)}catch(r){return nn.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Fs.getAccessToken();return e?Fs.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(ln,"isRetrying",!1);var dn=Object.defineProperty,cn=(e,t,a)=>((e,t,a)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const un=new class{constructor(){cn(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=ln.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Fs.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){const t=e.status||e.userStatus||"",a=void 0!==e.isActive?e.isActive:"active"===t.toLowerCase()||"ACTIVE"===t.toUpperCase();return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0,isActive:a,status:t||void 0}}async fetchUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Ks.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=a}if(!Array.isArray(r))return Ks.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(a){if(await ln.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Ks.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Ks.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Ks.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const s=a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex";return Ks.handleError(s,!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(r){return Ks.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),r=new Map;return a.forEach(e=>{r.set(e.userId,e)}),r}async fetchAllUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"all"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Ks.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Ks.handleError("[QualiexApi] Resposta não é um array",!1),[])}catch(a){if(await ln.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"all"},e);let r=a;if(a.data)r=a.data;else{if(!Array.isArray(a))return Ks.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Ks.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Ks.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Ks.handleError(a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async getUsers(e){const t=Fs.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async getAllUsers(e){const t=Fs.extractTokenData();return t&&t.companyId?this.fetchAllUsers(e,t.companyId):[]}},mn={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"}},hn={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},pn={debounceDelay:500},fn=()=>{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},gn={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},bn={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},vn=()=>bn,yn={isQualiex:"true"===import.meta.env.VITE_IS_QUALIEX},xn={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}`}};function Nn(e,t){const a=vn(),r=t||a.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function wn(e,t){const a=vn(),r=t||a.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function kn(e,t){const a=vn(),r=t||a.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Sn(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Nn(e.idField),emailField:e.emailField||wn(e.idField),usernameField:e.usernameField||kn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Nn(e),emailField:wn(e),usernameField:kn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Cn=new Map;class _n{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,r=Cn.get(a);if(r&&Date.now()-r.timestamp<3e5)return r.users;const s=await un.fetchUsers(e,t);return Cn.set(a,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const a=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const r={...e};for(const s of t){const t=e[s.idField];if(!t)continue;const n=a.get(t);if(n){if(s.nameField){r[s.nameField]||(r[s.nameField]=n.userName||n.displayName||null)}if(s.emailField){r[s.emailField]||(r[s.emailField]=n.userEmail||null)}if(s.usernameField){r[s.usernameField]||(r[s.usernameField]=n.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!Fs.areAllTokensValid())return e;const a=Fs.extractTokenData();if(!a)return e;const{alias:r,companyId:s}=a;if(!r||!s)return e;const n=Sn(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(r,s),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(a){return Ks.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const En=["responsible_name"],Pn=e=>En.includes(e);function In(e,t,a){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:s,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=r,c=()=>{if(!Fs.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return en().schema(o).from(s)},u=(e,t,a,r)=>{let s=c().select(i||"*",{count:"exact"});s=s.eq("is_removed",!1),Object.entries(r).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?s=s.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?s=s.not(e,"is",null):"is_null"===t.operator&&(s=s.is(e,null)):null!==t&&(s=s.eq(e,t)))}),s=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(s,e);const o=t.includes(".");return o||Pn(t)||(s=s.order(t,{ascending:"asc"===a})),{query:s,isForeignKey:o}},m=async(e,t,a,s,n)=>{const i=Sn(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),o=t.includes(".");if(Pn(t)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const d=await _n.enrichWithUserData(i.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let c;c=o?d.sort((e,r)=>{const s=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],r)||"",i=String(s).localeCompare(String(n),"pt-BR");return"asc"===a?i:-i}):((e,t,a)=>[...e].sort((e,r)=>{const s=e[t]||"",n=r[t]||"",i=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?i:-i}))(d,t,a);const u=((e,t=1,a=25)=>{const r=(t-1)*a,s=r+a,n=e.slice(r,s);return{data:n,pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:n.length,totalCount:e.length,itemsPerPage:a,hasNextPage:s<e.length,hasPreviousPage:t>1}}})(c,s,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await _n.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...i}=e;return{search:t,sortField:a,sortDirection:r,page:s,limit:n,additionalFilters:i}})(e),{query:h}=u(t,a,n,c),p=((e,t,a)=>{const r=(t-1)*a,s=r+a-1;return e.range(r,s)})(h,i,o),{data:f,error:g,count:b}=await p;if(g)throw new Error(`Error fetching ${s}: ${g.message}`);let v=((e,t,a,r)=>{const s=Math.ceil((t||0)/r);return{data:e,currentPage:a,totalPages:s,totalItems:t||0,itemsPerPage:r,hasNextPage:a<s,hasPreviousPage:a>1}})(f||[],b,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const t=Sn(r.userIdFields,r.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(v.data)){const e=await m(v.data,a,n,i,o);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:t,error:a}=await c().select(i||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${s}: ${a.message}`);return t},async create(e){const t=ja(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:r,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from create ${s} operation`);return r},async update(e,t){const a={...ja(t),updated_at:(new Date).toISOString()},{data:r,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${s}: ${n.message}`);if(!r)throw new Error(`No data returned from update ${s} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${s}: ${a.message}`)}}}const Tn=()=>{Fs.clearManualLogout()},An=e=>e?.placeId||null,Rn=e=>e?.placeName||null,On=e=>({placeId:An(e),placeName:Rn(e)}),Ln=class{static async initialize(){try{if(!Fs.hasAllTokens()||!Fs.areAllTokensValid())return Fs.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=Fs.getAccessToken(),a=Fs.getIdToken();Tn();const r=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),n=this.extractAliasFromAccessToken(t),i=Fs.extractTokenData(),o=i?.alias;let l=null;if(o&&s.some(e=>e.alias===o))l=o;else{const e=Fs.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);l=t?e:n||s[0]?.alias||null}!Fs.isSupabaseTokenValid()&&l&&await sn.attemptRegeneration();let d=null;if(l){const e=Fs.getCompanyId(l),t=s.find(e=>e.alias===l);t&&(d={id:e||t.id,name:t.name,alias:t.alias})}let c=null,u=null;if(r?.id&&l){const t=Fs.getCompanyId(l);if(t)try{const e=(await un.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=On(e);c=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:s,selectedUnit:d,userId:r?.id||null,userAlias:r?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=en(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL("/callback",window.location.origin);return r.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=r.toString(),!0}catch(e){return!1}}static loginProd(){const e=Fs.generateOAuthState();Fs.setOAuthState(e);const t=Fs.generateOAuthNonce();Fs.setOAuthNonce(t);const a=`${window.location.origin}/callback`,r=new URL(mn.oauth.authUrl);r.searchParams.set("client_id",mn.oauth.clientId),r.searchParams.set("response_type",mn.oauth.responseType),r.searchParams.set("scope",mn.oauth.scope),r.searchParams.set("redirect_uri",a),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),fn(),window.location.href=r.toString()}static async processCallback(){try{if(Fs.hasAllTokens()){if(!Fs.getValidSupabaseToken()){Fs.getAccessToken();await sn.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),r=a("access_token"),s=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!r||!s)throw new Error("Tokens não encontrados na URL de callback");Fs.setAccessToken(r),Fs.setIdToken(s),Tn();const i=this.extractAliasFromAccessToken(r);if(i)Fs.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(s);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Fs.setSelectedAlias(e[0].alias)}if(!await sn.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Fs.clearOAuthState(),Fs.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Fs.setManualLogout(),Fs.clearAll(),window.location.href="/login"}static decodeToken(e){return Es.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)a.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,s]=t[e].split("|");r&&s&&a.push({id:"",alias:r.trim(),name:s.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};sn.setLogoutCallback(()=>{Ln.logout()});let Fn=Ln;const jn=n(void 0),Dn=({children:t})=>{const[a,r]=c({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=mt()}catch{}const[n,i]=c(!1),[l,m]=c(0),h=d(e=>{r(t=>({...t,...e}))},[]),p=d(e=>{r(t=>({...t,isLoading:e}))},[]),f=d(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),g=d(async e=>{try{p(!0);const r=Fs.getAccessToken();if(!r)return;const n=await tn.generateToken(r,e.alias,void 0,!0);if(!n)return;Fs.setSupabaseToken(n),Fs.setSelectedAlias(e.alias);const i=Fs.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Fs.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let c=null,u=null;if(a.user?.id&&o&&l)try{const e=(await un.fetchActiveUsersMap(o,l)).get(a.user.id);if(e){const t=On(e);c=t.placeId,u=t.placeName}}catch(t){}h({alias:o,selectedUnit:d,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{p(!1)}},[h,s,p,a.user]),b=d(async()=>await Fn.processCallback(),[]),v=d(async()=>{Fn.logout(),f(),s&&await s.clear()},[f,s]),y=d(e=>{i(e)},[]),x=d(()=>{m(e=>e+1)},[]),N=d(()=>{m(e=>e+1)},[]);u(()=>{if(!a.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Fs.areAllTokensValid()||e&&v())},6e5);return()=>{e=!1,clearInterval(t)}},[a.isAuthenticated,v]),u(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Fn.initialize();if(!e)return;t&&t.isAuthenticated?h({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&p(!1)}catch(t){e&&(nn.handleError(t),p(!1))}})(),()=>{e=!1}},[h,p,v]);const w=o(()=>({...a,logout:v,processCallback:b,switchUnit:g,availableUnits:a.companies,isSearchVisible:n,setSearchVisible:y,clearSearch:x,refreshData:N}),[a.user,a.companies,a.alias,a.isAuthenticated,a.isLoading,a.selectedUnit,a.userId,a.userAlias,a.placeId,a.placeName,a.activePlaceId,a.activePlaceName,v,b,g,n,y,x,N]);return e(jn.Provider,{value:w,children:t})},Mn=()=>{const e=i(jn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function zn({queryKey:e,service:t,entityName:a,searchFields:r,additionalFilters:s={},onSuccess:n}){const[i,l]=gt(),u=mt(),{alias:m,userId:h,isAuthenticated:p}=Mn(),f=d(t=>{const a=`${e}_${t}`,r=i.get(a);return r||(i.get(t)||"")},[i,e]),g=f("search"),b=f("sortField")||hn.sorting.defaultField,v=f("sortDirection")||hn.sorting.defaultDirection,y=parseInt(f("page")||"1"),x=parseInt(f("limit")||String(hn.pagination.defaultPageSize)),N=g,k=o(()=>({search:N,sortField:b,sortDirection:v,page:y,limit:x,...s}),[N,b,v,y,x,s]),S=d(()=>t.getAll(k),[t,k]),C=ht({queryKey:[e,m,h,k],queryFn:S,enabled:!!m&&p});if(!C)throw new Error(`useCrud: Query initialization failed for "${a}". Ensure QueryClientProvider is configured in your app root.`);const _=pt({mutationFn:t.create,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(xn.success.created(a)),n?.()},onError:e=>{w.error(`${xn.error.create(a)}: ${e.message}`)}}),E=pt({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(xn.success.updated(a)),n?.()},onError:e=>{w.error(`${xn.error.update(a)}: ${e.message}`)}}),P=pt({mutationFn:t.delete,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),w.success(xn.success.deleted(a))},onError:e=>{w.error(`${xn.error.delete(a)}: ${e.message}`)}}),I=d(t=>{const a={...Object.fromEntries(i)};Object.entries(t).forEach(([t,r])=>{const s=`${e}_${t}`;""===r||0===r?delete a[s]:a[s]=String(r)}),delete a.sortField,delete a.sortDirection,l(a)},[i,l,e]),T=d(e=>{I({search:e,page:1})},[I]),A=d(e=>{I({sortField:e,sortDirection:b===e&&"asc"===v?"desc":"asc",page:1})},[b,v,I]),R=d(e=>{I({page:e})},[I]),O=d(e=>{I({limit:e,page:1})},[I]),L=d(()=>{const t=Object.fromEntries(i),a=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));l(r)},[l,i,e]),[F,j]=c([]),D=d(e=>{j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),M=d(()=>{const e=C?.data?.data.map(e=>e.id)||[];j(t=>t.length===e.length?[]:e)},[C?.data?.data]),z=d(()=>{j([])},[]),$=o(()=>{const e=C?.data?.data.map(e=>e.id)||[];return e.length>0&&F.length===e.length},[F,C?.data?.data]),U=pt({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,r)=>{u.invalidateQueries({queryKey:[e]}),w.success(`${r.length} ${a}(s) deletado(s) com sucesso`),z()},onError:e=>{w.error(`Erro ao deletar itens: ${e.message}`)}}),V=d((e,t)=>{const a=t?t(e):e;e.id?E.mutate({id:e.id,data:a}):_.mutate({...a,alias:m})},[m,_,E]);return{entities:C?.data?.data||[],pagination:{data:C?.data?.data||[],currentPage:C?.data?.currentPage||1,totalPages:C?.data?.totalPages||1,totalItems:C?.data?.totalItems||0,itemsPerPage:C?.data?.itemsPerPage||hn.pagination.defaultPageSize,hasNextPage:C?.data?.hasNextPage||!1,hasPreviousPage:C?.data?.hasPreviousPage||!1},isLoading:C?.isLoading??!0,isCreating:_?.isPending??!1,isUpdating:E?.isPending??!1,isDeleting:P?.isPending??!1,error:C?.error||null,searchTerm:g,sortField:b,sortDirection:v,currentPage:y,itemsPerPage:x,queryKey:e,createEntity:_.mutate,updateEntity:(e,t)=>E.mutate({id:e,data:t}),deleteEntity:P.mutate,save:V,handleSearch:T,handleSort:A,handlePageChange:R,handleItemsPerPageChange:O,clearFilters:L,refetch:C.refetch,selectedIds:F,selectItem:D,selectAll:M,clearSelection:z,isAllSelected:$,bulkDelete:e=>U.mutateAsync(e),isBulkDeleting:U.isPending}}function $n(e){const t=In({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,r)=>zn({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:r})}}const Un=xt.Root,Vn=xt.Trigger,qn=xt.Portal,Bn=r.forwardRef(({className:t,...a},r)=>e(xt.Overlay,{className:Fa("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",t),...a,ref:r}));Bn.displayName=xt.Overlay.displayName;const Wn=r.forwardRef(({className:a,...r},s)=>t(qn,{children:[e(Bn,{}),e(xt.Content,{ref:s,className:Fa("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",a),...r})]}));Wn.displayName=xt.Content.displayName;const Hn=({className:t,...a})=>e("div",{className:Fa("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",t),...a});Hn.displayName="AlertDialogHeader";const Kn=({className:t,...a})=>e("div",{className:Fa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Kn.displayName="AlertDialogFooter";const Qn=r.forwardRef(({className:t,...a},r)=>e(xt.Title,{ref:r,className:Fa("text-lg font-semibold",t),...a}));Qn.displayName=xt.Title.displayName;const Gn=r.forwardRef(({className:t,...a},r)=>e(xt.Description,{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));Gn.displayName=xt.Description.displayName;const Jn=r.forwardRef(({className:t,...a},r)=>e(xt.Action,{ref:r,className:Fa(Ua(),t),...a}));Jn.displayName=xt.Action.displayName;const Xn=r.forwardRef(({className:t,...a},r)=>e(xt.Cancel,{ref:r,className:Fa(Ua({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));Xn.displayName=xt.Cancel.displayName;const Yn=({open:a,onOpenChange:r,item:s,onConfirm:n,entityName:i="item",isDeleting:o=!1})=>{const{t:l}=Ns(),d=()=>{r(!1)};return s?e(Un,{open:a,onOpenChange:d,children:t(Wn,{className:"sm:max-w-[420px] bg-white",children:[t("button",{onClick:d,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",children:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Fechar"})]}),t("div",{className:"flex flex-col items-center text-center space-y-3 py-2",children:[e("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e(j,{className:"w-8 h-8 text-destructive"})}),e(Qn,{className:"text-xl font-semibold",children:"Tem certeza?"}),e(Gn,{asChild:!0,children:t("div",{className:"text-sm text-muted-foreground",children:[e("p",{children:"Você está prestes a excluir este registro."}),e("p",{children:"Esta ação não pode ser desfeita."})]})})]}),t("div",{className:"flex flex-row gap-2 justify-center mt-6",children:[e(Jn,{onClick:()=>{s&&(n(s),r(!1))},disabled:o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:l(o?"deleting":"confirm_delete")}),e(Xn,{onClick:d,className:"mt-0 border-none bg-transparent hover:bg-muted text-foreground shadow-none",children:"Cancelar"})]})]})}):null},Zn=r.forwardRef(({className:t,...a},r)=>e("table",{ref:r,className:Fa("w-full caption-bottom text-sm",t),...a}));Zn.displayName="Table";const ei=r.forwardRef(({className:t,...a},r)=>e("thead",{ref:r,className:Fa("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));ei.displayName="TableHeader";const ti=r.forwardRef(({className:t,...a},r)=>e("tbody",{ref:r,className:Fa("[&_tr:last-child]:border-0",t),...a}));ti.displayName="TableBody";const ai=r.forwardRef(({className:t,...a},r)=>e("tfoot",{ref:r,className:Fa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));ai.displayName="TableFooter";const ri=r.forwardRef(({className:t,...a},r)=>e("tr",{ref:r,className:Fa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",t),...a}));ri.displayName="TableRow";const si=r.forwardRef(({className:t,...a},r)=>e("th",{ref:r,className:Fa("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));si.displayName="TableHead";const ni=r.forwardRef(({className:t,...a},r)=>e("td",{ref:r,className:Fa("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",t),...a}));ni.displayName="TableCell";const ii=r.forwardRef(({className:t,...a},r)=>e("caption",{ref:r,className:Fa("mt-4 text-sm text-muted-foreground",t),...a}));function oi({rows:a=5,columns:r=4}){return e("div",{className:"w-full",children:t("div",{className:"rounded-md border",children:[e("div",{className:"border-b bg-muted/50 px-4 py-3",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((t,a)=>e(Xr,{className:"h-4 w-24"},a))})}),e("div",{children:Array.from({length:a}).map((t,a)=>e("div",{className:"border-b px-4 py-3 last:border-0",children:e("div",{className:"flex space-x-4",children:Array.from({length:r}).map((t,a)=>e(Xr,{className:"h-4 w-20"},a))})},a))})]})})}function li({count:a=3}){return e("div",{className:"space-y-4",children:Array.from({length:a}).map((a,r)=>t(Ka,{children:[t(Qa,{children:[e(Xr,{className:"h-4 w-3/4"}),e(Xr,{className:"h-3 w-1/2"})]}),e(Xa,{children:t("div",{className:"space-y-2",children:[e(Xr,{className:"h-3 w-full"}),e(Xr,{className:"h-3 w-2/3"})]})})]},r))})}function di({fields:a=4}){return t("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,r)=>t("div",{className:"space-y-2",children:[e(Xr,{className:"h-4 w-24"}),e(Xr,{className:"h-10 w-full"})]},r)),t("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Xr,{className:"h-10 w-20"}),e(Xr,{className:"h-10 w-20"})]})]})}function ci(){return t("div",{className:"flex items-center justify-between p-4 border-b",children:[t("div",{className:"flex items-center space-x-3",children:[e(Xr,{className:"h-8 w-8 rounded-full"}),e(Xr,{className:"h-6 w-32"})]}),t("div",{className:"flex items-center space-x-2",children:[e(Xr,{className:"h-8 w-8"}),e(Xr,{className:"h-8 w-24"})]})]})}function ui(){return e("div",{className:"w-64 border-r bg-muted/10",children:t("div",{className:"p-4",children:[e(Xr,{className:"h-8 w-32 mb-6"}),e("div",{className:"space-y-2",children:Array.from({length:6}).map((a,r)=>t("div",{className:"flex items-center space-x-3 p-2",children:[e(Xr,{className:"h-4 w-4"}),e(Xr,{className:"h-4 w-20"})]},r))})]})})}ii.displayName="TableCaption";const mi={default:M,search:D,error:F};function hi({icon:a,title:r,description:s,action:n,className:i,variant:o="default"}){const l=a?()=>a:mi[o];return t("div",{className:Fa("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[e("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e(l,{className:"h-8 w-8 text-muted-foreground"})}),e("h3",{className:"text-lg font-semibold mb-2",children:r}),s&&e("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),n&&e(Va,{onClick:n.onClick,variant:"outline",children:n.label})]})}const pi=Nt.Root,fi=Nt.Trigger,gi=Nt.Group,bi=Nt.Portal,vi=Nt.Sub,yi=Nt.RadioGroup,xi=r.forwardRef(({className:a,inset:r,children:s,...n},i)=>t(Nt.SubTrigger,{ref:i,className:Fa("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",a),...n,children:[s,e(z,{className:"ml-auto h-4 w-4"})]}));xi.displayName=Nt.SubTrigger.displayName;const Ni=r.forwardRef(({className:t,...a},r)=>e(Nt.SubContent,{ref:r,className:Fa("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",t),...a}));Ni.displayName=Nt.SubContent.displayName;const wi=r.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e(Nt.Portal,{children:e(Nt.Content,{ref:s,sideOffset:a,className:Fa("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",t),...r})}));wi.displayName=Nt.Content.displayName;const ki=r.forwardRef(({className:t,inset:a,...r},s)=>e(Nt.Item,{ref:s,className:Fa("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",t),...r}));ki.displayName=Nt.Item.displayName;const Si=r.forwardRef(({className:a,children:r,checked:s,...n},i)=>t(Nt.CheckboxItem,{ref:i,className:Fa("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",a),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Nt.ItemIndicator,{children:e(P,{className:"h-4 w-4"})})}),r]}));Si.displayName=Nt.CheckboxItem.displayName;const Ci=r.forwardRef(({className:a,children:r,...s},n)=>t(Nt.RadioItem,{ref:n,className:Fa("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",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(Nt.ItemIndicator,{children:e($,{className:"h-2 w-2 fill-current"})})}),r]}));Ci.displayName=Nt.RadioItem.displayName;const _i=r.forwardRef(({className:t,inset:a,...r},s)=>e(Nt.Label,{ref:s,className:Fa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...r}));_i.displayName=Nt.Label.displayName;const Ei=r.forwardRef(({className:t,...a},r)=>e(Nt.Separator,{ref:r,className:Fa("-mx-1 my-1 h-px bg-muted",t),...a}));Ei.displayName=Nt.Separator.displayName;const Pi=({className:t,...a})=>e("span",{className:Fa("ml-auto text-xs tracking-widest opacity-60",t),...a});Pi.displayName="DropdownMenuShortcut";const Ii=({onEdit:r,onDelete:s,onToggleStatus:n,isActive:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d})=>{const{t:c}=Ns(),u=[];if(r){const e={icon:U,label:c("edit"),onClick:r};u.push(e)}if(l.forEach(e=>{u.push(e)}),n){const e={icon:i?V:q,label:c(i?"deactivate":"activate"),onClick:n};u.push(e)}if(o&&s){const e={icon:B,label:c("delete"),onClick:s,destructive:!0};u.push(e)}return e(a,"dropdown"===d?{children:u.map((a,r)=>t(ki,{onClick:a.onClick,className:a.destructive?"text-destructive":"",children:[e(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},r))}:{children:u.map((a,r)=>t(Va,{variant:"ghost",size:"sm",onClick:a.onClick,className:"w-full justify-start px-2 py-1.5 text-sm font-normal h-7 "+(a.destructive?"text-destructive hover:text-destructive":""),children:[e(a.icon,{className:"h-4 w-4 mr-2"}),a.label]},r))})},Ti=({onEdit:a,onDelete:r,canDelete:s=!0,onToggleStatus:n,isActive:i=!0,customActions:o=[]})=>t(pi,{children:[e(fi,{asChild:!0,children:e(Va,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e(S,{size:12})})}),e(wi,{align:"end",className:"bg-background border border-border shadow-lg w-[160px]",children:e(Ii,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:r?e=>{e?.stopPropagation(),r?.()}:void 0,onToggleStatus:n?e=>{e?.stopPropagation(),n?.()}:void 0,isActive:i,canDelete:s&&!!r,customActions:o,renderAs:"dropdown"})})]}),Ai=wt.Root,Ri=wt.Trigger,Oi=wt.Group,Li=wt.Portal,Fi=wt.Sub,ji=wt.RadioGroup,Di=r.forwardRef(({className:a,inset:r,children:s,...n},i)=>t(wt.SubTrigger,{ref:i,className:Fa("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",r&&"pl-8",a),...n,children:[s,e(z,{className:"ml-auto h-4 w-4"})]}));Di.displayName=wt.SubTrigger.displayName;const Mi=r.forwardRef(({className:t,...a},r)=>e(wt.SubContent,{ref:r,className:Fa("z-50 min-w-[8rem] overflow-hidden rounded-md 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",t),...a}));Mi.displayName=wt.SubContent.displayName;const zi=r.forwardRef(({className:t,...a},r)=>e(wt.Portal,{children:e(wt.Content,{ref:r,className:Fa("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",t),...a})}));zi.displayName=wt.Content.displayName;const $i=r.forwardRef(({className:t,inset:a,...r},s)=>e(wt.Item,{ref:s,className:Fa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...r}));$i.displayName=wt.Item.displayName;const Ui=r.forwardRef(({className:a,children:r,checked:s,...n},i)=>t(wt.CheckboxItem,{ref:i,className:Fa("relative flex 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",a),checked:s,...n,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(wt.ItemIndicator,{children:e(P,{className:"h-4 w-4"})})}),r]}));Ui.displayName=wt.CheckboxItem.displayName;const Vi=r.forwardRef(({className:a,children:r,...s},n)=>t(wt.RadioItem,{ref:n,className:Fa("relative flex 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",a),...s,children:[e("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e(wt.ItemIndicator,{children:e($,{className:"h-2 w-2 fill-current"})})}),r]}));Vi.displayName=wt.RadioItem.displayName;const qi=r.forwardRef(({className:t,inset:a,...r},s)=>e(wt.Label,{ref:s,className:Fa("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...r}));qi.displayName=wt.Label.displayName;const Bi=r.forwardRef(({className:t,...a},r)=>e(wt.Separator,{ref:r,className:Fa("-mx-1 my-1 h-px bg-border",t),...a}));Bi.displayName=wt.Separator.displayName;const Wi=({className:t,...a})=>e("span",{className:Fa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Wi.displayName="ContextMenuShortcut";const Hi=h(({checked:t,onCheckedChange:a})=>e(Ar,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),Ki=({manager:a,columns:r,onEdit:s,onView:n,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:m,enableBulkActions:h=!1,onNew:p,newButtonLabel:f,showNewButton:g=!0,customActions:b=[],hideActionBar:v=!1})=>{const{t:y}=Ns(),{setSearchVisible:x}=Mn(),[N,w]=c(!1);u(()=>(x(!0),()=>x(!1)),[x]),u(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const k=o(()=>(()=>{r.length;let e=0;const t=r.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,r=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:r,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[r]),S=!v&&(p||b.length>0);return N?a.isLoading?e(li,{count:3}):0===a.entities.length?e(hi,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):t("div",{className:"flex flex-col h-full",children:[S&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:t("div",{className:"flex items-center gap-2",children:[p&&g&&t(Va,{onClick:p,children:[e(W,{size:16,className:"mr-2"}),f||y("new")]}),b.map((a,r)=>{const s=a.icon;return t(Va,{onClick:a.action,variant:a.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),a.label]},r)})]})}),e("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(o=>t(Ai,{children:[e(Ri,{asChild:!0,children:e(Ka,{className:Fa("overflow-hidden cursor-pointer hover:bg-muted/50",h&&a.selectedIds.includes(o.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?a.selectItem(o.id):s?.(o)},children:e(Xa,{className:"p-4",children:t("div",{className:"flex items-start gap-3",children:[h&&e("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e(Hi,{checked:a.selectedIds.includes(o.id),onCheckedChange:()=>a.selectItem(o.id)})}),t("div",{className:"flex-1",children:[r.map(a=>t("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[t("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(o):String(o[a.key]??"")})]},String(a.key))),(s||n||d)&&e("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(o):e(Ti,{onEdit:s?()=>{s(o)}:void 0,onDelete:l?()=>l(o):void 0,onToggleStatus:i?()=>i(o):void 0,isActive:o.is_actived,customActions:m?m(o):[]})})]})]})})})}),e(zi,{className:"w-[160px]",children:e(Ii,{onEdit:s?()=>s(o):void 0,onDelete:l?()=>l(o):void 0,onToggleStatus:i?()=>i(o):void 0,isActive:o.is_actived,canDelete:!!l,customActions:m?m(o):[],renderAs:"context"})})]},o.id))})]}):t("div",{className:"flex flex-col h-full",children:[S&&e("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:t("div",{className:"flex items-center gap-2",children:[p&&g&&t(Va,{onClick:p,children:[e(W,{size:16,className:"mr-2"}),f||y("new")]}),b.map((a,r)=>{const s=a.icon;return t(Va,{onClick:a.action,variant:a.variant||"outline",children:[s&&e(s,{size:16,className:"mr-2"}),a.label]},r)})]})}),a.isLoading?e(oi,{rows:5,columns:r.length}):e("div",{className:"flex flex-col h-full overflow-hidden",children:e("div",{className:"flex-1 overflow-auto",children:t(Zn,{className:"table-auto",children:[t("colgroup",{children:[h&&e("col",{style:{width:"50px"}}),k.map((t,a)=>e("col",{style:t.style},a)),e("col",{style:{width:"50px"}})]}),e(ei,{children:t(ri,{children:[h&&e(si,{className:"w-[50px]",children:e(Hi,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),r.map(r=>{return e(si,{className:`${r.className||""} ${r.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:r.sortable?()=>a.handleSort(String(r.key)):void 0,children:t("div",{className:"flex items-center "+(r.className?.includes("text-center")?"justify-center":""),children:[r.header,r.sortable&&(s=String(r.key),a.sortField!==s?e(H,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e(K,{size:14,className:"ml-1"}):e(Q,{size:14,className:"ml-1"}))]})},String(r.key));var s}),e(si,{className:"w-[50px] text-center",children:y("actions")})]})}),e(ti,{children:0===a.entities.length?e(ri,{children:e(ni,{colSpan:h?r.length+2:r.length+1,className:"h-32",children:e(hi,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):a.entities.map(n=>t(Ai,{children:[e(Ri,{asChild:!0,children:t(ri,{className:Fa("cursor-pointer hover:bg-muted/50",h&&a.selectedIds.includes(n.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),h?a.selectItem(n.id):s?.(n)},children:[h&&e(ni,{onClick:e=>e.stopPropagation(),children:e(Hi,{checked:a.selectedIds.includes(n.id),onCheckedChange:()=>a.selectItem(n.id)})}),r.map(t=>e(ni,{className:t.className,children:t.render?t.render(n):String(n[t.key]??"")},String(t.key))),e(ni,{className:"text-center",children:d?d(n):e(Ti,{onEdit:s?()=>s(n):void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,customActions:m?m(n):[]})})]})}),e(zi,{className:"w-[160px]",children:e(Ii,{onEdit:s?()=>s(n):void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,canDelete:!!l,customActions:m?m(n):[],renderAs:"context"})})]},n.id))})]})})})]})};function Qi(e,t,a,r){const[s,n]=c({}),[i,l]=c({}),d=o(()=>e,[e]),m=e=>e instanceof Date&&!isNaN(e.getTime()),h=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return h(e)}},f=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.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(t,a);if(e)return e}catch(r){}}};u(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},s=e(d),i={};s.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);m(e)&&(a=e.toISOString().split("T")[0])}else m(a)&&(a=a.toISOString().split("T")[0])}else a=h(e);i[e.name]=a}),s.forEach(e=>{const t=p(e,i);void 0!==t&&(i[e.name]=t)}),t&&Object.keys(t).forEach(e=>{s.find(t=>t.name===e)||void 0===t[e]||(i[e]=t[e])}),n(i),l({}),a&&a(i)},[d,t,a,r]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},b=()=>{const e=g(d),t={};return e.forEach(e=>{const a=f(e,s[e.name],s);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:s,errors:i,updateField:(e,t)=>{n(r=>{const s={...r,[e]:t},n=((e,t)=>{let a={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,s);return a&&a(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const r=g(d).find(t=>t.name===e);if(r){const a=f(r,t,s);a&&l(t=>({...t,[e]:a}))}},validateForm:b,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),b()&&e(s)}}}const Gi=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ji=({value:a="#3b82f6",onChange:r,label:s})=>t("div",{className:"space-y-2",children:[s&&e(Ha,{children:s}),t(zr,{children:[e($r,{asChild:!0,children:t(Va,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:a}}),a]})}),e(Ur,{className:"w-64",children:t("div",{className:"space-y-3",children:[t("div",{children:[e(Ha,{htmlFor:"color-input",children:"Cor personalizada"}),e(Ba,{id:"color-input",type:"color",value:a,onChange:e=>r?.(e.target.value),className:"h-10 w-full"})]}),t("div",{children:[e(Ha,{children:"Cores predefinidas"}),e("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Gi.map(t=>e("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>r?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),Xi=r.forwardRef(({className:a,children:r,...s},n)=>t(kt.Root,{ref:n,className:Fa("relative overflow-hidden",a),...s,children:[e(kt.Viewport,{className:"h-full w-full rounded-[inherit]",children:r}),e(Yi,{}),e(kt.Corner,{})]}));Xi.displayName=kt.Root.displayName;const Yi=r.forwardRef(({className:t,orientation:a="vertical",...r},s)=>e(kt.ScrollAreaScrollbar,{ref:s,orientation:a,className:Fa("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]",t),...r,children:e(kt.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Yi.displayName=kt.ScrollAreaScrollbar.displayName;const Zi={Star:ze,Heart:Me,Home:De,User:je,Settings:Fe,Mail:Le,Phone:Oe,Calendar:Re,MapPin:Ae,Camera:Te,Image:Ie,Music:Pe,Video:Ee,Book:_e,Bookmark:Ce,Search:D,Filter:Se,Edit:U,Trash2:B,Plus:W,Minus:ke,Check:P,X:C,ChevronDown:_,ChevronUp:E,ChevronLeft:we,ChevronRight:z,ArrowUp:K,ArrowDown:Q,ArrowLeft:Ne,ArrowRight:xe,Clock:ye,Bell:ve,AlertCircle:F,Info:be,HelpCircle:ge,Download:fe,Upload:pe,Share:he,Copy:me,Save:ue,FileText:ce,Folder:de,FolderOpen:le,Archive:oe,Lock:ie,Unlock:ne,Eye:se,EyeOff:re,Shield:ae,Key:te,Zap:ee,Flame:Z,Sparkles:Y,Award:X,Trophy:J,Target:G},eo=({value:a="Star",onChange:r,label:s})=>{const{t:n}=Ns(),[i,o]=c(""),l=Object.entries(Zi).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),d=Zi[a]||ze;return t("div",{className:"space-y-2",children:[s&&e(Ha,{children:s}),t(zr,{children:[e($r,{asChild:!0,children:t(Va,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e(d,{className:"h-4 w-4 mr-2"}),a]})}),e(Ur,{className:"w-80",children:t("div",{className:"space-y-3",children:[t("div",{children:[e(Ha,{htmlFor:"icon-search",children:n("search")}),e(Ba,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e(Xi,{className:"h-48",children:e("div",{className:"grid grid-cols-6 gap-2",children:l.map(([t,s])=>e("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>r?.(t),title:t,children:e(s,{className:"h-4 w-4"})},t))})})]})})]})]})},to=r.forwardRef(({className:t,...a},r)=>e(St.Root,{className:Fa("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:r,children:e(St.Thumb,{className:Fa("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));to.displayName=St.Root.displayName;const ao=(e={})=>{const{user:t,alias:a}=Mn(),{enabled:r=!0}=e;return ht({queryKey:["qualiex-users",a],queryFn:()=>un.getUsers(a),enabled:r&&!!a&&!!t,retry:2,retryDelay:1e3})},ro=({value:t="",onChange:a,placeholder:r,disabled:s,className:n,enabled:i})=>{const{t:o}=Ns(),{data:l=[],isLoading:d,error:c}=ao({enabled:i});return e(Cs,{value:t,onChange:a,options:l,isLoading:d,error:c,getOptionValue:e=>e.userId,getOptionLabel:e=>e.userName,placeholder:r||o("search_placeholder"),searchPlaceholder:o("search_placeholder"),emptyMessage:o("no_results"),disabled:s,className:n})};function so({title:a,sections:r,initialData:n,onSubmit:i,onCancel:u,open:m,submitButtonText:h,isLoading:p=!1,usersData:f}){const{t:g}=Ns(),[b,v]=c(r?.[0]?.id||""),y=l(null),[x,N]=c(null),w=d(e=>{y.current=e,N(e)},[]),k=o(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:S,errors:C,updateField:_,handleSubmit:E}=Qi(k,n,void 0,m),P=o(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(S):e.disabled||!1})):[],[r,S]),I=o(()=>{const e=P.find(e=>e.id===b);if(e&&!e.disabled)return b;const t=P.find(e=>!e.disabled);return t?.id||b},[P,b]);s.useEffect(()=>{I!==b&&v(I)},[I,b]);const T=P.find(e=>e.id===I),A=a=>{const r=(a.computedValue,S[a.name]),s=void 0!==r?r:"",n=C[a.name];switch(a.type){case"group":const r="horizontal"===a.layout,i=r?`flex gap-3 w-full ${a.className||""}`:"space-y-3",o=r?Fa("space-y-2 w-full",a.wrapperClassName):Fa("space-y-2",a.className,a.wrapperClassName);return t("div",{className:o,children:[a.label,e("div",{className:i,children:a.fields?.map(e=>A(e))})]},a.name);case"user-select":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ro,{value:s||"",onChange:e=>_(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:n?"border-red-500":""}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"textarea":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Rr,{id:a.name,value:s||"",onChange:e=>{_(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"select":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t(Nr,{value:String(s),onValueChange:e=>{_(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e(Sr,{className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:e(kr,{placeholder:a.placeholder})}),e(Er,{children:a.options?.map(t=>e(Ir,{value:t.value,children:t.label},t.value))})]}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"multiselect":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Cs,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>_(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:n,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"date":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:"date",value:String(s),onChange:e=>_(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Fa("w-full",n?"border-red-500":"",a.disabled?"bg-gray-100 cursor-not-allowed":"")}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"color":return t("div",{children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>_(a.name,e.target.value),className:"h-10"}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"color-picker":return t("div",{children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ji,{value:s||a.defaultValue||"#3b82f6",onChange:e=>_(a.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"icon-picker":return t("div",{children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(eo,{value:s||a.defaultValue||"Star",onChange:e=>_(a.name,e)}),n&&e("p",{className:"text-sm text-destructive mt-1",children:n})]},a.name);case"custom":if(!a.component)return null;const l=a.component,d="function"==typeof a.componentProps?a.componentProps(S):a.componentProps||{};return t("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(l,{value:s,onChange:e=>{_(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:n,popoverContainer:x,...d}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"number":return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,r=""===t?null:Number(t);_(a.name,r)},placeholder:a.placeholder,disabled:a.disabled,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"checkbox":return t("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e(Ar,{id:a.name,checked:!!s,onCheckedChange:e=>_(a.name,e),disabled:a.disabled}),t(Ha,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name);case"switch":return t("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(to,{id:a.name,checked:!!s,onCheckedChange:e=>_(a.name,e),disabled:a.disabled}),n&&e("p",{className:"text-sm text-red-500 mt-2",children:n})]},a.name);default:return t("div",{className:`space-y-2 ${a.className||""}`,children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:"text",value:s||"",onChange:e=>{_(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${n?"border-red-500":""} ${a.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:a.disabled}),n&&e("p",{className:"text-sm text-red-500",children:n})]},a.name)}},R=d(()=>{if(!T)return null;if(T.disabled)return t("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e("div",{className:"rounded-full bg-muted p-3 mb-4",children:e("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e("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(T.component){const t=T.component;return e(t,{formData:S,updateField:_,errors:C,users:f,disabled:T.disabled})}return e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:T.fields.map(A)})},[T,S,_,C,f,A]),O=t("div",{className:"flex flex-col max-h-[80vh]",children:[P.length>1&&e("div",{className:"flex-shrink-0 p-4 border-b",children:e("div",{className:"flex space-x-2",children:P.map(t=>e(Va,{variant:I===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=P.find(t=>t.id===e);t&&!t.disabled&&v(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:p?e("div",{className:"flex items-center justify-center py-12",children:e("div",{className:"text-muted-foreground",children:g("loading")})}):t("form",{onSubmit:E(i),className:"space-y-3 md:space-y-4",children:[R(),t("div",{className:"flex justify-end space-x-2 pt-4",children:[e(Va,{type:"button",variant:"outline",onClick:u,children:g("cancel")}),e(Va,{type:"submit",disabled:p,children:h||g("save")})]})]})})]});return e(er,{open:m,onOpenChange:e=>{!1===e&&!0===m&&u()},children:t(nr,{ref:w,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[t(ir,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e(dr,{className:"text-white",children:a}),e(cr,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),O]})})}function no({currentPage:r,totalPages:s,totalItems:n,itemsPerPage:i,onPageChange:o,onItemsPerPageChange:l,variant:d="full"}){const c=(r-1)*i+1,u=Math.min(r*i,n);return t("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e("div",{className:"flex items-center gap-2",children:"full"===d&&t(a,{children:[e("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),t(Nr,{value:String(i),onValueChange:e=>l(Number(e)),children:[e(Sr,{className:"h-8 w-[70px]",children:e(kr,{})}),t(Er,{children:[e(Ir,{value:"10",children:"10"}),e(Ir,{value:"25",children:"25"}),e(Ir,{value:"50",children:"50"}),e(Ir,{value:"100",children:"100"})]})]})]})}),t("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," de ",n," itens"]}),t("div",{className:"flex items-center gap-1",children:[e(Va,{variant:"outline",size:"sm",onClick:()=>o(1),disabled:1===r,className:"h-8 w-8 p-0",children:e($e,{size:16})}),e(Va,{variant:"outline",size:"sm",onClick:()=>o(r-1),disabled:1===r,className:"h-8 w-8 p-0",children:e(we,{size:16})}),t("div",{className:"flex items-center gap-1 px-2",children:[e("span",{className:"text-sm font-medium",children:r}),e("span",{className:"text-sm text-muted-foreground",children:"de"}),e("span",{className:"text-sm font-medium",children:s})]}),e(Va,{variant:"outline",size:"sm",onClick:()=>o(r+1),disabled:r===s,className:"h-8 w-8 p-0",children:e(z,{size:16})}),e(Va,{variant:"outline",size:"sm",onClick:()=>o(s),disabled:r===s,className:"h-8 w-8 p-0",children:e(Ue,{size:16})})]})]})}function io({manager:t}){return e(no,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const oo=({selectedCount:a,onClearSelection:r,onBulkDelete:s,customActions:n=[],isLoading:i=!1})=>{const{t:o}=Ns();return t("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[t("div",{className:"flex items-center gap-3",children:[e("span",{className:"text-sm font-medium",children:o("selected",{count:a})}),t(Va,{variant:"ghost",size:"sm",onClick:r,className:"h-7 px-2",children:[e(C,{size:14,className:"mr-1"}),o("clear")]})]}),t("div",{className:"flex items-center gap-2",children:[n.map((a,r)=>{const s=a.icon;return t(Va,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:i,className:"h-7",children:[s&&e(s,{size:14,className:"mr-1"}),a.label]},r)}),s&&t(Va,{variant:"destructive",size:"sm",onClick:s,disabled:i,className:"h-7",children:[e(B,{size:14,className:"mr-1"}),o("delete")]})]})]})},lo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},co={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},uo={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function mo({children:t,direction:a="column",gap:r="md",align:s="stretch",justify:n="start",wrap:i=!1,className:o}){return e("div",{className:Fa("flex","column"===a?"flex-col":"flex-row",lo[r],co[s],uo[n],i&&"flex-wrap",o),children:t})}function ho({manager:r,filters:s,inline:n=!1}){const{t:i}=Ns(),{isSearchVisible:o}=Mn(),l=r.searchTerm,d=t(a,{children:[s.some(e=>"search"===e.type)&&!o&&t("div",{className:"relative flex-1",children:[e(D,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(Ba,{placeholder:i("search"),value:r.searchTerm,onChange:e=>r.handleSearch(e.target.value),className:"pl-10"})]}),s.filter(e=>"select"===e.type&&e.options).map((a,r)=>t("select",{value:a.value||"",onChange:e=>a.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[a.placeholder&&e("option",{value:"",children:a.placeholder}),a.options.map(t=>e("option",{value:t.value,children:t.label},t.value))]},`select-${r}`)),s.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e("div",{className:n?"":"w-full sm:w-auto",children:e(r,{...t.props})},`custom-${a}`)}),l&&t(Va,{variant:"outline",onClick:r.clearFilters,className:"whitespace-nowrap",children:[e(C,{className:"h-4 w-4 mr-2"}),i("clear")]})]});return n?e("div",{className:"flex items-center gap-2",children:d}):e(mo,{direction:"column",gap:"md",className:"mb-6",children:e(mo,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:d})})}function po({manager:a,config:r,formSections:s,onSave:n,onToggleStatus:i,defaultSort:o}){a&&a.queryKey;const{t:l}=Ns(),{setSearchVisible:d}=Mn(),[m,h]=gt(),[p,f]=c(!1),[g,b]=c(null),[v,y]=c({isOpen:!1,entityId:null,entityName:""}),[x,N]=c({isOpen:!1,count:0});u(()=>(d(!0),()=>{d(!1)}),[d]),u(()=>{if(o&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!m.has(e)&&!m.has(t)){const a=Object.fromEntries(m);a[e]=o.column,a[t]=o.direction,h(a)}}},[]);return t("div",{className:"flex-1 flex flex-col h-full",children:[r.enableBulkActions&&a.selectedIds.length>0&&e(oo,{selectedCount:a.selectedIds.length,onClearSelection:a.clearSelection,onBulkDelete:r.bulkActions&&r.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:a.selectedIds.length})},customActions:r.bulkActions,isLoading:a.isBulkDeleting}),t("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[t("div",{className:"flex items-center gap-2",children:[t(Va,{onClick:()=>{r.onNew?r.onNew():(b(null),f(!0))},children:[e(W,{size:16,className:"mr-2"}),l("new")]}),r.customActions?.map((a,r)=>t(Va,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e(a.icon,{size:16,className:"mr-2"}),a.label]},r))]}),r.filters&&r.filters.length>0&&e("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e(ho,{manager:a,filters:r.filters,inline:!0})})]}),e("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?e("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(a.entities,a)}):e(Ki,{manager:a,columns:r.columns,onEdit:e=>{r.onEdit?r.onEdit(e):(b(e),f(!0))},onDelete:e=>{y({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions})}),e("div",{className:"flex-shrink-0 border-t bg-background",children:e(io,{manager:a})}),!r.useCustomRouting&&e(so,{open:p,title:g?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:g||void 0,onSubmit:e=>{n(e),f(!1),b(null)},onCancel:()=>{f(!1),b(null)},isLoading:a.isLoading,submitButtonText:l(g?"update":"create")}),e(Yn,{open:v.isOpen,onOpenChange:()=>{y({isOpen:!1,entityId:null,entityName:""})},onConfirm:e=>{v.entityId&&(a.deleteEntity(v.entityId),y({isOpen:!1,entityId:null,entityName:""}))},item:v.entityId?{id:v.entityId,title:v.entityName}:void 0,entityName:r.entityName,isDeleting:a.isDeleting}),e(Yn,{open:x.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),onConfirm:()=>(a.bulkDelete?.(a.selectedIds),void N({isOpen:!1,count:0})),item:{id:"bulk",title:`${x.count} ${1===x.count?r.entityName:r.entityNamePlural}`},entityName:r.entityNamePlural,isDeleting:a.isBulkDeleting,isBulk:!0,bulkCount:x.count})]})}function fo(t){return({manager:a})=>{const{manager:r,config:s,onSave:n,onEdit:i,onToggleStatus:o}=t,l=a??r,d={entityName:s.entityName,entityNamePlural:s.entityNamePlural,filters:s.filters||[],columns:s.columns,cardFields:s.cardFields||[],enableBulkActions:s.enableBulkActions??!1,bulkActions:s.bulkActions||[],customActions:s.customActions,customRowActions:s.customRowActions,customListView:s.customListView,onEdit:i||s.onEdit};return e(po,{manager:l,config:d,formSections:s.formSections,onSave:n,onToggleStatus:o,defaultSort:s.defaultSort})}}function go(e,t,a){return r=>{if(r.id){const t=a(r);e.updateEntity(r.id,t)}else{const a=t(r);e.createEntity(a)}}}function bo(e,t,a={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],s={key:e,header:yo(e),label:yo(e),...vo(e,a),sortable:!0,searchable:"string"==typeof a};r.push(s)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}}function vo(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function yo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const xo=r.forwardRef(({className:t,value:a,...r},s)=>e(Ct.Root,{ref:s,className:Fa("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...r,children:e(Ct.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));function No({steps:a,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:Fa("flex items-center justify-between mb-6",n),children:a.map((r,n)=>t("div",{className:"flex items-center flex-1",children:[e("div",{className:Fa("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",r.isActive&&"border-primary bg-primary text-primary-foreground",r.isCompleted&&"border-primary bg-primary text-primary-foreground",!r.isActive&&!r.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!r.isDisabled&&"cursor-pointer hover:border-primary/50",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:r.isCompleted?e(P,{className:"w-5 h-5"}):n+1}),n<a.length-1&&e("div",{className:Fa("flex-1 h-0.5 mx-2 transition-colors",r.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},r.id))})}function wo({steps:a,currentStepIndex:r,onStepClick:s,className:n}){return e("div",{className:Fa("flex items-center gap-2 mb-6 overflow-x-auto",n),children:a.map((r,n)=>t("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[t("div",{className:Fa("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",r.isActive&&"bg-primary text-primary-foreground font-medium",r.isCompleted&&"bg-primary/10 text-primary",!r.isActive&&!r.isCompleted&&"bg-muted text-muted-foreground",s&&!r.isDisabled&&"cursor-pointer hover:bg-primary/20",r.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!r.isDisabled&&s(n),role:s&&!r.isDisabled?"button":void 0,tabIndex:s&&!r.isDisabled?0:void 0,"aria-label":`${r.label} - ${r.isCompleted?"Completo":r.isActive?"Atual":"Pendente"}`,children:[e("span",{className:"text-sm font-medium",children:n+1}),e("span",{className:"text-sm",children:r.label}),r.isCompleted&&e(P,{className:"w-4 h-4 ml-1"})]}),n<a.length-1&&e("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},r.id))})}function ko({steps:a,currentStepIndex:r,className:s}){const n=a[r],i=(r+1)/a.length*100;return t("div",{className:Fa("mb-6 space-y-2",s),children:[t("div",{className:"flex items-center justify-between text-sm",children:[t("span",{className:"text-muted-foreground",children:["Etapa ",r+1," de ",a.length]}),e("span",{className:"font-medium",children:n?.label})]}),e(xo,{value:i,className:"h-2"})]})}function So({isFirstStep:r,isLastStep:s,canGoNext:n,canGoPrevious:i,isLoading:o,onPrevious:l,onNext:d,onSubmit:c,previousButtonText:u,nextButtonText:m,submitButtonText:h}){const{t:p}=Ns();return t(a,{children:[e("div",{children:i&&!r&&e(Va,{type:"button",variant:"outline",onClick:l,disabled:o,children:u||p("previous")})}),t("div",{className:"flex gap-2",children:[n&&!s&&e(Va,{type:"button",onClick:d,disabled:o,children:m||p("next")}),s&&e(Va,{type:"button",onClick:c,disabled:o,children:o?p("saving"):h||p("save")})]})]})}function Co({title:a,sections:r,initialData:n,onSubmit:i,onCancel:u,open:m,submitButtonText:h,isLoading:p=!1,usersData:f,showProgressIndicator:g=!0,progressType:b="stepper",validateOnNext:v=!0,allowSkipSections:y=!1,previousButtonText:x,nextButtonText:N,onStepChange:w,onStepValidationFail:k,renderProgressIndicator:S,renderButtons:C,currentStepIndex:_,onCurrentStepChange:E}){const[P,I]=c(0),T=_??P,A=E??I,R=l(null),[O,L]=c(null),F=d(e=>{R.current=e,L(e)},[]),j=o(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:D,errors:M,updateField:z,handleSubmit:$}=Qi(j,n,void 0,m);s.useEffect(()=>{m&&A(0)},[m,A]);const U=d(()=>{const e=r[T];if(!e)return!0;const t=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),a={};let s=!0;return t.forEach(e=>{const t=D[e.name];if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(a[e.name]=`${e.label} é obrigatório`,s=!1),e.validation&&"function"==typeof e.validation){const r=e.validation(t,D);r&&(a[e.name]=r,s=!1)}}),!s&&k&&k(T,a),s},[r,T,D,k]),V=d(()=>{if(v&&!U())return;const e=T+1;e<r.length&&(A(e),w?.(e,r[e].id))},[T,r,v,U,A,w]),q=d(()=>{const e=T-1;e>=0&&(A(e),w?.(e,r[e].id))},[T,r,A,w]),B=d(()=>{let e=!0;for(let t=0;t<r.length;t++){r[t].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(t=>{const a=D[t.name];t.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(e=!1)})}e&&$(i)()},[r,D,$,i]),W=o(()=>r.map((e,t)=>({index:t,id:e.id,label:e.label||e.id,isActive:t===T,isCompleted:t<T,isDisabled:e.disabled||!1})),[r,T]),H=0===T,K=T===r.length-1,Q=o(()=>{if(!g)return null;if(S)return S(T,r.length,r);const t=y?e=>{A(e),w?.(e,r[e].id)}:void 0;switch(b){case"breadcrumb":return e(wo,{steps:W,currentStepIndex:T,onStepClick:t});case"progressbar":return e(ko,{steps:W,currentStepIndex:T});default:return e(No,{steps:W,currentStepIndex:T,onStepClick:t})}},[g,S,b,W,T,r,y,A,w]),G=o(()=>{const t={isFirstStep:H,isLastStep:K,canGoNext:T<r.length-1,canGoPrevious:T>0,isLoading:p,onPrevious:q,onNext:V,onSubmit:B,previousButtonText:x,nextButtonText:N,submitButtonText:h};return C?C(t):e(So,{...t})},[H,K,T,r.length,p,q,V,B,x,N,h,C]),J=a=>{const r=(a.computedValue,D[a.name]),s=void 0!==r?r:"",n=M[a.name];switch(a.type){case"group":return t("div",{className:"space-y-2",children:[a.label&&e(Ha,{className:"text-sm font-medium",children:a.label}),e("div",{className:Fa("grid gap-4",1===a.columns&&"grid-cols-1",2===a.columns&&"grid-cols-1 md:grid-cols-2",3===a.columns&&"grid-cols-1 md:grid-cols-3",4===a.columns&&"grid-cols-1 md:grid-cols-4",!a.columns&&"grid-cols-1"),children:a.fields?.map(e=>J(e))})]},a.name);case"number":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:"number",value:s,onChange:e=>z(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"textarea":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Rr,{id:a.name,value:s,onChange:e=>z(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"select":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),t(Nr,{value:s,onValueChange:e=>z(a.name,e),children:[e(Sr,{className:n?"border-destructive":"",children:e(kr,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e(Er,{children:a.options?.map(t=>e(Ir,{value:String(t.value),children:t.label},t.value))})]}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"multiselect":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Cs,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>z(a.name,e),placeholder:a.placeholder,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"color":case"color-picker":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ji,{value:s,onChange:e=>z(a.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"icon-picker":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(eo,{value:s,onChange:e=>z(a.name,e),label:""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"user-select":return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(ro,{value:s,onChange:e=>z(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name);case"custom":return a.render?t("div",{className:"space-y-2",children:[a.label&&t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>z(a.name,e),error:n,disabled:a.disabled}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name):null;default:return t("div",{className:"space-y-2",children:[t(Ha,{htmlFor:a.name,children:[a.label,a.required&&e("span",{className:"text-destructive ml-1",children:"*"})]}),e(Ba,{id:a.name,type:a.type||"text",value:s,onChange:e=>z(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:n?"border-destructive":""}),n&&e("p",{className:"text-sm text-destructive",children:n})]},a.name)}},X=r[T];return e(er,{open:m,onOpenChange:u,children:t(nr,{ref:F,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e(ir,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e(dr,{className:"text-white",children:a})}),Q,e("div",{className:"space-y-4 py-4",children:X?.fields.map(e=>J(e))}),e("div",{className:"flex justify-between pt-4 border-t",children:G})]})})}xo.displayName=Ct.Root.displayName;const _o=({children:r})=>{const{isAuthenticated:n,isLoading:i}=Mn();if(s.useEffect(()=>{if(!n)return;const e=()=>{Fs.areAllTokensValid()||Fn.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),s.useEffect(()=>{if(i)return;if(n)return;if(Fs.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const r=fn();(async()=>{r?await Fn.loginDev():Fn.loginProd()})()},[n,i]),i)return e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:e(Ga,{className:"text-xl font-semibold",children:"Carregando..."})}),t(Xa,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){const a=new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token");return e("div",a?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:e(Ga,{className:"text-xl font-semibold",children:"Processando..."})}),t(Xa,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:e(Ga,{className:"text-xl font-semibold",children:"Iniciando..."})}),t(Xa,{className:"text-center",children:[e("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e("p",{className:"text-muted-foreground",children:fn()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e(a,{children:r})},Eo=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"}}),Po=r.forwardRef(({className:t,variant:a,...r},s)=>e("div",{ref:s,role:"alert",className:Fa(Eo({variant:a}),t),...r}));Po.displayName="Alert";const Io=r.forwardRef(({className:t,...a},r)=>e("h5",{ref:r,className:Fa("mb-1 font-medium leading-none tracking-tight",t),...a}));Io.displayName="AlertTitle";const To=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("text-sm [&_p]:leading-relaxed",t),...a}));To.displayName="AlertDescription";const Ao=()=>{const{processCallback:r}=Mn(),[s,n]=c(null),[i,o]=c(!1);u(()=>{(async()=>{try{if(await r()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[r]);const l=async()=>{o(!0),n(null);try{await r()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{o(!1)}},d=()=>{window.location.href="/"};return e("div",s?{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:t(Ga,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e(F,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),t(Xa,{className:"space-y-4",children:[e(Po,{variant:"destructive",children:e(To,{children:s})}),e("div",{className:"text-sm text-muted-foreground",children:e("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),t("div",{className:"flex gap-2",children:[e(Va,{onClick:l,disabled:i,className:"flex-1",children:t(a,i?{children:[e(jr,{size:"sm",className:"mr-2"}),"Tentando..."]}:{children:[e(Ve,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e(Va,{onClick:d,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}:{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:e(Ga,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),t(Xa,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(jr,{size:"lg"})}),e("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Ro=()=>e("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:t(Ka,{className:"w-full max-w-md",children:[e(Qa,{className:"text-center",children:e(Ga,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),t(Xa,{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e(Va,{onClick:async()=>{fn()?await Fn.loginDev():Fn.loginProd()},className:"w-full",size:"lg",children:fn()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Oo=n(void 0);function Lo({children:t,actions:a}){const[r,s]=c({}),[n,i]=c(a);return u(()=>{i(a)},[a]),e(Oo.Provider,{value:{metadata:r,setMetadata:s,clearMetadata:()=>s({}),headerActions:n,setHeaderActions:i},children:t})}function Fo(){const e=i(Oo);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function jo(e){const{setMetadata:t,clearMetadata:a}=Fo();u(()=>(t(e),()=>a()),[e.title,e.subtitle,t,a])}function Do(e){return{queryClient:e.queryClient||new ft({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Mo=_t.Root,zo=r.forwardRef(({className:t,...a},r)=>e(_t.Item,{ref:r,className:Fa("border-b",t),...a}));zo.displayName="AccordionItem";const $o=r.forwardRef(({className:a,children:r,...s},n)=>e(_t.Header,{className:"flex",children:t(_t.Trigger,{ref:n,className:Fa("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[r,e(_,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));$o.displayName=_t.Trigger.displayName;const Uo=r.forwardRef(({className:t,children:a,...r},s)=>e(_t.Content,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:e("div",{className:Fa("pb-4 pt-0",t),children:a})}));Uo.displayName=_t.Content.displayName;const Vo=Et.Root,qo=r.forwardRef(({className:t,...a},r)=>e(Pt.Root,{ref:r,className:Fa("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));qo.displayName=Pt.Root.displayName;const Bo=r.forwardRef(({className:t,...a},r)=>e(Pt.Image,{ref:r,className:Fa("aspect-square h-full w-full",t),...a}));Bo.displayName=Pt.Image.displayName;const Wo=r.forwardRef(({className:t,...a},r)=>e(Pt.Fallback,{ref:r,className:Fa("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Wo.displayName=Pt.Fallback.displayName;const Ho=r.forwardRef(({...t},a)=>e("nav",{ref:a,"aria-label":"breadcrumb",...t}));Ho.displayName="Breadcrumb";const Ko=r.forwardRef(({className:t,...a},r)=>e("ol",{ref:r,className:Fa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));Ko.displayName="BreadcrumbList";const Qo=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,className:Fa("inline-flex items-center gap-1.5",t),...a}));Qo.displayName="BreadcrumbItem";const Go=r.forwardRef(({asChild:t,className:a,...r},s)=>e(t?f:"a",{ref:s,className:Fa("transition-colors hover:text-foreground",a),...r}));Go.displayName="BreadcrumbLink";const Jo=r.forwardRef(({className:t,...a},r)=>e("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Fa("font-normal text-foreground",t),...a}));Jo.displayName="BreadcrumbPage";const Xo=({children:t,className:a,...r})=>e("li",{role:"presentation","aria-hidden":"true",className:Fa("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...r,children:t??e(z,{})});Xo.displayName="BreadcrumbSeparator";const Yo=({className:a,...r})=>t("span",{role:"presentation","aria-hidden":"true",className:Fa("flex h-9 w-9 items-center justify-center",a),...r,children:[e(qe,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Mais"})]});Yo.displayName="BreadcrumbEllipsis";const Zo=g("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),el=r.forwardRef(({className:t,orientation:a,...r},s)=>e("div",{ref:s,className:Fa(Zo({orientation:a}),t),...r}));function tl(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function al(e){return(t,a)=>{let r;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;r=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;r=e.values[s]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function rl(e){return(t,a={})=>{const r=a.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const i=n[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(o,e=>e.test(i)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(i.length)}}}function sl(e){return(t,a={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],n=t.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=a.valueCallback?a.valueCallback(i):i;return{value:i,rest:t.slice(s.length)}}}el.displayName="ButtonGroup";const nl={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},il={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ol={ordinalNumber:(e,t)=>{const a=Number(e),r=a%100;if(r>20||r<10)switch(r%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:al({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:al({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:al({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:al({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:al({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},ll={ordinalNumber:sl({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:rl({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:rl({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:rl({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/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,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:rl({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:rl({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},dl={code:"en-US",formatDistance:(e,t,a)=>{let r;const s=nl[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+r:r+" ago":r},formatLong:{date:tl({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:tl({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:tl({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,t,a,r)=>il[e],localize:ol,match:ll,options:{weekStartsOn:0,firstWeekContainsDate:1}},cl={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},ul={date:tl({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:tl({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:tl({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ml={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},hl={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},pl={ordinalNumber:(e,t)=>Number(e)+"º",era:al({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:al({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:al({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:al({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:al({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},fl={ordinalNumber:sl({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:rl({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:rl({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:rl({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:rl({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:rl({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},gl={code:"es",formatDistance:(e,t,a)=>{let r;const s=cl[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+r:"hace "+r:r},formatLong:ul,formatRelative:(e,t,a,r)=>1!==t.getHours()?hl[e]:ml[e],localize:pl,match:fl,options:{weekStartsOn:1,firstWeekContainsDate:1}},bl={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"}},vl={date:tl({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:tl({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:tl({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},yl={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},xl={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:al({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:al({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:al({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:al({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:al({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"})},Nl={ordinalNumber:sl({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:rl({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:rl({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:rl({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:rl({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:rl({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"})},wl={code:"pt-BR",formatDistance:(e,t,a)=>{let r;const s=bl[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+r:"há "+r:r},formatLong:vl,formatRelative:(e,t,a,r)=>{const s=yl[e];return"function"==typeof s?s(t):s},localize:xl,match:Nl,options:{weekStartsOn:0,firstWeekContainsDate:1}};function kl({className:t,classNames:a,showOutsideDays:r=!0,...s}){return e(It,{showOutsideDays:r,className:Fa("p-3 pointer-events-auto",t),locale:wl,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Fa(Ua({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Fa(Ua({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:({...t})=>e(we,{className:"h-4 w-4"}),IconRight:({...t})=>e(z,{className:"h-4 w-4"})},...s})}kl.displayName="Calendar";const Sl=Tt.Root,Cl=Tt.CollapsibleTrigger,_l=Tt.CollapsibleContent;const El={Root:function({children:t,className:a}){return e("div",{className:Fa("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:r}){return e(Ka,{className:Fa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",r),onClick:a,children:e(Xa,{className:"p-4",children:t})})},Field:function({label:a,value:r,className:s}){return t("div",{className:Fa("flex justify-between items-center text-sm",s),children:[t("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e("span",{className:"text-foreground",children:r})]})}};function Pl({date:a,onDateChange:r,placeholder:s="Pick a date",disabled:n=!1,className:i,disabledDates:o}){return t(zr,{children:[e($r,{asChild:!0,children:t(Va,{variant:"outline",disabled:n,className:Fa("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",i),children:[e(Re,{className:"mr-2 h-4 w-4"}),a?N(a,"PPP"):e("span",{children:s})]})}),e(Ur,{className:"w-auto p-0",align:"start",children:e(kl,{mode:"single",selected:a,onSelect:r,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const Il=({shouldScaleBackground:t=!0,...a})=>e(At.Root,{shouldScaleBackground:t,...a});Il.displayName="Drawer";const Tl=At.Trigger,Al=At.Portal,Rl=At.Close,Ol=r.forwardRef(({className:t,...a},r)=>e(At.Overlay,{ref:r,className:Fa("fixed inset-0 z-50 bg-black/80",t),...a}));Ol.displayName=At.Overlay.displayName;const Ll=r.forwardRef(({className:a,children:r,...s},n)=>t(Al,{children:[e(Ol,{}),t(At.Content,{ref:n,className:Fa("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),r]})]}));Ll.displayName="DrawerContent";const Fl=({className:t,...a})=>e("div",{className:Fa("grid gap-1.5 p-4 text-center sm:text-left",t),...a});Fl.displayName="DrawerHeader";const jl=({className:t,...a})=>e("div",{className:Fa("mt-auto flex flex-col gap-2 p-4",t),...a});jl.displayName="DrawerFooter";const Dl=r.forwardRef(({className:t,...a},r)=>e(At.Title,{ref:r,className:Fa("text-lg font-semibold leading-none tracking-tight",t),...a}));Dl.displayName=At.Title.displayName;const Ml=r.forwardRef(({className:t,...a},r)=>e(At.Description,{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));function zl({value:t,onChange:a,activeLabel:r,inactiveLabel:s,allLabel:n,placeholder:i,className:o="w-full sm:w-[180px]"}){const{t:l}=Ns(),d=[{id:"active",name:r||l("active")},{id:"inactive",name:s||l("inactive")},{id:"all",name:n||l("all")}];return e(Cs,{value:t,onChange:e=>a(e),options:d,getOptionValue:e=>e.id,getOptionLabel:e=>e.name,placeholder:i||l("select"),className:o})}Ml.displayName=At.Description.displayName;const $l={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))]"},Ul={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Vl({children:t,cols:a="auto-fit",gap:r="md",className:s}){return e("div",{className:Fa("grid",$l[a],Ul[r],s),children:t})}const ql=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-slot":"input-group",className:Fa("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));ql.displayName="InputGroup";const Bl=g("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),Wl=r.forwardRef(({className:t,align:a,...r},s)=>e("div",{ref:s,"data-slot":"input-group-addon",className:Fa(Bl({align:a}),t),...r}));Wl.displayName="InputGroupAddon";const Hl=g("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),Kl=r.forwardRef(({className:t,size:a,variant:r="ghost",...s},n)=>e(Va,{ref:n,"data-slot":"input-group-button",variant:r,className:Fa(Hl({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...s}));Kl.displayName="InputGroupButton";const Ql=r.forwardRef(({className:t,...a},r)=>e(Ba,{ref:r,"data-slot":"input-group-control",className:Fa("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Ql.displayName="InputGroupInput";const Gl=r.forwardRef(({className:t,...a},r)=>e(Rr,{ref:r,"data-slot":"input-group-control",className:Fa("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Gl.displayName="InputGroupTextarea";const Jl=r.forwardRef(({className:a,keys:r,children:s,...n},i)=>r&&r.length>0?t("span",{className:Fa("inline-flex items-center gap-1",a),children:[r.map((t,a)=>e("kbd",{className:Fa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100"),children:t},a)),s&&e("kbd",{ref:i,className:Fa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100"),...n,children:s})]}):e("kbd",{ref:i,className:Fa("pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",a),...n,children:s}));Jl.displayName="Kbd";const Xl=r.forwardRef(({className:t,children:a,...r},s)=>e("select",{ref:s,className:Fa("flex h-10 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",t),...r,children:a}));Xl.displayName="NativeSelect";const Yl=r.forwardRef(({className:t,...a},r)=>e("h1",{ref:r,className:Fa("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));Yl.displayName="H1";const Zl=r.forwardRef(({className:t,...a},r)=>e("h2",{ref:r,className:Fa("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));Zl.displayName="H2";const ed=r.forwardRef(({className:t,...a},r)=>e("h3",{ref:r,className:Fa("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));ed.displayName="H3";const td=r.forwardRef(({className:t,...a},r)=>e("h4",{ref:r,className:Fa("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));td.displayName="H4";const ad=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Fa("leading-7 [&:not(:first-child)]:mt-6",t),...a}));ad.displayName="P";const rd=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Fa("text-xl text-muted-foreground",t),...a}));rd.displayName="Lead";const sd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,className:Fa("text-lg font-semibold",t),...a}));sd.displayName="Large";const nd=r.forwardRef(({className:t,...a},r)=>e("small",{ref:r,className:Fa("text-sm font-medium leading-none",t),...a}));nd.displayName="Small";const id=r.forwardRef(({className:t,...a},r)=>e("p",{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));id.displayName="Muted";const od=r.forwardRef(({className:t,...a},r)=>e("code",{ref:r,className:Fa("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));od.displayName="InlineCode";const ld=r.forwardRef(({className:t,...a},r)=>e("blockquote",{ref:r,className:Fa("mt-6 border-l-2 pl-6 italic",t),...a}));ld.displayName="Blockquote";const dd=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,className:Fa("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));function cd({items:t,maxItems:a=3,className:r}){return t.length>a&&(t[0],t.slice(-(a-1))),t.length,e(Ho,{className:r})}function ud(){const e=bt();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,s)=>{r+=`/${e}`;const n=s===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:i,href:n?void 0:r,isCurrentPage:n})}),a})()}dd.displayName="List";const md=({className:t,...a})=>e("nav",{role:"navigation","aria-label":"pagination",className:Fa("mx-auto flex w-full justify-center",t),...a});md.displayName="Pagination";const hd=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,className:Fa("flex flex-row items-center gap-1",t),...a}));hd.displayName="PaginationContent";const pd=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,className:Fa("",t),...a}));pd.displayName="PaginationItem";const fd=({className:t,isActive:a,size:r="icon",...s})=>e("a",{"aria-current":a?"page":void 0,className:Fa(Ua({variant:a?"outline":"ghost",size:r}),t),...s});fd.displayName="PaginationLink";const gd=({className:a,...r})=>t(fd,{"aria-label":"Go to previous page",size:"default",className:Fa("gap-1 pl-2.5",a),...r,children:[e(we,{className:"h-4 w-4"}),e("span",{children:"Previous"})]});gd.displayName="PaginationPrevious";const bd=({className:a,...r})=>t(fd,{"aria-label":"Go to next page",size:"default",className:Fa("gap-1 pr-2.5",a),...r,children:[e("span",{children:"Next"}),e(z,{className:"h-4 w-4"})]});bd.displayName="PaginationNext";const vd=({className:a,...r})=>t("span",{"aria-hidden":!0,className:Fa("flex h-9 w-9 items-center justify-center",a),...r,children:[e(qe,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"More pages"})]});vd.displayName="PaginationEllipsis";const yd=r.forwardRef(({className:t,...a},r)=>e(Rt.Root,{className:Fa("grid gap-2",t),...a,ref:r}));yd.displayName=Rt.Root.displayName;const xd=r.forwardRef(({className:t,...a},r)=>e(Rt.Item,{ref:r,className:Fa("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e(Rt.Indicator,{className:"flex items-center justify-center",children:e($,{className:"h-2.5 w-2.5 fill-current text-current"})})}));xd.displayName=Rt.Item.displayName;const Nd=g("flex h-10 w-full items-center rounded-md border border-input bg-background text-sm ring-offset-background transition-colors focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",{variants:{variant:{default:"",filled:"bg-muted border-transparent",outline:"border-2"},size:{default:"h-10",sm:"h-8",lg:"h-12"}},defaultVariants:{variant:"default",size:"default"}}),wd=r.forwardRef(({className:a,variant:r,size:s,onClear:n,showClearButton:i=!0,value:o,...l},d)=>{const c=null!=o&&""!==o;return t("div",{className:Fa(Nd({variant:r,size:s,className:a})),children:[e(D,{className:"ml-3 h-4 w-4 shrink-0 text-muted-foreground"}),e("input",{type:"text",className:Fa("flex-1 bg-transparent px-3 py-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50","sm"===s&&"py-1 text-xs","lg"===s&&"py-3"),ref:d,value:o,...l}),i&&c&&n&&e("button",{type:"button",onClick:n,className:"mr-2 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","aria-label":"Clear search",children:e(C,{className:"h-4 w-4"})})]})});wd.displayName="Searchbar";const kd=tt.Root,Sd=tt.Trigger,Cd=tt.Close,_d=tt.Portal,Ed=r.forwardRef(({className:t,...a},r)=>e(tt.Overlay,{className:Fa("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",t),...a,ref:r}));Ed.displayName=tt.Overlay.displayName;const Pd=g("fixed z-50 flex flex-col 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 max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] 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"}}),Id=r.forwardRef(({side:a="right",className:r,children:s,...n},i)=>t(_d,{children:[e(Ed,{}),t(tt.Content,{ref:i,className:Fa(Pd({side:a}),r),...n,children:[s,t(tt.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e(C,{className:"h-4 w-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]}));Id.displayName=tt.Content.displayName;const Td=({className:a,showSeparator:r=!1,children:s,...n})=>t("div",{className:Fa("flex flex-col flex-shrink-0",a),...n,children:[e("div",{className:"flex flex-col text-left",children:s}),r&&e(Za,{className:"mt-2"})]});Td.displayName="SheetHeader";const Ad=({className:t,...a})=>e("div",{className:Fa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Ad.displayName="SheetBody";const Rd=({className:a,children:r,...s})=>t("div",{className:"flex-shrink-0 pt-4",children:[e(Za,{className:"mb-4"}),e("div",{className:Fa("flex flex-row justify-end gap-2",a),...s,children:r})]});Rd.displayName="SheetFooter";const Od=r.forwardRef(({className:t,...a},r)=>e(tt.Title,{ref:r,className:Fa("text-lg font-semibold text-foreground",t),...a}));Od.displayName=tt.Title.displayName;const Ld=r.forwardRef(({className:t,...a},r)=>e(tt.Description,{ref:r,className:Fa("text-sm text-muted-foreground",t),...a}));Ld.displayName=tt.Description.displayName;const Fd=Ot.Provider,jd=Ot.Root,Dd=Ot.Trigger,Md=r.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e(Ot.Content,{ref:s,sideOffset:a,className:Fa("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",t),...r}));Md.displayName=Ot.Content.displayName;const zd="sidebar:state",$d=r.createContext(null);function Ud(){const e=r.useContext($d);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Vd=r.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:n,style:i,children:o,...l},d)=>{const[c,u]=r.useState(!1);r.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[m,h]=r.useState(!1),[p,f]=r.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(zd);return null!==e?"true"===e:t}return t}),g=a??p,b=r.useCallback(e=>{const t="function"==typeof e?e(g):e;s?s(t):f(t),"undefined"!=typeof window&&localStorage.setItem(zd,String(t))},[s,g]),v=r.useCallback(()=>c?h(e=>!e):b(e=>!e),[c,b,h]);r.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);const y=g?"expanded":"collapsed",x=r.useMemo(()=>({state:y,open:g,setOpen:b,isMobile:c,openMobile:m,setOpenMobile:h,toggleSidebar:v}),[y,g,b,c,m,h,v]);return e($d.Provider,{value:x,children:e(Fd,{delayDuration:0,children:e("div",{className:Fa("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",n),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...i},ref:d,...l,children:o})})})});Vd.displayName="SidebarProvider";const qd=r.forwardRef(({side:a="left",variant:r="sidebar",collapsible:s="offcanvas",className:n,children:i,...o},l)=>{const{isMobile:d,state:c,openMobile:u,setOpenMobile:m}=Ud();return"none"===s?e("div",{className:Fa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:l,...o,children:i}):d?e(kd,{open:u,onOpenChange:m,...o,children:t(Id,{"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:a,children:[e(Od,{className:"sr-only",children:"Menu de Navegação"}),e("div",{className:"flex h-full w-full flex-col",children:i})]})}):t("div",{ref:l,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?s:"","data-variant":r,"data-side":a,children:[e("div",{className:Fa("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"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e("div",{className:Fa("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===r||"inset"===r?"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",n),...o,children:e("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:i})})]})});qd.displayName="Sidebar";const Bd=r.forwardRef(({className:a,onClick:r,...s},n)=>{const{toggleSidebar:i}=Ud();return t(Va,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Fa("h-7 w-7",a),onClick:e=>{r?.(e),i()},...s,children:[e(Be,{}),e("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Bd.displayName="SidebarTrigger";const Wd=r.forwardRef(({className:t,...a},r)=>{const{toggleSidebar:s}=Ud();return e("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:Fa("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",t),...a})});Wd.displayName="SidebarRail";const Hd=r.forwardRef(({className:t,...a},r)=>e("main",{ref:r,className:Fa("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",t),...a}));Hd.displayName="SidebarInset";const Kd=r.forwardRef(({className:t,...a},r)=>e(Ba,{ref:r,"data-sidebar":"input",className:Fa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));Kd.displayName="SidebarInput";const Qd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"header",className:Fa("flex flex-col gap-2 p-2",t),...a}));Qd.displayName="SidebarHeader";const Gd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"footer",className:Fa("flex flex-col gap-2 p-2",t),...a}));Gd.displayName="SidebarFooter";const Jd=r.forwardRef(({className:t,...a},r)=>e(Za,{ref:r,"data-sidebar":"separator",className:Fa("mx-2 w-auto bg-sidebar-border",t),...a}));Jd.displayName="SidebarSeparator";const Xd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"content",className:Fa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));Xd.displayName="SidebarContent";const Yd=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"group",className:Fa("relative flex w-full min-w-0 flex-col p-2",t),...a}));Yd.displayName="SidebarGroup";const Zd=r.forwardRef(({className:t,asChild:a=!1,...r},s)=>e(a?f:"div",{ref:s,"data-sidebar":"group-label",className:Fa("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",t),...r}));Zd.displayName="SidebarGroupLabel";const ec=r.forwardRef(({className:t,asChild:a=!1,...r},s)=>e(a?f:"button",{ref:s,"data-sidebar":"group-action",className:Fa("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",t),...r}));ec.displayName="SidebarGroupAction";const tc=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"group-content",className:Fa("w-full text-sm",t),...a}));tc.displayName="SidebarGroupContent";const ac=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,"data-sidebar":"menu",className:Fa("flex w-full min-w-0 flex-col gap-1",t),...a}));ac.displayName="SidebarMenu";const rc=r.forwardRef(({className:t,...a},r)=>e("li",{ref:r,"data-sidebar":"menu-item",className:Fa("group/menu-item relative",t),...a}));rc.displayName="SidebarMenuItem";const sc=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 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),nc=r.forwardRef(({asChild:a=!1,isActive:r=!1,variant:s="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?f:"button",{isMobile:u,state:m}=Ud(),h=e(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":r,className:Fa(sc({variant:s,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),t(jd,{children:[e(Dd,{asChild:!0,children:h}),e(Md,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):h});nc.displayName="SidebarMenuButton";const ic=r.forwardRef(({className:t,asChild:a=!1,showOnHover:r=!1,...s},n)=>e(a?f:"button",{ref:n,"data-sidebar":"menu-action",className:Fa("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...s}));ic.displayName="SidebarMenuAction";const oc=r.forwardRef(({className:t,...a},r)=>e("div",{ref:r,"data-sidebar":"menu-badge",className:Fa("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",t),...a}));oc.displayName="SidebarMenuBadge";const lc=r.forwardRef(({className:a,showIcon:s=!1,...n},i)=>{const o=r.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return t("div",{ref:i,"data-sidebar":"menu-skeleton",className:Fa("rounded-md h-8 flex gap-2 px-2 items-center",a),...n,children:[s&&e("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});lc.displayName="SidebarMenuSkeleton";const dc=r.forwardRef(({className:t,...a},r)=>e("ul",{ref:r,"data-sidebar":"menu-sub",className:Fa("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",t),...a}));dc.displayName="SidebarMenuSub";const cc=r.forwardRef(({...t},a)=>e("li",{ref:a,...t}));cc.displayName="SidebarMenuSubItem";const uc=r.forwardRef(({asChild:t=!1,size:a="md",isActive:r,className:s,...n},i)=>e(t?f:"a",{ref:i,"data-sidebar":"menu-sub-button","data-size":a,"data-active":r,className:Fa("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),...n}));uc.displayName="SidebarMenuSubButton";const mc=r.forwardRef(({className:a,...r},s)=>t(Lt.Root,{ref:s,className:Fa("relative flex w-full touch-none select-none items-center",a),...r,children:[e(Lt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e(Lt.Range,{className:"absolute h-full bg-primary"})}),e(Lt.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));mc.displayName=Lt.Root.displayName;const hc=Ft.Root,pc=r.forwardRef(({className:t,...a},r)=>e(Ft.List,{ref:r,className:Fa("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));pc.displayName=Ft.List.displayName;const fc=r.forwardRef(({className:t,...a},r)=>e(Ft.Trigger,{ref:r,className:Fa("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));fc.displayName=Ft.Trigger.displayName;const gc=r.forwardRef(({className:t,...a},r)=>e(Ft.Content,{ref:r,className:Fa("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));function bc({children:t,className:a}){return e("div",{className:Fa("flex flex-col h-full",a),children:e(Xi,{className:"flex-1",children:e("div",{className:"space-y-6 p-6",children:t})})})}function vc({title:a,description:r,actions:s,className:n}){return t("div",{className:Fa("space-y-4",n),children:[t("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[t("div",{className:"space-y-1",children:[e("h2",{className:"text-2xl font-bold tracking-tight",children:a}),r&&e("p",{className:"text-muted-foreground text-sm",children:r})]}),s&&e("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e(Za,{})]})}function yc({children:t,className:a}){return e("div",{className:Fa("space-y-6",a),children:t})}gc.displayName=Ft.Content.displayName;const xc=jt.Provider,Nc=r.forwardRef(({className:t,...a},r)=>e(jt.Viewport,{ref:r,className:Fa("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",t),...a}));Nc.displayName=jt.Viewport.displayName;const wc=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"}}),kc=r.forwardRef(({className:t,variant:a,...r},s)=>e(jt.Root,{ref:s,className:Fa(wc({variant:a}),t),...r}));kc.displayName=jt.Root.displayName;const Sc=r.forwardRef(({className:t,...a},r)=>e(jt.Action,{ref:r,className:Fa("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",t),...a}));Sc.displayName=jt.Action.displayName;const Cc=r.forwardRef(({className:t,...a},r)=>e(jt.Close,{ref:r,className:Fa("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",t),"toast-close":"",...a,children:e(C,{className:"h-4 w-4"})}));Cc.displayName=jt.Close.displayName;const _c=r.forwardRef(({className:t,...a},r)=>e(jt.Title,{ref:r,className:Fa("text-sm font-semibold",t),...a}));_c.displayName=jt.Title.displayName;const Ec=r.forwardRef(({className:t,...a},r)=>e(jt.Description,{ref:r,className:Fa("text-sm opacity-90",t),...a}));Ec.displayName=jt.Description.displayName;const Pc=g("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Ic=r.forwardRef(({className:t,variant:a,size:r,...s},n)=>e(Dt.Root,{ref:n,className:Fa(Pc({variant:a,size:r,className:t})),...s}));Ic.displayName=Dt.Root.displayName;const Tc=r.createContext({size:"default",variant:"default"}),Ac=r.forwardRef(({className:t,variant:a,size:r,children:s,...n},i)=>e(Mt.Root,{ref:i,className:Fa("flex items-center justify-center gap-1",t),...n,children:e(Tc.Provider,{value:{variant:a,size:r},children:s})}));Ac.displayName=Mt.Root.displayName;const Rc=r.forwardRef(({className:t,children:a,variant:s,size:n,...i},o)=>{const l=r.useContext(Tc);return e(Mt.Item,{ref:o,className:Fa(Pc({variant:l.variant||s,size:l.size||n}),t),...i,children:a})});function Oc({manager:a,config:r,onEdit:s,onDelete:n}){const{t:i}=Ns();return a.isLoading?e(Vl,{children:Array.from({length:3}).map((a,r)=>t(Ka,{children:[t(Qa,{children:[e(Xr,{className:"h-4 w-3/4"}),e(Xr,{className:"h-3 w-1/2"})]}),e(Xa,{children:t("div",{className:"space-y-2",children:[e(Xr,{className:"h-3 w-full"}),e(Xr,{className:"h-3 w-2/3"})]})})]},r))}):e(El.Root,{children:a.entities.map(a=>t(El.Item,{onClick:()=>s(a),children:[e(Qa,{className:"pb-3",children:t("div",{className:"flex items-start justify-between",children:[t("div",{className:"flex-1 min-w-0",children:[e(Ga,{className:"text-base leading-6 truncate",children:a.title||a.name||i("no_title")}),e(Ja,{className:"text-sm",children:N(new Date(a.created_at),"dd/MM/yyyy HH:mm",{locale:wl})})]}),t("div",{className:"flex items-center gap-2 ml-2",children:[a.link&&e(Va,{variant:"external-link",size:"icon-xs",onClick:e=>{e.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),w.info(i("link_copied")))}catch(t){window.location.href=e}})(a.link)},title:i("open_external_link"),children:e(We,{className:"h-4 w-4"})}),e("div",{onClick:e=>e.stopPropagation(),children:e(Ti,{onEdit:()=>s(a),onDelete:n?()=>n(a):void 0,canDelete:!!n})})]})]})}),e(Xa,{className:"pt-0",children:e("div",{className:"space-y-2",children:r.cardFields?.map(t=>{const r=a[t.key];return r?e(El.Field,{label:t.label,value:t.render?t.render(r,a):String(r)},String(t.key)):null})})})]},a.id))})}function Lc({data:a,columns:r,sortField:s,sortDirection:n,onSort:i,onRowClick:l,renderActions:d,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:h=!1,selectedIds:p=[],onSelectItem:f,onSelectAll:g,isAllSelected:b=!1}){const v=o(()=>{const e=r.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return r.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[r]);return c?e("div",{className:"flex-1 overflow-auto",children:e("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e(Xr,{className:"h-12 w-full"},a))})}):0===a.length?e("div",{className:"flex-1 flex items-center justify-center",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:u})})}):e("div",{className:"flex-1 overflow-auto",children:t(Zn,{className:m,children:[e(ei,{className:"sticky top-0 bg-background z-10",children:t(ri,{children:[h&&e(si,{className:"w-[40px]",children:e(Ar,{checked:b,onCheckedChange:g,"aria-label":"Selecionar todos"})}),r.map((a,r)=>{return e(si,{className:a.className,style:{width:v[r]},children:a.sortable&&i?t("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(o=String(a.key),s!==o?e(H,{size:14,className:"ml-1 opacity-50"}):e("asc"===n?K:Q,{size:14,className:"ml-1"}))]}):e("span",{className:"font-medium",children:a.header})},String(a.key));var o}),d&&e(si,{className:"w-[80px] text-right",children:"Ações"})]})}),e(ti,{children:a.map(a=>t(ri,{onClick:()=>l?.(a),className:l?"cursor-pointer":"",children:[h&&e(ni,{children:e(Ar,{checked:p.includes(a.id),onCheckedChange:()=>f?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),r.map(t=>e(ni,{className:t.className,children:t.render?t.render(a):String(a[t.key]??"-")},String(t.key))),d&&e(ni,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(a)})]},a.id))})]})})}function Fc({onEdit:a,onDelete:r,onToggleStatus:s,isActive:n=!0,canEdit:i=!0,canDelete:o=!0,customActions:l=[],renderAs:d="dropdown",variant:c="default"}){const{t:u}=Ns(),m=[];return a&&i&&m.push({icon:U,label:u("edit"),onClick:a,variant:"default"}),s&&m.push({icon:n?V:q,label:u(n?"deactivate":"activate"),onClick:s,variant:"default"}),l.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),r&&o&&m.push({icon:B,label:u("remove"),onClick:r,variant:"destructive"}),0===m.length?null:"dropdown"===d?t(pi,{children:[e(fi,{asChild:!0,children:e(Va,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e(S,{size:"compact"===c?14:16})})}),e(wi,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,r)=>t(ki,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},r))})]}):e("div",{className:"flex items-center gap-1",children:m.map((a,r)=>t(Va,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e("span",{className:"ml-1",children:a.label})]},r))})}function jc({searchValue:a="",onSearchChange:r,customFilters:s=[],onClearFilters:n,showClearButton:i=!0,layout:o="horizontal"}){const{t:l}=Ns(),d=a||s.length>0;return t("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[r&&t("div",{className:"relative flex-1 min-w-[200px]",children:[e(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(Ba,{type:"text",placeholder:l("search"),value:a,onChange:e=>r(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e("div",{className:"vertical"===o?"w-full":"",children:t},a)),i&&d&&n&&t(Va,{variant:"ghost",size:"sm",onClick:n,className:"h-9 px-3 whitespace-nowrap",children:[e(C,{size:14,className:"mr-1"}),l("clear_filters")]})]})}function Dc({data:t,renderCard:a,isLoading:r=!1,emptyMessage:s="Nenhum item encontrado",columns:n,gap:i="md",className:o}){return r?e(Vl,{cols:n?String(n):"auto-fit",gap:i,className:o,children:[...Array(6)].map((t,a)=>e(Xr,{className:"h-48 w-full"},a))}):0===t.length?e("div",{className:"flex items-center justify-center p-8",children:e("div",{className:"text-center text-muted-foreground",children:e("p",{children:s})})}):e(Vl,{cols:n?String(n):"auto-fit",gap:i,className:o,children:t.map(a)})}function Mc(e){const t=vt();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const r=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(r)}}}function zc(e,t){const a=Mc({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}}Rc.displayName=Mt.Item.displayName;const $c=(e={})=>{const{alias:t}=Mn(),{enabled:a=!0}=e;return ht({queryKey:["qualiex-all-users",t],queryFn:async()=>t?un.getAllUsers(t):[],enabled:a&&!!t,staleTime:3e5,retry:2})},Uc=import.meta.env.VITE_SUPABASE_URL,Vc=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;let qc=null;const Bc=new class{async getUserPreferences(e,t){if(!Fs.areAllTokensValid())return null;const a=en();try{const{data:r,error:s}=await a.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",t).maybeSingle();if(s)return"PGRST116"===s.code?this.createDefaultPreferences(e,t):("42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied"),null);if(!r)return this.createDefaultPreferences(e,t);const n=r;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(r){return null}}async createDefaultPreferences(e,t){const a=en(),r={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:t};try{const{data:e,error:t}=await a.schema("common").from("user_preferences").insert(r).select().single();if(t)throw t;const s=e;return{locale:s.locale,timezone:s.timezone,datetimeFormat:s.datetime_format}}catch(s){throw s}}async updatePreferences(e,t,a){const r=en();try{const{error:s}=await r.schema("common").from("user_preferences").update(a).eq("id_user",e).eq("alias",t);if(s)throw s}catch(s){throw s}}};var Wc=Object.defineProperty,Hc=(e,t,a)=>((e,t,a)=>t in e?Wc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Kc=new class{constructor(){Hc(this,"cache",{}),Hc(this,"cacheTimestamps",new Map),Hc(this,"CACHE_TTL",3e5),Hc(this,"loadingPromises",new Map)}isCacheValid(e){const t=this.cacheTimestamps.get(e);return!!t&&Date.now()-t<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const t=this.loadingPromises.get(e);if(t)return t;const a=this.fetchTranslations(e);this.loadingPromises.set(e,a);try{return await a}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const t=(!qc&&Uc&&Vc&&(qc=ut(Uc,Vc,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),qc),{data:a,error:r}=await t.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(r)return"42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied")||r.message?.includes("No suitable key"),{};const s={};return a?.forEach(t=>{let a;a="pt-BR"===e?t.pt:"en-US"===e?t.en||t.pt:"es-ES"===e&&t.es||t.pt,a&&(s[t.key]=a)}),this.cache[e]=s,this.cacheTimestamps.set(e,Date.now()),s}catch(t){return{}}}async upsertTranslation(e,t,a,r){const s=en(),{error:n}=await s.schema("common").from("translations").upsert({key:e,pt:t,en:a,es:r},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const t=en(),{error:a}=await t.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(a)throw a;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Qc=Object.defineProperty,Gc=(e,t,a)=>((e,t,a)=>t in e?Qc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Jc="true"===import.meta.env.VITE_I18N_DEBUG_MODE;Oa.use(new class{constructor(e=!1){Gc(this,"type","backend"),Gc(this,"isDebugMode"),Gc(this,"cache",new Map),Gc(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,t,a){if(this.cache.has(e))return void a(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{a(null,this.cache.get(e)||{})});const r=Kc.loadTranslations(e).then(t=>{if(this.isDebugMode){const a={};Object.keys(t).forEach(e=>{a[e]=`[${e} ✅]`}),this.cache.set(e,a)}else this.cache.set(e,t)}).catch(t=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,r),r.then(()=>{a(null,this.cache.get(e)||{})})}create(e,t,a,r){}}(Jc)).use(ds).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,t)=>Jc?`[${e} ❌]`:`[⚠️ ${e}]`});const Xc=n(void 0),Yc=({children:t})=>{const{user:a,alias:r}=Mn(),[s,n]=c({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[i,o]=c(!0);u(()=>{(async()=>{if(a?.id&&r)try{const e=await Bc.getUserPreferences(a.id,r);e&&(n({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await Oa.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{o(!1)}else o(!1)})()},[a?.id,r]);const l=d(async e=>{if(a?.id&&r)try{await Bc.updatePreferences(a.id,r,{locale:e}),n(t=>({...t,locale:e})),await Oa.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(t){throw t}},[a?.id,r]),m=d(async e=>{if(a?.id&&r)try{await Bc.updatePreferences(a.id,r,{timezone:e}),n(t=>({...t,timezone:e}))}catch(t){throw t}},[a?.id,r]),h=d(async e=>{if(a?.id&&r)try{await Bc.updatePreferences(a.id,r,{datetime_format:e}),n(t=>({...t,datetimeFormat:e}))}catch(t){throw t}},[a?.id,r]);return e(Xc.Provider,{value:{...s,setLocale:l,setTimezone:m,setDatetimeFormat:h,isLoading:i},children:t})},Zc=()=>{const e=i(Xc);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},eu=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],tu=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],au=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/New_York",label:"New York (UTC-5/-4)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6/-5)",offset:"-06:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8/-7)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0/+1)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1/+2)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1/+2)",offset:"+01:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10/+11)",offset:"+10:00"}],ru=()=>{const{locale:a,datetimeFormat:r,timezone:s,setLocale:n,setDatetimeFormat:i,setTimezone:o}=Zc(),{t:l}=Ns();return t("div",{className:"space-y-4 p-4",children:[t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(He,{className:"h-4 w-4"}),l("language")]}),t(Nr,{value:a,onValueChange:n,children:[e(Sr,{children:e(kr,{})}),e(Er,{children:eu.map(e=>t(Ir,{value:e.value,children:[e.flag," ",e.label]},e.value))})]})]}),t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(ye,{className:"h-4 w-4"}),l("timezone")||"Fuso Horário"]}),t(Nr,{value:s,onValueChange:o,children:[e(Sr,{children:e(kr,{})}),e(Er,{children:au.map(t=>e(Ir,{value:t.value,children:t.label},t.value))})]})]}),t("div",{children:[t("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e(Re,{className:"h-4 w-4"}),l("dateTimeFormat")||"Formato de Data/Hora"]}),t(Nr,{value:r,onValueChange:i,children:[e(Sr,{children:e(kr,{})}),e(Er,{children:tu.map(a=>e(Ir,{value:a.value,children:t("div",{className:"flex flex-col items-start",children:[e("span",{children:a.label}),t("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},su=s.memo(({variant:r="card",className:n="",selectedUnit:i,onUnitChange:o})=>{const{user:l,companies:d,alias:u,isAuthenticated:m,logout:h,switchUnit:p}=Mn(),[f,g]=c(!1),b="true"===import.meta.env.VITE_SHOW_USER_PREFERENCES,v=d?.[0]||null,y=u?d?.find(e=>e.alias===u):v,x=d||[],N=i||y||v||v,w=s.useCallback(e=>{o?o(e):p(e)},[o,p]),k=s.useMemo(()=>{if(!x?.length)return[];const e=new Map;x.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===N?.alias),r=t.filter(e=>e.alias!==N?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...r]:r},[x,N?.alias]);if(!m||!l)return null;const S=()=>t(a,{children:[t("div",{className:"flex items-center space-x-3",children:[e("div",{className:"flex-shrink-0",children:e("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e(je,{className:"h-5 w-5 text-primary-foreground"})})}),t("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:l.name}),t("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",N?.name||"N/A"]})]})]}),N&&e("div",{className:"mt-3",children:t("div",{className:"flex items-center space-x-2",children:[e(Ke,{className:"h-4 w-4 text-muted-foreground"}),e("span",{className:"text-sm font-medium",children:N.name})]})}),k.length>1&&t("div",{className:"mt-2",children:[t("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",k.length]}),t("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,3).map(t=>e(Lr,{variant:t.alias===N?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>w(t),children:t.name},t.alias)),k.length>3&&t(Lr,{variant:"outline",className:"text-xs",children:["+",k.length-3]})]})]})]});return"dropdown"===r?t(pi,{children:[e(fi,{asChild:!0,children:e(Va,{variant:"ghost",className:`h-auto p-2 ${n}`,children:t("div",{className:"flex items-center space-x-2",children:[t("div",{className:"hidden md:block text-left",children:[e("p",{className:"text-sm font-medium",children:l.name}),e("p",{className:"text-xs text-muted-foreground",children:N?.name||"N/A"})]}),e("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e(je,{className:"h-4 w-4 text-primary-foreground"})}),e(_,{className:"h-4 w-4"})]})})}),t(wi,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[t(vi,{children:[t(xi,{children:[e(Ve,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e(Ni,{children:k.map(a=>t(ki,{onClick:()=>w(a),className:a.alias===N?.alias?"bg-muted":"",children:[e(Ke,{className:"mr-2 h-4 w-4"}),a.name,a.alias===N?.alias&&e(Lr,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),b&&e(Ei,{}),b&&t(ki,{onClick:()=>g(!0),children:[e(Fe,{className:"mr-2 h-4 w-4"}),"Preferências"]}),t(ki,{onClick:h,children:[e(Qe,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),b&&e(er,{open:f,onOpenChange:g,children:t(nr,{children:[e(ir,{children:e(dr,{children:"Preferências de Internacionalização"})}),e(ru,{})]})})]}):t(Ka,{className:n,children:[e(Qa,{children:e(Ga,{className:"text-lg",children:"Informações do Usuário"})}),t(Xa,{className:"space-y-4",children:[e(S,{}),e(Za,{}),b&&t(Va,{variant:"outline",onClick:()=>g(!0),size:"sm",className:"w-full",children:[e(Fe,{className:"mr-2 h-4 w-4"}),"Preferências"]}),t(Va,{variant:"outline",onClick:h,size:"sm",className:"w-full",children:[e(Qe,{className:"mr-2 h-4 w-4"}),"Sair"]}),b&&e(er,{open:f,onOpenChange:g,children:t(nr,{children:[e(ir,{children:e(dr,{children:"Preferências de Internacionalização"})}),e(ru,{})]})})]})]})}),nu=n({});function iu({children:t,config:a}){const r=o(()=>({navigation:a?.navigation,appName:a?.appName}),[a?.navigation,a?.appName]);return e(nu.Provider,{value:r,children:t})}function ou(){return i(nu)}function lu(){const e=bt(),{navigation:t}=ou(),{t:a}=Ns();if(!t)return a("page");const r=t.find(t=>t.path===e.pathname);if(r)return r.label;const s=t.find(t=>e.pathname.startsWith(t.path+"/"));return s?.label||a("page")}function du(e,t){const[a,r]=c(e),s=l(),n=d(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return u(()=>(n(),s.current=setTimeout(()=>{r(e)},t),n),[e,t,n]),[a,n]}const cu=h(function({actions:a}){const r=bt(),s=lu(),{navigation:n,appName:i}=ou(),{metadata:o,headerActions:l}=Fo(),{t:d}=Ns(),{companies:m,alias:h,isSearchVisible:p,clearSearch:f,refreshData:g,switchUnit:b}=Mn(),v=h?m?.find(e=>e.alias===h)||m?.[0]||null:m?.[0]||null,[y,x]=gt(),[N,w]=c(()=>y.get("search")||""),[k,S]=du(N,pn.debounceDelay);u(()=>{if(!p)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),x(e)},[k,x,p]);const _=n?.find(e=>e.path===r.pathname)||n?.find(e=>r.pathname.startsWith(e.path+"/")),E=o.title||s,P=o.subtitle||_?.complementaryText||d("item_details");return e("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:t("div",{className:"flex items-center gap-4",children:[t("div",{className:"flex-shrink-0",children:[t("div",{className:"flex items-center gap-2 mb-1",children:[e("h1",{className:"text-lg font-semibold text-foreground truncate",children:E}),e(Lr,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||d("module")})]}),P&&e("p",{className:"text-sm text-muted-foreground truncate",children:P})]}),p&&t("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[t("div",{className:"relative flex-1",children:[e(D,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e(Ba,{placeholder:d("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e(Va,{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:()=>{S(),w("");const e=new URLSearchParams(y);e.delete("search"),e.delete("page"),x(e)},title:d("clear_search"),children:e(C,{size:14})})]}),e(Va,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0",title:d("refresh_data"),children:e(Ve,{size:14})})]}),t("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||a)&&e("div",{className:"flex items-center gap-2",children:l||a}),import.meta.env.VITE_WIKI_URL&&e(Va,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>La(import.meta.env.VITE_WIKI_URL,e),title:d("open_wiki"),children:"Wiki"}),e("div",{className:"text-sm",children:e(su,{variant:"dropdown",selectedUnit:v,onUnitChange:b})})]})]})})}),uu=({key:e,enabled:t,checkFn:a,staleTime:r=3e5,gcTime:s=6e5})=>ht({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1}),mu=(e={})=>{const{enabled:t=!0}=e,{alias:a}=Mn();return ht({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=en(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(r){if(!nn.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!a})},hu="forlogic-sidebar-pinned",pu=()=>{try{const e=localStorage.getItem(hu);return!!e&&JSON.parse(e)}catch{return!1}},fu=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]},gu=`https://${import.meta.env.VITE_SUPABASE_PROJECT_ID_STORAGE??import.meta.env.VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,bu={logo:`${gu}/${yn.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${gu}/${yn.isQualiex?"small-forlogic.svg":"small.svg"}`},vu=bu.logo,yu=bu.smallLogo;function xu({appName:r,isPinned:s,onPinToggle:n,open:i,dropdownOpen:o,onDropdownChange:l}){const{t:d}=Ns(),{data:c,isLoading:u,error:m}=mu({enabled:o}),h=e=>{((e,t)=>{const a=e?.find(e=>e.url===t);a?.url&&window.open(a.url,"_blank")})(c,e)};return t(Qd,{className:"p-0 gap-0",children:[e("div",{className:"flex items-center justify-between h-[34px]",children:i?t(a,{children:[e("div",{className:"flex items-center pl-[12px]",children:e("img",{src:bu.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(s?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e(Be,{className:"h-4 w-4"})})]}):e("div",{className:"flex items-center justify-center w-full h-[34px]",children:e("img",{src:bu.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e("div",{className:"mt-2 pt-0",children:t(pi,{onOpenChange:l,children:[e(fi,{asChild:!0,children:i?t("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[t("div",{className:"flex items-center gap-2 min-w-0",children:[e("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:r})]}),e(_,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e(_,{className:"h-6 w-6 text-muted-foreground"})})}),e(wi,{className:i?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:i?"start":"center",children:u?t("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e(I,{className:"h-4 w-4 animate-spin"}),e("span",{className:"text-sm",children:d("loading")})]}):m?t("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e(F,{className:"h-4 w-4"}),e("span",{className:"text-sm",children:d("error")})]}):c&&0!==c.length?e("div",{className:"space-y-2",children:c.map((a,r)=>e("div",{onClick:()=>h(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${fu(r)} transition-colors duration-200\n `,children:t("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-medium text-foreground text-sm",children:a.name}),a.url&&e(We,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:d("no_results")})})]})})]})}function Nu({direction:e="right",minWidth:t=224,maxWidth:a=384,defaultWidth:r=240,storageKey:s="sidebar-width",onResize:n,isOpen:i=!0}={}){const[o,m]=c(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(s);return e?parseInt(e):r}),[h,p]=c(!1),f=l(null);u(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${o}px`):e.style.setProperty("--sidebar-width","240px"))},[o,i]);const g=d(e=>{e.preventDefault(),p(!0)},[]);return u(()=>{if(!h)return;const r=r=>{let s;s="left"===e?window.innerWidth-r.clientX:r.clientX,s=Math.max(t,Math.min(a,s)),m(s),n?.(s)},i=()=>{p(!1),localStorage.setItem(s,o.toString())};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)}},[h,e,t,a,o,s,n]),u(()=>{h?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[h,e]),{width:o,isDragging:h,dragRef:f,handleMouseDown:g}}const wu=s.forwardRef(({className:t,onMouseDown:a,isDragging:r,...s},n)=>e("div",{ref:n,onMouseDown:a,className:Fa("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",r&&"bg-primary/40",t),...s}));function ku({config:a,customContent:r,resizable:s=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=Ns(),{open:d,setOpen:m}=Ud(),h=bt(),{alias:p,user:f}=Mn(),[g,b]=c(!1),[v,y]=c(pu),[x,N]=c(!1),w=l(!1),k=s?Nu({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:d}):null;u(()=>{m(!!v||!(!x&&!g))},[v,x,g,m]);return t(qd,{collapsible:"icon",onMouseEnter:()=>{v||w.current||N(!0)},onMouseLeave:()=>{v||N(!1)},className:"app-sidebar bg-white border-r border-gray-200 py-6 px-3",style:k&&d?{width:`${k.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e(xu,{appName:a?.appName||o("module_title"),isPinned:v,onPinToggle:()=>{const e=!v;y(e),(e=>{try{localStorage.setItem(hu,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),m(!1),setTimeout(()=>{w.current=!1},300))},open:d,dropdownOpen:g,onDropdownChange:b}),e(Xd,{children:r||e(Yd,{className:"p-0 mt-6",children:e(tc,{children:e(ac,{className:"space-y-2",children:e(Fd,{children:a?.navigation?.map((a,r)=>{const s=({item:a,index:r})=>{const n=`${a.path}-${r}-${p??"noalias"}-${f?.id??"nouser"}`,{data:i=!0,isLoading:l}=uu({key:n,enabled:Boolean(a.permissionCheck&&p&&f?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),d=a.permissionCheck&&!i;if(d&&"Admin"===a.label)return null;const c=l?I:d?ie:a.icon;d?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e(Sl,{defaultOpen:!0,className:"group/collapsible",children:t(rc,{children:[e(Cl,{asChild:!0,children:e(nc,{size:"lg",className:"h-10",children:t("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label}),e(z,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e(_l,{children:e(dc,{children:a.children.map((t,a)=>e(s,{item:t,index:a},t.path))})})]})},a.path):e(rc,{children:d||l?t(jd,{children:[e(Dd,{asChild:!0,children:e(nc,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:t("div",{className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-4 w-4 "+(l?"animate-spin":"")})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})}),e(Md,{children:e("p",{children:o(l?"checking_access":"restricted_access")})})]}):e(nc,{asChild:!0,isActive:(u=a.path,h.pathname===u||h.pathname.startsWith(u+"/")),size:"lg",className:"h-10",children:t(yt,{to:a.path,className:"flex w-full items-center gap-3",children:[e("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e(c,{className:"h-5 w-4"})}),e("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})},a.path);var u};return e(s,{item:a,index:r},a.path)})})})})})}),s&&k&&d&&e(wu,{ref:k.dragRef,onMouseDown:k.handleMouseDown,isDragging:k.isDragging})]})}wu.displayName="ResizableRail";const Su=h(function({children:a,sidebar:r,sidebarConfig:s,showHeader:n=!0}){const i=o(()=>r||e(ku,{config:s}),[r,s]),l=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e(iu,{config:s,children:e(Lo,{children:e(Vd,{defaultOpen:!1,style:l,children:t("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,t("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e(cu,{})}),e("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:a})]})]})})})})});var Cu=Object.defineProperty,_u=(e,t,a)=>((e,t,a)=>t in e?Cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class Eu extends p{constructor(e){super(e),_u(this,"copyErrorDetails",()=>{const e=Ks.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),qs({title:"Detalhes copiados!",description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if(import.meta.env.DEV)throw e;Ks.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Ks.getErrors().slice(0,2);return e("div",{className:"flex items-center justify-center min-h-screen p-4",children:t(Ka,{className:"w-full max-w-2xl",children:[t(Qa,{className:"text-center",children:[e("div",{className:"flex justify-center mb-4",children:e(j,{className:"h-12 w-12 text-destructive"})}),e(Ga,{children:"Algo deu errado"})]}),t(Xa,{className:"space-y-4",children:[e("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),t(Sl,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e(Cl,{asChild:!0,children:t(Va,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e(_,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),t(_l,{className:"mt-4 space-y-4",children:[t("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[t("div",{children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),t("div",{className:"text-sm space-y-2",children:[e("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e(Xi,{className:"h-32 w-full rounded border bg-muted p-2",children:e("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&t("div",{className:"pt-3 border-t",children:[e("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e("div",{className:"space-y-2",children:a.map((a,r)=>e("div",{className:"text-sm p-2 rounded bg-muted/50",children:t("div",{className:"flex items-start gap-2",children:[t("span",{className:"font-medium text-muted-foreground shrink-0",children:[r+1,"."]}),t("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 flex-wrap",children:t("span",{className:"text-xs text-muted-foreground",children:["[",new Date(a.timestamp).toLocaleTimeString(),"]"]})}),e("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),t(Va,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e(me,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e(Va,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}function Pu({children:r}){const{ready:s}=Ns(),[n,i]=c(!0);return u(()=>{s&&n&&i(!1)},[s,n]),n&&!s?e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:t("div",{className:"flex flex-col items-center gap-4",children:[e(jr,{size:"lg"}),e("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e(a,{children:r})}const Iu={"pt-BR":wl,"en-US":dl,"es-ES":gl},Tu=(e,t="pt-BR")=>{if(!e)return"";const a=y(e);if(!x(a))return"Invalid date";return N(a,"PP",{locale:Iu[t]||wl})},Au=()=>{const{locale:e,timezone:t,datetimeFormat:a}=Zc();return{formatDatetime:e=>((e,t="dd/MM/yyyy HH:mm")=>{if(!e)return"";const a=y(e);return x(a)?N(a,t):"Invalid date"})(e,a,t),formatDate:t=>Tu(t,e),locale:e,timezone:t,datetimeFormat:a}};class Ru{static async sendEmail(e){const t=en(),{data:a,error:r}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(r)throw r;return a}}const Ou=Ru;function Lu(){const[e,t]=c([]),[a,r]=c(!1),[s,n]=c(null),[i,o]=c(null);u(()=>{l()},[]);const l=async()=>{try{const e=en(),{data:a,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;n(a.threadId),t([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){o("Erro ao inicializar conversa"),w.error("Erro ao inicializar conversa")}};return{messages:e,isLoading:a,error:i,sendMessage:d(async e=>{if(!s||!e.trim())return;const a={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,a]),r(!0),o(null);try{const a=en(),{data:r,error:n}=await a.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:s,message:e}});if(n)throw n;const{runId:i}=r,o=await(async e=>{if(!s)return!1;for(let a=0;a<60;a++)try{const t=en(),{data:a,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:s,runId:e}});if(r)throw r;const{status:n}=a;if("completed"===n)return!0;if("failed"===n||"cancelled"===n)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(i);o&&await(async()=>{if(s)try{const e=en(),{data:a,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:s}});if(r)throw r;const n=a.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));t(n)}catch(e){throw e}})()}catch(n){const e=n instanceof Error?n.message:"Erro ao enviar mensagem";o(e),w.error(e),t(e=>e.filter(e=>e.id!==a.id))}finally{r(!1)}},[s]),threadId:s}}function Fu({content:t,className:a}){return e("div",{className:Fa("prose prose-sm max-w-none",a),children:e(zt,{remarkPlugins:[$t],components:{h1:({children:t})=>e("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:t}),h2:({children:t})=>e("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:t}),h3:({children:t})=>e("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:t}),p:({children:t})=>e("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:t}),ul:({children:t})=>e("ul",{className:"list-disc list-inside mb-2 space-y-1",children:t}),ol:({children:t})=>e("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:t}),li:({children:t})=>e("li",{className:"text-sm text-foreground",children:t}),code:({inline:t,children:a,...r})=>e("code",t?{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...r,children:a}:{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...r,children:a}),pre:({children:t})=>e("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:t}),a:({children:t,href:a})=>e("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:t}),blockquote:({children:t})=>e("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:t}),strong:({children:t})=>e("strong",{className:"font-bold text-foreground",children:t}),em:({children:t})=>e("em",{className:"italic text-foreground",children:t})},children:t})})}function ju(){const{t:r}=Ns(),[s,n]=c(!1),[i,o]=c(""),{messages:d,isLoading:m,error:h,sendMessage:p}=Lu(),f=l(null),g=l(null);u(()=>{if(f.current){const e=f.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[d]),u(()=>{s&&g.current&&g.current.focus()},[s]),u(()=>{const e=e=>{"Escape"===e.key&&s&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]);const b=()=>{i.trim()&&!m&&(p(i),o(""))};return t(a,{children:[e(Va,{onClick:()=>n(!s),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e(s?C:Ge,{className:"h-6 w-6"})}),s&&t(Ka,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[t(Qa,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e(Ga,{className:"text-lg font-semibold",children:r("title")}),e(Va,{variant:"ghost",size:"icon",onClick:()=>n(!1),className:"h-8 w-8",children:e(C,{className:"h-4 w-4"})})]}),t(Xa,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[e(Xi,{ref:f,className:"flex-1 px-4",children:t("div",{className:"space-y-4 py-4",children:[d.map(t=>e("div",{className:"flex "+("user"===t.role?"justify-end":"justify-start"),children:e("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===t.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===t.role?e(Fu,{content:t.content}):e("p",{className:"text-sm whitespace-pre-wrap",children:t.content})})},t.id)),m&&e("div",{className:"flex justify-start",children:e("div",{className:"bg-muted rounded-lg px-4 py-2",children:t("div",{className:"flex space-x-2",children:[e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),e("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),h&&e("div",{className:"text-center text-sm text-destructive py-2",children:h})]})}),e("div",{className:"border-t p-4",children:t("div",{className:"flex space-x-2",children:[e(Ba,{ref:g,value:i,onChange:e=>o(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:r("placeholder"),disabled:m,className:"flex-1"}),e(Va,{onClick:b,disabled:m||!i.trim(),size:"icon",children:e(Je,{className:"h-4 w-4"})})]})})]})]})]})}function Du({open:a,onOpenChange:r,placeId:s,placeName:n,onMakeManager:i,onMakeMembers:l,currentManagerId:d,currentMemberIds:u=[]}){const{t:m}=Ns(),[h,p]=c([]),[f,g]=c(!1),[b,v]=c(""),{data:y=[],isLoading:x}=ao({enabled:a}),N=o(()=>{let e=[...y];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",r=t.userName?.toLowerCase()||"";return a.localeCompare(r)}),b){const t=b.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[y,b]),w=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},k=1===h.length,S=h.length>0;return e(er,{open:a,onOpenChange:r,children:t(nr,{className:"max-w-2xl",children:[e(ir,{children:t(dr,{className:"flex items-center gap-2",children:[e(Xe,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),t("div",{className:"relative",children:[e(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(Ba,{placeholder:m("search_placeholder"),value:b,onChange:e=>v(e.target.value),className:"pl-9"})]}),e(Xi,{className:"h-[400px] pr-4",children:x?e("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e(Xr,{className:"h-16 w-full"},a))}):0===N.length?t("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e(Xe,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e("p",{className:"text-sm text-muted-foreground",children:b?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e("div",{className:"space-y-2",children:N.map(a=>{const r=a.userId===d,s=u.includes(a.userId||""),n=h.includes(a.userId||"");return t("div",{className:Fa("flex items-center gap-3 p-3 rounded-lg border transition-colors",n&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(a.userId||""),children:[e(Ar,{checked:n,onCheckedChange:()=>w(a.userId||""),onClick:e=>e.stopPropagation()}),t("div",{className:"flex-1",children:[t("div",{className:"flex items-center gap-2",children:[e("p",{className:"font-medium",children:a.userName}),r&&e(Ye,{className:"h-4 w-4 text-yellow-500"})]}),e("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(r||s)&&e("div",{className:"text-xs text-muted-foreground",children:r?"Gestor":"Membro"})]},a.userId)})})}),t(lr,{className:"flex gap-2 sm:gap-2",children:[e("div",{className:"flex-1 text-sm text-muted-foreground",children:h.length>0&&t("span",{children:[h.length," selecionado(s)"]})}),k&&i&&t(Va,{onClick:async()=>{if(i&&1===h.length){g(!0);try{await i(h[0],s),p([])}finally{g(!1)}}},disabled:f,variant:"outline",children:[e(Ye,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),S&&l&&t(Va,{onClick:async()=>{if(l&&0!==h.length){g(!0);try{await l(h,s),p([])}finally{g(!1)}}},disabled:f,children:[e(Ze,{className:"h-4 w-4 mr-2"}),"Tornar ",h.length>1?"Membros":"Membro"]})]})]})})}function Mu({place:a,level:r=0,manageAccessConfig:s}){const[n,i]=c(!1),[o,l]=c(!1),d=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return t("div",{children:[t(Sl,{open:n,onOpenChange:i,children:[t("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*r+1+"rem"},children:[d?t(Cl,{className:"flex items-center gap-2 flex-1",children:[e(z,{className:Fa("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e(Ke,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:a.name}),t("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):t("div",{className:"flex items-center gap-2 flex-1",children:[e("div",{className:"w-4 shrink-0"}),e(Ke,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e("span",{className:"font-medium",children:a.name})]}),t("div",{className:"flex items-center gap-3 ml-auto",children:[t("div",{className:"flex items-center gap-1.5",children:[e(Xe,{className:"h-3.5 w-3.5 text-muted-foreground"}),e("span",{className:"text-sm text-muted-foreground",children:m})]}),e(Lr,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),s&&e(Fc,{customActions:[{label:"Gerenciar Acessos",icon:Fe,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),d&&e(_l,{children:a.subPlaces.map(t=>e(Mu,{place:t,level:r+1,manageAccessConfig:s},t.id))})]}),0===r&&e(Za,{}),s&&e(Du,{open:o,onOpenChange:l,placeId:a.id,placeName:a.name,onMakeManager:s.onMakeManager,onMakeMembers:s.onMakeMembers,currentManagerId:s.getCurrentManagerId?.(a.id),currentMemberIds:s.getCurrentMemberIds?.(a.id)})]})}function zu({places:a,isLoading:r,manageAccessConfig:s}){const{t:n}=Ns();return r?e("div",{className:"flex items-center justify-center py-12",children:t("div",{className:"text-center space-y-2",children:[e("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e("p",{className:"text-sm text-muted-foreground",children:n("loading_data")})]})}):a&&0!==a.length?t("div",{className:"space-y-1",children:[e("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(t=>e(Mu,{place:t,manageAccessConfig:s},t.id))]}):t("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e(Ke,{className:"h-12 w-12 text-muted-foreground/50"}),t("div",{children:[e("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var $u=Object.defineProperty,Uu=(e,t,a)=>((e,t,a)=>t in e?$u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const Vu=new class{constructor(){Uu(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=ln.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=Fs.getAccessToken();if(!s)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=t.get(e.id);if(e.parentId){const s=t.get(e.parentId);s?(s.subPlaces=s.subPlaces||[],s.subPlaces.push(r)):a.push(r)}else a.push(r)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=a.data||a||[];return this.buildHierarchy(r)}catch(a){if(await ln.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=a.data||a||[];return this.buildHierarchy(r)}catch(r){return Ks.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return Ks.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function qu(e,t){const a=e.map(e=>({...e})),r=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&r.has(e.id_leader)){let t=e.id_leader;for(;t&&r.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))}function Bu(e){const t=new Map,a=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};t.set(e.id,r),a.set(e.id_user,r)}),e.forEach(e=>{const s=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(s)}r.push(s)});const s=(e,t)=>{e.level=t,e.children.forEach(e=>s(e,t+1))};r.forEach(e=>s(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",r=t.name||t.id_user||t.email||"";return a.localeCompare(r)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(r),r}function Wu(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Hu(){const{alias:e,isAuthenticated:t}=Mn(),a=Fs.getAccessToken(),{data:r=[]}=ao({enabled:!0});return ht({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=en(),{data:s,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!s||0===s.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=s.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:s.filter(t=>t.id_leader===e.id_user).length})),l=new Set(s.map(e=>e.id_user));return new Set(s.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=i[e];o.push({id:`virtual-${e}`,alias:s[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:s.filter(t=>t.id_leader===e).length})}),Bu(o)},enabled:!!a&&!!e&&t&&r.length>0})}function Ku(){const e="common",{alias:t}=Mn(),a=mt(),r=en();return pt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",a.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");a.id_leader&&await Zu(r,t,e,a.id_user,a.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder adicionado com sucesso")},onError:e=>{w.error(e.message||"Erro ao adicionar líder")}})}function Qu(){const e="common",{alias:t}=Mn(),a=mt(),r=en();return pt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Zu(r,t,e,a.id_user,a.id_leader);const{data:s,error:n}=await r.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder virtual promovido com sucesso")},onError:e=>{w.error(e.message||"Erro ao criar líder")}})}function Gu(){const e="common",{alias:t}=Mn(),a=mt(),r=en();return pt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(!a.users.length)throw new Error("Selecione pelo menos um liderado");const s=a.users.map(e=>e.id_user),{data:n}=await r.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",s).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Zu(r,t,e,d.id_user,a.id_leader)}const i=a.users.map(e=>({alias:t,id_user:e.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{w.error(e.message||"Erro ao adicionar liderados")}})}function Ju(){const e="common",{alias:t}=Mn(),a=mt(),r=en();return pt({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");const{data:s}=await r.schema(e).from("leaders").select("id_user").eq("id",a.id).eq("alias",t).single();if(!s)throw new Error("Líder não encontrado");if(s.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Zu(r,t,e,s.id_user,a.id_leader,a.id);const{data:n,error:i}=await r.schema(e).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",t).select().single();if(i)throw i;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success("Líder atualizado com sucesso")},onError:e=>{w.error(e.message||"Erro ao atualizar líder")}})}function Xu(){const{alias:e}=Mn(),t=mt(),a=en();return pt({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await a.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),w.success("Líder removido com sucesso")},onError:e=>{w.error(e.message||"Erro ao remover líder")}})}function Yu(){const e="common",{alias:t}=Mn(),a=mt(),r=en();return pt({mutationFn:async({leaderUserId:a,selectedUsers:s})=>{if(!t)throw new Error("Unidade não selecionada");const n=s.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",a),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:o,error:l},{data:d,error:c}]=i;if(l)throw l;if(c)throw c;const u=o||[],m=d||[],h=new Set(n),p=u.filter(e=>!h.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),g=new Set(m.map(e=>e.id_user)),b=s.filter(e=>!g.has(e.id_user));for(const x of f)await Zu(r,t,e,x.id_user,a,x.id);for(const x of b){if(x.id_user===a)throw new Error("Usuário não pode ser seu próprio líder");await Zu(r,t,e,x.id_user,a)}const v=[];if(p.length){const a=p.map(e=>e.id);v.push(r.schema(e).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",t))}if(f.length){const s=f.map(e=>e.id);v.push(r.schema(e).from("leaders").update({id_leader:a}).in("id",s).eq("alias",t))}if(b.length){const s=b.map(e=>({alias:t,id_user:e.id_user,id_leader:a,is_active:!0,is_removed:!1}));v.push(r.schema(e).from("leaders").insert(s))}const y=(await Promise.all(v)).find(e=>e?.error);if(y?.error)throw y.error;return{unlinked:p.length,updated:f.length,created:b.length}},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),w.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{w.error(e.message||"Erro ao sincronizar subordinados")}})}async function Zu(e,t,a,r,s,n){const{data:i,error:o}=await e.schema(a).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=s;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===r)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function em({leader:r,expandedIds:s,onToggleExpand:n,onEdit:i}){const o=s.has(r.id),l=r.children.length>0,d=32*r.level;return t(a,{children:[t("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e("td",{className:"py-3 px-4",children:t("div",{className:"flex items-center gap-2",style:{paddingLeft:`${d}px`},children:[l?e("button",{onClick:()=>n(r.id),className:"p-1 hover:bg-accent rounded",children:e(o?_:z,{className:"h-4 w-4"})}):e("div",{className:"w-6"}),e(je,{className:"h-4 w-4 text-muted-foreground"}),e("button",{onClick:()=>{i(r)},className:"font-medium hover:text-primary hover:underline text-left",children:r.name||r.id_user||r.email})]})}),e("td",{className:"py-3 px-4 text-center",children:e("span",{className:"text-sm",children:r.subordinatesCount||0})})]}),l&&o&&r.children.map(t=>e(em,{leader:t,expandedIds:s,onToggleExpand:n,onEdit:i},t.id))]})}var tm=function(e,t){for(var a={};e.length;){var r=e[0],s=r.code,n=r.message,i=r.path.join(".");if(!a[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];a[i]={message:o.message,type:o.code}}else a[i]={message:n,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[i].types,d=l&&l[r.code];a[i]=it(i,t,a,s,d?[].concat(d,r.message):r.message)}e.shift()}return a},am=function(e,t,a){return void 0===a&&(a={}),function(r,s,n){try{return Promise.resolve(function(s,i){try{var o=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](r,t)).then(function(e){return n.shouldUseNativeValidation&&Vt({},n),{errors:{},values:a.raw?r:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:qt(tm(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const rm=Ut.object({id_leader:Ut.string().nullable(),id_users:Ut.array(Ut.string()).min(1,"Selecione pelo menos um liderado")}),sm=Ut.object({id_leader:Ut.string().nullable(),id_users:Ut.array(Ut.string())});function nm({value:a,onChange:r,excludeUserIds:s=[],error:n}){const{data:i=[],isLoading:o}=ao(),[d,m]=c(""),h=l(null),p=l(0),{t:f}=Ns(),g=i.filter(e=>!s.includes(e.userId||"")).filter(e=>{const t=d.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const r=a.includes(e.userId),s=a.includes(t.userId);if(r&&!s)return-1;if(!r&&s)return 1;const n=e.userName||e.userEmail||"",i=t.userName||t.userEmail||"";return n.localeCompare(i)});return u(()=>{h.current&&p.current>0&&(h.current.scrollTop=p.current)},[g]),t("div",o?{className:"flex items-center justify-center p-4",children:[e(I,{className:"h-6 w-6 animate-spin"}),e("span",{className:"ml-2",children:f("loading_data")})]}:{className:"space-y-2",children:[e(Ba,{placeholder:f("search_user"),value:d,onChange:e=>m(e.target.value)}),e("div",{ref:h,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===g.length?e("p",{className:"text-sm text-muted-foreground",children:f("search_user")}):e("div",{className:"space-y-2",children:g.map(s=>t("div",{className:"flex items-center space-x-2",children:[e(Ar,{id:s.userId,checked:a.includes(s.userId),onCheckedChange:()=>{return e=s.userId,h.current&&(p.current=h.current.scrollTop),void(a.includes(e)?r(a.filter(t=>t!==e)):r([...a,e]));var e}}),e(Ha,{htmlFor:s.userId,className:"flex-1 cursor-pointer",children:s.userName||s.userEmail})]},s.userId))})}),a.length>0&&e("p",{className:"text-sm text-muted-foreground",children:f("selected_count",{count:a.length})}),n&&e("p",{className:"text-sm text-destructive",children:n})]})}function im({leader:r,prefilledLeaderId:s,onSuccess:n}){const{t:i}=Ns(),{alias:o}=Mn(),l=!!r,d=r?.id.startsWith("virtual-"),m=Gu(),h=Qu(),p=Ju(),f=Yu(),g=Xu(),{data:b=[]}=Hu(),{data:v=[]}=ao(),[y,x]=c(""),N=Wu(b).map(e=>e.id_user),w=l?Wu(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user):[],k=ot({resolver:am(l?sm:rm),defaultValues:{id_leader:s||(l?r?.id_leader:null)||null,id_users:l?w:[]}});u(()=>{if(r){const e=Wu(b).filter(e=>e.id_leader===r.id_user).map(e=>e.id_user);k.reset({id_leader:r.id_leader||null,id_users:e})}else s?k.reset({id_leader:s,id_users:[]}):k.reset({id_leader:null,id_users:[]})},[o,r?.id,r?.id_user,r?.id_leader,s,b]);const S=m.isPending||h.isPending||p.isPending||f.isPending||g.isPending,C=k.watch("id_leader"),_=k.watch("id_users"),E=l?[r.id_user,...N.filter(e=>e!==r.id_user&&!_.includes(e)&&!w.includes(e))]:[C,...N.filter(e=>!_.includes(e))].filter(Boolean);return t("form",{onSubmit:k.handleSubmit(async e=>{try{if(l)if(d){await h.mutateAsync({id_user:r.id_user,id_leader:e.id_leader});const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:t})}else{await p.mutateAsync({id:r.id,id_leader:e.id_leader});const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await f.mutateAsync({leaderUserId:r.id_user,selectedUsers:t})}else{const t=v.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({id_leader:e.id_leader,users:t})}n?.()}catch(t){}}),className:"space-y-4",children:[l&&t("div",{children:[e(Ha,{children:i("leader")}),e(Ba,{value:v.find(e=>e.userId===r.id_user)?.userName||r.name||r.id_user,disabled:!0,className:"bg-muted"})]}),t("div",{children:[e(Ha,{children:i("superior")}),t(Nr,{value:C||"none",onValueChange:e=>k.setValue("id_leader","none"===e?null:e),children:[e(Sr,{children:e(kr,{placeholder:i("select_placeholder")})}),t(Er,{children:[e("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e(Ba,{placeholder:i("superior_search"),value:y,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),t(Xi,{className:"h-[200px]",children:[e(Ir,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const t=l?e.userId!==r.id_user:!_.includes(e.userId),a=!y||e.userName?.toLowerCase().includes(y.toLowerCase());return t&&a}).sort((e,t)=>{const a=e.userName||e.userEmail||"",r=t.userName||t.userEmail||"";return a.localeCompare(r)}).map(t=>e(Ir,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${o}`),k.formState.errors.id_leader&&e("p",{className:"text-sm text-destructive mt-1",children:k.formState.errors.id_leader.message})]}),t("div",{children:[t(Ha,{children:[i("subordinates")," *"]}),e(nm,{value:_,onChange:e=>k.setValue("id_users",e),excludeUserIds:E,error:k.formState.errors.id_users?.message},`users-multiselect-${o}`)]}),t("div",{className:"flex items-center justify-between gap-2",children:[e(Va,{type:"submit",disabled:S||!l&&0===_.length,children:S&&!g.isPending?t(a,{children:[e(I,{className:"mr-2 h-4 w-4 animate-spin"}),i(l?"updating":"saving")]}):l?_.length>0?i("update_success",{count:_.length}):i("update"):i("create_success",{count:_.length})}),l&&!C&&0===_.length&&e(Va,{type:"button",variant:"destructive",disabled:S,onClick:async()=>{if(r&&window.confirm(i("remove_confirm")))try{await g.mutateAsync(r.id),n?.()}catch(e){}},className:"ml-auto",children:g.isPending?t(a,{children:[e(I,{className:"mr-2 h-4 w-4 animate-spin"}),i("removing")]}):t(a,{children:[e(B,{className:"mr-2 h-4 w-4"}),i("remove")]})})]})]})}function om({open:a,onOpenChange:r,leader:s,prefilledLeaderId:n,title:i}){return e(er,{open:a,onOpenChange:r,children:t(nr,{className:"sm:max-w-[500px]",children:[e(ir,{children:e(dr,{children:i})}),e(im,{leader:s,prefilledLeaderId:n,onSuccess:()=>r(!1)})]})})}const lm="leadership-expanded-nodes",dm=(e,t)=>{try{localStorage.setItem(`${lm}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function cm(){const{alias:a}=Mn(),{t:r}=Ns(),{data:s,isLoading:n,error:i,refetch:o}=Hu(),{data:l=[]}=ao({enabled:!0}),[d,m]=c(()=>a?(e=>{try{const t=localStorage.getItem(`${lm}-${e}`);if(t)return new Set(JSON.parse(t))}catch(i){}return new Set})(a):new Set),[h,p]=c(!1),[f,g]=c(),[b,v]=c(null),y=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),x=new Set(y.map(e=>e.userId)),N=y.length-(s?Wu(s).filter(e=>x.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);u(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${lm}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);m(t),dm(a,t)}}},[s,a]);const w=e=>{m(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),a&&dm(a,r),r})},k=e=>{g(e),v(null),p(!0)};return n?e("div",{className:"flex items-center justify-center h-full",children:t("div",{className:"text-center",children:[e(Ve,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e("p",{className:"text-muted-foreground",children:r("loading")})]})}):i?e("div",{className:"flex items-center justify-center h-full",children:t("div",{className:"text-center",children:[e("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e(Va,{onClick:()=>o(),children:"Tentar novamente"})]})}):t("div",{className:"flex flex-col h-full",children:[e("div",{className:"flex items-center justify-between p-4 border-b",children:t("div",{className:"flex gap-2 items-center",children:[t(Va,{size:"sm",onClick:()=>{g(void 0),v(null),p(!0)},children:[e(W,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),t(Va,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Wu(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);m(t),a&&dm(a,t)},disabled:!s||0===s.length,children:[e(_,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),t(Va,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;m(e),a&&dm(a,e)},disabled:!s||0===s.length,children:[e(z,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e("div",{className:"flex items-center gap-2 ml-4",children:t("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e(Xe,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-sm font-medium",children:[N," usuário",1!==N?"s":""," não associado",1!==N?"s":""]})]})})]})}),s&&0!==s.length?e(Xi,{className:"flex-1",children:e("div",{children:t("table",{className:"w-full",children:[e("thead",{children:t("tr",{className:"border-b bg-muted/50",children:[e("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e("tbody",{children:s.map(t=>e(em,{leader:t,expandedIds:d,onToggleExpand:w,onEdit:k},t.id))})]})})}):e("div",{className:"flex items-center justify-center flex-1",children:t("div",{className:"text-center space-y-4",children:[e("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e(om,{open:h,onOpenChange:()=>{p(!1),g(void 0),v(null)},leader:f,prefilledLeaderId:b,title:f?r("edit")+" "+r("name"):b?r("add")+" Liderado":r("add")+" Líder Raiz"},`leadership-dialog-${a}`)]})}function um(e){const[t,a]=c(!1),[r,s]=c(0),{t:n}=Ns(),{uploadFunction:i,deleteFunction:o,defaultOptions:l,onSuccess:d,onError:u}=e||{};return{upload:async(e,t)=>{if(!i){const e=new Error("uploadFunction não fornecida");throw qs({title:"Erro de configuração",description:"Função de upload não configurada. Verifique a documentação.",variant:"destructive"}),e}a(!0),s(0);try{const a={...l,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){if(!a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const r=await i(e,a);return s(100),qs({title:"Sucesso",description:n("file_upload_success")}),d?.(r),r}catch(r){const e=r instanceof Error?r:new Error("Erro ao fazer upload");throw qs({title:"Erro",description:e.message,variant:"destructive"}),u?.(e),e}finally{a(!1)}},deleteMedia:async(e,t)=>{if(!o){const e=new Error("deleteFunction não fornecida");throw qs({title:"Erro de configuração",description:"Função de delete não configurada.",variant:"destructive"}),e}try{await o(e,t),qs({title:"Sucesso",description:"Arquivo removido com sucesso"})}catch(a){throw qs({title:"Erro",description:"Erro ao remover o arquivo",variant:"destructive"}),a}},uploading:t,progress:r}}function mm(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function hm(e,t){const a=mm(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function pm(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function fm(e,t){const a=pm(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function gm(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function bm(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function vm(e,t,a){switch(t||bm(e)){case"youtube":return hm(e,a);case"vimeo":return fm(e,a);default:return e}}function ym({value:r,onChange:s,onSubmit:n,onCancel:i,uploadFunction:d,deleteFunction:u,uploadOptions:m}){const{t:h}=Ns(),[p,f]=c(r||{inputType:"url",controls:!0}),g=l(null),b=l(null),{upload:v,uploading:y}=um({uploadFunction:d,deleteFunction:u,defaultOptions:{...m,allowedTypes:["video/*"],maxSize:104857600}}),{upload:x,uploading:N}=um({uploadFunction:d,deleteFunction:u,defaultOptions:{...m,allowedTypes:["image/*"],maxSize:5242880}}),w=o(()=>bm(p.videoUrl||gm(p.embedCode)||""),[p.videoUrl,p.embedCode]),k=(e,t)=>{const a={...p,[e]:t};f(a),s(a)};return t("div",{className:"space-y-6",children:[t("div",{className:"space-y-2",children:[e(Ha,{children:h("input_type")}),t(Nr,{value:p.inputType||"url",onValueChange:e=>k("inputType",e),children:[e(Sr,{children:e(kr,{})}),t(Er,{children:[e(Ir,{value:"url",children:h("url")}),e(Ir,{value:"upload",children:h("input_type_upload")}),e(Ir,{value:"embed",children:h("input_type_embed")})]})]})]}),"upload"===p.inputType&&d&&t("div",{className:"space-y-2",children:[e(Ha,{children:h("file")}),t("div",{className:"flex gap-2",children:[e("input",{ref:g,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await v(t),a={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||t.name.replace(/\.[^/.]+$/,"")};f(a),s(a)}catch(a){}finally{g.current&&(g.current.value="")}},className:"hidden"}),e(Va,{type:"button",variant:"outline",onClick:()=>g.current?.click(),disabled:y,children:t(a,y?{children:[e(I,{className:"mr-2 h-4 w-4 animate-spin"}),h("uploading")]}:{children:[e(pe,{className:"mr-2 h-4 w-4"}),h("select_video")]})}),p.videoFile&&e("span",{className:"text-xs text-muted-foreground truncate self-center",children:h("video.fileInfo",{name:p.videoFile,size:Math.round((p.videoSize||0)/1024/1024)})})]})]}),"embed"===p.inputType&&t("div",{className:"space-y-2",children:[e(Ha,{children:h("embed")}),e(Rr,{placeholder:h("embed"),value:p.embedCode||"",onChange:e=>k("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),d&&t("div",{className:"space-y-2",children:[e(Ha,{children:h("thumbnail")}),t("div",{className:"flex gap-2",children:[e(Ba,{type:"url",placeholder:h("thumbnail"),value:p.thumbnail||"",onChange:e=>k("thumbnail",e.target.value),className:"flex-1"}),e("input",{ref:b,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await x(t),a={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};f(a),s(a)}catch(a){}finally{b.current&&(b.current.value="")}},className:"hidden"}),e(Va,{type:"button",variant:"outline",onClick:()=>b.current?.click(),disabled:N,children:t(a,N?{children:[e(I,{className:"mr-2 h-4 w-4 animate-spin"}),h("video.uploading")]}:{children:[e(pe,{className:"mr-2 h-4 w-4"}),h("upload")]})})]}),p.thumbnailFile&&e("p",{className:"text-xs text-muted-foreground",children:h("video.thumbnailFileInfo",{name:p.thumbnailFile})})]}),t("div",{className:"space-y-2",children:[e(Ha,{htmlFor:"title",children:h("title")}),e(Ba,{id:"title",placeholder:h("title"),value:p.title||"",onChange:e=>k("title",e.target.value)})]}),t("div",{className:"flex gap-6",children:[t("div",{className:"flex items-center gap-2",children:[e("input",{id:"autoplay",type:"checkbox",checked:p.autoplay||!1,onChange:e=>k("autoplay",e.target.checked),className:"h-4 w-4"}),e(Ha,{htmlFor:"autoplay",className:"cursor-pointer",children:h("video.autoplay")})]}),t("div",{className:"flex items-center gap-2",children:[e("input",{id:"controls",type:"checkbox",checked:!1!==p.controls,onChange:e=>k("controls",e.target.checked),className:"h-4 w-4"}),e(Ha,{htmlFor:"controls",className:"cursor-pointer",children:h("video.controls")})]})]}),t("div",{className:"space-y-2",children:[e(Ha,{children:h("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=p.videoUrl||gm(p.embedCode)||"";if(!a)return e("div",{className:"text-center py-8 text-muted-foreground",children:h("no_content_preview")});if("file"===w)return t("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e("source",{src:a}),h("unsupported")]});const r="youtube"===w?hm(a,p.autoplay):fm(a,p.autoplay);return e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:p.title||h("video"),src:r,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),t("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Va,{variant:"outline",onClick:i,children:h("cancel")}),e(Va,{onClick:()=>{p.videoUrl||p.embedCode?n(p):qs({title:h("error"),description:h("error_no_video"),variant:"destructive"})},disabled:!(p.videoUrl||p.embedCode),children:h("save")})]})]})}function xm({content:a,className:r="",style:s}){const n=a.videoUrl||gm(a.embedCode)||"";if(!n)return null;const i=bm(n),{t:o}=Ns();return e(Ka,{className:`overflow-hidden my-4 ${r}`,style:s,children:t(Xa,{className:"p-0",children:["file"===i?t("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[e("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):e("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e("iframe",{title:a.title||o("video"),src:"youtube"===i?hm(n,a.autoplay):fm(n,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e("div",{className:"p-4",children:e("p",{className:"text-sm font-medium",children:a.title})})]})})}function Nm({value:r,onChange:s,onSubmit:n,onCancel:i,uploadFunction:o,deleteFunction:d,uploadOptions:u}){const{t:m}=Ns(),[h,p]=c(r||{alignment:"center",allowDownload:!1}),f=l(null),{upload:g,uploading:b}=um({uploadFunction:o,deleteFunction:d,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),v=(e,t)=>{const a={...h,[e]:t};p(a),s(a)};return t("div",{className:"space-y-6",children:[t("div",{className:"space-y-2",children:[e(Ha,{children:m("url")}),t("div",{className:"flex gap-2",children:[e(Ba,{type:"url",placeholder:m("url_placeholder"),value:h.imageUrl||"",onChange:e=>v("imageUrl",e.target.value),className:"flex-1"}),o&&t(a,{children:[e("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...h,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(a),s(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e(Va,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:b,children:t(a,b?{children:[e(I,{className:"mr-2 h-4 w-4 animate-spin"}),m("uploading")]}:{children:[e(pe,{className:"mr-2 h-4 w-4"}),m("upload")]})})]})]}),h.imageFile&&e("p",{className:"text-xs text-muted-foreground",children:m("image.fileInfo",{name:h.imageFile,size:Math.round((h.imageSize||0)/1024)})})]}),h.imageUrl&&t("div",{className:"space-y-2",children:[e(Ha,{children:m("preview")}),e("div",{className:"border rounded-lg p-4 bg-muted/30",children:e("div",{className:"flex "+("left"===h.alignment?"justify-start":"right"===h.alignment?"justify-end":"justify-center"),children:e("img",{src:h.imageUrl,alt:h.alt||"Preview",style:{width:h.width?`${h.width}px`:"auto",height:h.height?`${h.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),t("div",{className:"space-y-2",children:[e(Ha,{htmlFor:"caption",children:m("caption")}),e(Rr,{id:"caption",placeholder:m("caption"),value:h.caption||"",onChange:e=>v("caption",e.target.value),rows:2})]}),t("div",{className:"space-y-2",children:[e(Ha,{htmlFor:"alt",children:m("alt")}),e(Ba,{id:"alt",placeholder:m("alt"),value:h.alt||"",onChange:e=>v("alt",e.target.value)})]}),t("div",{className:"space-y-2",children:[e(Ha,{children:m("alignment")}),t(Nr,{value:h.alignment||"center",onValueChange:e=>v("alignment",e),children:[e(Sr,{children:e(kr,{})}),t(Er,{children:[e(Ir,{value:"left",children:m("left")}),e(Ir,{value:"center",children:m("center")}),e(Ir,{value:"right",children:m("right")})]})]})]}),t("div",{className:"grid grid-cols-2 gap-4",children:[t("div",{className:"space-y-2",children:[e(Ha,{htmlFor:"width",children:m("width")}),e(Ba,{id:"width",type:"number",placeholder:"px",value:h.width||"",onChange:e=>v("width",e.target.value?Number(e.target.value):void 0)})]}),t("div",{className:"space-y-2",children:[e(Ha,{htmlFor:"height",children:m("height")}),e(Ba,{id:"height",type:"number",placeholder:"px",value:h.height||"",onChange:e=>v("height",e.target.value?Number(e.target.value):void 0)})]})]}),t("div",{className:"flex items-center gap-2",children:[e("input",{id:"allowDownload",type:"checkbox",checked:h.allowDownload||!1,onChange:e=>v("allowDownload",e.target.checked),className:"h-4 w-4"}),e(Ha,{htmlFor:"allowDownload",className:"cursor-pointer",children:m("allow_download")})]}),t("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(Va,{variant:"outline",onClick:i,children:m("cancel")}),e(Va,{onClick:()=>{h.imageUrl?n(h):qs({title:m("error"),description:m("error_no_image"),variant:"destructive"})},disabled:!h.imageUrl,children:m("save")})]})]})}function wm({content:a,className:r="",style:s}){if(!a.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e("div",{className:`flex ${n} my-4 ${r}`,style:s,children:t("div",{className:"space-y-2 max-w-full",children:[e("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&t("a",{href:a.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e(fe,{className:"h-4 w-4"}),"Baixar imagem"]})]})})}function km(e,t){return e/t}function Sm(e,t,a,r){const s=km(e,t);return a&&!r?{width:a,height:Math.round(a/s)}:r&&!a?{width:Math.round(r*s),height:r}:{width:e,height:t}}function Cm(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))}function _m(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}}function Em(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`}export{mn as AUTH_CONFIG,Mo as Accordion,Uo as AccordionContent,zo as AccordionItem,$o as AccordionTrigger,qa as ActionButton,Fc as ActionMenu,Ii as ActionMenuItems,Po as Alert,To as AlertDescription,Un as AlertDialog,Jn as AlertDialogAction,Xn as AlertDialogCancel,Wn as AlertDialogContent,Gn as AlertDialogDescription,Kn as AlertDialogFooter,Hn as AlertDialogHeader,Bn as AlertDialogOverlay,qn as AlertDialogPortal,Qn as AlertDialogTitle,Vn as AlertDialogTrigger,Io as AlertTitle,cu as AppHeader,Su as AppLayout,ku as AppSidebar,Vo as AspectRatio,nn as AuthErrorInterceptor,Dn as AuthProvider,Fn as AuthService,qo as Avatar,Wo as AvatarFallback,Bo as AvatarImage,Lr as Badge,so as BaseForm,ld as Blockquote,Ho as Breadcrumb,Yo as BreadcrumbEllipsis,Qo as BreadcrumbItem,Go as BreadcrumbLink,Ko as BreadcrumbList,Jo as BreadcrumbPage,Xo as BreadcrumbSeparator,oo as BulkActionBar,Va as Button,el as ButtonGroup,hn as CRUD_CONFIG,kl as Calendar,Ao as CallbackPage,Ka as Card,Xa as CardContent,Ja as CardDescription,Ya as CardFooter,Qa as CardHeader,li as CardSkeleton,Ga as CardTitle,Dc as Cards,ju as ChatbotPage,Ar as Checkbox,Sl as Collapsible,_l as CollapsibleContent,Cl as CollapsibleTrigger,Ji as ColorPicker,Cs as Combobox,Vr as Command,qr as CommandDialog,Hr as CommandEmpty,Kr as CommandGroup,Br as CommandInput,Gr as CommandItem,Wr as CommandList,Qr as CommandSeparator,Jr as CommandShortcut,Ai as ContextMenu,Ui as ContextMenuCheckboxItem,zi as ContextMenuContent,Oi as ContextMenuGroup,$i as ContextMenuItem,qi as ContextMenuLabel,Li as ContextMenuPortal,ji as ContextMenuRadioGroup,Vi as ContextMenuRadioItem,Bi as ContextMenuSeparator,Wi as ContextMenuShortcut,Fi as ContextMenuSub,Mi as ContextMenuSubContent,Di as ContextMenuSubTrigger,Ri as ContextMenuTrigger,Oc as CrudCards,po as CrudPageInternal,io as CrudPagination,jc as CrudPrimitiveFilterBar,no as CrudPrimitivePagination,Lc as CrudPrimitiveTable,Ki as CrudTable,El as DataList,Pl as DatePicker,Yn as DeleteConfirmationDialog,er as Dialog,or as DialogBody,rr as DialogClose,nr as DialogContent,cr as DialogDescription,lr as DialogFooter,ir as DialogHeader,sr as DialogOverlay,ar as DialogPortal,dr as DialogTitle,tr as DialogTrigger,Il as Drawer,Rl as DrawerClose,Ll as DrawerContent,Ml as DrawerDescription,jl as DrawerFooter,Fl as DrawerHeader,Ol as DrawerOverlay,Al as DrawerPortal,Dl as DrawerTitle,Tl as DrawerTrigger,pi as DropdownMenu,Si as DropdownMenuCheckboxItem,wi as DropdownMenuContent,gi as DropdownMenuGroup,ki as DropdownMenuItem,_i as DropdownMenuLabel,bi as DropdownMenuPortal,yi as DropdownMenuRadioGroup,Ci as DropdownMenuRadioItem,Ei as DropdownMenuSeparator,Pi as DropdownMenuShortcut,vi as DropdownMenuSub,Ni as DropdownMenuSubContent,xi as DropdownMenuSubTrigger,fi as DropdownMenuTrigger,Ru as EmailService,hi as EmptyState,Cs as EntitySelect,Eu as ErrorBoundary,ho as FilterBar,ur as Form,vr as FormControl,yr as FormDescription,hr as FormField,gr as FormItem,br as FormLabel,xr as FormMessage,di as FormSkeleton,Vl as Grid,Yl as H1,Zl as H2,ed as H3,td as H4,ci as HeaderSkeleton,ws as I18nextProvider,eo as IconPicker,Nm as ImageEditor,wm as ImageRenderer,od as InlineCode,Ba as Input,ql as InputGroup,Wl as InputGroupAddon,Kl as InputGroupButton,Ql as InputGroupInput,Gl as InputGroupTextarea,Jl as Kbd,yn as LOGO_CONFIG,Ha as Label,sd as Large,rd as Lead,em as LeaderRow,om as LeadershipDialog,im as LeadershipForm,cm as LeadershipPage,dd as List,Dr as LoadingState,Yc as LocaleProvider,ru as LocaleSelector,Ro as LoginPage,xn as MESSAGES,Du as ManageAccessModal,Fu as MarkdownMessage,Cs as MultiSelect,id as Muted,Xl as NativeSelect,iu as NavigationProvider,ad as P,cd as PageBreadcrumb,Lo as PageMetadataProvider,md as Pagination,hd as PaginationContent,vd as PaginationEllipsis,pd as PaginationItem,fd as PaginationLink,bd as PaginationNext,gd as PaginationPrevious,Mu as PlaceCard,zu as PlacesList,zr as Popover,Ur as PopoverContent,$r as PopoverTrigger,xo as Progress,_o as ProtectedRoute,bn as QUALIEX_CONFIG,gn as QUERY_KEYS,_n as QualiexEnrichmentService,ln as QualiexErrorInterceptor,ro as QualiexUserField,yd as RadioGroup,xd as RadioGroupItem,wu as ResizableRail,pn as SEARCH_CONFIG,Xi as ScrollArea,Yi as ScrollBar,wd as Searchbar,Nr as Select,Er as SelectContent,wr as SelectGroup,Ir as SelectItem,Pr as SelectLabel,_r as SelectScrollDownButton,Cr as SelectScrollUpButton,Cs as SelectSearch,Tr as SelectSeparator,Sr as SelectTrigger,kr as SelectValue,Za as Separator,kd as Sheet,Ad as SheetBody,Cd as SheetClose,Id as SheetContent,Ld as SheetDescription,Rd as SheetFooter,Td as SheetHeader,Ed as SheetOverlay,_d as SheetPortal,Od as SheetTitle,Sd as SheetTrigger,qd as Sidebar,Xd as SidebarContent,Gd as SidebarFooter,Yd as SidebarGroup,ec as SidebarGroupAction,tc as SidebarGroupContent,Zd as SidebarGroupLabel,xu as SidebarHeader,Kd as SidebarInput,Hd as SidebarInset,ac as SidebarMenu,ic as SidebarMenuAction,oc as SidebarMenuBadge,nc as SidebarMenuButton,rc as SidebarMenuItem,lc as SidebarMenuSkeleton,dc as SidebarMenuSub,uc as SidebarMenuSubButton,cc as SidebarMenuSubItem,Vd as SidebarProvider,Wd as SidebarRail,Jd as SidebarSeparator,ui as SidebarSkeleton,Bd as SidebarTrigger,Xr as Skeleton,mc as Slider,nd as Small,Mr as SonnerToaster,jr as Spinner,mo as Stack,zl as StatusSelect,to as Switch,yc as TabPageContent,vc as TabPageHeader,bc as TabPageLayout,Zn as Table,ti as TableBody,ii as TableCaption,ni as TableCell,ai as TableFooter,si as TableHead,ei as TableHeader,ri as TableRow,Ti as TableRowActions,oi as TableSkeleton,hc as Tabs,gc as TabsContent,pc as TabsList,fc as TabsTrigger,Rr as Textarea,kc as Toast,Sc as ToastAction,Cc as ToastClose,Ec as ToastDescription,xc as ToastProvider,_c as ToastTitle,Nc as ToastViewport,Mr as Toaster,Ic as Toggle,Ac as ToggleGroup,Rc as ToggleGroupItem,Fs as TokenManager,Es as TokenService,jd as Tooltip,Md as TooltipContent,Fd as TooltipProvider,Dd as TooltipTrigger,Pu as TranslationLoader,ym as VideoEditor,xm as VideoRenderer,wo as WizardBreadcrumb,So as WizardButtons,Co as WizardForm,ko as WizardProgressBar,No as WizardStepper,bu as assets,Or as badgeVariants,Bu as buildHierarchy,Zo as buttonGroupVariants,Ua as buttonVariants,km as calculateAspectRatio,Fa as cn,fo as createCrudPage,zc as createCrudRoutingConfig,Mc as createRoutingHandlers,In as createService,go as createSimpleSaveHandler,$n as createSimpleService,za as debounce,wn as deriveEmailField,Nn as deriveNameField,kn as deriveUsernameField,bm as detectVideoProvider,Ou as emailService,Ks as errorService,_m as extractImageFileName,pm as extractVimeoId,mm as extractYouTubeId,qu as filterAndPromoteOrphans,Wu as flattenTree,Ma as formatCurrency,Tu as formatDate,Da as formatDatetime,Em as formatFileSize,bo as generateCrudConfig,vn as getQualiexConfig,en as getSupabaseClient,La as handleExternalLink,Oa as i18n,Bl as inputGroupAddonVariants,Hl as inputGroupButtonVariants,fn as isDevEnvironment,Cm as isImageUrl,vu as logoSrc,vm as normalizeVideoUrl,fm as normalizeVimeoUrl,hm as normalizeYouTubeUrl,gm as parseIframeSrc,Vu as placeService,un as qualiexApi,Sm as resizeKeepingAspect,Sn as resolveFieldMappings,Nd as searchbarVariants,Do as setupQualiexCore,$a as slugify,yu as smallLogoSrc,Pc as toggleVariants,Kc as translationService,ja as trimTextFields,mu as useActiveModules,$c as useAllQualiexUsers,Mn as useAuth,Qi as useBaseForm,Ku as useCreateLeaderMutation,Gu as useCreateMultipleLeadersMutation,Qu as useCreateSingleLeaderMutation,zn as useCrud,du as useDebounce,pr as useFormField,Au as useI18nFormatters,Hu as useLeadershipApi,Zc as useLocale,um as useMediaUpload,ou as useNavigation,Lu as useOpenAIChat,jo as usePageMetadata,Fo as usePageMetadataContext,lu as usePageTitle,uu as usePermissionQuery,ao as useQualiexUsers,Xu as useRemoveLeaderMutation,ud as useRouteBreadcrumbs,Ud as useSidebar,Nu as useSidebarResize,Yu as useSyncSubordinatesMutation,Bs as useToast,Ns as useTranslation,Ju as useUpdateLeaderMutation};
|