forlogic-core 1.12.1 → 1.12.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/dist/index.js CHANGED
@@ -1,10 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),r=require("class-variance-authority"),s=require("clsx"),n=require("tailwind-merge"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),c=require("@radix-ui/react-label"),d=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("react-hook-form"),p=require("@radix-ui/react-select"),h=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("@supabase/supabase-js"),x=require("@tanstack/react-query"),v=require("react-router-dom"),b=require("@radix-ui/react-tooltip"),y=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),j=require("@radix-ui/react-scroll-area"),N=require("@radix-ui/react-switch"),C=require("@radix-ui/react-progress"),k=require("@radix-ui/react-collapsible"),S=require("@radix-ui/react-accordion"),E=require("@radix-ui/react-alert-dialog"),P=require("@radix-ui/react-avatar"),R=require("react-day-picker"),_=require("vaul"),T=require("@radix-ui/react-radio-group"),A=require("@radix-ui/react-slider"),M=require("@radix-ui/react-tabs"),I=require("@radix-ui/react-toggle"),L=require("@radix-ui/react-toggle-group"),O=require("react-dom"),D=require("recharts"),F=require("@tiptap/react"),z=require("@tiptap/starter-kit"),$=require("@tiptap/extension-underline"),U=require("@tiptap/extension-link"),V=require("@tiptap/extension-text-style"),B=require("@tiptap/extension-color"),W=require("@tiptap/extension-highlight"),q=require("zod"),H=require("@hookform/resolvers");function K(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var G=K(t),Q=K(c),X=K(d),J=K(u),Y=K(p),Z=K(h),ee=K(f),te=K(b),ae=K(y),re=K(w),se=K(j),ne=K(N),oe=K(C),ie=K(k),le=K(S),ce=K(E),de=K(P),ue=K(T),me=K(A),pe=K(M),he=K(I),fe=K(L),ge=K(O),xe=K(D);const ve=e=>"string"==typeof e,be=()=>{let e,t;const a=new Promise((a,r)=>{e=a,t=r});return a.resolve=e,a.reject=t,a},ye=e=>null==e?"":""+e,we=/###/g,je=e=>e&&e.indexOf("###")>-1?e.replace(we,"."):e,Ne=e=>!e||ve(e),Ce=(e,t,a)=>{const r=ve(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Ne(e))return{};const t=je(r[s]);!e[t]&&a&&(e[t]=new a),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++s}return Ne(e)?{}:{obj:e,k:je(r[s])}},ke=(e,t,a)=>{const{obj:r,k:s}=Ce(e,t,Object);if(void 0!==r||1===t.length)return void(r[s]=a);let n=t[t.length-1],o=t.slice(0,t.length-1),i=Ce(e,o,Object);for(;void 0===i.obj&&o.length;)n=`${o[o.length-1]}.${n}`,o=o.slice(0,o.length-1),i=Ce(e,o,Object),i?.obj&&void 0!==i.obj[`${i.k}.${n}`]&&(i.obj=void 0);i.obj[`${i.k}.${n}`]=a},Se=(e,t)=>{const{obj:a,k:r}=Ce(e,t);if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r]},Ee=(e,t,a)=>{for(const r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?ve(e[r])||e[r]instanceof String||ve(t[r])||t[r]instanceof String?a&&(e[r]=t[r]):Ee(e[r],t[r],a):e[r]=t[r]);return e},Pe=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Re={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const _e=e=>ve(e)?e.replace(/[&<>"'\/]/g,e=>Re[e]):e;const Te=[" ",",","?","!",";"],Ae=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),Me=(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 o=n;o<r.length;++o)if(o!==n&&(t+=a),t+=r[o],e=s[t],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&o<r.length-1)continue;n+=o-n+1;break}s=e}return s},Ie=e=>e?.replace("_","-"),Le={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){}};class Oe{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Le,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:(ve(e[0])&&(e[0]=`${a}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Oe(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new Oe(this.logger,e)}}var De=new Oe;class Fe{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 ze extends Fe{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 o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],a&&(Array.isArray(a)?o.push(...a):ve(a)&&s?o.push(...a.split(s)):o.push(a)));const i=Se(this.data,o);return!i&&!t&&!a&&e.indexOf(".")>-1&&(e=o[0],t=o[1],a=o.slice(2).join(".")),!i&&n&&ve(a)?Me(this.data?.[e]?.[t],a,s):i}addResource(e,t,a,r,s={silent:!1}){const n=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let o=[e,t];a&&(o=o.concat(n?a.split(n):a)),e.indexOf(".")>-1&&(o=e.split("."),r=t,t=o[1]),this.addNamespaces(t),ke(this.data,o,r),s.silent||this.emit("added",e,t,a,r)}addResources(e,t,a,r={silent:!1}){for(const s in a)(ve(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 o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),r=a,a=t,t=o[1]),this.addNamespaces(t);let i=Se(this.data,o)||{};n.skipCopy||(a=JSON.parse(JSON.stringify(a))),r?Ee(i,a,s):i={...i,...a},ke(this.data,o,i),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 $e={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 Ue=Symbol("i18next/PATH_KEY");function Ve(e,t){const{[Ue]:a}=e(function(){const e=[],t=Object.create(null);let a;return t.get=(r,s)=>(a?.revoke?.(),s===Ue?e:(e.push(s),a=Proxy.revocable(r,t),a.proxy)),Proxy.revocable(Object.create(null),t).proxy}());return a.join(t?.keySeparator??".")}const Be={},We=e=>!ve(e)&&"boolean"!=typeof e&&"number"!=typeof e;class qe extends Fe{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=De.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=We(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,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,a)=>{t=t||"",a=a||"";const r=Te.filter(e=>t.indexOf(e)<0&&a.indexOf(e)<0);if(0===r.length)return!0;const s=Ae.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&&!o){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:ve(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:ve(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=Ve(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:o,namespaces:i}=this.extractFromKey(e[e.length-1],r),l=i[i.length-1];let c=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");const d=r.lng||this.language,u=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===d?.toLowerCase())return u?s?{res:`${l}${c}${o}`,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${c}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:o;const m=this.resolve(e,r);let p=m?.res;const h=m?.usedKey||o,f=m?.exactUsedKey||o,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==r.count&&!ve(r.count),b=qe.hasDefaultValue(r),y=v?this.pluralResolver.getSuffix(d,r.count,r):"",w=r.ordinal&&v?this.pluralResolver.getSuffix(d,r.count,{ordinal:!1}):"",j=v&&!r.ordinal&&0===r.count,N=j&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${y}`]||r[`defaultValue${w}`]||r.defaultValue;let C=p;x&&!p&&b&&(C=N);const k=We(C),S=Object.prototype.toString.apply(C);if(!(x&&C&&k&&["[object Number]","[object Function]","[object RegExp]"].indexOf(S)<0)||ve(g)&&Array.isArray(C))if(x&&ve(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,e,r,a));else{let t=!1,s=!1;!this.isValidLookup(p)&&b&&(t=!0,p=N),this.isValidLookup(p)||(s=!0,p=o);const i=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:p,u=b&&N!==p&&this.options.updateMissing;if(s||t||u){if(this.logger.log(u?"updateKey":"missingKey",d,l,o,u?N:p),n){const e=this.resolve(o,{...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=b&&a!==p?a:i;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,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,r);j&&r[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{a([e],o+t,r[`defaultValue${t}`]||N)})}):a(e,o,N))}p=this.extendTranslation(p,e,r,m,a),s&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${l}${c}${o}`),(s||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${o}`:o,t?p: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(h,C,{...r,ns:i}):`key '${o} (${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(C),t=e?[]:{},a=e?f:h;for(const s in C)if(Object.prototype.hasOwnProperty.call(C,s)){const e=`${a}${n}${s}`;t[s]=b&&!p?this.translate(e,{...r,defaultValue:We(N)?N[s]:void 0,joinArrays:!1,ns:i}):this.translate(e,{...r,joinArrays:!1,ns:i}),t[s]===e&&(t[s]=C[s])}p=t}}return s?(m.res=p,m.usedParams=this.getUsedParamsDetails(r),m):p}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=ve(e)&&(void 0!==a?.interpolation?.skipOnVariables?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let o;if(n){const t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let i=a.replace&&!ve(a.replace)?a.replace:a;if(this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),e=this.interpolator.interpolate(e,i,a.lng||this.language||r.usedLng,a),n){const t=e.match(this.interpolator.nestingRegexp);o<(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,o=ve(n)?[n]:n;return null!=e&&o?.length&&!1!==a.applyPostProcessor&&(e=$e.handle(o,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,o;return ve(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(a))return;const i=this.extractFromKey(e,t),l=i.key;r=l;let c=i.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const d=void 0!==t.count&&!ve(t.count),u=d&&!t.ordinal&&0===t.count,m=void 0!==t.context&&(ve(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);c.forEach(e=>{this.isValidLookup(a)||(o=e,Be[`${p[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(o)||(Be[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(", ")}" won't get resolved as namespace "${o}" 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!!!")),p.forEach(r=>{if(this.isValidLookup(a))return;n=r;const o=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,r,e,t);else{let e;d&&(e=this.pluralResolver.getSuffix(r,t.count,t));const a=`${this.options.pluralSeparator}zero`,s=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(t.ordinal&&0===e.indexOf(s)&&o.push(l+e.replace(s,this.options.pluralSeparator)),o.push(l+e),u&&o.push(l+a)),m){const r=`${l}${this.options.contextSeparator||"_"}${t.context}`;o.push(r),d&&(t.ordinal&&0===e.indexOf(s)&&o.push(r+e.replace(s,this.options.pluralSeparator)),o.push(r+e),u&&o.push(r+a))}}let i;for(;i=o.pop();)this.isValidLookup(a)||(s=i,a=this.getResource(r,e,i,t))}))})}),{res:a,usedKey:r,exactUsedKey:s,usedLng:n,usedNS:o}}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&&!ve(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 He{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=De.create("languageUtils")}getScriptPartFromCode(e){if(!(e=Ie(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=Ie(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(ve(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)),ve(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 ve(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))):ve(e)&&s(this.formatLanguageCode(e)),a.forEach(e=>{r.indexOf(e)<0&&s(this.formatLanguageCode(e))}),r}}const Ke={zero:0,one:1,two:2,few:3,many:4,other:5},Ge={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Qe{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=De.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const a=Ie("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(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Ge;if(!e.match(/-|_/))return Ge;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)=>Ke[e]-Ke[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 Xe=(e,t,a,r=".",s=!0)=>{let n=((e,t,a)=>{const r=Se(e,a);return void 0!==r?r:Se(t,a)})(e,t,a);return!n&&s&&ve(a)&&(n=Me(e,a,r),void 0===n&&(n=Me(t,a,r))),n},Je=e=>e.replace(/\$/g,"$$$$");class Ye{constructor(e={}){this.logger=De.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:o,suffixEscaped:i,formatSeparator:l,unescapeSuffix:c,unescapePrefix:d,nestingPrefix:u,nestingPrefixEscaped:m,nestingSuffix:p,nestingSuffixEscaped:h,nestingOptionsSeparator:f,maxReplaces:g,alwaysFormat:x}=e.interpolation;this.escape=void 0!==t?t:_e,this.escapeValue=void 0===a||a,this.useRawValueToEscape=void 0!==r&&r,this.prefix=s?Pe(s):n||"{{",this.suffix=o?Pe(o):i||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=u?Pe(u):m||Pe("$t("),this.nestingSuffix=p?Pe(p):h||Pe(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==x&&x,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,o;const i=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(e.indexOf(this.formatSeparator)<0){const s=Xe(t,i,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(),o=s.join(this.formatSeparator).trim();return this.format(Xe(t,i,n,this.options.keySeparator,this.options.ignoreJSONStructure),o,a,{...r,...t,interpolationkey:n})};this.resetRegExp();const c=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=void 0!==r?.interpolation?.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>Je(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?Je(this.escape(e)):Je(e)}].forEach(t=>{for(o=0;s=t.regex.exec(e);){const a=s[1].trim();if(n=l(a),void 0===n)if("function"==typeof c){const t=c(e,s,r);n=ve(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,a))n="";else{if(d){n=s[0];continue}this.logger.warn(`missed to pass in variable ${a} for interpolating ${e}`),n=""}else ve(n)||this.useRawValueToEscape||(n=ye(n));const i=t.safeValue(n);if(e=e.replace(s[0],i),d?(t.regex.lastIndex+=n.length,t.regex.lastIndex-=s[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,a={}){let r,s,n;const o=(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 o=s.match(/'/g),i=s.match(/"/g);((o?.length??0)%2==0&&!i||i.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 i=[];n={...a},n=n.replace&&!ve(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&&(i=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),s=t(o.call(this,r[1].trim(),n),n),s&&r[0]===e&&!ve(s))return s;ve(s)||(s=ye(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),i.length&&(s=i.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 Ze=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 o=r+JSON.stringify(n);let i=t[o];return i||(i=e(Ie(r),s),t[o]=i),i(a)}},et=e=>(t,a,r)=>e(Ie(a),r)(t);class tt{constructor(e={}){this.logger=De.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const a=t.cacheInBuiltFormats?Ze:et;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()]=Ze(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 o=r?.formatParams?.[r.interpolationkey]||{},i=o.locale||o.lng||r.locale||r.lng||a;t=this.formats[s](e,i,{...n,...r,...o})}catch(o){this.logger.warn(o)}return t}return this.logger.warn(`there was no format function for ${s}`),e},e)}}class at extends Fe{constructor(e,t,a,r={}){super(),this.backend=e,this.store=t,this.services=a,this.languageUtils=a.languageUtils,this.options=r,this.logger=De.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={},o={},i={};return e.forEach(e=>{let r=!0;t.forEach(t=>{const o=`${e}|${t}`;!a.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(1===this.state[o]?void 0===n[o]&&(n[o]=!0):(this.state[o]=1,r=!1,void 0===n[o]&&(n[o]=!0),void 0===s[o]&&(s[o]=!0),void 0===i[t]&&(i[t]=!0)))}),r||(o[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(o),toLoadNamespaces:Object.keys(i)}}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 o={};this.queue.forEach(a=>{((e,t,a)=>{const{obj:r,k:s}=Ce(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=>{o[e]||(o[e]={});const t=a.loaded[e];t.length&&t.forEach(t=>{void 0===o[e][t]&&(o[e][t]=!0)})}),a.done=!0,a.errors.length?a.callback(a.errors):a.callback())}),this.emit("loaded",o),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 o=(o,i)=>{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)}o&&i&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,a,r+1,2*s,n)},s):n(o,i)},i=this.backend[a].bind(this.backend);if(2!==i.length)return i(e,t,o);try{const a=i(e,t);a&&"function"==typeof a.then?a.then(e=>o(null,e)).catch(o):o(null,a)}catch(l){o(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();ve(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ve(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={},o=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=a&&""!==a){if(this.backend?.create){const l={...n,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let s;s=5===c.length?c(e,t,a,r,l):c(e,t,a,r),s&&"function"==typeof s.then?s.then(e=>o(null,e)).catch(o):o(null,s)}catch(i){o(i)}else c(e,t,a,r,o,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 rt=()=>({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]),ve(e[1])&&(t.defaultValue=e[1]),ve(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}),st=e=>(ve(e.ns)&&(e.ns=[e.ns]),ve(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),ve(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),nt=()=>{};class ot extends Fe{constructor(e={},t){var a;if(super(),this.options=st(e),this.services={},this.logger=De,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&&(ve(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const a=rt();this.options={...a,...this.options,...st(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),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?De.init(r(this.modules.logger),this.options):De.init(null,this.options),e=this.modules.formatter?this.modules.formatter:tt;const t=new He(this.options);this.store=new ze(this.options.resources,this.options);const s=this.services;s.logger=De,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new Qe(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 Ye(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new at(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 qe(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=nt),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=be(),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=nt){let a=t;const r=ve(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=be();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=nt),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&&$e.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=be();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=ve(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(a)?a:this.services.languageUtils.getBestMatchFromCodes(ve(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 o=this.options.keySeparator||".";let i;return n.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=Ve(e,{...this.options,...t})),`${n.keyPrefix}${o}${e}`)):("function"==typeof e&&(e=Ve(e,{...this.options,...t})),i=n.keyPrefix?`${n.keyPrefix}${o}${e}`:e),this.t(i,n)};return ve(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=be();return this.options.ns?(ve(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=be();ve(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 He(rt());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 ot(e,t);return a.createInstance=ot.createInstance,a}cloneInstance(e={},t=nt){const a=e.forkResourceStore;a&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new ot(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 ze(e,r),s.services.resourceStore=s.store}return e.interpolation&&(s.services.interpolator=new Ye(r)),s.translator=new qe(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 it=ot.createInstance();function lt(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info(it.t("link_copied"))})}function ct(...e){return n.twMerge(s.clsx(e))}it.createInstance,it.dir,it.init,it.loadResources,it.reloadResources,it.use,it.changeLanguage,it.getFixedT,it.t,it.exists,it.setDefaultNamespace,it.hasLoadedNamespace,it.loadNamespaces,it.loadLanguages;const dt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(dt);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,r]of Object.entries(e))t[a]=dt(r);return t}return e},ut=r.cva("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"}}),mt=G.forwardRef(({className:t,variant:r,size:s,asChild:n=!1,...o},i)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:ct(ut({variant:r,size:s,className:t})),ref:i,...o})});mt.displayName="Button";const pt=t.forwardRef(({className:t,children:a,...r},s)=>e.jsx(mt,{ref:s,variant:"action",size:"sm",className:ct("h-7 px-2 text-xs",t),...r,children:a||e.jsx(l.EllipsisVertical,{size:12})}));pt.displayName="ActionButton";const ht=G.forwardRef(({className:t,type:a,...r},s)=>e.jsx("input",{type:a,className:ct("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}));ht.displayName="Input";const ft=r.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),gt=G.forwardRef(({className:t,...a},r)=>e.jsx(Q.Root,{ref:r,className:ct(ft(),t),...a}));gt.displayName=Q.Root.displayName;const xt=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));xt.displayName="Card";const vt=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("flex flex-col space-y-1.5 p-6",t),...a}));vt.displayName="CardHeader";const bt=G.forwardRef(({className:t,...a},r)=>e.jsx("h3",{ref:r,className:ct("text-2xl font-semibold leading-none tracking-tight",t),...a}));bt.displayName="CardTitle";const yt=G.forwardRef(({className:t,...a},r)=>e.jsx("p",{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));yt.displayName="CardDescription";const wt=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("p-6 pt-0",t),...a}));wt.displayName="CardContent";const jt=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("flex items-center p-6 pt-0",t),...a}));jt.displayName="CardFooter";const Nt=G.forwardRef(({className:t,orientation:a="horizontal",decorative:r=!0,...s},n)=>e.jsx(J.Root,{ref:n,decorative:r,orientation:a,className:ct("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...s}));Nt.displayName=J.Root.displayName;const Ct=X.Root,kt=X.Trigger,St=X.Portal,Et=X.Close,Pt=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Overlay,{ref:r,className:ct("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}));Pt.displayName=X.Overlay.displayName;const Rt={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},_t=G.forwardRef(({className:t,children:a,size:r="md",...s},n)=>e.jsxs(St,{children:[e.jsx(Pt,{}),e.jsxs(X.Content,{ref:n,className:ct("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",Rt[r],t),...s,children:[a,e.jsxs(X.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.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_t.displayName=X.Content.displayName;const Tt=({className:t,showSeparator:a=!1,children:r,...s})=>e.jsxs("div",{className:ct("flex flex-col flex-shrink-0",t),...s,children:[e.jsx("div",{className:"flex flex-col text-left",children:r}),a&&e.jsx(Nt,{className:"mt-2"})]});Tt.displayName="DialogHeader";const At=({className:t,...a})=>e.jsx("div",{className:ct("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});At.displayName="DialogBody";const Mt=({className:t,children:a,...r})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Nt,{className:"mb-4"}),e.jsx("div",{className:ct("flex flex-row justify-end gap-2",t),...r,children:a})]});Mt.displayName="DialogFooter";const It=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Title,{ref:r,className:ct("text-lg font-semibold leading-none tracking-tight",t),...a}));It.displayName=X.Title.displayName;const Lt=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Description,{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));Lt.displayName=X.Description.displayName;const Ot=m.FormProvider,Dt=G.createContext({}),Ft=()=>{const e=G.useContext(Dt),t=G.useContext(zt),{getFieldState:a,formState:r}=m.useFormContext(),s=a(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...s}},zt=G.createContext({}),$t=G.forwardRef(({className:t,...a},r)=>{const s=G.useId();return e.jsx(zt.Provider,{value:{id:s},children:e.jsx("div",{ref:r,className:ct("space-y-2",t),...a})})});$t.displayName="FormItem";const Ut=G.forwardRef(({className:t,...a},r)=>{const{error:s,formItemId:n}=Ft();return e.jsx(gt,{ref:r,className:ct(s&&"text-destructive",t),htmlFor:n,...a})});Ut.displayName="FormLabel";const Vt=G.forwardRef(({...t},r)=>{const{error:s,formItemId:n,formDescriptionId:o,formMessageId:i}=Ft();return e.jsx(a.Slot,{ref:r,id:n,"aria-describedby":s?`${o} ${i}`:`${o}`,"aria-invalid":!!s,...t})});Vt.displayName="FormControl";const Bt=G.forwardRef(({className:t,...a},r)=>{const{formDescriptionId:s}=Ft();return e.jsx("p",{ref:r,id:s,className:ct("text-sm text-muted-foreground",t),...a})});Bt.displayName="FormDescription";const Wt=G.forwardRef(({className:t,children:a,...r},s)=>{const{error:n,formMessageId:o}=Ft(),i=n?String(n?.message):a;return i?e.jsx("p",{ref:s,id:o,className:ct("text-sm font-medium text-destructive",t),...r,children:i}):null});Wt.displayName="FormMessage";const qt=Y.Root,Ht=Y.Group,Kt=Y.Value,Gt=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(Y.Trigger,{ref:s,className:ct("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",t),...r,children:[a,e.jsx(Y.Icon,{asChild:!0,children:e.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Gt.displayName=Y.Trigger.displayName;const Qt=G.forwardRef(({className:t,...a},r)=>e.jsx(Y.ScrollUpButton,{ref:r,className:ct("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));Qt.displayName=Y.ScrollUpButton.displayName;const Xt=G.forwardRef(({className:t,...a},r)=>e.jsx(Y.ScrollDownButton,{ref:r,className:ct("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Xt.displayName=Y.ScrollDownButton.displayName;const Jt=G.forwardRef(({className:t,children:a,position:r="popper",container:s,collisionBoundary:n,...o},i)=>e.jsx(Y.Portal,{container:s,children:e.jsxs(Y.Content,{ref:i,className:ct("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"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,collisionBoundary:n,...o,children:[e.jsx(Qt,{}),e.jsx(Y.Viewport,{className:ct("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(Xt,{})]})}));Jt.displayName=Y.Content.displayName;const Yt=G.forwardRef(({className:t,...a},r)=>e.jsx(Y.Label,{ref:r,className:ct("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));Yt.displayName=Y.Label.displayName;const Zt=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(Y.Item,{ref:s,className:ct("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",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Y.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),e.jsx(Y.ItemText,{children:a})]}));Zt.displayName=Y.Item.displayName;const ea=G.forwardRef(({className:t,...a},r)=>e.jsx(Y.Separator,{ref:r,className:ct("-mx-1 my-1 h-px bg-muted",t),...a}));ea.displayName=Y.Separator.displayName;const ta=G.forwardRef(({className:t,...a},r)=>e.jsx(Z.Root,{ref:r,className:ct("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.jsx(Z.Indicator,{className:ct("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));ta.displayName=Z.Root.displayName;const aa=G.forwardRef(({className:t,...a},r)=>e.jsx("textarea",{className:ct("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}));aa.displayName="Textarea";const ra=r.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),sa=G.forwardRef(({className:t,variant:a,...r},s)=>e.jsx("div",{ref:s,className:ct(ra({variant:a}),t),...r}));sa.displayName="Badge";const na={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function oa({size:t="md",className:a}){return e.jsx(l.Loader2,{className:ct("animate-spin text-muted-foreground",na[t],a)})}const ia=({...t})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.Loader2Icon,{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-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...t}),la=ee.Root,ca=ee.Trigger,da=G.forwardRef(({className:t,align:a="center",sideOffset:r=4,container:s,...n},o)=>e.jsx(ee.Portal,{container:s,children:e.jsx(ee.Content,{ref:o,align:a,sideOffset:r,className:ct("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})}));da.displayName=ee.Content.displayName;const ua=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));ua.displayName="Command";const ma=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:r,className:ct("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})}));ma.displayName="CommandInput";const pa=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));pa.displayName="CommandList";const ha=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("py-6 text-center text-sm text-muted-foreground",t),...a}));ha.displayName="CommandEmpty";const fa=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("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}));fa.displayName="CommandGroup";const ga=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("-mx-1 h-px bg-border",t),...a}));ga.displayName="CommandSeparator";const xa=G.forwardRef(({className:t,disabled:a,onSelect:r,value:s,...n},o)=>e.jsx("div",{ref:o,className:ct("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground 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}));xa.displayName="CommandItem";const va=({className:t,...a})=>e.jsx("span",{className:ct("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function ba({className:t,...a}){return e.jsx("div",{className:ct("animate-pulse rounded-md bg-muted",t),...a})}va.displayName="CommandShortcut";const ya={},wa=(e,t,a,r)=>{ka(a)&&ya[a]||(ka(a)&&(ya[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);ka(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console})(e,t,a,r))},ja=(e,t)=>()=>{if(e.isInitialized)t();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),t()};e.on("initialized",a)}},Na=(e,t,a)=>{e.loadNamespaces(t,ja(e,a))},Ca=(e,t,a,r)=>{if(ka(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Na(e,a,r);a.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,ja(e,r))},ka=e=>"string"==typeof e,Sa=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Ea={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Pa=e=>Ea[e];let Ra={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(Sa,Pa),transDefaultProps:void 0};let _a;const Ta={type:"3rdParty",init(e){((e={})=>{Ra={...Ra,...e}})(e.options.react),(e=>{_a=e})(e)}},Aa=t.createContext();class Ma{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Ia,La={exports:{}},Oa={};var Da,Fa,za={};
2
- /**
3
- * @license React
4
- * use-sync-external-store-shim.development.js
5
- *
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var $a=(Fa||(Fa=1,"production"===process.env.NODE_ENV?La.exports=function(){if(Ia)return Oa;Ia=1;var e=t,a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,s=e.useEffect,n=e.useLayoutEffect,o=e.useDebugValue;function i(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!a(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 a=t(),l=r({inst:{value:a,getSnapshot:t}}),c=l[0].inst,d=l[1];return n(function(){c.value=a,c.getSnapshot=t,i(c)&&d({inst:c})},[e,a,t]),s(function(){return i(c)&&d({inst:c}),e(function(){i(c)&&d({inst:c})})},[e]),o(a),a};return Oa.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,Oa}():La.exports=(Da||(Da=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!r(e,a)}catch(s){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=a.useState,n=a.useEffect,o=a.useLayoutEffect,i=a.useDebugValue,l=!1,c=!1,d="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,d){l||void 0===a.startTransition||(l=!0);var u=d();if(!c){var m=d();r(u,m)||(c=!0)}var p=(m=s({inst:{value:u,getSnapshot:d}}))[0].inst,h=m[1];return o(function(){p.value=u,p.getSnapshot=d,e(p)&&h({inst:p})},[t,u,d]),n(function(){return e(p)&&h({inst:p}),t(function(){e(p)&&h({inst:p})})},[t]),i(u),u};za.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:d,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),za)),La.exports);const Ua={t:(e,t)=>{return ka(t)?t:"object"==typeof(a=t)&&null!==a&&ka(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e;var a},ready:!1},Va=()=>()=>{},Ba=(e,a={})=>{const{i18n:r}=a,{i18n:s,defaultNS:n}=t.useContext(Aa)||{},o=r||s||_a;o&&!o.reportNamespaces&&(o.reportNamespaces=new Ma),o||wa(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=t.useMemo(()=>({...Ra,...o?.options?.react,...a}),[o,a]),{useSuspense:l,keyPrefix:c}=i,d=e||n||o?.options?.defaultNS,u=ka(d)?[d]:d||["translation"],m=t.useMemo(()=>u,u);o?.reportNamespaces?.addUsedNamespaces?.(m);const p=t.useRef(0),h=t.useCallback(e=>{if(!o)return Va;const{bindI18n:t,bindI18nStore:a}=i,r=()=>{p.current+=1,e()};return t&&o.on(t,r),a&&o.store.on(a,r),()=>{t&&t.split(" ").forEach(e=>o.off(e,r)),a&&a.split(" ").forEach(e=>o.store.off(e,r))}},[o,i]),f=t.useRef(),g=t.useCallback(()=>{if(!o)return Ua;const e=!(!o.isInitialized&&!o.initializedStoreOnce)&&m.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}}):(wa(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0))(e,o,i)),t=a.lng||o.language,r=p.current,s=f.current;if(s&&s.ready===e&&s.lng===t&&s.keyPrefix===c&&s.revision===r)return s;const n={t:o.getFixedT(t,"fallback"===i.nsMode?m:m[0],c),ready:e,lng:t,keyPrefix:c,revision:r};return f.current=n,n},[o,m,c,i,a.lng]),[x,v]=t.useState(0),{t:b,ready:y}=$a.useSyncExternalStore(h,g,g);t.useEffect(()=>{if(o&&!y&&!l){const e=()=>v(e=>e+1);a.lng?Ca(o,a.lng,m,e):Na(o,m,e)}},[o,a.lng,m,y,l,x]);const w=o||{},j=t.useRef(null),N=t.useRef(),C=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},k=t.useMemo(()=>{const e=w,t=e?.language;let a=e;e&&(j.current&&j.current.__original===e?N.current!==t?(a=C(e),j.current=a,N.current=t):a=j.current:(a=C(e),j.current=a,N.current=t));const r=[b,a,y];return r.t=b,r.i18n=a,r.ready=y,r},[b,w,y,w.resolvedLanguage,w.language,w.languages]);if(o&&l&&!y)throw new Promise(e=>{const t=()=>e();a.lng?Ca(o,a.lng,m,t):Na(o,m,t)});return k};function Wa({i18n:e,defaultNS:a,children:r}){const s=t.useMemo(()=>({i18n:e,defaultNS:a}),[e,a]);return t.createElement(Aa.Provider,{value:s},r)}const qa=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Ha({multiple:a,options:r,value:s,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:c,label:d,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:g,sortOptions:x,maxDisplayedBadges:v,popoverContainer:b,onOpen:y,onClose:w}){const{t:j}=Ba(),[N,C]=t.useState(!1),[k,S]=t.useState(""),E=t.useMemo(()=>s?Array.isArray(s)?s:[s]:[],[s]),P=t.useMemo(()=>{if(!b)return;let e=b,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},[b]),R=t.useMemo(()=>{const e=r.map(e=>({original:e,value:o(e),label:i(e)}));return x?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[r,o,i,x]),_=t.useMemo(()=>{if(!k)return R;const e=qa(k);return R.filter(t=>qa(t.label).includes(e))},[R,k]),T=t.useMemo(()=>R.filter(e=>E.includes(e.value)),[R,E]),A=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?E.filter(t=>t!==e):"")},M=v?T.slice(0,v):T,I=v&&T.length>v?T.length-v:0;return e.jsxs("div",{className:ct("space-y-2",g),children:[d&&e.jsxs(gt,{children:[d,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(la,{open:N,onOpenChange:e=>{C(e),e?y?.():(S(""),w?.())},modal:!1,children:[e.jsx(ca,{asChild:!0,children:e.jsxs(mt,{variant:"outline",role:"combobox","aria-expanded":N,disabled:h,className:ct("w-full justify-between min-h-10 h-auto",0===T.length&&"text-muted-foreground"),children:[0===T.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),c]}):a?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[M.map(t=>e.jsxs(sa,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("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&&A(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>A(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),I>0&&e.jsxs(sa,{variant:"outline",className:"gap-1",children:["+",I]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),T[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(da,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:P,collisionBoundary:P,children:e.jsxs(ua,{children:[e.jsx(ma,{placeholder:p,value:k,onChange:e=>S(e.target.value)}),e.jsx(pa,{children:0===r.length?e.jsx(ha,{children:m}):0===_.length?e.jsx(ha,{children:j("no_results")}):e.jsx(fa,{children:_.map(t=>e.jsxs(xa,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=E.includes(e)?E.filter(t=>t!==e):[...E,e];n(t)}else n(e),C(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:ct("mr-2 h-4 w-4",E.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function Ka({multiple:t=!1,options:a,items:r,value:s,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:c=e=>e.label,placeholder:d,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:g=!1,isLoading:x=!1,error:v,className:b,sortOptions:y=!0,maxDisplayedBadges:w,popoverContainer:j,onOpen:N,onClose:C}){const{t:k}=Ba(),S=r||a||[],E=o||n,P=d||k("select_placeholder"),R=p||k("no_results"),_=h||k("search_placeholder");if(x)return e.jsxs("div",{className:ct("space-y-2",b),children:[u&&e.jsxs(gt,{children:[u,g&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ba,{className:"h-10 w-full"})]});const T="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return T?e.jsxs("div",{className:ct("space-y-2",b),children:[u&&e.jsxs(gt,{children:[u,g&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:T})]})]}):e.jsx(Ha,{multiple:t,options:S,value:s||(t?[]:""),onChange:E,getOptionValue:i,getOptionLabel:c,placeholder:P,label:u,icon:m,emptyMessage:R,searchPlaceholder:_,disabled:f,required:g,className:b,sortOptions:y,maxDisplayedBadges:w,popoverContainer:j,onOpen:N,onClose:C})}var Ga=Object.defineProperty;class Qa{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 o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(s.exp&&s.exp<i){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,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?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(Qa,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Xa="qualiex_access_token",Ja="qualiex_id_token",Ya="supabase_token",Za="oauth_state",er="oauth_nonce",tr="selected_alias",ar="manual_logout",rr={setAccessToken:e=>localStorage.setItem(Xa,e),getAccessToken:()=>localStorage.getItem(Xa),setIdToken:e=>localStorage.setItem(Ja,e),getIdToken:()=>localStorage.getItem(Ja),getSupabaseToken:()=>localStorage.getItem(Ya),setOAuthState:e=>sessionStorage.setItem(Za,e),getOAuthState:()=>sessionStorage.getItem(Za),clearOAuthState:()=>sessionStorage.removeItem(Za),setOAuthNonce:e=>sessionStorage.setItem(er,e),getOAuthNonce:()=>sessionStorage.getItem(er),clearOAuthNonce:()=>sessionStorage.removeItem(er),setSelectedAlias:e=>localStorage.setItem(tr,e),getSelectedAlias:()=>localStorage.getItem(tr),clearSelectedAlias:()=>localStorage.removeItem(tr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!rr.getAccessToken()||!rr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Ya,e),rr._clearValidationCache()},areAllTokensValid:()=>{const e=rr.getAccessToken(),t=rr.getIdToken();if(!e||!t)return!1;try{const a=Qa.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=rr.getAccessToken(),a=rr.getIdToken(),r=rr.getSupabaseToken();return t&&rr.isTokenExpired(t)&&(localStorage.removeItem(Xa),e=!0),a&&rr.isTokenExpired(a)&&(localStorage.removeItem(Ja),e=!0),r&&rr.isTokenExpired(r)&&(localStorage.removeItem(Ya),e=!0),e},clearAll:()=>{localStorage.removeItem(Xa),localStorage.removeItem(Ja),localStorage.removeItem(Ya),localStorage.removeItem(tr),localStorage.removeItem(ar),sessionStorage.removeItem(Za),sessionStorage.removeItem(er)},setManualLogout:()=>localStorage.setItem(ar,"true"),isManualLogout:()=>"true"===localStorage.getItem(ar),clearManualLogout:()=>localStorage.removeItem(ar),isTokenExpired:e=>{try{return Qa.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{rr._validationCache.isValid=!1,rr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=rr.getSupabaseToken();if(!e)return!1;if(rr.isTokenExpired(e))return rr._clearValidationCache(),rr._handleExpiredToken(),!1;const t=Date.now();return t-rr._validationCache.timestamp<rr._validationCache.cacheValidityMs?rr._validationCache.isValid:(rr._validationCache.isValid=!0,rr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>rr.isSupabaseTokenValid()?rr.getSupabaseToken():null,_handleExpiredToken:()=>{rr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!rr.isSupabaseTokenValid())return null;const e=rr.getSupabaseToken();if(!e)return null;try{const t=Qa.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 rr._handleExpiredToken(),null}},getCompanyId:e=>{const t=rr.getAccessToken();if(t)try{const a=Qa.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=rr.extractTokenData();if(a?.companyId)return a.companyId;const r=rr.getIdToken();if(r)try{const t=Qa.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=rr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=rr.getIdToken();if(!e)return[];try{const t=Qa.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 sr=Object.defineProperty,nr=(e,t,a)=>((e,t,a)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const or=new class{constructor(){nr(this,"errors",[]),nr(this,"toastCount",0),nr(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()){const e=this.getErrorTitle(a);i.toast.error(e,{description:a})}}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){i.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var ir=Object.defineProperty,lr=(e,t,a)=>((e,t,a)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const cr=(void 0).VITE_SUPABASE_URL,dr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,ur=class e{constructor(){lr(this,"client"),lr(this,"currentToken",null),lr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:dr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return g.createClient(cr,dr,{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=rr.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 or.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};lr(ur,"instance");let mr=ur;function pr(){return mr.getInstance().getClient()}class hr{static async generateToken(e,t,a,r=!1){try{if(!r){const e=rr.getSupabaseToken();if(e&&rr.isSupabaseTokenValid())return e}const s=pr(),{data:n,error:o}=await s.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(rr.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 fr=Object.defineProperty,gr=(e,t,a)=>((e,t,a)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class xr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=rr.getAccessToken(),t=rr.getSelectedAlias();if(!e||!t)return null;const a=await hr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(rr.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}gr(xr,"isRegenerating",!1),gr(xr,"onLogoutCallback",null);class vr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(rr.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 br=Object.defineProperty;class yr{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 xr.attemptRegeneration()?(this.isRetrying=!1,!0):(vr.handleError(e),this.isRetrying=!1,!1)}catch(r){return vr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=rr.getAccessToken();return e?rr.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?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(yr,"isRetrying",!1);var wr=Object.defineProperty,jr=(e,t,a)=>((e,t,a)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const Nr=new class{constructor(){jr(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=yr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=rr.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 o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.json()}mapToQualiexUser(e){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}}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 or.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=a}if(!Array.isArray(r))return or.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(a){if(await yr.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 or.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=a}return Array.isArray(r)?r.map(this.mapToQualiexUser):(or.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return or.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 or.handleError(s,!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(r){return or.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 getUsers(e){const t=rr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},Cr={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},kr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Sr={debounceDelay:500},Er=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},Pr={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Rr=()=>Pr,_r={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Tr={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 Ar(e,t){const a=Rr(),r=t||a.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Mr(e,t){const a=Rr(),r=t||a.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Ir(e,t){const a=Rr(),r=t||a.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Lr(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Ar(e.idField),emailField:e.emailField||Mr(e.idField),usernameField:e.usernameField||Ir(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Ar(e),emailField:Mr(e),usernameField:Ir(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Or=new Map;class Dr{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,r=Or.get(a);if(r&&Date.now()-r.timestamp<3e5)return r.users;const s=await Nr.fetchUsers(e,t);return Or.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(!rr.areAllTokensValid())return e;const a=rr.extractTokenData();if(!a)return e;const{alias:r,companyId:s}=a;if(!r||!s)return e;const n=Lr(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(r,s),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return or.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 Fr=["responsible_name"],zr=e=>Fr.includes(e);function $r(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:o,schemaName:i,entityName:l,enableQualiexEnrichment:c=!1}=r,d=()=>{if(!rr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return pr().schema(i).from(s)},u=(e,t,a,r)=>{let s=d().select(o||"*",{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 i=t.includes(".");return i||zr(t)||(s=s.order(t,{ascending:"asc"===a})),{query:s,isForeignKey:i}},m=async(e,t,a,s,n)=>{const o=Lr(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(zr(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await this.getAll(e);if(!o?.data?.length)return o;const c=await Dr.enrichWithUserData(o.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let d;d=i?c.sort((e,r)=>{const s=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],r)||"",o=String(s).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,r)=>{const s=e[t]||"",n=r[t]||"",o=s.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(c,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}}})(d,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 Dr.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:d}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:r="desc",page:s=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:r,page:s,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,d),h=((e,t,a)=>{const r=(t-1)*a,s=r+a-1;return e.range(r,s)})(p,o,i),{data:f,error:g,count:x}=await h;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||[],x,o,i);if((e=>{if(!c||!l||0===e.length)return!1;const t=Lr(r.userIdFields,r.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(v.data)){const e=await m(v.data,a,n,o,i);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:t,error:a}=await d().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${s}: ${a.message}`);return t},async create(e){const t=dt(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:r,error:n}=await d().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={...dt(t),updated_at:(new Date).toISOString()},{data:r,error:n}=await d().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 d().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${s}: ${a.message}`)}}}const Ur=()=>{rr.clearManualLogout()},Vr=e=>e?.placeId||null,Br=e=>e?.placeName||null,Wr=e=>({placeId:Vr(e),placeName:Br(e)}),qr=class{static async initialize(){try{if(!rr.hasAllTokens()||!rr.areAllTokensValid())return rr.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=rr.getAccessToken(),a=rr.getIdToken();Ur();const r=this.extractUserFromIdToken(a),s=this.extractCompaniesFromIdToken(a),n=this.extractAliasFromAccessToken(t),o=rr.extractTokenData(),i=o?.alias;let l=null;if(i&&s.some(e=>e.alias===i))l=i;else{const e=rr.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);l=t?e:n||s[0]?.alias||null}!rr.isSupabaseTokenValid()&&l&&await xr.attemptRegeneration();let c=null;if(l){const e=rr.getCompanyId(l),t=s.find(e=>e.alias===l);t&&(c={id:e||t.id,name:t.name,alias:t.alias})}let d=null,u=null;if(r?.id&&l){const t=rr.getCompanyId(l);if(t)try{const e=(await Nr.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=Wr(e);d=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:s,selectedUnit:c,userId:r?.id||null,userAlias:r?.id||null,placeId:d,placeName:u,activePlaceId:d,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=pr(),{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=rr.generateOAuthState();rr.setOAuthState(e);const t=rr.generateOAuthNonce();rr.setOAuthNonce(t);const a=`${window.location.origin}/callback`,r=new URL(Cr.oauth.authUrl);r.searchParams.set("client_id",Cr.oauth.clientId),r.searchParams.set("response_type",Cr.oauth.responseType),r.searchParams.set("scope",Cr.oauth.scope),r.searchParams.set("redirect_uri",a),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),Er(),window.location.href=r.toString()}static async processCallback(){try{if(rr.hasAllTokens()){if(!rr.getValidSupabaseToken()){rr.getAccessToken();await xr.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");rr.setAccessToken(r),rr.setIdToken(s),Ur();const o=this.extractAliasFromAccessToken(r);if(o)rr.setSelectedAlias(o);else{const e=this.extractCompaniesFromIdToken(s);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");rr.setSelectedAlias(e[0].alias)}if(!await xr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return rr.clearOAuthState(),rr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){rr.setManualLogout(),rr.clearAll(),window.location.href="/login"}static decodeToken(e){return Qa.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}};xr.setLogoutCallback(()=>{qr.logout()});let Hr=qr;const Kr=t.createContext(void 0),Gr=({children:a})=>{const[r,s]=t.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=x.useQueryClient()}catch{}const[o,i]=t.useState(!1),[l,c]=t.useState(0),d=t.useCallback(e=>{s(t=>({...t,...e}))},[]),u=t.useCallback(e=>{s(t=>({...t,isLoading:e}))},[]),m=t.useCallback(()=>{s({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=t.useCallback(async e=>{try{u(!0);const a=rr.getAccessToken();if(!a)return;const s=await hr.generateToken(a,e.alias,void 0,!0);if(!s)return;rr.setSupabaseToken(s),rr.setSelectedAlias(e.alias);const o=rr.extractTokenData(),i=o?.alias||e.alias,l=o?.companyId||rr.getCompanyId(e.alias),c={id:l||e.id,name:e.name,alias:i};let m=null,p=null;if(r.user?.id&&i&&l)try{const e=(await Nr.fetchActiveUsersMap(i,l)).get(r.user.id);if(e){const t=Wr(e);m=t.placeId,p=t.placeName}}catch(t){}d({alias:i,selectedUnit:c,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{u(!1)}},[d,n,u,r.user]),h=t.useCallback(async()=>await Hr.processCallback(),[]),f=t.useCallback(async()=>{Hr.logout(),m(),n&&await n.clear()},[m,n]),g=t.useCallback(e=>{i(e)},[]),v=t.useCallback(()=>{c(e=>e+1)},[]),b=t.useCallback(()=>{c(e=>e+1)},[]);t.useEffect(()=>{if(!r.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(rr.areAllTokensValid()||e&&f())},6e5);return()=>{e=!1,clearInterval(t)}},[r.isAuthenticated,f]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Hr.initialize();if(!e)return;t&&t.isAuthenticated?d({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&&u(!1)}catch(t){e&&(vr.handleError(t),u(!1))}})(),()=>{e=!1}},[d,u,f]);const y=t.useMemo(()=>({...r,logout:f,processCallback:h,switchUnit:p,availableUnits:r.companies,isSearchVisible:o,setSearchVisible:g,clearSearch:v,refreshData:b}),[r.user,r.companies,r.alias,r.isAuthenticated,r.isLoading,r.selectedUnit,r.userId,r.userAlias,r.placeId,r.placeName,r.activePlaceId,r.activePlaceName,f,h,p,o,g,v,b]);return e.jsx(Kr.Provider,{value:y,children:a})},Qr=()=>{const e=t.useContext(Kr);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Xr({queryKey:e,service:a,entityName:r,searchFields:s,additionalFilters:n={},onSuccess:o}){const[l,c]=v.useSearchParams(),d=x.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Qr(),h=t.useCallback(t=>{const a=`${e}_${t}`,r=l.get(a);return r||(l.get(t)||"")},[l,e]),f=h("search"),g=h("sortField")||kr.sorting.defaultField,b=h("sortDirection")||kr.sorting.defaultDirection,y=parseInt(h("page")||"1"),w=parseInt(h("limit")||String(kr.pagination.defaultPageSize)),j=f,N=t.useMemo(()=>({search:j,sortField:g,sortDirection:b,page:y,limit:w,...n}),[j,g,b,y,w,n]),C=t.useCallback(()=>a.getAll(N),[a,N]),k=x.useQuery({queryKey:[e,u,m,N],queryFn:C,enabled:!!u&&p});if(!k)throw new Error(`useCrud: Query initialization failed for "${r}". Ensure QueryClientProvider is configured in your app root.`);const S=x.useMutation({mutationFn:a.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(Tr.success.created(r)),o?.()},onError:e=>{i.toast.error(`${Tr.error.create(r)}: ${e.message}`)}}),E=x.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(Tr.success.updated(r)),o?.()},onError:e=>{i.toast.error(`${Tr.error.update(r)}: ${e.message}`)}}),P=x.useMutation({mutationFn:a.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(Tr.success.deleted(r))},onError:e=>{i.toast.error(`${Tr.error.delete(r)}: ${e.message}`)}}),R=t.useCallback(t=>{const a={...Object.fromEntries(l)};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,c(a)},[l,c,e]),_=t.useCallback(e=>{R({search:e,page:1})},[R]),T=t.useCallback(e=>{R({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,R]),A=t.useCallback(e=>{R({page:e})},[R]),M=t.useCallback(e=>{R({limit:e,page:1})},[R]),I=t.useCallback(()=>{const t=Object.fromEntries(l),a=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));c(r)},[c,l,e]),[L,O]=t.useState([]),D=t.useCallback(e=>{O(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),F=t.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];O(t=>t.length===e.length?[]:e)},[k?.data?.data]),z=t.useCallback(()=>{O([])},[]),$=t.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&L.length===e.length},[L,k?.data?.data]),U=x.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{d.invalidateQueries({queryKey:[e]}),i.toast.success(`${a.length} ${r}(s) deletado(s) com sucesso`),z()},onError:e=>{i.toast.error(`Erro ao deletar itens: ${e.message}`)}}),V=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?E.mutate({id:e.id,data:a}):S.mutate({...a,alias:u})},[u,S,E]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||kr.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:E?.isPending??!1,isDeleting:P?.isPending??!1,error:k?.error||null,searchTerm:f,sortField:g,sortDirection:b,currentPage:y,itemsPerPage:w,queryKey:e,createEntity:S.mutate,updateEntity:(e,t)=>E.mutate({id:e,data:t}),deleteEntity:P.mutate,save:V,handleSearch:_,handleSort:T,handlePageChange:A,handleItemsPerPageChange:M,clearFilters:I,refetch:k.refetch,selectedIds:L,selectItem:D,selectAll:F,clearSelection:z,isAllSelected:$,bulkDelete:e=>U.mutateAsync(e),isBulkDeleting:U.isPending}}const Jr=G.forwardRef(({className:t,...a},r)=>e.jsx("table",{ref:r,className:ct("w-full caption-bottom text-sm table-fixed",t),...a}));Jr.displayName="Table";const Yr=G.forwardRef(({className:t,...a},r)=>e.jsx("thead",{ref:r,className:ct("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));Yr.displayName="TableHeader";const Zr=G.forwardRef(({className:t,...a},r)=>e.jsx("tbody",{ref:r,className:ct("[&_tr:last-child]:border-0",t),...a}));Zr.displayName="TableBody";const es=G.forwardRef(({className:t,...a},r)=>e.jsx("tfoot",{ref:r,className:ct("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));es.displayName="TableFooter";const ts=G.forwardRef(({className:t,...a},r)=>e.jsx("tr",{ref:r,className:ct("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));ts.displayName="TableRow";const as=G.forwardRef(({className:t,...a},r)=>e.jsx("th",{ref:r,className:ct("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}));as.displayName="TableHead";const rs=G.forwardRef(({className:t,...a},r)=>e.jsx("td",{ref:r,className:ct("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));rs.displayName="TableCell";const ss=G.forwardRef(({className:t,...a},r)=>e.jsx("caption",{ref:r,className:ct("mt-4 text-sm text-muted-foreground",t),...a}));function ns({rows:t=5,columns:a=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(ba,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,r)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(ba,{className:"h-4 w-20"},a))})},r))})]})})}function os({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(xt,{children:[e.jsxs(vt,{children:[e.jsx(ba,{className:"h-4 w-3/4"}),e.jsx(ba,{className:"h-3 w-1/2"})]}),e.jsx(wt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ba,{className:"h-3 w-full"}),e.jsx(ba,{className:"h-3 w-2/3"})]})})]},a))})}ss.displayName="TableCaption";const is={default:l.FileX,search:l.Search,error:l.AlertCircle};function ls({icon:t,title:a,description:r,action:s,className:n,variant:o="default"}){const i=t?()=>t:is[o];return e.jsxs("div",{className:ct("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),r&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:r}),s&&e.jsx(mt,{onClick:s.onClick,variant:"outline",children:s.label})]})}const cs=te.Provider,ds=te.Root,us=te.Trigger,ms=G.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e.jsx(te.Content,{ref:s,sideOffset:a,className:ct("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}));function ps({children:t,className:a}){const r=G.useRef(null),[s,n]=G.useState(!1);G.useEffect(()=>{const e=()=>{const e=r.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return r.current&&t.observe(r.current),()=>t.disconnect()},[t]);const o=e.jsx("div",{ref:r,className:`truncate w-full max-w-full ${a||""}`,children:t});return s?e.jsx(cs,{delayDuration:300,children:e.jsxs(ds,{children:[e.jsx(us,{asChild:!0,children:o}),e.jsx(ms,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):o}ms.displayName=te.Content.displayName;const hs=G.forwardRef(({direction:t,onMouseDown:a,isDragging:r,className:s},n)=>{const o="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:ct("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],r&&"bg-primary/30",s),children:e.jsx("div",{className:ct("rounded-full bg-border transition-colors group-hover:bg-primary",r&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});hs.displayName="TableResizeHandle";const fs=ae.Root,gs=ae.Trigger,xs=ae.Group,vs=ae.Portal,bs=ae.Sub,ys=ae.RadioGroup,ws=G.forwardRef(({className:t,inset:a,children:r,...s},n)=>e.jsxs(ae.SubTrigger,{ref:n,className:ct("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...s,children:[r,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ws.displayName=ae.SubTrigger.displayName;const js=G.forwardRef(({className:t,...a},r)=>e.jsx(ae.SubContent,{ref:r,className:ct("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}));js.displayName=ae.SubContent.displayName;const Ns=G.forwardRef(({className:t,sideOffset:a=4,...r},s)=>e.jsx(ae.Portal,{children:e.jsx(ae.Content,{ref:s,sideOffset:a,className:ct("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 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),...r})}));Ns.displayName=ae.Content.displayName;const Cs=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(ae.Item,{ref:s,className:ct("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}));Cs.displayName=ae.Item.displayName;const ks=G.forwardRef(({className:t,children:a,checked:r,...s},n)=>e.jsxs(ae.CheckboxItem,{ref:n,className:ct("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",t),checked:r,...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ae.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));ks.displayName=ae.CheckboxItem.displayName;const Ss=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(ae.RadioItem,{ref:s,className:ct("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",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ae.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Ss.displayName=ae.RadioItem.displayName;const Es=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(ae.Label,{ref:s,className:ct("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...r}));Es.displayName=ae.Label.displayName;const Ps=G.forwardRef(({className:t,...a},r)=>e.jsx(ae.Separator,{ref:r,className:ct("-mx-1 my-1 h-px bg-muted",t),...a}));Ps.displayName=ae.Separator.displayName;const Rs=({className:t,...a})=>e.jsx("span",{className:ct("ml-auto text-xs tracking-widest opacity-60",t),...a});Rs.displayName="DropdownMenuShortcut";const _s=re.Root,Ts=re.Trigger,As=re.Group,Ms=re.Portal,Is=re.Sub,Ls=re.RadioGroup,Os=G.forwardRef(({className:t,inset:a,children:r,...s},n)=>e.jsxs(re.SubTrigger,{ref:n,className:ct("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",a&&"pl-8",t),...s,children:[r,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Os.displayName=re.SubTrigger.displayName;const Ds=G.forwardRef(({className:t,...a},r)=>e.jsx(re.SubContent,{ref:r,className:ct("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}));Ds.displayName=re.SubContent.displayName;const Fs=G.forwardRef(({className:t,...a},r)=>e.jsx(re.Portal,{children:e.jsx(re.Content,{ref:r,className:ct("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})}));Fs.displayName=re.Content.displayName;const zs=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(re.Item,{ref:s,className:ct("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}));zs.displayName=re.Item.displayName;const $s=G.forwardRef(({className:t,children:a,checked:r,...s},n)=>e.jsxs(re.CheckboxItem,{ref:n,className:ct("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",t),checked:r,...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(re.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));$s.displayName=re.CheckboxItem.displayName;const Us=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(re.RadioItem,{ref:s,className:ct("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",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(re.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Us.displayName=re.RadioItem.displayName;const Vs=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(re.Label,{ref:s,className:ct("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...r}));Vs.displayName=re.Label.displayName;const Bs=G.forwardRef(({className:t,...a},r)=>e.jsx(re.Separator,{ref:r,className:ct("-mx-1 my-1 h-px bg-border",t),...a}));Bs.displayName=re.Separator.displayName;const Ws=({className:t,...a})=>e.jsx("span",{className:ct("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Ws.displayName="ContextMenuShortcut";const qs=({onEdit:t,onDelete:a,onToggleStatus:r,isActive:s=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:c}=Ba(),d=[];if(t){const e={icon:l.Edit,label:c("edit"),onClick:t};d.push(e)}if(o.forEach(e=>{d.push(e)}),r){const e={icon:s?l.PowerOff:l.Power,label:c(s?"deactivate":"activate"),onClick:r};d.push(e)}if(n&&a){const e={icon:l.Trash2,label:c("delete"),onClick:a,destructive:!0};d.push(e)}const u="dropdown"===i?Cs:zs;return e.jsx(e.Fragment,{children:d.map((t,a)=>e.jsxs(u,{onClick:t.onClick,className:ct("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},Hs=({onEdit:t,onDelete:a,canDelete:r=!0,onToggleStatus:s,isActive:n=!0,customActions:o=[]})=>e.jsxs(fs,{children:[e.jsx(gs,{asChild:!0,children:e.jsx(mt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Ns,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(qs,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:s?e=>{e?.stopPropagation(),s?.()}:void 0,isActive:n,canDelete:r&&!!a,customActions:o,renderAs:"dropdown"})})]}),Ks=150;function Gs({columns:e,storageKey:a,onResize:r,enabled:s=!0}){const[n,o]=t.useState(()=>{if(!s||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Ks,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Ks,e),{})}),[i,l]=t.useState(!1),[c,d]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,t)=>{s&&(t.preventDefault(),t.stopPropagation(),l(!0),d(e),u.current=t.clientX,m.current=n[e]??Ks)},[s,n]);t.useEffect(()=>{if(!i||!c)return;const t=e.find(e=>e.key===c),s=t?.minWidth??60,n=t?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(s,Math.min(n,m.current+t));o(e=>{const t={...e,[c]:a};return r?.(t),t})},h=()=>{l(!1),d(null),a&&o(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,c,e,a,r]),t.useEffect(()=>{i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[i]);const h=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Ks,e),{});o(t),a&&localStorage.removeItem(a),r?.(t)},[e,a,r]);return{columnWidths:n,isDragging:i,activeColumn:c,handleMouseDown:p,resetWidths:h}}function Qs({rowIds:e,defaultHeight:a=48,minHeight:r=32,maxHeight:s=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,c]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[d,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),f=t.useRef(0),g=t.useCallback(e=>l[e]??a,[l,a]),x=t.useCallback((e,t)=>{i&&(t.preventDefault(),t.stopPropagation(),u(!0),p(e),h.current=t.clientY,f.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!d||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(r,Math.min(s,f.current+t));c(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&c(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[d,m,r,s,n,o]),t.useEffect(()=>{d?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[d]);const v=t.useCallback(()=>{c({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:d,activeRow:m,handleMouseDown:x,resetHeights:v,getRowHeight:g}}const Xs=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(ta,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),Js=({manager:a,columns:r,onEdit:s,onView:n,onToggleStatus:o,onDelete:i,renderActions:c,customRowActions:d,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:f=[],hideActionBar:g=!1,enableColumnResize:x=!1,enableRowResize:v=!1,resizeStorageKey:b})=>{const{t:y}=Ba(),{setSearchVisible:w}=Qr(),[j,N]=t.useState(!1);t.useEffect(()=>(w(!0),()=>w(!1)),[w]),t.useEffect(()=>{const e=()=>N(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:E}=Gs({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:b?`${b}-columns`:void 0,enabled:x}),{isDragging:P,activeRow:R,handleMouseDown:_,getRowHeight:T}=Qs({rowIds:a.entities.map(e=>e.id),storageKey:b?`${b}-rows`:void 0,enabled:v}),A=t.useMemo(()=>(()=>{if(x)return r.map(e=>{const t=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});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,x,C]),M=!g&&(m||f.length>0);return j?a.isLoading?e.jsx(os,{count:3}):0===a.entities.length?e.jsx(ls,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(mt,{onClick:m,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),p||y("new")]}),f.map((t,a)=>{const r=t.icon;return e.jsxs(mt,{onClick:t.action,variant:t.variant||"outline",children:[r&&e.jsx(r,{size:16,className:"mr-2"}),t.label]},a)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(_s,{children:[e.jsx(Ts,{asChild:!0,children:e.jsx(xt,{className:ct("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):s?.(t)},children:e.jsx(wt,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Xs,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[r.map(a=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(s||n||c)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(t):e.jsx(Hs,{onEdit:s?()=>{s(t)}:void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})]})})})}),e.jsx(Fs,{className:"w-[160px]",children:e.jsx(qs,{onEdit:s?()=>s(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(mt,{onClick:m,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),p||y("new")]}),f.map((t,a)=>{const r=t.icon;return e.jsxs(mt,{onClick:t.action,variant:t.variant||"outline",children:[r&&e.jsx(r,{size:16,className:"mr-2"}),t.label]},a)})]})}),a.isLoading?e.jsx(ns,{rows:5,columns:r.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(Jr,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),A.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Yr,{children:e.jsxs(ts,{children:[u&&e.jsx(as,{className:"w-[50px]",children:e.jsx(Xs,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),r.map(t=>{const r=x&&!1!==t.resizable,s=S===String(t.key);return e.jsxs(as,{className:ct(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),r&&e.jsx(hs,{direction:"horizontal",onMouseDown:e=>E(String(t.key),e),isDragging:s})]},String(t.key));var n}),e.jsx(as,{className:"w-[50px] text-center",children:y("actions")})]})}),e.jsx(Zr,{children:0===a.entities.length?e.jsx(ts,{children:e.jsx(rs,{colSpan:u?r.length+2:r.length+1,className:"h-32",children:e.jsx(ls,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):a.entities.map(t=>e.jsxs(_s,{children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(ts,{className:ct("cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):s?.(t)},children:[u&&e.jsx(rs,{onClick:e=>e.stopPropagation(),children:e.jsx(Xs,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),r.map(a=>e.jsx(rs,{className:a.className,children:e.jsx(ps,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(rs,{className:"text-center",children:c?c(t):e.jsx(Hs,{onEdit:s?()=>s(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})}),e.jsx(Fs,{className:"w-[160px]",children:e.jsx(qs,{onEdit:s?()=>s(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id))})]})})})]})};function Ys(e,a,r,s){const[n,o]=t.useState({}),[i,l]=t.useState({}),c=t.useMemo(()=>e,[e]),d=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let 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){}}};t.useEffect(()=>{if(!s)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(c),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);d(e)&&(t=e.toISOString().split("T")[0])}else d(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),r&&r(n)},[c,a,r,s]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},f=()=>{const e=h(c),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const s={...a,[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(c).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,s);return r&&r(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(c).find(t=>t.name===e);if(a){const r=p(a,t,n);r&&l(t=>({...t,[e]:r}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const Zs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],en=({value:t="#3b82f6",onChange:a,label:r})=>e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(gt,{children:r}),e.jsxs(la,{children:[e.jsx(ca,{asChild:!0,children:e.jsxs(mt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e.jsx(da,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(gt,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(ht,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(gt,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Zs.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),tn=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(se.Root,{ref:s,className:ct("relative overflow-hidden",t),...r,children:[e.jsx(se.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(an,{}),e.jsx(se.Corner,{})]}));tn.displayName=se.Root.displayName;const an=G.forwardRef(({className:t,orientation:a="vertical",...r},s)=>e.jsx(se.ScrollAreaScrollbar,{ref:s,orientation:a,className:ct("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.jsx(se.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));an.displayName=se.ScrollAreaScrollbar.displayName;const rn={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},sn=({value:a="Star",onChange:r,label:s})=>{const{t:n}=Ba(),[o,i]=t.useState(""),c=Object.entries(rn).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),d=rn[a]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(gt,{children:s}),e.jsxs(la,{children:[e.jsx(ca,{asChild:!0,children:e.jsxs(mt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(da,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(gt,{htmlFor:"icon-search",children:n("search")}),e.jsx(ht,{id:"icon-search",placeholder:n("search"),value:o,onChange:e=>i(e.target.value)})]}),e.jsx(tn,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:c.map(([t,s])=>e.jsx("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.jsx(s,{className:"h-4 w-4"})},t))})})]})})]})]})},nn=G.forwardRef(({className:t,...a},r)=>e.jsx(ne.Root,{className:ct("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.jsx(ne.Thumb,{className:ct("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")})}));nn.displayName=ne.Root.displayName;const on=(e={})=>{const{user:t,alias:a}=Qr(),{enabled:r=!0}=e;return x.useQuery({queryKey:["qualiex-users",a],queryFn:()=>Nr.getUsers(a),enabled:r&&!!a&&!!t,retry:2,retryDelay:1e3})},ln=({value:a,onChange:r,multiple:s=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:c,className:d,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:g=!0,popoverContainer:x,onOpen:v,onClose:b})=>{const{t:y}=Ba(),{data:w=[],isLoading:j,error:N}=on({enabled:m}),C=t.useMemo(()=>f?w.filter(f):w,[w,f]),k=t.useCallback(e=>{if("custom"===p&&h)return h(e);const t=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[p,h]);return e.jsx(Ka,{multiple:s,value:a??(s?[]:""),onChange:r,options:C,isLoading:j,error:N,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:k,placeholder:i||y("search_placeholder"),searchPlaceholder:y("search_placeholder"),emptyMessage:y("no_results"),label:n,required:o,icon:l,maxDisplayedBadges:c,disabled:u,className:d,sortOptions:g,popoverContainer:x,onOpen:v,onClose:b})};function cn({title:a,sections:r,initialData:s,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d}){const{t:u}=Ba(),[m,p]=t.useState(r?.[0]?.id||""),h=t.useRef(null),[f,g]=t.useState(null),x=t.useCallback(e=>{h.current=e,g(e)},[]),v=t.useMemo(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:b,errors:y,updateField:w,handleSubmit:j}=Ys(v,s,void 0,i),N=t.useMemo(()=>r&&Array.isArray(r)?r.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[r,b]),C=t.useMemo(()=>{const e=N.find(e=>e.id===m);if(e&&!e.disabled)return m;const t=N.find(e=>!e.disabled);return t?.id||m},[N,m]);t.useEffect(()=>{C!==m&&p(C)},[C,m]);const k=N.find(e=>e.id===C),S=t=>{const a=(t.computedValue,b[t.name]),r=void 0!==a?a:"",s=y[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=a?ct("space-y-2 w-full",t.wrapperClassName):ct("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:o,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>S(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ln,{value:r||"",onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:s?"border-destructive":""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(aa,{id:t.name,value:r||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${s?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(qt,{value:String(r),onValueChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(Gt,{className:`${s?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(Kt,{placeholder:t.placeholder})}),e.jsx(Jt,{children:t.options?.map(t=>e.jsx(Zt,{value:t.value,children:t.label},t.value))})]}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ka,{options:t.options||[],value:Array.isArray(r)?r:[],onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:s,popoverContainer:f,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:"date",value:String(r),onChange:e=>w(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:ct("w-full",s?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:"color",value:r||t.defaultValue||"#000000",onChange:e=>w(t.name,e.target.value),className:"h-10"}),s&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(en,{value:r||t.defaultValue||"#3b82f6",onChange:e=>w(t.name,e)}),s&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(sn,{value:r||t.defaultValue||"Star",onChange:e=>w(t.name,e)}),s&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:s})]},t.name);case"custom":if(!t.component)return null;const i=t.component,l="function"==typeof t.componentProps?t.componentProps(b):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:r,onChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:s,popoverContainer:f,...l}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:"number",value:null!=r?String(r):"",onChange:e=>{const a=e.target.value,r=""===a?null:Number(a);w(t.name,r)},placeholder:t.placeholder,disabled:t.disabled,className:`${s?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(ta,{id:t.name,checked:!!r,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),e.jsxs(gt,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(nn,{id:t.name,checked:!!r,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),s&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:s})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:"text",value:r||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${s?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name)}},E=t.useCallback(()=>{if(!k)return null;if(k.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(k.component){const t=k.component;return e.jsx(t,{formData:b,updateField:w,errors:y,users:d,disabled:k.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:k.fields.map(S)})},[k,b,w,y,d,S]),P=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[N.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:N.map(t=>e.jsx(mt,{variant:C===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=N.find(t=>t.id===e);t&&!t.disabled&&p(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:u("loading")})}):e.jsxs("form",{onSubmit:j(n),className:"space-y-3 md:space-y-4",children:[E(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(mt,{type:"button",variant:"outline",onClick:o,children:u("cancel")}),e.jsx(mt,{type:"submit",disabled:c,children:l||u("save")})]})]})})]});return e.jsx(Ct,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(_t,{ref:x,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Tt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(It,{children:a}),e.jsx(Lt,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),P]})})}function dn({currentPage:t,totalPages:a,totalItems:r,itemsPerPage:s,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const c=(t-1)*s+1,d=Math.min(t*s,r);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(qt,{value:String(s),onValueChange:e=>o(Number(e)),children:[e.jsx(Gt,{className:"h-8 w-[70px]",children:e.jsx(Kt,{})}),e.jsxs(Jt,{children:[e.jsx(Zt,{value:"10",children:"10"}),e.jsx(Zt,{value:"25",children:"25"}),e.jsx(Zt,{value:"50",children:"50"}),e.jsx(Zt,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",d," de ",r," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(mt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(mt,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(mt,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(mt,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function un({manager:t}){return e.jsx(dn,{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 mn=({selectedCount:t,onClearSelection:a,onBulkDelete:r,customActions:s=[],isLoading:n=!1})=>{const{t:o}=Ba();return e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:o("selected_count",{count:t})}),e.jsxs(mt,{variant:"ghost",size:"sm",onClick:a,className:"h-7 px-2",children:[e.jsx(l.X,{size:14,className:"mr-1"}),o("clear")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.map((t,a)=>{const r=t.icon;return e.jsxs(mt,{variant:t.variant||"outline",size:"sm",onClick:()=>t.action([]),disabled:n,className:"h-7",children:[r&&e.jsx(r,{size:14,className:"mr-1"}),t.label]},a)}),r&&e.jsxs(mt,{variant:"destructive",size:"sm",onClick:r,disabled:n,className:"h-7",children:[e.jsx(l.Trash2,{size:14,className:"mr-1"}),o("delete")]})]})]})},pn={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},hn={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},fn={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function gn({children:t,direction:a="column",gap:r="md",align:s="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:ct("flex","column"===a?"flex-col":"flex-row",pn[r],hn[s],fn[n],o&&"flex-wrap",i),children:t})}function xn({manager:t,filters:a,inline:r=!1}){const{t:s}=Ba(),{isSearchVisible:n}=Qr(),o=t.searchTerm,i=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!n&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(ht,{placeholder:s("search"),value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs("select",{value:t.value||"",onChange:e=>t.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:[t.placeholder&&e.jsx("option",{value:"",children:t.placeholder}),t.options.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const s=t.component;return e.jsx("div",{className:r?"":"w-full sm:w-auto",children:e.jsx(s,{...t.props})},`custom-${a}`)}),o&&e.jsxs(mt,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),s("clear")]})]});return r?e.jsx("div",{className:"flex items-center gap-2",children:i}):e.jsx(gn,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(gn,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function vn({manager:a,config:r,formSections:s,onSave:n,onToggleStatus:o,defaultSort:i}){a&&a.queryKey;const{t:c}=Ba(),{setSearchVisible:d}=Qr(),[u,m]=v.useSearchParams(),[p,h]=t.useState(!1),[f,g]=t.useState(null),[x,b]=t.useState({isOpen:!1,entityId:null,entityName:""}),[y,w]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(d(!0),()=>{d(!1)}),[d]),t.useEffect(()=>{if(i&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(t)){const a=Object.fromEntries(u);a[e]=i.column,a[t]=i.direction,m(a)}}},[]);const j=()=>{b({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[r.enableBulkActions&&a.selectedIds.length>0&&e.jsx(mn,{selectedCount:a.selectedIds.length,onClearSelection:a.clearSelection,onBulkDelete:r.bulkActions&&r.bulkActions.length>0?void 0:()=>{w({isOpen:!0,count:a.selectedIds.length})},customActions:r.bulkActions,isLoading:a.isBulkDeleting}),e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(mt,{onClick:()=>{r.onNew?r.onNew():(g(null),h(!0))},children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),c("new")]}),r.customActions?.map((t,a)=>e.jsxs(mt,{onClick:t.action,variant:t.variant||"outline",children:[t.icon&&e.jsx(t.icon,{size:16,className:"mr-2"}),t.label]},a))]}),r.filters&&r.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(xn,{manager:a,filters:r.filters,inline:!0})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:r.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:r.customListView(a.entities,a)}):e.jsx(Js,{manager:a,columns:r.columns,onEdit:e=>{r.onEdit?r.onEdit(e):(g(e),h(!0))},onDelete:e=>{b({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:o,enableBulkActions:r.enableBulkActions,customRowActions:r.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(un,{manager:a})}),!r.useCustomRouting&&e.jsx(cn,{open:p,title:f?`Editar ${r.entityName}`:`Novo ${r.entityName}`,sections:s,initialData:f||void 0,onSubmit:e=>{n(e),h(!1),g(null)},onCancel:()=>{h(!1),g(null)},isLoading:a.isLoading,submitButtonText:c(f?"update":"create")}),e.jsx(Ct,{open:x.isOpen,onOpenChange:j,children:e.jsxs(_t,{size:"sm",children:[e.jsx(Tt,{showSeparator:!0,children:e.jsx(It,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:x.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Mt,{children:[e.jsx(mt,{variant:"outline",onClick:j,children:"Cancelar"}),e.jsx(mt,{variant:"destructive",onClick:()=>{x.entityId&&(a.deleteEntity(x.entityId),b({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(Ct,{open:y.isOpen,onOpenChange:()=>w({isOpen:!1,count:0}),children:e.jsxs(_t,{size:"sm",children:[e.jsx(Tt,{showSeparator:!0,children:e.jsx(It,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:y.count})," ",1===y.count?r.entityName:r.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Mt,{children:[e.jsx(mt,{variant:"outline",onClick:()=>w({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(mt,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),w({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function bn(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 yn(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const wn=G.forwardRef(({className:t,value:a,...r},s)=>e.jsx(oe.Root,{ref:s,className:ct("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...r,children:e.jsx(oe.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));function jn({steps:t,currentStepIndex:a,onStepClick:r,className:s}){return e.jsx("div",{className:ct("flex items-center justify-between mb-6",s),children:t.map((a,s)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:ct("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",a.isActive&&"border-primary bg-primary text-primary-foreground",a.isCompleted&&"border-primary bg-primary text-primary-foreground",!a.isActive&&!a.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",r&&!a.isDisabled&&"cursor-pointer hover:border-primary/50",a.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>r&&!a.isDisabled&&r(s),role:r&&!a.isDisabled?"button":void 0,tabIndex:r&&!a.isDisabled?0:void 0,"aria-label":`${a.label} - ${a.isCompleted?"Completo":a.isActive?"Atual":"Pendente"}`,children:a.isCompleted?e.jsx(l.Check,{className:"w-5 h-5"}):s+1}),s<t.length-1&&e.jsx("div",{className:ct("flex-1 h-0.5 mx-2 transition-colors",a.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},a.id))})}function Nn({steps:t,currentStepIndex:a,onStepClick:r,className:s}){return e.jsx("div",{className:ct("flex items-center gap-2 mb-6 overflow-x-auto",s),children:t.map((a,s)=>e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsxs("div",{className:ct("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",a.isActive&&"bg-primary text-primary-foreground font-medium",a.isCompleted&&"bg-primary/10 text-primary",!a.isActive&&!a.isCompleted&&"bg-muted text-muted-foreground",r&&!a.isDisabled&&"cursor-pointer hover:bg-primary/20",a.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>r&&!a.isDisabled&&r(s),role:r&&!a.isDisabled?"button":void 0,tabIndex:r&&!a.isDisabled?0:void 0,"aria-label":`${a.label} - ${a.isCompleted?"Completo":a.isActive?"Atual":"Pendente"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:s+1}),e.jsx("span",{className:"text-sm",children:a.label}),a.isCompleted&&e.jsx(l.Check,{className:"w-4 h-4 ml-1"})]}),s<t.length-1&&e.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},a.id))})}function Cn({steps:t,currentStepIndex:a,className:r}){const s=t[a],n=(a+1)/t.length*100;return e.jsxs("div",{className:ct("mb-6 space-y-2",r),children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Etapa ",a+1," de ",t.length]}),e.jsx("span",{className:"font-medium",children:s?.label})]}),e.jsx(wn,{value:n,className:"h-2"})]})}function kn({isFirstStep:t,isLastStep:a,canGoNext:r,canGoPrevious:s,isLoading:n,onPrevious:o,onNext:i,onSubmit:l,previousButtonText:c,nextButtonText:d,submitButtonText:u}){const{t:m}=Ba();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:s&&!t&&e.jsx(mt,{type:"button",variant:"outline",onClick:o,disabled:n,children:c||m("previous")})}),e.jsxs("div",{className:"flex gap-2",children:[r&&!a&&e.jsx(mt,{type:"button",onClick:i,disabled:n,children:d||m("next")}),a&&e.jsx(mt,{type:"button",onClick:l,disabled:n,children:n?m("saving"):u||m("save")})]})]})}wn.displayName=oe.Root.displayName;const Sn=r.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),En=G.forwardRef(({className:t,variant:a,...r},s)=>e.jsx("div",{ref:s,role:"alert",className:ct(Sn({variant:a}),t),...r}));En.displayName="Alert";const Pn=G.forwardRef(({className:t,...a},r)=>e.jsx("h5",{ref:r,className:ct("mb-1 font-medium leading-none tracking-tight",t),...a}));Pn.displayName="AlertTitle";const Rn=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("text-sm [&_p]:leading-relaxed",t),...a}));Rn.displayName="AlertDescription";const _n=t.createContext(void 0);function Tn({children:a,actions:r}){const[s,n]=t.useState({}),[o,i]=t.useState(r);return t.useEffect(()=>{i(r)},[r]),e.jsx(_n.Provider,{value:{metadata:s,setMetadata:n,clearMetadata:()=>n({}),headerActions:o,setHeaderActions:i},children:a})}function An(){const e=t.useContext(_n);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const Mn=(void 0).VITE_SUPABASE_URL,In=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Ln=null;var On=Object.defineProperty,Dn=(e,t,a)=>((e,t,a)=>t in e?On(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Fn=new class{constructor(){Dn(this,"cache",{}),Dn(this,"cacheTimestamps",new Map),Dn(this,"CACHE_TTL",3e5),Dn(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=(!Ln&&Mn&&In&&(Ln=g.createClient(Mn,In,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Ln),{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=pr(),{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=pr(),{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 zn=Object.defineProperty,$n=(e,t,a)=>((e,t,a)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Un="true"===(void 0).VITE_I18N_DEBUG_MODE;it.use(new class{constructor(e=!1){$n(this,"type","backend"),$n(this,"isDebugMode"),$n(this,"cache",new Map),$n(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=Fn.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){}}(Un)).use(Ta).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,t)=>Un?`[${e} ❌]`:`[⚠️ ${e}]`});const Vn=new class{async getUserPreferences(e,t){if(!rr.areAllTokensValid())return null;const a=pr();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=pr(),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=pr();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}}},Bn=t.createContext(void 0),Wn=({children:a})=>{const{user:r,alias:s}=Qr(),[n,o]=t.useState({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[i,l]=t.useState(!0);t.useEffect(()=>{(async()=>{if(r?.id&&s)try{const e=await Vn.getUserPreferences(r.id,s);e&&(o({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await it.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{l(!1)}else l(!1)})()},[r?.id,s]);const c=t.useCallback(async e=>{if(r?.id&&s)try{await Vn.updatePreferences(r.id,s,{locale:e}),o(t=>({...t,locale:e})),await it.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(t){throw t}},[r?.id,s]),d=t.useCallback(async e=>{if(r?.id&&s)try{await Vn.updatePreferences(r.id,s,{timezone:e}),o(t=>({...t,timezone:e}))}catch(t){throw t}},[r?.id,s]),u=t.useCallback(async e=>{if(r?.id&&s)try{await Vn.updatePreferences(r.id,s,{datetime_format:e}),o(t=>({...t,datetimeFormat:e}))}catch(t){throw t}},[r?.id,s]);return e.jsx(Bn.Provider,{value:{...n,setLocale:c,setTimezone:d,setDatetimeFormat:u,isLoading:i},children:a})},qn=()=>{const e=t.useContext(Bn);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Hn({children:a}){const{ready:r}=Ba(),[s,n]=t.useState(!0);return t.useEffect(()=>{r&&s&&n(!1)},[r,s]),s&&!r?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(oa,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:a})}const Kn=ie.Root,Gn=ie.CollapsibleTrigger,Qn=ie.CollapsibleContent;var Xn=Object.defineProperty,Jn=(e,t,a)=>((e,t,a)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class Yn extends t.Component{constructor(e){super(e),Jn(this,"copyErrorDetails",()=>{const e=or.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),i.toast.success("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((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if((void 0).DEV)throw e;or.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=or.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(xt,{className:"w-full max-w-2xl",children:[e.jsxs(vt,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(bt,{children:"Algo deu errado"})]}),e.jsxs(wt,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs(Kn,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Gn,{asChild:!0,children:e.jsxs(mt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Qn,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(tn,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:t.map((t,a)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(mt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(mt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Zn=le.Root,eo=G.forwardRef(({className:t,...a},r)=>e.jsx(le.Item,{ref:r,className:ct("border-b",t),...a}));eo.displayName="AccordionItem";const to=G.forwardRef(({className:t,children:a,...r},s)=>e.jsx(le.Header,{className:"flex",children:e.jsxs(le.Trigger,{ref:s,className:ct("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...r,children:[a,e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));to.displayName=le.Trigger.displayName;const ao=G.forwardRef(({className:t,children:a,...r},s)=>e.jsx(le.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.jsx("div",{className:ct("pb-4 pt-0",t),children:a})}));ao.displayName=le.Content.displayName;const ro=ce.Root,so=ce.Trigger,no=ce.Portal,oo=G.forwardRef(({className:t,...a},r)=>e.jsx(ce.Overlay,{className:ct("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}));oo.displayName=ce.Overlay.displayName;const io=G.forwardRef(({className:t,...a},r)=>e.jsxs(no,{children:[e.jsx(oo,{}),e.jsx(ce.Content,{ref:r,className:ct("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",t),...a})]}));io.displayName=ce.Content.displayName;const lo=({className:t,...a})=>e.jsx("div",{className:ct("flex flex-col space-y-2 text-center sm:text-left",t),...a});lo.displayName="AlertDialogHeader";const co=({className:t,...a})=>e.jsx("div",{className:ct("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});co.displayName="AlertDialogFooter";const uo=G.forwardRef(({className:t,...a},r)=>e.jsx(ce.Title,{ref:r,className:ct("text-lg font-semibold",t),...a}));uo.displayName=ce.Title.displayName;const mo=G.forwardRef(({className:t,...a},r)=>e.jsx(ce.Description,{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));mo.displayName=ce.Description.displayName;const po=G.forwardRef(({className:t,...a},r)=>e.jsx(ce.Action,{ref:r,className:ct(ut(),t),...a}));po.displayName=ce.Action.displayName;const ho=G.forwardRef(({className:t,...a},r)=>e.jsx(ce.Cancel,{ref:r,className:ct(ut({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));ho.displayName=ce.Cancel.displayName;const fo=G.forwardRef(({className:t,...a},r)=>e.jsx(de.Root,{ref:r,className:ct("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));fo.displayName=de.Root.displayName;const go=G.forwardRef(({className:t,...a},r)=>e.jsx(de.Image,{ref:r,className:ct("aspect-square h-full w-full",t),...a}));go.displayName=de.Image.displayName;const xo=G.forwardRef(({className:t,...a},r)=>e.jsx(de.Fallback,{ref:r,className:ct("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));xo.displayName=de.Fallback.displayName;const vo=G.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));vo.displayName="Breadcrumb";const bo=G.forwardRef(({className:t,...a},r)=>e.jsx("ol",{ref:r,className:ct("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));bo.displayName="BreadcrumbList";const yo=G.forwardRef(({className:t,...a},r)=>e.jsx("li",{ref:r,className:ct("inline-flex items-center gap-1.5",t),...a}));yo.displayName="BreadcrumbItem";const wo=G.forwardRef(({asChild:t,className:r,...s},n)=>{const o=t?a.Slot:"a";return e.jsx(o,{ref:n,className:ct("transition-colors hover:text-foreground",r),...s})});wo.displayName="BreadcrumbLink";const jo=G.forwardRef(({className:t,...a},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:ct("font-normal text-foreground",t),...a}));jo.displayName="BreadcrumbPage";const No=({children:t,className:a,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:ct("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...r,children:t??e.jsx(l.ChevronRight,{})});No.displayName="BreadcrumbSeparator";const Co=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:ct("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Co.displayName="BreadcrumbEllipsis";const ko=r.cva("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"}}),So=G.forwardRef(({className:t,orientation:a,...r},s)=>e.jsx("div",{ref:s,className:ct(ko({orientation:a}),t),...r}));function Eo(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function Po(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 Ro(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 o=n[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let c;c=e.valueCallback?e.valueCallback(l):l,c=a.valueCallback?a.valueCallback(c):c;return{value:c,rest:t.slice(o.length)}}}function _o(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 o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(s.length)}}}So.displayName="ButtonGroup";const To={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"}},Ao={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Mo={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:Po({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Po({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:Po({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:Po({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:Po({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"})},Io={ordinalNumber:_o({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ro({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:Ro({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:Ro({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:Ro({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:Ro({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"})},Lo={code:"en-US",formatDistance:(e,t,a)=>{let r;const s=To[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:Eo({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Eo({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:Eo({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,t,a,r)=>Ao[e],localize:Mo,match:Io,options:{weekStartsOn:0,firstWeekContainsDate:1}},Oo={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"}},Do={date:Eo({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:Eo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Eo({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Fo={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"},zo={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"},$o={ordinalNumber:(e,t)=>Number(e)+"º",era:Po({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Po({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:Po({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:Po({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:Po({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"})},Uo={ordinalNumber:_o({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Ro({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:Ro({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ro({matchPatterns:{narrow:/^[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:Ro({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:Ro({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"})},Vo={code:"es",formatDistance:(e,t,a)=>{let r;const s=Oo[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:Do,formatRelative:(e,t,a,r)=>1!==t.getHours()?zo[e]:Fo[e],localize:$o,match:Uo,options:{weekStartsOn:1,firstWeekContainsDate:1}},Bo={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"}},Wo={date:Eo({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:Eo({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Eo({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},qo={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"},Ho={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:Po({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Po({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:Po({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:Po({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:Po({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"})},Ko={ordinalNumber:_o({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ro({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:Ro({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ro({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:Ro({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:Ro({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})},Go={code:"pt-BR",formatDistance:(e,t,a)=>{let r;const s=Bo[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:Wo,formatRelative:(e,t,a,r)=>{const s=qo[e];return"function"==typeof s?s(t):s},localize:Ho,match:Ko,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Qo({className:t,classNames:a,showOutsideDays:r=!0,...s}){return e.jsx(R.DayPicker,{showOutsideDays:r,className:ct("p-3 pointer-events-auto",t),locale:Go,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:ct(ut({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:ct(ut({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.jsx(l.ChevronLeft,{className:"h-4 w-4"}),IconRight:({...t})=>e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...s})}Qo.displayName="Calendar";const Xo={Root:function({children:t,className:a}){return e.jsx("div",{className:ct("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:r}){return e.jsx(xt,{className:ct("transition-colors",a&&"cursor-pointer hover:bg-muted/50",r),onClick:a,children:e.jsx(wt,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:r}){return e.jsxs("div",{className:ct("flex justify-between items-center text-sm",r),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const Jo=({shouldScaleBackground:t=!0,...a})=>e.jsx(_.Drawer.Root,{shouldScaleBackground:t,...a});Jo.displayName="Drawer";const Yo=_.Drawer.Trigger,Zo=_.Drawer.Portal,ei=_.Drawer.Close,ti=G.forwardRef(({className:t,...a},r)=>e.jsx(_.Drawer.Overlay,{ref:r,className:ct("fixed inset-0 z-50 bg-black/80",t),...a}));ti.displayName=_.Drawer.Overlay.displayName;const ai=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(Zo,{children:[e.jsx(ti,{}),e.jsxs(_.Drawer.Content,{ref:s,className:ct("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...r,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));ai.displayName="DrawerContent";const ri=({className:t,...a})=>e.jsx("div",{className:ct("grid gap-1.5 p-4 text-center sm:text-left",t),...a});ri.displayName="DrawerHeader";const si=({className:t,...a})=>e.jsx("div",{className:ct("mt-auto flex flex-col gap-2 p-4",t),...a});si.displayName="DrawerFooter";const ni=G.forwardRef(({className:t,...a},r)=>e.jsx(_.Drawer.Title,{ref:r,className:ct("text-lg font-semibold leading-none tracking-tight",t),...a}));ni.displayName=_.Drawer.Title.displayName;const oi=G.forwardRef(({className:t,...a},r)=>e.jsx(_.Drawer.Description,{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));oi.displayName=_.Drawer.Description.displayName;const ii={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},li={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function ci({children:t,cols:a="auto-fit",gap:r="md",className:s}){return e.jsx("div",{className:ct("grid",ii[a],li[r],s),children:t})}const di=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-slot":"input-group",className:ct("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}));di.displayName="InputGroup";const ui=r.cva("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"}}),mi=G.forwardRef(({className:t,align:a,...r},s)=>e.jsx("div",{ref:s,"data-slot":"input-group-addon",className:ct(ui({align:a}),t),...r}));mi.displayName="InputGroupAddon";const pi=r.cva("",{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"}}),hi=G.forwardRef(({className:t,size:a,variant:r="ghost",...s},n)=>e.jsx(mt,{ref:n,"data-slot":"input-group-button",variant:r,className:ct(pi({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...s}));hi.displayName="InputGroupButton";const fi=G.forwardRef(({className:t,...a},r)=>e.jsx(ht,{ref:r,"data-slot":"input-group-control",className:ct("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));fi.displayName="InputGroupInput";const gi=G.forwardRef(({className:t,...a},r)=>e.jsx(aa,{ref:r,"data-slot":"input-group-control",className:ct("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));gi.displayName="InputGroupTextarea";const xi=G.forwardRef(({className:t,...a},r)=>e.jsx("h1",{ref:r,className:ct("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));xi.displayName="H1";const vi=G.forwardRef(({className:t,...a},r)=>e.jsx("h2",{ref:r,className:ct("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));vi.displayName="H2";const bi=G.forwardRef(({className:t,...a},r)=>e.jsx("h3",{ref:r,className:ct("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));bi.displayName="H3";const yi=G.forwardRef(({className:t,...a},r)=>e.jsx("h4",{ref:r,className:ct("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));yi.displayName="H4";const wi=G.forwardRef(({className:t,...a},r)=>e.jsx("p",{ref:r,className:ct("leading-7 [&:not(:first-child)]:mt-6",t),...a}));wi.displayName="P";const ji=G.forwardRef(({className:t,...a},r)=>e.jsx("p",{ref:r,className:ct("text-xl text-muted-foreground",t),...a}));ji.displayName="Lead";const Ni=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,className:ct("text-lg font-semibold",t),...a}));Ni.displayName="Large";const Ci=G.forwardRef(({className:t,...a},r)=>e.jsx("small",{ref:r,className:ct("text-sm font-medium leading-none",t),...a}));Ci.displayName="Small";const ki=G.forwardRef(({className:t,...a},r)=>e.jsx("p",{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));ki.displayName="Muted";const Si=G.forwardRef(({className:t,...a},r)=>e.jsx("code",{ref:r,className:ct("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));Si.displayName="InlineCode";const Ei=G.forwardRef(({className:t,...a},r)=>e.jsx("blockquote",{ref:r,className:ct("mt-6 border-l-2 pl-6 italic",t),...a}));Ei.displayName="Blockquote";const Pi=G.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,className:ct("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));Pi.displayName="List";const Ri=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:ct("mx-auto flex w-full justify-center",t),...a});Ri.displayName="Pagination";const _i=G.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,className:ct("flex flex-row items-center gap-1",t),...a}));_i.displayName="PaginationContent";const Ti=G.forwardRef(({className:t,...a},r)=>e.jsx("li",{ref:r,className:ct("",t),...a}));Ti.displayName="PaginationItem";const Ai=({className:t,isActive:a,size:r="icon",...s})=>e.jsx("a",{"aria-current":a?"page":void 0,className:ct(ut({variant:a?"outline":"ghost",size:r}),t),...s});Ai.displayName="PaginationLink";const Mi=({className:t,...a})=>e.jsxs(Ai,{"aria-label":"Go to previous page",size:"default",className:ct("gap-1 pl-2.5",t),...a,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Mi.displayName="PaginationPrevious";const Ii=({className:t,...a})=>e.jsxs(Ai,{"aria-label":"Go to next page",size:"default",className:ct("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Ii.displayName="PaginationNext";const Li=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:ct("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Li.displayName="PaginationEllipsis";const Oi=G.forwardRef(({className:t,...a},r)=>e.jsx(ue.Root,{className:ct("grid gap-2",t),...a,ref:r}));Oi.displayName=ue.Root.displayName;const Di=G.forwardRef(({className:t,...a},r)=>e.jsx(ue.Item,{ref:r,className:ct("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.jsx(ue.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Di.displayName=ue.Item.displayName;const Fi=X.Root,zi=X.Trigger,$i=X.Close,Ui=X.Portal,Vi=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Overlay,{className:ct("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}));Vi.displayName=X.Overlay.displayName;const Bi=r.cva("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"}}),Wi=G.forwardRef(({side:t="right",className:a,children:r,...s},n)=>e.jsxs(Ui,{children:[e.jsx(Vi,{}),e.jsxs(X.Content,{ref:n,className:ct(Bi({side:t}),a),...s,children:[r,e.jsxs(X.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.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Wi.displayName=X.Content.displayName;const qi=({className:t,showSeparator:a=!1,children:r,...s})=>e.jsxs("div",{className:ct("flex flex-col flex-shrink-0",t),...s,children:[e.jsx("div",{className:"flex flex-col text-left",children:r}),a&&e.jsx(Nt,{className:"mt-2"})]});qi.displayName="SheetHeader";const Hi=({className:t,...a})=>e.jsx("div",{className:ct("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Hi.displayName="SheetBody";const Ki=({className:t,children:a,...r})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Nt,{className:"mb-4"}),e.jsx("div",{className:ct("flex flex-row justify-end gap-2",t),...r,children:a})]});Ki.displayName="SheetFooter";const Gi=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Title,{ref:r,className:ct("text-lg font-semibold text-foreground",t),...a}));Gi.displayName=X.Title.displayName;const Qi=G.forwardRef(({className:t,...a},r)=>e.jsx(X.Description,{ref:r,className:ct("text-sm text-muted-foreground",t),...a}));Qi.displayName=X.Description.displayName;const Xi="sidebar:state",Ji=G.createContext(null);function Yi(){const e=G.useContext(Ji);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Zi=G.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:r,className:s,style:n,children:o,...i},l)=>{const[c,d]=G.useState(!1);G.useEffect(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=G.useState(!1),[p,h]=G.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Xi);return null!==e?"true"===e:t}return t}),f=a??p,g=G.useCallback(e=>{const t="function"==typeof e?e(f):e;r?r(t):h(t),"undefined"!=typeof window&&localStorage.setItem(Xi,String(t))},[r,f]),x=G.useCallback(()=>c?m(e=>!e):g(e=>!e),[c,g,m]);G.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const v=f?"expanded":"collapsed",b=G.useMemo(()=>({state:v,open:f,setOpen:g,isMobile:c,openMobile:u,setOpenMobile:m,toggleSidebar:x}),[v,f,g,c,u,m,x]);return e.jsx(Ji.Provider,{value:b,children:e.jsx(cs,{delayDuration:0,children:e.jsx("div",{className:ct("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",s),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...n},ref:l,...i,children:o})})})});Zi.displayName="SidebarProvider";const el=G.forwardRef(({side:t="left",variant:a="sidebar",collapsible:r="offcanvas",className:s,children:n,...o},i)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=Yi();return"none"===r?e.jsx("div",{className:ct("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:i,...o,children:n}):l?e.jsx(Fi,{open:d,onOpenChange:u,...o,children:e.jsxs(Wi,{"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:t,children:[e.jsx(Gi,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":"collapsed"===c?r:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:ct("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:ct("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});el.displayName="Sidebar";const tl=G.forwardRef(({className:t,onClick:a,...r},s)=>{const{toggleSidebar:n}=Yi();return e.jsxs(mt,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:ct("h-7 w-7",t),onClick:e=>{a?.(e),n()},...r,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});tl.displayName="SidebarTrigger";const al=G.forwardRef(({className:t,...a},r)=>{const{toggleSidebar:s}=Yi();return e.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:ct("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})});al.displayName="SidebarRail";const rl=G.forwardRef(({className:t,...a},r)=>e.jsx("main",{ref:r,className:ct("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}));rl.displayName="SidebarInset";const sl=G.forwardRef(({className:t,...a},r)=>e.jsx(ht,{ref:r,"data-sidebar":"input",className:ct("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));sl.displayName="SidebarInput";const nl=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"header",className:ct("flex flex-col gap-2 p-2",t),...a}));nl.displayName="SidebarHeader";const ol=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"footer",className:ct("flex flex-col gap-2 p-2",t),...a}));ol.displayName="SidebarFooter";const il=G.forwardRef(({className:t,...a},r)=>e.jsx(Nt,{ref:r,"data-sidebar":"separator",className:ct("mx-2 w-auto bg-sidebar-border",t),...a}));il.displayName="SidebarSeparator";const ll=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"content",className:ct("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));ll.displayName="SidebarContent";const cl=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"group",className:ct("relative flex w-full min-w-0 flex-col p-2",t),...a}));cl.displayName="SidebarGroup";const dl=G.forwardRef(({className:t,asChild:r=!1,...s},n)=>{const o=r?a.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:ct("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),...s})});dl.displayName="SidebarGroupLabel";const ul=G.forwardRef(({className:t,asChild:r=!1,...s},n)=>{const o=r?a.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:ct("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),...s})});ul.displayName="SidebarGroupAction";const ml=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"group-content",className:ct("w-full text-sm",t),...a}));ml.displayName="SidebarGroupContent";const pl=G.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,"data-sidebar":"menu",className:ct("flex w-full min-w-0 flex-col gap-1",t),...a}));pl.displayName="SidebarMenu";const hl=G.forwardRef(({className:t,...a},r)=>e.jsx("li",{ref:r,"data-sidebar":"menu-item",className:ct("group/menu-item relative",t),...a}));hl.displayName="SidebarMenuItem";const fl=r.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),gl=G.forwardRef(({asChild:t=!1,isActive:r=!1,variant:s="default",size:n="default",tooltip:o,className:i,...l},c)=>{const d=t?a.Slot:"button",{isMobile:u,state:m}=Yi(),p=e.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":r,className:ct(fl({variant:s,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(ds,{children:[e.jsx(us,{asChild:!0,children:p}),e.jsx(ms,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});gl.displayName="SidebarMenuButton";const xl=G.forwardRef(({className:t,asChild:r=!1,showOnHover:s=!1,...n},o)=>{const i=r?a.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:ct("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",s&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...n})});xl.displayName="SidebarMenuAction";const vl=G.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:ct("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}));vl.displayName="SidebarMenuBadge";const bl=G.forwardRef(({className:t,showIcon:a=!1,...r},s)=>{const n=G.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:ct("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[a&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});bl.displayName="SidebarMenuSkeleton";const yl=G.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:ct("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}));yl.displayName="SidebarMenuSub";const wl=G.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));wl.displayName="SidebarMenuSubItem";const jl=G.forwardRef(({asChild:t=!1,size:r="md",isActive:s,className:n,...o},i)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":r,"data-active":s,className:ct("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"===r&&"text-xs","md"===r&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});jl.displayName="SidebarMenuSubButton";const Nl=G.forwardRef(({className:t,...a},r)=>e.jsxs(me.Root,{ref:r,className:ct("relative flex w-full touch-none select-none items-center",t),...a,children:[e.jsx(me.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(me.Range,{className:"absolute h-full bg-primary"})}),e.jsx(me.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"})]}));Nl.displayName=me.Root.displayName;const Cl=pe.Root,kl=G.forwardRef(({className:t,...a},r)=>e.jsx(pe.List,{ref:r,className:ct("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));kl.displayName=pe.List.displayName;const Sl=G.forwardRef(({className:t,...a},r)=>e.jsx(pe.Trigger,{ref:r,className:ct("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}));Sl.displayName=pe.Trigger.displayName;const El=G.forwardRef(({className:t,...a},r)=>e.jsx(pe.Content,{ref:r,className:ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));El.displayName=pe.Content.displayName;const Pl=r.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Rl=G.forwardRef(({className:t,variant:a,size:r,...s},n)=>e.jsx(he.Root,{ref:n,className:ct(Pl({variant:a,size:r,className:t})),...s}));Rl.displayName=he.Root.displayName;const _l=G.createContext({size:"default",variant:"default"}),Tl=G.forwardRef(({className:t,variant:a,size:r,children:s,...n},o)=>e.jsx(fe.Root,{ref:o,className:ct("flex items-center justify-center gap-1",t),...n,children:e.jsx(_l.Provider,{value:{variant:a,size:r},children:s})}));Tl.displayName=fe.Root.displayName;const Al=G.forwardRef(({className:t,children:a,variant:r,size:s,...n},o)=>{const i=G.useContext(_l);return e.jsx(fe.Item,{ref:o,className:ct(Pl({variant:i.variant||r,size:i.size||s}),t),...n,children:a})});function Ml(t,a=[]){let r=[];const s=()=>{const e=r.map(e=>G.createContext(e));return function(a){const r=a?.[t]||e;return G.useMemo(()=>({[`__scope${t}`]:{...a,[t]:r}}),[a,r])}};return s.scopeName=t,[function(a,s){const n=G.createContext(s),o=r.length;r=[...r,s];const i=a=>{const{scope:r,children:s,...i}=a,l=r?.[t]?.[o]||n,c=G.useMemo(()=>i,Object.values(i));return e.jsx(l.Provider,{value:c,children:s})};return i.displayName=a+"Provider",[i,function(e,r){const i=r?.[t]?.[o]||n,l=G.useContext(i);if(l)return l;if(void 0!==s)return s;throw new Error(`\`${e}\` must be used within \`${a}\``)}]},Il(s,...a)]}function Il(...e){const t=e[0];if(1===e.length)return t;const a=()=>{const a=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=a.reduce((t,{useScope:a,scopeName:r})=>({...t,...a(e)[`__scope${r}`]}),{});return G.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return a.scopeName=t.scopeName,a}function Ll(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ol(...e){return t=>{let a=!1;const r=e.map(e=>{const r=Ll(e,t);return a||"function"!=typeof r||(a=!0),r});if(a)return()=>{for(let t=0;t<r.length;t++){const a=r[t];"function"==typeof a?a():Ll(e[t],null)}}}}function Dl(...e){return G.useCallback(Ol(...e),e)}function Fl(r){const s=r+"CollectionProvider",[n,o]=Ml(s),[i,l]=n(s,{collectionRef:{current:null},itemMap:new Map}),c=a=>{const{scope:r,children:s}=a,n=t.useRef(null),o=t.useRef(new Map).current;return e.jsx(i,{scope:r,itemMap:o,collectionRef:n,children:s})};c.displayName=s;const d=r+"CollectionSlot",u=a.createSlot(d),m=t.forwardRef((t,a)=>{const{scope:r,children:s}=t,n=Dl(a,l(d,r).collectionRef);return e.jsx(u,{ref:n,children:s})});m.displayName=d;const p=r+"CollectionItemSlot",h="data-radix-collection-item",f=a.createSlot(p),g=t.forwardRef((a,r)=>{const{scope:s,children:n,...o}=a,i=t.useRef(null),c=Dl(r,i),d=l(p,s);return t.useEffect(()=>(d.itemMap.set(i,{ref:i,...o}),()=>{d.itemMap.delete(i)})),e.jsx(f,{[h]:"",ref:c,children:n})});return g.displayName=p,[{Provider:c,Slot:m,ItemSlot:g},function(e){const a=l(r+"CollectionConsumer",e);return t.useCallback(()=>{const e=a.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(a.itemMap.values()).sort((e,a)=>t.indexOf(e.ref.current)-t.indexOf(a.ref.current))},[a.collectionRef,a.itemMap])},o]}Al.displayName=fe.Item.displayName;var zl=G.createContext(void 0);function $l(e){const t=G.useContext(zl);return e||t||"ltr"}function Ul(e,t,{checkForDefaultPrevented:a=!0}={}){return function(r){if(e?.(r),!1===a||!r.defaultPrevented)return t?.(r)}}var Vl=globalThis?.document?G.useLayoutEffect:()=>{},Bl=G[" useId ".trim().toString()]||(()=>{}),Wl=0;function ql(e){const[t,a]=G.useState(Bl());return Vl(()=>{a(e=>e??String(Wl++))},[e]),t?`radix-${t}`:""}var Hl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const s=a.createSlot(`Primitive.${r}`),n=G.forwardRef((t,a)=>{const{asChild:n,...o}=t,i=n?s:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),e.jsx(i,{...o,ref:a})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function Kl(e,t){e&&ge.flushSync(()=>e.dispatchEvent(t))}function Gl(e){const t=G.useRef(e);return G.useEffect(()=>{t.current=e}),G.useMemo(()=>(...e)=>t.current?.(...e),[])}var Ql,Xl="dismissableLayer.update",Jl="dismissableLayer.pointerDownOutside",Yl="dismissableLayer.focusOutside",Zl=G.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ec=G.forwardRef((t,a)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:o,onInteractOutside:i,onDismiss:l,...c}=t,d=G.useContext(Zl),[u,m]=G.useState(null),p=u?.ownerDocument??globalThis?.document,[,h]=G.useState({}),f=Dl(a,e=>m(e)),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(x),b=u?g.indexOf(u):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,w=b>=v,j=function(e,t=globalThis?.document){const a=Gl(e),r=G.useRef(!1),s=G.useRef(()=>{});return G.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){ac(Jl,a,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",s.current),s.current=r,t.addEventListener("click",s.current,{once:!0})):r()}else t.removeEventListener("click",s.current);r.current=!1},n=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(n),t.removeEventListener("pointerdown",e),t.removeEventListener("click",s.current)}},[t,a]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,a=[...d.branches].some(e=>e.contains(t));w&&!a&&(n?.(e),i?.(e),e.defaultPrevented||l?.())},p),N=function(e,t=globalThis?.document){const a=Gl(e),r=G.useRef(!1);return G.useEffect(()=>{const e=e=>{if(e.target&&!r.current){ac(Yl,a,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,a]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),i?.(e),e.defaultPrevented||l?.())},p);return function(e,t=globalThis?.document){const a=Gl(e);G.useEffect(()=>{const e=e=>{"Escape"===e.key&&a(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[a,t])}(e=>{b===d.layers.size-1&&(s?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),G.useEffect(()=>{if(u)return r&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(Ql=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),tc(),()=>{r&&1===d.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Ql)}},[u,p,r,d]),G.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),tc())},[u,d]),G.useEffect(()=>{const e=()=>h({});return document.addEventListener(Xl,e),()=>document.removeEventListener(Xl,e)},[]),e.jsx(Hl.div,{...c,ref:f,style:{pointerEvents:y?w?"auto":"none":void 0,...t.style},onFocusCapture:Ul(t.onFocusCapture,N.onFocusCapture),onBlurCapture:Ul(t.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Ul(t.onPointerDownCapture,j.onPointerDownCapture)})});ec.displayName="DismissableLayer";function tc(){const e=new CustomEvent(Xl);document.dispatchEvent(e)}function ac(e,t,a,{discrete:r}){const s=a.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});t&&s.addEventListener(e,t,{once:!0}),r?Kl(s,n):s.dispatchEvent(n)}G.forwardRef((t,a)=>{const r=G.useContext(Zl),s=G.useRef(null),n=Dl(a,s);return G.useEffect(()=>{const e=s.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),e.jsx(Hl.div,{...t,ref:n})}).displayName="DismissableLayerBranch";var rc=0;function sc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nc="focusScope.autoFocusOnMount",oc="focusScope.autoFocusOnUnmount",ic={bubbles:!1,cancelable:!0},lc=G.forwardRef((t,a)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:o,...i}=t,[l,c]=G.useState(null),d=Gl(n),u=Gl(o),m=G.useRef(null),p=Dl(a,e=>c(e)),h=G.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;G.useEffect(()=>{if(s){let e=function(e){if(h.paused||!l)return;const t=e.target;l.contains(t)?m.current=t:mc(m.current,{select:!0})},t=function(e){if(h.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||mc(m.current,{select:!0}))},a=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&mc(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(a);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[s,l,h.paused]),G.useEffect(()=>{if(l){pc.add(h);const t=document.activeElement;if(!l.contains(t)){const a=new CustomEvent(nc,ic);l.addEventListener(nc,d),l.dispatchEvent(a),a.defaultPrevented||(!function(e,{select:t=!1}={}){const a=document.activeElement;for(const r of e)if(mc(r,{select:t}),document.activeElement!==a)return}((e=cc(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&mc(l))}return()=>{l.removeEventListener(nc,d),setTimeout(()=>{const e=new CustomEvent(oc,ic);l.addEventListener(oc,u),l.dispatchEvent(e),e.defaultPrevented||mc(t??document.body,{select:!0}),l.removeEventListener(oc,u),pc.remove(h)},0)}}var e},[l,d,u,h]);const f=G.useCallback(e=>{if(!r&&!s)return;if(h.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){const t=e.currentTarget,[s,n]=function(e){const t=cc(e),a=dc(t,e),r=dc(t.reverse(),e);return[a,r]}(t);s&&n?e.shiftKey||a!==n?e.shiftKey&&a===s&&(e.preventDefault(),r&&mc(n,{select:!0})):(e.preventDefault(),r&&mc(s,{select:!0})):a===t&&e.preventDefault()}},[r,s,h.paused]);return e.jsx(Hl.div,{tabIndex:-1,...i,ref:p,onKeyDown:f})});function cc(e){const t=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)t.push(a.currentNode);return t}function dc(e,t){for(const a of e)if(!uc(a,{upTo:t}))return a}function uc(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function mc(e,{select:t=!1}={}){if(e&&e.focus){const a=document.activeElement;e.focus({preventScroll:!0}),e!==a&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}lc.displayName="FocusScope";var pc=function(){let e=[];return{add(t){const a=e[0];t!==a&&a?.pause(),e=hc(e,t),e.unshift(t)},remove(t){e=hc(e,t),e[0]?.resume()}}}();function hc(e,t){const a=[...e],r=a.indexOf(t);return-1!==r&&a.splice(r,1),a}const fc=["top","right","bottom","left"],gc=Math.min,xc=Math.max,vc=Math.round,bc=Math.floor,yc=e=>({x:e,y:e}),wc={left:"right",right:"left",bottom:"top",top:"bottom"},jc={start:"end",end:"start"};function Nc(e,t,a){return xc(e,gc(t,a))}function Cc(e,t){return"function"==typeof e?e(t):e}function kc(e){return e.split("-")[0]}function Sc(e){return e.split("-")[1]}function Ec(e){return"x"===e?"y":"x"}function Pc(e){return"y"===e?"height":"width"}const Rc=new Set(["top","bottom"]);function _c(e){return Rc.has(kc(e))?"y":"x"}function Tc(e){return Ec(_c(e))}function Ac(e){return e.replace(/start|end/g,e=>jc[e])}const Mc=["left","right"],Ic=["right","left"],Lc=["top","bottom"],Oc=["bottom","top"];function Dc(e,t,a,r){const s=Sc(e);let n=function(e,t,a){switch(e){case"top":case"bottom":return a?t?Ic:Mc:t?Mc:Ic;case"left":case"right":return t?Lc:Oc;default:return[]}}(kc(e),"start"===a,r);return s&&(n=n.map(e=>e+"-"+s),t&&(n=n.concat(n.map(Ac)))),n}function Fc(e){return e.replace(/left|right|bottom|top/g,e=>wc[e])}function zc(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function $c(e){const{x:t,y:a,width:r,height:s}=e;return{width:r,height:s,top:a,left:t,right:t+r,bottom:a+s,x:t,y:a}}function Uc(e,t,a){let{reference:r,floating:s}=e;const n=_c(t),o=Tc(t),i=Pc(o),l=kc(t),c="y"===n,d=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,m=r[i]/2-s[i]/2;let p;switch(l){case"top":p={x:d,y:r.y-s.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:u};break;case"left":p={x:r.x-s.width,y:u};break;default:p={x:r.x,y:r.y}}switch(Sc(t)){case"start":p[o]-=m*(a&&c?-1:1);break;case"end":p[o]+=m*(a&&c?-1:1)}return p}async function Vc(e,t){var a;void 0===t&&(t={});const{x:r,y:s,platform:n,rects:o,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:m=!1,padding:p=0}=Cc(t,e),h=zc(p),f=i[m?"floating"===u?"reference":"floating":u],g=$c(await n.getClippingRect({element:null==(a=await(null==n.isElement?void 0:n.isElement(f)))||a?f:f.contextElement||await(null==n.getDocumentElement?void 0:n.getDocumentElement(i.floating)),boundary:c,rootBoundary:d,strategy:l})),x="floating"===u?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(null==n.getOffsetParent?void 0:n.getOffsetParent(i.floating)),b=await(null==n.isElement?void 0:n.isElement(v))&&await(null==n.getScale?void 0:n.getScale(v))||{x:1,y:1},y=$c(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:x,offsetParent:v,strategy:l}):x);return{top:(g.top-y.top+h.top)/b.y,bottom:(y.bottom-g.bottom+h.bottom)/b.y,left:(g.left-y.left+h.left)/b.x,right:(y.right-g.right+h.right)/b.x}}function Bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Wc(e){return fc.some(t=>e[t]>=0)}const qc=new Set(["left","top"]);function Hc(){return"undefined"!=typeof window}function Kc(e){return Xc(e)?(e.nodeName||"").toLowerCase():"#document"}function Gc(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Qc(e){var t;return null==(t=(Xc(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Xc(e){return!!Hc()&&(e instanceof Node||e instanceof Gc(e).Node)}function Jc(e){return!!Hc()&&(e instanceof Element||e instanceof Gc(e).Element)}function Yc(e){return!!Hc()&&(e instanceof HTMLElement||e instanceof Gc(e).HTMLElement)}function Zc(e){return!(!Hc()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Gc(e).ShadowRoot)}const ed=new Set(["inline","contents"]);function td(e){const{overflow:t,overflowX:a,overflowY:r,display:s}=pd(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+a)&&!ed.has(s)}const ad=new Set(["table","td","th"]);function rd(e){return ad.has(Kc(e))}const sd=[":popover-open",":modal"];function nd(e){return sd.some(t=>{try{return e.matches(t)}catch(a){return!1}})}const od=["transform","translate","scale","rotate","perspective"],id=["transform","translate","scale","rotate","perspective","filter"],ld=["paint","layout","strict","content"];function cd(e){const t=dd(),a=Jc(e)?pd(e):e;return od.some(e=>!!a[e]&&"none"!==a[e])||!!a.containerType&&"normal"!==a.containerType||!t&&!!a.backdropFilter&&"none"!==a.backdropFilter||!t&&!!a.filter&&"none"!==a.filter||id.some(e=>(a.willChange||"").includes(e))||ld.some(e=>(a.contain||"").includes(e))}function dd(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const ud=new Set(["html","body","#document"]);function md(e){return ud.has(Kc(e))}function pd(e){return Gc(e).getComputedStyle(e)}function hd(e){return Jc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fd(e){if("html"===Kc(e))return e;const t=e.assignedSlot||e.parentNode||Zc(e)&&e.host||Qc(e);return Zc(t)?t.host:t}function gd(e){const t=fd(e);return md(t)?e.ownerDocument?e.ownerDocument.body:e.body:Yc(t)&&td(t)?t:gd(t)}function xd(e,t,a){var r;void 0===t&&(t=[]),void 0===a&&(a=!0);const s=gd(e),n=s===(null==(r=e.ownerDocument)?void 0:r.body),o=Gc(s);if(n){const e=vd(o);return t.concat(o,o.visualViewport||[],td(s)?s:[],e&&a?xd(e):[])}return t.concat(s,xd(s,[],a))}function vd(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bd(e){const t=pd(e);let a=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Yc(e),n=s?e.offsetWidth:a,o=s?e.offsetHeight:r,i=vc(a)!==n||vc(r)!==o;return i&&(a=n,r=o),{width:a,height:r,$:i}}function yd(e){return Jc(e)?e:e.contextElement}function wd(e){const t=yd(e);if(!Yc(t))return yc(1);const a=t.getBoundingClientRect(),{width:r,height:s,$:n}=bd(t);let o=(n?vc(a.width):a.width)/r,i=(n?vc(a.height):a.height)/s;return o&&Number.isFinite(o)||(o=1),i&&Number.isFinite(i)||(i=1),{x:o,y:i}}const jd=yc(0);function Nd(e){const t=Gc(e);return dd()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:jd}function Cd(e,t,a,r){void 0===t&&(t=!1),void 0===a&&(a=!1);const s=e.getBoundingClientRect(),n=yd(e);let o=yc(1);t&&(r?Jc(r)&&(o=wd(r)):o=wd(e));const i=function(e,t,a){return void 0===t&&(t=!1),!(!a||t&&a!==Gc(e))&&t}(n,a,r)?Nd(n):yc(0);let l=(s.left+i.x)/o.x,c=(s.top+i.y)/o.y,d=s.width/o.x,u=s.height/o.y;if(n){const e=Gc(n),t=r&&Jc(r)?Gc(r):r;let a=e,s=vd(a);for(;s&&r&&t!==a;){const e=wd(s),t=s.getBoundingClientRect(),r=pd(s),n=t.left+(s.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(s.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,d*=e.x,u*=e.y,l+=n,c+=o,a=Gc(s),s=vd(a)}}return $c({width:d,height:u,x:l,y:c})}function kd(e,t){const a=hd(e).scrollLeft;return t?t.left+a:Cd(Qc(e)).left+a}function Sd(e,t){const a=e.getBoundingClientRect();return{x:a.left+t.scrollLeft-kd(e,a),y:a.top+t.scrollTop}}const Ed=new Set(["absolute","fixed"]);function Pd(e,t,a){let r;if("viewport"===t)r=function(e,t){const a=Gc(e),r=Qc(e),s=a.visualViewport;let n=r.clientWidth,o=r.clientHeight,i=0,l=0;if(s){n=s.width,o=s.height;const e=dd();(!e||e&&"fixed"===t)&&(i=s.offsetLeft,l=s.offsetTop)}const c=kd(r);if(c<=0){const e=r.ownerDocument,t=e.body,a=getComputedStyle(t),s="CSS1Compat"===e.compatMode&&parseFloat(a.marginLeft)+parseFloat(a.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-s);o<=25&&(n-=o)}else c<=25&&(n+=c);return{width:n,height:o,x:i,y:l}}(e,a);else if("document"===t)r=function(e){const t=Qc(e),a=hd(e),r=e.ownerDocument.body,s=xc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),n=xc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-a.scrollLeft+kd(e);const i=-a.scrollTop;return"rtl"===pd(r).direction&&(o+=xc(t.clientWidth,r.clientWidth)-s),{width:s,height:n,x:o,y:i}}(Qc(e));else if(Jc(t))r=function(e,t){const a=Cd(e,!0,"fixed"===t),r=a.top+e.clientTop,s=a.left+e.clientLeft,n=Yc(e)?wd(e):yc(1);return{width:e.clientWidth*n.x,height:e.clientHeight*n.y,x:s*n.x,y:r*n.y}}(t,a);else{const a=Nd(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return $c(r)}function Rd(e,t){const a=fd(e);return!(a===t||!Jc(a)||md(a))&&("fixed"===pd(a).position||Rd(a,t))}function _d(e,t,a){const r=Yc(t),s=Qc(t),n="fixed"===a,o=Cd(e,!0,n,t);let i={scrollLeft:0,scrollTop:0};const l=yc(0);function c(){l.x=kd(s)}if(r||!r&&!n)if(("body"!==Kc(t)||td(s))&&(i=hd(t)),r){const e=Cd(t,!0,n,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else s&&c();n&&!r&&s&&c();const d=!s||r||n?yc(0):Sd(s,i);return{x:o.left+i.scrollLeft-l.x-d.x,y:o.top+i.scrollTop-l.y-d.y,width:o.width,height:o.height}}function Td(e){return"static"===pd(e).position}function Ad(e,t){if(!Yc(e)||"fixed"===pd(e).position)return null;if(t)return t(e);let a=e.offsetParent;return Qc(e)===a&&(a=a.ownerDocument.body),a}function Md(e,t){const a=Gc(e);if(nd(e))return a;if(!Yc(e)){let t=fd(e);for(;t&&!md(t);){if(Jc(t)&&!Td(t))return t;t=fd(t)}return a}let r=Ad(e,t);for(;r&&rd(r)&&Td(r);)r=Ad(r,t);return r&&md(r)&&Td(r)&&!cd(r)?a:r||function(e){let t=fd(e);for(;Yc(t)&&!md(t);){if(cd(t))return t;if(nd(t))return null;t=fd(t)}return null}(e)||a}const Id={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:a,offsetParent:r,strategy:s}=e;const n="fixed"===s,o=Qc(r),i=!!t&&nd(t.floating);if(r===o||i&&n)return a;let l={scrollLeft:0,scrollTop:0},c=yc(1);const d=yc(0),u=Yc(r);if((u||!u&&!n)&&(("body"!==Kc(r)||td(o))&&(l=hd(r)),Yc(r))){const e=Cd(r);c=wd(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}const m=!o||u||n?yc(0):Sd(o,l);return{width:a.width*c.x,height:a.height*c.y,x:a.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:a.y*c.y-l.scrollTop*c.y+d.y+m.y}},getDocumentElement:Qc,getClippingRect:function(e){let{element:t,boundary:a,rootBoundary:r,strategy:s}=e;const n=[..."clippingAncestors"===a?nd(t)?[]:function(e,t){const a=t.get(e);if(a)return a;let r=xd(e,[],!1).filter(e=>Jc(e)&&"body"!==Kc(e)),s=null;const n="fixed"===pd(e).position;let o=n?fd(e):e;for(;Jc(o)&&!md(o);){const t=pd(o),a=cd(o);a||"fixed"!==t.position||(s=null),(n?!a&&!s:!a&&"static"===t.position&&s&&Ed.has(s.position)||td(o)&&!a&&Rd(e,o))?r=r.filter(e=>e!==o):s=t,o=fd(o)}return t.set(e,r),r}(t,this._c):[].concat(a),r],o=n[0],i=n.reduce((e,a)=>{const r=Pd(t,a,s);return e.top=xc(r.top,e.top),e.right=gc(r.right,e.right),e.bottom=gc(r.bottom,e.bottom),e.left=xc(r.left,e.left),e},Pd(t,o,s));return{width:i.right-i.left,height:i.bottom-i.top,x:i.left,y:i.top}},getOffsetParent:Md,getElementRects:async function(e){const t=this.getOffsetParent||Md,a=this.getDimensions,r=await a(e.floating);return{reference:_d(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:a}=bd(e);return{width:t,height:a}},getScale:wd,isElement:Jc,isRTL:function(e){return"rtl"===pd(e).direction}};function Ld(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Od(e,t,a,r){void 0===r&&(r={});const{ancestorScroll:s=!0,ancestorResize:n=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:i="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=yd(e),d=s||n?[...c?xd(c):[],...xd(t)]:[];d.forEach(e=>{s&&e.addEventListener("scroll",a,{passive:!0}),n&&e.addEventListener("resize",a)});const u=c&&i?function(e,t){let a,r=null;const s=Qc(e);function n(){var e;clearTimeout(a),null==(e=r)||e.disconnect(),r=null}return function o(i,l){void 0===i&&(i=!1),void 0===l&&(l=1),n();const c=e.getBoundingClientRect(),{left:d,top:u,width:m,height:p}=c;if(i||t(),!m||!p)return;const h={rootMargin:-bc(u)+"px "+-bc(s.clientWidth-(d+m))+"px "+-bc(s.clientHeight-(u+p))+"px "+-bc(d)+"px",threshold:xc(0,gc(1,l))||1};let f=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!f)return o();r?o(!1,r):a=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==r||Ld(c,e.getBoundingClientRect())||o(),f=!1}try{r=new IntersectionObserver(g,{...h,root:s.ownerDocument})}catch(x){r=new IntersectionObserver(g,h)}r.observe(e)}(!0),n}(c,a):null;let m,p=-1,h=null;o&&(h=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),a()}),c&&!l&&h.observe(c),h.observe(t));let f=l?Cd(e):null;return l&&function t(){const r=Cd(e);f&&!Ld(f,r)&&a();f=r,m=requestAnimationFrame(t)}(),a(),()=>{var e;d.forEach(e=>{s&&e.removeEventListener("scroll",a),n&&e.removeEventListener("resize",a)}),null==u||u(),null==(e=h)||e.disconnect(),h=null,l&&cancelAnimationFrame(m)}}const Dd=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var a,r;const{x:s,y:n,placement:o,middlewareData:i}=t,l=await async function(e,t){const{placement:a,platform:r,elements:s}=e,n=await(null==r.isRTL?void 0:r.isRTL(s.floating)),o=kc(a),i=Sc(a),l="y"===_c(a),c=qc.has(o)?-1:1,d=n&&l?-1:1,u=Cc(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return i&&"number"==typeof h&&(p="end"===i?-1*h:h),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}(t,e);return o===(null==(a=i.offset)?void 0:a.placement)&&null!=(r=i.arrow)&&r.alignmentOffset?{}:{x:s+l.x,y:n+l.y,data:{...l,placement:o}}}}},Fd=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:a,y:r,placement:s}=t,{mainAxis:n=!0,crossAxis:o=!1,limiter:i={fn:e=>{let{x:t,y:a}=e;return{x:t,y:a}}},...l}=Cc(e,t),c={x:a,y:r},d=await Vc(t,l),u=_c(kc(s)),m=Ec(u);let p=c[m],h=c[u];if(n){const e="y"===m?"bottom":"right";p=Nc(p+d["y"===m?"top":"left"],p,p-d[e])}if(o){const e="y"===u?"bottom":"right";h=Nc(h+d["y"===u?"top":"left"],h,h-d[e])}const f=i.fn({...t,[m]:p,[u]:h});return{...f,data:{x:f.x-a,y:f.y-r,enabled:{[m]:n,[u]:o}}}}}},zd=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var a,r;const{placement:s,middlewareData:n,rects:o,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:f=!0,...g}=Cc(e,t);if(null!=(a=n.arrow)&&a.alignmentOffset)return{};const x=kc(s),v=_c(i),b=kc(i)===i,y=await(null==l.isRTL?void 0:l.isRTL(c.floating)),w=m||(b||!f?[Fc(i)]:function(e){const t=Fc(e);return[Ac(e),t,Ac(t)]}(i)),j="none"!==h;!m&&j&&w.push(...Dc(i,f,h,y));const N=[i,...w],C=await Vc(t,g),k=[];let S=(null==(r=n.flip)?void 0:r.overflows)||[];if(d&&k.push(C[x]),u){const e=function(e,t,a){void 0===a&&(a=!1);const r=Sc(e),s=Tc(e),n=Pc(s);let o="x"===s?r===(a?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[n]>t.floating[n]&&(o=Fc(o)),[o,Fc(o)]}(s,o,y);k.push(C[e[0]],C[e[1]])}if(S=[...S,{placement:s,overflows:k}],!k.every(e=>e<=0)){var E,P;const e=((null==(E=n.flip)?void 0:E.index)||0)+1,t=N[e];if(t){if(!("alignment"===u&&v!==_c(t))||S.every(e=>_c(e.placement)!==v||e.overflows[0]>0))return{data:{index:e,overflows:S},reset:{placement:t}}}let a=null==(P=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:P.placement;if(!a)switch(p){case"bestFit":{var R;const e=null==(R=S.filter(e=>{if(j){const t=_c(e.placement);return t===v||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:R[0];e&&(a=e);break}case"initialPlacement":a=i}if(s!==a)return{reset:{placement:a}}}return{}}}},$d=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var a,r;const{placement:s,rects:n,platform:o,elements:i}=t,{apply:l=()=>{},...c}=Cc(e,t),d=await Vc(t,c),u=kc(s),m=Sc(s),p="y"===_c(s),{width:h,height:f}=n.floating;let g,x;"top"===u||"bottom"===u?(g=u,x=m===(await(null==o.isRTL?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(x=u,g="end"===m?"top":"bottom");const v=f-d.top-d.bottom,b=h-d.left-d.right,y=gc(f-d[g],v),w=gc(h-d[x],b),j=!t.middlewareData.shift;let N=y,C=w;if(null!=(a=t.middlewareData.shift)&&a.enabled.x&&(C=b),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(N=v),j&&!m){const e=xc(d.left,0),t=xc(d.right,0),a=xc(d.top,0),r=xc(d.bottom,0);p?C=h-2*(0!==e||0!==t?e+t:xc(d.left,d.right)):N=f-2*(0!==a||0!==r?a+r:xc(d.top,d.bottom))}await l({...t,availableWidth:C,availableHeight:N});const k=await o.getDimensions(i.floating);return h!==k.width||f!==k.height?{reset:{rects:!0}}:{}}}},Ud=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:a}=t,{strategy:r="referenceHidden",...s}=Cc(e,t);switch(r){case"referenceHidden":{const e=Bc(await Vc(t,{...s,elementContext:"reference"}),a.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Wc(e)}}}case"escaped":{const e=Bc(await Vc(t,{...s,altBoundary:!0}),a.floating);return{data:{escapedOffsets:e,escaped:Wc(e)}}}default:return{}}}}},Vd=e=>({name:"arrow",options:e,async fn(t){const{x:a,y:r,placement:s,rects:n,platform:o,elements:i,middlewareData:l}=t,{element:c,padding:d=0}=Cc(e,t)||{};if(null==c)return{};const u=zc(d),m={x:a,y:r},p=Tc(s),h=Pc(p),f=await o.getDimensions(c),g="y"===p,x=g?"top":"left",v=g?"bottom":"right",b=g?"clientHeight":"clientWidth",y=n.reference[h]+n.reference[p]-m[p]-n.floating[h],w=m[p]-n.reference[p],j=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let N=j?j[b]:0;N&&await(null==o.isElement?void 0:o.isElement(j))||(N=i.floating[b]||n.floating[h]);const C=y/2-w/2,k=N/2-f[h]/2-1,S=gc(u[x],k),E=gc(u[v],k),P=S,R=N-f[h]-E,_=N/2-f[h]/2+C,T=Nc(P,_,R),A=!l.arrow&&null!=Sc(s)&&_!==T&&n.reference[h]/2-(_<P?S:E)-f[h]/2<0,M=A?_<P?_-P:_-R:0;return{[p]:m[p]+M,data:{[p]:T,centerOffset:_-T-M,...A&&{alignmentOffset:M}},reset:A}}}),Bd=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:a,y:r,placement:s,rects:n,middlewareData:o}=t,{offset:i=0,mainAxis:l=!0,crossAxis:c=!0}=Cc(e,t),d={x:a,y:r},u=_c(s),m=Ec(u);let p=d[m],h=d[u];const f=Cc(i,t),g="number"==typeof f?{mainAxis:f,crossAxis:0}:{mainAxis:0,crossAxis:0,...f};if(l){const e="y"===m?"height":"width",t=n.reference[m]-n.floating[e]+g.mainAxis,a=n.reference[m]+n.reference[e]-g.mainAxis;p<t?p=t:p>a&&(p=a)}if(c){var x,v;const e="y"===m?"width":"height",t=qc.has(kc(s)),a=n.reference[u]-n.floating[e]+(t&&(null==(x=o.offset)?void 0:x[u])||0)+(t?0:g.crossAxis),r=n.reference[u]+n.reference[e]+(t?0:(null==(v=o.offset)?void 0:v[u])||0)-(t?g.crossAxis:0);h<a?h=a:h>r&&(h=r)}return{[m]:p,[u]:h}}}},Wd=(e,t,a)=>{const r=new Map,s={platform:Id,...a},n={...s.platform,_c:r};return(async(e,t,a)=>{const{placement:r="bottom",strategy:s="absolute",middleware:n=[],platform:o}=a,i=n.filter(Boolean),l=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:u}=Uc(c,r,l),m=r,p={},h=0;for(let f=0;f<i.length;f++){const{name:a,fn:n}=i[f],{x:g,y:x,data:v,reset:b}=await n({x:d,y:u,initialPlacement:r,placement:m,strategy:s,middlewareData:p,rects:c,platform:o,elements:{reference:e,floating:t}});d=null!=g?g:d,u=null!=x?x:u,p={...p,[a]:{...p[a],...v}},b&&h<=50&&(h++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(c=!0===b.rects?await o.getElementRects({reference:e,floating:t,strategy:s}):b.rects),({x:d,y:u}=Uc(c,m,l))),f=-1)}return{x:d,y:u,placement:m,strategy:s,middlewareData:p}})(e,t,{...s,platform:n})};var qd="undefined"!=typeof document?t.useLayoutEffect:function(){};function Hd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let a,r,s;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(a=e.length,a!==t.length)return!1;for(r=a;0!==r--;)if(!Hd(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),a=s.length,a!==Object.keys(t).length)return!1;for(r=a;0!==r--;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=a;0!==r--;){const a=s[r];if(("_owner"!==a||!e.$$typeof)&&!Hd(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function Kd(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gd(e,t){const a=Kd(e);return Math.round(t*a)/a}function Qd(e){const t=G.useRef(e);return qd(()=>{t.current=e}),t}const Xd=e=>({name:"arrow",options:e,fn(t){const{element:a,padding:r}="function"==typeof e?e(t):e;return a&&function(e){return{}.hasOwnProperty.call(e,"current")}(a)?null!=a.current?Vd({element:a.current,padding:r}).fn(t):{}:a?Vd({element:a,padding:r}).fn(t):{}}}),Jd=(e,t)=>({...Dd(e),options:[e,t]}),Yd=(e,t)=>({...Fd(e),options:[e,t]}),Zd=(e,t)=>({...Bd(e),options:[e,t]}),eu=(e,t)=>({...zd(e),options:[e,t]}),tu=(e,t)=>({...$d(e),options:[e,t]}),au=(e,t)=>({...Ud(e),options:[e,t]}),ru=(e,t)=>({...Xd(e),options:[e,t]});var su=G.forwardRef((t,a)=>{const{children:r,width:s=10,height:n=5,...o}=t;return e.jsx(Hl.svg,{...o,ref:a,width:s,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});su.displayName="Arrow";var nu=su;var ou="Popper",[iu,lu]=Ml(ou),[cu,du]=iu(ou),uu=t=>{const{__scopePopper:a,children:r}=t,[s,n]=G.useState(null);return e.jsx(cu,{scope:a,anchor:s,onAnchorChange:n,children:r})};uu.displayName=ou;var mu="PopperAnchor",pu=G.forwardRef((t,a)=>{const{__scopePopper:r,virtualRef:s,...n}=t,o=du(mu,r),i=G.useRef(null),l=Dl(a,i),c=G.useRef(null);return G.useEffect(()=>{const e=c.current;c.current=s?.current||i.current,e!==c.current&&o.onAnchorChange(c.current)}),s?null:e.jsx(Hl.div,{...n,ref:l})});pu.displayName=mu;var hu="PopperContent",[fu,gu]=iu(hu),xu=G.forwardRef((t,a)=>{const{__scopePopper:r,side:s="bottom",sideOffset:n=0,align:o="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:f,...g}=t,x=du(hu,r),[v,b]=G.useState(null),y=Dl(a,e=>b(e)),[w,j]=G.useState(null),N=function(e){const[t,a]=G.useState(void 0);return Vl(()=>{if(e){a({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let s,n;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;s=t.inlineSize,n=t.blockSize}else s=e.offsetWidth,n=e.offsetHeight;a({width:s,height:n})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}a(void 0)},[e]),t}(w),C=N?.width??0,k=N?.height??0,S=s+("center"!==o?"-"+o:""),E="number"==typeof u?u:{top:0,right:0,bottom:0,left:0,...u},P=Array.isArray(d)?d:[d],R=P.length>0,_={padding:E,boundary:P.filter(wu),altBoundary:R},{refs:T,floatingStyles:A,placement:M,isPositioned:I,middlewareData:L}=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:a="absolute",middleware:r=[],platform:s,elements:{reference:n,floating:o}={},transform:i=!0,whileElementsMounted:l,open:c}=e,[d,u]=G.useState({x:0,y:0,strategy:a,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=G.useState(r);Hd(m,r)||p(r);const[h,f]=G.useState(null),[g,x]=G.useState(null),v=G.useCallback(e=>{e!==j.current&&(j.current=e,f(e))},[]),b=G.useCallback(e=>{e!==N.current&&(N.current=e,x(e))},[]),y=n||h,w=o||g,j=G.useRef(null),N=G.useRef(null),C=G.useRef(d),k=null!=l,S=Qd(l),E=Qd(s),P=Qd(c),R=G.useCallback(()=>{if(!j.current||!N.current)return;const e={placement:t,strategy:a,middleware:m};E.current&&(e.platform=E.current),Wd(j.current,N.current,e).then(e=>{const t={...e,isPositioned:!1!==P.current};_.current&&!Hd(C.current,t)&&(C.current=t,ge.flushSync(()=>{u(t)}))})},[m,t,a,E,P]);qd(()=>{!1===c&&C.current.isPositioned&&(C.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[c]);const _=G.useRef(!1);qd(()=>(_.current=!0,()=>{_.current=!1}),[]),qd(()=>{if(y&&(j.current=y),w&&(N.current=w),y&&w){if(S.current)return S.current(y,w,R);R()}},[y,w,R,S,k]);const T=G.useMemo(()=>({reference:j,floating:N,setReference:v,setFloating:b}),[v,b]),A=G.useMemo(()=>({reference:y,floating:w}),[y,w]),M=G.useMemo(()=>{const e={position:a,left:0,top:0};if(!A.floating)return e;const t=Gd(A.floating,d.x),r=Gd(A.floating,d.y);return i?{...e,transform:"translate("+t+"px, "+r+"px)",...Kd(A.floating)>=1.5&&{willChange:"transform"}}:{position:a,left:t,top:r}},[a,i,A.floating,d.x,d.y]);return G.useMemo(()=>({...d,update:R,refs:T,elements:A,floatingStyles:M}),[d,R,T,A,M])}({strategy:"fixed",placement:S,whileElementsMounted:(...e)=>Od(...e,{animationFrame:"always"===h}),elements:{reference:x.anchor},middleware:[Jd({mainAxis:n+k,alignmentAxis:i}),c&&Yd({mainAxis:!0,crossAxis:!1,limiter:"partial"===m?Zd():void 0,..._}),c&&eu({..._}),tu({..._,apply:({elements:e,rects:t,availableWidth:a,availableHeight:r})=>{const{width:s,height:n}=t.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${a}px`),o.setProperty("--radix-popper-available-height",`${r}px`),o.setProperty("--radix-popper-anchor-width",`${s}px`),o.setProperty("--radix-popper-anchor-height",`${n}px`)}}),w&&ru({element:w,padding:l}),ju({arrowWidth:C,arrowHeight:k}),p&&au({strategy:"referenceHidden",..._})]}),[O,D]=Nu(M),F=Gl(f);Vl(()=>{I&&F?.()},[I,F]);const z=L.arrow?.x,$=L.arrow?.y,U=0!==L.arrow?.centerOffset,[V,B]=G.useState();return Vl(()=>{v&&B(window.getComputedStyle(v).zIndex)},[v]),e.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...A,transform:I?A.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(fu,{scope:r,placedSide:O,onArrowChange:j,arrowX:z,arrowY:$,shouldHideArrow:U,children:e.jsx(Hl.div,{"data-side":O,"data-align":D,...g,ref:y,style:{...g.style,animation:I?void 0:"none"}})})})});xu.displayName=hu;var vu="PopperArrow",bu={top:"bottom",right:"left",bottom:"top",left:"right"},yu=G.forwardRef(function(t,a){const{__scopePopper:r,...s}=t,n=gu(vu,r),o=bu[n.placedSide];return e.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:e.jsx(nu,{...s,ref:a,style:{...s.style,display:"block"}})})});function wu(e){return null!==e}yu.displayName=vu;var ju=e=>({name:"transformOrigin",options:e,fn(t){const{placement:a,rects:r,middlewareData:s}=t,n=0!==s.arrow?.centerOffset,o=n?0:e.arrowWidth,i=n?0:e.arrowHeight,[l,c]=Nu(a),d={start:"0%",center:"50%",end:"100%"}[c],u=(s.arrow?.x??0)+o/2,m=(s.arrow?.y??0)+i/2;let p="",h="";return"bottom"===l?(p=n?d:`${u}px`,h=-i+"px"):"top"===l?(p=n?d:`${u}px`,h=`${r.floating.height+i}px`):"right"===l?(p=-i+"px",h=n?d:`${m}px`):"left"===l&&(p=`${r.floating.width+i}px`,h=n?d:`${m}px`),{data:{x:p,y:h}}}});function Nu(e){const[t,a="center"]=e.split("-");return[t,a]}var Cu=uu,ku=pu,Su=xu,Eu=yu,Pu=G.forwardRef((t,a)=>{const{container:r,...s}=t,[n,o]=G.useState(!1);Vl(()=>o(!0),[]);const i=r||n&&globalThis?.document?.body;return i?O.createPortal(e.jsx(Hl.div,{...s,ref:a}),i):null});Pu.displayName="Portal";var Ru=e=>{const{present:t,children:a}=e,r=function(e){const[t,a]=G.useState(),r=G.useRef(null),s=G.useRef(e),n=G.useRef("none"),o=e?"mounted":"unmounted",[i,l]=function(e,t){return G.useReducer((e,a)=>t[e][a]??e,e)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return G.useEffect(()=>{const e=_u(r.current);n.current="mounted"===i?e:"none"},[i]),Vl(()=>{const t=r.current,a=s.current;if(a!==e){const r=n.current,o=_u(t);if(e)l("MOUNT");else if("none"===o||"none"===t?.display)l("UNMOUNT");else{l(a&&r!==o?"ANIMATION_OUT":"UNMOUNT")}s.current=e}},[e,l]),Vl(()=>{if(t){let e;const a=t.ownerDocument.defaultView??window,o=n=>{const o=_u(r.current).includes(CSS.escape(n.animationName));if(n.target===t&&o&&(l("ANIMATION_END"),!s.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=a.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},i=e=>{e.target===t&&(n.current=_u(r.current))};return t.addEventListener("animationstart",i),t.addEventListener("animationcancel",o),t.addEventListener("animationend",o),()=>{a.clearTimeout(e),t.removeEventListener("animationstart",i),t.removeEventListener("animationcancel",o),t.removeEventListener("animationend",o)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:G.useCallback(e=>{r.current=e?getComputedStyle(e):null,a(e)},[])}}(t),s="function"==typeof a?a({present:r.isPresent}):G.Children.only(a),n=Dl(r.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning;if(a)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(s));return"function"==typeof a||r.isPresent?G.cloneElement(s,{ref:n}):null};function _u(e){return e?.animationName||"none"}Ru.displayName="Presence";var Tu=G[" useInsertionEffect ".trim().toString()]||Vl;function Au({prop:e,defaultProp:t,onChange:a=()=>{},caller:r}){const[s,n,o]=function({defaultProp:e,onChange:t}){const[a,r]=G.useState(e),s=G.useRef(a),n=G.useRef(t);return Tu(()=>{n.current=t},[t]),G.useEffect(()=>{s.current!==a&&(n.current?.(a),s.current=a)},[a,s]),[a,r,n]}({defaultProp:t,onChange:a}),i=void 0!==e,l=i?e:s;{const t=G.useRef(void 0!==e);G.useEffect(()=>{const e=t.current;if(e!==i){}t.current=i},[i,r])}const c=G.useCallback(t=>{if(i){const a=function(e){return"function"==typeof e}(t)?t(e):t;a!==e&&o.current?.(a)}else n(t)},[i,e,n,o]);return[l,c]}var Mu="rovingFocusGroup.onEntryFocus",Iu={bubbles:!1,cancelable:!0},Lu="RovingFocusGroup",[Ou,Du,Fu]=Fl(Lu),[zu,$u]=Ml(Lu,[Fu]),[Uu,Vu]=zu(Lu),Bu=G.forwardRef((t,a)=>e.jsx(Ou.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Ou.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Wu,{...t,ref:a})})}));Bu.displayName=Lu;var Wu=G.forwardRef((t,a)=>{const{__scopeRovingFocusGroup:r,orientation:s,loop:n=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...m}=t,p=G.useRef(null),h=Dl(a,p),f=$l(o),[g,x]=Au({prop:i,defaultProp:l??null,onChange:c,caller:Lu}),[v,b]=G.useState(!1),y=Gl(d),w=Du(r),j=G.useRef(!1),[N,C]=G.useState(0);return G.useEffect(()=>{const e=p.current;if(e)return e.addEventListener(Mu,y),()=>e.removeEventListener(Mu,y)},[y]),e.jsx(Uu,{scope:r,orientation:s,dir:f,loop:n,currentTabStopId:g,onItemFocus:G.useCallback(e=>x(e),[x]),onItemShiftTab:G.useCallback(()=>b(!0),[]),onFocusableItemAdd:G.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:G.useCallback(()=>C(e=>e-1),[]),children:e.jsx(Hl.div,{tabIndex:v||0===N?-1:0,"data-orientation":s,...m,ref:h,style:{outline:"none",...t.style},onMouseDown:Ul(t.onMouseDown,()=>{j.current=!0}),onFocus:Ul(t.onFocus,e=>{const t=!j.current;if(e.target===e.currentTarget&&t&&!v){const t=new CustomEvent(Mu,Iu);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=w().filter(e=>e.focusable);Gu([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}j.current=!1}),onBlur:Ul(t.onBlur,()=>b(!1))})})}),qu="RovingFocusGroupItem",Hu=G.forwardRef((t,a)=>{const{__scopeRovingFocusGroup:r,focusable:s=!0,active:n=!1,tabStopId:o,children:i,...l}=t,c=ql(),d=o||c,u=Vu(qu,r),m=u.currentTabStopId===d,p=Du(r),{onFocusableItemAdd:h,onFocusableItemRemove:f,currentTabStopId:g}=u;return G.useEffect(()=>{if(s)return h(),()=>f()},[s,h,f]),e.jsx(Ou.ItemSlot,{scope:r,id:d,focusable:s,active:n,children:e.jsx(Hl.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...l,ref:a,onMouseDown:Ul(t.onMouseDown,e=>{s?u.onItemFocus(d):e.preventDefault()}),onFocus:Ul(t.onFocus,()=>u.onItemFocus(d)),onKeyDown:Ul(t.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,a){const r=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,a);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(r)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)?void 0:Ku[r]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let s=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)s.reverse();else if("prev"===t||"next"===t){"prev"===t&&s.reverse();const n=s.indexOf(e.currentTarget);s=u.loop?(r=n+1,(a=s).map((e,t)=>a[(r+t)%a.length])):s.slice(n+1)}setTimeout(()=>Gu(s))}var a,r}),children:"function"==typeof i?i({isCurrentTabStop:m,hasTabStop:null!=g}):i})})});Hu.displayName=qu;var Ku={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Gu(e,t=!1){const a=document.activeElement;for(const r of e){if(r===a)return;if(r.focus({preventScroll:t}),document.activeElement!==a)return}}var Qu=Bu,Xu=Hu,Ju=new WeakMap,Yu=new WeakMap,Zu={},em=0,tm=function(e){return e&&(e.host||tm(e.parentNode))},am=function(e,t,a,r){var s=function(e,t){return t.map(function(t){if(e.contains(t))return t;var a=tm(t);return a&&e.contains(a)?a:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Zu[a]||(Zu[a]=new WeakMap);var n=Zu[a],o=[],i=new Set,l=new Set(s),c=function(e){e&&!i.has(e)&&(i.add(e),c(e.parentNode))};s.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(i.has(e))d(e);else try{var t=e.getAttribute(r),s=null!==t&&"false"!==t,l=(Ju.get(e)||0)+1,c=(n.get(e)||0)+1;Ju.set(e,l),n.set(e,c),o.push(e),1===l&&s&&Yu.set(e,!0),1===c&&e.setAttribute(a,"true"),s||e.setAttribute(r,"true")}catch(u){}})};return d(t),i.clear(),em++,function(){o.forEach(function(e){var t=Ju.get(e)-1,s=n.get(e)-1;Ju.set(e,t),n.set(e,s),t||(Yu.has(e)||e.removeAttribute(r),Yu.delete(e)),s||e.removeAttribute(a)}),--em||(Ju=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,Zu={})}},rm=function(e,t,a){void 0===a&&(a="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),am(r,s,a,"aria-hidden")):function(){return null}},sm=function(){return sm=Object.assign||function(e){for(var t,a=1,r=arguments.length;a<r;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},sm.apply(this,arguments)};function nm(e,t){var a={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(a[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(a[r[s]]=e[r[s]])}return a}"function"==typeof SuppressedError&&SuppressedError;var om="right-scroll-bar-position",im="width-before-scroll-bar";function lm(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var cm="undefined"!=typeof window?G.useLayoutEffect:G.useEffect,dm=new WeakMap;function um(e,a){var r,s,n,o=(r=null,s=function(t){return e.forEach(function(e){return lm(e,t)})},n=t.useState(function(){return{value:r,callback:s,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0],n.callback=s,n.facade);return cm(function(){var t=dm.get(o);if(t){var a=new Set(t),r=new Set(e),s=o.current;a.forEach(function(e){r.has(e)||lm(e,null)}),r.forEach(function(e){a.has(e)||lm(e,s)})}dm.set(o,e)},[e]),o}function mm(e){return e}var pm=function(e){var t=e.sideCar,a=nm(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return G.createElement(r,sm({},a))};pm.isSideCarExport=!0;var hm=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=mm);var a=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return a.length?a[a.length-1]:e},useMedium:function(e){var s=t(e,r);return a.push(s),function(){a=a.filter(function(e){return e!==s})}},assignSyncMedium:function(e){for(r=!0;a.length;){var t=a;a=[],t.forEach(e)}a={push:function(t){return e(t)},filter:function(){return a}}},assignMedium:function(e){r=!0;var t=[];if(a.length){var s=a;a=[],s.forEach(e),t=a}var n=function(){var a=t;t=[],a.forEach(e)},o=function(){return Promise.resolve().then(n)};o(),a={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),a}}}}}(null);return t.options=sm({async:!0,ssr:!1},e),t}(),fm=function(){},gm=G.forwardRef(function(e,t){var a=G.useRef(null),r=G.useState({onScrollCapture:fm,onWheelCapture:fm,onTouchMoveCapture:fm}),s=r[0],n=r[1],o=e.forwardProps,i=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,u=e.shards,m=e.sideCar,p=e.noRelative,h=e.noIsolation,f=e.inert,g=e.allowPinchZoom,x=e.as,v=void 0===x?"div":x,b=e.gapMode,y=nm(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=m,j=um([a,t]),N=sm(sm({},y),s);return G.createElement(G.Fragment,null,d&&G.createElement(w,{sideCar:hm,removeScrollBar:c,shards:u,noRelative:p,noIsolation:h,inert:f,setCallbacks:n,allowPinchZoom:!!g,lockRef:a,gapMode:b}),o?G.cloneElement(G.Children.only(i),sm(sm({},N),{ref:j})):G.createElement(v,sm({},N,{className:l,ref:j}),i))});gm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gm.classNames={fullWidth:im,zeroRight:om};function xm(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var vm=function(){var e=0,t=null;return{add:function(a){var r,s;0==e&&(t=xm())&&(s=a,(r=t).styleSheet?r.styleSheet.cssText=s:r.appendChild(document.createTextNode(s)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},bm=function(){var e,t=(e=vm(),function(t,a){G.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&a])});return function(e){var a=e.styles,r=e.dynamic;return t(a,r),null}},ym={left:0,top:0,right:0,gap:0},wm=function(e){return parseInt(e||"",10)||0},jm=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return ym;var t=function(e){var t=window.getComputedStyle(document.body),a=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],s=t["padding"===e?"paddingRight":"marginRight"];return[wm(a),wm(r),wm(s)]}(e),a=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-a+t[2]-t[0])}},Nm=bm(),Cm="data-scroll-locked",km=function(e,t,a,r){var s=e.left,n=e.top,o=e.right,i=e.gap;return void 0===a&&(a="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(i,"px ").concat(r,";\n }\n body[").concat(Cm,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===a&&"\n padding-left: ".concat(s,"px;\n padding-top: ").concat(n,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(i,"px ").concat(r,";\n "),"padding"===a&&"padding-right: ".concat(i,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(om," {\n right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(im," {\n margin-right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(om," .").concat(om," {\n right: 0 ").concat(r,";\n }\n \n .").concat(im," .").concat(im," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(Cm,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(i,"px;\n }\n")},Sm=function(){var e=parseInt(document.body.getAttribute(Cm)||"0",10);return isFinite(e)?e:0},Em=function(e){var t=e.noRelative,a=e.noImportant,r=e.gapMode,s=void 0===r?"margin":r;G.useEffect(function(){return document.body.setAttribute(Cm,(Sm()+1).toString()),function(){var e=Sm()-1;e<=0?document.body.removeAttribute(Cm):document.body.setAttribute(Cm,e.toString())}},[]);var n=G.useMemo(function(){return jm(s)},[s]);return G.createElement(Nm,{styles:km(n,!t,s,a?"":"!important")})},Pm=!1;if("undefined"!=typeof window)try{var Rm=Object.defineProperty({},"passive",{get:function(){return Pm=!0,!0}});window.addEventListener("test",Rm,Rm),window.removeEventListener("test",Rm,Rm)}catch(Wg){Pm=!1}var _m=!!Pm&&{passive:!1},Tm=function(e,t){if(!(e instanceof Element))return!1;var a=window.getComputedStyle(e);return"hidden"!==a[t]&&!(a.overflowY===a.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===a[t])},Am=function(e,t){var a=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Mm(e,r)){var s=Im(e,r);if(s[1]>s[2])return!0}r=r.parentNode}while(r&&r!==a.body);return!1},Mm=function(e,t){return"v"===e?function(e){return Tm(e,"overflowY")}(t):function(e){return Tm(e,"overflowX")}(t)},Im=function(e,t){return"v"===e?[(a=t).scrollTop,a.scrollHeight,a.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var a},Lm=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Om=function(e){return[e.deltaX,e.deltaY]},Dm=function(e){return e&&"current"in e?e.current:e},Fm=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},zm=0,$m=[];function Um(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Vm,Bm=(Vm=function(e){var t=G.useRef([]),a=G.useRef([0,0]),r=G.useRef(),s=G.useState(zm++)[0],n=G.useState(bm)[0],o=G.useRef(e);G.useEffect(function(){o.current=e},[e]),G.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var t=function(e,t,a){if(a||2===arguments.length)for(var r,s=0,n=t.length;s<n;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(Dm),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var i=G.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var s,n=Lm(e),i=a.current,l="deltaX"in e?e.deltaX:i[0]-n[0],c="deltaY"in e?e.deltaY:i[1]-n[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var m=Am(u,d);if(!m)return!0;if(m?s=u:(s="v"===u?"h":"v",m=Am(u,d)),!m)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=s),!s)return!0;var p=r.current||s;return function(e,t,a,r){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),n=s*r,o=a.target,i=t.contains(o),l=!1,c=n>0,d=0,u=0;do{if(!o)break;var m=Im(e,o),p=m[0],h=m[1]-m[2]-s*p;(p||h)&&Mm(e,o)&&(d+=h,u+=p);var f=o.parentNode;o=f&&f.nodeType===Node.DOCUMENT_FRAGMENT_NODE?f.host:f}while(!i&&o!==document.body||i&&(t.contains(o)||t===o));return(c&&Math.abs(d)<1||!c&&Math.abs(u)<1)&&(l=!0),l}(p,t,e,"h"===p?l:c)},[]),l=G.useCallback(function(e){var a=e;if($m.length&&$m[$m.length-1]===n){var r="deltaY"in a?Om(a):Lm(a),s=t.current.filter(function(e){return e.name===a.type&&(e.target===a.target||a.target===e.shadowParent)&&(t=e.delta,s=r,t[0]===s[0]&&t[1]===s[1]);var t,s})[0];if(s&&s.should)a.cancelable&&a.preventDefault();else if(!s){var l=(o.current.shards||[]).map(Dm).filter(Boolean).filter(function(e){return e.contains(a.target)});(l.length>0?i(a,l[0]):!o.current.noIsolation)&&a.cancelable&&a.preventDefault()}}},[]),c=G.useCallback(function(e,a,r,s){var n={name:e,delta:a,target:r,should:s,shadowParent:Um(r)};t.current.push(n),setTimeout(function(){t.current=t.current.filter(function(e){return e!==n})},1)},[]),d=G.useCallback(function(e){a.current=Lm(e),r.current=void 0},[]),u=G.useCallback(function(t){c(t.type,Om(t),t.target,i(t,e.lockRef.current))},[]),m=G.useCallback(function(t){c(t.type,Lm(t),t.target,i(t,e.lockRef.current))},[]);G.useEffect(function(){return $m.push(n),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:m}),document.addEventListener("wheel",l,_m),document.addEventListener("touchmove",l,_m),document.addEventListener("touchstart",d,_m),function(){$m=$m.filter(function(e){return e!==n}),document.removeEventListener("wheel",l,_m),document.removeEventListener("touchmove",l,_m),document.removeEventListener("touchstart",d,_m)}},[]);var p=e.removeScrollBar,h=e.inert;return G.createElement(G.Fragment,null,h?G.createElement(n,{styles:Fm(s)}):null,p?G.createElement(Em,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},hm.useMedium(Vm),pm),Wm=G.forwardRef(function(e,t){return G.createElement(gm,sm({},e,{ref:t,sideCar:Bm}))});Wm.classNames=gm.classNames;var qm=["Enter"," "],Hm=["ArrowUp","PageDown","End"],Km=["ArrowDown","PageUp","Home",...Hm],Gm={ltr:[...qm,"ArrowRight"],rtl:[...qm,"ArrowLeft"]},Qm={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Xm="Menu",[Jm,Ym,Zm]=Fl(Xm),[ep,tp]=Ml(Xm,[Zm,lu,$u]),ap=lu(),rp=$u(),[sp,np]=ep(Xm),[op,ip]=ep(Xm),lp=t=>{const{__scopeMenu:a,open:r=!1,children:s,dir:n,onOpenChange:o,modal:i=!0}=t,l=ap(a),[c,d]=G.useState(null),u=G.useRef(!1),m=Gl(o),p=$l(n);return G.useEffect(()=>{const e=()=>{u.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),e.jsx(Cu,{...l,children:e.jsx(sp,{scope:a,open:r,onOpenChange:m,content:c,onContentChange:d,children:e.jsx(op,{scope:a,onClose:G.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:u,dir:p,modal:i,children:s})})})};lp.displayName=Xm;var cp=G.forwardRef((t,a)=>{const{__scopeMenu:r,...s}=t,n=ap(r);return e.jsx(ku,{...n,...s,ref:a})});cp.displayName="MenuAnchor";var dp="MenuPortal",[up,mp]=ep(dp,{forceMount:void 0}),pp=t=>{const{__scopeMenu:a,forceMount:r,children:s,container:n}=t,o=np(dp,a);return e.jsx(up,{scope:a,forceMount:r,children:e.jsx(Ru,{present:r||o.open,children:e.jsx(Pu,{asChild:!0,container:n,children:s})})})};pp.displayName=dp;var hp="MenuContent",[fp,gp]=ep(hp),xp=G.forwardRef((t,a)=>{const r=mp(hp,t.__scopeMenu),{forceMount:s=r.forceMount,...n}=t,o=np(hp,t.__scopeMenu),i=ip(hp,t.__scopeMenu);return e.jsx(Jm.Provider,{scope:t.__scopeMenu,children:e.jsx(Ru,{present:s||o.open,children:e.jsx(Jm.Slot,{scope:t.__scopeMenu,children:i.modal?e.jsx(vp,{...n,ref:a}):e.jsx(bp,{...n,ref:a})})})})}),vp=G.forwardRef((t,a)=>{const r=np(hp,t.__scopeMenu),s=G.useRef(null),n=Dl(a,s);return G.useEffect(()=>{const e=s.current;if(e)return rm(e)},[]),e.jsx(wp,{...t,ref:n,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ul(t.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),bp=G.forwardRef((t,a)=>{const r=np(hp,t.__scopeMenu);return e.jsx(wp,{...t,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),yp=a.createSlot("MenuContent.ScrollLock"),wp=G.forwardRef((t,a)=>{const{__scopeMenu:r,loop:s=!1,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:p,onDismiss:h,disableOutsideScroll:f,...g}=t,x=np(hp,r),v=ip(hp,r),b=ap(r),y=rp(r),w=Ym(r),[j,N]=G.useState(null),C=G.useRef(null),k=Dl(a,C,x.onContentChange),S=G.useRef(0),E=G.useRef(""),P=G.useRef(0),R=G.useRef(null),_=G.useRef("right"),T=G.useRef(0),A=f?Wm:G.Fragment,M=f?{as:yp,allowPinchZoom:!0}:void 0,I=e=>{const t=E.current+e,a=w().filter(e=>!e.disabled),r=document.activeElement,s=a.find(e=>e.ref.current===r)?.textValue,n=function(e,t,a){const r=t.length>1&&Array.from(t).every(e=>e===t[0]),s=r?t[0]:t,n=a?e.indexOf(a):-1;let o=(i=e,l=Math.max(n,0),i.map((e,t)=>i[(l+t)%i.length]));var i,l;1===s.length&&(o=o.filter(e=>e!==a));const c=o.find(e=>e.toLowerCase().startsWith(s.toLowerCase()));return c!==a?c:void 0}(a.map(e=>e.textValue),t,s),o=a.find(e=>e.textValue===n)?.ref.current;!function e(t){E.current=t,window.clearTimeout(S.current),""!==t&&(S.current=window.setTimeout(()=>e(""),1e3))}(t),o&&setTimeout(()=>o.focus())};G.useEffect(()=>()=>window.clearTimeout(S.current),[]),G.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sc()),document.body.insertAdjacentElement("beforeend",e[1]??sc()),rc++,()=>{1===rc&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),rc--}},[]);const L=G.useCallback(e=>_.current===R.current?.side&&function(e,t){if(!t)return!1;const a={x:e.clientX,y:e.clientY};return function(e,t){const{x:a,y:r}=e;let s=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const e=t[n],i=t[o],l=e.x,c=e.y,d=i.x,u=i.y;c>r!=u>r&&a<(d-l)*(r-c)/(u-c)+l&&(s=!s)}return s}(a,t)}(e,R.current?.area),[]);return e.jsx(fp,{scope:r,searchRef:E,onItemEnter:G.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:G.useCallback(e=>{L(e)||(C.current?.focus(),N(null))},[L]),onTriggerLeave:G.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:P,onPointerGraceIntentChange:G.useCallback(e=>{R.current=e},[]),children:e.jsx(A,{...M,children:e.jsx(lc,{asChild:!0,trapped:n,onMountAutoFocus:Ul(o,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:e.jsx(ec,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:p,onDismiss:h,children:e.jsx(Qu,{asChild:!0,...y,dir:v.dir,orientation:"vertical",loop:s,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:Ul(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Su,{role:"menu","aria-orientation":"vertical","data-state":Qp(x.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:Ul(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,a=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!a&&r&&I(e.key));const s=C.current;if(e.target!==s)return;if(!Km.includes(e.key))return;e.preventDefault();const n=w().filter(e=>!e.disabled).map(e=>e.ref.current);Hm.includes(e.key)&&n.reverse(),function(e){const t=document.activeElement;for(const a of e){if(a===t)return;if(a.focus(),document.activeElement!==t)return}}(n)}),onBlur:Ul(t.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(S.current),E.current="")}),onPointerMove:Ul(t.onPointerMove,Yp(e=>{const t=e.target,a=T.current!==e.clientX;if(e.currentTarget.contains(t)&&a){const t=e.clientX>T.current?"right":"left";_.current=t,T.current=e.clientX}}))})})})})})})});xp.displayName=hp;var jp=G.forwardRef((t,a)=>{const{__scopeMenu:r,...s}=t;return e.jsx(Hl.div,{role:"group",...s,ref:a})});jp.displayName="MenuGroup";var Np=G.forwardRef((t,a)=>{const{__scopeMenu:r,...s}=t;return e.jsx(Hl.div,{...s,ref:a})});Np.displayName="MenuLabel";var Cp="MenuItem",kp="menu.itemSelect",Sp=G.forwardRef((t,a)=>{const{disabled:r=!1,onSelect:s,...n}=t,o=G.useRef(null),i=ip(Cp,t.__scopeMenu),l=gp(Cp,t.__scopeMenu),c=Dl(a,o),d=G.useRef(!1);return e.jsx(Ep,{...n,ref:c,disabled:r,onClick:Ul(t.onClick,()=>{const e=o.current;if(!r&&e){const t=new CustomEvent(kp,{bubbles:!0,cancelable:!0});e.addEventListener(kp,e=>s?.(e),{once:!0}),Kl(e,t),t.defaultPrevented?d.current=!1:i.onClose()}}),onPointerDown:e=>{t.onPointerDown?.(e),d.current=!0},onPointerUp:Ul(t.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:Ul(t.onKeyDown,e=>{const t=""!==l.searchRef.current;r||t&&" "===e.key||qm.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Sp.displayName=Cp;var Ep=G.forwardRef((t,a)=>{const{__scopeMenu:r,disabled:s=!1,textValue:n,...o}=t,i=gp(Cp,r),l=rp(r),c=G.useRef(null),d=Dl(a,c),[u,m]=G.useState(!1),[p,h]=G.useState("");return G.useEffect(()=>{const e=c.current;e&&h((e.textContent??"").trim())},[o.children]),e.jsx(Jm.ItemSlot,{scope:r,disabled:s,textValue:n??p,children:e.jsx(Xu,{asChild:!0,...l,focusable:!s,children:e.jsx(Hl.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...o,ref:d,onPointerMove:Ul(t.onPointerMove,Yp(e=>{if(s)i.onItemLeave(e);else if(i.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:Ul(t.onPointerLeave,Yp(e=>i.onItemLeave(e))),onFocus:Ul(t.onFocus,()=>m(!0)),onBlur:Ul(t.onBlur,()=>m(!1))})})})}),Pp=G.forwardRef((t,a)=>{const{checked:r=!1,onCheckedChange:s,...n}=t;return e.jsx(Op,{scope:t.__scopeMenu,checked:r,children:e.jsx(Sp,{role:"menuitemcheckbox","aria-checked":Xp(r)?"mixed":r,...n,ref:a,"data-state":Jp(r),onSelect:Ul(n.onSelect,()=>s?.(!!Xp(r)||!r),{checkForDefaultPrevented:!1})})})});Pp.displayName="MenuCheckboxItem";var Rp="MenuRadioGroup",[_p,Tp]=ep(Rp,{value:void 0,onValueChange:()=>{}}),Ap=G.forwardRef((t,a)=>{const{value:r,onValueChange:s,...n}=t,o=Gl(s);return e.jsx(_p,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(jp,{...n,ref:a})})});Ap.displayName=Rp;var Mp="MenuRadioItem",Ip=G.forwardRef((t,a)=>{const{value:r,...s}=t,n=Tp(Mp,t.__scopeMenu),o=r===n.value;return e.jsx(Op,{scope:t.__scopeMenu,checked:o,children:e.jsx(Sp,{role:"menuitemradio","aria-checked":o,...s,ref:a,"data-state":Jp(o),onSelect:Ul(s.onSelect,()=>n.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});Ip.displayName=Mp;var Lp="MenuItemIndicator",[Op,Dp]=ep(Lp,{checked:!1}),Fp=G.forwardRef((t,a)=>{const{__scopeMenu:r,forceMount:s,...n}=t,o=Dp(Lp,r);return e.jsx(Ru,{present:s||Xp(o.checked)||!0===o.checked,children:e.jsx(Hl.span,{...n,ref:a,"data-state":Jp(o.checked)})})});Fp.displayName=Lp;var zp=G.forwardRef((t,a)=>{const{__scopeMenu:r,...s}=t;return e.jsx(Hl.div,{role:"separator","aria-orientation":"horizontal",...s,ref:a})});zp.displayName="MenuSeparator";var $p=G.forwardRef((t,a)=>{const{__scopeMenu:r,...s}=t,n=ap(r);return e.jsx(Eu,{...n,...s,ref:a})});$p.displayName="MenuArrow";var Up="MenuSub",[Vp,Bp]=ep(Up),Wp=t=>{const{__scopeMenu:a,children:r,open:s=!1,onOpenChange:n}=t,o=np(Up,a),i=ap(a),[l,c]=G.useState(null),[d,u]=G.useState(null),m=Gl(n);return G.useEffect(()=>(!1===o.open&&m(!1),()=>m(!1)),[o.open,m]),e.jsx(Cu,{...i,children:e.jsx(sp,{scope:a,open:s,onOpenChange:m,content:d,onContentChange:u,children:e.jsx(Vp,{scope:a,contentId:ql(),triggerId:ql(),trigger:l,onTriggerChange:c,children:r})})})};Wp.displayName=Up;var qp="MenuSubTrigger",Hp=G.forwardRef((t,a)=>{const r=np(qp,t.__scopeMenu),s=ip(qp,t.__scopeMenu),n=Bp(qp,t.__scopeMenu),o=gp(qp,t.__scopeMenu),i=G.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,d={__scopeMenu:t.__scopeMenu},u=G.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return G.useEffect(()=>u,[u]),G.useEffect(()=>{const e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),e.jsx(cp,{asChild:!0,...d,children:e.jsx(Ep,{id:n.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":n.contentId,"data-state":Qp(r.open),...t,ref:Ol(a,n.onTriggerChange),onClick:e=>{t.onClick?.(e),t.disabled||e.defaultPrevented||(e.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ul(t.onPointerMove,Yp(e=>{o.onItemEnter(e),e.defaultPrevented||t.disabled||r.open||i.current||(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:Ul(t.onPointerLeave,Yp(e=>{u();const t=r.content?.getBoundingClientRect();if(t){const a=r.content?.dataset.side,s="right"===a,n=s?-5:5,i=t[s?"left":"right"],c=t[s?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+n,y:e.clientY},{x:i,y:t.top},{x:c,y:t.top},{x:c,y:t.bottom},{x:i,y:t.bottom}],side:a}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ul(t.onKeyDown,e=>{const a=""!==o.searchRef.current;t.disabled||a&&" "===e.key||Gm[s.dir].includes(e.key)&&(r.onOpenChange(!0),r.content?.focus(),e.preventDefault())})})})});Hp.displayName=qp;var Kp="MenuSubContent",Gp=G.forwardRef((t,a)=>{const r=mp(hp,t.__scopeMenu),{forceMount:s=r.forceMount,...n}=t,o=np(hp,t.__scopeMenu),i=ip(hp,t.__scopeMenu),l=Bp(Kp,t.__scopeMenu),c=G.useRef(null),d=Dl(a,c);return e.jsx(Jm.Provider,{scope:t.__scopeMenu,children:e.jsx(Ru,{present:s||o.open,children:e.jsx(Jm.Slot,{scope:t.__scopeMenu,children:e.jsx(wp,{id:l.contentId,"aria-labelledby":l.triggerId,...n,ref:d,align:"start",side:"rtl"===i.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{i.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Ul(t.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ul(t.onEscapeKeyDown,e=>{i.onClose(),e.preventDefault()}),onKeyDown:Ul(t.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),a=Qm[i.dir].includes(e.key);t&&a&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function Qp(e){return e?"open":"closed"}function Xp(e){return"indeterminate"===e}function Jp(e){return Xp(e)?"indeterminate":e?"checked":"unchecked"}function Yp(e){return t=>"mouse"===t.pointerType?e(t):void 0}Gp.displayName=Kp;var Zp=lp,eh=cp,th=pp,ah=xp,rh=jp,sh=Np,nh=Sp,oh=Pp,ih=Ap,lh=Ip,ch=Fp,dh=zp,uh=$p,mh=Wp,ph=Hp,hh=Gp,fh="Menubar",[gh,xh,vh]=Fl(fh),[bh]=Ml(fh,[vh,$u]),yh=tp(),wh=$u(),[jh,Nh]=bh(fh),Ch=G.forwardRef((t,a)=>{const{__scopeMenubar:r,value:s,onValueChange:n,defaultValue:o,loop:i=!0,dir:l,...c}=t,d=$l(l),u=wh(r),[m,p]=Au({prop:s,onChange:n,defaultProp:o??"",caller:fh}),[h,f]=G.useState(null);return e.jsx(jh,{scope:r,value:m,onMenuOpen:G.useCallback(e=>{p(e),f(e)},[p]),onMenuClose:G.useCallback(()=>p(""),[p]),onMenuToggle:G.useCallback(e=>{p(t=>t?"":e),f(e)},[p]),dir:d,loop:i,children:e.jsx(gh.Provider,{scope:r,children:e.jsx(gh.Slot,{scope:r,children:e.jsx(Qu,{asChild:!0,...u,orientation:"horizontal",loop:i,dir:d,currentTabStopId:h,onCurrentTabStopIdChange:f,children:e.jsx(Hl.div,{role:"menubar",...c,ref:a})})})})})});Ch.displayName=fh;var kh="MenubarMenu",[Sh,Eh]=bh(kh),Ph=t=>{const{__scopeMenubar:a,value:r,...s}=t,n=ql(),o=r||n||"LEGACY_REACT_AUTO_VALUE",i=Nh(kh,a),l=yh(a),c=G.useRef(null),d=G.useRef(!1),u=i.value===o;return G.useEffect(()=>{u||(d.current=!1)},[u]),e.jsx(Sh,{scope:a,value:o,triggerId:ql(),triggerRef:c,contentId:ql(),wasKeyboardTriggerOpenRef:d,children:e.jsx(Zp,{...l,open:u,onOpenChange:e=>{e||i.onMenuClose()},modal:!1,dir:i.dir,...s})})};Ph.displayName=kh;var Rh="MenubarTrigger",_h=G.forwardRef((t,a)=>{const{__scopeMenubar:r,disabled:s=!1,...n}=t,o=wh(r),i=yh(r),l=Nh(Rh,r),c=Eh(Rh,r),d=G.useRef(null),u=Dl(a,d,c.triggerRef),[m,p]=G.useState(!1),h=l.value===c.value;return e.jsx(gh.ItemSlot,{scope:r,value:c.value,disabled:s,children:e.jsx(Xu,{asChild:!0,...o,focusable:!s,tabStopId:c.value,children:e.jsx(eh,{asChild:!0,...i,children:e.jsx(Hl.button,{type:"button",role:"menuitem",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?c.contentId:void 0,"data-highlighted":m?"":void 0,"data-state":h?"open":"closed","data-disabled":s?"":void 0,disabled:s,...n,ref:u,onPointerDown:Ul(t.onPointerDown,e=>{s||0!==e.button||!1!==e.ctrlKey||(l.onMenuOpen(c.value),h||e.preventDefault())}),onPointerEnter:Ul(t.onPointerEnter,()=>{Boolean(l.value)&&!h&&(l.onMenuOpen(c.value),d.current?.focus())}),onKeyDown:Ul(t.onKeyDown,e=>{s||(["Enter"," "].includes(e.key)&&l.onMenuToggle(c.value),"ArrowDown"===e.key&&l.onMenuOpen(c.value),["Enter"," ","ArrowDown"].includes(e.key)&&(c.wasKeyboardTriggerOpenRef.current=!0,e.preventDefault()))}),onFocus:Ul(t.onFocus,()=>p(!0)),onBlur:Ul(t.onBlur,()=>p(!1))})})})})});_h.displayName=Rh;var Th=t=>{const{__scopeMenubar:a,...r}=t,s=yh(a);return e.jsx(th,{...s,...r})};Th.displayName="MenubarPortal";var Ah="MenubarContent",Mh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,align:s="start",...n}=t,o=yh(r),i=Nh(Ah,r),l=Eh(Ah,r),c=xh(r),d=G.useRef(!1);return e.jsx(ah,{id:l.contentId,"aria-labelledby":l.triggerId,"data-radix-menubar-content":"",...o,...n,ref:a,align:s,onCloseAutoFocus:Ul(t.onCloseAutoFocus,e=>{Boolean(i.value)||d.current||l.triggerRef.current?.focus(),d.current=!1,e.preventDefault()}),onFocusOutside:Ul(t.onFocusOutside,e=>{const t=e.target;c().some(e=>e.ref.current?.contains(t))&&e.preventDefault()}),onInteractOutside:Ul(t.onInteractOutside,()=>{d.current=!0}),onEntryFocus:e=>{l.wasKeyboardTriggerOpenRef.current||e.preventDefault()},onKeyDown:Ul(t.onKeyDown,e=>{if(["ArrowRight","ArrowLeft"].includes(e.key)){const r=e.target,s=r.hasAttribute("data-radix-menubar-subtrigger"),n=r.closest("[data-radix-menubar-content]")!==e.currentTarget,o=("rtl"===i.dir?"ArrowRight":"ArrowLeft")===e.key;if(!o&&s)return;if(n&&o)return;let d=c().filter(e=>!e.disabled).map(e=>e.value);o&&d.reverse();const u=d.indexOf(l.value);d=i.loop?(a=u+1,(t=d).map((e,r)=>t[(a+r)%t.length])):d.slice(u+1);const[m]=d;m&&i.onMenuOpen(m)}var t,a},{checkForDefaultPrevented:!1}),style:{...t.style,"--radix-menubar-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-menubar-content-available-width":"var(--radix-popper-available-width)","--radix-menubar-content-available-height":"var(--radix-popper-available-height)","--radix-menubar-trigger-width":"var(--radix-popper-anchor-width)","--radix-menubar-trigger-height":"var(--radix-popper-anchor-height)"}})});Mh.displayName=Ah;var Ih=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(rh,{...n,...s,ref:a})});Ih.displayName="MenubarGroup";var Lh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(sh,{...n,...s,ref:a})});Lh.displayName="MenubarLabel";var Oh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(nh,{...n,...s,ref:a})});Oh.displayName="MenubarItem";var Dh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(oh,{...n,...s,ref:a})});Dh.displayName="MenubarCheckboxItem";var Fh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(ih,{...n,...s,ref:a})});Fh.displayName="MenubarRadioGroup";var zh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(lh,{...n,...s,ref:a})});zh.displayName="MenubarRadioItem";var $h=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(ch,{...n,...s,ref:a})});$h.displayName="MenubarItemIndicator";var Uh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(dh,{...n,...s,ref:a})});Uh.displayName="MenubarSeparator";G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(uh,{...n,...s,ref:a})}).displayName="MenubarArrow";var Vh="MenubarSub",Bh=t=>{const{__scopeMenubar:a,children:r,open:s,onOpenChange:n,defaultOpen:o}=t,i=yh(a),[l,c]=Au({prop:s,defaultProp:o??!1,onChange:n,caller:Vh});return e.jsx(mh,{...i,open:l,onOpenChange:c,children:r})};Bh.displayName=Vh;var Wh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(ph,{"data-radix-menubar-subtrigger":"",...n,...s,ref:a})});Wh.displayName="MenubarSubTrigger";var qh=G.forwardRef((t,a)=>{const{__scopeMenubar:r,...s}=t,n=yh(r);return e.jsx(hh,{...n,"data-radix-menubar-content":"",...s,ref:a,style:{...t.style,"--radix-menubar-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-menubar-content-available-width":"var(--radix-popper-available-width)","--radix-menubar-content-available-height":"var(--radix-popper-available-height)","--radix-menubar-trigger-width":"var(--radix-popper-anchor-width)","--radix-menubar-trigger-height":"var(--radix-popper-anchor-height)"}})});qh.displayName="MenubarSubContent";var Hh=Ch,Kh=_h,Gh=Th,Qh=Mh,Xh=Lh,Jh=Oh,Yh=Dh,Zh=zh,ef=$h,tf=Uh,af=Wh,rf=qh;const sf=Ph,nf=Ih,of=Gh,lf=Bh,cf=Fh,df=G.forwardRef(({className:t,...a},r)=>e.jsx(Hh,{ref:r,className:ct("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));df.displayName=Hh.displayName;const uf=G.forwardRef(({className:t,...a},r)=>e.jsx(Kh,{ref:r,className:ct("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t),...a}));uf.displayName=Kh.displayName;const mf=G.forwardRef(({className:t,inset:a,children:r,...s},n)=>e.jsxs(af,{ref:n,className:ct("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",a&&"pl-8",t),...s,children:[r,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));mf.displayName=af.displayName;const pf=G.forwardRef(({className:t,...a},r)=>e.jsx(rf,{ref:r,className:ct("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground 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}));pf.displayName=rf.displayName;const hf=G.forwardRef(({className:t,align:a="start",alignOffset:r=-4,sideOffset:s=8,...n},o)=>e.jsx(Gh,{children:e.jsx(Qh,{ref:o,align:a,alignOffset:r,sideOffset:s,className:ct("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in 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})}));hf.displayName=Qh.displayName;const ff=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(Jh,{ref:s,className:ct("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}));ff.displayName=Jh.displayName;const gf=G.forwardRef(({className:t,children:a,checked:r,...s},n)=>e.jsxs(Yh,{ref:n,className:ct("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",t),checked:r,...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ef,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));gf.displayName=Yh.displayName;const xf=G.forwardRef(({className:t,children:a,...r},s)=>e.jsxs(Zh,{ref:s,className:ct("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",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ef,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));xf.displayName=Zh.displayName;const vf=G.forwardRef(({className:t,inset:a,...r},s)=>e.jsx(Xh,{ref:s,className:ct("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...r}));vf.displayName=Xh.displayName;const bf=G.forwardRef(({className:t,...a},r)=>e.jsx(tf,{ref:r,className:ct("-mx-1 my-1 h-px bg-muted",t),...a}));bf.displayName=tf.displayName;const yf=({className:t,...a})=>e.jsx("span",{className:ct("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});yf.displayname="MenubarShortcut";const wf={light:"",dark:".dark"},jf=G.createContext(null);function Nf(){const e=G.useContext(jf);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Cf=G.forwardRef(({id:t,className:a,children:r,config:s,...n},o)=>{const i=G.useId(),l=`chart-${t||i.replace(/:/g,"")}`;return e.jsx(jf.Provider,{value:{config:s},children:e.jsxs("div",{"data-chart":l,ref:o,className:ct("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[e.jsx(kf,{id:l,config:s}),e.jsx(xe.ResponsiveContainer,{children:r})]})})});Cf.displayName="Chart";const kf=({id:t,config:a})=>{const r=Object.entries(a).filter(([,e])=>e.theme||e.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(wf).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${r.map(([t,a])=>{const r=a.theme?.[e]||a.color;return r?` --color-${t}: ${r};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Sf=xe.Tooltip,Ef=G.forwardRef(({active:t,payload:a,className:r,indicator:s="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:c,formatter:d,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=Nf(),g=G.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,r=_f(f,t,`${p||t?.dataKey||t?.name||"value"}`),s=p||"string"!=typeof i?r?.label:f[i]?.label||i;return l?e.jsx("div",{className:ct("font-medium",c),children:l(s,a)}):s?e.jsx("div",{className:ct("font-medium",c),children:s}):null},[i,l,a,n,c,f,p]);if(!t||!a?.length)return null;const x=1===a.length&&"dot"!==s;return e.jsxs("div",{ref:h,className:ct("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[x?null:g,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const r=`${m||t.name||t.dataKey||"value"}`,n=_f(f,t,r),i=u||t.payload?.fill||t.color;return e.jsx("div",{className:ct("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===s&&"items-center"),children:d&&void 0!==t?.value&&t.name?d(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:ct("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===s,"w-1":"line"===s,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===s,"my-0.5":x&&"dashed"===s}),style:{"--color-bg":i,"--color-border":i}}),e.jsxs("div",{className:ct("flex flex-1 justify-between leading-none",x?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[x?g:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});Ef.displayName="ChartTooltip";const Pf=xe.Legend,Rf=G.forwardRef(({className:t,hideIcon:a=!1,payload:r,verticalAlign:s="bottom",nameKey:n},o)=>{const{config:i}=Nf();return r?.length?e.jsx("div",{ref:o,className:ct("flex items-center justify-center gap-4","top"===s?"pb-3":"pt-3",t),children:r.map(t=>{const r=`${n||t.dataKey||"value"}`,s=_f(i,t,r);return e.jsxs("div",{className:ct("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[s?.icon&&!a?e.jsx(s.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),s?.label]},t.value)})}):null});function _f(e,t,a){if("object"!=typeof t||null===t)return;const r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let s=a;return a in t&&"string"==typeof t[a]?s=t[a]:r&&a in r&&"string"==typeof r[a]&&(s=r[a]),s in e?e[s]:e[a]}Rf.displayName="ChartLegend";const Tf=({onClick:t,isActive:a,disabled:r,children:s,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:r,title:n,className:ct("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",r&&"opacity-50 cursor-not-allowed"),children:s}),Af=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Mf({onEdit:t,onDelete:a,onToggleStatus:r,isActive:s=!0,canEdit:n=!0,canDelete:o=!0,customActions:i=[],renderAs:c="dropdown",variant:d="default"}){const{t:u}=Ba(),m=[];return t&&n&&m.push({icon:l.Edit,label:u("edit"),onClick:t,variant:"default"}),r&&m.push({icon:s?l.PowerOff:l.Power,label:u(s?"deactivate":"activate"),onClick:r,variant:"default"}),i.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),a&&o&&m.push({icon:l.Trash2,label:u("remove"),onClick:a,variant:"destructive"}),0===m.length?null:"dropdown"===c?e.jsxs(fs,{children:[e.jsx(gs,{asChild:!0,children:e.jsx(mt,{variant:"ghost",size:"compact"===d?"sm":"default",className:"compact"===d?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===d?14:16})})}),e.jsx(Ns,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((t,a)=>e.jsxs(Cs,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},a))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((t,a)=>e.jsxs(mt,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===d?"sm":"default",onClick:t.onClick,className:"compact"===d?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===d?14:16}),"compact"!==d&&e.jsx("span",{className:"ml-1",children:t.label})]},a))})}function If(e){const t=v.useNavigate();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)}}}const Lf=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Of=[{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"}],Df=[{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"}],Ff=()=>{const{locale:t,datetimeFormat:a,timezone:r,setLocale:s,setDatetimeFormat:n,setTimezone:o}=qn(),{t:i}=Ba();return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(l.Globe,{className:"h-4 w-4"}),i("language")]}),e.jsxs(qt,{value:t,onValueChange:s,children:[e.jsx(Gt,{children:e.jsx(Kt,{})}),e.jsx(Jt,{children:Lf.map(t=>e.jsxs(Zt,{value:t.value,children:[t.flag," ",t.label]},t.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(l.Clock,{className:"h-4 w-4"}),i("timezone")||"Fuso Horário"]}),e.jsxs(qt,{value:r,onValueChange:o,children:[e.jsx(Gt,{children:e.jsx(Kt,{})}),e.jsx(Jt,{children:Df.map(t=>e.jsx(Zt,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(l.Calendar,{className:"h-4 w-4"}),i("dateTimeFormat")||"Formato de Data/Hora"]}),e.jsxs(qt,{value:a,onValueChange:n,children:[e.jsx(Gt,{children:e.jsx(Kt,{})}),e.jsx(Jt,{children:Of.map(t=>e.jsx(Zt,{value:t.value,children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{children:t.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.description," • ",t.example]})]})},t.value))})]})]})]})},zf=t.memo(({variant:a="card",className:r="",selectedUnit:s,onUnitChange:n})=>{const{user:o,companies:i,alias:c,isAuthenticated:d,logout:u,switchUnit:m}=Qr(),[p,h]=t.useState(!1),f="true"===(void 0).VITE_SHOW_USER_PREFERENCES,g=i?.[0]||null,x=c?i?.find(e=>e.alias===c):g,v=i||[],b=s||x||g||g,y=t.useCallback(e=>{n?n(e):m(e)},[n,m]),w=t.useMemo(()=>{if(!v?.length)return[];const e=new Map;v.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===b?.alias),r=t.filter(e=>e.alias!==b?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...r]:r},[v,b?.alias]);if(!d||!o)return null;const j=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",b?.name||"N/A"]})]})]}),b&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:b.name})]})}),w.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",w.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[w.slice(0,3).map(t=>e.jsx(sa,{variant:t.alias===b?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>y(t),children:t.name},t.alias)),w.length>3&&e.jsxs(sa,{variant:"outline",className:"text-xs",children:["+",w.length-3]})]})]})]});return"dropdown"===a?e.jsxs(fs,{children:[e.jsx(gs,{asChild:!0,children:e.jsx(mt,{variant:"ghost",className:`h-auto p-2 ${r}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Ns,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(bs,{children:[e.jsxs(ws,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(js,{children:w.map(t=>e.jsxs(Cs,{onClick:()=>y(t),className:t.alias===b?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===b?.alias&&e.jsx(sa,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),f&&e.jsx(Ps,{}),f&&e.jsxs(Cs,{onClick:()=>h(!0),children:[e.jsx(l.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(Cs,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),f&&e.jsx(Ct,{open:p,onOpenChange:h,children:e.jsxs(_t,{children:[e.jsx(Tt,{children:e.jsx(It,{children:"Preferências de Internacionalização"})}),e.jsx(Ff,{})]})})]}):e.jsxs(xt,{className:r,children:[e.jsx(vt,{children:e.jsx(bt,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(wt,{className:"space-y-4",children:[e.jsx(j,{}),e.jsx(Nt,{}),f&&e.jsxs(mt,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(l.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(mt,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),f&&e.jsx(Ct,{open:p,onOpenChange:h,children:e.jsxs(_t,{children:[e.jsx(Tt,{children:e.jsx(It,{children:"Preferências de Internacionalização"})}),e.jsx(Ff,{})]})})]})]})}),$f=t.createContext({});function Uf({children:a,config:r}){const s=t.useMemo(()=>({navigation:r?.navigation,appName:r?.appName}),[r?.navigation,r?.appName]);return e.jsx($f.Provider,{value:s,children:a})}function Vf(){return t.useContext($f)}function Bf(){const e=v.useLocation(),{navigation:t}=Vf(),{t:a}=Ba();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 Wf(e,a){const[r,s]=t.useState(e),n=t.useRef(),o=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(o(),n.current=setTimeout(()=>{s(e)},a),o),[e,a,o]),[r,o]}const qf=t.memo(function({actions:a}){const r=v.useLocation(),s=Bf(),{navigation:n,appName:o}=Vf(),{metadata:i,headerActions:c}=An(),{t:d}=Ba(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:f,switchUnit:g}=Qr(),x=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,y]=v.useSearchParams(),[w,j]=t.useState(()=>b.get("search")||""),[N,C]=Wf(w,Sr.debounceDelay);t.useEffect(()=>{if(!p)return;const e=new URLSearchParams(b);N?(e.set("search",N),e.set("page","1")):e.delete("search"),y(e)},[N,y,p]);const k=n?.find(e=>e.path===r.pathname)||n?.find(e=>r.pathname.startsWith(e.path+"/")),S=i.title||s,E=i.subtitle||k?.complementaryText||d("item_details");return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:S}),e.jsx(sa,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:o||d("module")})]}),E&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:E})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(ht,{placeholder:d("search"),value:w,onChange:e=>(e=>{j(e)})(e.target.value),className:"w-full pl-10 pr-8"}),w&&e.jsx(mt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{C(),j("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),y(e)},title:d("clear_search"),children:e.jsx(l.X,{size:14})})]}),e.jsx(mt,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:d("refresh_data"),children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(c||a)&&e.jsx("div",{className:"flex items-center gap-2",children:c||a}),(void 0).VITE_WIKI_URL&&e.jsx(mt,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>lt((void 0).VITE_WIKI_URL,e),title:d("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(zf,{variant:"dropdown",selectedUnit:x,onUnitChange:g})})]})]})})}),Hf=({key:e,enabled:t,checkFn:a,staleTime:r=3e5,gcTime:s=6e5})=>x.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:r,gcTime:s,retry:0,refetchOnWindowFocus:!1}),Kf=(e={})=>{const{enabled:t=!0}=e,{alias:a}=Qr();return x.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=pr(),{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(!vr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!a})},Gf="forlogic-sidebar-pinned",Qf=()=>{try{const e=localStorage.getItem(Gf);return!!e&&JSON.parse(e)}catch{return!1}},Xf=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]},Jf=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,Yf={logo:`${Jf}/${_r.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Jf}/${_r.isQualiex?"small-forlogic.svg":"small.svg"}`},Zf=Yf.logo,eg=Yf.smallLogo;function tg({appName:t,isPinned:a,onPinToggle:r,open:s,dropdownOpen:n,onDropdownChange:o}){const{t:i}=Ba(),{data:c,isLoading:d,error:u}=Kf({enabled:n}),m=e=>{((e,t)=>{const a=e?.find(e=>e.url===t);a?.url&&window.open(a.url,"_blank")})(c,e)};return e.jsxs(nl,{className:"p-0 gap-0",children:[e.jsx("div",{className:"flex items-center justify-between h-[34px]",children:s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center pl-[12px]",children:e.jsx("img",{src:Yf.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e.jsx("button",{onClick:r,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(a?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e.jsx(l.PanelLeft,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:e.jsx("img",{src:Yf.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(fs,{onOpenChange:o,children:[e.jsx(gs,{asChild:!0,children:s?e.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:t})]}),e.jsx(l.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e.jsx(l.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),e.jsx(Ns,{className:s?"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50":"w-[58px] bg-popover rounded-lg shadow-lg border border-border p-2 z-50",align:s?"start":"center",children:d?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:i("loading")})]}):u?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:i("error")})]}):c&&0!==c.length?e.jsx("div",{className:"space-y-2",children:c.map((t,a)=>e.jsx("div",{onClick:()=>m(t.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${Xf(a)} transition-colors duration-200\n `,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-foreground text-sm",children:t.name}),t.url&&e.jsx(l.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},t.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:i("no_results")})})]})})]})}function ag({config:t,isCollapsed:a=!1,isDisabled:r=!1,className:s}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus}=t;if(!n||0===n.length)return null;const c=(t,r,s=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&r&&e.jsx("span",{className:"truncate",children:r}),!a&&s&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],o=t.icon||i,l=r||t.disabled,d=e.jsx(mt,{onClick:t.onClick,disabled:l,className:ct("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:c(e.jsx(o,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(ds,{children:[e.jsx(us,{asChild:!0,children:d}),e.jsx(ms,{side:"right",children:e.jsx("p",{children:t.label})})]}):d}const d=e.jsx(mt,{disabled:r,className:ct("w-full gap-2 justify-start",a&&"justify-center px-2",s),variant:"outline",size:"default",children:c(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(fs,{children:[e.jsx(gs,{asChild:!0,children:a?e.jsxs(ds,{children:[e.jsx(us,{asChild:!0,children:d}),e.jsx(ms,{side:"right",children:e.jsx("p",{children:o})})]}):d}),e.jsx(Ns,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Cs,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}function rg({direction:e="right",minWidth:a=224,maxWidth:r=384,defaultWidth:s=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,c]=t.useState(()=>{if("undefined"==typeof window)return s;const e=localStorage.getItem(n);return e?parseInt(e):s}),[d,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!d)return;const t=t=>{let s;s="left"===e?window.innerWidth-t.clientX:t.clientX,s=Math.max(a,Math.min(r,s)),c(s),o?.(s)},s=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s)}},[d,e,a,r,l,n,o]),t.useEffect(()=>{d?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[d,e]),{width:l,isDragging:d,dragRef:m,handleMouseDown:p}}const sg=t.createContext(void 0);function ng(){const e=t.useContext(sg);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function og({config:a,customContent:r,resizable:s=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=Ba(),{open:c,setOpen:d}=Yi(),u=v.useLocation(),{alias:m,user:p}=Qr(),{hasOpenModal:h}=ng(),[f,g]=t.useState(!1),[x,b]=t.useState(Qf),[y,w]=t.useState(!1),j=t.useRef(!1),N=s?rg({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:c}):null;t.useEffect(()=>{d(!!x||!(!y&&!f))},[x,y,f,d]);return e.jsxs(el,{collapsible:"icon",onMouseEnter:()=>{x||j.current||w(!0)},onMouseLeave:()=>{x||w(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:N&&c?{width:`${N.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(tg,{appName:a?.appName||i("module_title"),isPinned:x,onPinToggle:()=>{const e=!x;b(e),(e=>{try{localStorage.setItem(Gf,JSON.stringify(e))}catch{}})(e),e||(j.current=!0,w(!1),d(!1),setTimeout(()=>{j.current=!1},300))},open:c,dropdownOpen:f,onDropdownChange:g}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(cs,{children:e.jsx(ag,{config:a.moduleActions,isCollapsed:!c,isDisabled:h})})}),e.jsx(ll,{children:r||e.jsx(cl,{className:"p-0 mt-6",children:e.jsx(ml,{children:e.jsx(pl,{className:"space-y-2",children:e.jsx(cs,{children:a?.navigation?.map((t,a)=>{const r=({item:t,index:a})=>{const s=`${t.path}-${a}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:o}=Hf({key:s,enabled:Boolean(t.permissionCheck&&m&&p?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),c=t.permissionCheck&&!n;if(c&&"Admin"===t.label)return null;const d=o?l.Loader2:c?l.Lock:t.icon;c?i("restricted_access"):t.complementaryText;return t.children&&t.children.length>0?e.jsx(Kn,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(hl,{children:[e.jsx(Gn,{asChild:!0,children:e.jsx(gl,{size:"lg",className:"h-10",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(d,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e.jsx(Qn,{children:e.jsx(yl,{children:t.children.map((t,a)=>e.jsx(r,{item:t,index:a},t.path))})})]})},t.path):e.jsx(hl,{children:c||o?e.jsxs(ds,{children:[e.jsx(us,{asChild:!0,children:e.jsx(gl,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(d,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})}),e.jsx(ms,{children:e.jsx("p",{children:i(o?"checking_access":"restricted_access")})})]}):e.jsx(gl,{asChild:!0,isActive:(h=t.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(v.Link,{to:t.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(d,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})},t.path);var h};return e.jsx(r,{item:t,index:a},t.path)})})})})})}),s&&N&&c&&e.jsx("div",{ref:N.dragRef,onMouseDown:N.handleMouseDown,className:ct("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-['']",N.isDragging&&"bg-primary/40")})]})}const ig=t.memo(function({children:a,sidebar:r,sidebarConfig:s,showHeader:n=!0}){const o=t.useMemo(()=>r||e.jsx(og,{config:s}),[r,s]),i=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(Uf,{config:s,children:e.jsx(Tn,{children:e.jsx(Zi,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(qf,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:a})]})]})})})})}),lg={"pt-BR":Go,"en-US":Lo,"es-ES":Vo},cg=(e,t="pt-BR")=>{if(!e)return"";const a=o.parseISO(e);if(!o.isValid(a))return"Invalid date";const r=lg[t]||Go;return o.format(a,"PP",{locale:r})};class dg{static async sendEmail(e){const t=pr(),{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 ug=dg;function mg({open:a,onOpenChange:r,placeId:s,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:c,currentMemberIds:d=[]}){const{t:u}=Ba(),[m,p]=t.useState([]),[h,f]=t.useState(!1),[g,x]=t.useState(""),{data:v=[],isLoading:b}=on({enabled:a}),y=t.useMemo(()=>{let e=[...v];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",r=t.userName?.toLowerCase()||"";return a.localeCompare(r)}),g){const t=g.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[v,g]),w=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=1===m.length,N=m.length>0;return e.jsx(Ct,{open:a,onOpenChange:r,children:e.jsxs(_t,{className:"max-w-2xl",children:[e.jsx(Tt,{children:e.jsxs(It,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ht,{placeholder:u("search_placeholder"),value:g,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(tn,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(ba,{className:"h-16 w-full"},a))}):0===y.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:y.map(t=>{const a=t.userId===c,r=d.includes(t.userId||""),s=m.includes(t.userId||"");return e.jsxs("div",{className:ct("flex items-center gap-3 p-3 rounded-lg border transition-colors",s&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e.jsx(ta,{checked:s,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:t.userName}),a&&e.jsx(l.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||r)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})}),e.jsxs(Mt,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&e.jsxs("span",{children:[m.length," selecionado(s)"]})}),j&&o&&e.jsxs(mt,{onClick:async()=>{if(o&&1===m.length){f(!0);try{await o(m[0],s),p([])}finally{f(!1)}}},disabled:h,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),N&&i&&e.jsxs(mt,{onClick:async()=>{if(i&&0!==m.length){f(!0);try{await i(m,s),p([])}finally{f(!1)}}},disabled:h,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function pg({place:a,level:r=0,manageAccessConfig:s}){const[n,o]=t.useState(!1),[i,c]=t.useState(!1),d=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Kn,{open:n,onOpenChange:o,children:[e.jsxs("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?e.jsxs(Gn,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:ct("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(sa,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),s&&e.jsx(Mf,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),d&&e.jsx(Qn,{children:a.subPlaces.map(t=>e.jsx(pg,{place:t,level:r+1,manageAccessConfig:s},t.id))})]}),0===r&&e.jsx(Nt,{}),s&&e.jsx(mg,{open:i,onOpenChange:c,placeId:a.id,placeName:a.name,onMakeManager:s.onMakeManager,onMakeMembers:s.onMakeMembers,currentManagerId:s.getCurrentManagerId?.(a.id),currentMemberIds:s.getCurrentMemberIds?.(a.id)})]})}var hg=Object.defineProperty,fg=(e,t,a)=>((e,t,a)=>t in e?hg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const gg=new class{constructor(){fg(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const r=yr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const s=rr.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 o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.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 yr.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 or.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return or.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function xg(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 vg(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function bg(){const{alias:e,isAuthenticated:t}=Qr(),a=rr.getAccessToken(),{data:r=[]}=on({enabled:!0});return x.useQuery({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=pr(),{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 o={};r.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=s.map(e=>({...e,name:o[e.id_user]?.name||"[Não encontrado]",email:o[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=o[e];i.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})}),xg(i)},enabled:!!a&&!!e&&t&&r.length>0})}function yg(){const e="common",{alias:t}=Qr(),a=x.useQueryClient(),r=pr();return x.useMutation({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 kg(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]}),i.toast.success("Líder virtual promovido com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao criar líder")}})}function wg(){const e="common",{alias:t}=Qr(),a=x.useQueryClient(),r=pr();return x.useMutation({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 c of a.users){if(a.id_leader&&c.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await kg(r,t,e,c.id_user,a.id_leader)}const o=a.users.map(e=>({alias:t,id_user:e.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await r.schema(e).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{i.toast.error(e.message||"Erro ao adicionar liderados")}})}function jg(){const e="common",{alias:t}=Qr(),a=x.useQueryClient(),r=pr();return x.useMutation({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 kg(r,t,e,s.id_user,a.id_leader,a.id);const{data:n,error:o}=await r.schema(e).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",t).select().single();if(o)throw o;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success("Líder atualizado com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao atualizar líder")}})}function Ng(){const{alias:e}=Qr(),t=x.useQueryClient(),a=pr();return x.useMutation({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]}),i.toast.success("Líder removido com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao remover líder")}})}function Cg(){const e="common",{alias:t}=Qr(),a=x.useQueryClient(),r=pr();return x.useMutation({mutationFn:async({leaderUserId:a,selectedUsers:s})=>{if(!t)throw new Error("Unidade não selecionada");const n=s.map(e=>e.id_user),o=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:i,error:l},{data:c,error:d}]=o;if(l)throw l;if(d)throw d;const u=i||[],m=c||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),g=new Set(m.map(e=>e.id_user)),x=s.filter(e=>!g.has(e.id_user));for(const y of f)await kg(r,t,e,y.id_user,a,y.id);for(const y of x){if(y.id_user===a)throw new Error("Usuário não pode ser seu próprio líder");await kg(r,t,e,y.id_user,a)}const v=[];if(h.length){const a=h.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(x.length){const s=x.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 b=(await Promise.all(v)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:h.length,updated:f.length,created:x.length}},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{i.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function kg(e,t,a,r,s,n){const{data:o,error:i}=await e.schema(a).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,c=new Set;let d=s;for(;d;){if(c.has(d))throw new Error("Esta associação criaria um ciclo na hierarquia");if(d===r)throw new Error("Esta associação criaria um ciclo na hierarquia");c.add(d);const e=l.find(e=>e.id_user===d);d=e?.id_leader||null}}function Sg({leader:t,expandedIds:a,onToggleExpand:r,onEdit:s}){const n=a.has(t.id),o=t.children.length>0,i=32*t.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[o?e.jsx("button",{onClick:()=>r(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{s(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),o&&n&&t.children.map(t=>e.jsx(Sg,{leader:t,expandedIds:a,onToggleExpand:r,onEdit:s},t.id))]})}var Eg=function(e,t){for(var a={};e.length;){var r=e[0],s=r.code,n=r.message,o=r.path.join(".");if(!a[o])if("unionErrors"in r){var i=r.unionErrors[0].errors[0];a[o]={message:i.message,type:i.code}}else a[o]={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[o].types,c=l&&l[r.code];a[o]=m.appendErrors(o,t,a,s,c?[].concat(c,r.message):r.message)}e.shift()}return a},Pg=function(e,t,a){return void 0===a&&(a={}),function(r,s,n){try{return Promise.resolve(function(s,o){try{var i=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](r,t)).then(function(e){return n.shouldUseNativeValidation&&H.validateFieldsNatively({},n),{errors:{},values:a.raw?r:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:H.toNestErrors(Eg(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Rg=q.z.object({id_leader:q.z.string().nullable(),id_users:q.z.array(q.z.string()).min(1,"Selecione pelo menos um liderado")}),_g=q.z.object({id_leader:q.z.string().nullable(),id_users:q.z.array(q.z.string())});function Tg({value:a,onChange:r,excludeUserIds:s=[],error:n}){const{data:o=[],isLoading:i}=on(),[c,d]=t.useState(""),u=t.useRef(null),m=t.useRef(0),{t:p}=Ba(),h=o.filter(e=>!s.includes(e.userId||"")).filter(e=>{const t=c.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||"",o=t.userName||t.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ht,{placeholder:p("search_user"),value:c,onChange:e=>d(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ta,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?r(a.filter(t=>t!==e)):r([...a,e]));var e}}),e.jsx(gt,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:a.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Ag({leader:a,prefilledLeaderId:r,onSuccess:s}){const{t:n}=Ba(),{alias:o}=Qr(),i=!!a,c=a?.id.startsWith("virtual-"),d=wg(),u=yg(),p=jg(),h=Cg(),f=Ng(),{data:g=[]}=bg(),{data:x=[]}=on(),[v,b]=t.useState(""),y=vg(g).map(e=>e.id_user),w=i?vg(g).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],j=m.useForm({resolver:Pg(i?_g:Rg),defaultValues:{id_leader:r||(i?a?.id_leader:null)||null,id_users:i?w:[]}});t.useEffect(()=>{if(a){const e=vg(g).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);j.reset({id_leader:a.id_leader||null,id_users:e})}else r?j.reset({id_leader:r,id_users:[]}):j.reset({id_leader:null,id_users:[]})},[o,a?.id,a?.id_user,a?.id_leader,r,g]);const N=d.isPending||u.isPending||p.isPending||h.isPending||f.isPending,C=j.watch("id_leader"),k=j.watch("id_users"),S=i?[a.id_user,...y.filter(e=>e!==a.id_user&&!k.includes(e)&&!w.includes(e))]:[C,...y.filter(e=>!k.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:j.handleSubmit(async e=>{try{if(i)if(c){await u.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await p.mutateAsync({id:a.id,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await d.mutateAsync({id_leader:e.id_leader,users:t})}s?.()}catch(t){}}),className:"space-y-4",children:[i&&e.jsxs("div",{children:[e.jsx(gt,{children:n("leader")}),e.jsx(ht,{value:x.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(gt,{children:n("superior")}),e.jsxs(qt,{value:C||"none",onValueChange:e=>j.setValue("id_leader","none"===e?null:e),children:[e.jsx(Gt,{children:e.jsx(Kt,{placeholder:n("select_placeholder")})}),e.jsxs(Jt,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(ht,{placeholder:n("superior_search"),value:v,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(tn,{className:"h-[200px]",children:[e.jsx(Zt,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const t=i?e.userId!==a.id_user:!k.includes(e.userId),r=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return t&&r}).sort((e,t)=>{const a=e.userName||e.userEmail||"",r=t.userName||t.userEmail||"";return a.localeCompare(r)}).map(t=>e.jsx(Zt,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${o}`),j.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:j.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(gt,{children:[n("subordinates")," *"]}),e.jsx(Tg,{value:k,onChange:e=>j.setValue("id_users",e),excludeUserIds:S,error:j.formState.errors.id_users?.message},`users-multiselect-${o}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(mt,{type:"submit",disabled:N||!i&&0===k.length,children:N&&!f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n(i?"updating":"saving")]}):i?k.length>0?n("update_success",{count:k.length}):n("update"):n("create_success",{count:k.length})}),i&&!C&&0===k.length&&e.jsx(mt,{type:"button",variant:"destructive",disabled:N,onClick:async()=>{if(a&&window.confirm(n("remove_confirm")))try{await f.mutateAsync(a.id),s?.()}catch(e){}},className:"ml-auto",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n("removing")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),n("remove")]})})]})]})}function Mg({open:t,onOpenChange:a,leader:r,prefilledLeaderId:s,title:n}){return e.jsx(Ct,{open:t,onOpenChange:a,children:e.jsxs(_t,{className:"sm:max-w-[500px]",children:[e.jsx(Tt,{children:e.jsx(It,{children:n})}),e.jsx(Ag,{leader:r,prefilledLeaderId:s,onSuccess:()=>a(!1)})]})})}const Ig="leadership-expanded-nodes",Lg=(e,t)=>{try{localStorage.setItem(`${Ig}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function Og(e){const[a,r]=t.useState(!1),[s,n]=t.useState(0),{t:o}=Ba(),{uploadFunction:l,deleteFunction:c,defaultOptions:d,onSuccess:u,onError:m}=e||{};return{upload:async(e,t)=>{if(!l){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}r(!0),n(0);try{const a={...d,...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 l(e,a);return n(100),i.toast.success("Sucesso",{description:o("file_upload_success")}),u?.(r),r}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),m?.(e),e}finally{r(!1)}},deleteMedia:async(e,t)=>{if(!c){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await c(e,t),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a,progress:s}}function Dg(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 Fg(e,t){const a=Dg(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function zg(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function $g(e,t){const a=zg(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function Ug(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function Vg(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Bg(e,t){return e/t}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),exports.AUTH_CONFIG=Cr,exports.Accordion=Zn,exports.AccordionContent=ao,exports.AccordionItem=eo,exports.AccordionTrigger=to,exports.ActionButton=pt,exports.ActionMenu=Mf,exports.ActionMenuItems=qs,exports.Alert=En,exports.AlertDescription=Rn,exports.AlertDialog=ro,exports.AlertDialogAction=po,exports.AlertDialogCancel=ho,exports.AlertDialogContent=io,exports.AlertDialogDescription=mo,exports.AlertDialogFooter=co,exports.AlertDialogHeader=lo,exports.AlertDialogOverlay=oo,exports.AlertDialogPortal=no,exports.AlertDialogTitle=uo,exports.AlertDialogTrigger=so,exports.AlertTitle=Pn,exports.AppHeader=qf,exports.AppLayout=ig,exports.AppSidebar=og,exports.AuthErrorInterceptor=vr,exports.AuthProvider=Gr,exports.AuthService=Hr,exports.Avatar=fo,exports.AvatarFallback=xo,exports.AvatarImage=go,exports.Badge=sa,exports.BaseForm=cn,exports.Blockquote=Ei,exports.Breadcrumb=vo,exports.BreadcrumbEllipsis=Co,exports.BreadcrumbItem=yo,exports.BreadcrumbLink=wo,exports.BreadcrumbList=bo,exports.BreadcrumbPage=jo,exports.BreadcrumbSeparator=No,exports.BulkActionBar=mn,exports.Button=mt,exports.ButtonGroup=So,exports.CRUD_CONFIG=kr,exports.Calendar=Qo,exports.CallbackPage=()=>{const{processCallback:a}=Qr(),[r,s]=t.useState(null),[n,o]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else s("Falha na autenticação. Tente novamente.")}catch(Wg){s(Wg?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a]);const i=async()=>{o(!0),s(null);try{await a()||s("Falha na autenticação. Tente novamente.")}catch(Wg){s(Wg?.message||"Erro ao tentar novamente.")}finally{o(!1)}},c=()=>{window.location.href="/"};return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsxs(bt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(wt,{className:"space-y-4",children:[e.jsx(En,{variant:"destructive",children:e.jsx(Rn,{children:r})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(mt,{onClick:i,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(oa,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(mt,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsx(bt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(wt,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(oa,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=xt,exports.CardContent=wt,exports.CardDescription=yt,exports.CardFooter=jt,exports.CardHeader=vt,exports.CardSkeleton=os,exports.CardTitle=bt,exports.Cards=function({data:t,renderCard:a,isLoading:r=!1,emptyMessage:s="Nenhum item encontrado",columns:n,gap:o="md",className:i}){return r?e.jsx(ci,{cols:n?String(n):"auto-fit",gap:o,className:i,children:[...Array(6)].map((t,a)=>e.jsx(ba,{className:"h-48 w-full"},a))}):0===t.length?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:s})})}):e.jsx(ci,{cols:n?String(n):"auto-fit",gap:o,className:i,children:t.map(a)})},exports.ChartContainer=Cf,exports.ChartLegend=Pf,exports.ChartLegendContent=Rf,exports.ChartStyle=kf,exports.ChartTooltip=Sf,exports.ChartTooltipContent=Ef,exports.Checkbox=ta,exports.Collapsible=Kn,exports.CollapsibleContent=Qn,exports.CollapsibleTrigger=Gn,exports.ColorPicker=en,exports.Combobox=Ka,exports.Command=ua,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(ua,{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})}),exports.CommandEmpty=ha,exports.CommandGroup=fa,exports.CommandInput=ma,exports.CommandItem=xa,exports.CommandList=pa,exports.CommandSeparator=ga,exports.CommandShortcut=va,exports.ContextMenu=_s,exports.ContextMenuCheckboxItem=$s,exports.ContextMenuContent=Fs,exports.ContextMenuGroup=As,exports.ContextMenuItem=zs,exports.ContextMenuLabel=Vs,exports.ContextMenuPortal=Ms,exports.ContextMenuRadioGroup=Ls,exports.ContextMenuRadioItem=Us,exports.ContextMenuSeparator=Bs,exports.ContextMenuShortcut=Ws,exports.ContextMenuSub=Is,exports.ContextMenuSubContent=Ds,exports.ContextMenuSubTrigger=Os,exports.ContextMenuTrigger=Ts,exports.CoreProviders=function({children:t,queryClient:a}){const r=a??new x.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Yn,{children:e.jsx(Wa,{i18n:it,children:e.jsx(x.QueryClientProvider,{client:r,children:e.jsx(Gr,{children:e.jsx(Wn,{children:e.jsx(Hn,{children:t})})})})})})},exports.CrudCards=function({manager:t,config:a,onEdit:r,onDelete:s}){const{t:n}=Ba();return t.isLoading?e.jsx(ci,{children:Array.from({length:3}).map((t,a)=>e.jsxs(xt,{children:[e.jsxs(vt,{children:[e.jsx(ba,{className:"h-4 w-3/4"}),e.jsx(ba,{className:"h-3 w-1/2"})]}),e.jsx(wt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ba,{className:"h-3 w-full"}),e.jsx(ba,{className:"h-3 w-2/3"})]})})]},a))}):e.jsx(Xo.Root,{children:t.entities.map(t=>e.jsxs(Xo.Item,{onClick:()=>r(t),children:[e.jsx(vt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(bt,{className:"text-base leading-6 truncate",children:t.title||t.name||n("no_title")}),e.jsx(yt,{className:"text-sm",children:o.format(new Date(t.created_at),"dd/MM/yyyy HH:mm",{locale:Go})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[t.link&&e.jsx(mt,{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),i.toast.info(n("link_copied")))}catch(t){window.location.href=e}})(t.link)},title:n("open_external_link"),children:e.jsx(l.ExternalLink,{className:"h-4 w-4"})}),e.jsx("div",{onClick:e=>e.stopPropagation(),children:e.jsx(Hs,{onEdit:()=>r(t),onDelete:s?()=>s(t):void 0,canDelete:!!s})})]})]})}),e.jsx(wt,{className:"pt-0",children:e.jsx("div",{className:"space-y-2",children:a.cardFields?.map(a=>{const r=t[a.key];return r?e.jsx(Xo.Field,{label:a.label,value:a.render?a.render(r,t):String(r)},String(a.key)):null})})})]},t.id))})},exports.CrudPageInternal=vn,exports.CrudPagination=un,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:r=[],onClearFilters:s,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=Ba(),c=t||r.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ht,{type:"text",placeholder:i("search"),value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),r.map((t,a)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:t},a)),n&&c&&s&&e.jsxs(mt,{variant:"ghost",size:"sm",onClick:s,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),i("clear_filters")]})]})},exports.CrudPrimitivePagination=dn,exports.CrudPrimitiveTable=function({data:a,columns:r,sortField:s,sortDirection:n,onSort:o,onRowClick:i,renderActions:c,isLoading:d=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:g,isAllSelected:x=!1,enableColumnResize:v=!1,enableRowResize:b=!1,onColumnResize:y,onRowResize:w,storageKey:j}){const{columnWidths:N,isDragging:C,activeColumn:k,handleMouseDown:S}=Gs({columns:r.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:j?`${j}-columns`:void 0,onResize:y,enabled:v}),{isDragging:E,activeRow:P,handleMouseDown:R,getRowHeight:_}=Qs({rowIds:a.map(e=>e.id),storageKey:j?`${j}-rows`:void 0,onResize:w,enabled:b}),T=t.useMemo(()=>{if(v)return r.map(e=>`${N[String(e.key)]??e.width??e.minWidth??150}px`);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,v,N]);if(d)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(ba,{className:"h-12 w-full"},a))})});if(0===a.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const A=C||E;return e.jsx("div",{className:"flex-1 overflow-auto "+(A?"select-none":""),children:e.jsxs(Jr,{className:m,children:[e.jsx(Yr,{className:"sticky top-0 bg-background z-10",children:e.jsxs(ts,{children:[p&&e.jsx(as,{className:"w-[40px]",children:e.jsx(ta,{checked:x,onCheckedChange:g,"aria-label":"Selecionar todos"})}),r.map((t,a)=>{const r=v&&!1!==t.resizable,i=k===String(t.key);return e.jsxs(as,{className:`${t.className||""} relative`,style:{width:T[a]},children:[t.sortable&&o?e.jsxs("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(c=String(t.key),s!==c?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),r&&e.jsx(hs,{direction:"horizontal",onMouseDown:e=>S(String(t.key),e),isDragging:i})]},String(t.key));var c}),c&&e.jsx(as,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Zr,{children:a.map(t=>{const a=b?_(t.id):void 0,s=P===t.id;return e.jsxs(ts,{onClick:()=>i?.(t),className:(i?"cursor-pointer":"")+" relative",style:a?{height:`${a}px`}:void 0,children:[p&&e.jsx(rs,{children:e.jsx(ta,{checked:h.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${t.id}`})}),r.map(a=>e.jsx(rs,{className:a.className,children:e.jsx(ps,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),c&&e.jsx(rs,{className:"text-right",onClick:e=>e.stopPropagation(),children:c(t)}),b&&e.jsx(hs,{direction:"vertical",onMouseDown:e=>R(t.id,e),isDragging:s})]},t.id)})})]})})},exports.CrudTable=Js,exports.DataList=Xo,exports.DatePicker=function({date:t,onDateChange:a,placeholder:r="Pick a date",disabled:s=!1,className:n,disabledDates:i}){return e.jsxs(la,{children:[e.jsx(ca,{asChild:!0,children:e.jsxs(mt,{variant:"outline",disabled:s,className:ct("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),t?o.format(t,"PPP"):e.jsx("span",{children:r})]})}),e.jsx(da,{className:"w-auto p-0",align:"start",children:e.jsx(Qo,{mode:"single",selected:t,onSelect:a,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=Ct,exports.DialogBody=At,exports.DialogClose=Et,exports.DialogContent=_t,exports.DialogDescription=Lt,exports.DialogFooter=Mt,exports.DialogHeader=Tt,exports.DialogOverlay=Pt,exports.DialogPortal=St,exports.DialogTitle=It,exports.DialogTrigger=kt,exports.Drawer=Jo,exports.DrawerClose=ei,exports.DrawerContent=ai,exports.DrawerDescription=oi,exports.DrawerFooter=si,exports.DrawerHeader=ri,exports.DrawerOverlay=ti,exports.DrawerPortal=Zo,exports.DrawerTitle=ni,exports.DrawerTrigger=Yo,exports.DropdownMenu=fs,exports.DropdownMenuCheckboxItem=ks,exports.DropdownMenuContent=Ns,exports.DropdownMenuGroup=xs,exports.DropdownMenuItem=Cs,exports.DropdownMenuLabel=Es,exports.DropdownMenuPortal=vs,exports.DropdownMenuRadioGroup=ys,exports.DropdownMenuRadioItem=Ss,exports.DropdownMenuSeparator=Ps,exports.DropdownMenuShortcut=Rs,exports.DropdownMenuSub=bs,exports.DropdownMenuSubContent=js,exports.DropdownMenuSubTrigger=ws,exports.DropdownMenuTrigger=gs,exports.EmailService=dg,exports.EmptyState=ls,exports.EntitySelect=Ka,exports.ErrorBoundary=Yn,exports.FilterBar=xn,exports.Form=Ot,exports.FormControl=Vt,exports.FormDescription=Bt,exports.FormField=({...t})=>e.jsx(Dt.Provider,{value:{name:t.name},children:e.jsx(m.Controller,{...t})}),exports.FormItem=$t,exports.FormLabel=Ut,exports.FormMessage=Wt,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(ba,{className:"h-4 w-24"}),e.jsx(ba,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(ba,{className:"h-10 w-20"}),e.jsx(ba,{className:"h-10 w-20"})]})]})},exports.Grid=ci,exports.H1=xi,exports.H2=vi,exports.H3=bi,exports.H4=yi,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(ba,{className:"h-8 w-8 rounded-full"}),e.jsx(ba,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ba,{className:"h-8 w-8"}),e.jsx(ba,{className:"h-8 w-24"})]})]})},exports.I18nextProvider=Wa,exports.IconPicker=sn,exports.ImageEditor=function({value:a,onChange:r,onSubmit:s,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const{t:u}=Ba(),[m,p]=t.useState(a||{alignment:"center",allowDownload:!1}),h=t.useRef(null),{upload:f,uploading:g}=Og({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,t)=>{const a={...m,[e]:t};p(a),r(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ht,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(a),r(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(mt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),m.imageFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:m.imageFile,size:Math.round((m.imageSize||0)/1024)})})]}),m.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{htmlFor:"caption",children:u("caption")}),e.jsx(aa,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{htmlFor:"alt",children:u("alt")}),e.jsx(ht,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("alignment")}),e.jsxs(qt,{value:m.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(Gt,{children:e.jsx(Kt,{})}),e.jsxs(Jt,{children:[e.jsx(Zt,{value:"left",children:u("left")}),e.jsx(Zt,{value:"center",children:u("center")}),e.jsx(Zt,{value:"right",children:u("right")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{htmlFor:"width",children:u("width")}),e.jsx(ht,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{htmlFor:"height",children:u("height")}),e.jsx(ht,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:m.allowDownload||!1,onChange:e=>x("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(gt,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(mt,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(mt,{onClick:()=>{m.imageUrl?s(m):i.toast.error(u("error"),{description:u("error_no_image")})},disabled:!m.imageUrl,children:u("save")})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:r}){if(!t.imageUrl)return null;const s={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${s} my-4 ${a}`,style:r,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Si,exports.Input=ht,exports.InputGroup=di,exports.InputGroupAddon=mi,exports.InputGroupButton=hi,exports.InputGroupInput=fi,exports.InputGroupTextarea=gi,exports.LOGO_CONFIG=_r,exports.Label=gt,exports.Large=Ni,exports.Lead=ji,exports.LeaderRow=Sg,exports.LeadershipDialog=Mg,exports.LeadershipForm=Ag,exports.LeadershipPage=function(){const{alias:a}=Qr(),{t:r}=Ba(),{data:s,isLoading:n,error:o,refetch:i}=bg(),{data:c=[]}=on({enabled:!0}),[d,u]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Ig}-${e}`);if(t)return new Set(JSON.parse(t))}catch(o){}return new Set})(a):new Set),[m,p]=t.useState(!1),[h,f]=t.useState(),[g,x]=t.useState(null),v=c.filter(e=>e.userName&&"Nome não disponível"!==e.userName),b=new Set(v.map(e=>e.userId)),y=v.length-(s?vg(s).filter(e=>b.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);t.useEffect(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${Ig}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);u(t),Lg(a,t)}}},[s,a]);const w=e=>{u(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),a&&Lg(a,r),r})},j=e=>{f(e),x(null),p(!0)};return n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:r("loading")})]})}):o?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(mt,{onClick:()=>i(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(mt,{size:"sm",onClick:()=>{f(void 0),x(null),p(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=vg(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);u(t),a&&Lg(a,t)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),a&&Lg(a,e)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[y," usuário",1!==y?"s":""," não associado",1!==y?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(tn,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsx(Sg,{leader:t,expandedIds:d,onToggleExpand:w,onEdit:j},t.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(Mg,{open:m,onOpenChange:()=>{p(!1),f(void 0),x(null)},leader:h,prefilledLeaderId:g,title:h?r("edit")+" "+r("name"):g?r("add")+" Liderado":r("add")+" Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=Pi,exports.LoadingState=function({isLoading:t,children:a,className:r,type:s="spinner",size:n="md"}){return t?"overlay"===s?e.jsxs("div",{className:ct("relative",r),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(oa,{size:n})})]}):"skeleton"===s?e.jsx("div",{className:ct("animate-pulse",r),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:ct("flex items-center justify-center py-8",r),children:e.jsx(oa,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Wn,exports.LocaleSelector=Ff,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsx(bt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(wt,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(mt,{onClick:async()=>{Er()?await Hr.loginDev():Hr.loginProd()},className:"w-full",size:"lg",children:Er()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Tr,exports.ManageAccessModal=mg,exports.Menubar=df,exports.MenubarCheckboxItem=gf,exports.MenubarContent=hf,exports.MenubarGroup=nf,exports.MenubarItem=ff,exports.MenubarLabel=vf,exports.MenubarMenu=sf,exports.MenubarPortal=of,exports.MenubarRadioGroup=cf,exports.MenubarRadioItem=xf,exports.MenubarSeparator=bf,exports.MenubarShortcut=yf,exports.MenubarSub=lf,exports.MenubarSubContent=pf,exports.MenubarSubTrigger=mf,exports.MenubarTrigger=uf,exports.ModalStateProvider=function({children:a}){const[r,s]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{s(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{s(t=>{const a=new Set(t);return a.delete(e),a})},[]),c=t.useCallback(e=>{o(e)},[]),d=t.useMemo(()=>r.size>0||n,[r,n]),u=t.useMemo(()=>({openModals:r,hasOpenModal:d,registerModal:i,unregisterModal:l,setHasOpenModal:c}),[r,d,i,l,c]);return e.jsx(sg.Provider,{value:u,children:a})},exports.MultiSelect=Ka,exports.Muted=ki,exports.NavigationProvider=Uf,exports.P=wi,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:r}){const s=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(vo,{className:r,children:e.jsx(bo,{children:s.map((t,a)=>{const r=0===a,s=n&&1===a;return e.jsxs(yo,{children:[!r&&e.jsx(No,{}),s&&e.jsxs(e.Fragment,{children:[e.jsx(Co,{}),e.jsx(No,{})]}),t.isCurrentPage?e.jsx(jo,{children:t.label}):e.jsx(wo,{href:t.href,children:t.label})]},t.label)})})})},exports.PageMetadataProvider=Tn,exports.Pagination=Ri,exports.PaginationContent=_i,exports.PaginationEllipsis=Li,exports.PaginationItem=Ti,exports.PaginationLink=Ai,exports.PaginationNext=Ii,exports.PaginationPrevious=Mi,exports.PlaceCard=pg,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:r}){const{t:s}=Ba();return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("loading_data")})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(pg,{place:t,manageAccessConfig:r},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(l.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=la,exports.PopoverContent=da,exports.PopoverTrigger=ca,exports.Progress=wn,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:r,isLoading:s}=Qr();if(t.useEffect(()=>{if(!r)return;const e=()=>{rr.areAllTokensValid()||Hr.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[r]),t.useEffect(()=>{if(s)return;if(r)return;if(rr.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 n=Er();(async()=>{n?await Hr.loginDev():Hr.loginProd()})()},[r,s]),s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsx(bt,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(wt,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!r){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsx(bt,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(wt,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(xt,{className:"w-full max-w-md",children:[e.jsx(vt,{className:"text-center",children:e.jsx(bt,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(wt,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:Er()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=Pr,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=Dr,exports.QualiexErrorInterceptor=yr,exports.QualiexUserField=ln,exports.RadioGroup=Oi,exports.RadioGroupItem=Di,exports.RichTextEditor=({value:a,onChange:r,disabled:s,placeholder:n="Escreva o conteúdo aqui...",minHeight:o="300px",showModeToggle:i=!0,showVariableHint:c=!0,className:d})=>{const[u,m]=t.useState("visual"),p=F.useEditor({extensions:[z.configure({heading:{levels:[1,2,3]}}),$,U.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),V.TextStyle,B.Color,W.configure({multicolor:!0})],content:a||"",editable:!s,onUpdate:({editor:e})=>{r(e.getHTML())}});G.useEffect(()=>{p&&a!==p.getHTML()&&p.commands.setContent(a||"")},[a,p]);const h=t.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?p.chain().focus().extendMarkRange("link").setLink({href:t}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:ct("space-y-2",d),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(mt,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:s,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(mt,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:s,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(mt,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:s,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(Tf,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:s,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:s,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:s,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(Af,{}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:s,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:s,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:s,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:s,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Af,{}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:s,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:s,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Af,{}),e.jsx(Tf,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:s,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:h,isActive:p.isActive("link"),disabled:s,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(Af,{}),e.jsx(Tf,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:s,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Af,{}),e.jsx(Tf,{onClick:()=>p.chain().focus().undo().run(),disabled:s||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(Tf,{onClick:()=>p.chain().focus().redo().run(),disabled:s||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx(F.EditorContent,{editor:p,className:ct("prose prose-sm max-w-none p-4 focus:outline-none","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:o}})]}),"code"===u&&e.jsx("textarea",{value:a||"",onChange:e=>r(e.target.value),disabled:s,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Sr,exports.ScrollArea=tn,exports.ScrollBar=an,exports.Select=qt,exports.SelectContent=Jt,exports.SelectGroup=Ht,exports.SelectItem=Zt,exports.SelectLabel=Yt,exports.SelectScrollDownButton=Xt,exports.SelectScrollUpButton=Qt,exports.SelectSearch=Ka,exports.SelectSeparator=ea,exports.SelectTrigger=Gt,exports.SelectValue=Kt,exports.Separator=Nt,exports.Sheet=Fi,exports.SheetBody=Hi,exports.SheetClose=$i,exports.SheetContent=Wi,exports.SheetDescription=Qi,exports.SheetFooter=Ki,exports.SheetHeader=qi,exports.SheetOverlay=Vi,exports.SheetPortal=Ui,exports.SheetTitle=Gi,exports.SheetTrigger=zi,exports.Sidebar=el,exports.SidebarActionTrigger=ag,exports.SidebarContent=ll,exports.SidebarFooter=ol,exports.SidebarGroup=cl,exports.SidebarGroupAction=ul,exports.SidebarGroupContent=ml,exports.SidebarGroupLabel=dl,exports.SidebarHeader=tg,exports.SidebarInput=sl,exports.SidebarInset=rl,exports.SidebarMenu=pl,exports.SidebarMenuAction=xl,exports.SidebarMenuBadge=vl,exports.SidebarMenuButton=gl,exports.SidebarMenuItem=hl,exports.SidebarMenuSkeleton=bl,exports.SidebarMenuSub=yl,exports.SidebarMenuSubButton=jl,exports.SidebarMenuSubItem=wl,exports.SidebarProvider=Zi,exports.SidebarRail=al,exports.SidebarSeparator=il,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(ba,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(ba,{className:"h-4 w-4"}),e.jsx(ba,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=tl,exports.Skeleton=ba,exports.Slider=Nl,exports.Small=Ci,exports.SonnerToaster=ia,exports.Spinner=oa,exports.SplitButton=function({label:t,onClick:a,icon:r,actions:s=[],variant:n="default",size:o="default",disabled:i=!1,loading:c=!1,menuAlign:d="end",className:u}){const m=i||c;return s.length>0?e.jsxs("div",{className:ct("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(mt,{variant:n,size:o,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[c?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?e.jsx(r,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(fs,{children:[e.jsx(gs,{asChild:!0,children:e.jsx(mt,{variant:n,size:o,disabled:m,className:ct("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Ns,{align:d,className:"min-w-[160px]",children:s.map(t=>{const a=t.icon;return e.jsxs(Cs,{onClick:t.onClick,disabled:t.disabled,className:ct("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]}):e.jsxs(mt,{variant:n,size:o,disabled:m,onClick:a,className:u,children:[c?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):r?e.jsx(r,{className:"mr-2 h-4 w-4"}):null,t]})},exports.Stack=gn,exports.Switch=nn,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:ct("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:r,className:s}){return e.jsxs("div",{className:ct("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:r})]}),e.jsx(Nt,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:ct("flex flex-col h-full",a),children:e.jsx(tn,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=Jr,exports.TableBody=Zr,exports.TableCaption=ss,exports.TableCell=rs,exports.TableFooter=es,exports.TableHead=as,exports.TableHeader=Yr,exports.TableResizeHandle=hs,exports.TableRow=ts,exports.TableRowActions=Hs,exports.TableSkeleton=ns,exports.Tabs=Cl,exports.TabsContent=El,exports.TabsList=kl,exports.TabsTrigger=Sl,exports.Textarea=aa,exports.Toaster=ia,exports.Toggle=Rl,exports.ToggleGroup=Tl,exports.ToggleGroupItem=Al,exports.TokenManager=rr,exports.TokenService=Qa,exports.Tooltip=ds,exports.TooltipContent=ms,exports.TooltipProvider=cs,exports.TooltipTrigger=us,exports.TranslationLoader=Hn,exports.TruncatedCell=ps,exports.VideoEditor=function({value:a,onChange:r,onSubmit:s,onCancel:n,uploadFunction:o,deleteFunction:c,uploadOptions:d}){const{t:u}=Ba(),[m,p]=t.useState(a||{inputType:"url",controls:!0}),h=t.useRef(null),f=t.useRef(null),{upload:g,uploading:x}=Og({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:b}=Og({uploadFunction:o,deleteFunction:c,defaultOptions:{...d,allowedTypes:["image/*"],maxSize:5242880}}),y=t.useMemo(()=>Vg(m.videoUrl||Ug(m.embedCode)||""),[m.videoUrl,m.embedCode]),w=(e,t)=>{const a={...m,[e]:t};p(a),r(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("input_type")}),e.jsxs(qt,{value:m.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(Gt,{children:e.jsx(Kt,{})}),e.jsxs(Jt,{children:[e.jsx(Zt,{value:"url",children:u("url")}),e.jsx(Zt,{value:"upload",children:u("input_type_upload")}),e.jsx(Zt,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||t.name.replace(/\.[^/.]+$/,"")};p(a),r(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(mt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),u("select_video")]})}),m.videoFile&&e.jsx("span",{className:"text-xs text-muted-foreground truncate self-center",children:u("video.fileInfo",{name:m.videoFile,size:Math.round((m.videoSize||0)/1024/1024)})})]})]}),"embed"===m.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("embed")}),e.jsx(aa,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ht,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await v(t),a={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(a),r(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e.jsx(mt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("video.uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]}),m.thumbnailFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("video.thumbnailFileInfo",{name:m.thumbnailFile})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{htmlFor:"title",children:u("title")}),e.jsx(ht,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:m.autoplay||!1,onChange:e=>w("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(gt,{htmlFor:"autoplay",className:"cursor-pointer",children:u("video.autoplay")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==m.controls,onChange:e=>w("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(gt,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(gt,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=m.videoUrl||Ug(m.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===y)return e.jsxs("video",{controls:!1!==m.controls,autoPlay:m.autoplay,poster:m.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),u("unsupported")]});const a="youtube"===y?Fg(t,m.autoplay):$g(t,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:a,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(mt,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(mt,{onClick:()=>{m.videoUrl||m.embedCode?s(m):i.toast.error(u("error"),{description:u("error_no_video")})},disabled:!(m.videoUrl||m.embedCode),children:u("save")})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:r}){const s=t.videoUrl||Ug(t.embedCode)||"";if(!s)return null;const n=Vg(s),{t:o}=Ba();return e.jsx(xt,{className:`overflow-hidden my-4 ${a}`,style:r,children:e.jsxs(wt,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e.jsx("source",{src:s}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:t.title||o("video"),src:"youtube"===n?Fg(s,t.autoplay):$g(s,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.WizardBreadcrumb=Nn,exports.WizardButtons=kn,exports.WizardForm=function({title:a,sections:r,initialData:s,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:c=!1,usersData:d,showProgressIndicator:u=!0,progressType:m="stepper",validateOnNext:p=!0,allowSkipSections:h=!1,previousButtonText:f,nextButtonText:g,onStepChange:x,onStepValidationFail:v,renderProgressIndicator:b,renderButtons:y,currentStepIndex:w,onCurrentStepChange:j}){const[N,C]=t.useState(0),k=w??N,S=j??C,E=t.useRef(null),[P,R]=t.useState(null),_=t.useCallback(e=>{E.current=e,R(e)},[]),T=t.useMemo(()=>r&&Array.isArray(r)?r.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[r]),{formData:A,errors:M,updateField:I,handleSubmit:L}=Ys(T,s,void 0,i);t.useEffect(()=>{i&&S(0)},[i,S]);const O=t.useCallback(()=>{const e=r[k];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=A[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,A);r&&(a[e.name]=r,s=!1)}}),!s&&v&&v(k,a),s},[r,k,A,v]),D=t.useCallback(()=>{if(p&&!O())return;const e=k+1;e<r.length&&(S(e),x?.(e,r[e].id))},[k,r,p,O,S,x]),F=t.useCallback(()=>{const e=k-1;e>=0&&(S(e),x?.(e,r[e].id))},[k,r,S,x]),z=t.useCallback(()=>{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=A[t.name];t.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(e=!1)})}e&&L(n)()},[r,A,L,n]),$=t.useMemo(()=>r.map((e,t)=>({index:t,id:e.id,label:e.label||e.id,isActive:t===k,isCompleted:t<k,isDisabled:e.disabled||!1})),[r,k]),U=0===k,V=k===r.length-1,B=t.useMemo(()=>{if(!u)return null;if(b)return b(k,r.length,r);const t=h?e=>{S(e),x?.(e,r[e].id)}:void 0;switch(m){case"breadcrumb":return e.jsx(Nn,{steps:$,currentStepIndex:k,onStepClick:t});case"progressbar":return e.jsx(Cn,{steps:$,currentStepIndex:k});default:return e.jsx(jn,{steps:$,currentStepIndex:k,onStepClick:t})}},[u,b,m,$,k,r,h,S,x]),W=t.useMemo(()=>{const t={isFirstStep:U,isLastStep:V,canGoNext:k<r.length-1,canGoPrevious:k>0,isLoading:c,onPrevious:F,onNext:D,onSubmit:z,previousButtonText:f,nextButtonText:g,submitButtonText:l};return y?y(t):e.jsx(kn,{...t})},[U,V,k,r.length,c,F,D,z,f,g,l,y]),q=t=>{const a=(t.computedValue,A[t.name]),r=void 0!==a?a:"",s=M[t.name];switch(t.type){case"group":return e.jsxs("div",{className:"space-y-2",children:[t.label&&e.jsx(gt,{className:"text-sm font-medium",children:t.label}),e.jsx("div",{className:ct("grid gap-4",1===t.columns&&"grid-cols-1",2===t.columns&&"grid-cols-1 md:grid-cols-2",3===t.columns&&"grid-cols-1 md:grid-cols-3",4===t.columns&&"grid-cols-1 md:grid-cols-4",!t.columns&&"grid-cols-1"),children:t.fields?.map(e=>q(e))})]},t.name);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:"number",value:r,onChange:e=>I(t.name,""===e.target.value?"":Number(e.target.value)),placeholder:t.placeholder,disabled:t.disabled||void 0!==t.computedValue,className:s?"border-destructive":""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(aa,{id:t.name,value:r,onChange:e=>I(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,rows:t.rows||3,className:s?"border-destructive":""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(qt,{value:r,onValueChange:e=>I(t.name,e),children:[e.jsx(Gt,{className:s?"border-destructive":"",children:e.jsx(Kt,{placeholder:t.placeholder||`Selecione ${t.label}`})}),e.jsx(Jt,{children:t.options?.map(t=>e.jsx(Zt,{value:String(t.value),children:t.label},t.value))})]}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"multiselect":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ka,{options:t.options||[],value:Array.isArray(r)?r:[],onChange:e=>I(t.name,e),placeholder:t.placeholder,className:s?"border-destructive":""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"color":case"color-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(en,{value:r,onChange:e=>I(t.name,e),label:""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"icon-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(sn,{value:r,onChange:e=>I(t.name,e),label:""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"user-select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ln,{value:r,onChange:e=>I(t.name,e),placeholder:t.placeholder,disabled:t.disabled}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name);case"custom":return t.render?e.jsxs("div",{className:"space-y-2",children:[t.label&&e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.render({value:r,onChange:e=>I(t.name,e),error:s,disabled:t.disabled}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name):null;default:return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(gt,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ht,{id:t.name,type:t.type||"text",value:r,onChange:e=>I(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled||void 0!==t.computedValue,className:s?"border-destructive":""}),s&&e.jsx("p",{className:"text-sm text-destructive",children:s})]},t.name)}},H=r[k];return e.jsx(Ct,{open:i,onOpenChange:o,children:e.jsxs(_t,{ref:_,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Tt,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e.jsx(It,{className:"text-white",children:a})}),B,e.jsx("div",{className:"space-y-4 py-4",children:H?.fields.map(e=>q(e))}),e.jsx("div",{className:"flex justify-between pt-4 border-t",children:W})]})})},exports.WizardProgressBar=Cn,exports.WizardStepper=jn,exports.assets=Yf,exports.badgeVariants=ra,exports.buildHierarchy=xg,exports.buttonGroupVariants=ko,exports.buttonVariants=ut,exports.calculateAspectRatio=Bg,exports.cn=ct,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:r,config:s,onSave:n,onEdit:o,onToggleStatus:i}=t,l=a??r,c={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:o||s.onEdit};return e.jsx(vn,{manager:l,config:c,formSections:s.formSections,onSave:n,onToggleStatus:i,defaultSort:s.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=If({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=If,exports.createService=$r,exports.createSimpleSaveHandler=function(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)}}},exports.createSimpleService=function(e){const t=$r({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)=>Xr({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:r})}},exports.debounce=(e,t)=>{let a;return(...r)=>{clearTimeout(a),a=setTimeout(()=>e(...r),t)}},exports.deriveEmailField=Mr,exports.deriveNameField=Ar,exports.deriveUsernameField=Ir,exports.detectVideoProvider=Vg,exports.emailService=ug,exports.errorService=or,exports.extractImageFileName=function(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"}},exports.extractVimeoId=zg,exports.extractYouTubeId=Dg,exports.filterAndPromoteOrphans=function(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))},exports.flattenTree=vg,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=cg,exports.formatDatetime=e=>{if(!e)return"";const t=o.parseISO(e);if(!o.isValid(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(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:yn(e),label:yn(e),...bn(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}},exports.getQualiexConfig=Rr,exports.getSupabaseClient=pr,exports.handleExternalLink=lt,exports.i18n=it,exports.inputGroupAddonVariants=ui,exports.inputGroupButtonVariants=pi,exports.isDevEnvironment=Er,exports.isImageUrl=function(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))},exports.logoSrc=Zf,exports.normalizeVideoUrl=function(e,t,a){switch(t||Vg(e)){case"youtube":return Fg(e,a);case"vimeo":return $g(e,a);default:return e}},exports.normalizeVimeoUrl=$g,exports.normalizeYouTubeUrl=Fg,exports.parseIframeSrc=Ug,exports.placeService=gg,exports.qualiexApi=Nr,exports.resizeKeepingAspect=function(e,t,a,r){const s=Bg(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}},exports.resolveFieldMappings=Lr,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new x.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=eg,exports.toggleVariants=Pl,exports.translationService=Fn,exports.trimTextFields=dt,exports.useActiveModules=Kf,exports.useAuth=Qr,exports.useBaseForm=Ys,exports.useColumnResize=Gs,exports.useCreateLeaderMutation=function(){const e="common",{alias:t}=Qr(),a=x.useQueryClient(),r=pr();return x.useMutation({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 kg(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]}),i.toast.success("Líder adicionado com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=wg,exports.useCreateSingleLeaderMutation=yg,exports.useCrud=Xr,exports.useDebounce=Wf,exports.useFormField=Ft,exports.useHasOpenModal=function(){const{hasOpenModal:e}=ng();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t,datetimeFormat:a}=qn();return{formatDatetime:e=>((e,t="dd/MM/yyyy HH:mm")=>{if(!e)return"";const a=o.parseISO(e);return o.isValid(a)?o.format(a,t):"Invalid date"})(e,a,t),formatDate:t=>cg(t,e),locale:e,timezone:t,datetimeFormat:a}},exports.useLeadershipApi=bg,exports.useLocale=qn,exports.useMediaUpload=Og,exports.useModalState=ng,exports.useNavigation=Vf,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:r}=An();t.useEffect(()=>(a(e),()=>r()),[e.title,e.subtitle,a,r])},exports.usePageMetadataContext=An,exports.usePageTitle=Bf,exports.usePermissionQuery=Hf,exports.useQualiexUsers=on,exports.useRemoveLeaderMutation=Ng,exports.useRouteBreadcrumbs=function(){const e=v.useLocation();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,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:r,isCurrentPage:n})}),a})()},exports.useRowResize=Qs,exports.useSidebar=Yi,exports.useSidebarResize=rg,exports.useSyncSubordinatesMutation=Cg,exports.useTranslation=Ba,exports.useUpdateLeaderMutation=jg;
1
+ "use strict";var e=require("react/jsx-runtime"),a=require("react"),t=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),i=require("date-fns"),o=require("i18next"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),x=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("react-i18next"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),y=require("react-router-dom"),j=require("@radix-ui/react-tooltip"),N=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-progress"),P=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-alert-dialog"),_=require("@radix-ui/react-avatar"),A=require("react-day-picker"),E=require("vaul"),M=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),D=require("@radix-ui/react-radio-group"),F=require("react-resizable-panels"),z=require("@radix-ui/react-slider"),L=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-toggle"),U=require("@radix-ui/react-toggle-group"),q=require("@radix-ui/react-menubar"),$=require("recharts"),B=require("@tiptap/react"),W=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("zod"),J=require("@hookform/resolvers");function Y(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var Z=Y(a),ee=Y(c),ae=Y(u),te=Y(m),se=Y(h),re=Y(x),ne=Y(f),ie=Y(j),oe=Y(N),le=Y(w),de=Y(C),ce=Y(k),ue=Y(S),me=Y(P),pe=Y(T),he=Y(I),xe=Y(_),fe=Y(M),ge=Y(R),be=Y(D),ve=Y(F),ye=Y(z),je=Y(L),Ne=Y(O),we=Y(U),Ce=Y(q),ke=Y($);function Se(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Pe(...e){return n.twMerge(r.clsx(e))}const Te=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Te);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Te(s);return a}return e},Ie=s.cva("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",danger:"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"}}),_e=Z.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:Pe(Ie({variant:s,size:r,className:a})),ref:o,...i})});_e.displayName="Button";const Ae=a.forwardRef(({className:a,children:t,...s},r)=>e.jsx(_e,{ref:r,variant:"action",size:"sm",className:Pe("h-7 px-2 text-xs",a),...s,children:t||e.jsx(d.EllipsisVertical,{size:12})}));Ae.displayName="ActionButton";const Ee=Z.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:Pe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:r,...s}));Ee.displayName="Input";const Me=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=Z.forwardRef(({className:a,...t},s)=>e.jsx(ee.Root,{ref:s,className:Pe(Me(),a),...t}));Re.displayName=ee.Root.displayName;const De=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));De.displayName="Card";const Fe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex flex-col space-y-1.5 p-6",a),...t}));Fe.displayName="CardHeader";const ze=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("text-2xl font-semibold leading-none tracking-tight",a),...t}));ze.displayName="CardTitle";const Le=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Le.displayName="CardDescription";const Oe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("p-6 pt-0",a),...t}));Oe.displayName="CardContent";const Ue=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex items-center p-6 pt-0",a),...t}));Ue.displayName="CardFooter";const qe=Z.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(te.Root,{ref:n,decorative:s,orientation:t,className:Pe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));qe.displayName=te.Root.displayName;const $e=ae.Root,Be=ae.Trigger,We=ae.Portal,Ve=ae.Close,He=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t}));He.displayName=ae.Overlay.displayName;const Ge={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},Qe=Z.forwardRef(({className:a,children:t,size:s="md",...r},n)=>e.jsxs(We,{children:[e.jsx(He,{}),e.jsxs(ae.Content,{ref:n,className:Pe("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",Ge[s],a),...r,children:[t,e.jsxs(ae.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Qe.displayName=ae.Content.displayName;const Ke=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Ke.displayName="DialogHeader";const Xe=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Xe.displayName="DialogBody";const Je=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Je.displayName="DialogFooter";const Ye=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Ye.displayName=ae.Title.displayName;const Ze=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Ze.displayName=ae.Description.displayName;const ea=p.FormProvider,aa=Z.createContext({}),ta=()=>{const e=Z.useContext(aa),a=Z.useContext(sa),{getFieldState:t,formState:s}=p.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},sa=Z.createContext({}),ra=Z.forwardRef(({className:a,...t},s)=>{const r=Z.useId();return e.jsx(sa.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Pe("space-y-2",a),...t})})});ra.displayName="FormItem";const na=Z.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=ta();return e.jsx(Re,{ref:s,className:Pe(r&&"text-destructive",a),htmlFor:n,...t})});na.displayName="FormLabel";const ia=Z.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=ta();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...a})});ia.displayName="FormControl";const oa=Z.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=ta();return e.jsx("p",{ref:s,id:r,className:Pe("text-sm text-muted-foreground",a),...t})});oa.displayName="FormDescription";const la=Z.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:i}=ta(),o=n?String(n?.message):t;return o?e.jsx("p",{ref:r,id:i,className:Pe("text-sm font-medium text-destructive",a),...s,children:o}):null});la.displayName="FormMessage";const da=se.Root,ca=se.Group,ua=se.Value,ma=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...s,children:[t,e.jsx(se.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ma.displayName=se.Trigger.displayName;const pa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));pa.displayName=se.ScrollUpButton.displayName;const ha=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));ha.displayName=se.ScrollDownButton.displayName;const xa=Z.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:o,className:Pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===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:n,...i,children:[e.jsx(pa,{}),e.jsx(se.Viewport,{className:Pe("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(ha,{})]})}));xa.displayName=se.Content.displayName;const fa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Label,{ref:s,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));fa.displayName=se.Label.displayName;const ga=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Item,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(se.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),e.jsx(se.ItemText,{children:t})]}));ga.displayName=se.Item.displayName;const ba=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));ba.displayName=se.Separator.displayName;const va=Z.forwardRef(({className:a,...t},s)=>e.jsx(re.Root,{ref:s,className:Pe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...t,children:e.jsx(re.Indicator,{className:Pe("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));va.displayName=re.Root.displayName;const ya=Z.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:Pe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:s,...t}));ya.displayName="Textarea";const ja=s.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),Na=Z.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(ja({variant:t}),a),...s}));Na.displayName="Badge";const wa={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ca({size:a="md",className:t}){return e.jsx(d.Loader2,{className:Pe("animate-spin text-muted-foreground",wa[a],t)})}const ka=({...a})=>e.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(d.Loader2Icon,{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-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...a}),Sa=ne.Root,Pa=ne.Trigger,Ta=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(ne.Portal,{container:r,children:e.jsx(ne.Content,{ref:i,align:t,sideOffset:s,className:Pe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...n})}));Ta.displayName=ne.Content.displayName;const Ia=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ia.displayName="Command";const _a=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Pe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})}));_a.displayName="CommandInput";const Aa=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Aa.displayName="CommandList";const Ea=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("py-6 text-center text-sm text-muted-foreground",a),...t}));Ea.displayName="CommandEmpty";const Ma=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Ma.displayName="CommandGroup";const Ra=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("-mx-1 h-px bg-border",a),...t}));Ra.displayName="CommandSeparator";const Da=Z.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",a),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Da.displayName="CommandItem";const Fa=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function za({className:a,...t}){return e.jsx("div",{className:Pe("animate-pulse rounded-md bg-muted",a),...t})}Fa.displayName="CommandShortcut";const La=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Oa({multiple:t,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:x,className:f,sortOptions:b,maxDisplayedBadges:v,popoverContainer:y,onOpen:j,onClose:N}){const{t:w}=g.useTranslation(),[C,k]=a.useState(!1),[S,P]=a.useState(""),T=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=a.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),_=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return b?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,b]),A=a.useMemo(()=>{if(!S)return _;const e=La(S);return _.filter(a=>La(a.label).includes(e))},[_,S]),E=a.useMemo(()=>_.filter(e=>T.includes(e.value)),[_,T]),M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?T.filter(a=>a!==e):"")},R=v?E.slice(0,v):E,D=v&&E.length>v?E.length-v:0;return e.jsxs("div",{className:Pe("space-y-2",f),children:[c&&e.jsxs(Re,{children:[c,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Sa,{open:C,onOpenChange:e=>{k(e),e?j?.():(P(""),N?.())},modal:!1,children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":C,disabled:h,className:Pe("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),l]}):t?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(a=>e.jsxs(Na,{variant:"secondary",className:"gap-1 pr-1",children:[a.label,e.jsx("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&&M(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(a.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),D>0&&e.jsxs(Na,{variant:"outline",className:"gap-1",children:["+",D]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ta,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:e.jsxs(Ia,{children:[e.jsx(_a,{placeholder:p,value:S,onChange:e=>P(e.target.value)}),e.jsx(Aa,{children:0===s.length?e.jsx(Ea,{children:m}):0===A.length?e.jsx(Ea,{children:w("no_results")}):e.jsx(Ma,{children:A.map(a=>e.jsxs(Da,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];n(a)}else n(e),k(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Pe("mr-2 h-4 w-4",T.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function Ua({multiple:a=!1,options:t,items:s,value:r,onChange:n,onValueChange:i,getOptionValue:o=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:b=!1,error:v,className:y,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k}){const{t:S}=g.useTranslation(),P=s||t||[],T=i||n,I=c||S("select_placeholder"),_=p||S("no_results"),A=h||S("search_placeholder");if(b)return e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(za,{className:"h-10 w-full"})]});const E="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return E?e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:E})]})]}):e.jsx(Oa,{multiple:a,options:P,value:r||(a?[]:""),onChange:T,getOptionValue:o,getOptionLabel:l,placeholder:I,label:u,icon:m,emptyMessage:_,searchPlaceholder:A,disabled:x,required:f,className:y,sortOptions:j,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k})}var qa=Object.defineProperty;class $a{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";t.push(e),i=!1}if(r.exp&&r.exp<o){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?qa(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})($a,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Ba="qualiex_access_token",Wa="qualiex_id_token",Va="supabase_token",Ha="oauth_state",Ga="oauth_nonce",Qa="selected_alias",Ka="manual_logout",Xa={setAccessToken:e=>localStorage.setItem(Ba,e),getAccessToken:()=>localStorage.getItem(Ba),setIdToken:e=>localStorage.setItem(Wa,e),getIdToken:()=>localStorage.getItem(Wa),getSupabaseToken:()=>localStorage.getItem(Va),setOAuthState:e=>sessionStorage.setItem(Ha,e),getOAuthState:()=>sessionStorage.getItem(Ha),clearOAuthState:()=>sessionStorage.removeItem(Ha),setOAuthNonce:e=>sessionStorage.setItem(Ga,e),getOAuthNonce:()=>sessionStorage.getItem(Ga),clearOAuthNonce:()=>sessionStorage.removeItem(Ga),setSelectedAlias:e=>localStorage.setItem(Qa,e),getSelectedAlias:()=>localStorage.getItem(Qa),clearSelectedAlias:()=>localStorage.removeItem(Qa),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Xa.getAccessToken()||!Xa.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Va,e),Xa._clearValidationCache()},areAllTokensValid:()=>{const e=Xa.getAccessToken(),a=Xa.getIdToken();if(!e||!a)return!1;try{const t=$a.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Xa.getAccessToken(),t=Xa.getIdToken(),s=Xa.getSupabaseToken();return a&&Xa.isTokenExpired(a)&&(localStorage.removeItem(Ba),e=!0),t&&Xa.isTokenExpired(t)&&(localStorage.removeItem(Wa),e=!0),s&&Xa.isTokenExpired(s)&&(localStorage.removeItem(Va),e=!0),e},clearAll:()=>{localStorage.removeItem(Ba),localStorage.removeItem(Wa),localStorage.removeItem(Va),localStorage.removeItem(Qa),localStorage.removeItem(Ka),sessionStorage.removeItem(Ha),sessionStorage.removeItem(Ga)},setManualLogout:()=>localStorage.setItem(Ka,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ka),clearManualLogout:()=>localStorage.removeItem(Ka),isTokenExpired:e=>{try{return $a.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Xa._validationCache.isValid=!1,Xa._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Xa.getSupabaseToken();if(!e)return!1;if(Xa.isTokenExpired(e))return Xa._clearValidationCache(),Xa._handleExpiredToken(),!1;const a=Date.now();return a-Xa._validationCache.timestamp<Xa._validationCache.cacheValidityMs?Xa._validationCache.isValid:(Xa._validationCache.isValid=!0,Xa._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Xa.isSupabaseTokenValid()?Xa.getSupabaseToken():null,_handleExpiredToken:()=>{Xa.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Xa.isSupabaseTokenValid())return null;const e=Xa.getSupabaseToken();if(!e)return null;try{const a=$a.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return Xa._handleExpiredToken(),null}},getCompanyId:e=>{const a=Xa.getAccessToken();if(a)try{const t=$a.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=Xa.extractTokenData();if(t?.companyId)return t.companyId;const s=Xa.getIdToken();if(s)try{const a=$a.parseJwtPayload(s);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Xa.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Xa.getIdToken();if(!e)return[];try{const a=$a.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var Ja=Object.defineProperty,Ya=(e,a,t)=>((e,a,t)=>a in e?Ja(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Za=new class{constructor(){Ya(this,"errors",[]),Ya(this,"toastCount",0),Ya(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);l.toast.error(e,{description:t})}}getErrorTitle(e){const a=e.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?"Sessão Expirada":a.includes("token")||a.includes("autenticação")?"Erro de Autenticação":a.includes("api")||a.includes("network")?"Erro de Conexão":"Erro"}success(e,a){l.toast.success(e,{description:a})}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 et=Object.defineProperty,at=(e,a,t)=>((e,a,t)=>a in e?et(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const tt=(void 0).VITE_SUPABASE_URL,st=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,rt=class e{constructor(){at(this,"client"),at(this,"currentToken",null),at(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:st};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return b.createClient(tt,st,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("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,a)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Xa.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return Za.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};at(rt,"instance");let nt=rt;function it(){return nt.getInstance().getClient()}class ot{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Xa.getSupabaseToken();if(e&&Xa.isSupabaseTokenValid())return e}const r=it(),{data:n,error:i}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token&&n.access_token?(Xa.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}var lt=Object.defineProperty,dt=(e,a,t)=>((e,a,t)=>a in e?lt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class ct{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Xa.getAccessToken(),a=Xa.getSelectedAlias();if(!e||!a)return null;const t=await ot.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Xa.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}dt(ct,"isRegenerating",!1),dt(ct,"onLogoutCallback",null);class ut{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Xa.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var mt=Object.defineProperty;class pt{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await ct.attemptRegeneration()?(this.isRetrying=!1,!0):(ut.handleError(e),this.isRetrying=!1,!1)}catch(s){return ut.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Xa.getAccessToken();return e?Xa.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,a,t)=>{((e,a,t)=>{a in e?mt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(pt,"isRetrying",!1);var ht=Object.defineProperty,xt=(e,a,t)=>((e,a,t)=>a in e?ht(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ft=new class{constructor(){xt(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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){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}}async fetchUsers(e,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=t}if(!Array.isArray(s))return Za.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=t}return Array.isArray(s)?s.map(this.mapToQualiexUser):(Za.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return Za.handleError(r,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return Za.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),s=new Map;return t.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const a=Xa.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},gt={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},bt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},vt={debounceDelay:500},yt=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},jt={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Nt=()=>jt,wt={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Ct={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 kt(e,a){const t=Nt(),s=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function St(e,a){const t=Nt(),s=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Pt(e,a){const t=Nt(),s=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Tt(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||kt(e.idField),emailField:e.emailField||St(e.idField),usernameField:e.usernameField||Pt(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:kt(e),emailField:St(e),usernameField:Pt(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const It=new Map;class _t{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=It.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await ft.fetchUsers(e,a);return It.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||n.displayName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Xa.areAllTokensValid())return e;const t=Xa.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=Tt(a.userIdFields,a.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(s,r),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(t){return Za.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,a){return this.enrichWithUserData(e,{entityName:a.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const At=["responsible_name"],Et=e=>At.includes(e);function Mt(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!Xa.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return it().schema(o).from(r)},u=(e,a,t,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const o=a.includes(".");return o||Et(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:o}},m=async(e,a,t,r,n)=>{const i=Tt(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(Et(a)||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 _t.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,r,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 _t.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})};return{async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,i,o),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let b=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=Tt(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Te(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Te(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}}}const Rt=()=>{Xa.clearManualLogout()},Dt=e=>e?.placeId||null,Ft=e=>e?.placeName||null,zt=e=>({placeId:Dt(e),placeName:Ft(e)}),Lt=class{static async initialize(){try{if(!Xa.hasAllTokens()||!Xa.areAllTokensValid())return Xa.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 a=Xa.getAccessToken(),t=Xa.getIdToken();Rt();const s=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Xa.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=Xa.getSelectedAlias(),a=e&&r.some(a=>a.alias===e);l=a?e:n||r[0]?.alias||null}!Xa.isSupabaseTokenValid()&&l&&await ct.attemptRegeneration();let d=null;if(l){const e=Xa.getCompanyId(l),a=r.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,u=null;if(s?.id&&l){const a=Xa.getCompanyId(l);if(a)try{const e=(await ft.fetchActiveUsersMap(l,a)).get(s.id);if(e){const a=zt(e);c=a.placeId,u=a.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:s,alias:l,companies:r,selectedUnit:d,userId:s?.id||null,userAlias:s?.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=it(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Xa.generateOAuthState();Xa.setOAuthState(e);const a=Xa.generateOAuthNonce();Xa.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(gt.oauth.authUrl);s.searchParams.set("client_id",gt.oauth.clientId),s.searchParams.set("response_type",gt.oauth.responseType),s.searchParams.set("scope",gt.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),yt(),window.location.href=s.toString()}static async processCallback(){try{if(Xa.hasAllTokens()){if(!Xa.getValidSupabaseToken()){Xa.getAccessToken();await ct.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");Xa.setAccessToken(s),Xa.setIdToken(r),Rt();const i=this.extractAliasFromAccessToken(s);if(i)Xa.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Xa.setSelectedAlias(e[0].alias)}if(!await ct.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Xa.clearOAuthState(),Xa.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Xa.setManualLogout(),Xa.clearAll(),window.location.href="/login"}static decodeToken(e){return $a.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};ct.setLogoutCallback(()=>{Lt.logout()});let Ot=Lt;const Ut=a.createContext(void 0),qt=({children:t})=>{const[s,r]=a.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=v.useQueryClient()}catch{}const[i,o]=a.useState(!1),[l,d]=a.useState(0),c=a.useCallback(e=>{r(a=>({...a,...e}))},[]),u=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),m=a.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=a.useCallback(async e=>{try{u(!0);const t=Xa.getAccessToken();if(!t)return;const r=await ot.generateToken(t,e.alias,void 0,!0);if(!r)return;Xa.setSupabaseToken(r),Xa.setSelectedAlias(e.alias);const i=Xa.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Xa.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let m=null,p=null;if(s.user?.id&&o&&l)try{const e=(await ft.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const a=zt(e);m=a.placeId,p=a.placeName}}catch(a){}c({alias:o,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{u(!1)}},[c,n,u,s.user]),h=a.useCallback(async()=>await Ot.processCallback(),[]),x=a.useCallback(async()=>{Ot.logout(),m(),n&&await n.clear()},[m,n]),f=a.useCallback(e=>{o(e)},[]),g=a.useCallback(()=>{d(e=>e+1)},[]),b=a.useCallback(()=>{d(e=>e+1)},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Xa.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Ot.initialize();if(!e)return;a&&a.isAuthenticated?c({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&u(!1)}catch(a){e&&(ut.handleError(a),u(!1))}})(),()=>{e=!1}},[c,u,x]);const y=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,x,h,p,i,f,g,b]);return e.jsx(Ut.Provider,{value:y,children:t})},$t=()=>{const e=a.useContext(Ut);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Bt({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=y.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=$t(),h=a.useCallback(a=>{const t=`${e}_${a}`,s=o.get(t);return s||(o.get(a)||"")},[o,e]),x=h("search"),f=h("sortField")||bt.sorting.defaultField,g=h("sortDirection")||bt.sorting.defaultDirection,b=parseInt(h("page")||"1"),j=parseInt(h("limit")||String(bt.pagination.defaultPageSize)),N=x,w=a.useMemo(()=>({search:N,sortField:f,sortDirection:g,page:b,limit:j,...n}),[N,f,g,b,j,n]),C=a.useCallback(()=>t.getAll(w),[t,w]),k=v.useQuery({queryKey:[e,u,m,w],queryFn:C,enabled:!!u&&p});if(!k)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const S=v.useMutation({mutationFn:t.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.created(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.create(s)}: ${e.message}`)}}),P=v.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.update(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:t.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.deleted(s))},onError:e=>{l.toast.error(`${Ct.error.delete(s)}: ${e.message}`)}}),I=a.useCallback(a=>{const t={...Object.fromEntries(o)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[o,d,e]),_=a.useCallback(e=>{I({search:e,page:1})},[I]),A=a.useCallback(e=>{I({sortField:e,sortDirection:f===e&&"asc"===g?"desc":"asc",page:1})},[f,g,I]),E=a.useCallback(e=>{I({page:e})},[I]),M=a.useCallback(e=>{I({limit:e,page:1})},[I]),R=a.useCallback(()=>{const a=Object.fromEntries(o),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,o,e]),[D,F]=a.useState([]),z=a.useCallback(e=>{F(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=a.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];F(a=>a.length===e.length?[]:e)},[k?.data?.data]),O=a.useCallback(()=>{F([])},[]),U=a.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,k?.data?.data]),q=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${t.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),$=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):S.mutate({...t,alias:u})},[u,S,P]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||bt.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:T?.isPending??!1,error:k?.error||null,searchTerm:x,sortField:f,sortDirection:g,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:S.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:T.mutate,save:$,handleSearch:_,handleSort:A,handlePageChange:E,handleItemsPerPageChange:M,clearFilters:R,refetch:k.refetch,selectedIds:D,selectItem:z,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}const Wt=Z.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:Pe("w-full caption-bottom text-sm table-fixed",a),...t}));Wt.displayName="Table";const Vt=Z.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:Pe("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Vt.displayName="TableHeader";const Ht=Z.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:Pe("[&_tr:last-child]:border-0",a),...t}));Ht.displayName="TableBody";const Gt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:Pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Gt.displayName="TableFooter";const Qt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:Pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Qt.displayName="TableRow";const Kt=Z.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:Pe("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",a),...t}));Kt.displayName="TableHead";const Xt=Z.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:Pe("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Xt.displayName="TableCell";const Jt=Z.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:Pe("mt-4 text-sm text-muted-foreground",a),...t}));function Yt({rows:a=5,columns:t=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-24"},t))})}),e.jsx("div",{children:Array.from({length:a}).map((a,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-20"},t))})},s))})]})})}function Zt({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(De,{children:[e.jsxs(Fe,{children:[e.jsx(za,{className:"h-4 w-3/4"}),e.jsx(za,{className:"h-3 w-1/2"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-3 w-full"}),e.jsx(za,{className:"h-3 w-2/3"})]})})]},t))})}Jt.displayName="TableCaption";const es={default:d.FileX,search:d.Search,error:d.AlertCircle};function as({icon:a,title:t,description:s,action:r,className:n,variant:i="default"}){const o=a?()=>a:es[i];return e.jsxs("div",{className:Pe("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(_e,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ts=ie.Provider,ss=ie.Root,rs=ie.Trigger,ns=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:t,className:Pe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s}));function is({children:a,className:t}){const s=Z.useRef(null),[r,n]=Z.useState(!1);Z.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[a]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(ts,{delayDuration:300,children:e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:i}),e.jsx(ns,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):i}ns.displayName=ie.Content.displayName;const os=Z.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const i="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:Pe("absolute z-20 select-none touch-none","transition-colors duration-150",i&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!i&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Pe("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});os.displayName="TableResizeHandle";const ls=oe.Root,ds=oe.Trigger,cs=oe.Group,us=oe.Portal,ms=oe.Sub,ps=oe.RadioGroup,hs=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Pe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));hs.displayName=oe.SubTrigger.displayName;const xs=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.SubContent,{ref:s,className:Pe("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...t}));xs.displayName=oe.SubContent.displayName;const fs=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:t,className:Pe("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 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",a),...s})}));fs.displayName=oe.Content.displayName;const gs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Item,{ref:r,className:Pe("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",a),...s}));gs.displayName=oe.Item.displayName;const bs=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Pe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));bs.displayName=oe.CheckboxItem.displayName;const vs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Pe("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));vs.displayName=oe.RadioItem.displayName;const ys=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));ys.displayName=oe.Label.displayName;const js=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));js.displayName=oe.Separator.displayName;const Ns=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest opacity-60",a),...t});Ns.displayName="DropdownMenuShortcut";const ws=le.Root,Cs=le.Trigger,ks=le.Group,Ss=le.Portal,Ps=le.Sub,Ts=le.RadioGroup,Is=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Is.displayName=le.SubTrigger.displayName;const _s=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.SubContent,{ref:s,className:Pe("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",a),...t}));_s.displayName=le.SubContent.displayName;const As=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Pe("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",a),...t})}));As.displayName=le.Content.displayName;const Es=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Item,{ref:r,className:Pe("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",t&&"pl-8",a),...s}));Es.displayName=le.Item.displayName;const Ms=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Pe("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,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Ms.displayName=le.CheckboxItem.displayName;const Rs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Pe("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.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Rs.displayName=le.RadioItem.displayName;const Ds=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));Ds.displayName=le.Label.displayName;const Fs=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-border",a),...t}));Fs.displayName=le.Separator.displayName;const zs=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});zs.displayName="ContextMenuShortcut";const Ls=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=g.useTranslation(),c=[];if(a){const e={icon:d.Edit,label:l("edit"),onClick:a};c.push(e)}if(i.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:l(r?"deactivate":"activate"),onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===o?gs:Es;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(u,{onClick:a.onClick,className:Pe("whitespace-normal cursor-pointer",a.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(a.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.label]},t))})},Os=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Ls,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:i,renderAs:"dropdown"})})]}),Us=150;function qs({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,i]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{})}),[o,l]=a.useState(!1),[d,c]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??Us)},[r,n]);a.useEffect(()=>{if(!o||!d)return;const a=e.find(e=>e.key===d),r=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));i(e=>{const a={...e,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(null),t&&i(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[o,d,e,t,s]),a.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});i(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:p,resetWidths:h}}function $s({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=a.useState(()=>{if(!o||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{o&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[o,l,t]);a.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return i?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=a.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}}const Bs=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(va,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Ws=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,enableColumnResize:b=!0,resizeStorageKey:v})=>{const{t:y}=g.useTranslation(),{setSearchVisible:j}=$t(),[N,w]=a.useState(!1);a.useEffect(()=>(j(!0),()=>j(!1)),[j]),a.useEffect(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:P}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:v?`${v}-columns`:void 0,enabled:b}),{isDragging:T,activeRow:I,handleMouseDown:_,getRowHeight:A}=$s({rowIds:t.entities.map(e=>e.id),storageKey:v?`${v}-rows`:void 0,enabled:!1}),E=a.useMemo(()=>(()=>{if(b)return s.map(e=>{const a=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=s.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,b,C]),M=!f&&(m||x.length>0);return N?t.isLoading?e.jsx(Zt,{count:3}):0===t.entities.length?e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsx(De,{className:Pe("overflow-hidden cursor-pointer hover:bg-muted/50",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(t=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Os,{onEdit:r?()=>{r(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})})})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),t.isLoading?e.jsx(Yt,{rows:5,columns:s.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(Wt,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Vt,{children:e.jsxs(Qt,{children:[u&&e.jsx(Kt,{className:"w-[50px]",children:e.jsx(Bs,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),s.map(a=>{const s=b&&!1!==a.resizable,r=S===String(a.key);return e.jsxs(Kt,{className:Pe(a.className,a.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(n=String(a.key),t.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>P(String(a.key),e),isDragging:r})]},String(a.key));var n}),e.jsx(Kt,{className:"w-[50px] text-center",children:y("actions")})]})}),e.jsx(Ht,{children:0===t.entities.length?e.jsx(Qt,{children:e.jsx(Xt,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):t.entities.map(a=>{const n=A(a.id);return a.id,e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsxs(Qt,{className:Pe("cursor-pointer hover:bg-muted/50 relative",u&&t.selectedIds.includes(a.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Xt,{onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),e.jsx(Xt,{className:"text-center",children:l?l(a):e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})]})})})]})};function Vs(e,t,s,r){const[n,i]=a.useState({}),[o,l]=a.useState({}),d=a.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};a.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},a=e(d),n={};a.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);c(e)&&(a=e.toISOString().split("T")[0])}else c(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),t&&Object.keys(t).forEach(e=>{a.find(a=>a.name===e)||void 0===t[e]||(n[e]=t[e])}),i(n),l({}),s&&s(n)},[d,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:o,updateField:(e,a)=>{i(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),o[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Hs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Gs=({value:a="#3b82f6",onChange:t,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Re,{children:s}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:a}}),a]})}),e.jsx(Ta,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Ee,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Hs.map(a=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>t?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),Qs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.Root,{ref:r,className:Pe("relative overflow-hidden",a),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(Ks,{}),e.jsx(de.Corner,{})]}));Qs.displayName=de.Root.displayName;const Ks=Z.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:t,className:Pe("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ks.displayName=de.ScrollAreaScrollbar.displayName;const Xs={Star:d.Star,Heart:d.Heart,Home:d.Home,User:d.User,Settings:d.Settings,Mail:d.Mail,Phone:d.Phone,Calendar:d.Calendar,MapPin:d.MapPin,Camera:d.Camera,Image:d.Image,Music:d.Music,Video:d.Video,Book:d.Book,Bookmark:d.Bookmark,Search:d.Search,Filter:d.Filter,Edit:d.Edit,Trash2:d.Trash2,Plus:d.Plus,Minus:d.Minus,Check:d.Check,X:d.X,ChevronDown:d.ChevronDown,ChevronUp:d.ChevronUp,ChevronLeft:d.ChevronLeft,ChevronRight:d.ChevronRight,ArrowUp:d.ArrowUp,ArrowDown:d.ArrowDown,ArrowLeft:d.ArrowLeft,ArrowRight:d.ArrowRight,Clock:d.Clock,Bell:d.Bell,AlertCircle:d.AlertCircle,Info:d.Info,HelpCircle:d.HelpCircle,Download:d.Download,Upload:d.Upload,Share:d.Share,Copy:d.Copy,Save:d.Save,FileText:d.FileText,Folder:d.Folder,FolderOpen:d.FolderOpen,Archive:d.Archive,Lock:d.Lock,Unlock:d.Unlock,Eye:d.Eye,EyeOff:d.EyeOff,Shield:d.Shield,Key:d.Key,Zap:d.Zap,Flame:d.Flame,Sparkles:d.Sparkles,Award:d.Award,Trophy:d.Trophy,Target:d.Target},Js=({value:t="Star",onChange:s,label:r})=>{const{t:n}=g.useTranslation(),[i,o]=a.useState(""),l=Object.entries(Xs).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Xs[t]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Re,{children:r}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(Ta,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{htmlFor:"icon-search",children:n("search")}),e.jsx(Ee,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e.jsx(Qs,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:l.map(([a,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(a),title:a,children:e.jsx(r,{className:"h-4 w-4"})},a))})})]})})]})]})},Ys=Z.forwardRef(({className:a,...t},s)=>e.jsx(ce.Root,{className:Pe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...t,ref:s,children:e.jsx(ce.Thumb,{className:Pe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ys.displayName=ce.Root.displayName;const Zs=(e={})=>{const{user:a,alias:t}=$t(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",t],queryFn:()=>ft.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},er=({value:t,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:x,sortOptions:f=!0,popoverContainer:b,onOpen:v,onClose:y})=>{const{t:j}=g.useTranslation(),{data:N=[],isLoading:w,error:C}=Zs({enabled:m}),k=a.useMemo(()=>x?N.filter(x):N,[N,x]),S=a.useCallback(e=>{if("custom"===p&&h)return h(e);const a=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[p,h]);return e.jsx(Ua,{multiple:r,value:t??(r?[]:""),onChange:s,options:k,isLoading:w,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||j("search_placeholder"),searchPlaceholder:j("search_placeholder"),emptyMessage:j("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:f,popoverContainer:b,onOpen:v,onClose:y})};function ar({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(s?.[0]?.id||""),h=a.useRef(null),[x,f]=a.useState(null),b=a.useCallback(e=>{h.current=e,f(e)},[]),v=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:y,errors:j,updateField:N,handleSubmit:w}=Vs(v,r,void 0,o),C=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(y):e.disabled||!1})):[],[s,y]),k=a.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const a=C.find(e=>!e.disabled);return a?.id||m},[C,m]);a.useEffect(()=>{k!==m&&p(k)},[k,m]);const S=C.find(e=>e.id===k),P=a=>{const t=(a.computedValue,y[a.name]),s=void 0!==t?t:"",r=j[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",i=t?Pe("space-y-2 w-full",a.wrapperClassName):Pe("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:i,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>P(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s||"",onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:String(s),onValueChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(ma,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ua,{placeholder:a.placeholder})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"date":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"date",value:String(s),onChange:e=>N(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Pe("w-full",r?"border-destructive":"",a.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>N(a.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s||a.defaultValue||"#3b82f6",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s||a.defaultValue||"Star",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"custom":if(!a.component)return null;const o=a.component,l="function"==typeof a.componentProps?a.componentProps(y):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:x,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"number":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);N(a.name,s)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e.jsx(va,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),e.jsxs(Re,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ys,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},a.name);default:return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"text",value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},T=a.useCallback(()=>{if(!S)return null;if(S.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(S.component){const a=S.component;return e.jsx(a,{formData:y,updateField:N,errors:j,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(P)})},[S,y,N,j,c,P]),I=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:C.map(a=>e.jsx(_e,{variant:k===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=C.find(a=>a.id===e);a&&!a.disabled&&p(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:u("loading")})}):e.jsxs("form",{onSubmit:w(n),className:"space-y-3 md:space-y-4",children:[T(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(_e,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(_e,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx($e,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Qe,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(Ye,{children:t}),e.jsx(Ze,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),I]})})}function tr({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(a-1)*r+1,c=Math.min(a*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(da,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(ma,{className:"h-8 w-[70px]",children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"10",children:"10"}),e.jsx(ga,{value:"25",children:"25"}),e.jsx(ga,{value:"50",children:"50"}),e.jsx(ga,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[l,"-",c," de ",s," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:a}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function sr({manager:a}){return e.jsx(tr,{currentPage:a.pagination.currentPage,totalPages:a.pagination.totalPages,totalItems:a.pagination.totalItems,itemsPerPage:a.pagination.itemsPerPage,onPageChange:a.handlePageChange,onItemsPerPageChange:a.handleItemsPerPageChange,variant:"full"})}const rr=({selectedCount:a,onClearSelection:t,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=g.useTranslation();return e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:i("selected_count",{count:a})}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[e.jsx(d.X,{size:14,className:"mr-1"}),i("clear")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:n,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),a.label]},t)}),s&&e.jsxs(_e,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})},nr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ir={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},or={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function lr({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Pe("flex","column"===t?"flex-col":"flex-row",nr[s],ir[r],or[n],i&&"flex-wrap",o),children:a})}function dr({manager:a,filters:t,inline:s=!1}){const{t:r}=g.useTranslation(),{isSearchVisible:n}=$t(),i=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:r("search"),value:a.searchTerm,onChange:e=>a.handleSearch(e.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((a,t)=>e.jsxs("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.jsx("option",{value:"",children:a.placeholder}),a.options.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...a.props})},`custom-${t}`)}),i&&e.jsxs(_e,{variant:"outline",onClick:a.clearFilters,className:"whitespace-nowrap",children:[e.jsx(d.X,{className:"h-4 w-4 mr-2"}),r("clear")]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(lr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(lr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function cr({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){t&&t.queryKey;const{t:l}=g.useTranslation(),{setSearchVisible:c}=$t(),[u,m]=y.useSearchParams(),[p,h]=a.useState(!1),[x,f]=a.useState(null),[b,v]=a.useState({isOpen:!1,entityId:null,entityName:""}),[j,N]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(o&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=o.column,t[a]=o.direction,m(t)}}},[]);const w=()=>{v({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&t.selectedIds.length>0&&e.jsx(rr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:t.selectedIds.length})},customActions:s.bulkActions,isLoading:t.isBulkDeleting}),e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_e,{onClick:()=>{s.onNew?s.onNew():(f(null),h(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((a,t)=>e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e.jsx(a.icon,{size:16,className:"mr-2"}),a.label]},t))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(dr,{manager:t,filters:s.filters,inline:!0})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(t.entities,t)}):e.jsx(Ws,{manager:t,columns:s.columns,onEdit:e=>{s.onEdit?s.onEdit(e):(f(e),h(!0))},onDelete:e=>{v({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(sr,{manager:t})}),!s.useCustomRouting&&e.jsx(ar,{open:p,title:x?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:x||void 0,onSubmit:e=>{n(e),h(!1),f(null)},onCancel:()=>{h(!1),f(null)},isLoading:t.isLoading,submitButtonText:l(x?"update":"create")}),e.jsx($e,{open:b.isOpen,onOpenChange:w,children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:b.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{b.entityId&&(t.deleteEntity(b.entityId),v({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx($e,{open:j.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:j.count})," ",1===j.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),N({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function ur(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function mr(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const pr=Z.forwardRef(({className:a,value:t,...s},r)=>e.jsx(ue.Root,{ref:r,className:Pe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(ue.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function hr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center justify-between mb-6",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:Pe("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",t.isActive&&"border-primary bg-primary text-primary-foreground",t.isCompleted&&"border-primary bg-primary text-primary-foreground",!t.isActive&&!t.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!t.isDisabled&&"cursor-pointer hover:border-primary/50",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:t.isCompleted?e.jsx(d.Check,{className:"w-5 h-5"}):r+1}),r<a.length-1&&e.jsx("div",{className:Pe("flex-1 h-0.5 mx-2 transition-colors",t.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},t.id))})}function xr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center gap-2 mb-6 overflow-x-auto",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsxs("div",{className:Pe("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",t.isActive&&"bg-primary text-primary-foreground font-medium",t.isCompleted&&"bg-primary/10 text-primary",!t.isActive&&!t.isCompleted&&"bg-muted text-muted-foreground",s&&!t.isDisabled&&"cursor-pointer hover:bg-primary/20",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:r+1}),e.jsx("span",{className:"text-sm",children:t.label}),t.isCompleted&&e.jsx(d.Check,{className:"w-4 h-4 ml-1"})]}),r<a.length-1&&e.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},t.id))})}function fr({steps:a,currentStepIndex:t,className:s}){const r=a[t],n=(t+1)/a.length*100;return e.jsxs("div",{className:Pe("mb-6 space-y-2",s),children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Etapa ",t+1," de ",a.length]}),e.jsx("span",{className:"font-medium",children:r?.label})]}),e.jsx(pr,{value:n,className:"h-2"})]})}function gr({isFirstStep:a,isLastStep:t,canGoNext:s,canGoPrevious:r,isLoading:n,onPrevious:i,onNext:o,onSubmit:l,previousButtonText:d,nextButtonText:c,submitButtonText:u}){const{t:m}=g.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:r&&!a&&e.jsx(_e,{type:"button",variant:"outline",onClick:i,disabled:n,children:d||m("previous")})}),e.jsxs("div",{className:"flex gap-2",children:[s&&!t&&e.jsx(_e,{type:"button",onClick:o,disabled:n,children:c||m("next")}),t&&e.jsx(_e,{type:"button",onClick:l,disabled:n,children:n?m("saving"):u||m("save")})]})]})}pr.displayName=ue.Root.displayName;const br=s.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),vr={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},yr=Z.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},i)=>{const o=vr[t||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Pe(br({variant:t}),a),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});yr.displayName="Alert";const jr=Z.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:Pe("mb-1 font-medium leading-none tracking-tight",a),...t}));jr.displayName="AlertTitle";const Nr=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-sm [&_p]:leading-relaxed",a),...t}));Nr.displayName="AlertDescription";const wr=a.createContext(void 0);function Cr({children:t,actions:s}){const[r,n]=a.useState({}),[i,o]=a.useState(s);return a.useEffect(()=>{o(s)},[s]),e.jsx(wr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:t})}function kr(){const e=a.useContext(wr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const Sr=(void 0).VITE_SUPABASE_URL,Pr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Tr=null;var Ir=Object.defineProperty,_r=(e,a,t)=>((e,a,t)=>a in e?Ir(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ar=new class{constructor(){_r(this,"cache",{}),_r(this,"cacheTimestamps",new Map),_r(this,"CACHE_TTL",3e5),_r(this,"loadingPromises",new Map)}isCacheValid(e){const a=this.cacheTimestamps.get(e);return!!a&&Date.now()-a<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const a=this.loadingPromises.get(e);if(a)return a;const t=this.fetchTranslations(e);this.loadingPromises.set(e,t);try{return await t}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const a=(!Tr&&Sr&&Pr&&(Tr=b.createClient(Sr,Pr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Tr),{data:t,error:s}=await a.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(s)return"42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied")||s.message?.includes("No suitable key"),{};const r={};return t?.forEach(a=>{let t;t="pt-BR"===e?a.pt:"en-US"===e?a.en||a.pt:"es-ES"===e&&a.es||a.pt,t&&(r[a.key]=t)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(a){return{}}}async upsertTranslation(e,a,t,s){const r=it(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=it(),{error:t}=await a.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(t)throw t;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Er=Object.defineProperty,Mr=(e,a,t)=>((e,a,t)=>a in e?Er(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Rr="true"===(void 0).VITE_I18N_DEBUG_MODE;o.use(new class{constructor(e=!1){Mr(this,"type","backend"),Mr(this,"isDebugMode"),Mr(this,"cache",new Map),Mr(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,a,t){if(this.cache.has(e))return void t(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{t(null,this.cache.get(e)||{})});const s=Ar.loadTranslations(e).then(a=>{if(this.isDebugMode){const t={};Object.keys(a).forEach(e=>{t[e]=`[${e} ✅]`}),this.cache.set(e,t)}else this.cache.set(e,a)}).catch(a=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,s),s.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,s){}}(Rr)).use(g.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Rr?`[${e} ❌]`:`[⚠️ ${e}]`});const Dr=new class{async getUserPreferences(e,a){if(!Xa.areAllTokensValid())return null;const t=it();try{const{data:s,error:r}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(r)return"PGRST116"===r.code?this.createDefaultPreferences(e,a):("42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied"),null);if(!s)return this.createDefaultPreferences(e,a);const n=s;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(s){return null}}async createDefaultPreferences(e,a){const t=it(),s={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:a};try{const{data:e,error:a}=await t.schema("common").from("user_preferences").insert(s).select().single();if(a)throw a;const r=e;return{locale:r.locale,timezone:r.timezone,datetimeFormat:r.datetime_format}}catch(r){throw r}}async updatePreferences(e,a,t){const s=it();try{const{error:r}=await s.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(r)throw r}catch(r){throw r}}},Fr=a.createContext(void 0),zr=({children:t})=>{const{user:s,alias:r}=$t(),[n,i]=a.useState({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[l,d]=a.useState(!0);a.useEffect(()=>{(async()=>{if(s?.id&&r)try{const e=await Dr.getUserPreferences(s.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{d(!1)}else d(!1)})()},[s?.id,r]);const c=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{locale:e}),i(a=>({...a,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[s?.id,r]),u=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[s?.id,r]),m=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[s?.id,r]);return e.jsx(Fr.Provider,{value:{...n,setLocale:c,setTimezone:u,setDatetimeFormat:m,isLoading:l},children:t})},Lr=()=>{const e=a.useContext(Fr);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Or({children:t}){const{ready:s}=g.useTranslation(),[r,n]=a.useState(!0);return a.useEffect(()=>{s&&r&&n(!1)},[s,r]),r&&!s?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(Ca,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:t})}const Ur=me.Root,qr=me.CollapsibleTrigger,$r=me.CollapsibleContent;var Br=Object.defineProperty,Wr=(e,a,t)=>((e,a,t)=>a in e?Br(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class Vr extends a.Component{constructor(e){super(e),Wr(this,"copyErrorDetails",()=>{const e=Za.getErrors().slice(0,2),a=`\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,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(a),l.toast.success("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((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if((void 0).DEV)throw e;Za.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Za.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(De,{className:"w-full max-w-2xl",children:[e.jsxs(Fe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(ze,{children:"Algo deu errado"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs(Ur,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(qr,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs($r,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(Qs,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),a.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:a.map((a,t)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(a.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),e.jsxs(_e,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(_e,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Hr=pe.Root,Gr=Z.forwardRef(({className:a,...t},s)=>e.jsx(pe.Item,{ref:s,className:Pe("border-b",a),...t}));Gr.displayName="AccordionItem";const Qr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Header,{className:"flex",children:e.jsxs(pe.Trigger,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[t,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Qr.displayName=pe.Trigger.displayName;const Kr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e.jsx("div",{className:Pe("pb-4 pt-0",a),children:t})}));Kr.displayName=pe.Content.displayName;const Xr=he.Root,Jr=he.Trigger,Yr=he.Portal,Zr=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Overlay,{className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Zr.displayName=he.Overlay.displayName;const en=Z.forwardRef(({className:a,...t},s)=>e.jsxs(Yr,{children:[e.jsx(Zr,{}),e.jsx(he.Content,{ref:s,className:Pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...t})]}));en.displayName=he.Content.displayName;const an=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",a),...t});an.displayName="AlertDialogHeader";const tn=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});tn.displayName="AlertDialogFooter";const sn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Title,{ref:s,className:Pe("text-lg font-semibold",a),...t}));sn.displayName=he.Title.displayName;const rn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));rn.displayName=he.Description.displayName;const nn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Action,{ref:s,className:Pe(Ie(),a),...t}));nn.displayName=he.Action.displayName;const on=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Cancel,{ref:s,className:Pe(Ie({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));on.displayName=he.Cancel.displayName;const ln=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Root,{ref:s,className:Pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));ln.displayName=xe.Root.displayName;const dn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Image,{ref:s,className:Pe("aspect-square h-full w-full",a),...t}));dn.displayName=xe.Image.displayName;const cn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Fallback,{ref:s,className:Pe("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));cn.displayName=xe.Fallback.displayName;const un=Z.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));un.displayName="Breadcrumb";const mn=Z.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:Pe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));mn.displayName="BreadcrumbList";const pn=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("inline-flex items-center gap-1.5",a),...t}));pn.displayName="BreadcrumbItem";const hn=Z.forwardRef(({asChild:a,className:s,...r},n)=>{const i=a?t.Slot:"a";return e.jsx(i,{ref:n,className:Pe("transition-colors hover:text-foreground",s),...r})});hn.displayName="BreadcrumbLink";const xn=Z.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Pe("font-normal text-foreground",a),...t}));xn.displayName="BreadcrumbPage";const fn=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pe("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(d.ChevronRight,{})});fn.displayName="BreadcrumbSeparator";const gn=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});gn.displayName="BreadcrumbEllipsis";const bn=s.cva("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"}}),vn=Z.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(bn({orientation:t}),a),...s}));function yn(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function jn(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Nn(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const i=n[0],o=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}function wn(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[0],n=a.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=t.valueCallback?t.valueCallback(i):i;return{value:i,rest:a.slice(r.length)}}}vn.displayName="ButtonGroup";const Cn={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"}},kn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Sn={ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:jn({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Pn={ordinalNumber:wn({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Tn={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Cn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:{date:yn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:yn({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:yn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,s)=>kn[e],localize:Sn,match:Pn,options:{weekStartsOn:0,firstWeekContainsDate:1}},In={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"}},_n={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},An={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"},En={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"},Mn={ordinalNumber:(e,a)=>Number(e)+"º",era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Rn={ordinalNumber:wn({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Dn={code:"es",formatDistance:(e,a,t)=>{let s;const r=In[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:_n,formatRelative:(e,a,t,s)=>1!==a.getHours()?En[e]:An[e],localize:Mn,match:Rn,options:{weekStartsOn:1,firstWeekContainsDate:1}},Fn={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"}},zn={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ln={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},On={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Un={ordinalNumber:wn({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},qn={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Fn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:zn,formatRelative:(e,a,t,s)=>{const r=Ln[e];return"function"==typeof r?r(a):r},localize:On,match:Un,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $n({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(A.DayPicker,{showOutsideDays:s,className:Pe("p-3 pointer-events-auto",a),locale:qn,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Pe(Ie({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Pe(Ie({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...a})=>e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}$n.displayName="Calendar";const Bn={Root:function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(De,{className:Pe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Oe,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:Pe("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:t})]})}};const Wn=({shouldScaleBackground:a=!0,...t})=>e.jsx(E.Drawer.Root,{shouldScaleBackground:a,...t});Wn.displayName="Drawer";const Vn=E.Drawer.Trigger,Hn=E.Drawer.Portal,Gn=E.Drawer.Close,Qn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80",a),...t}));Qn.displayName=E.Drawer.Overlay.displayName;const Kn=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Hn,{children:[e.jsx(Qn,{}),e.jsxs(E.Drawer.Content,{ref:r,className:Pe("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.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));Kn.displayName="DrawerContent";const Xn=({className:a,...t})=>e.jsx("div",{className:Pe("grid gap-1.5 p-4 text-center sm:text-left",a),...t});Xn.displayName="DrawerHeader";const Jn=({className:a,...t})=>e.jsx("div",{className:Pe("mt-auto flex flex-col gap-2 p-4",a),...t});Jn.displayName="DrawerFooter";const Yn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Yn.displayName=E.Drawer.Title.displayName;const Zn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Zn.displayName=E.Drawer.Description.displayName;const ei={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))]"},ai={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const ti=fe.Root,si=fe.Trigger,ri=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:t,sideOffset:s,className:Pe("z-50 w-64 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",a),...r}));ri.displayName=fe.Content.displayName;const ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Pe("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",a),...t}));ni.displayName="InputGroup";const ii=s.cva("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"}}),oi=Z.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Pe(ii({align:t}),a),...s}));oi.displayName="InputGroupAddon";const li=s.cva("",{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"}}),di=Z.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(_e,{ref:n,"data-slot":"input-group-button",variant:s,className:Pe(li({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));di.displayName="InputGroupButton";const ci=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ci.displayName="InputGroupInput";const ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(ya,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ui.displayName="InputGroupTextarea";const mi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:Pe("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));mi.displayName="H1";const pi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:Pe("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));pi.displayName="H2";const hi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));hi.displayName="H3";const xi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:Pe("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));xi.displayName="H4";const fi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("leading-7 [&:not(:first-child)]:mt-6",a),...t}));fi.displayName="P";const gi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-xl text-muted-foreground",a),...t}));gi.displayName="Lead";const bi=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-lg font-semibold",a),...t}));bi.displayName="Large";const vi=Z.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:Pe("text-sm font-medium leading-none",a),...t}));vi.displayName="Small";const yi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));yi.displayName="Muted";const ji=Z.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:Pe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));ji.displayName="InlineCode";const Ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:Pe("mt-6 border-l-2 pl-6 italic",a),...t}));Ni.displayName="Blockquote";const wi=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));wi.displayName="List";const Ci=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Root,{ref:r,className:Pe("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Ai,{})]}));Ci.displayName=ge.Root.displayName;const ki=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.List,{ref:s,className:Pe("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));ki.displayName=ge.List.displayName;const Si=ge.Item,Pi=s.cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),Ti=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Trigger,{ref:r,className:Pe(Pi(),"group",a),...s,children:[t," ",e.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Ti.displayName=ge.Trigger.displayName;const Ii=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Content,{ref:s,className:Pe("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",a),...t}));Ii.displayName=ge.Content.displayName;const _i=ge.Link,Ai=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:Pe("absolute left-0 top-full flex justify-center"),children:e.jsx(ge.Viewport,{className:Pe("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",a),ref:s,...t})}));Ai.displayName=ge.Viewport.displayName;const Ei=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Indicator,{ref:s,className:Pe("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",a),...t,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ei.displayName=ge.Indicator.displayName;const Mi=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Pe("mx-auto flex w-full justify-center",a),...t});Mi.displayName="Pagination";const Ri=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("flex flex-row items-center gap-1",a),...t}));Ri.displayName="PaginationContent";const Di=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("",a),...t}));Di.displayName="PaginationItem";const Fi=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:Pe(Ie({variant:t?"outline":"ghost",size:s}),a),...r});Fi.displayName="PaginationLink";const zi=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to previous page",size:"default",className:Pe("gap-1 pl-2.5",a),...t,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});zi.displayName="PaginationPrevious";const Li=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to next page",size:"default",className:Pe("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Li.displayName="PaginationNext";const Oi=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Oi.displayName="PaginationEllipsis";const Ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Root,{className:Pe("grid gap-2",a),...t,ref:s}));Ui.displayName=be.Root.displayName;const qi=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Item,{ref:s,className:Pe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),...t,children:e.jsx(be.Indicator,{className:"flex items-center justify-center",children:e.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));qi.displayName=be.Item.displayName;const $i=ve.Panel,Bi=ae.Root,Wi=ae.Trigger,Vi=ae.Close,Hi=ae.Portal,Gi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Gi.displayName=ae.Overlay.displayName;const Qi=s.cva("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"}}),Ki=Z.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(Hi,{children:[e.jsx(Gi,{}),e.jsxs(ae.Content,{ref:n,className:Pe(Qi({side:a}),t),...r,children:[s,e.jsxs(ae.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.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ki.displayName=ae.Content.displayName;const Xi=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Xi.displayName="SheetHeader";const Ji=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Ji.displayName="SheetBody";const Yi=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Yi.displayName="SheetFooter";const Zi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold text-foreground",a),...t}));Zi.displayName=ae.Title.displayName;const eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));eo.displayName=ae.Description.displayName;const ao="sidebar:state",to=Z.createContext(null);function so(){const e=Z.useContext(to);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const ro=Z.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=Z.useState(!1);Z.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=Z.useState(!1),[p,h]=Z.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(ao);return null!==e?"true"===e:a}return a}),x=t??p,f=Z.useCallback(e=>{const a="function"==typeof e?e(x):e;s?s(a):h(a),"undefined"!=typeof window&&localStorage.setItem(ao,String(a))},[s,x]),g=Z.useCallback(()=>d?m(e=>!e):f(e=>!e),[d,f,m]);Z.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const b=x?"expanded":"collapsed",v=Z.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,x,f,d,u,m,g]);return e.jsx(to.Provider,{value:v,children:e.jsx(ts,{delayDuration:0,children:e.jsx("div",{className:Pe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...n},ref:l,...o,children:i})})})});ro.displayName="SidebarProvider";const no=Z.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=so();return"none"===s?e.jsx("div",{className:Pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(Bi,{open:c,onOpenChange:u,...i,children:e.jsxs(Ki,{"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.jsx(Zi,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":a,children:[e.jsx("div",{className:Pe("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Pe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===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"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});no.displayName="Sidebar";const io=Z.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=so();return e.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Pe("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});io.displayName="SidebarTrigger";const oo=Z.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=so();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Pe("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",a),...t})});oo.displayName="SidebarRail";const lo=Z.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:Pe("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",a),...t}));lo.displayName="SidebarInset";const co=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-sidebar":"input",className:Pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));co.displayName="SidebarInput";const uo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Pe("flex flex-col gap-2 p-2",a),...t}));uo.displayName="SidebarHeader";const mo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Pe("flex flex-col gap-2 p-2",a),...t}));mo.displayName="SidebarFooter";const po=Z.forwardRef(({className:a,...t},s)=>e.jsx(qe,{ref:s,"data-sidebar":"separator",className:Pe("mx-2 w-auto bg-sidebar-border",a),...t}));po.displayName="SidebarSeparator";const ho=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));ho.displayName="SidebarContent";const xo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Pe("relative flex w-full min-w-0 flex-col p-2",a),...t}));xo.displayName="SidebarGroup";const fo=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Pe("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",a),...r})});fo.displayName="SidebarGroupLabel";const go=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Pe("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",a),...r})});go.displayName="SidebarGroupAction";const bo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Pe("w-full text-sm",a),...t}));bo.displayName="SidebarGroupContent";const vo=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Pe("flex w-full min-w-0 flex-col gap-1",a),...t}));vo.displayName="SidebarMenu";const yo=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Pe("group/menu-item relative",a),...t}));yo.displayName="SidebarMenuItem";const jo=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),No=Z.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?t.Slot:"button",{isMobile:u,state:m}=so(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Pe(jo({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:p}),e.jsx(ns,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):p});No.displayName="SidebarMenuButton";const wo=Z.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Pe("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",a),...n})});wo.displayName="SidebarMenuAction";const Co=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Pe("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a),...t}));Co.displayName="SidebarMenuBadge";const ko=Z.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=Z.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Pe("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});ko.displayName="SidebarMenuSkeleton";const So=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Pe("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",a),...t}));So.displayName="SidebarMenuSub";const Po=Z.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));Po.displayName="SidebarMenuSubItem";const To=Z.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Pe("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...i})});To.displayName="SidebarMenuSubButton";const Io=Z.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const i=t||s||[0];return e.jsxs(ye.Root,{ref:n,value:t,defaultValue:s,className:Pe("relative flex w-full touch-none select-none items-center",a),...r,children:[e.jsx(ye.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ye.Range,{className:"absolute h-full bg-primary"})}),i.map((a,t)=>e.jsx(ye.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"},t))]})});Io.displayName=ye.Root.displayName;const _o=je.Root,Ao=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.List,{ref:s,className:Pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));Ao.displayName=je.List.displayName;const Eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Trigger,{ref:s,className:Pe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a),...t}));Eo.displayName=je.Trigger.displayName;const Mo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Content,{ref:s,className:Pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));Mo.displayName=je.Content.displayName;const Ro=s.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Do=Z.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(Ne.Root,{ref:n,className:Pe(Ro({variant:t,size:s,className:a})),...r}));Do.displayName=Ne.Root.displayName;const Fo=Z.createContext({size:"default",variant:"default"}),zo=Z.forwardRef(({className:a,variant:t,size:s,children:r,...n},i)=>e.jsx(we.Root,{ref:i,className:Pe("flex items-center justify-center gap-1",a),...n,children:e.jsx(Fo.Provider,{value:{variant:t,size:s},children:r})}));zo.displayName=we.Root.displayName;const Lo=Z.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=Z.useContext(Fo);return e.jsx(we.Item,{ref:i,className:Pe(Ro({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Lo.displayName=we.Item.displayName;const Oo=Ce.Menu,Uo=Ce.Group,qo=Ce.Portal,$o=Ce.Sub,Bo=Ce.RadioGroup,Wo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Root,{ref:s,className:Pe("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));Wo.displayName=Ce.Root.displayName;const Vo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Trigger,{ref:s,className:Pe("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a),...t}));Vo.displayName=Ce.Trigger.displayName;const Ho=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ho.displayName=Ce.SubTrigger.displayName;const Go=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.SubContent,{ref:s,className:Pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground 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",a),...t}));Go.displayName=Ce.SubContent.displayName;const Qo=Z.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:i,align:t,alignOffset:s,sideOffset:r,className:Pe("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in 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",a),...n})}));Qo.displayName=Ce.Content.displayName;const Ko=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Pe("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",t&&"pl-8",a),...s}));Ko.displayName=Ce.Item.displayName;const Xo=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Pe("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,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Xo.displayName=Ce.CheckboxItem.displayName;const Jo=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Pe("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.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Jo.displayName=Ce.RadioItem.displayName;const Yo=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Yo.displayName=Ce.Label.displayName;const Zo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));Zo.displayName=Ce.Separator.displayName;const el=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});el.displayname="MenubarShortcut";const al={light:"",dark:".dark"},tl=Z.createContext(null);function sl(){const e=Z.useContext(tl);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const rl=Z.forwardRef(({id:a,className:t,children:s,config:r,...n},i)=>{const o=Z.useId(),l=`chart-${a||o.replace(/:/g,"")}`;return e.jsx(tl.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Pe("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",t),...n,children:[e.jsx(nl,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});rl.displayName="Chart";const nl=({id:a,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(al).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${s.map(([a,t])=>{const s=t.theme?.[e]||t.color;return s?` --color-${a}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},il=ke.Tooltip,ol=Z.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=sl(),f=Z.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=cl(x,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof o?s?.label:x[o]?.label||o;return l?e.jsx("div",{className:Pe("font-medium",d),children:l(r,t)}):r?e.jsx("div",{className:Pe("font-medium",d),children:r}):null},[o,l,t,n,d,x,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Pe("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:f,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=cl(x,a,s),o=u||a.payload?.fill||a.color;return e.jsx("div",{className:Pe("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==a?.value&&a.name?c(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Pe("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":o,"--color-border":o}}),e.jsxs("div",{className:Pe("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||a.name})]}),void 0!==a.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof a.value?a.value.toLocaleString():a.value})]})]})},a.dataKey||t)})})]})});ol.displayName="ChartTooltip";const ll=ke.Legend,dl=Z.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=sl();return s?.length?e.jsx("div",{ref:i,className:Pe("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",a),children:s.map(a=>{const s=`${n||a.dataKey||"value"}`,r=cl(o,a,s);return e.jsxs("div",{className:Pe("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:a.color}}),r?.label]},a.value)})}):null});function cl(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}dl.displayName="ChartLegend";const ul=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:Pe("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),ml=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function pl({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=g.useTranslation(),m=[];return a&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:a,variant:"default"}),s&&m.push({icon:r?d.PowerOff:d.Power,label:u(r?"deactivate":"activate"),onClick:s,variant:"default"}),o.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),t&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:t,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e.jsx(d.EllipsisVertical,{size:"compact"===c?14:16})})}),e.jsx(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,t)=>e.jsxs(gs,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},t))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((a,t)=>e.jsxs(_e,{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.jsx(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:a.label})]},t))})}function hl(e){const a=y.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const xl=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],fl=[{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"}],gl=[{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"}],bl=()=>{const{locale:a,datetimeFormat:t,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Lr(),{t:o}=g.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Globe,{className:"h-4 w-4"}),o("language")]}),e.jsxs(da,{value:a,onValueChange:r,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:xl.map(a=>e.jsxs(ga,{value:a.value,children:[a.flag," ",a.label]},a.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Clock,{className:"h-4 w-4"}),o("timezone")||"Fuso Horário"]}),e.jsxs(da,{value:s,onValueChange:i,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:gl.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Calendar,{className:"h-4 w-4"}),o("dateTimeFormat")||"Formato de Data/Hora"]}),e.jsxs(da,{value:t,onValueChange:n,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:fl.map(a=>e.jsx(ga,{value:a.value,children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{children:a.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},vl=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=$t(),[p,h]=a.useState(!1),x="true"===(void 0).VITE_SHOW_USER_PREFERENCES,f=o?.[0]||null,g=l?o?.find(e=>e.alias===l):f,b=o||[],v=r||g||f||f,y=a.useCallback(e=>{n?n(e):m(e)},[n,m]),j=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===v?.alias),s=a.filter(e=>e.alias!==v?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[b,v?.alias]);if(!c||!i)return null;const N=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),j.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",j.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[j.slice(0,3).map(a=>e.jsx(Na,{variant:a.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>y(a),children:a.name},a.alias)),j.length>3&&e.jsxs(Na,{variant:"outline",className:"text-xs",children:["+",j.length-3]})]})]})]});return"dropdown"===t?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(fs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(ms,{children:[e.jsxs(hs,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(xs,{children:j.map(a=>e.jsxs(gs,{onClick:()=>y(a),className:a.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===v?.alias&&e.jsx(Na,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),x&&e.jsx(js,{}),x&&e.jsxs(gs,{onClick:()=>h(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(gs,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]}):e.jsxs(De,{className:s,children:[e.jsx(Fe,{children:e.jsx(ze,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(N,{}),e.jsx(qe,{}),x&&e.jsxs(_e,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(_e,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]})]})}),yl=a.createContext({});function jl({children:t,config:s}){const r=a.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(yl.Provider,{value:r,children:t})}function Nl(){return a.useContext(yl)}function wl(){const e=y.useLocation(),{navigation:a}=Nl(),{t:t}=g.useTranslation();if(!a)return t("page");const s=a.find(a=>a.path===e.pathname);if(s)return s.label;const r=a.find(a=>e.pathname.startsWith(a.path+"/"));return r?.label||t("page")}function Cl(e,t){const[s,r]=a.useState(e),n=a.useRef(),i=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},t),i),[e,t,i]),[s,i]}const kl=a.memo(function({actions:t}){const s=y.useLocation(),r=wl(),{navigation:n,appName:i}=Nl(),{metadata:o,headerActions:l}=kr(),{t:c}=g.useTranslation(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:x,switchUnit:f}=$t(),b=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[v,j]=y.useSearchParams(),[N,w]=a.useState(()=>v.get("search")||""),[C,k]=Cl(N,vt.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(v);C?(e.set("search",C),e.set("page","1")):e.delete("search"),j(e)},[C,j,p]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),P=o.title||r,T=o.subtitle||S?.complementaryText||c("item_details");return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:P}),e.jsx(Na,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),T&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:c("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(_e,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{k(),w("");const e=new URLSearchParams(v);e.delete("search"),e.delete("page"),j(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:x,className:"flex-shrink-0 h-10 w-10 p-0",title:c("refresh_data"),children:e.jsx(d.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||t)&&e.jsx("div",{className:"flex items-center gap-2",children:l||t}),(void 0).VITE_WIKI_URL&&e.jsx(_e,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Se((void 0).VITE_WIKI_URL,e),title:c("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(vl,{variant:"dropdown",selectedUnit:b,onUnitChange:f})})]})]})})}),Sl=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Pl=(e={})=>{const{enabled:a=!0}=e,{alias:t}=$t();return v.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=it(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!ut.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},Tl="forlogic-sidebar-pinned",Il=()=>{try{const e=localStorage.getItem(Tl);return!!e&&JSON.parse(e)}catch{return!1}},_l=e=>{const a=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return a[e%a.length]},Al=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,El={logo:`${Al}/${wt.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Al}/${wt.isQualiex?"small-forlogic.svg":"small.svg"}`},Ml=El.logo,Rl=El.smallLogo;function Dl({appName:a,isPinned:t,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=g.useTranslation(),{data:l,isLoading:c,error:u}=Pl({enabled:n}),m=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(l,e)};return e.jsxs(uo,{className:"p-0 gap-0",children:[e.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center pl-[12px]",children:e.jsx("img",{src:El.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e.jsx("button",{onClick:s,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(t?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e.jsx(d.PanelLeft,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:e.jsx("img",{src:El.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(ls,{onOpenChange:i,children:[e.jsx(ds,{asChild:!0,children:r?e.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:a})]}),e.jsx(d.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e.jsx(d.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),e.jsx(fs,{className:r?"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50":"w-[58px] bg-popover rounded-lg shadow-lg border border-border p-2 z-50",align:r?"start":"center",children:c?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:o("loading")})]}):u?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o("error")})]}):l&&0!==l.length?e.jsx("div",{className:"space-y-2",children:l.map((a,t)=>e.jsx("div",{onClick:()=>m(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${_l(t)} transition-colors duration-200\n `,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-foreground text-sm",children:a.name}),a.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function Fl({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=a;if(!n||0===n.length)return null;const l=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],i=a.icon||o,d=s||a.disabled,c=e.jsx(_e,{onClick:a.onClick,disabled:d,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const c=e.jsx(_e,{disabled:s,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(o,{className:"h-4 w-4 shrink-0"}),i,!0)});return e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(fs,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:n.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:"cursor-pointer",children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})}function zl({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=a.useState(!1),m=a.useRef(null);a.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(o?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,o]);const p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!c)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[c,e,t,s,l,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const Ll=a.createContext(void 0);function Ol(){const e=a.useContext(Ll);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Ul({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=g.useTranslation(),{open:l,setOpen:c}=so(),u=y.useLocation(),{alias:m,user:p}=$t(),{hasOpenModal:h}=Ol(),[x,f]=a.useState(!1),[b,v]=a.useState(Il),[j,N]=a.useState(!1),w=a.useRef(!1),C=r?zl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{c(!!b||!(!j&&!x))},[b,j,x,c]);return e.jsxs(no,{collapsible:"icon",onMouseEnter:()=>{b||w.current||N(!0)},onMouseLeave:()=>{b||N(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&l?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(Dl,{appName:t?.appName||o("module_title"),isPinned:b,onPinToggle:()=>{const e=!b;v(e),(e=>{try{localStorage.setItem(Tl,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),c(!1),setTimeout(()=>{w.current=!1},300))},open:l,dropdownOpen:x,onDropdownChange:f}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(ts,{children:e.jsx(Fl,{config:t.moduleActions,isCollapsed:!l,isDisabled:h})})}),e.jsx(ho,{children:s||e.jsx(xo,{className:"p-0 mt-6",children:e.jsx(bo,{children:e.jsx(vo,{className:"space-y-2",children:e.jsx(ts,{children:t?.navigation?.map((a,t)=>{const s=({item:a,index:t})=>{const r=`${a.path}-${t}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:i}=Sl({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),l=a.permissionCheck&&!n;if(l&&"Admin"===a.label)return null;const c=i?d.Loader2:l?d.Lock:a.icon;l?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e.jsx(Ur,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(yo,{children:[e.jsx(qr,{asChild:!0,children:e.jsx(No,{size:"lg",className:"h-10",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label}),e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e.jsx($r,{children:e.jsx(So,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(yo,{children:l||i?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:e.jsx(No,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-4 w-4 "+(i?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})}),e.jsx(ns,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(No,{asChild:!0,isActive:(h=a.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(y.Link,{to:a.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:a.label})]})})},a.path);var h};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Pe("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-['']",C.isDragging&&"bg-primary/40")})]})}const ql=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=a.useMemo(()=>s||e.jsx(Ul,{config:r}),[s,r]),o=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(jl,{config:r,children:e.jsx(Cr,{children:e.jsx(ro,{defaultOpen:!1,style:o,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,e.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(kl,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})}),$l={"pt-BR":qn,"en-US":Tn,"es-ES":Dn},Bl=(e,a="pt-BR")=>{if(!e)return"";const t=i.parseISO(e);if(!i.isValid(t))return"Invalid date";const s=$l[a]||qn;return i.format(t,"PP",{locale:s})};class Wl{static async sendEmail(e){const a=it(),{data:t,error:s}=await a.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(s)throw s;return t}}const Vl=Wl;function Hl({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=g.useTranslation(),[m,p]=a.useState([]),[h,x]=a.useState(!1),[f,b]=a.useState(""),{data:v=[],isLoading:y}=Zs({enabled:t}),j=a.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),N=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},w=1===m.length,C=m.length>0;return e.jsx($e,{open:t,onOpenChange:s,children:e.jsxs(Qe,{className:"max-w-2xl",children:[e.jsx(Ke,{children:e.jsxs(Ye,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:u("search_placeholder"),value:f,onChange:e=>b(e.target.value),className:"pl-9"})]}),e.jsx(Qs,{className:"h-[400px] pr-4",children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(za,{className:"h-16 w-full"},t))}):0===j.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:j.map(a=>{const t=a.userId===l,s=c.includes(a.userId||""),r=m.includes(a.userId||"");return e.jsxs("div",{className:Pe("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>N(a.userId||""),children:[e.jsx(va,{checked:r,onCheckedChange:()=>N(a.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:a.userName}),t&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(t||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},a.userId)})})}),e.jsxs(Je,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&e.jsxs("span",{children:[m.length," selecionado(s)"]})}),w&&i&&e.jsxs(_e,{onClick:async()=>{if(i&&1===m.length){x(!0);try{await i(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(_e,{onClick:async()=>{if(o&&0!==m.length){x(!0);try{await o(m,r),p([])}finally{x(!1)}}},disabled:h,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Gl({place:t,level:s=0,manageAccessConfig:r}){const[n,i]=a.useState(!1),[o,l]=a.useState(!1),c=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Ur,{open:n,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(qr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Pe("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",t.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Na,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(pl,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx($r,{children:t.subPlaces.map(a=>e.jsx(Gl,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx(qe,{}),r&&e.jsx(Hl,{open:o,onOpenChange:l,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}var Ql=Object.defineProperty,Kl=(e,a,t)=>((e,a,t)=>a in e?Ql(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Xl=new class{constructor(){Kl(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Za.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Jl(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Yl(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Zl(){const{alias:e,isAuthenticated:a}=$t(),t=Xa.getAccessToken(),{data:s=[]}=Zs({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=it(),{data:r,error:n}=await a.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(!r||0===r.length)return[];const i={};s.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=r.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e];o.push({id:`virtual-${e}`,alias:r[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:a?.name||"[Não encontrado]",email:a?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e).length})}),Jl(o)},enabled:!!t&&!!e&&a&&s.length>0})}function ed(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function ad(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(!t.users.length)throw new Error("Selecione pelo menos um liderado");const r=t.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",a).in("id_user",r).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 t.users){if(t.id_leader&&d.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,d.id_user,t.id_leader)}const i=t.users.map(e=>({alias:a,id_user:e.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await s.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function td(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,r.id_user,t.id_leader,t.id);const{data:n,error:i}=await s.schema(e).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",a).select().single();if(i)throw i;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function sd(){const{alias:e}=$t(),a=v.useQueryClient(),t=it();return v.useMutation({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(s)throw s},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success("Líder removido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao remover líder")}})}function rd(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!a)throw new Error("Unidade não selecionada");const n=r.map(e=>e.id_user),i=await Promise.all([s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1).eq("id_leader",t),s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).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||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==t),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const y of x)await nd(s,a,e,y.id_user,t,y.id);for(const y of g){if(y.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await nd(s,a,e,y.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(x.length){const r=x.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:t}).in("id",r).eq("alias",a))}if(g.length){const r=g.map(e=>({alias:a,id_user:e.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(s.schema(e).from("leaders").insert(r))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{l.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function nd(e,a,t,s,r,n){const{data:i,error:o}=await e.schema(t).from("leaders").select("id, id_user, id_leader").eq("alias",a).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===s)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 id({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),i=a.children.length>0,o=32*a.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${o}px`},children:[i?e.jsx("button",{onClick:()=>s(a.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(d.ChevronDown,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(d.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(a)},className:"font-medium hover:text-primary hover:underline text-left",children:a.name||a.id_user||a.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),i&&n&&a.children.map(a=>e.jsx(id,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}var od=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},ld=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,i){try{var o=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&J.validateFieldsNatively({},n),{errors:{},values:t.raw?s: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:J.toNestErrors(od(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const dd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string()).min(1,"Selecione pelo menos um liderado")}),cd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string())});function ud({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=Zs(),[l,c]=a.useState(""),u=a.useRef(null),m=a.useRef(0),{t:p}=g.useTranslation(),h=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=l.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const s=t.includes(e.userId),r=t.includes(a.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),o?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ee,{placeholder:p("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(va,{id:a.userId,checked:t.includes(a.userId),onCheckedChange:()=>{return e=a.userId,u.current&&(m.current=u.current.scrollTop),void(t.includes(e)?s(t.filter(a=>a!==e)):s([...t,e]));var e}}),e.jsx(Re,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:t.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function md({leader:t,prefilledLeaderId:s,onSuccess:r}){const{t:n}=g.useTranslation(),{alias:i}=$t(),o=!!t,l=t?.id.startsWith("virtual-"),c=ad(),u=ed(),m=td(),h=rd(),x=sd(),{data:f=[]}=Zl(),{data:b=[]}=Zs(),[v,y]=a.useState(""),j=Yl(f).map(e=>e.id_user),N=o?Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],w=p.useForm({resolver:ld(o?cd:dd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?N:[]}});a.useEffect(()=>{if(t){const e=Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);w.reset({id_leader:t.id_leader||null,id_users:e})}else s?w.reset({id_leader:s,id_users:[]}):w.reset({id_leader:null,id_users:[]})},[i,t?.id,t?.id_user,t?.id_leader,s,f]);const C=c.isPending||u.isPending||m.isPending||h.isPending||x.isPending,k=w.watch("id_leader"),S=w.watch("id_users"),P=o?[t.id_user,...j.filter(e=>e!==t.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...j.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:w.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await m.mutateAsync({id:t.id,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:a})}r?.()}catch(a){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Re,{children:n("leader")}),e.jsx(Ee,{value:b.find(e=>e.userId===t.id_user)?.userName||t.name||t.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:n("superior")}),e.jsxs(da,{value:k||"none",onValueChange:e=>w.setValue("id_leader","none"===e?null:e),children:[e.jsx(ma,{children:e.jsx(ua,{placeholder:n("select_placeholder")})}),e.jsxs(xa,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ee,{placeholder:n("superior_search"),value:v,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Qs,{className:"h-[200px]",children:[e.jsx(ga,{value:"none",children:"[Nenhum]"}),b.filter(e=>{const a=o?e.userId!==t.id_user:!S.includes(e.userId),s=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return a&&s}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(a=>e.jsx(ga,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${i}`),w.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:w.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(Re,{children:[n("subordinates")," *"]}),e.jsx(ud,{value:S,onChange:e=>w.setValue("id_users",e),excludeUserIds:P,error:w.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(_e,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n(o?"updating":"saving")]}):o?S.length>0?n("update_success",{count:S.length}):n("update"):n("create_success",{count:S.length})}),o&&!k&&0===S.length&&e.jsx(_e,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(t&&window.confirm(n("remove_confirm")))try{await x.mutateAsync(t.id),r?.()}catch(e){}},className:"ml-auto",children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n("removing")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),n("remove")]})})]})]})}function pd({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx($e,{open:a,onOpenChange:t,children:e.jsxs(Qe,{className:"sm:max-w-[500px]",children:[e.jsx(Ke,{children:e.jsx(Ye,{children:n})}),e.jsx(md,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const hd="leadership-expanded-nodes",xd=(e,a)=>{try{localStorage.setItem(`${hd}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function fd(e){const[t,s]=a.useState(!1),[r,n]=a.useState(0),{t:i}=g.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,a)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0),n(0);try{const t={...c,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await o(e,t);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!d){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await d(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t,progress:r}}function gd(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function bd(e,a){const t=gd(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function vd(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function yd(e,a){const t=vd(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function jd(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Nd(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function wd(e,a){return e/a}exports.i18n=o,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return g.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return g.useTranslation}}),exports.AUTH_CONFIG=gt,exports.Accordion=Hr,exports.AccordionContent=Kr,exports.AccordionItem=Gr,exports.AccordionTrigger=Qr,exports.ActionButton=Ae,exports.ActionMenu=pl,exports.ActionMenuItems=Ls,exports.Alert=yr,exports.AlertDescription=Nr,exports.AlertDialog=Xr,exports.AlertDialogAction=nn,exports.AlertDialogCancel=on,exports.AlertDialogContent=en,exports.AlertDialogDescription=rn,exports.AlertDialogFooter=tn,exports.AlertDialogHeader=an,exports.AlertDialogOverlay=Zr,exports.AlertDialogPortal=Yr,exports.AlertDialogTitle=sn,exports.AlertDialogTrigger=Jr,exports.AlertTitle=jr,exports.AppHeader=kl,exports.AppLayout=ql,exports.AppSidebar=Ul,exports.AuthErrorInterceptor=ut,exports.AuthProvider=qt,exports.AuthService=Ot,exports.Avatar=ln,exports.AvatarFallback=cn,exports.AvatarImage=dn,exports.Badge=Na,exports.BaseForm=ar,exports.Blockquote=Ni,exports.Breadcrumb=un,exports.BreadcrumbEllipsis=gn,exports.BreadcrumbItem=pn,exports.BreadcrumbLink=hn,exports.BreadcrumbList=mn,exports.BreadcrumbPage=xn,exports.BreadcrumbSeparator=fn,exports.BulkActionBar=rr,exports.Button=_e,exports.ButtonGroup=vn,exports.CRUD_CONFIG=bt,exports.Calendar=$n,exports.CallbackPage=()=>{const{processCallback:t}=$t(),[s,r]=a.useState(null),[n,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{i(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return s?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsxs(ze,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(yr,{variant:"danger",children:e.jsx(Nr,{children:s})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_e,{onClick:o,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(_e,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ca,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=De,exports.CardContent=Oe,exports.CardDescription=Le,exports.CardFooter=Ue,exports.CardHeader=Fe,exports.CardSkeleton=Zt,exports.CardTitle=ze,exports.ChartContainer=rl,exports.ChartLegend=ll,exports.ChartLegendContent=dl,exports.ChartStyle=nl,exports.ChartTooltip=il,exports.ChartTooltipContent=ol,exports.Checkbox=va,exports.Collapsible=Ur,exports.CollapsibleContent=$r,exports.CollapsibleTrigger=qr,exports.ColorPicker=Gs,exports.Combobox=Ua,exports.Command=Ia,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(Ia,{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:a})}),exports.CommandEmpty=Ea,exports.CommandGroup=Ma,exports.CommandInput=_a,exports.CommandItem=Da,exports.CommandList=Aa,exports.CommandSeparator=Ra,exports.CommandShortcut=Fa,exports.ContextMenu=ws,exports.ContextMenuCheckboxItem=Ms,exports.ContextMenuContent=As,exports.ContextMenuGroup=ks,exports.ContextMenuItem=Es,exports.ContextMenuLabel=Ds,exports.ContextMenuPortal=Ss,exports.ContextMenuRadioGroup=Ts,exports.ContextMenuRadioItem=Rs,exports.ContextMenuSeparator=Fs,exports.ContextMenuShortcut=zs,exports.ContextMenuSub=Ps,exports.ContextMenuSubContent=_s,exports.ContextMenuSubTrigger=Is,exports.ContextMenuTrigger=Cs,exports.CoreProviders=function({children:a,queryClient:t}){const s=t??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Vr,{children:e.jsx(g.I18nextProvider,{i18n:o,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx(qt,{children:e.jsx(zr,{children:e.jsx(Or,{children:a})})})})})})},exports.CrudPageInternal=cr,exports.CrudPagination=sr,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=g.useTranslation(),l=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{type:"text",placeholder:o("search"),value:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:a},t)),n&&l&&r&&e.jsxs(_e,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(d.X,{size:14,className:"mr-1"}),o("clear_filters")]})]})},exports.CrudPrimitivePagination=tr,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:y}){const{columnWidths:j,isDragging:N,activeColumn:w,handleMouseDown:C}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:y?`${y}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:P,getRowHeight:T}=$s({rowIds:t.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),I=a.useMemo(()=>{if(b)return s.map(e=>`${j[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[s,b,j]);if(c)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((a,t)=>e.jsx(za,{className:"h-12 w-full"},t))})});if(0===t.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const _=N||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(_?"select-none":""),children:e.jsxs(Wt,{className:m,children:[e.jsx(Vt,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Qt,{children:[p&&e.jsx(Kt,{className:"w-[40px]",children:e.jsx(va,{checked:g,onCheckedChange:f,"aria-label":"Selecionar todos"})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,o=w===String(a.key);return e.jsxs(Kt,{className:`${a.className||""} relative`,style:{width:I[t]},children:[a.sortable&&i?e.jsxs("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(l=String(a.key),r!==l?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:a.header}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>C(String(a.key),e),isDragging:o})]},String(a.key));var l}),l&&e.jsx(Kt,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Ht,{children:t.map(a=>{const t=T(a.id);return a.id,e.jsxs(Qt,{onClick:()=>o?.(a),className:(o?"cursor-pointer":"")+" relative",style:t?{height:`${t}px`}:void 0,children:[p&&e.jsx(Xt,{children:e.jsx(va,{checked:h.includes(a.id),onCheckedChange:()=>x?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),l&&e.jsx(Xt,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(a)})]},a.id)})})]})})},exports.CrudTable=Ws,exports.DataList=Bn,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Pick a date",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",disabled:r,className:Pe("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),a?i.format(a,"PPP"):e.jsx("span",{children:s})]})}),e.jsx(Ta,{className:"w-auto p-0",align:"start",children:e.jsx($n,{mode:"single",selected:a,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=$e,exports.DialogBody=Xe,exports.DialogClose=Ve,exports.DialogContent=Qe,exports.DialogDescription=Ze,exports.DialogFooter=Je,exports.DialogHeader=Ke,exports.DialogOverlay=He,exports.DialogPortal=We,exports.DialogTitle=Ye,exports.DialogTrigger=Be,exports.Drawer=Wn,exports.DrawerClose=Gn,exports.DrawerContent=Kn,exports.DrawerDescription=Zn,exports.DrawerFooter=Jn,exports.DrawerHeader=Xn,exports.DrawerOverlay=Qn,exports.DrawerPortal=Hn,exports.DrawerTitle=Yn,exports.DrawerTrigger=Vn,exports.DropdownMenu=ls,exports.DropdownMenuCheckboxItem=bs,exports.DropdownMenuContent=fs,exports.DropdownMenuGroup=cs,exports.DropdownMenuItem=gs,exports.DropdownMenuLabel=ys,exports.DropdownMenuPortal=us,exports.DropdownMenuRadioGroup=ps,exports.DropdownMenuRadioItem=vs,exports.DropdownMenuSeparator=js,exports.DropdownMenuShortcut=Ns,exports.DropdownMenuSub=ms,exports.DropdownMenuSubContent=xs,exports.DropdownMenuSubTrigger=hs,exports.DropdownMenuTrigger=ds,exports.EmailService=Wl,exports.EmptyState=as,exports.EntitySelect=Ua,exports.ErrorBoundary=Vr,exports.FilterBar=dr,exports.Form=ea,exports.FormControl=ia,exports.FormDescription=oa,exports.FormField=({...a})=>e.jsx(aa.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=ra,exports.FormLabel=na,exports.FormMessage=la,exports.FormSkeleton=function({fields:a=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-4 w-24"}),e.jsx(za,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(za,{className:"h-10 w-20"}),e.jsx(za,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Pe("grid",ei[t],ai[s],r),children:a})},exports.H1=mi,exports.H2=pi,exports.H3=hi,exports.H4=xi,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(za,{className:"h-8 w-8 rounded-full"}),e.jsx(za,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(za,{className:"h-8 w-8"}),e.jsx(za,{className:"h-8 w-24"})]})]})},exports.HoverCard=ti,exports.HoverCardContent=ri,exports.HoverCardTrigger=si,exports.IconPicker=Js,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),b=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>b("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),m.imageFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:m.imageFile,size:Math.round((m.imageSize||0)/1024)})})]}),m.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"caption",children:u("caption")}),e.jsx(ya,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>b("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"alt",children:u("alt")}),e.jsx(Ee,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>b("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("alignment")}),e.jsxs(da,{value:m.alignment||"center",onValueChange:e=>b("alignment",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"left",children:u("left")}),e.jsx(ga,{value:"center",children:u("center")}),e.jsx(ga,{value:"right",children:u("right")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"width",children:u("width")}),e.jsx(Ee,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>b("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"height",children:u("height")}),e.jsx(Ee,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>b("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:m.allowDownload||!1,onChange:e=>b("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.imageUrl?r(m):l.toast.error(u("error"),{description:u("error_no_image")})},disabled:!m.imageUrl,children:u("save")})]})]})},exports.ImageRenderer=function({content:a,className:t="",style:s}){if(!a.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${t}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("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.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&e.jsxs("a",{href:a.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=ji,exports.Input=Ee,exports.InputGroup=ni,exports.InputGroupAddon=oi,exports.InputGroupButton=di,exports.InputGroupInput=ci,exports.InputGroupTextarea=ui,exports.LOGO_CONFIG=wt,exports.Label=Re,exports.Large=bi,exports.Lead=gi,exports.LeaderRow=id,exports.LeadershipDialog=pd,exports.LeadershipForm=md,exports.LeadershipPage=function(){const{alias:t}=$t(),{t:s}=g.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=Zl(),{data:l=[]}=Zs({enabled:!0}),[c,u]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${hd}-${e}`);if(a)return new Set(JSON.parse(a))}catch(i){}return new Set})(t):new Set),[m,p]=a.useState(!1),[h,x]=a.useState(),[f,b]=a.useState(null),v=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),y=new Set(v.map(e=>e.userId)),j=v.length-(r?Yl(r).filter(e=>y.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);a.useEffect(()=>{if(r&&r.length>0&&t){if(!localStorage.getItem(`${hd}-${t}`)){const e=r.map(e=>e.id),a=new Set(e);u(a),xd(t,a)}}},[r,t]);const N=e=>{u(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&xd(t,s),s})},w=e=>{x(e),b(null),p(!0)};return n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:s("loading")})]})}):i?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(_e,{onClick:()=>o(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(_e,{size:"sm",onClick:()=>{x(void 0),b(null),p(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=Yl(r).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&xd(t,a)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&xd(t,e)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[j," usuário",1!==j?"s":""," não associado",1!==j?"s":""]})]})})]})}),r&&0!==r.length?e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:r.map(a=>e.jsx(id,{leader:a,expandedIds:c,onToggleExpand:N,onEdit:w},a.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(pd,{open:m,onOpenChange:()=>{p(!1),x(void 0),b(null)},leader:h,prefilledLeaderId:f,title:h?s("edit")+" "+s("name"):f?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=wi,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:Pe("relative",s),children:[t,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ca,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Pe("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Pe("flex items-center justify-center py-8",s),children:e.jsx(Ca,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=zr,exports.LocaleSelector=bl,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(_e,{onClick:async()=>{yt()?await Ot.loginDev():Ot.loginProd()},className:"w-full",size:"lg",children:yt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Ct,exports.ManageAccessModal=Hl,exports.Menubar=Wo,exports.MenubarCheckboxItem=Xo,exports.MenubarContent=Qo,exports.MenubarGroup=Uo,exports.MenubarItem=Ko,exports.MenubarLabel=Yo,exports.MenubarMenu=Oo,exports.MenubarPortal=qo,exports.MenubarRadioGroup=Bo,exports.MenubarRadioItem=Jo,exports.MenubarSeparator=Zo,exports.MenubarShortcut=el,exports.MenubarSub=$o,exports.MenubarSubContent=Go,exports.MenubarSubTrigger=Ho,exports.MenubarTrigger=Vo,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,i]=a.useState(!1),o=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=a.useCallback(e=>{i(e)},[]),c=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(Ll.Provider,{value:u,children:t})},exports.MultiSelect=Ua,exports.Muted=yi,exports.NavigationMenu=Ci,exports.NavigationMenuContent=Ii,exports.NavigationMenuIndicator=Ei,exports.NavigationMenuItem=Si,exports.NavigationMenuLink=_i,exports.NavigationMenuList=ki,exports.NavigationMenuTrigger=Ti,exports.NavigationMenuViewport=Ai,exports.NavigationProvider=jl,exports.P=fi,exports.PageBreadcrumb=function({items:a,maxItems:t=3,className:s}){const r=a.length>t?[a[0],...a.slice(-(t-1))]:a,n=a.length>t;return e.jsx(un,{className:s,children:e.jsx(mn,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(pn,{children:[!s&&e.jsx(fn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(gn,{}),e.jsx(fn,{})]}),a.isCurrentPage?e.jsx(xn,{children:a.label}):e.jsx(hn,{href:a.href,children:a.label})]},a.label)})})})},exports.PageMetadataProvider=Cr,exports.Pagination=Mi,exports.PaginationContent=Ri,exports.PaginationEllipsis=Oi,exports.PaginationItem=Di,exports.PaginationLink=Fi,exports.PaginationNext=Li,exports.PaginationPrevious=zi,exports.PlaceCard=Gl,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){const{t:r}=g.useTranslation();return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("loading_data")})]})}):a&&0!==a.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(a=>e.jsx(Gl,{place:a,manageAccessConfig:s},a.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Sa,exports.PopoverContent=Ta,exports.PopoverTrigger=Pa,exports.Progress=pr,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=$t();if(a.useEffect(()=>{if(!s)return;const e=()=>{Xa.areAllTokensValid()||Ot.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[s]),a.useEffect(()=>{if(r)return;if(s)return;if(Xa.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const n=yt();(async()=>{n?await Ot.loginDev():Ot.loginProd()})()},[s,r]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:yt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=jt,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=_t,exports.QualiexErrorInterceptor=pt,exports.QualiexUserField=er,exports.RadioGroup=Ui,exports.RadioGroupItem=qi,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(ve.PanelResizeHandle,{className:Pe("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...s,children:a&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=$i,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(ve.PanelGroup,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),exports.RichTextEditor=({value:t,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:i="300px",showModeToggle:o=!0,showVariableHint:l=!0,className:c})=>{const[u,m]=a.useState("visual"),p=B.useEditor({extensions:[W.configure({heading:{levels:[1,2,3]}}),V,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Q.Color,K.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});Z.useEffect(()=>{p&&t!==p.getHTML()&&p.commands.setContent(t||"")},[t,p]);const h=a.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?p.chain().focus().extendMarkRange("link").setLink({href:a}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Pe("space-y-2",c),children:[o&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(_e,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(_e,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(B.EditorContent,{editor:p,className:Pe("prose prose-sm max-w-none p-4 focus:outline-none","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:i}})]}),"code"===u&&e.jsx("textarea",{value:t||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:t||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=vt,exports.ScrollArea=Qs,exports.ScrollBar=Ks,exports.Select=da,exports.SelectContent=xa,exports.SelectGroup=ca,exports.SelectItem=ga,exports.SelectLabel=fa,exports.SelectScrollDownButton=ha,exports.SelectScrollUpButton=pa,exports.SelectSearch=Ua,exports.SelectSeparator=ba,exports.SelectTrigger=ma,exports.SelectValue=ua,exports.Separator=qe,exports.Sheet=Bi,exports.SheetBody=Ji,exports.SheetClose=Vi,exports.SheetContent=Ki,exports.SheetDescription=eo,exports.SheetFooter=Yi,exports.SheetHeader=Xi,exports.SheetOverlay=Gi,exports.SheetPortal=Hi,exports.SheetTitle=Zi,exports.SheetTrigger=Wi,exports.Sidebar=no,exports.SidebarActionTrigger=Fl,exports.SidebarContent=ho,exports.SidebarFooter=mo,exports.SidebarGroup=xo,exports.SidebarGroupAction=go,exports.SidebarGroupContent=bo,exports.SidebarGroupLabel=fo,exports.SidebarHeader=Dl,exports.SidebarInput=co,exports.SidebarInset=lo,exports.SidebarMenu=vo,exports.SidebarMenuAction=wo,exports.SidebarMenuBadge=Co,exports.SidebarMenuButton=No,exports.SidebarMenuItem=yo,exports.SidebarMenuSkeleton=ko,exports.SidebarMenuSub=So,exports.SidebarMenuSubButton=To,exports.SidebarMenuSubItem=Po,exports.SidebarProvider=ro,exports.SidebarRail=oo,exports.SidebarSeparator=po,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(za,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx(za,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=io,exports.Skeleton=za,exports.Slider=Io,exports.Small=vi,exports.SonnerToaster=ka,exports.Spinner=Ca,exports.SplitButton=function({label:a,onClick:t,icon:s,actions:r=[],variant:n="default",size:i="default",disabled:o=!1,loading:l=!1,menuAlign:c="end",className:u}){const m=o||l;return r.length>0?e.jsxs("div",{className:Pe("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]}),e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:n,size:i,disabled:m,className:Pe("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[i]),"aria-label":"Mais opções",children:e.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[i]})})}),e.jsx(fs,{align:c,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:Pe("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]}):e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,className:u,children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,a]})},exports.Stack=lr,exports.Switch=Ys,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:Pe("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:a}),t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(qe,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:Pe("flex flex-col h-full",t),children:e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=Wt,exports.TableBody=Ht,exports.TableCaption=Jt,exports.TableCell=Xt,exports.TableFooter=Gt,exports.TableHead=Kt,exports.TableHeader=Vt,exports.TableResizeHandle=os,exports.TableRow=Qt,exports.TableRowActions=Os,exports.TableSkeleton=Yt,exports.Tabs=_o,exports.TabsContent=Mo,exports.TabsList=Ao,exports.TabsTrigger=Eo,exports.Textarea=ya,exports.Toaster=ka,exports.Toggle=Do,exports.ToggleGroup=zo,exports.ToggleGroupItem=Lo,exports.TokenManager=Xa,exports.TokenService=$a,exports.Tooltip=ss,exports.TooltipContent=ns,exports.TooltipProvider=ts,exports.TooltipTrigger=rs,exports.TranslationLoader=Or,exports.TruncatedCell=is,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{inputType:"url",controls:!0}),h=a.useRef(null),x=a.useRef(null),{upload:f,uploading:b}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:y}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>Nd(m.videoUrl||jd(m.embedCode)||""),[m.videoUrl,m.embedCode]),N=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("input_type")}),e.jsxs(da,{value:m.inputType||"url",onValueChange:e=>N("inputType",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"url",children:u("url")}),e.jsx(ga,{value:"upload",children:u("input_type_upload")}),e.jsx(ga,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||a.name.replace(/\.[^/.]+$/,"")};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("select_video")]})}),m.videoFile&&e.jsx("span",{className:"text-xs text-muted-foreground truncate self-center",children:u("video.fileInfo",{name:m.videoFile,size:Math.round((m.videoSize||0)/1024/1024)})})]})]}),"embed"===m.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("embed")}),e.jsx(ya,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(t),s(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("video.uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]}),m.thumbnailFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("video.thumbnailFileInfo",{name:m.thumbnailFile})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"title",children:u("title")}),e.jsx(Ee,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>N("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:m.autoplay||!1,onChange:e=>N("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"autoplay",className:"cursor-pointer",children:u("video.autoplay")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==m.controls,onChange:e=>N("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=m.videoUrl||jd(m.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===j)return e.jsxs("video",{controls:!1!==m.controls,autoPlay:m.autoplay,poster:m.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:a}),u("unsupported")]});const t="youtube"===j?bd(a,m.autoplay):yd(a,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:t,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{onClick:()=>{m.videoUrl||m.embedCode?r(m):l.toast.error(u("error"),{description:u("error_no_video")})},disabled:!(m.videoUrl||m.embedCode),children:u("save")})]})]})},exports.VideoRenderer=function({content:a,className:t="",style:s}){const r=a.videoUrl||jd(a.embedCode)||"";if(!r)return null;const n=Nd(r),{t:i}=g.useTranslation();return e.jsx(De,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Oe,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:a.title||i("video"),src:"youtube"===n?bd(r,a.autoplay):yd(r,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.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.WizardBreadcrumb=xr,exports.WizardButtons=gr,exports.WizardForm=function({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c,showProgressIndicator:u=!0,progressType:m="stepper",validateOnNext:p=!0,allowSkipSections:h=!1,previousButtonText:x,nextButtonText:f,onStepChange:g,onStepValidationFail:b,renderProgressIndicator:v,renderButtons:y,currentStepIndex:j,onCurrentStepChange:N}){const[w,C]=a.useState(0),k=j??w,S=N??C,P=a.useRef(null),[T,I]=a.useState(null),_=a.useCallback(e=>{P.current=e,I(e)},[]),A=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:E,errors:M,updateField:R,handleSubmit:D}=Vs(A,r,void 0,o);a.useEffect(()=>{o&&S(0)},[o,S]);const F=a.useCallback(()=>{const e=s[k];if(!e)return!0;const a=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),t={};let r=!0;return a.forEach(e=>{const a=E[e.name];if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(t[e.name]=`${e.label} é obrigatório`,r=!1),e.validation&&"function"==typeof e.validation){const s=e.validation(a,E);s&&(t[e.name]=s,r=!1)}}),!r&&b&&b(k,t),r},[s,k,E,b]),z=a.useCallback(()=>{if(p&&!F())return;const e=k+1;e<s.length&&(S(e),g?.(e,s[e].id))},[k,s,p,F,S,g]),L=a.useCallback(()=>{const e=k-1;e>=0&&(S(e),g?.(e,s[e].id))},[k,s,S,g]),O=a.useCallback(()=>{let e=!0;for(let a=0;a<s.length;a++){s[a].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(a=>{const t=E[a.name];a.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(e=!1)})}e&&D(n)()},[s,E,D,n]),U=a.useMemo(()=>s.map((e,a)=>({index:a,id:e.id,label:e.label||e.id,isActive:a===k,isCompleted:a<k,isDisabled:e.disabled||!1})),[s,k]),q=0===k,$=k===s.length-1,B=a.useMemo(()=>{if(!u)return null;if(v)return v(k,s.length,s);const a=h?e=>{S(e),g?.(e,s[e].id)}:void 0;switch(m){case"breadcrumb":return e.jsx(xr,{steps:U,currentStepIndex:k,onStepClick:a});case"progressbar":return e.jsx(fr,{steps:U,currentStepIndex:k});default:return e.jsx(hr,{steps:U,currentStepIndex:k,onStepClick:a})}},[u,v,m,U,k,s,h,S,g]),W=a.useMemo(()=>{const a={isFirstStep:q,isLastStep:$,canGoNext:k<s.length-1,canGoPrevious:k>0,isLoading:d,onPrevious:L,onNext:z,onSubmit:O,previousButtonText:x,nextButtonText:f,submitButtonText:l};return y?y(a):e.jsx(gr,{...a})},[q,$,k,s.length,d,L,z,O,x,f,l,y]),V=a=>{const t=(a.computedValue,E[a.name]),s=void 0!==t?t:"",r=M[a.name];switch(a.type){case"group":return e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsx(Re,{className:"text-sm font-medium",children:a.label}),e.jsx("div",{className:Pe("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=>V(e))})]},a.name);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:s,onChange:e=>R(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:s,onValueChange:e=>R(a.name,e),children:[e.jsx(ma,{className:r?"border-destructive":"",children:e.jsx(ua,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:String(a.value),children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>R(a.name,e),placeholder:a.placeholder,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":case"color-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"user-select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s,onChange:e=>R(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"custom":return a.render?e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>R(a.name,e),error:r,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name):null;default:return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:a.type||"text",value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},H=s[k];return e.jsx($e,{open:o,onOpenChange:i,children:e.jsxs(Qe,{ref:_,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e.jsx(Ye,{className:"text-white",children:t})}),B,e.jsx("div",{className:"space-y-4 py-4",children:H?.fields.map(e=>V(e))}),e.jsx("div",{className:"flex justify-between pt-4 border-t",children:W})]})})},exports.WizardProgressBar=fr,exports.WizardStepper=hr,exports.assets=El,exports.badgeVariants=ja,exports.buildHierarchy=Jl,exports.buttonGroupVariants=bn,exports.buttonVariants=Ie,exports.calculateAspectRatio=wd,exports.cn=Pe,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:i||r.onEdit};return e.jsx(cr,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=hl({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=hl,exports.createService=Mt,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=Mt({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:a,useCrudHook:(t,s)=>Bt({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=St,exports.deriveNameField=kt,exports.deriveUsernameField=Pt,exports.detectVideoProvider=Nd,exports.emailService=Vl,exports.errorService=Za,exports.extractImageFileName=function(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}},exports.extractVimeoId=vd,exports.extractYouTubeId=gd,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))},exports.flattenTree=Yl,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Bl,exports.formatDatetime=e=>{if(!e)return"";const a=i.parseISO(e);if(!i.isValid(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${a.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:mr(e),label:mr(e),...ur(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.getQualiexConfig=Nt,exports.getSupabaseClient=it,exports.handleExternalLink=Se,exports.inputGroupAddonVariants=ii,exports.inputGroupButtonVariants=li,exports.isDevEnvironment=yt,exports.isImageUrl=function(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))},exports.logoSrc=Ml,exports.navigationMenuTriggerStyle=Pi,exports.normalizeVideoUrl=function(e,a,t){switch(a||Nd(e)){case"youtube":return bd(e,t);case"vimeo":return yd(e,t);default:return e}},exports.normalizeVimeoUrl=yd,exports.normalizeYouTubeUrl=bd,exports.parseIframeSrc=jd,exports.placeService=Xl,exports.qualiexApi=ft,exports.resizeKeepingAspect=function(e,a,t,s){const r=wd(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=Tt,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=Rl,exports.toggleVariants=Ro,exports.translationService=Ar,exports.trimTextFields=Te,exports.useActiveModules=Pl,exports.useAuth=$t,exports.useBaseForm=Vs,exports.useColumnResize=qs,exports.useCreateLeaderMutation=function(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await s.schema(e).from("leaders").select("id").eq("alias",a).eq("id_user",t.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");t.id_leader&&await nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=ad,exports.useCreateSingleLeaderMutation=ed,exports.useCrud=Bt,exports.useDebounce=Cl,exports.useFormField=ta,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Ol();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a,datetimeFormat:t}=Lr();return{formatDatetime:e=>((e,a="dd/MM/yyyy HH:mm")=>{if(!e)return"";const t=i.parseISO(e);return i.isValid(t)?i.format(t,a):"Invalid date"})(e,t,a),formatDate:a=>Bl(a,e),locale:e,timezone:a,datetimeFormat:t}},exports.useLeadershipApi=Zl,exports.useLocale=Lr,exports.useMediaUpload=fd,exports.useModalState=Ol,exports.useNavigation=Nl,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=kr();a.useEffect(()=>(t(e),()=>s()),[e.title,e.subtitle,t,s])},exports.usePageMetadataContext=kr,exports.usePageTitle=wl,exports.usePermissionQuery=Sl,exports.useQualiexUsers=Zs,exports.useRemoveLeaderMutation=sd,exports.useRouteBreadcrumbs=function(){const e=y.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=$s,exports.useSidebar=so,exports.useSidebarResize=zl,exports.useSyncSubordinatesMutation=rd,exports.useUpdateLeaderMutation=td;