componentes-exagono 0.2.70 → 0.2.72

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.es.js CHANGED
@@ -19725,7 +19725,7 @@ const Q4 = {
19725
19725
  SER: { url: "/netcar/servicio/", pag: 14, tipo: "SER" },
19726
19726
  PM: { url: "/netcar/pruebademanejo/", pag: 16, tipo: "PM" }
19727
19727
  }[X];
19728
- fe && J(`${fe.url}${parseInt(String(W?.solID || "0"))}`, {
19728
+ fe && J(`${fe.url}${W?.solID}`, {
19729
19729
  replace: !0,
19730
19730
  state: {
19731
19731
  tipoSOL: fe.tipo,
package/dist/index.umd.js CHANGED
@@ -185,7 +185,7 @@ const theme2 = createTheme({ palette: {
185
185
  * @license MIT
186
186
  */function Ht(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Xr(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Ql({pathname:e="/",search:r="",hash:t=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),t&&t!=="#"&&(e+=t.charAt(0)==="#"?t:"#"+t),e}function Jl(e){let r={};if(e){let t=e.indexOf("#");t>=0&&(r.hash=e.substring(t),e=e.substring(0,t));let n=e.indexOf("?");n>=0&&(r.search=e.substring(n),e=e.substring(0,n)),e&&(r.pathname=e)}return r}function Wh(e,r,t="/"){return zA(e,r,t,!1)}function zA(e,r,t,n){let o=typeof r=="string"?Jl(r):r,a=pn(o.pathname||"/",t);if(a==null)return null;let s=Vh(e);BA(s);let i=null;for(let l=0;i==null&&l<s.length;++l){let d=QA(a);i=GA(s[l],d,n)}return i}function Vh(e,r=[],t=[],n="",o=!1){let a=(s,i,l=o,d)=>{let u={relativePath:d===void 0?s.path||"":d,caseSensitive:s.caseSensitive===!0,childrenIndex:i,route:s};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(n)&&l)return;Ht(u.relativePath.startsWith(n),`Absolute route path "${u.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(n.length)}let f=Hr([n,u.relativePath]),h=t.concat(u);s.children&&s.children.length>0&&(Ht(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Vh(s.children,r,h,f,l)),!(s.path==null&&!s.index)&&r.push({path:f,score:qA(f,s.index),routesMeta:h})};return e.forEach((s,i)=>{if(s.path===""||!s.path?.includes("?"))a(s,i);else for(let l of Hh(s.path))a(s,i,!0,l)}),r}function Hh(e){let r=e.split("/");if(r.length===0)return[];let[t,...n]=r,o=t.endsWith("?"),a=t.replace(/\?$/,"");if(n.length===0)return o?[a,""]:[a];let s=Hh(n.join("/")),i=[];return i.push(...s.map(l=>l===""?a:[a,l].join("/"))),o&&i.push(...s),i.map(l=>e.startsWith("/")&&l===""?"/":l)}function BA(e){e.sort((r,t)=>r.score!==t.score?t.score-r.score:ZA(r.routesMeta.map(n=>n.childrenIndex),t.routesMeta.map(n=>n.childrenIndex)))}var FA=/^:[\w-]+$/,UA=3,WA=2,VA=1,HA=10,YA=-2,Yh=e=>e==="*";function qA(e,r){let t=e.split("/"),n=t.length;return t.some(Yh)&&(n+=YA),r&&(n+=WA),t.filter(o=>!Yh(o)).reduce((o,a)=>o+(FA.test(a)?UA:a===""?VA:HA),n)}function ZA(e,r){return e.length===r.length&&e.slice(0,-1).every((n,o)=>n===r[o])?e[e.length-1]-r[r.length-1]:0}function GA(e,r,t=!1){let{routesMeta:n}=e,o={},a="/",s=[];for(let i=0;i<n.length;++i){let l=n[i],d=i===n.length-1,u=a==="/"?r:r.slice(a.length)||"/",f=Qs({path:l.relativePath,caseSensitive:l.caseSensitive,end:d},u),h=l.route;if(!f&&d&&t&&!n[n.length-1].route.index&&(f=Qs({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!f)return null;Object.assign(o,f.params),s.push({params:o,pathname:Hr([a,f.pathname]),pathnameBase:tk(Hr([a,f.pathnameBase])),route:h}),f.pathnameBase!=="/"&&(a=Hr([a,f.pathnameBase]))}return s}function Qs(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[t,n]=KA(e.path,e.caseSensitive,e.end),o=r.match(t);if(!o)return null;let a=o[0],s=a.replace(/(.)\/+$/,"$1"),i=o.slice(1);return{params:n.reduce((d,{paramName:u,isOptional:f},h)=>{if(u==="*"){let v=i[h]||"";s=a.slice(0,a.length-v.length).replace(/(.)\/+$/,"$1")}const g=i[h];return f&&!g?d[u]=void 0:d[u]=(g||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:s,pattern:e}}function KA(e,r=!1,t=!0){Xr(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,i,l,d,u)=>{if(n.push({paramName:i,isOptional:l!=null}),l){let f=u.charAt(d+s.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,r?void 0:"i"),n]}function QA(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Xr(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function pn(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let t=r.endsWith("/")?r.length-1:r.length,n=e.charAt(t);return n&&n!=="/"?null:e.slice(t)||"/"}var JA=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function XA(e,r="/"){let{pathname:t,search:n="",hash:o=""}=typeof e=="string"?Jl(e):e,a;return t?(t=t.replace(/\/\/+/g,"/"),t.startsWith("/")?a=qh(t.substring(1),"/"):a=qh(t,r)):a=r,{pathname:a,search:rk(n),hash:nk(o)}}function qh(e,r){let t=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?t.length>1&&t.pop():o!=="."&&t.push(o)}),t.length>1?t.join("/"):"/"}function Xl(e,r,t,n){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ek(e){return e.filter((r,t)=>t===0||r.route.path&&r.route.path.length>0)}function Zh(e){let r=ek(e);return r.map((t,n)=>n===r.length-1?t.pathname:t.pathnameBase)}function ec(e,r,t,n=!1){let o;typeof e=="string"?o=Jl(e):(o={...e},Ht(!o.pathname||!o.pathname.includes("?"),Xl("?","pathname","search",o)),Ht(!o.pathname||!o.pathname.includes("#"),Xl("#","pathname","hash",o)),Ht(!o.search||!o.search.includes("#"),Xl("#","search","hash",o)));let a=e===""||o.pathname==="",s=a?"/":o.pathname,i;if(s==null)i=t;else{let f=r.length-1;if(!n&&s.startsWith("..")){let h=s.split("/");for(;h[0]==="..";)h.shift(),f-=1;o.pathname=h.join("/")}i=f>=0?r[f]:"/"}let l=XA(o,i),d=s&&s!=="/"&&s.endsWith("/"),u=(a||s===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(d||u)&&(l.pathname+="/"),l}var Hr=e=>e.join("/").replace(/\/\/+/g,"/"),tk=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),rk=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,nk=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ok=class{constructor(e,r,t,n=!1){this.status=e,this.statusText=r||"",this.internal=n,t instanceof Error?(this.data=t.toString(),this.error=t):this.data=t}};function ak(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function sk(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Gh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kh(e,r){let t=e;if(typeof t!="string"||!JA.test(t))return{absoluteURL:void 0,isExternal:!1,to:t};let n=t,o=!1;if(Gh)try{let a=new URL(window.location.href),s=t.startsWith("//")?new URL(a.protocol+t):new URL(t),i=pn(s.pathname,r);s.origin===a.origin&&i!=null?t=i+s.search+s.hash:o=!0}catch{Xr(!1,`<Link to="${t}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:o,to:t}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Qh=["POST","PUT","PATCH","DELETE"];new Set(Qh);var ik=["GET",...Qh];new Set(ik);var to=M.createContext(null);to.displayName="DataRouter";var Js=M.createContext(null);Js.displayName="DataRouterState";var Jh=M.createContext(!1);function lk(){return M.useContext(Jh)}var Xh=M.createContext({isTransitioning:!1});Xh.displayName="ViewTransition";var ck=M.createContext(new Map);ck.displayName="Fetchers";var uk=M.createContext(null);uk.displayName="Await";var Tr=M.createContext(null);Tr.displayName="Navigation";var tc=M.createContext(null);tc.displayName="Location";var en=M.createContext({outlet:null,matches:[],isDataRoute:!1});en.displayName="Route";var rc=M.createContext(null);rc.displayName="RouteError";var e0="REACT_ROUTER_ERROR",dk="REDIRECT",fk="ROUTE_ERROR_RESPONSE";function pk(e){if(e.startsWith(`${e0}:${dk}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function hk(e){if(e.startsWith(`${e0}:${fk}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new ok(r.status,r.statusText,r.data)}catch{}}function mk(e,{relative:r}={}){Ht(Xs(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:n}=M.useContext(Tr),{hash:o,pathname:a,search:s}=oa(e,{relative:r}),i=a;return t!=="/"&&(i=a==="/"?t:Hr([t,a])),n.createHref({pathname:i,search:s,hash:o})}function Xs(){return M.useContext(tc)!=null}function tn(){return Ht(Xs(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(tc).location}var t0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function r0(e){M.useContext(Tr).static||M.useLayoutEffect(e)}function n0(){let{isDataRoute:e}=M.useContext(en);return e?kk():gk()}function gk(){Ht(Xs(),"useNavigate() may be used only in the context of a <Router> component.");let e=M.useContext(to),{basename:r,navigator:t}=M.useContext(Tr),{matches:n}=M.useContext(en),{pathname:o}=tn(),a=JSON.stringify(Zh(n)),s=M.useRef(!1);return r0(()=>{s.current=!0}),M.useCallback((l,d={})=>{if(Xr(s.current,t0),!s.current)return;if(typeof l=="number"){t.go(l);return}let u=ec(l,JSON.parse(a),o,d.relative==="path");e==null&&r!=="/"&&(u.pathname=u.pathname==="/"?r:Hr([r,u.pathname])),(d.replace?t.replace:t.push)(u,d.state,d)},[r,t,a,o,e])}M.createContext(null);function oa(e,{relative:r}={}){let{matches:t}=M.useContext(en),{pathname:n}=tn(),o=JSON.stringify(Zh(t));return M.useMemo(()=>ec(e,JSON.parse(o),n,r==="path"),[e,o,n,r])}function vk(e,r,t){Ht(Xs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=M.useContext(Tr),{matches:o}=M.useContext(en),a=o[o.length-1],s=a?a.params:{},i=a?a.pathname:"/",l=a?a.pathnameBase:"/",d=a&&a.route;{let y=d&&d.path||"";s0(i,!d||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${i}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
187
187
 
188
- Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let u=tn(),f;f=u;let h=f.pathname||"/",g=h;if(l!=="/"){let y=l.replace(/^\//,"").split("/");g="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let v=Wh(e,{pathname:g});return Xr(d||v!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Xr(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),_k(v&&v.map(y=>Object.assign({},y,{params:Object.assign({},s,y.params),pathname:Hr([l,n.encodeLocation?n.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?l:Hr([l,n.encodeLocation?n.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),o,t)}function yk(){let e=Ak(),r=ak(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:a},"ErrorBoundary")," or"," ",M.createElement("code",{style:a},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},r),t?M.createElement("pre",{style:o},t):null,s)}var bk=M.createElement(yk,null),o0=class extends M.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const t=hk(e.digest);t&&(e=t)}let r=e!==void 0?M.createElement(en.Provider,{value:this.props.routeContext},M.createElement(rc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?M.createElement(xk,{error:e},r):r}};o0.contextType=Jh;var nc=new WeakMap;function xk({children:e,error:r}){let{basename:t}=M.useContext(Tr);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let n=pk(r.digest);if(n){let o=nc.get(r);if(o)throw o;let a=Kh(n.location,t);if(Gh&&!nc.get(r))if(a.isExternal||n.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const s=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:n.replace}));throw nc.set(r,s),s}return M.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function wk({routeContext:e,match:r,children:t}){let n=M.useContext(to);return n&&n.static&&n.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=r.route.id),M.createElement(en.Provider,{value:e},t)}function _k(e,r=[],t){let n=t?.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(r.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=n?.errors;if(a!=null){let u=o.findIndex(f=>f.route.id&&a?.[f.route.id]!==void 0);Ht(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),o=o.slice(0,Math.min(o.length,u+1))}let s=!1,i=-1;if(t&&n){s=n.renderFallback;for(let u=0;u<o.length;u++){let f=o[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(i=u),f.route.id){let{loaderData:h,errors:g}=n,v=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!g||g[f.route.id]===void 0);if(f.route.lazy||v){t.isStatic&&(s=!0),i>=0?o=o.slice(0,i+1):o=[o[0]];break}}}}let l=t?.onError,d=n&&l?(u,f)=>{l(u,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:sk(n.matches),errorInfo:f})}:void 0;return o.reduceRight((u,f,h)=>{let g,v=!1,p=null,y=null;n&&(g=a&&f.route.id?a[f.route.id]:void 0,p=f.route.errorElement||bk,s&&(i<0&&h===0?(s0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,y=null):i===h&&(v=!0,y=f.route.hydrateFallbackElement||null)));let _=r.concat(o.slice(0,h+1)),S=()=>{let C;return g?C=p:v?C=y:f.route.Component?C=M.createElement(f.route.Component,null):f.route.element?C=f.route.element:C=u,M.createElement(wk,{match:f,routeContext:{outlet:u,matches:_,isDataRoute:n!=null},children:C})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?M.createElement(o0,{location:n.location,revalidation:n.revalidation,component:p,error:g,children:S(),routeContext:{outlet:null,matches:_,isDataRoute:!0},onError:d}):S()},null)}function oc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sk(e){let r=M.useContext(to);return Ht(r,oc(e)),r}function Ck(e){let r=M.useContext(Js);return Ht(r,oc(e)),r}function Ek(e){let r=M.useContext(en);return Ht(r,oc(e)),r}function ac(e){let r=Ek(e),t=r.matches[r.matches.length-1];return Ht(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function Dk(){return ac("useRouteId")}function Ak(){let e=M.useContext(rc),r=Ck("useRouteError"),t=ac("useRouteError");return e!==void 0?e:r.errors?.[t]}function kk(){let{router:e}=Sk("useNavigate"),r=ac("useNavigate"),t=M.useRef(!1);return r0(()=>{t.current=!0}),M.useCallback(async(o,a={})=>{Xr(t.current,t0),t.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:r,...a}))},[e,r])}var a0={};function s0(e,r,t){!r&&!a0[e]&&(a0[e]=!0,Xr(!1,t))}M.memo(Tk);function Tk({routes:e,future:r,state:t,isStatic:n,onError:o}){return vk(e,void 0,{state:t,isStatic:n,onError:o})}var ei="get",ti="application/x-www-form-urlencoded";function ri(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Mk(e){return ri(e)&&e.tagName.toLowerCase()==="button"}function Ik(e){return ri(e)&&e.tagName.toLowerCase()==="form"}function Ok(e){return ri(e)&&e.tagName.toLowerCase()==="input"}function Pk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function jk(e,r){return e.button===0&&(!r||r==="_self")&&!Pk(e)}var ni=null;function Rk(){if(ni===null)try{new FormData(document.createElement("form"),0),ni=!1}catch{ni=!0}return ni}var Nk=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function sc(e){return e!=null&&!Nk.has(e)?(Xr(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ti}"`),null):e}function Lk(e,r){let t,n,o,a,s;if(Ik(e)){let i=e.getAttribute("action");n=i?pn(i,r):null,t=e.getAttribute("method")||ei,o=sc(e.getAttribute("enctype"))||ti,a=new FormData(e)}else if(Mk(e)||Ok(e)&&(e.type==="submit"||e.type==="image")){let i=e.form;if(i==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||i.getAttribute("action");if(n=l?pn(l,r):null,t=e.getAttribute("formmethod")||i.getAttribute("method")||ei,o=sc(e.getAttribute("formenctype"))||sc(i.getAttribute("enctype"))||ti,a=new FormData(i,e),!Rk()){let{name:d,type:u,value:f}=e;if(u==="image"){let h=d?`${d}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else d&&a.append(d,f)}}else{if(ri(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=ei,n=null,o=ti,s=e}return a&&o==="text/plain"&&(s=a,a=void 0),{action:n,method:t.toLowerCase(),encType:o,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ic(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function i0(e,r,t,n){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return t?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${n}`:o.pathname=`${o.pathname}.${n}`:o.pathname==="/"?o.pathname=`_root.${n}`:r&&pn(o.pathname,r)==="/"?o.pathname=`${r.replace(/\/$/,"")}/_root.${n}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${n}`,o}async function $k(e,r){if(e.id in r)return r[e.id];try{let t=await import(e.module);return r[e.id]=t,t}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function zk(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Bk(e,r,t){let n=await Promise.all(e.map(async o=>{let a=r.routes[o.route.id];if(a){let s=await $k(a,t);return s.links?s.links():[]}return[]}));return Vk(n.flat(1).filter(zk).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function l0(e,r,t,n,o,a){let s=(l,d)=>t[d]?l.route.id!==t[d].route.id:!0,i=(l,d)=>t[d].pathname!==l.pathname||t[d].route.path?.endsWith("*")&&t[d].params["*"]!==l.params["*"];return a==="assets"?r.filter((l,d)=>s(l,d)||i(l,d)):a==="data"?r.filter((l,d)=>{let u=n.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,d)||i(l,d))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:t[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Fk(e,r,{includeHydrateFallback:t}={}){return Uk(e.map(n=>{let o=r.routes[n.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),t&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function Uk(e){return[...new Set(e)]}function Wk(e){let r={},t=Object.keys(e).sort();for(let n of t)r[n]=e[n];return r}function Vk(e,r){let t=new Set;return new Set(r),e.reduce((n,o)=>{let a=JSON.stringify(Wk(o));return t.has(a)||(t.add(a),n.push({key:a,link:o})),n},[])}function lc(){let e=M.useContext(to);return ic(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Hk(){let e=M.useContext(Js);return ic(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var cc=M.createContext(void 0);cc.displayName="FrameworkContext";function uc(){let e=M.useContext(cc);return ic(e,"You must render this element inside a <HydratedRouter> element"),e}function Yk(e,r){let t=M.useContext(cc),[n,o]=M.useState(!1),[a,s]=M.useState(!1),{onFocus:i,onBlur:l,onMouseEnter:d,onMouseLeave:u,onTouchStart:f}=r,h=M.useRef(null);M.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let p=_=>{_.forEach(S=>{s(S.isIntersecting)})},y=new IntersectionObserver(p,{threshold:.5});return h.current&&y.observe(h.current),()=>{y.disconnect()}}},[e]),M.useEffect(()=>{if(n){let p=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(p)}}},[n]);let g=()=>{o(!0)},v=()=>{o(!1),s(!1)};return t?e!=="intent"?[a,h,{}]:[a,h,{onFocus:aa(i,g),onBlur:aa(l,v),onMouseEnter:aa(d,g),onMouseLeave:aa(u,v),onTouchStart:aa(f,g)}]:[!1,h,{}]}function aa(e,r){return t=>{e&&e(t),t.defaultPrevented||r(t)}}function qk({page:e,...r}){let t=lk(),{router:n}=lc(),o=M.useMemo(()=>Wh(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?t?M.createElement(Gk,{page:e,matches:o,...r}):M.createElement(Kk,{page:e,matches:o,...r}):null}function Zk(e){let{manifest:r,routeModules:t}=uc(),[n,o]=M.useState([]);return M.useEffect(()=>{let a=!1;return Bk(e,r,t).then(s=>{a||o(s)}),()=>{a=!0}},[e,r,t]),n}function Gk({page:e,matches:r,...t}){let n=tn(),{future:o}=uc(),{basename:a}=lc(),s=M.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let i=i0(e,a,o.unstable_trailingSlashAwareDataRequests,"rsc"),l=!1,d=[];for(let u of r)typeof u.route.shouldRevalidate=="function"?l=!0:d.push(u.route.id);return l&&d.length>0&&i.searchParams.set("_routes",d.join(",")),[i.pathname+i.search]},[a,o.unstable_trailingSlashAwareDataRequests,e,n,r]);return M.createElement(M.Fragment,null,s.map(i=>M.createElement("link",{key:i,rel:"prefetch",as:"fetch",href:i,...t})))}function Kk({page:e,matches:r,...t}){let n=tn(),{future:o,manifest:a,routeModules:s}=uc(),{basename:i}=lc(),{loaderData:l,matches:d}=Hk(),u=M.useMemo(()=>l0(e,r,d,a,n,"data"),[e,r,d,a,n]),f=M.useMemo(()=>l0(e,r,d,a,n,"assets"),[e,r,d,a,n]),h=M.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,y=!1;if(r.forEach(S=>{let C=a.routes[S.route.id];!C||!C.hasLoader||(!u.some(E=>E.route.id===S.route.id)&&S.route.id in l&&s[S.route.id]?.shouldRevalidate||C.hasClientLoader?y=!0:p.add(S.route.id))}),p.size===0)return[];let _=i0(e,i,o.unstable_trailingSlashAwareDataRequests,"data");return y&&p.size>0&&_.searchParams.set("_routes",r.filter(S=>p.has(S.route.id)).map(S=>S.route.id).join(",")),[_.pathname+_.search]},[i,o.unstable_trailingSlashAwareDataRequests,l,n,a,u,r,e,s]),g=M.useMemo(()=>Fk(f,a),[f,a]),v=Zk(f);return M.createElement(M.Fragment,null,h.map(p=>M.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...t})),g.map(p=>M.createElement("link",{key:p,rel:"modulepreload",href:p,...t})),v.map(({key:p,link:y})=>M.createElement("link",{key:p,nonce:t.nonce,...y,crossOrigin:y.crossOrigin??t.crossOrigin})))}function Qk(...e){return r=>{e.forEach(t=>{typeof t=="function"?t(r):t!=null&&(t.current=r)})}}var Jk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jk&&(window.__reactRouterVersion="7.14.0")}catch{}var c0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,u0=M.forwardRef(function({onClick:r,discover:t="render",prefetch:n="none",relative:o,reloadDocument:a,replace:s,unstable_mask:i,state:l,target:d,to:u,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:g,...v},p){let{basename:y,navigator:_,unstable_useTransitions:S}=M.useContext(Tr),C=typeof u=="string"&&c0.test(u),E=Kh(u,y);u=E.to;let w=mk(u,{relative:o}),N=tn(),D=null;if(i){let J=ec(i,[],N.unstable_mask?N.unstable_mask.pathname:"/",!0);y!=="/"&&(J.pathname=J.pathname==="/"?y:Hr([y,J.pathname])),D=_.createHref(J)}let[k,O,I]=Yk(n,v),q=r3(u,{replace:s,unstable_mask:i,state:l,target:d,preventScrollReset:f,relative:o,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:S});function H(J){r&&r(J),J.defaultPrevented||q(J)}let W=!(E.isExternal||a),Z=M.createElement("a",{...v,...I,href:(W?D:void 0)||E.absoluteURL||w,onClick:W?H:r,ref:Qk(p,O),target:d,"data-discover":!C&&t==="render"?"true":void 0});return k&&!C?M.createElement(M.Fragment,null,Z,M.createElement(qk,{page:w})):Z});u0.displayName="Link";var Xk=M.forwardRef(function({"aria-current":r="page",caseSensitive:t=!1,className:n="",end:o=!1,style:a,to:s,viewTransition:i,children:l,...d},u){let f=oa(s,{relative:d.relative}),h=tn(),g=M.useContext(Js),{navigator:v,basename:p}=M.useContext(Tr),y=g!=null&&i3(f)&&i===!0,_=v.encodeLocation?v.encodeLocation(f).pathname:f.pathname,S=h.pathname,C=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;t||(S=S.toLowerCase(),C=C?C.toLowerCase():null,_=_.toLowerCase()),C&&p&&(C=pn(C,p)||C);const E=_!=="/"&&_.endsWith("/")?_.length-1:_.length;let w=S===_||!o&&S.startsWith(_)&&S.charAt(E)==="/",N=C!=null&&(C===_||!o&&C.startsWith(_)&&C.charAt(_.length)==="/"),D={isActive:w,isPending:N,isTransitioning:y},k=w?r:void 0,O;typeof n=="function"?O=n(D):O=[n,w?"active":null,N?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let I=typeof a=="function"?a(D):a;return M.createElement(u0,{...d,"aria-current":k,className:O,ref:u,style:I,to:s,viewTransition:i},typeof l=="function"?l(D):l)});Xk.displayName="NavLink";var e3=M.forwardRef(({discover:e="render",fetcherKey:r,navigate:t,reloadDocument:n,replace:o,state:a,method:s=ei,action:i,onSubmit:l,relative:d,preventScrollReset:u,viewTransition:f,unstable_defaultShouldRevalidate:h,...g},v)=>{let{unstable_useTransitions:p}=M.useContext(Tr),y=a3(),_=s3(i,{relative:d}),S=s.toLowerCase()==="get"?"get":"post",C=typeof i=="string"&&c0.test(i),E=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let N=w.nativeEvent.submitter,D=N?.getAttribute("formmethod")||s,k=()=>y(N||w.currentTarget,{fetcherKey:r,method:D,navigate:t,replace:o,state:a,relative:d,preventScrollReset:u,viewTransition:f,unstable_defaultShouldRevalidate:h});p&&t!==!1?M.startTransition(()=>k()):k()};return M.createElement("form",{ref:v,method:S,action:_,onSubmit:n?l:E,...g,"data-discover":!C&&e==="render"?"true":void 0})});e3.displayName="Form";function t3(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function d0(e){let r=M.useContext(to);return Ht(r,t3(e)),r}function r3(e,{target:r,replace:t,unstable_mask:n,state:o,preventScrollReset:a,relative:s,viewTransition:i,unstable_defaultShouldRevalidate:l,unstable_useTransitions:d}={}){let u=n0(),f=tn(),h=oa(e,{relative:s});return M.useCallback(g=>{if(jk(g,r)){g.preventDefault();let v=t!==void 0?t:Ql(f)===Ql(h),p=()=>u(e,{replace:v,unstable_mask:n,state:o,preventScrollReset:a,relative:s,viewTransition:i,unstable_defaultShouldRevalidate:l});d?M.startTransition(()=>p()):p()}},[f,u,h,t,n,o,r,e,a,s,i,l,d])}var n3=0,o3=()=>`__${String(++n3)}__`;function a3(){let{router:e}=d0("useSubmit"),{basename:r}=M.useContext(Tr),t=Dk(),n=e.fetch,o=e.navigate;return M.useCallback(async(a,s={})=>{let{action:i,method:l,encType:d,formData:u,body:f}=Lk(a,r);if(s.navigate===!1){let h=s.fetcherKey||o3();await n(h,t,s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:u,body:f,formMethod:s.method||l,formEncType:s.encType||d,flushSync:s.flushSync})}else await o(s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:u,body:f,formMethod:s.method||l,formEncType:s.encType||d,replace:s.replace,state:s.state,fromRouteId:t,flushSync:s.flushSync,viewTransition:s.viewTransition})},[n,o,r,t])}function s3(e,{relative:r}={}){let{basename:t}=M.useContext(Tr),n=M.useContext(en);Ht(n,"useFormAction must be used inside a RouteContext");let[o]=n.matches.slice(-1),a={...oa(e||".",{relative:r})},s=tn();if(e==null){a.search=s.search;let i=new URLSearchParams(a.search),l=i.getAll("index");if(l.some(u=>u==="")){i.delete("index"),l.filter(f=>f).forEach(f=>i.append("index",f));let u=i.toString();a.search=u?`?${u}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(a.pathname=a.pathname==="/"?t:Hr([t,a.pathname])),Ql(a)}function i3(e,{relative:r}={}){let t=M.useContext(Xh);Ht(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=d0("useViewTransitionState"),o=oa(e,{relative:r});if(!t.isTransitioning)return!1;let a=pn(t.currentLocation.pathname,n)||t.currentLocation.pathname,s=pn(t.nextLocation.pathname,n)||t.nextLocation.pathname;return Qs(o.pathname,s)!=null||Qs(o.pathname,a)!=null}const l3={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:{xs:"90%",sm:450,md:500},bgcolor:"background.paper",boxShadow:24,p:{xs:2,sm:3},borderRadius:2,maxHeight:"90vh",overflowY:"auto"},f0=["#dbe3fe","#fcebc7","#d9f1d2","#fdf5d1","#ebe3d7","#e1d6fb","#f7c7cc","#f9e7fb","#eaedf2","#d5d8dd"],c3=()=>{const e=[];for(let r=0;r<24;r++)for(let t=0;t<60;t+=15){const n=new Date;n.setHours(r,t),e.push(x.format(n,"h:mmaaaa"))}return e},p0=[],oi=c3(),hn=(e,r)=>{if(!e||!r)return null;const t=r.toLowerCase().replace(/\s/g,"").replace(/\./g,""),n=t.includes("pm"),o=t.includes("am"),a=t.replace(/[a-z]/g,""),[s,i]=a.split(":");if(!s||!i)return null;let l=parseInt(s,10);const d=parseInt(i,10);n&&l<12&&(l+=12),o&&l===12&&(l=0);const[u,f,h]=e.split("-").map(Number),g=new Date(u,f-1,h,l,d);return x.isValid(g)?g:null},u3=({isVisible:e,onClose:r,onSave:t,onDelete:n,selectedDate:o,initialEvent:a,userId:s,masNombreBD:i,disId:l,gmail:d,onReenviar:u})=>{const[f,h]=b.useState(!1),[g,v]=b.useState(!1),p=x.format(new Date,"yyyy-MM-dd"),[y,_]=b.useState(""),[S,C]=b.useState([]),[E,w]=b.useState(!1),N=Nl(),[D,k]=b.useState(""),[O,I]=b.useState(p0),[q,H]=b.useState(!1),[W,Z]=b.useState(""),[J,Y]=b.useState(!1),[z,ie]=b.useState([]),[ue,$]=b.useState(!1),X=n0(),[Se,we]=b.useState(null),_e=(V,ee)=>{console.log("client",V),we(V),Ce("client",V.nombreCliente||""),Ce("solID",null),$(!1)},[oe,le]=b.useState([]),se=MA(W,300),ge=O.filter(V=>V.tieneConflicto).length,[De,he]=b.useState(!1),[Le,L]=b.useState("COT"),{control:Ne,handleSubmit:lt,reset:Ze,formState:{errors:Ie,isValid:ot},watch:$e,setValue:Ce}=Ch({resolver:ZD(KD),defaultValues:{titulo:a?.titulo||"",fechaInicio:x.format(new Date,"yyyy-MM-dd"),horaInicio:x.format(new Date,"h:mmaaaa"),horaFin:x.format(x.addHours(new Date,1),"h:mmaaaa"),todoElDia:!1,client:a?.client||null,repetir:"No repetir",link:a?.link||"",descripcion:a?.descripcion||"",solID:a?.solID??null,invitados:[],incluirMeet:!1},mode:"onChange"}),A=$e("fechaInicio"),P=$e("fechaFin"),U=$e("todoElDia");b.useEffect(()=>{if(y.trim()===""||!s||!l||!i){C([]),Ce("solID",null),w(!1),k("");return}w(!0);const V=setTimeout(()=>{N.getClients(y,l,i,s,Le).then(ee=>{w(!1);const Ee=Array.from(new Map(ee.map(fe=>[fe.nombreCliente,fe])).values());if(console.log("uniqueClients",Ee),Ee.length>0)C(Ee),k("");else if(a?.client&&a.solID!==null){const fe=[{solID:a.solID,nombreCliente:a.client}];C(fe),k("Sin resultados")}else C([]),k("Sin resultados")}).catch(ee=>{console.error("Error al buscar clientes:",ee),w(!1)})},500);return()=>clearTimeout(V)},[y,s,l,i,Le]),b.useEffect(()=>{if(a){const V=a?.solicitudRelacionada&&a?.solicitudRelacionada[0];if(V){const ee={nombreCliente:a?.client||"",tel:V.tel||"",email:V.email||"",marca:V.marca||"",modelo:V.modelo||"",solID:Number(V.solID)};we(ee),C([ee]),Ce("client",V.nombreCliente),Ce("solID",V?.solID)}}},[a]),b.useEffect(()=>{if(A&&P){const V=new Date(A),ee=new Date(P);(V===ee||V>ee)&&Ce("fechaFin",A)}},[A,P,Ce]),b.useEffect(()=>{A&&Ce("fechaFin",A)},[A]),b.useEffect(()=>{Ce("showEndDate",f)},[f,Ce]),b.useEffect(()=>{if(console.log("initialEvent",a),a){const V=x.format(a.fechaInicio,"yyyy-MM-dd")===x.format(a.fechaFin,"yyyy-MM-dd");if(h(!V),Ce("titulo",a?.titulo),Ce("fechaInicio",x.format(a.fechaInicio,"yyyy-MM-dd")),Ce("fechaFin",x.format(a.fechaFin,"yyyy-MM-dd")),Ce("horaInicio",x.format(a.fechaInicio,"h:mmaaaa")),Ce("horaFin",x.format(a.fechaFin,"h:mmaaaa")),Ce("horaInicio2",x.format(a.fechaFin,"h:mmaaaa")),Ce("descripcion",a.descripcion),Ce("link",a.link),Ce("repetir","false"),Ce("color",a.color),Ce("todoElDia",a.todoElDia),Ce("solID",a.solID),Ce("client",a.client),a.invitados&&a.invitados.length>0){const ee=(a?.invitados||[]).map(fe=>{const je=fe.usrNombre?.trim()||"",Ue=je.split(/\s+/),yt=Ue.length>1?(Ue[0][0]+Ue[1][0]).toUpperCase():je.substring(0,2).toUpperCase();return{nombre:fe.usrNombre||"Sin nombre",correo:fe.correo||"",iniciales:yt||"--",usrID:fe.usuarioID??null,isHost:fe.esOrganizador||!1,estatus:fe.statusInvitacion,tieneConflicto:!1,disID:fe.disID}}),Ee={nombre:a?.nombreAnfitrion?a?.nombreAnfitrion:"Anfitrion",correo:"",iniciales:(a?.nombreAnfitrion?a?.nombreAnfitrion:"Anfitrion").substring(0,2).toUpperCase(),usrID:s??0,isHost:!0,estatus:"CONFIRMADA",tieneConflicto:!1};I([Ee,...ee])}else I(p0);a.solID?v(!0):v(!1)}else{const V=o||new Date,ee=new Date,Ee=new Date(V.getFullYear(),V.getMonth(),V.getDate(),ee.getHours(),ee.getMinutes()),fe=x.addHours(Ee,1);console.log("defaultEndTime",fe),Ze({titulo:"",fechaInicio:x.format(Ee,"yyyy-MM-dd"),fechaFin:x.format(fe,"yyyy-MM-dd"),horaFin:x.format(fe,"h:mmaaaa"),horaInicio:x.format(Ee,"h:mmaaaa"),horaInicio2:x.format(fe,"HH:mm"),todoElDia:!1,client:"",repetir:"No repetir",link:"",descripcion:"",color:f0[0],solID:null}),h(!1),v(!1)}},[a,e,o]);const ce=V=>({UsuarioID:V.usrID??null,Correo:V.correo,EsOrganizador:V.usrID==s,StatusInvitacion:V.estatus,disID:l??null}),ae=lt(V=>{const ee=O.map(fe=>ce(fe)),Ee={...V,invitados:ee};t(Ee,a?.eventoID),r(),Ze(),h(!1)},V=>{console.log("Errores de validación:",V)});b.useEffect(()=>{U&&(Ce("horaInicio","00:00"),Ce("horaFin","23:59"))},[U,Ce,$e]);const j=()=>{const V=$e("fechaInicio");if(V){const ee=new Date(`${V}T00:00:00`),Ee=x.addDays(ee,1);Ce("fechaFin",x.format(Ee,"yyyy-MM-dd"))}h(!0)},K=$e("fechaInicio"),de=$e("horaInicio"),Oe=$e("fechaFin"),R=$e("horaFin"),[te,xe]=b.useState(null),[qe,gt]=b.useState(null);b.useEffect(()=>{(te===null||te!==de)&&xe(de)},[de,te]),b.useEffect(()=>{(qe===null||qe!==R)&&gt(R??"")},[R,qe]);const vt=$e("todoElDia");b.useEffect(()=>{if(vt||!de||!R||!K||!Oe)return;const V=hn(K,de),ee=hn(Oe,R);if(!V||!ee||!x.isValid(V)||!x.isValid(ee))return;const Ee=x.isSameDay(V,ee),fe=Ee&&(x.isAfter(V,ee)||V.getTime()===ee.getTime()),je=x.isBefore(ee,V)&&!Ee;(fe||je)&&(Ce("horaFin",""),gt(""))},[de,K]);const Kt=b.useMemo(()=>{if(!de||!K)return oi;const V=hn(K,de);return V?oi.map(ee=>{const Ee=hn(Oe||K,ee);if(Ee&&x.isAfter(Ee,V)){const fe=(Ee.getTime()-V.getTime())/6e4,je=Math.floor(fe/60),Ue=fe%60,yt=je>0?`${je} h${Ue>0?` ${Ue} min`:""}`:`${Ue} min`;return{value:ee,label:`${ee} (${yt})`}}return ee}).filter(ee=>{const Ee=typeof ee=="string"?ee:ee.value,fe=hn(Oe||K,Ee);return fe?x.isAfter(fe,V):!1}):oi},[de,K,Oe]),er=b.useMemo(()=>oi,[]);b.useEffect(()=>{if(!a&&de&&K){const V=hn(K,de);if(V){const ee=x.addMinutes(V,15),Ee=de.toLowerCase(),fe=Ee.includes("pm")||Ee.includes("p.m."),je=Ee.includes(".");let Ue=x.format(ee,"h:mm"),yt=fe?"pm":"am";je&&(yt=fe?"p.m.":"a.m.");const ir=`${Ue}${yt}`,Or=(R||"").toLowerCase();(R!==ir||fe&&(Or.includes("am")||Or.includes("a.m.")))&&Ce("horaFin",ir,{shouldValidate:!0})}}},[de,Ce,K]);const Qt=async V=>{const ee=$e("fechaInicio"),Ee=$e("horaInicio"),fe=$e("horaFin");if(console.log("currentGuests",V),!l||!ee||!Ee||!fe||V.length===0)return;const je=await Promise.all(V.map(async Ue=>{if(Ue.isHost||!Ue.correo)return Ue;try{const yt=await N.VerificarConflicto(l,Ue.correo,ee,Ee+":00",fe+":00"),ir=Array.isArray(yt)?yt[0]:yt;if(console.log("conflictResult",yt),ir){const Or=await N.getDisponibilidadUsuario(l,Ue.correo,ee,"60");ie(Or)}return{...Ue,tieneConflicto:String(ir.tieneConflicto).toLowerCase()==="true"}}catch{return{...Ue,tieneConflicto:!1}}}));I(je)};b.useEffect(()=>{O.filter(ee=>!ee.isHost).length>0&&K&&de&&R&&Qt(O)},[K,de,R]);const re=async V=>{if(O.some(Ue=>Ue.correo===V.correo))return;Y(!0);const Ee=$e("fechaInicio"),fe=$e("horaInicio"),je=$e("horaFin");if(!l||!V.correo||!Ee||!fe||!je){I(Ue=>[...Ue,{...V,estatus:"PENDIENTE",isHost:!1,tieneConflicto:!1}]);return}try{const Ue=await N.VerificarConflicto(l,V.correo,Ee,fe+":00",je+":00"),yt=Array.isArray(Ue)?Ue[0]:Ue,ir=String(yt?.tieneConflicto).toLowerCase()==="true",Or={...V,estatus:"PENDIENTE",isHost:!1,tieneConflicto:ir};if(ir){const rn=await N.getDisponibilidadUsuario(l,V.correo,Ee,"60");ie(rn)}I(rn=>[...rn,Or])}catch(Ue){console.error("Error al verificar conflicto:",Ue),I(yt=>[...yt,{...V,tieneConflicto:!1,isHost:!1}])}},Pe=V=>{I(ee=>ee.filter(Ee=>Ee.nombre!==V))},Ae=()=>{H(!1)},ze=V=>{const fe=(V.usrNombre??"").split(" ").map(je=>je.charAt(0)).join("").toUpperCase().substring(0,2);return{nombre:V.usrNombre??"",correo:V.usrMail??"",iniciales:fe,usrID:V.usrID??0,estatus:"PENDIENTE",tieneConflicto:!1,isHost:!1}};b.useEffect(()=>{console.log("debouncedSearchText.length",se.length),se.length>2&&l?(async()=>{const ee=await N.getUsuariosInvitados(l,se),Ee=ee.map(ze).filter(fe=>fe.usrID!==s&&!O.some(je=>je.correo===fe.correo));console.log("sugerencias",ee),le(Ee)})():le([])},[se,O]);const Yt=V=>{Z(V)},tr=V=>{const{Fecha:ee,HoraInicio:Ee,HoraFin:fe}=V,je=Ue=>Ue.split(":").slice(0,2).join(":");Ce("fechaInicio",ee),Ce("fechaFin",ee),Ce("horaInicio",je(Ee)),Ce("horaFin",je(fe)),h(!1),Ae()},Ir=async()=>{const V=$e(),ee=hn(V.fechaInicio,V.horaInicio),Ee=hn(V.fechaFin||V.fechaInicio,V.horaFin);if(!ee||!Ee)return;if(!l||!d){console.error("Faltan datos requeridos (disId, userMail o calendarId)");return}he(!0);const fe={summary:V.titulo||"Sin título",description:V.descripcion||"",start:{dateTime:x.format(ee,"yyyy-MM-dd'T'HH:mm:ssxxx"),timeZone:"America/Mexico_City"},end:{dateTime:x.format(Ee,"yyyy-MM-dd'T'HH:mm:ssxxx"),timeZone:"America/Mexico_City"}};try{const je=await N.insertarEventoGoogle(l,d,!0,fe);je?.hangoutLink&&(Ce("link",je.hangoutLink),Ce("incluirMeet",!1))}catch(je){console.error("Error al generar Meet",je)}finally{he(!1)}};return c.jsx(c.Fragment,{children:c.jsx(m.Modal,{open:e,onClose:r,children:c.jsxs("form",{onSubmit:ae,children:[c.jsxs(m.Box,{sx:l3,children:[c.jsx(m.IconButton,{"aria-label":"close",onClick:r,sx:{position:"absolute",right:8,top:12},children:c.jsx(Er,{})}),c.jsx(m.Typography,{variant:"h6",mb:2,children:a?.isGoogleEvent||a?.isOutlookEvent?c.jsx(c.Fragment,{children:a?.titulo||"Evento de Google"}):!a&&"Agregar evento"}),c.jsx(m.Typography,{style:{fontSize:18,fontWeight:600},mb:2,children:a?.client&&a?.solicitudRelacionada?.[0]?c.jsxs(c.Fragment,{children:["Evento para el cliente:"," ",c.jsx(m.Link,{component:"button",variant:"inherit",type:"button",onClick:()=>{const V=a?.solicitudRelacionada?.[0];if(V&&V.tipoSol){const ee=V?.tipoSol,fe={COT:{url:"/netcar/cotizaciones/",pag:10,tipo:"COT"},SEMI:{url:"/netcar/seminuevos/",pag:12,tipo:"SEMI"},SER:{url:"/netcar/servicio/",pag:14,tipo:"SER"},PM:{url:"/netcar/pruebademanejo/",pag:16,tipo:"PM"}}[ee];fe&&X(`${fe.url}${parseInt(String(V?.solID||"0"))}`,{replace:!0,state:{tipoSOL:fe.tipo,pag:fe.pag,modulo:"Consulta"}})}},sx:{color:"#1976d2",cursor:"pointer",fontWeight:700,textDecoration:"underline",verticalAlign:"baseline",p:0,border:"none",backgroundColor:"transparent",fontSize:"14px"},children:`${a.client} / ${a.solicitudRelacionada[0].marca} ${a.solicitudRelacionada[0].modelo}`})]}):"Editar Evento"}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"titulo",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,label:"Título",fullWidth:!0,variant:"outlined",size:"small",error:!!Ie.titulo,helperText:Ie.titulo?.message,inputProps:{maxLength:100},sx:{"& .MuiInputLabel-root.Mui-focused":{color:"black"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"black"},"& .MuiInputLabel-root":{backgroundColor:"transparent !important",padding:"0 !important"}}})})})}),c.jsxs("div",{className:`row g-2 ${f?"mb-1":"mb-2"}`,children:[c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"fechaInicio",control:Ne,render:({field:V})=>c.jsx(m.TextField,{fullWidth:!0,...V,type:"date",placeholder:"Fecha de inicio",size:"small",InputLabelProps:{shrink:!0},error:!!Ie.fechaInicio,helperText:Ie.fechaInicio?.message})})}),f?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"col-md-3 d-none d-md-block"}),c.jsx("div",{className:"col-10 col-md-4",children:c.jsx(Ar,{name:"fechaFin",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,type:"date",placeholder:"Fecha de fin",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0},inputProps:{min:A||p},error:!!Ie.fechaFin,helperText:Ie.fechaFin?.message})})}),!a&&c.jsx("div",{className:"col-2 col-md-1 d-flex align-items-start",children:c.jsx(m.IconButton,{onClick:()=>h(!1),sx:{fontSize:18},children:c.jsx(QD,{})})})]}):c.jsx("div",{className:"col-md-8"})]}),f&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12 d-flex justify-content-center",children:c.jsx(Ph,{sx:{color:"#757575",my:1}})})}),c.jsxs("div",{className:"row g-2 mb-2",children:[c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"horaInicio",control:Ne,render:({field:{onChange:V,value:ee,...Ee}})=>c.jsx(m.Autocomplete,{freeSolo:!0,options:er,value:ee||"",getOptionLabel:fe=>typeof fe=="string"?fe:fe.value,onChange:(fe,je)=>{const Ue=typeof je=="string"?je:je?.value;if(Ue){const yt=Ue.split(" (")[0].trim();V(yt)}else V("")},slotProps:{paper:{sx:{width:"fit-content",minWidth:"250px"}}},onInputChange:(fe,je)=>V(je),renderInput:fe=>c.jsx(m.TextField,{...fe,...Ee,size:"small",error:!!Ie.horaInicio,helperText:Ie.horaInicio?.message,sx:{"& .MuiOutlinedInput-root":{paddingRight:"8px !important"},"& .MuiAutocomplete-endAdornment":{position:"end",right:10}},InputProps:{...fe.InputProps}}),popupIcon:c.jsx(Ll,{sx:{cursor:"pointer",color:"#5f6368"}}),forcePopupIcon:!0,sx:{"& .MuiAutocomplete-clearIndicator":{display:"none"}},disabled:vt})})}),!f&&c.jsx("div",{className:"col-1 d-flex align-items-center justify-content-center",style:{marginTop:Ie.horaInicio?"5px":"0px"},children:c.jsx(Ph,{sx:{color:"#757575"}})}),f&&c.jsx("div",{className:"col-md-3 d-none d-md-block"}),c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"horaFin",control:Ne,render:({field:{onChange:V,value:ee,...Ee}})=>c.jsx(m.Autocomplete,{freeSolo:!0,options:Kt,getOptionLabel:fe=>typeof fe=="string"?fe:fe.value,value:ee||"",onChange:(fe,je)=>{const Ue=typeof je=="string"?je:je?.value;if(Ue){const yt=Ue.split(" (")[0].trim();V(yt)}else V("")},slotProps:{paper:{sx:{width:"fit-content",minWidth:"250px"}}},renderOption:(fe,je)=>b.createElement(m.Box,{component:"li",...fe,key:typeof je=="string"?je:je.value},c.jsx(m.Typography,{children:typeof je=="string"?je:je.label})),onInputChange:(fe,je)=>V(je),renderInput:fe=>c.jsx(m.TextField,{...fe,...Ee,size:"small",error:!!Ie.horaFin,helperText:Ie.horaFin?.message,sx:{"& .MuiOutlinedInput-root":{paddingRight:"8px !important"},"& .MuiAutocomplete-endAdornment":{position:"end",right:10}},InputProps:{...fe.InputProps}}),popupIcon:c.jsx(Ll,{sx:{cursor:"pointer",color:"#5f6368"}}),forcePopupIcon:!0,sx:{"& .MuiAutocomplete-clearIndicator":{display:"none"}},disabled:vt})})}),!f&&c.jsx("div",{className:"col-12 col-md-2 d-flex align-items-center",children:c.jsx(Ar,{name:"todoElDia",control:Ne,render:({field:V})=>c.jsx(m.FormControlLabel,{control:c.jsx(m.Checkbox,{checked:V.value,onChange:ee=>V.onChange(ee.target.checked)}),label:c.jsx("label",{style:{fontSize:"0.7rem",fontWeight:"normal"},children:"Todo el día"}),sx:{whiteSpace:"nowrap"}})})})]}),(!a?.isGoogleEvent||a?.isOutlookEvent)&&!f&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsxs(m.Button,{onClick:j,size:"small",sx:{textTransform:"none",fontSize:16},children:[c.jsx(eA,{}),"  Agregar fecha final"]})})}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"link",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,placeholder:" Agregar enlace de reunión",fullWidth:!0,variant:"outlined",size:"small",error:!!Ie.link,helperText:Ie.link?.message,InputProps:{startAdornment:c.jsx("img",{src:JD,width:20,style:{alignSelf:"flex-start",marginRight:"8px",marginTop:"8px"}})}})})})}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"descripcion",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,placeholder:" Agregar descripción aquí...",fullWidth:!0,multiline:!0,rows:3,inputProps:{maxLength:500},variant:"outlined",size:"small",InputProps:{startAdornment:c.jsx("img",{src:tA,width:20,style:{alignSelf:"flex-start",marginRight:"8px"}})}})})})}),a?.solicitudRelacionada===null&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(wA,{onSelectGuest:re,availableSuggestions:oe,onInputTextChange:Yt})})}),(J||ge>0)&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(TA,{guests:O,conflictCount:ge,onViewSuggestions:()=>H(!0),onDeleteGuest:Pe})})}),a?.invitados&&a?.invitados?.length>0&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(m.Box,{children:c.jsx(fA,{guests:O,onReenviar:u,esOrganizador:a?.esOrganizador})})})}),c.jsx(yA,{open:q,handleClose:Ae,suggestions:z,onSelectSlot:tr})]}),c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",mt:1,mb:1,px:0},children:[c.jsx(m.Box,{sx:{minWidth:40,display:"flex",justifyContent:"flex-start"},children:c.jsx("img",{src:"https://fonts.gstatic.com/s/i/productlogos/meet_2020q4/v1/web-512dp/logo_meet_2020q4_color_2x_web_512dp.png",alt:"Meet",style:{width:22,height:22}})}),c.jsx(m.Box,{sx:{flex:1},children:!$e("link")&&!$e("incluirMeet")?c.jsx(m.Button,{fullWidth:!0,disabled:De||!l||!d,onClick:Ir,sx:{justifyContent:"flex-start",textTransform:"none",bgcolor:"#f1f3f4",color:"#3c4043","&:hover":{bgcolor:"#e8eaed",boxShadow:"none"},borderRadius:"4px",fontWeight:400,fontSize:"14px",py:1,px:2,border:"none",boxShadow:"none"},children:De?c.jsxs(c.Fragment,{children:[c.jsx(m.CircularProgress,{size:18,sx:{mr:1.5,color:"#5f6368"}}),c.jsx(m.Typography,{variant:"body2",sx:{fontSize:"14px",color:"#5f6368"},children:"Generando enlace..."})]}):"Añadir videoconferencia de Google Meet"}):c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#f1f3f4",p:"6px 12px",borderRadius:"4px",border:"1px solid #dadce0"},children:[c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:[c.jsx(m.Typography,{variant:"body2",sx:{color:"#1a73e8",fontWeight:500,cursor:$e("link")?"pointer":"default",textDecoration:"none","&:hover":{textDecoration:$e("link")?"underline":"none"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},onClick:()=>$e("link")&&window.open($e("link"),"_blank"),children:$e("link")?$e("link"):"Se añadirá Google Meet al guardar"}),c.jsx(m.Typography,{variant:"caption",sx:{color:"#70757a"},children:"Google Meet"})]}),c.jsx(m.IconButton,{size:"small",onClick:()=>{Ce("incluirMeet",!1),Ce("link","")},sx:{color:"#5f6368"},children:c.jsx(Er,{sx:{fontSize:18}})})]})})]}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap"},children:[c.jsx(XD,{}),f0.map(V=>c.jsx(Ar,{name:"color",control:Ne,render:({field:ee})=>c.jsx(m.IconButton,{onClick:()=>ee.onChange(V),sx:{width:24,height:24,borderRadius:"50%",bgcolor:V,border:ee.value===V?"2px solid":"none",borderColor:ee.value===V?"primary.main":"transparent"}})},V))]})})}),c.jsx("div",{className:"row",children:c.jsxs("div",{className:"col-12 d-flex gap-2",style:{width:"100%",marginTop:"20px"},children:[a&&!a?.isGoogleEvent&&!a?.isOutlookEvent&&c.jsx(m.Button,{onClick:n,variant:"outlined",startIcon:c.jsx("img",{src:Ih,width:15}),hidden:a?a?.esOrganizador!=!0:!1,sx:{flex:1,textTransform:"none",backgroundColor:"#FFF5F5",color:"#d32f2f",borderColor:"red",borderRadius:"8px",fontWeight:700,fontSize:"14px",padding:"8px 0","&:hover":{backgroundColor:"#FEE2E2",borderColor:"red"}},children:"Eliminar"}),c.jsx(m.Button,{onClick:r,variant:"outlined",sx:{flex:1,textTransform:"none",fontWeight:700,fontSize:"14px",borderRadius:"8px",color:"#1976D2",borderColor:"#1976D2","&:hover":{backgroundColor:"rgba(25, 118, 210, 0.04)",borderColor:"#115293"}},children:"Cancelar"}),c.jsx(m.Button,{onClick:ae,variant:"contained",disabled:!ot,hidden:a?a?.esOrganizador!=!0:!1,sx:{flex:1,textTransform:"none",fontWeight:700,fontSize:"14px",borderRadius:"8px",backgroundColor:"#1976D2",boxShadow:"none","&:hover":{backgroundColor:"#115293",boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"}},children:"Guardar"})]})})]}),c.jsx($A,{open:ue,onClose:()=>$(!1),clientOptions:S,isClientsLoading:E,setClientSearchTerm:_,onSelectClient:_e,setFiltroPadre:L})]})})})},d3={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:450,bgcolor:"background.paper",boxShadow:24,p:2,borderRadius:2,maxHeight:"80vh",overflowY:"auto"},f3=({isOpen:e,onClose:r,events:t,date:n,onEventClick:o})=>{if(!n)return null;const a=i=>{o(i),r()},s=i=>i.isGoogleEvent?{label:"G",borderColor:"#4285F4"}:i.isOutlookEvent?{label:"O",borderColor:"#0078d9"}:{label:"-",borderColor:"#CCC"};return c.jsx(m.Modal,{open:e,onClose:r,children:c.jsxs(m.Box,{sx:d3,children:[c.jsxs(m.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},children:[c.jsxs(m.Typography,{sx:{fontSize:"18px",fontWeight:"bold"},component:"h2",children:["Eventos del"," ",n.toLocaleDateString("es-ES",{weekday:"long",day:"numeric",month:"long"})]}),c.jsx(m.IconButton,{onClick:r,size:"small",children:c.jsx(Er,{})})]}),c.jsx(m.Divider,{}),c.jsx(m.List,{sx:{mt:1},children:t.map(i=>{const l=s(i);return c.jsx(m.ListItem,{disablePadding:!0,sx:{mb:1},children:c.jsx(m.ListItemButton,{onClick:()=>a(i),sx:{py:1,borderRadius:"4px",backgroundColor:"rgba(0,0,0,0.02)",borderLeft:`5px solid ${l?.borderColor}`,"&:hover":{backgroundColor:"rgba(0,0,0,0.04)"}},children:c.jsxs(m.Box,{sx:{flexGrow:1},children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[c.jsx(m.Typography,{sx:{fontSize:"10px",fontWeight:"bold",px:.5,borderRadius:"3px",backgroundColor:l?.borderColor,color:"white",textTransform:"uppercase"},children:l?.label}),c.jsx(m.Typography,{sx:{fontSize:"14px",fontWeight:600,lineHeight:1.2,color:"#333"},children:i.titulo})]}),c.jsx(m.Typography,{sx:{fontSize:"12px",color:"#666"},children:i.todoElDia?"Todo el día":`${x.format(i.fechaInicio,"hh:mm aa").toLowerCase()} - ${x.format(i.fechaFin,"hh:mm aa").toLowerCase()}`})]})})},i.eventoID)})})]})})};var sa={},h0;function p3(){if(h0)return sa;h0=1;var e=st();Object.defineProperty(sa,"__esModule",{value:!0}),sa.default=void 0;var r=e(pt()),t=ut();return sa.default=(0,r.default)((0,t.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error"),sa}var h3=p3();const m3=at(h3);var ia={},m0;function g3(){if(m0)return ia;m0=1;var e=st();Object.defineProperty(ia,"__esModule",{value:!0}),ia.default=void 0;var r=e(pt()),t=ut();return ia.default=(0,r.default)((0,t.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),ia}var v3=g3();const y3=at(v3),b3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23fff'%20d='M19.378%204.405a1.813%201.813%200%201%201%202.565%202.565L9.571%2019.342a1.813%201.813%200%200%201-2.565%200l-4.949-4.949a1.814%201.814%200%200%201%202.428-2.69l.137.126%203.666%203.666z'/%3e%3c/svg%3e",x3="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAALVBMVEVHcEzfEBfjCxzkChvkChvkChzkCxvlChv////96uv60dT1o6ryho/mGyvkCxypwAsrAAAACHRSTlMAECtdiKDJ5DEbuTIAAAHoSURBVHjatdlbjsMgDAVQ87JJKHf/y51pf9CIp+vJ/SzSkUloAZc2cSEkFgEAYU7RO/o+zkdBF07hO9QnwSzJq4uLgmUkGDgzGTrORHrGcZLXlmcvMkKZaJxuH/YLTwB9ZCo6AUyivb4m7uuziwxDeLtezKsnwJiwfCH2x5hgDi8mbJ+0APaI6wo0Ju4KrIBqQNyqwFqufL3qYOD1O1DqqkQZeVd+567dwJ3fuUai0Cceg5Scm9h5v3lhED9fgzk3ceTlC4Ok+YxzLzbvk+lrCRjl6sTmzSuEn80Yr9yJzZs+Q6Tp72C9/4jdRwXDCJEDTsQzD3DkcSaeeQgUcSZuvAYmnIlnHhIxVqLWAxNjKSo9CAl0YsEGBFRiwSYEhdh5dvCuBrB5GlH3UvaikOw8ncjbha0UeffV04qJwplX7jMxUjjzUM9ET+7Mw6HoiOTIOxR5ehYunXe8SfndNlpwvo2G2XWidl4nYhQ3PYpczVMfRfxqoy9QHZbWx7nm9eK9OM5RnB84h8VPTqJA6G55toj5WtYX+K8lypMXH2KYkx64PD55vbVfwJ9pEZgfo70tYm/c2FtLds/eTHu23WdvSG7jk2a6zzV17aRER4oEUXDm1r0kT18lJB5o5n8sErN8JOEUtv9U/ACrTv/qOzhclQAAAABJRU5ErkJggg==",dc=b.forwardRef(({id:e,message:r,variant:t},n)=>{const{closeSnackbar:o}=ba.useSnackbar(),a={success:{color:"#fff",icon:c.jsx("img",{width:25,src:b3,style:{borderRadius:"50%",backgroundColor:"#4caf50",color:"white",fontSize:"12px",padding:3}})},error:{color:"#f44336",icon:c.jsx(m3,{sx:{color:"#f44336"}})},info:{color:"#2196f3",icon:c.jsx(y3,{sx:{color:"#2196f3"}})},delete:{color:"#fff",icon:c.jsx("img",{src:Ih,width:25,style:{borderRadius:"50%",backgroundColor:"#ffdfd4",color:"red",fontSize:"16px",padding:3}})},rechazar:{color:"#fff",icon:c.jsx("img",{src:x3,width:30,style:{borderRadius:"50%",color:"red",fontSize:"16px",padding:3}})}},s=a[t]||a.info;return c.jsx(ba.SnackbarContent,{ref:n,children:c.jsxs(m.Box,{sx:{backgroundColor:"white",color:"#333",padding:"8px 16px",borderRadius:"8px",boxShadow:"0 3px 10px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",width:{xs:"90%",sm:"auto"},minWidth:"300px",borderLeft:`5px solid ${s.color}`},children:[c.jsx(m.Box,{sx:{mr:1.5},children:s.icon}),c.jsx(m.Typography,{variant:"body2",sx:{flexGrow:1},children:r}),c.jsx(m.IconButton,{size:"small",onClick:()=>o(e),children:c.jsx(Er,{fontSize:"small"})})]})})}),g0=b.createContext(void 0),w3=({children:e})=>{const[r,t]=b.useState([]),[n,o]=b.useState([]),[a,s]=b.useState(!1);return c.jsx(g0.Provider,{value:{googleEvents:r,setGoogleEvents:t,outlookEvents:n,setOutlookEvents:o,isLoadingGoogleEvents:a,setIsLoadingGoogleEvents:s},children:e})},_3=()=>{const e=b.useContext(g0);if(e===void 0)throw new Error("useEvents must be used within an EventsProvider");return e},S3=(e,r,t)=>{const n=(s,i)=>i?new Date(i):s?new Date(s.replace(/-/g,"/")):new Date,o=n(e.start.date,e.start.dateTime);let a=n(e.end.date,e.end.dateTime);return e.end.date&&!e.end.dateTime&&a.setDate(a.getDate()-1),{eventoID:Math.abs(C3(e.id)),titulo:e.summary||"(Sin título)",descripcion:e.description,fechaInicio:o,fechaFin:a,todoElDia:!!(e.start.date&&!e.start.dateTime),color:"#4285F4C",hasVideoCall:!!e.conferenceData,link:e.htmlLink,repetir:void 0,solID:null,disID:r,client:null,usrID:t,solicitudRelacionada:[],isGoogleEvent:!0}};function C3(e){let r=0;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);r=(r<<5)-r+n,r|=0}return r}function E3(e){let r=0;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);r=(r<<5)-r+n,r|=0}return r}const D3=(e,r,t)=>{const n=new Date(e.start.dateTime);let o=new Date(e.end.dateTime);return e.isAllDay&&o.setDate(o.getDate()-1),{eventoID:Math.abs(E3(e.id)),titulo:e?.summary||"(Sin título)",descripcion:e.body?.content||"",fechaInicio:n,fechaFin:o,todoElDia:e.isAllDay,color:"#0078D4",hasVideoCall:!!e.onlineMeetingUrl,link:e.webLink,repetir:void 0,solID:null,disID:r,client:null,usrID:t,solicitudRelacionada:[],isGoogleEvent:!1,isOutlookEvent:!0}},v0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='49'%20fill='none'%3e%3cpath%20fill='%23E40B1C'%20d='M34.559%2048.077c-7.413%200-13.44-6.039-13.44-13.44s6.027-13.44%2013.44-13.44%2013.44%206.027%2013.44%2013.44c0%207.414-6.027%2013.44-13.44%2013.44'/%3e%3cpath%20fill='%23fff'%20d='M39.827%2029.346c.583.583.605%201.505.05%202.06l-3.218%203.219%203.219%203.218c.555.556.532%201.48-.051%202.062-.584.583-1.506.605-2.062.05l-3.218-3.218-3.218%203.218c-.556.555-1.478.533-2.061-.05s-.606-1.506-.05-2.062l3.217-3.218-3.218-3.218c-.555-.555-.533-1.478.05-2.061.583-.584%201.507-.606%202.063-.05l3.217%203.217%203.218-3.218c.556-.555%201.478-.533%202.062.05'/%3e%3cpath%20fill='%23404756'%20d='M30.367.078c1.112%200%202.001.868%202.001%201.954v1.195h.979c4.913%200%208.892%203.887%208.892%208.686v9.237a15.4%2015.4%200%200%200-4.424-1.691v-1.312H4.468V33.63c0%202.389%202%204.343%204.446%204.343H19.4a15.4%2015.4%200%200%200%201.676%204.343H8.892C3.979%2042.317%200%2038.43%200%2033.631V11.913c0-4.8%203.979-8.686%208.892-8.686h1V2.032c0-1.086.89-1.954%202.002-1.954s2%20.868%202%201.954v1.195h14.473V2.032c0-1.085.889-1.954%202-1.954'/%3e%3c/svg%3e",A3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23fff'%20d='M20.36%204.14H16c0-1.65-1.35-3-3-3h-2c-1.65%200-3%201.35-3%203H3.64c-.55%200-1%20.45-1%201s.45%201%201%201h1.04l.84%2013.91a3%203%200%200%200%202.99%202.82h6.98c1.58%200%202.9-1.24%203-2.82l.84-13.91h1.04c.55%200%201-.45%201-1s-.45-1-1-1zm-9.36-1h2c.55%200%201%20.45%201%201h-4c0-.55.45-1%201-1m-.39%2014.9c0%20.55-.45%201-1%201s-1-.45-1-1V9.99c0-.55.45-1%201-1s1%20.45%201%201zm4.78%200c0%20.55-.45%201-1%201s-1-.45-1-1V9.99c0-.55.45-1%201-1s1%20.45%201%201z'/%3e%3c/svg%3e",k3=({open:e,onClose:r,onConfirm:t,title:n,description:o,icon:a,confirmText:s,confirmColor:i="#d32f2f",loading:l=!1})=>c.jsxs(m.Dialog,{open:e,onClose:r,PaperProps:{sx:{borderRadius:"15px",p:1,maxWidth:"400px"}},children:[c.jsx(m.Box,{sx:{display:"flex",justifyContent:"flex-end"},children:c.jsx(m.IconButton,{onClick:r,size:"small",children:c.jsx(Er,{fontSize:"small"})})}),c.jsxs(m.DialogContent,{sx:{textAlign:"center",pt:0},children:[c.jsx(m.Box,{sx:{mb:2,display:"flex",justifyContent:"center"},children:a}),c.jsx(m.Typography,{variant:"h6",sx:{fontWeight:"bold",mb:2},children:n}),c.jsx(m.Typography,{variant:"body2",sx:{color:"#555",mb:4,px:2},children:o}),c.jsxs(m.Box,{sx:{display:"flex",gap:2,justifyContent:"center",mb:2},children:[c.jsx(m.Button,{variant:"outlined",onClick:r,sx:{textTransform:"none",borderRadius:"8px",px:4,borderColor:"#1976D2",color:"#1976D2"},children:"Regresar"}),c.jsxs(m.Button,{variant:"contained",onClick:t,disabled:l,sx:{textTransform:"none",borderRadius:"8px",px:4,bgcolor:i,"&:hover":{bgcolor:"#b71c1c"}},children:[s=="Eliminar"&&c.jsx("img",{src:A3,width:15,style:{marginRight:6,marginBottom:2}}),l?"Procesando...":s]})]})]})]}),ai=(e,r)=>{if(!e||!r)return null;const t=r.toLowerCase().replace(/\s/g,"").replace(/\./g,""),n=t.includes("pm"),o=t.includes("am"),a=t.replace(/[a-z]/g,""),[s,i]=a.split(":");if(!s||!i)return null;let l=parseInt(s,10);const d=parseInt(i,10);n&&l<12&&(l+=12),o&&l===12&&(l=0);const[u,f,h]=e.split("-").map(Number),g=new Date(u,f-1,h,l,d);return x.isValid(g)?g:null},T3=({userId:e,leads30Days:r,leads90Days:t,disId:n,masNombreBD:o,usrNombre:a})=>{const[s,i]=b.useState(new Date),[l,d]=b.useState([]),[u,f]=b.useState(!1),[h,g]=b.useState(null),[v,p]=b.useState(null),[y,_]=b.useState([]),{enqueueSnackbar:S}=ba.useSnackbar(),C=Nl(),E=Ts(),w=Sl(),[N,D]=b.useState(!1),[k,O]=b.useState([]),[I,q]=b.useState(null),{session:H,sessionoutlook:W}=cl(),{googleEvents:Z,setGoogleEvents:J,outlookEvents:Y,setOutlookEvents:z}=_3(),[ie,ue]=b.useState([]),[$,X]=b.useState([]),[Se,we]=b.useState([]),[_e,oe]=b.useState(!1),[le,se]=b.useState([]),[ge,De]=b.useState(),he=(re,Pe)=>{O(re),q(Pe),D(!0)},Le=async()=>{if(e===void 0||n===void 0)return;const re=await C.getNotificacionesXUsuario(e,n);a?localStorage.setItem("nombreAnfitrion",a):localStorage.setItem("nombreAnfitrion","Anfitrion"),se(re)};b.useEffect(()=>{const re=new Date,Pe=x.startOfDay(re),Ae=x.endOfDay(x.addDays(Pe,6)),ze={start:Pe,end:Ae},Yt=l.filter(tr=>{const Ir={start:tr.fechaInicio,end:tr.fechaFin};return ef(Ir,ze)}).sort((tr,Ir)=>tr.fechaInicio.getTime()-Ir.fechaInicio.getTime());_(Yt)},[l]),b.useEffect(()=>{const re=async()=>{try{if(e&&n){const Ae=await C.getEventsByUser(e,n);Le(),d(Ae)}}catch(Ae){console.log("Error al cargar eventos locales:",Ae)}};re();const Pe=setInterval(re,4e3);return()=>clearInterval(Pe)},[e]),b.useEffect(()=>{if(!n||!e)return;const re=[...l];if(Z.length>0&&H?.userEmail){const Pe=Z.map(Ae=>S3(Ae,n,e));re.push(...Pe)}if(Y.length>0&&W?.userEmail){const Pe=Y.map(Ae=>D3(Ae,n,e));re.push(...Pe)}ue(re)},[l,Z,Y,n,e,H?.userEmail,W?.userEmail]);const L=async re=>{try{if(re?.isGoogleEvent||re.isOutlookEvent)g(re),f(!0);else{const Pe=await C.getEventById(re.eventoID);g(Pe),f(!0)}}catch(Pe){console.error(Pe)}},Ne=()=>{f(!1),g(null)},lt=async(re,Pe)=>{let Ae,ze;if(re.todoElDia)Ae=ai(re.fechaInicio,re.horaInicio),ze=ai(re.fechaInicio,re.horaFin);else{Ae=ai(re.fechaInicio,re.horaInicio);const V=re.fechaFin||re.fechaInicio;ze=ai(V,re.horaFin)}if(!Ae||!ze){console.error("No se pudieron procesar las fechas. Revisa el formato de hora:",{inicio:re.horaInicio,fin:re.horaFin});return}const Yt=x.format(Ae,"yyyy-MM-dd HH:mm:ss.SSS"),tr=x.format(ze,"yyyy-MM-dd HH:mm:ss.SSS");if(Pe){const V={...re,eventoID:Pe,fechaInicio:Yt,fechaFin:tr,solID:re.solID??null,disID:n??null,client:re.client,invitados:re.invitados.map(ee=>({usrNombre:ee.nombre||ee.usrNombre,Correo:ee.correo||ee.Correo,EsOrganizador:ee.isHost||ee.EsOrganizador,StatusInvitacion:ee.StatusInvitacion,UsuarioID:ee.usrID||ee.UsuarioID,disID:ee.disID||n}))};try{const ee=await C.updateEvent(V);var Ir=l.map(Ee=>Ee.eventoID===ee.eventoID?ee:Ee);d(Ir),S("El evento se ha actualizado correctamente.",{variant:"success"}),Ne()}catch{S("Error al actualizar Evento",{variant:"error"})}}else{const V={...re,fechaInicio:Yt,fechaFin:tr,todoElDia:re.todoElDia,solID:re.solID??null,disID:n??null,client:re.client,invitados:re.invitados.map(ee=>({usrNombre:ee.nombre||ee.usrNombre,Correo:ee.correo||ee.Correo,EsOrganizador:ee.isHost||ee.EsOrganizador,StatusInvitacion:ee.StatusInvitacion,UsuarioID:ee.usrID||ee.UsuarioID,disID:ee.disID||n}))};try{const ee=await C.createEvent(V,e);d(Ee=>[...Ee,ee]),S("El evento se ha creado con éxito",{variant:"success"}),Ne()}catch{S("Error al guardar Evento",{variant:"error"})}}if(e&&n){const V=await C.getEventsByUser(e,n);d(V)}},Ze=()=>{i(re=>new Date(re.getFullYear(),re.getMonth()-1,1))},Ie=()=>{i(re=>new Date(re.getFullYear(),re.getMonth()+1,1))},ot=()=>{vt("ELIMINAR")},$e=()=>{vt("RECHAZAR")},Ce=()=>{p(new Date),f(!0)},A=re=>{re&&i(re)},P=re=>{p(re),f(!0),g(null)},U=async()=>{if(h)try{await C.deleteEvent(h.eventoID),d(l.filter(re=>re.eventoID!==h.eventoID)),S("El evento se ha eliminado de tu calendario",{content:(re,Pe)=>c.jsx(dc,{id:re,message:String(Pe),variant:"delete"})})}catch{S("Error al eliminar Evento",{variant:"error"})}finally{Ne(),Kt()}},ce=async()=>{if(!(!H?.userEmail||!n)){oe(!0);try{const Pe=(await E.getGoogleCalendars(H.userEmail,n)).map(ze=>({...ze,selected:!0}));X(Pe);const Ae=Pe.map(ze=>ze.id);de(Ae)}catch(re){console.error("Error Google Cals:",re)}finally{oe(!1)}}},ae=async re=>{const Pe=$.map(ze=>ze.id===re?{...ze,selected:!ze.selected}:ze);X(Pe);const Ae=Pe.filter(ze=>ze.selected).map(ze=>ze.id);de(Ae)},j=async()=>{if(!(!W?.userEmail||!n)){oe(!0);try{const Pe=(await w.getOutlookCalendars(W.userEmail,n)).map(ze=>({...ze,selected:!0}));we(Pe);const Ae=Pe.map(ze=>ze.id);Oe(Ae)}catch(re){console.error("Error Outlook Cals:",re)}finally{oe(!1)}}},K=async re=>{const Pe=Se.map(ze=>ze.id===re?{...ze,selected:!ze.selected}:ze);we(Pe);const Ae=Pe.filter(ze=>ze.selected).map(ze=>ze.id);Oe(Ae)};b.useEffect(()=>{ce()},[H?.userEmail,n]),b.useEffect(()=>{j()},[W?.userEmail,n]);const de=async re=>{if(!H?.userEmail||!n)return;const Pe=re||$.filter(Ae=>Ae.selected).map(Ae=>Ae.id);try{const Ae={disID:n,year:s.getFullYear(),month:s.getMonth()+1,usrMail:H.userEmail,calendarIds:Pe},ze=await E.getGoogleEventsByMonth(Ae);J(ze)}catch(Ae){console.error("Error al obtener eventos de Google:",Ae)}},Oe=async re=>{if(!W?.userEmail||!n)return;const Pe=re||Se.filter(Ae=>Ae.selected).map(Ae=>Ae.id);try{const Ae={disID:n,year:s.getFullYear(),month:s.getMonth()+1,usrMail:W.userEmail,calendarIds:Pe},ze=await w.getOutlookEventsByMonth(Ae);z(ze)}catch(Ae){console.error("Error al obtener eventos de Outlook:",Ae)}};if(n===void 0||e===void 0)return c.jsx("div",{children:"Cargando configuración de usuario..."});const R=async(re,Pe)=>{await C.UpdateStatusEvento(re.evento.eventoID,e,Pe)&&(await C.MarcarLeido(re.notificacionID,e),S(re?.evento?.titulo+" fue agregado a tu calendario",{variant:"success"}))},te=async()=>{ge&&C.UpdateStatusEvento(ge.evento.eventoID,e,"RECHAZADA")&&(await C.MarcarLeido(ge.notificacionID,e),await C.MarcarLeido(ge.notificacionID,e),S("Haz rechazado la Invitación a "+ge?.evento?.titulo,{content:(Pe,Ae)=>c.jsx(dc,{id:Pe,message:String(Ae),variant:"rechazar"})}),Kt())},xe=async(re,Pe)=>{try{if(!e)return;De(re),Pe=="RECHAZADA"?($e(),console.log("noti",re)):R(re,Pe)}catch{S("Error al procesar la invitación",{variant:"error"})}},qe=async re=>{try{if(!h)return;await C.ReenviarNotificacion(h?.eventoID,re),S("Invitación enviada con éxito",{variant:"success"})}catch(Pe){console.error("Error al conectar con la API",Pe)}},[gt,vt]=b.useState(null),Kt=()=>vt(null),er={RECHAZAR:{title:"Rechazar invitación",confirmText:"Rechazar evento",description:c.jsxs(c.Fragment,{children:["Estás a punto de declinar la invitación de ",c.jsx("strong",{children:ge?.evento?.nombreAnfitrion})," a ",c.jsx("strong",{children:ge?.evento?.titulo})]}),icon:c.jsx("img",{src:v0}),action:()=>ge&&te()},ELIMINAR:{title:"Eliminar evento",confirmText:"Eliminar",description:"¿De verdad deseas eliminar este evento? Esta acción no se puede deshacer.",icon:c.jsx("img",{src:v0}),action:()=>U()},DESVINCULAR:{title:"Desvincular Outlook",confirmText:"Desvincular",description:"Si desvinculas tu cuenta, perderás acceso a todos los eventos sincronizados.",icon:"",action:()=>U}},Qt=gt?er[gt]:null;return c.jsxs("div",{id:"Agenda",style:{height:"100%",width:"100%"},children:[c.jsx(Ry,{header:c.jsx(eb,{currentDate:s,onPrevMonth:Ze,onNextMonth:Ie,onAddEvent:Ce,onDateChange:A}),sidebar:c.jsx(Qw,{onEventClick:L,upcomingEvents:y,leads30Days:r,leads90Days:t,disID:n,usrID:e,onAddEvent:Ce,googleCalendars:$,outlookCalendars:Se,isLoadingCalendars:_e,onToggleGoogle:ae,onToggleOutlook:K,notifications:le,unreadCount:le?.filter(re=>!re.leida).length,onAceppInvitacion:xe}),mainContent:c.jsx(d_,{onSeeMoreClick:he,currentDate:s,events:ie,onDayClick:P,onEventClick:L})}),u&&c.jsx(u3,{isVisible:u,onClose:Ne,onSave:lt,onDelete:ot,selectedDate:v,initialEvent:h,userId:e,masNombreBD:o,disId:n,gmail:"llopez@exagono.net",onReenviar:qe}),c.jsx(f3,{isOpen:N,onClose:()=>D(!1),events:k,date:I,onEventClick:L}),Qt&&c.jsx(k3,{open:!!gt,onClose:Kt,onConfirm:()=>{Qt.action()},title:Qt.title,description:Qt.description,icon:Qt.icon,confirmText:Qt.confirmText})]})},M3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20fill='%23070c10'%20d='M18.575%203.172A10.829%2010.829%200%200%200%201.564%2016.284l-.028-.051L0%2021.843l5.739-1.506a10.7%2010.7%200%200%200%205.173%201.318%2010.83%2010.83%200%200%200%207.663-18.483m-7.658%2016.655a8.94%208.94%200%200%201-4.62-1.277l.041.023-.329-.194-3.405.894.908-3.321-.214-.34a8.9%208.9%200%200%201-1.376-4.782%209%209%200%201%201%209%209Zm4.935-6.736c-.27-.135-1.6-.789-1.848-.88s-.429-.135-.61.136-.7.879-.856%201.06-.316.2-.586.068a7.5%207.5%200%200%201-2.183-1.349l.007.007a8.2%208.2%200%200%201-1.483-1.842l-.02-.038c-.157-.27-.017-.417.118-.551s.271-.316.406-.473a1.9%201.9%200%200%200%20.267-.44v-.012a.5.5%200%200%200%20.05-.216.5.5%200%200%200-.074-.26c-.068-.135-.609-1.467-.834-2.009s-.444-.455-.609-.464-.338-.009-.519-.009a.99.99%200%200%200-.72.337%203.03%203.03%200%200%200-.947%202.2v.058a5.27%205.27%200%200%200%201.114%202.815v-.011a12.16%2012.16%200%200%200%204.553%204.053l.068.031a14%2014%200%200%200%201.434.539l.109.03a3.6%203.6%200%200%200%201.077.161%203.7%203.7%200%200%200%20.648-.057h-.023a2.8%202.8%200%200%200%201.819-1.274l.007-.012a2.2%202.2%200%200%200%20.19-.9%202.3%202.3%200%200%200-.034-.395v.014c-.067-.113-.248-.18-.519-.316Z'/%3e%3c/svg%3e",I3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='25.085'%20height='18.5'%3e%3cdefs%3e%3cclipPath%20id='a'%3e%3cpath%20fill='none'%20d='M0%200h25.085v18.5H0z'%20data-name='Rectángulo%204598'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23a)'%20data-name='Grupo%207946'%3e%3cpath%20d='M23.12%205.809V3.226a3.2%203.2%200%200%200-.068-.656l-3.141%202.21a7.8%207.8%200%200%201%203.209%201.032'%20data-name='Trazado%2013329'/%3e%3cpath%20d='M11.847%209.791c-.1.009-.2.023-.308.023a3.78%203.78%200%200%201-2.18-.688L.067%202.58A3.2%203.2%200%200%200%200%203.227V13.98a3.23%203.23%200%200%200%203.226%203.226h9.611a7.86%207.86%200%200%201-.99-7.414'%20data-name='Trazado%2013330'/%3e%3cpath%20d='M12.478%207.369%2021.92.737A3.2%203.2%200%200%200%2019.894%200H3.226a3.2%203.2%200%200%200-2.031.74l9.4%206.628a1.64%201.64%200%200%200%201.881%200'%20data-name='Trazado%2013331'/%3e%3cpath%20d='M23.356%208.407a5.914%205.914%200%201%200%200%208.364%205.92%205.92%200%200%200%200-8.364m-1.833%204.842a.54.54%200%200%201-1.081%200v-1.164l-2.513%202.516a.54.54%200%200%201-.765-.763l2.515-2.515h-1.167a.54.54%200%201%201%200-1.081h2.471a.54.54%200%200%201%20.54.54Z'%20data-name='Trazado%2013332'/%3e%3c/g%3e%3c/svg%3e";function fc(e,r,t){return e.accessor?e.accessor(r,t):e.field?r?.[e.field]:r?.[e?.key||""]}function O3(e,r){const t=e??"",n=r??"";return t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():typeof t=="number"&&typeof n=="number"?t-n:typeof t=="boolean"&&typeof n=="boolean"?Number(t)-Number(n):String(t).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}function pc(e,r,t=!0){return typeof e=="function"?e(r):e??t}function P3(e){return e.replace(/[^\d]/g,"")}function j3(e,r){return r}var la={},y0;function R3(){if(y0)return la;y0=1;var e=st();Object.defineProperty(la,"__esModule",{value:!0}),la.default=void 0;var r=e(pt()),t=ut();return la.default=(0,r.default)((0,t.jsx)("path",{d:"M4.25 5.61C6.27 8.2 10 13 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-6s3.72-4.8 5.74-7.39c.51-.66.04-1.61-.79-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAlt"),la}var N3=R3();const L3=at(N3);var ca={},b0;function $3(){if(b0)return ca;b0=1;var e=st();Object.defineProperty(ca,"__esModule",{value:!0}),ca.default=void 0;var r=e(pt()),t=ut();return ca.default=(0,r.default)((0,t.jsx)("path",{d:"M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"SearchRounded"),ca}var z3=$3();const B3=at(z3);var ua={},x0;function F3(){if(x0)return ua;x0=1;var e=st();Object.defineProperty(ua,"__esModule",{value:!0}),ua.default=void 0;var r=e(pt()),t=ut();return ua.default=(0,r.default)((0,t.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown"),ua}var U3=F3();const W3=at(U3);var da={},w0;function V3(){if(w0)return da;w0=1;var e=st();Object.defineProperty(da,"__esModule",{value:!0}),da.default=void 0;var r=e(pt()),t=ut();return da.default=(0,r.default)((0,t.jsx)("path",{d:"M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp"),da}var H3=V3();const Y3=at(H3);function _0(e){return e==="right"?"end":e==="center"?"center":"start"}function S0(e){const r=e.filter(t=>!t.width).length||1;return e.map(t=>typeof t.width=="number"?`${t.width}px`:typeof t.width=="string"?t.width:`minmax(0, ${1/r}fr)`).join(" ")}const q3=1060,hc=(e,r)=>e.metrics.find(t=>String(t.label).toLowerCase()===r.toLowerCase())?.value??"";function Z3({sections:e,detailColumns:r,summaryWidths:t=["1fr",120,120,150],minWidth:n=q3,getDetailColumns:o,onRowClick:a}){function l(u){if(typeof u=="number")return u;if(!u)return 0;const f=/^(\d+)\s*px$/.exec(u.trim());return f?Number(f[1]):/fr$/i.test(u)?160:0}function d(u){const f=u.reduce((v,p)=>v+l(p.width),0),h=Math.max(u.length-1,0)*16;return f+h+32}return c.jsx(m.Box,{sx:{border:"1px solid rgba(0,0,0,0.15)",overflow:"hidden",bgcolor:"background.paper",width:"100%"},children:c.jsxs(m.Box,{children:[c.jsx(m.Box,{sx:{display:"grid",gridTemplateColumns:t.map(u=>typeof u=="number"?`${u}px`:u).join(" "),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:"#1E5BCE",color:"#fff",boxSizing:"border-box"},children:["Tipo","En Proceso","Finalizadas","Último seg."].map(u=>c.jsx(m.Typography,{sx:{fontSize:13,fontWeight:800},children:u},u))}),e.map((u,f)=>{const[h,g]=M.useState(!!u.initiallyOpen),v=f%2===1,p=o?o(u):r,y=Math.max(n,d(p));return c.jsxs(m.Box,{children:[c.jsxs(m.Box,{sx:{display:"grid",gridTemplateColumns:t.map(_=>typeof _=="number"?`${_}px`:_).join(" "),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:v?"rgba(30,91,206,0.06)":"background.paper",borderTop:"1px solid rgba(0,0,0,0.08)","&:hover":{bgcolor:"rgba(30,91,206,0.12)"},boxSizing:"border-box",cursor:"pointer"},onClick:()=>g(_=>!_),children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[c.jsx(m.IconButton,{size:"small",disableRipple:!0,children:h?c.jsx(Y3,{}):c.jsx(W3,{})}),c.jsx(m.Typography,{sx:{fontWeight:700,fontSize:14,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(u.title),children:u.title})]}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"En Proceso")}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"Finalizadas")}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"Último seg.")})]}),c.jsx(m.Collapse,{in:h,unmountOnExit:!0,children:c.jsxs(m.Box,{sx:{overflowX:"auto","&::-webkit-scrollbar":{height:"5px"}},children:[c.jsx(m.Box,{sx:{minWidth:y,display:"grid",gridTemplateColumns:S0(p),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:"rgba(30,91,206,0.18)",color:"#1a1a1a",borderTop:"1px solid rgba(0,0,0,0.12)",boxSizing:"border-box"},children:p.map(_=>c.jsx(m.Typography,{sx:{justifySelf:_0(_.align),textAlign:_.align??"left",fontSize:12.5,fontWeight:800,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.header},_.key))}),(u.rows??[]).map((_,S)=>c.jsx(m.Box,{sx:{minWidth:y,display:"grid",gridTemplateColumns:S0(p),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:S%2===0?"background.paper":"rgba(30,91,206,0.06)",borderTop:"1px solid rgba(0,0,0,0.06)","&:hover":{bgcolor:"rgba(30,91,206,0.12)"},boxSizing:"border-box",cursor:"pointer"},onClick:()=>a?.(_,u),children:p.map((C,E)=>{const w=C.accessor?C.accessor(_,S):C.field?_[C.field]:null;return c.jsx(m.Box,{sx:{justifySelf:_0(C.align),textAlign:C.align??"left",minWidth:0,overflow:"hidden",maxWidth:"100%"},children:typeof w=="string"||typeof w=="number"?c.jsx(m.Typography,{sx:{fontSize:13,fontWeight:/^(estatus|seg|avance|nivel|asesor|fecha)$/i.test(C.key)?700:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(w),children:w}):w},C.key??E)})},_.id??S))]})})]},u.id)})]})})}var fa={},C0;function G3(){if(C0)return fa;C0=1;var e=st();Object.defineProperty(fa,"__esModule",{value:!0}),fa.default=void 0;var r=e(pt()),t=ut();return fa.default=(0,r.default)((0,t.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m3.3 14.71L11 12.41V7h2v4.59l3.71 3.71z"}),"AccessTimeFilled"),fa}var K3=G3();const Q3=at(K3),J3=e=>e?new Date(e).toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}).replace(".",""):"",X3=e=>{const r=`${e?.Nombre??""} ${e?.Apellido??""}`.trim();return r||(e?.IdAsesor?e?.Correo??"Usuario":"Sin asesor asignado")},e5=e=>{const r=(e||"").split(" ").filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():(e?.[0]??"?").toUpperCase()};var pa={},E0;function t5(){if(E0)return pa;E0=1;var e=st();Object.defineProperty(pa,"__esModule",{value:!0}),pa.default=void 0;var r=e(pt()),t=ut();return pa.default=(0,r.default)((0,t.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Create"),pa}var r5=t5();const n5=at(r5),mc=({current:e=0,total:r=0,color:t="#4caf50"})=>c.jsx("div",{style:{display:"flex",gap:"1px",width:"100%",height:"100%",justifyContent:"center",overflow:"hidden",minWidth:0},children:Array.from({length:r}).map((n,o)=>c.jsx("div",{style:{width:"7px",height:"7px",borderRadius:"2px",backgroundColor:o<e?t:"#e0e0e0",display:"flex"}},o))});var ha={},D0;function o5(){if(D0)return ha;D0=1;var e=st();Object.defineProperty(ha,"__esModule",{value:!0}),ha.default=void 0;var r=e(pt()),t=ut();return ha.default=(0,r.default)((0,t.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),ha}var a5=o5();const A0=at(a5);var ma={},k0;function s5(){if(k0)return ma;k0=1;var e=st();Object.defineProperty(ma,"__esModule",{value:!0}),ma.default=void 0;var r=e(pt()),t=ut();return ma.default=(0,r.default)((0,t.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack"),ma}var i5=s5();const l5=at(i5),c5=e=>{const r=String(e??"").toLowerCase().trim();return r==="muy interesado"?{bg:"#E53935",color:"#FFFFFF"}:r==="interesado"?{bg:"#FB8C00",color:"#FFFFFF"}:r==="venta definitiva"?{bg:"#2E7D32",color:"#FFFFFF"}:r==="no sé"||r==="no se"?{bg:"#9E9E9E",color:"#FFFFFF"}:r==="algo interesado"?{bg:"#FFEB3B",color:"#000000"}:{bg:"transparent",color:"#2c2c2c"}},u5=e=>{switch(parseInt(String(e??""),10)){case 1:return"Por Asignar";case 2:return"Solicitud Asignada";case 3:return"Solicitud asignada en proceso";case 4:return"Finalizadas sin Venta";case 5:return"Finalizadas con Venta";case 6:return"Rechazadas";case 7:return"Finalizada por sistema";case 8:return"";case 9:return"";case 10:return"Prospección";case 11:return"Interés Real";case 12:return"Proceso de Compra";case 13:return"";case 14:return"En espera de Unidad";case 15:return"Auto Facturado";case 16:return"";case 17:return"";case 18:return"Compró otra Marca";case 19:return"No comprará";default:return null}},d5=e=>{switch(parseInt(String(e??""),10)){case 1:return"Por asignar";case 2:return"Solicitud Asignada";case 3:return"En seguimiento";case 6:return"Rechazada";case 7:return"Finalizada sin enviar a Ventas";case 8:return"Finalizada enviado a Ventas";default:return null}},f5=e=>{switch(parseInt(String(e??""),10)){case 0:return"Sin asignar";case 1:return"Confirmado";case 2:return"Solicitud Asignada";case 3:return"En seguimiento";case 4:return"Confirmado";case 5:return"Finalizada";case 6:return"Rechazada";case 10:return"Reagendado";case 20:return"Seguimiento [Cita Finalizada]";case 30:return"Reenvio";case 40:return"Seguimiento [Mecanico]";case 50:return"Seguimiento";default:return null}};function p5(e){const r=new Date(e),t=r.toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}),n=r.toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"});return`${t.replace(".","")} • ${n}`}function h5(e){return e.replace(/<br\s*\/?>/gi,`
188
+ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let u=tn(),f;f=u;let h=f.pathname||"/",g=h;if(l!=="/"){let y=l.replace(/^\//,"").split("/");g="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let v=Wh(e,{pathname:g});return Xr(d||v!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Xr(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),_k(v&&v.map(y=>Object.assign({},y,{params:Object.assign({},s,y.params),pathname:Hr([l,n.encodeLocation?n.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?l:Hr([l,n.encodeLocation?n.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),o,t)}function yk(){let e=Ak(),r=ak(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:a},"ErrorBoundary")," or"," ",M.createElement("code",{style:a},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},r),t?M.createElement("pre",{style:o},t):null,s)}var bk=M.createElement(yk,null),o0=class extends M.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const t=hk(e.digest);t&&(e=t)}let r=e!==void 0?M.createElement(en.Provider,{value:this.props.routeContext},M.createElement(rc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?M.createElement(xk,{error:e},r):r}};o0.contextType=Jh;var nc=new WeakMap;function xk({children:e,error:r}){let{basename:t}=M.useContext(Tr);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let n=pk(r.digest);if(n){let o=nc.get(r);if(o)throw o;let a=Kh(n.location,t);if(Gh&&!nc.get(r))if(a.isExternal||n.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const s=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:n.replace}));throw nc.set(r,s),s}return M.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function wk({routeContext:e,match:r,children:t}){let n=M.useContext(to);return n&&n.static&&n.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=r.route.id),M.createElement(en.Provider,{value:e},t)}function _k(e,r=[],t){let n=t?.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(r.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=n?.errors;if(a!=null){let u=o.findIndex(f=>f.route.id&&a?.[f.route.id]!==void 0);Ht(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),o=o.slice(0,Math.min(o.length,u+1))}let s=!1,i=-1;if(t&&n){s=n.renderFallback;for(let u=0;u<o.length;u++){let f=o[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(i=u),f.route.id){let{loaderData:h,errors:g}=n,v=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!g||g[f.route.id]===void 0);if(f.route.lazy||v){t.isStatic&&(s=!0),i>=0?o=o.slice(0,i+1):o=[o[0]];break}}}}let l=t?.onError,d=n&&l?(u,f)=>{l(u,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:sk(n.matches),errorInfo:f})}:void 0;return o.reduceRight((u,f,h)=>{let g,v=!1,p=null,y=null;n&&(g=a&&f.route.id?a[f.route.id]:void 0,p=f.route.errorElement||bk,s&&(i<0&&h===0?(s0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,y=null):i===h&&(v=!0,y=f.route.hydrateFallbackElement||null)));let _=r.concat(o.slice(0,h+1)),S=()=>{let C;return g?C=p:v?C=y:f.route.Component?C=M.createElement(f.route.Component,null):f.route.element?C=f.route.element:C=u,M.createElement(wk,{match:f,routeContext:{outlet:u,matches:_,isDataRoute:n!=null},children:C})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?M.createElement(o0,{location:n.location,revalidation:n.revalidation,component:p,error:g,children:S(),routeContext:{outlet:null,matches:_,isDataRoute:!0},onError:d}):S()},null)}function oc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sk(e){let r=M.useContext(to);return Ht(r,oc(e)),r}function Ck(e){let r=M.useContext(Js);return Ht(r,oc(e)),r}function Ek(e){let r=M.useContext(en);return Ht(r,oc(e)),r}function ac(e){let r=Ek(e),t=r.matches[r.matches.length-1];return Ht(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function Dk(){return ac("useRouteId")}function Ak(){let e=M.useContext(rc),r=Ck("useRouteError"),t=ac("useRouteError");return e!==void 0?e:r.errors?.[t]}function kk(){let{router:e}=Sk("useNavigate"),r=ac("useNavigate"),t=M.useRef(!1);return r0(()=>{t.current=!0}),M.useCallback(async(o,a={})=>{Xr(t.current,t0),t.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:r,...a}))},[e,r])}var a0={};function s0(e,r,t){!r&&!a0[e]&&(a0[e]=!0,Xr(!1,t))}M.memo(Tk);function Tk({routes:e,future:r,state:t,isStatic:n,onError:o}){return vk(e,void 0,{state:t,isStatic:n,onError:o})}var ei="get",ti="application/x-www-form-urlencoded";function ri(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Mk(e){return ri(e)&&e.tagName.toLowerCase()==="button"}function Ik(e){return ri(e)&&e.tagName.toLowerCase()==="form"}function Ok(e){return ri(e)&&e.tagName.toLowerCase()==="input"}function Pk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function jk(e,r){return e.button===0&&(!r||r==="_self")&&!Pk(e)}var ni=null;function Rk(){if(ni===null)try{new FormData(document.createElement("form"),0),ni=!1}catch{ni=!0}return ni}var Nk=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function sc(e){return e!=null&&!Nk.has(e)?(Xr(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ti}"`),null):e}function Lk(e,r){let t,n,o,a,s;if(Ik(e)){let i=e.getAttribute("action");n=i?pn(i,r):null,t=e.getAttribute("method")||ei,o=sc(e.getAttribute("enctype"))||ti,a=new FormData(e)}else if(Mk(e)||Ok(e)&&(e.type==="submit"||e.type==="image")){let i=e.form;if(i==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||i.getAttribute("action");if(n=l?pn(l,r):null,t=e.getAttribute("formmethod")||i.getAttribute("method")||ei,o=sc(e.getAttribute("formenctype"))||sc(i.getAttribute("enctype"))||ti,a=new FormData(i,e),!Rk()){let{name:d,type:u,value:f}=e;if(u==="image"){let h=d?`${d}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else d&&a.append(d,f)}}else{if(ri(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=ei,n=null,o=ti,s=e}return a&&o==="text/plain"&&(s=a,a=void 0),{action:n,method:t.toLowerCase(),encType:o,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ic(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function i0(e,r,t,n){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return t?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${n}`:o.pathname=`${o.pathname}.${n}`:o.pathname==="/"?o.pathname=`_root.${n}`:r&&pn(o.pathname,r)==="/"?o.pathname=`${r.replace(/\/$/,"")}/_root.${n}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${n}`,o}async function $k(e,r){if(e.id in r)return r[e.id];try{let t=await import(e.module);return r[e.id]=t,t}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function zk(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Bk(e,r,t){let n=await Promise.all(e.map(async o=>{let a=r.routes[o.route.id];if(a){let s=await $k(a,t);return s.links?s.links():[]}return[]}));return Vk(n.flat(1).filter(zk).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function l0(e,r,t,n,o,a){let s=(l,d)=>t[d]?l.route.id!==t[d].route.id:!0,i=(l,d)=>t[d].pathname!==l.pathname||t[d].route.path?.endsWith("*")&&t[d].params["*"]!==l.params["*"];return a==="assets"?r.filter((l,d)=>s(l,d)||i(l,d)):a==="data"?r.filter((l,d)=>{let u=n.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,d)||i(l,d))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:t[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Fk(e,r,{includeHydrateFallback:t}={}){return Uk(e.map(n=>{let o=r.routes[n.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),t&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function Uk(e){return[...new Set(e)]}function Wk(e){let r={},t=Object.keys(e).sort();for(let n of t)r[n]=e[n];return r}function Vk(e,r){let t=new Set;return new Set(r),e.reduce((n,o)=>{let a=JSON.stringify(Wk(o));return t.has(a)||(t.add(a),n.push({key:a,link:o})),n},[])}function lc(){let e=M.useContext(to);return ic(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Hk(){let e=M.useContext(Js);return ic(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var cc=M.createContext(void 0);cc.displayName="FrameworkContext";function uc(){let e=M.useContext(cc);return ic(e,"You must render this element inside a <HydratedRouter> element"),e}function Yk(e,r){let t=M.useContext(cc),[n,o]=M.useState(!1),[a,s]=M.useState(!1),{onFocus:i,onBlur:l,onMouseEnter:d,onMouseLeave:u,onTouchStart:f}=r,h=M.useRef(null);M.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let p=_=>{_.forEach(S=>{s(S.isIntersecting)})},y=new IntersectionObserver(p,{threshold:.5});return h.current&&y.observe(h.current),()=>{y.disconnect()}}},[e]),M.useEffect(()=>{if(n){let p=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(p)}}},[n]);let g=()=>{o(!0)},v=()=>{o(!1),s(!1)};return t?e!=="intent"?[a,h,{}]:[a,h,{onFocus:aa(i,g),onBlur:aa(l,v),onMouseEnter:aa(d,g),onMouseLeave:aa(u,v),onTouchStart:aa(f,g)}]:[!1,h,{}]}function aa(e,r){return t=>{e&&e(t),t.defaultPrevented||r(t)}}function qk({page:e,...r}){let t=lk(),{router:n}=lc(),o=M.useMemo(()=>Wh(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?t?M.createElement(Gk,{page:e,matches:o,...r}):M.createElement(Kk,{page:e,matches:o,...r}):null}function Zk(e){let{manifest:r,routeModules:t}=uc(),[n,o]=M.useState([]);return M.useEffect(()=>{let a=!1;return Bk(e,r,t).then(s=>{a||o(s)}),()=>{a=!0}},[e,r,t]),n}function Gk({page:e,matches:r,...t}){let n=tn(),{future:o}=uc(),{basename:a}=lc(),s=M.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let i=i0(e,a,o.unstable_trailingSlashAwareDataRequests,"rsc"),l=!1,d=[];for(let u of r)typeof u.route.shouldRevalidate=="function"?l=!0:d.push(u.route.id);return l&&d.length>0&&i.searchParams.set("_routes",d.join(",")),[i.pathname+i.search]},[a,o.unstable_trailingSlashAwareDataRequests,e,n,r]);return M.createElement(M.Fragment,null,s.map(i=>M.createElement("link",{key:i,rel:"prefetch",as:"fetch",href:i,...t})))}function Kk({page:e,matches:r,...t}){let n=tn(),{future:o,manifest:a,routeModules:s}=uc(),{basename:i}=lc(),{loaderData:l,matches:d}=Hk(),u=M.useMemo(()=>l0(e,r,d,a,n,"data"),[e,r,d,a,n]),f=M.useMemo(()=>l0(e,r,d,a,n,"assets"),[e,r,d,a,n]),h=M.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,y=!1;if(r.forEach(S=>{let C=a.routes[S.route.id];!C||!C.hasLoader||(!u.some(E=>E.route.id===S.route.id)&&S.route.id in l&&s[S.route.id]?.shouldRevalidate||C.hasClientLoader?y=!0:p.add(S.route.id))}),p.size===0)return[];let _=i0(e,i,o.unstable_trailingSlashAwareDataRequests,"data");return y&&p.size>0&&_.searchParams.set("_routes",r.filter(S=>p.has(S.route.id)).map(S=>S.route.id).join(",")),[_.pathname+_.search]},[i,o.unstable_trailingSlashAwareDataRequests,l,n,a,u,r,e,s]),g=M.useMemo(()=>Fk(f,a),[f,a]),v=Zk(f);return M.createElement(M.Fragment,null,h.map(p=>M.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...t})),g.map(p=>M.createElement("link",{key:p,rel:"modulepreload",href:p,...t})),v.map(({key:p,link:y})=>M.createElement("link",{key:p,nonce:t.nonce,...y,crossOrigin:y.crossOrigin??t.crossOrigin})))}function Qk(...e){return r=>{e.forEach(t=>{typeof t=="function"?t(r):t!=null&&(t.current=r)})}}var Jk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jk&&(window.__reactRouterVersion="7.14.0")}catch{}var c0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,u0=M.forwardRef(function({onClick:r,discover:t="render",prefetch:n="none",relative:o,reloadDocument:a,replace:s,unstable_mask:i,state:l,target:d,to:u,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:g,...v},p){let{basename:y,navigator:_,unstable_useTransitions:S}=M.useContext(Tr),C=typeof u=="string"&&c0.test(u),E=Kh(u,y);u=E.to;let w=mk(u,{relative:o}),N=tn(),D=null;if(i){let J=ec(i,[],N.unstable_mask?N.unstable_mask.pathname:"/",!0);y!=="/"&&(J.pathname=J.pathname==="/"?y:Hr([y,J.pathname])),D=_.createHref(J)}let[k,O,I]=Yk(n,v),q=r3(u,{replace:s,unstable_mask:i,state:l,target:d,preventScrollReset:f,relative:o,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:S});function H(J){r&&r(J),J.defaultPrevented||q(J)}let W=!(E.isExternal||a),Z=M.createElement("a",{...v,...I,href:(W?D:void 0)||E.absoluteURL||w,onClick:W?H:r,ref:Qk(p,O),target:d,"data-discover":!C&&t==="render"?"true":void 0});return k&&!C?M.createElement(M.Fragment,null,Z,M.createElement(qk,{page:w})):Z});u0.displayName="Link";var Xk=M.forwardRef(function({"aria-current":r="page",caseSensitive:t=!1,className:n="",end:o=!1,style:a,to:s,viewTransition:i,children:l,...d},u){let f=oa(s,{relative:d.relative}),h=tn(),g=M.useContext(Js),{navigator:v,basename:p}=M.useContext(Tr),y=g!=null&&i3(f)&&i===!0,_=v.encodeLocation?v.encodeLocation(f).pathname:f.pathname,S=h.pathname,C=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;t||(S=S.toLowerCase(),C=C?C.toLowerCase():null,_=_.toLowerCase()),C&&p&&(C=pn(C,p)||C);const E=_!=="/"&&_.endsWith("/")?_.length-1:_.length;let w=S===_||!o&&S.startsWith(_)&&S.charAt(E)==="/",N=C!=null&&(C===_||!o&&C.startsWith(_)&&C.charAt(_.length)==="/"),D={isActive:w,isPending:N,isTransitioning:y},k=w?r:void 0,O;typeof n=="function"?O=n(D):O=[n,w?"active":null,N?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let I=typeof a=="function"?a(D):a;return M.createElement(u0,{...d,"aria-current":k,className:O,ref:u,style:I,to:s,viewTransition:i},typeof l=="function"?l(D):l)});Xk.displayName="NavLink";var e3=M.forwardRef(({discover:e="render",fetcherKey:r,navigate:t,reloadDocument:n,replace:o,state:a,method:s=ei,action:i,onSubmit:l,relative:d,preventScrollReset:u,viewTransition:f,unstable_defaultShouldRevalidate:h,...g},v)=>{let{unstable_useTransitions:p}=M.useContext(Tr),y=a3(),_=s3(i,{relative:d}),S=s.toLowerCase()==="get"?"get":"post",C=typeof i=="string"&&c0.test(i),E=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let N=w.nativeEvent.submitter,D=N?.getAttribute("formmethod")||s,k=()=>y(N||w.currentTarget,{fetcherKey:r,method:D,navigate:t,replace:o,state:a,relative:d,preventScrollReset:u,viewTransition:f,unstable_defaultShouldRevalidate:h});p&&t!==!1?M.startTransition(()=>k()):k()};return M.createElement("form",{ref:v,method:S,action:_,onSubmit:n?l:E,...g,"data-discover":!C&&e==="render"?"true":void 0})});e3.displayName="Form";function t3(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function d0(e){let r=M.useContext(to);return Ht(r,t3(e)),r}function r3(e,{target:r,replace:t,unstable_mask:n,state:o,preventScrollReset:a,relative:s,viewTransition:i,unstable_defaultShouldRevalidate:l,unstable_useTransitions:d}={}){let u=n0(),f=tn(),h=oa(e,{relative:s});return M.useCallback(g=>{if(jk(g,r)){g.preventDefault();let v=t!==void 0?t:Ql(f)===Ql(h),p=()=>u(e,{replace:v,unstable_mask:n,state:o,preventScrollReset:a,relative:s,viewTransition:i,unstable_defaultShouldRevalidate:l});d?M.startTransition(()=>p()):p()}},[f,u,h,t,n,o,r,e,a,s,i,l,d])}var n3=0,o3=()=>`__${String(++n3)}__`;function a3(){let{router:e}=d0("useSubmit"),{basename:r}=M.useContext(Tr),t=Dk(),n=e.fetch,o=e.navigate;return M.useCallback(async(a,s={})=>{let{action:i,method:l,encType:d,formData:u,body:f}=Lk(a,r);if(s.navigate===!1){let h=s.fetcherKey||o3();await n(h,t,s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:u,body:f,formMethod:s.method||l,formEncType:s.encType||d,flushSync:s.flushSync})}else await o(s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:u,body:f,formMethod:s.method||l,formEncType:s.encType||d,replace:s.replace,state:s.state,fromRouteId:t,flushSync:s.flushSync,viewTransition:s.viewTransition})},[n,o,r,t])}function s3(e,{relative:r}={}){let{basename:t}=M.useContext(Tr),n=M.useContext(en);Ht(n,"useFormAction must be used inside a RouteContext");let[o]=n.matches.slice(-1),a={...oa(e||".",{relative:r})},s=tn();if(e==null){a.search=s.search;let i=new URLSearchParams(a.search),l=i.getAll("index");if(l.some(u=>u==="")){i.delete("index"),l.filter(f=>f).forEach(f=>i.append("index",f));let u=i.toString();a.search=u?`?${u}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(a.pathname=a.pathname==="/"?t:Hr([t,a.pathname])),Ql(a)}function i3(e,{relative:r}={}){let t=M.useContext(Xh);Ht(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=d0("useViewTransitionState"),o=oa(e,{relative:r});if(!t.isTransitioning)return!1;let a=pn(t.currentLocation.pathname,n)||t.currentLocation.pathname,s=pn(t.nextLocation.pathname,n)||t.nextLocation.pathname;return Qs(o.pathname,s)!=null||Qs(o.pathname,a)!=null}const l3={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:{xs:"90%",sm:450,md:500},bgcolor:"background.paper",boxShadow:24,p:{xs:2,sm:3},borderRadius:2,maxHeight:"90vh",overflowY:"auto"},f0=["#dbe3fe","#fcebc7","#d9f1d2","#fdf5d1","#ebe3d7","#e1d6fb","#f7c7cc","#f9e7fb","#eaedf2","#d5d8dd"],c3=()=>{const e=[];for(let r=0;r<24;r++)for(let t=0;t<60;t+=15){const n=new Date;n.setHours(r,t),e.push(x.format(n,"h:mmaaaa"))}return e},p0=[],oi=c3(),hn=(e,r)=>{if(!e||!r)return null;const t=r.toLowerCase().replace(/\s/g,"").replace(/\./g,""),n=t.includes("pm"),o=t.includes("am"),a=t.replace(/[a-z]/g,""),[s,i]=a.split(":");if(!s||!i)return null;let l=parseInt(s,10);const d=parseInt(i,10);n&&l<12&&(l+=12),o&&l===12&&(l=0);const[u,f,h]=e.split("-").map(Number),g=new Date(u,f-1,h,l,d);return x.isValid(g)?g:null},u3=({isVisible:e,onClose:r,onSave:t,onDelete:n,selectedDate:o,initialEvent:a,userId:s,masNombreBD:i,disId:l,gmail:d,onReenviar:u})=>{const[f,h]=b.useState(!1),[g,v]=b.useState(!1),p=x.format(new Date,"yyyy-MM-dd"),[y,_]=b.useState(""),[S,C]=b.useState([]),[E,w]=b.useState(!1),N=Nl(),[D,k]=b.useState(""),[O,I]=b.useState(p0),[q,H]=b.useState(!1),[W,Z]=b.useState(""),[J,Y]=b.useState(!1),[z,ie]=b.useState([]),[ue,$]=b.useState(!1),X=n0(),[Se,we]=b.useState(null),_e=(V,ee)=>{console.log("client",V),we(V),Ce("client",V.nombreCliente||""),Ce("solID",null),$(!1)},[oe,le]=b.useState([]),se=MA(W,300),ge=O.filter(V=>V.tieneConflicto).length,[De,he]=b.useState(!1),[Le,L]=b.useState("COT"),{control:Ne,handleSubmit:lt,reset:Ze,formState:{errors:Ie,isValid:ot},watch:$e,setValue:Ce}=Ch({resolver:ZD(KD),defaultValues:{titulo:a?.titulo||"",fechaInicio:x.format(new Date,"yyyy-MM-dd"),horaInicio:x.format(new Date,"h:mmaaaa"),horaFin:x.format(x.addHours(new Date,1),"h:mmaaaa"),todoElDia:!1,client:a?.client||null,repetir:"No repetir",link:a?.link||"",descripcion:a?.descripcion||"",solID:a?.solID??null,invitados:[],incluirMeet:!1},mode:"onChange"}),A=$e("fechaInicio"),P=$e("fechaFin"),U=$e("todoElDia");b.useEffect(()=>{if(y.trim()===""||!s||!l||!i){C([]),Ce("solID",null),w(!1),k("");return}w(!0);const V=setTimeout(()=>{N.getClients(y,l,i,s,Le).then(ee=>{w(!1);const Ee=Array.from(new Map(ee.map(fe=>[fe.nombreCliente,fe])).values());if(console.log("uniqueClients",Ee),Ee.length>0)C(Ee),k("");else if(a?.client&&a.solID!==null){const fe=[{solID:a.solID,nombreCliente:a.client}];C(fe),k("Sin resultados")}else C([]),k("Sin resultados")}).catch(ee=>{console.error("Error al buscar clientes:",ee),w(!1)})},500);return()=>clearTimeout(V)},[y,s,l,i,Le]),b.useEffect(()=>{if(a){const V=a?.solicitudRelacionada&&a?.solicitudRelacionada[0];if(V){const ee={nombreCliente:a?.client||"",tel:V.tel||"",email:V.email||"",marca:V.marca||"",modelo:V.modelo||"",solID:Number(V.solID)};we(ee),C([ee]),Ce("client",V.nombreCliente),Ce("solID",V?.solID)}}},[a]),b.useEffect(()=>{if(A&&P){const V=new Date(A),ee=new Date(P);(V===ee||V>ee)&&Ce("fechaFin",A)}},[A,P,Ce]),b.useEffect(()=>{A&&Ce("fechaFin",A)},[A]),b.useEffect(()=>{Ce("showEndDate",f)},[f,Ce]),b.useEffect(()=>{if(console.log("initialEvent",a),a){const V=x.format(a.fechaInicio,"yyyy-MM-dd")===x.format(a.fechaFin,"yyyy-MM-dd");if(h(!V),Ce("titulo",a?.titulo),Ce("fechaInicio",x.format(a.fechaInicio,"yyyy-MM-dd")),Ce("fechaFin",x.format(a.fechaFin,"yyyy-MM-dd")),Ce("horaInicio",x.format(a.fechaInicio,"h:mmaaaa")),Ce("horaFin",x.format(a.fechaFin,"h:mmaaaa")),Ce("horaInicio2",x.format(a.fechaFin,"h:mmaaaa")),Ce("descripcion",a.descripcion),Ce("link",a.link),Ce("repetir","false"),Ce("color",a.color),Ce("todoElDia",a.todoElDia),Ce("solID",a.solID),Ce("client",a.client),a.invitados&&a.invitados.length>0){const ee=(a?.invitados||[]).map(fe=>{const je=fe.usrNombre?.trim()||"",Ue=je.split(/\s+/),yt=Ue.length>1?(Ue[0][0]+Ue[1][0]).toUpperCase():je.substring(0,2).toUpperCase();return{nombre:fe.usrNombre||"Sin nombre",correo:fe.correo||"",iniciales:yt||"--",usrID:fe.usuarioID??null,isHost:fe.esOrganizador||!1,estatus:fe.statusInvitacion,tieneConflicto:!1,disID:fe.disID}}),Ee={nombre:a?.nombreAnfitrion?a?.nombreAnfitrion:"Anfitrion",correo:"",iniciales:(a?.nombreAnfitrion?a?.nombreAnfitrion:"Anfitrion").substring(0,2).toUpperCase(),usrID:s??0,isHost:!0,estatus:"CONFIRMADA",tieneConflicto:!1};I([Ee,...ee])}else I(p0);a.solID?v(!0):v(!1)}else{const V=o||new Date,ee=new Date,Ee=new Date(V.getFullYear(),V.getMonth(),V.getDate(),ee.getHours(),ee.getMinutes()),fe=x.addHours(Ee,1);console.log("defaultEndTime",fe),Ze({titulo:"",fechaInicio:x.format(Ee,"yyyy-MM-dd"),fechaFin:x.format(fe,"yyyy-MM-dd"),horaFin:x.format(fe,"h:mmaaaa"),horaInicio:x.format(Ee,"h:mmaaaa"),horaInicio2:x.format(fe,"HH:mm"),todoElDia:!1,client:"",repetir:"No repetir",link:"",descripcion:"",color:f0[0],solID:null}),h(!1),v(!1)}},[a,e,o]);const ce=V=>({UsuarioID:V.usrID??null,Correo:V.correo,EsOrganizador:V.usrID==s,StatusInvitacion:V.estatus,disID:l??null}),ae=lt(V=>{const ee=O.map(fe=>ce(fe)),Ee={...V,invitados:ee};t(Ee,a?.eventoID),r(),Ze(),h(!1)},V=>{console.log("Errores de validación:",V)});b.useEffect(()=>{U&&(Ce("horaInicio","00:00"),Ce("horaFin","23:59"))},[U,Ce,$e]);const j=()=>{const V=$e("fechaInicio");if(V){const ee=new Date(`${V}T00:00:00`),Ee=x.addDays(ee,1);Ce("fechaFin",x.format(Ee,"yyyy-MM-dd"))}h(!0)},K=$e("fechaInicio"),de=$e("horaInicio"),Oe=$e("fechaFin"),R=$e("horaFin"),[te,xe]=b.useState(null),[qe,gt]=b.useState(null);b.useEffect(()=>{(te===null||te!==de)&&xe(de)},[de,te]),b.useEffect(()=>{(qe===null||qe!==R)&&gt(R??"")},[R,qe]);const vt=$e("todoElDia");b.useEffect(()=>{if(vt||!de||!R||!K||!Oe)return;const V=hn(K,de),ee=hn(Oe,R);if(!V||!ee||!x.isValid(V)||!x.isValid(ee))return;const Ee=x.isSameDay(V,ee),fe=Ee&&(x.isAfter(V,ee)||V.getTime()===ee.getTime()),je=x.isBefore(ee,V)&&!Ee;(fe||je)&&(Ce("horaFin",""),gt(""))},[de,K]);const Kt=b.useMemo(()=>{if(!de||!K)return oi;const V=hn(K,de);return V?oi.map(ee=>{const Ee=hn(Oe||K,ee);if(Ee&&x.isAfter(Ee,V)){const fe=(Ee.getTime()-V.getTime())/6e4,je=Math.floor(fe/60),Ue=fe%60,yt=je>0?`${je} h${Ue>0?` ${Ue} min`:""}`:`${Ue} min`;return{value:ee,label:`${ee} (${yt})`}}return ee}).filter(ee=>{const Ee=typeof ee=="string"?ee:ee.value,fe=hn(Oe||K,Ee);return fe?x.isAfter(fe,V):!1}):oi},[de,K,Oe]),er=b.useMemo(()=>oi,[]);b.useEffect(()=>{if(!a&&de&&K){const V=hn(K,de);if(V){const ee=x.addMinutes(V,15),Ee=de.toLowerCase(),fe=Ee.includes("pm")||Ee.includes("p.m."),je=Ee.includes(".");let Ue=x.format(ee,"h:mm"),yt=fe?"pm":"am";je&&(yt=fe?"p.m.":"a.m.");const ir=`${Ue}${yt}`,Or=(R||"").toLowerCase();(R!==ir||fe&&(Or.includes("am")||Or.includes("a.m.")))&&Ce("horaFin",ir,{shouldValidate:!0})}}},[de,Ce,K]);const Qt=async V=>{const ee=$e("fechaInicio"),Ee=$e("horaInicio"),fe=$e("horaFin");if(console.log("currentGuests",V),!l||!ee||!Ee||!fe||V.length===0)return;const je=await Promise.all(V.map(async Ue=>{if(Ue.isHost||!Ue.correo)return Ue;try{const yt=await N.VerificarConflicto(l,Ue.correo,ee,Ee+":00",fe+":00"),ir=Array.isArray(yt)?yt[0]:yt;if(console.log("conflictResult",yt),ir){const Or=await N.getDisponibilidadUsuario(l,Ue.correo,ee,"60");ie(Or)}return{...Ue,tieneConflicto:String(ir.tieneConflicto).toLowerCase()==="true"}}catch{return{...Ue,tieneConflicto:!1}}}));I(je)};b.useEffect(()=>{O.filter(ee=>!ee.isHost).length>0&&K&&de&&R&&Qt(O)},[K,de,R]);const re=async V=>{if(O.some(Ue=>Ue.correo===V.correo))return;Y(!0);const Ee=$e("fechaInicio"),fe=$e("horaInicio"),je=$e("horaFin");if(!l||!V.correo||!Ee||!fe||!je){I(Ue=>[...Ue,{...V,estatus:"PENDIENTE",isHost:!1,tieneConflicto:!1}]);return}try{const Ue=await N.VerificarConflicto(l,V.correo,Ee,fe+":00",je+":00"),yt=Array.isArray(Ue)?Ue[0]:Ue,ir=String(yt?.tieneConflicto).toLowerCase()==="true",Or={...V,estatus:"PENDIENTE",isHost:!1,tieneConflicto:ir};if(ir){const rn=await N.getDisponibilidadUsuario(l,V.correo,Ee,"60");ie(rn)}I(rn=>[...rn,Or])}catch(Ue){console.error("Error al verificar conflicto:",Ue),I(yt=>[...yt,{...V,tieneConflicto:!1,isHost:!1}])}},Pe=V=>{I(ee=>ee.filter(Ee=>Ee.nombre!==V))},Ae=()=>{H(!1)},ze=V=>{const fe=(V.usrNombre??"").split(" ").map(je=>je.charAt(0)).join("").toUpperCase().substring(0,2);return{nombre:V.usrNombre??"",correo:V.usrMail??"",iniciales:fe,usrID:V.usrID??0,estatus:"PENDIENTE",tieneConflicto:!1,isHost:!1}};b.useEffect(()=>{console.log("debouncedSearchText.length",se.length),se.length>2&&l?(async()=>{const ee=await N.getUsuariosInvitados(l,se),Ee=ee.map(ze).filter(fe=>fe.usrID!==s&&!O.some(je=>je.correo===fe.correo));console.log("sugerencias",ee),le(Ee)})():le([])},[se,O]);const Yt=V=>{Z(V)},tr=V=>{const{Fecha:ee,HoraInicio:Ee,HoraFin:fe}=V,je=Ue=>Ue.split(":").slice(0,2).join(":");Ce("fechaInicio",ee),Ce("fechaFin",ee),Ce("horaInicio",je(Ee)),Ce("horaFin",je(fe)),h(!1),Ae()},Ir=async()=>{const V=$e(),ee=hn(V.fechaInicio,V.horaInicio),Ee=hn(V.fechaFin||V.fechaInicio,V.horaFin);if(!ee||!Ee)return;if(!l||!d){console.error("Faltan datos requeridos (disId, userMail o calendarId)");return}he(!0);const fe={summary:V.titulo||"Sin título",description:V.descripcion||"",start:{dateTime:x.format(ee,"yyyy-MM-dd'T'HH:mm:ssxxx"),timeZone:"America/Mexico_City"},end:{dateTime:x.format(Ee,"yyyy-MM-dd'T'HH:mm:ssxxx"),timeZone:"America/Mexico_City"}};try{const je=await N.insertarEventoGoogle(l,d,!0,fe);je?.hangoutLink&&(Ce("link",je.hangoutLink),Ce("incluirMeet",!1))}catch(je){console.error("Error al generar Meet",je)}finally{he(!1)}};return c.jsx(c.Fragment,{children:c.jsx(m.Modal,{open:e,onClose:r,children:c.jsxs("form",{onSubmit:ae,children:[c.jsxs(m.Box,{sx:l3,children:[c.jsx(m.IconButton,{"aria-label":"close",onClick:r,sx:{position:"absolute",right:8,top:12},children:c.jsx(Er,{})}),c.jsx(m.Typography,{variant:"h6",mb:2,children:a?.isGoogleEvent||a?.isOutlookEvent?c.jsx(c.Fragment,{children:a?.titulo||"Evento de Google"}):!a&&"Agregar evento"}),c.jsx(m.Typography,{style:{fontSize:18,fontWeight:600},mb:2,children:a?.client&&a?.solicitudRelacionada?.[0]?c.jsxs(c.Fragment,{children:["Evento para el cliente:"," ",c.jsx(m.Link,{component:"button",variant:"inherit",type:"button",onClick:()=>{const V=a?.solicitudRelacionada?.[0];if(V&&V.tipoSol){const ee=V?.tipoSol,fe={COT:{url:"/netcar/cotizaciones/",pag:10,tipo:"COT"},SEMI:{url:"/netcar/seminuevos/",pag:12,tipo:"SEMI"},SER:{url:"/netcar/servicio/",pag:14,tipo:"SER"},PM:{url:"/netcar/pruebademanejo/",pag:16,tipo:"PM"}}[ee];fe&&X(`${fe.url}${V?.solID}`,{replace:!0,state:{tipoSOL:fe.tipo,pag:fe.pag,modulo:"Consulta"}})}},sx:{color:"#1976d2",cursor:"pointer",fontWeight:700,textDecoration:"underline",verticalAlign:"baseline",p:0,border:"none",backgroundColor:"transparent",fontSize:"14px"},children:`${a.client} / ${a.solicitudRelacionada[0].marca} ${a.solicitudRelacionada[0].modelo}`})]}):"Editar Evento"}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"titulo",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,label:"Título",fullWidth:!0,variant:"outlined",size:"small",error:!!Ie.titulo,helperText:Ie.titulo?.message,inputProps:{maxLength:100},sx:{"& .MuiInputLabel-root.Mui-focused":{color:"black"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"black"},"& .MuiInputLabel-root":{backgroundColor:"transparent !important",padding:"0 !important"}}})})})}),c.jsxs("div",{className:`row g-2 ${f?"mb-1":"mb-2"}`,children:[c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"fechaInicio",control:Ne,render:({field:V})=>c.jsx(m.TextField,{fullWidth:!0,...V,type:"date",placeholder:"Fecha de inicio",size:"small",InputLabelProps:{shrink:!0},error:!!Ie.fechaInicio,helperText:Ie.fechaInicio?.message})})}),f?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"col-md-3 d-none d-md-block"}),c.jsx("div",{className:"col-10 col-md-4",children:c.jsx(Ar,{name:"fechaFin",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,type:"date",placeholder:"Fecha de fin",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0},inputProps:{min:A||p},error:!!Ie.fechaFin,helperText:Ie.fechaFin?.message})})}),!a&&c.jsx("div",{className:"col-2 col-md-1 d-flex align-items-start",children:c.jsx(m.IconButton,{onClick:()=>h(!1),sx:{fontSize:18},children:c.jsx(QD,{})})})]}):c.jsx("div",{className:"col-md-8"})]}),f&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12 d-flex justify-content-center",children:c.jsx(Ph,{sx:{color:"#757575",my:1}})})}),c.jsxs("div",{className:"row g-2 mb-2",children:[c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"horaInicio",control:Ne,render:({field:{onChange:V,value:ee,...Ee}})=>c.jsx(m.Autocomplete,{freeSolo:!0,options:er,value:ee||"",getOptionLabel:fe=>typeof fe=="string"?fe:fe.value,onChange:(fe,je)=>{const Ue=typeof je=="string"?je:je?.value;if(Ue){const yt=Ue.split(" (")[0].trim();V(yt)}else V("")},slotProps:{paper:{sx:{width:"fit-content",minWidth:"250px"}}},onInputChange:(fe,je)=>V(je),renderInput:fe=>c.jsx(m.TextField,{...fe,...Ee,size:"small",error:!!Ie.horaInicio,helperText:Ie.horaInicio?.message,sx:{"& .MuiOutlinedInput-root":{paddingRight:"8px !important"},"& .MuiAutocomplete-endAdornment":{position:"end",right:10}},InputProps:{...fe.InputProps}}),popupIcon:c.jsx(Ll,{sx:{cursor:"pointer",color:"#5f6368"}}),forcePopupIcon:!0,sx:{"& .MuiAutocomplete-clearIndicator":{display:"none"}},disabled:vt})})}),!f&&c.jsx("div",{className:"col-1 d-flex align-items-center justify-content-center",style:{marginTop:Ie.horaInicio?"5px":"0px"},children:c.jsx(Ph,{sx:{color:"#757575"}})}),f&&c.jsx("div",{className:"col-md-3 d-none d-md-block"}),c.jsx("div",{className:"col-12 col-md-4",children:c.jsx(Ar,{name:"horaFin",control:Ne,render:({field:{onChange:V,value:ee,...Ee}})=>c.jsx(m.Autocomplete,{freeSolo:!0,options:Kt,getOptionLabel:fe=>typeof fe=="string"?fe:fe.value,value:ee||"",onChange:(fe,je)=>{const Ue=typeof je=="string"?je:je?.value;if(Ue){const yt=Ue.split(" (")[0].trim();V(yt)}else V("")},slotProps:{paper:{sx:{width:"fit-content",minWidth:"250px"}}},renderOption:(fe,je)=>b.createElement(m.Box,{component:"li",...fe,key:typeof je=="string"?je:je.value},c.jsx(m.Typography,{children:typeof je=="string"?je:je.label})),onInputChange:(fe,je)=>V(je),renderInput:fe=>c.jsx(m.TextField,{...fe,...Ee,size:"small",error:!!Ie.horaFin,helperText:Ie.horaFin?.message,sx:{"& .MuiOutlinedInput-root":{paddingRight:"8px !important"},"& .MuiAutocomplete-endAdornment":{position:"end",right:10}},InputProps:{...fe.InputProps}}),popupIcon:c.jsx(Ll,{sx:{cursor:"pointer",color:"#5f6368"}}),forcePopupIcon:!0,sx:{"& .MuiAutocomplete-clearIndicator":{display:"none"}},disabled:vt})})}),!f&&c.jsx("div",{className:"col-12 col-md-2 d-flex align-items-center",children:c.jsx(Ar,{name:"todoElDia",control:Ne,render:({field:V})=>c.jsx(m.FormControlLabel,{control:c.jsx(m.Checkbox,{checked:V.value,onChange:ee=>V.onChange(ee.target.checked)}),label:c.jsx("label",{style:{fontSize:"0.7rem",fontWeight:"normal"},children:"Todo el día"}),sx:{whiteSpace:"nowrap"}})})})]}),(!a?.isGoogleEvent||a?.isOutlookEvent)&&!f&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsxs(m.Button,{onClick:j,size:"small",sx:{textTransform:"none",fontSize:16},children:[c.jsx(eA,{}),"  Agregar fecha final"]})})}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"link",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,placeholder:" Agregar enlace de reunión",fullWidth:!0,variant:"outlined",size:"small",error:!!Ie.link,helperText:Ie.link?.message,InputProps:{startAdornment:c.jsx("img",{src:JD,width:20,style:{alignSelf:"flex-start",marginRight:"8px",marginTop:"8px"}})}})})})}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(Ar,{name:"descripcion",control:Ne,render:({field:V})=>c.jsx(m.TextField,{...V,placeholder:" Agregar descripción aquí...",fullWidth:!0,multiline:!0,rows:3,inputProps:{maxLength:500},variant:"outlined",size:"small",InputProps:{startAdornment:c.jsx("img",{src:tA,width:20,style:{alignSelf:"flex-start",marginRight:"8px"}})}})})})}),a?.solicitudRelacionada===null&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(wA,{onSelectGuest:re,availableSuggestions:oe,onInputTextChange:Yt})})}),(J||ge>0)&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(TA,{guests:O,conflictCount:ge,onViewSuggestions:()=>H(!0),onDeleteGuest:Pe})})}),a?.invitados&&a?.invitados?.length>0&&c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsx(m.Box,{children:c.jsx(fA,{guests:O,onReenviar:u,esOrganizador:a?.esOrganizador})})})}),c.jsx(yA,{open:q,handleClose:Ae,suggestions:z,onSelectSlot:tr})]}),c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",mt:1,mb:1,px:0},children:[c.jsx(m.Box,{sx:{minWidth:40,display:"flex",justifyContent:"flex-start"},children:c.jsx("img",{src:"https://fonts.gstatic.com/s/i/productlogos/meet_2020q4/v1/web-512dp/logo_meet_2020q4_color_2x_web_512dp.png",alt:"Meet",style:{width:22,height:22}})}),c.jsx(m.Box,{sx:{flex:1},children:!$e("link")&&!$e("incluirMeet")?c.jsx(m.Button,{fullWidth:!0,disabled:De||!l||!d,onClick:Ir,sx:{justifyContent:"flex-start",textTransform:"none",bgcolor:"#f1f3f4",color:"#3c4043","&:hover":{bgcolor:"#e8eaed",boxShadow:"none"},borderRadius:"4px",fontWeight:400,fontSize:"14px",py:1,px:2,border:"none",boxShadow:"none"},children:De?c.jsxs(c.Fragment,{children:[c.jsx(m.CircularProgress,{size:18,sx:{mr:1.5,color:"#5f6368"}}),c.jsx(m.Typography,{variant:"body2",sx:{fontSize:"14px",color:"#5f6368"},children:"Generando enlace..."})]}):"Añadir videoconferencia de Google Meet"}):c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#f1f3f4",p:"6px 12px",borderRadius:"4px",border:"1px solid #dadce0"},children:[c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:[c.jsx(m.Typography,{variant:"body2",sx:{color:"#1a73e8",fontWeight:500,cursor:$e("link")?"pointer":"default",textDecoration:"none","&:hover":{textDecoration:$e("link")?"underline":"none"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},onClick:()=>$e("link")&&window.open($e("link"),"_blank"),children:$e("link")?$e("link"):"Se añadirá Google Meet al guardar"}),c.jsx(m.Typography,{variant:"caption",sx:{color:"#70757a"},children:"Google Meet"})]}),c.jsx(m.IconButton,{size:"small",onClick:()=>{Ce("incluirMeet",!1),Ce("link","")},sx:{color:"#5f6368"},children:c.jsx(Er,{sx:{fontSize:18}})})]})})]}),c.jsx("div",{className:"row mb-2",children:c.jsx("div",{className:"col-12",children:c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap"},children:[c.jsx(XD,{}),f0.map(V=>c.jsx(Ar,{name:"color",control:Ne,render:({field:ee})=>c.jsx(m.IconButton,{onClick:()=>ee.onChange(V),sx:{width:24,height:24,borderRadius:"50%",bgcolor:V,border:ee.value===V?"2px solid":"none",borderColor:ee.value===V?"primary.main":"transparent"}})},V))]})})}),c.jsx("div",{className:"row",children:c.jsxs("div",{className:"col-12 d-flex gap-2",style:{width:"100%",marginTop:"20px"},children:[a&&!a?.isGoogleEvent&&!a?.isOutlookEvent&&c.jsx(m.Button,{onClick:n,variant:"outlined",startIcon:c.jsx("img",{src:Ih,width:15}),hidden:a?a?.esOrganizador!=!0:!1,sx:{flex:1,textTransform:"none",backgroundColor:"#FFF5F5",color:"#d32f2f",borderColor:"red",borderRadius:"8px",fontWeight:700,fontSize:"14px",padding:"8px 0","&:hover":{backgroundColor:"#FEE2E2",borderColor:"red"}},children:"Eliminar"}),c.jsx(m.Button,{onClick:r,variant:"outlined",sx:{flex:1,textTransform:"none",fontWeight:700,fontSize:"14px",borderRadius:"8px",color:"#1976D2",borderColor:"#1976D2","&:hover":{backgroundColor:"rgba(25, 118, 210, 0.04)",borderColor:"#115293"}},children:"Cancelar"}),c.jsx(m.Button,{onClick:ae,variant:"contained",disabled:!ot,hidden:a?a?.esOrganizador!=!0:!1,sx:{flex:1,textTransform:"none",fontWeight:700,fontSize:"14px",borderRadius:"8px",backgroundColor:"#1976D2",boxShadow:"none","&:hover":{backgroundColor:"#115293",boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"}},children:"Guardar"})]})})]}),c.jsx($A,{open:ue,onClose:()=>$(!1),clientOptions:S,isClientsLoading:E,setClientSearchTerm:_,onSelectClient:_e,setFiltroPadre:L})]})})})},d3={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:450,bgcolor:"background.paper",boxShadow:24,p:2,borderRadius:2,maxHeight:"80vh",overflowY:"auto"},f3=({isOpen:e,onClose:r,events:t,date:n,onEventClick:o})=>{if(!n)return null;const a=i=>{o(i),r()},s=i=>i.isGoogleEvent?{label:"G",borderColor:"#4285F4"}:i.isOutlookEvent?{label:"O",borderColor:"#0078d9"}:{label:"-",borderColor:"#CCC"};return c.jsx(m.Modal,{open:e,onClose:r,children:c.jsxs(m.Box,{sx:d3,children:[c.jsxs(m.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},children:[c.jsxs(m.Typography,{sx:{fontSize:"18px",fontWeight:"bold"},component:"h2",children:["Eventos del"," ",n.toLocaleDateString("es-ES",{weekday:"long",day:"numeric",month:"long"})]}),c.jsx(m.IconButton,{onClick:r,size:"small",children:c.jsx(Er,{})})]}),c.jsx(m.Divider,{}),c.jsx(m.List,{sx:{mt:1},children:t.map(i=>{const l=s(i);return c.jsx(m.ListItem,{disablePadding:!0,sx:{mb:1},children:c.jsx(m.ListItemButton,{onClick:()=>a(i),sx:{py:1,borderRadius:"4px",backgroundColor:"rgba(0,0,0,0.02)",borderLeft:`5px solid ${l?.borderColor}`,"&:hover":{backgroundColor:"rgba(0,0,0,0.04)"}},children:c.jsxs(m.Box,{sx:{flexGrow:1},children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[c.jsx(m.Typography,{sx:{fontSize:"10px",fontWeight:"bold",px:.5,borderRadius:"3px",backgroundColor:l?.borderColor,color:"white",textTransform:"uppercase"},children:l?.label}),c.jsx(m.Typography,{sx:{fontSize:"14px",fontWeight:600,lineHeight:1.2,color:"#333"},children:i.titulo})]}),c.jsx(m.Typography,{sx:{fontSize:"12px",color:"#666"},children:i.todoElDia?"Todo el día":`${x.format(i.fechaInicio,"hh:mm aa").toLowerCase()} - ${x.format(i.fechaFin,"hh:mm aa").toLowerCase()}`})]})})},i.eventoID)})})]})})};var sa={},h0;function p3(){if(h0)return sa;h0=1;var e=st();Object.defineProperty(sa,"__esModule",{value:!0}),sa.default=void 0;var r=e(pt()),t=ut();return sa.default=(0,r.default)((0,t.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error"),sa}var h3=p3();const m3=at(h3);var ia={},m0;function g3(){if(m0)return ia;m0=1;var e=st();Object.defineProperty(ia,"__esModule",{value:!0}),ia.default=void 0;var r=e(pt()),t=ut();return ia.default=(0,r.default)((0,t.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),ia}var v3=g3();const y3=at(v3),b3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23fff'%20d='M19.378%204.405a1.813%201.813%200%201%201%202.565%202.565L9.571%2019.342a1.813%201.813%200%200%201-2.565%200l-4.949-4.949a1.814%201.814%200%200%201%202.428-2.69l.137.126%203.666%203.666z'/%3e%3c/svg%3e",x3="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAALVBMVEVHcEzfEBfjCxzkChvkChvkChzkCxvlChv////96uv60dT1o6ryho/mGyvkCxypwAsrAAAACHRSTlMAECtdiKDJ5DEbuTIAAAHoSURBVHjatdlbjsMgDAVQ87JJKHf/y51pf9CIp+vJ/SzSkUloAZc2cSEkFgEAYU7RO/o+zkdBF07hO9QnwSzJq4uLgmUkGDgzGTrORHrGcZLXlmcvMkKZaJxuH/YLTwB9ZCo6AUyivb4m7uuziwxDeLtezKsnwJiwfCH2x5hgDi8mbJ+0APaI6wo0Ju4KrIBqQNyqwFqufL3qYOD1O1DqqkQZeVd+567dwJ3fuUai0Cceg5Scm9h5v3lhED9fgzk3ceTlC4Ok+YxzLzbvk+lrCRjl6sTmzSuEn80Yr9yJzZs+Q6Tp72C9/4jdRwXDCJEDTsQzD3DkcSaeeQgUcSZuvAYmnIlnHhIxVqLWAxNjKSo9CAl0YsEGBFRiwSYEhdh5dvCuBrB5GlH3UvaikOw8ncjbha0UeffV04qJwplX7jMxUjjzUM9ET+7Mw6HoiOTIOxR5ehYunXe8SfndNlpwvo2G2XWidl4nYhQ3PYpczVMfRfxqoy9QHZbWx7nm9eK9OM5RnB84h8VPTqJA6G55toj5WtYX+K8lypMXH2KYkx64PD55vbVfwJ9pEZgfo70tYm/c2FtLds/eTHu23WdvSG7jk2a6zzV17aRER4oEUXDm1r0kT18lJB5o5n8sErN8JOEUtv9U/ACrTv/qOzhclQAAAABJRU5ErkJggg==",dc=b.forwardRef(({id:e,message:r,variant:t},n)=>{const{closeSnackbar:o}=ba.useSnackbar(),a={success:{color:"#fff",icon:c.jsx("img",{width:25,src:b3,style:{borderRadius:"50%",backgroundColor:"#4caf50",color:"white",fontSize:"12px",padding:3}})},error:{color:"#f44336",icon:c.jsx(m3,{sx:{color:"#f44336"}})},info:{color:"#2196f3",icon:c.jsx(y3,{sx:{color:"#2196f3"}})},delete:{color:"#fff",icon:c.jsx("img",{src:Ih,width:25,style:{borderRadius:"50%",backgroundColor:"#ffdfd4",color:"red",fontSize:"16px",padding:3}})},rechazar:{color:"#fff",icon:c.jsx("img",{src:x3,width:30,style:{borderRadius:"50%",color:"red",fontSize:"16px",padding:3}})}},s=a[t]||a.info;return c.jsx(ba.SnackbarContent,{ref:n,children:c.jsxs(m.Box,{sx:{backgroundColor:"white",color:"#333",padding:"8px 16px",borderRadius:"8px",boxShadow:"0 3px 10px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",width:{xs:"90%",sm:"auto"},minWidth:"300px",borderLeft:`5px solid ${s.color}`},children:[c.jsx(m.Box,{sx:{mr:1.5},children:s.icon}),c.jsx(m.Typography,{variant:"body2",sx:{flexGrow:1},children:r}),c.jsx(m.IconButton,{size:"small",onClick:()=>o(e),children:c.jsx(Er,{fontSize:"small"})})]})})}),g0=b.createContext(void 0),w3=({children:e})=>{const[r,t]=b.useState([]),[n,o]=b.useState([]),[a,s]=b.useState(!1);return c.jsx(g0.Provider,{value:{googleEvents:r,setGoogleEvents:t,outlookEvents:n,setOutlookEvents:o,isLoadingGoogleEvents:a,setIsLoadingGoogleEvents:s},children:e})},_3=()=>{const e=b.useContext(g0);if(e===void 0)throw new Error("useEvents must be used within an EventsProvider");return e},S3=(e,r,t)=>{const n=(s,i)=>i?new Date(i):s?new Date(s.replace(/-/g,"/")):new Date,o=n(e.start.date,e.start.dateTime);let a=n(e.end.date,e.end.dateTime);return e.end.date&&!e.end.dateTime&&a.setDate(a.getDate()-1),{eventoID:Math.abs(C3(e.id)),titulo:e.summary||"(Sin título)",descripcion:e.description,fechaInicio:o,fechaFin:a,todoElDia:!!(e.start.date&&!e.start.dateTime),color:"#4285F4C",hasVideoCall:!!e.conferenceData,link:e.htmlLink,repetir:void 0,solID:null,disID:r,client:null,usrID:t,solicitudRelacionada:[],isGoogleEvent:!0}};function C3(e){let r=0;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);r=(r<<5)-r+n,r|=0}return r}function E3(e){let r=0;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);r=(r<<5)-r+n,r|=0}return r}const D3=(e,r,t)=>{const n=new Date(e.start.dateTime);let o=new Date(e.end.dateTime);return e.isAllDay&&o.setDate(o.getDate()-1),{eventoID:Math.abs(E3(e.id)),titulo:e?.summary||"(Sin título)",descripcion:e.body?.content||"",fechaInicio:n,fechaFin:o,todoElDia:e.isAllDay,color:"#0078D4",hasVideoCall:!!e.onlineMeetingUrl,link:e.webLink,repetir:void 0,solID:null,disID:r,client:null,usrID:t,solicitudRelacionada:[],isGoogleEvent:!1,isOutlookEvent:!0}},v0="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='49'%20fill='none'%3e%3cpath%20fill='%23E40B1C'%20d='M34.559%2048.077c-7.413%200-13.44-6.039-13.44-13.44s6.027-13.44%2013.44-13.44%2013.44%206.027%2013.44%2013.44c0%207.414-6.027%2013.44-13.44%2013.44'/%3e%3cpath%20fill='%23fff'%20d='M39.827%2029.346c.583.583.605%201.505.05%202.06l-3.218%203.219%203.219%203.218c.555.556.532%201.48-.051%202.062-.584.583-1.506.605-2.062.05l-3.218-3.218-3.218%203.218c-.556.555-1.478.533-2.061-.05s-.606-1.506-.05-2.062l3.217-3.218-3.218-3.218c-.555-.555-.533-1.478.05-2.061.583-.584%201.507-.606%202.063-.05l3.217%203.217%203.218-3.218c.556-.555%201.478-.533%202.062.05'/%3e%3cpath%20fill='%23404756'%20d='M30.367.078c1.112%200%202.001.868%202.001%201.954v1.195h.979c4.913%200%208.892%203.887%208.892%208.686v9.237a15.4%2015.4%200%200%200-4.424-1.691v-1.312H4.468V33.63c0%202.389%202%204.343%204.446%204.343H19.4a15.4%2015.4%200%200%200%201.676%204.343H8.892C3.979%2042.317%200%2038.43%200%2033.631V11.913c0-4.8%203.979-8.686%208.892-8.686h1V2.032c0-1.086.89-1.954%202.002-1.954s2%20.868%202%201.954v1.195h14.473V2.032c0-1.085.889-1.954%202-1.954'/%3e%3c/svg%3e",A3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23fff'%20d='M20.36%204.14H16c0-1.65-1.35-3-3-3h-2c-1.65%200-3%201.35-3%203H3.64c-.55%200-1%20.45-1%201s.45%201%201%201h1.04l.84%2013.91a3%203%200%200%200%202.99%202.82h6.98c1.58%200%202.9-1.24%203-2.82l.84-13.91h1.04c.55%200%201-.45%201-1s-.45-1-1-1zm-9.36-1h2c.55%200%201%20.45%201%201h-4c0-.55.45-1%201-1m-.39%2014.9c0%20.55-.45%201-1%201s-1-.45-1-1V9.99c0-.55.45-1%201-1s1%20.45%201%201zm4.78%200c0%20.55-.45%201-1%201s-1-.45-1-1V9.99c0-.55.45-1%201-1s1%20.45%201%201z'/%3e%3c/svg%3e",k3=({open:e,onClose:r,onConfirm:t,title:n,description:o,icon:a,confirmText:s,confirmColor:i="#d32f2f",loading:l=!1})=>c.jsxs(m.Dialog,{open:e,onClose:r,PaperProps:{sx:{borderRadius:"15px",p:1,maxWidth:"400px"}},children:[c.jsx(m.Box,{sx:{display:"flex",justifyContent:"flex-end"},children:c.jsx(m.IconButton,{onClick:r,size:"small",children:c.jsx(Er,{fontSize:"small"})})}),c.jsxs(m.DialogContent,{sx:{textAlign:"center",pt:0},children:[c.jsx(m.Box,{sx:{mb:2,display:"flex",justifyContent:"center"},children:a}),c.jsx(m.Typography,{variant:"h6",sx:{fontWeight:"bold",mb:2},children:n}),c.jsx(m.Typography,{variant:"body2",sx:{color:"#555",mb:4,px:2},children:o}),c.jsxs(m.Box,{sx:{display:"flex",gap:2,justifyContent:"center",mb:2},children:[c.jsx(m.Button,{variant:"outlined",onClick:r,sx:{textTransform:"none",borderRadius:"8px",px:4,borderColor:"#1976D2",color:"#1976D2"},children:"Regresar"}),c.jsxs(m.Button,{variant:"contained",onClick:t,disabled:l,sx:{textTransform:"none",borderRadius:"8px",px:4,bgcolor:i,"&:hover":{bgcolor:"#b71c1c"}},children:[s=="Eliminar"&&c.jsx("img",{src:A3,width:15,style:{marginRight:6,marginBottom:2}}),l?"Procesando...":s]})]})]})]}),ai=(e,r)=>{if(!e||!r)return null;const t=r.toLowerCase().replace(/\s/g,"").replace(/\./g,""),n=t.includes("pm"),o=t.includes("am"),a=t.replace(/[a-z]/g,""),[s,i]=a.split(":");if(!s||!i)return null;let l=parseInt(s,10);const d=parseInt(i,10);n&&l<12&&(l+=12),o&&l===12&&(l=0);const[u,f,h]=e.split("-").map(Number),g=new Date(u,f-1,h,l,d);return x.isValid(g)?g:null},T3=({userId:e,leads30Days:r,leads90Days:t,disId:n,masNombreBD:o,usrNombre:a})=>{const[s,i]=b.useState(new Date),[l,d]=b.useState([]),[u,f]=b.useState(!1),[h,g]=b.useState(null),[v,p]=b.useState(null),[y,_]=b.useState([]),{enqueueSnackbar:S}=ba.useSnackbar(),C=Nl(),E=Ts(),w=Sl(),[N,D]=b.useState(!1),[k,O]=b.useState([]),[I,q]=b.useState(null),{session:H,sessionoutlook:W}=cl(),{googleEvents:Z,setGoogleEvents:J,outlookEvents:Y,setOutlookEvents:z}=_3(),[ie,ue]=b.useState([]),[$,X]=b.useState([]),[Se,we]=b.useState([]),[_e,oe]=b.useState(!1),[le,se]=b.useState([]),[ge,De]=b.useState(),he=(re,Pe)=>{O(re),q(Pe),D(!0)},Le=async()=>{if(e===void 0||n===void 0)return;const re=await C.getNotificacionesXUsuario(e,n);a?localStorage.setItem("nombreAnfitrion",a):localStorage.setItem("nombreAnfitrion","Anfitrion"),se(re)};b.useEffect(()=>{const re=new Date,Pe=x.startOfDay(re),Ae=x.endOfDay(x.addDays(Pe,6)),ze={start:Pe,end:Ae},Yt=l.filter(tr=>{const Ir={start:tr.fechaInicio,end:tr.fechaFin};return ef(Ir,ze)}).sort((tr,Ir)=>tr.fechaInicio.getTime()-Ir.fechaInicio.getTime());_(Yt)},[l]),b.useEffect(()=>{const re=async()=>{try{if(e&&n){const Ae=await C.getEventsByUser(e,n);Le(),d(Ae)}}catch(Ae){console.log("Error al cargar eventos locales:",Ae)}};re();const Pe=setInterval(re,4e3);return()=>clearInterval(Pe)},[e]),b.useEffect(()=>{if(!n||!e)return;const re=[...l];if(Z.length>0&&H?.userEmail){const Pe=Z.map(Ae=>S3(Ae,n,e));re.push(...Pe)}if(Y.length>0&&W?.userEmail){const Pe=Y.map(Ae=>D3(Ae,n,e));re.push(...Pe)}ue(re)},[l,Z,Y,n,e,H?.userEmail,W?.userEmail]);const L=async re=>{try{if(re?.isGoogleEvent||re.isOutlookEvent)g(re),f(!0);else{const Pe=await C.getEventById(re.eventoID);g(Pe),f(!0)}}catch(Pe){console.error(Pe)}},Ne=()=>{f(!1),g(null)},lt=async(re,Pe)=>{let Ae,ze;if(re.todoElDia)Ae=ai(re.fechaInicio,re.horaInicio),ze=ai(re.fechaInicio,re.horaFin);else{Ae=ai(re.fechaInicio,re.horaInicio);const V=re.fechaFin||re.fechaInicio;ze=ai(V,re.horaFin)}if(!Ae||!ze){console.error("No se pudieron procesar las fechas. Revisa el formato de hora:",{inicio:re.horaInicio,fin:re.horaFin});return}const Yt=x.format(Ae,"yyyy-MM-dd HH:mm:ss.SSS"),tr=x.format(ze,"yyyy-MM-dd HH:mm:ss.SSS");if(Pe){const V={...re,eventoID:Pe,fechaInicio:Yt,fechaFin:tr,solID:re.solID??null,disID:n??null,client:re.client,invitados:re.invitados.map(ee=>({usrNombre:ee.nombre||ee.usrNombre,Correo:ee.correo||ee.Correo,EsOrganizador:ee.isHost||ee.EsOrganizador,StatusInvitacion:ee.StatusInvitacion,UsuarioID:ee.usrID||ee.UsuarioID,disID:ee.disID||n}))};try{const ee=await C.updateEvent(V);var Ir=l.map(Ee=>Ee.eventoID===ee.eventoID?ee:Ee);d(Ir),S("El evento se ha actualizado correctamente.",{variant:"success"}),Ne()}catch{S("Error al actualizar Evento",{variant:"error"})}}else{const V={...re,fechaInicio:Yt,fechaFin:tr,todoElDia:re.todoElDia,solID:re.solID??null,disID:n??null,client:re.client,invitados:re.invitados.map(ee=>({usrNombre:ee.nombre||ee.usrNombre,Correo:ee.correo||ee.Correo,EsOrganizador:ee.isHost||ee.EsOrganizador,StatusInvitacion:ee.StatusInvitacion,UsuarioID:ee.usrID||ee.UsuarioID,disID:ee.disID||n}))};try{const ee=await C.createEvent(V,e);d(Ee=>[...Ee,ee]),S("El evento se ha creado con éxito",{variant:"success"}),Ne()}catch{S("Error al guardar Evento",{variant:"error"})}}if(e&&n){const V=await C.getEventsByUser(e,n);d(V)}},Ze=()=>{i(re=>new Date(re.getFullYear(),re.getMonth()-1,1))},Ie=()=>{i(re=>new Date(re.getFullYear(),re.getMonth()+1,1))},ot=()=>{vt("ELIMINAR")},$e=()=>{vt("RECHAZAR")},Ce=()=>{p(new Date),f(!0)},A=re=>{re&&i(re)},P=re=>{p(re),f(!0),g(null)},U=async()=>{if(h)try{await C.deleteEvent(h.eventoID),d(l.filter(re=>re.eventoID!==h.eventoID)),S("El evento se ha eliminado de tu calendario",{content:(re,Pe)=>c.jsx(dc,{id:re,message:String(Pe),variant:"delete"})})}catch{S("Error al eliminar Evento",{variant:"error"})}finally{Ne(),Kt()}},ce=async()=>{if(!(!H?.userEmail||!n)){oe(!0);try{const Pe=(await E.getGoogleCalendars(H.userEmail,n)).map(ze=>({...ze,selected:!0}));X(Pe);const Ae=Pe.map(ze=>ze.id);de(Ae)}catch(re){console.error("Error Google Cals:",re)}finally{oe(!1)}}},ae=async re=>{const Pe=$.map(ze=>ze.id===re?{...ze,selected:!ze.selected}:ze);X(Pe);const Ae=Pe.filter(ze=>ze.selected).map(ze=>ze.id);de(Ae)},j=async()=>{if(!(!W?.userEmail||!n)){oe(!0);try{const Pe=(await w.getOutlookCalendars(W.userEmail,n)).map(ze=>({...ze,selected:!0}));we(Pe);const Ae=Pe.map(ze=>ze.id);Oe(Ae)}catch(re){console.error("Error Outlook Cals:",re)}finally{oe(!1)}}},K=async re=>{const Pe=Se.map(ze=>ze.id===re?{...ze,selected:!ze.selected}:ze);we(Pe);const Ae=Pe.filter(ze=>ze.selected).map(ze=>ze.id);Oe(Ae)};b.useEffect(()=>{ce()},[H?.userEmail,n]),b.useEffect(()=>{j()},[W?.userEmail,n]);const de=async re=>{if(!H?.userEmail||!n)return;const Pe=re||$.filter(Ae=>Ae.selected).map(Ae=>Ae.id);try{const Ae={disID:n,year:s.getFullYear(),month:s.getMonth()+1,usrMail:H.userEmail,calendarIds:Pe},ze=await E.getGoogleEventsByMonth(Ae);J(ze)}catch(Ae){console.error("Error al obtener eventos de Google:",Ae)}},Oe=async re=>{if(!W?.userEmail||!n)return;const Pe=re||Se.filter(Ae=>Ae.selected).map(Ae=>Ae.id);try{const Ae={disID:n,year:s.getFullYear(),month:s.getMonth()+1,usrMail:W.userEmail,calendarIds:Pe},ze=await w.getOutlookEventsByMonth(Ae);z(ze)}catch(Ae){console.error("Error al obtener eventos de Outlook:",Ae)}};if(n===void 0||e===void 0)return c.jsx("div",{children:"Cargando configuración de usuario..."});const R=async(re,Pe)=>{await C.UpdateStatusEvento(re.evento.eventoID,e,Pe)&&(await C.MarcarLeido(re.notificacionID,e),S(re?.evento?.titulo+" fue agregado a tu calendario",{variant:"success"}))},te=async()=>{ge&&C.UpdateStatusEvento(ge.evento.eventoID,e,"RECHAZADA")&&(await C.MarcarLeido(ge.notificacionID,e),await C.MarcarLeido(ge.notificacionID,e),S("Haz rechazado la Invitación a "+ge?.evento?.titulo,{content:(Pe,Ae)=>c.jsx(dc,{id:Pe,message:String(Ae),variant:"rechazar"})}),Kt())},xe=async(re,Pe)=>{try{if(!e)return;De(re),Pe=="RECHAZADA"?($e(),console.log("noti",re)):R(re,Pe)}catch{S("Error al procesar la invitación",{variant:"error"})}},qe=async re=>{try{if(!h)return;await C.ReenviarNotificacion(h?.eventoID,re),S("Invitación enviada con éxito",{variant:"success"})}catch(Pe){console.error("Error al conectar con la API",Pe)}},[gt,vt]=b.useState(null),Kt=()=>vt(null),er={RECHAZAR:{title:"Rechazar invitación",confirmText:"Rechazar evento",description:c.jsxs(c.Fragment,{children:["Estás a punto de declinar la invitación de ",c.jsx("strong",{children:ge?.evento?.nombreAnfitrion})," a ",c.jsx("strong",{children:ge?.evento?.titulo})]}),icon:c.jsx("img",{src:v0}),action:()=>ge&&te()},ELIMINAR:{title:"Eliminar evento",confirmText:"Eliminar",description:"¿De verdad deseas eliminar este evento? Esta acción no se puede deshacer.",icon:c.jsx("img",{src:v0}),action:()=>U()},DESVINCULAR:{title:"Desvincular Outlook",confirmText:"Desvincular",description:"Si desvinculas tu cuenta, perderás acceso a todos los eventos sincronizados.",icon:"",action:()=>U}},Qt=gt?er[gt]:null;return c.jsxs("div",{id:"Agenda",style:{height:"100%",width:"100%"},children:[c.jsx(Ry,{header:c.jsx(eb,{currentDate:s,onPrevMonth:Ze,onNextMonth:Ie,onAddEvent:Ce,onDateChange:A}),sidebar:c.jsx(Qw,{onEventClick:L,upcomingEvents:y,leads30Days:r,leads90Days:t,disID:n,usrID:e,onAddEvent:Ce,googleCalendars:$,outlookCalendars:Se,isLoadingCalendars:_e,onToggleGoogle:ae,onToggleOutlook:K,notifications:le,unreadCount:le?.filter(re=>!re.leida).length,onAceppInvitacion:xe}),mainContent:c.jsx(d_,{onSeeMoreClick:he,currentDate:s,events:ie,onDayClick:P,onEventClick:L})}),u&&c.jsx(u3,{isVisible:u,onClose:Ne,onSave:lt,onDelete:ot,selectedDate:v,initialEvent:h,userId:e,masNombreBD:o,disId:n,gmail:"llopez@exagono.net",onReenviar:qe}),c.jsx(f3,{isOpen:N,onClose:()=>D(!1),events:k,date:I,onEventClick:L}),Qt&&c.jsx(k3,{open:!!gt,onClose:Kt,onConfirm:()=>{Qt.action()},title:Qt.title,description:Qt.description,icon:Qt.icon,confirmText:Qt.confirmText})]})},M3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20fill='%23070c10'%20d='M18.575%203.172A10.829%2010.829%200%200%200%201.564%2016.284l-.028-.051L0%2021.843l5.739-1.506a10.7%2010.7%200%200%200%205.173%201.318%2010.83%2010.83%200%200%200%207.663-18.483m-7.658%2016.655a8.94%208.94%200%200%201-4.62-1.277l.041.023-.329-.194-3.405.894.908-3.321-.214-.34a8.9%208.9%200%200%201-1.376-4.782%209%209%200%201%201%209%209Zm4.935-6.736c-.27-.135-1.6-.789-1.848-.88s-.429-.135-.61.136-.7.879-.856%201.06-.316.2-.586.068a7.5%207.5%200%200%201-2.183-1.349l.007.007a8.2%208.2%200%200%201-1.483-1.842l-.02-.038c-.157-.27-.017-.417.118-.551s.271-.316.406-.473a1.9%201.9%200%200%200%20.267-.44v-.012a.5.5%200%200%200%20.05-.216.5.5%200%200%200-.074-.26c-.068-.135-.609-1.467-.834-2.009s-.444-.455-.609-.464-.338-.009-.519-.009a.99.99%200%200%200-.72.337%203.03%203.03%200%200%200-.947%202.2v.058a5.27%205.27%200%200%200%201.114%202.815v-.011a12.16%2012.16%200%200%200%204.553%204.053l.068.031a14%2014%200%200%200%201.434.539l.109.03a3.6%203.6%200%200%200%201.077.161%203.7%203.7%200%200%200%20.648-.057h-.023a2.8%202.8%200%200%200%201.819-1.274l.007-.012a2.2%202.2%200%200%200%20.19-.9%202.3%202.3%200%200%200-.034-.395v.014c-.067-.113-.248-.18-.519-.316Z'/%3e%3c/svg%3e",I3="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='25.085'%20height='18.5'%3e%3cdefs%3e%3cclipPath%20id='a'%3e%3cpath%20fill='none'%20d='M0%200h25.085v18.5H0z'%20data-name='Rectángulo%204598'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23a)'%20data-name='Grupo%207946'%3e%3cpath%20d='M23.12%205.809V3.226a3.2%203.2%200%200%200-.068-.656l-3.141%202.21a7.8%207.8%200%200%201%203.209%201.032'%20data-name='Trazado%2013329'/%3e%3cpath%20d='M11.847%209.791c-.1.009-.2.023-.308.023a3.78%203.78%200%200%201-2.18-.688L.067%202.58A3.2%203.2%200%200%200%200%203.227V13.98a3.23%203.23%200%200%200%203.226%203.226h9.611a7.86%207.86%200%200%201-.99-7.414'%20data-name='Trazado%2013330'/%3e%3cpath%20d='M12.478%207.369%2021.92.737A3.2%203.2%200%200%200%2019.894%200H3.226a3.2%203.2%200%200%200-2.031.74l9.4%206.628a1.64%201.64%200%200%200%201.881%200'%20data-name='Trazado%2013331'/%3e%3cpath%20d='M23.356%208.407a5.914%205.914%200%201%200%200%208.364%205.92%205.92%200%200%200%200-8.364m-1.833%204.842a.54.54%200%200%201-1.081%200v-1.164l-2.513%202.516a.54.54%200%200%201-.765-.763l2.515-2.515h-1.167a.54.54%200%201%201%200-1.081h2.471a.54.54%200%200%201%20.54.54Z'%20data-name='Trazado%2013332'/%3e%3c/g%3e%3c/svg%3e";function fc(e,r,t){return e.accessor?e.accessor(r,t):e.field?r?.[e.field]:r?.[e?.key||""]}function O3(e,r){const t=e??"",n=r??"";return t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():typeof t=="number"&&typeof n=="number"?t-n:typeof t=="boolean"&&typeof n=="boolean"?Number(t)-Number(n):String(t).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}function pc(e,r,t=!0){return typeof e=="function"?e(r):e??t}function P3(e){return e.replace(/[^\d]/g,"")}function j3(e,r){return r}var la={},y0;function R3(){if(y0)return la;y0=1;var e=st();Object.defineProperty(la,"__esModule",{value:!0}),la.default=void 0;var r=e(pt()),t=ut();return la.default=(0,r.default)((0,t.jsx)("path",{d:"M4.25 5.61C6.27 8.2 10 13 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-6s3.72-4.8 5.74-7.39c.51-.66.04-1.61-.79-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAlt"),la}var N3=R3();const L3=at(N3);var ca={},b0;function $3(){if(b0)return ca;b0=1;var e=st();Object.defineProperty(ca,"__esModule",{value:!0}),ca.default=void 0;var r=e(pt()),t=ut();return ca.default=(0,r.default)((0,t.jsx)("path",{d:"M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"SearchRounded"),ca}var z3=$3();const B3=at(z3);var ua={},x0;function F3(){if(x0)return ua;x0=1;var e=st();Object.defineProperty(ua,"__esModule",{value:!0}),ua.default=void 0;var r=e(pt()),t=ut();return ua.default=(0,r.default)((0,t.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown"),ua}var U3=F3();const W3=at(U3);var da={},w0;function V3(){if(w0)return da;w0=1;var e=st();Object.defineProperty(da,"__esModule",{value:!0}),da.default=void 0;var r=e(pt()),t=ut();return da.default=(0,r.default)((0,t.jsx)("path",{d:"M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp"),da}var H3=V3();const Y3=at(H3);function _0(e){return e==="right"?"end":e==="center"?"center":"start"}function S0(e){const r=e.filter(t=>!t.width).length||1;return e.map(t=>typeof t.width=="number"?`${t.width}px`:typeof t.width=="string"?t.width:`minmax(0, ${1/r}fr)`).join(" ")}const q3=1060,hc=(e,r)=>e.metrics.find(t=>String(t.label).toLowerCase()===r.toLowerCase())?.value??"";function Z3({sections:e,detailColumns:r,summaryWidths:t=["1fr",120,120,150],minWidth:n=q3,getDetailColumns:o,onRowClick:a}){function l(u){if(typeof u=="number")return u;if(!u)return 0;const f=/^(\d+)\s*px$/.exec(u.trim());return f?Number(f[1]):/fr$/i.test(u)?160:0}function d(u){const f=u.reduce((v,p)=>v+l(p.width),0),h=Math.max(u.length-1,0)*16;return f+h+32}return c.jsx(m.Box,{sx:{border:"1px solid rgba(0,0,0,0.15)",overflow:"hidden",bgcolor:"background.paper",width:"100%"},children:c.jsxs(m.Box,{children:[c.jsx(m.Box,{sx:{display:"grid",gridTemplateColumns:t.map(u=>typeof u=="number"?`${u}px`:u).join(" "),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:"#1E5BCE",color:"#fff",boxSizing:"border-box"},children:["Tipo","En Proceso","Finalizadas","Último seg."].map(u=>c.jsx(m.Typography,{sx:{fontSize:13,fontWeight:800},children:u},u))}),e.map((u,f)=>{const[h,g]=M.useState(!!u.initiallyOpen),v=f%2===1,p=o?o(u):r,y=Math.max(n,d(p));return c.jsxs(m.Box,{children:[c.jsxs(m.Box,{sx:{display:"grid",gridTemplateColumns:t.map(_=>typeof _=="number"?`${_}px`:_).join(" "),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:v?"rgba(30,91,206,0.06)":"background.paper",borderTop:"1px solid rgba(0,0,0,0.08)","&:hover":{bgcolor:"rgba(30,91,206,0.12)"},boxSizing:"border-box",cursor:"pointer"},onClick:()=>g(_=>!_),children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[c.jsx(m.IconButton,{size:"small",disableRipple:!0,children:h?c.jsx(Y3,{}):c.jsx(W3,{})}),c.jsx(m.Typography,{sx:{fontWeight:700,fontSize:14,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(u.title),children:u.title})]}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"En Proceso")}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"Finalizadas")}),c.jsx(m.Typography,{sx:{fontSize:13.5,fontWeight:800},children:hc(u,"Último seg.")})]}),c.jsx(m.Collapse,{in:h,unmountOnExit:!0,children:c.jsxs(m.Box,{sx:{overflowX:"auto","&::-webkit-scrollbar":{height:"5px"}},children:[c.jsx(m.Box,{sx:{minWidth:y,display:"grid",gridTemplateColumns:S0(p),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:"rgba(30,91,206,0.18)",color:"#1a1a1a",borderTop:"1px solid rgba(0,0,0,0.12)",boxSizing:"border-box"},children:p.map(_=>c.jsx(m.Typography,{sx:{justifySelf:_0(_.align),textAlign:_.align??"left",fontSize:12.5,fontWeight:800,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.header},_.key))}),(u.rows??[]).map((_,S)=>c.jsx(m.Box,{sx:{minWidth:y,display:"grid",gridTemplateColumns:S0(p),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:S%2===0?"background.paper":"rgba(30,91,206,0.06)",borderTop:"1px solid rgba(0,0,0,0.06)","&:hover":{bgcolor:"rgba(30,91,206,0.12)"},boxSizing:"border-box",cursor:"pointer"},onClick:()=>a?.(_,u),children:p.map((C,E)=>{const w=C.accessor?C.accessor(_,S):C.field?_[C.field]:null;return c.jsx(m.Box,{sx:{justifySelf:_0(C.align),textAlign:C.align??"left",minWidth:0,overflow:"hidden",maxWidth:"100%"},children:typeof w=="string"||typeof w=="number"?c.jsx(m.Typography,{sx:{fontSize:13,fontWeight:/^(estatus|seg|avance|nivel|asesor|fecha)$/i.test(C.key)?700:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(w),children:w}):w},C.key??E)})},_.id??S))]})})]},u.id)})]})})}var fa={},C0;function G3(){if(C0)return fa;C0=1;var e=st();Object.defineProperty(fa,"__esModule",{value:!0}),fa.default=void 0;var r=e(pt()),t=ut();return fa.default=(0,r.default)((0,t.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m3.3 14.71L11 12.41V7h2v4.59l3.71 3.71z"}),"AccessTimeFilled"),fa}var K3=G3();const Q3=at(K3),J3=e=>e?new Date(e).toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}).replace(".",""):"",X3=e=>{const r=`${e?.Nombre??""} ${e?.Apellido??""}`.trim();return r||(e?.IdAsesor?e?.Correo??"Usuario":"Sin asesor asignado")},e5=e=>{const r=(e||"").split(" ").filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():(e?.[0]??"?").toUpperCase()};var pa={},E0;function t5(){if(E0)return pa;E0=1;var e=st();Object.defineProperty(pa,"__esModule",{value:!0}),pa.default=void 0;var r=e(pt()),t=ut();return pa.default=(0,r.default)((0,t.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Create"),pa}var r5=t5();const n5=at(r5),mc=({current:e=0,total:r=0,color:t="#4caf50"})=>c.jsx("div",{style:{display:"flex",gap:"1px",width:"100%",height:"100%",justifyContent:"center",overflow:"hidden",minWidth:0},children:Array.from({length:r}).map((n,o)=>c.jsx("div",{style:{width:"7px",height:"7px",borderRadius:"2px",backgroundColor:o<e?t:"#e0e0e0",display:"flex"}},o))});var ha={},D0;function o5(){if(D0)return ha;D0=1;var e=st();Object.defineProperty(ha,"__esModule",{value:!0}),ha.default=void 0;var r=e(pt()),t=ut();return ha.default=(0,r.default)((0,t.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),ha}var a5=o5();const A0=at(a5);var ma={},k0;function s5(){if(k0)return ma;k0=1;var e=st();Object.defineProperty(ma,"__esModule",{value:!0}),ma.default=void 0;var r=e(pt()),t=ut();return ma.default=(0,r.default)((0,t.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack"),ma}var i5=s5();const l5=at(i5),c5=e=>{const r=String(e??"").toLowerCase().trim();return r==="muy interesado"?{bg:"#E53935",color:"#FFFFFF"}:r==="interesado"?{bg:"#FB8C00",color:"#FFFFFF"}:r==="venta definitiva"?{bg:"#2E7D32",color:"#FFFFFF"}:r==="no sé"||r==="no se"?{bg:"#9E9E9E",color:"#FFFFFF"}:r==="algo interesado"?{bg:"#FFEB3B",color:"#000000"}:{bg:"transparent",color:"#2c2c2c"}},u5=e=>{switch(parseInt(String(e??""),10)){case 1:return"Por Asignar";case 2:return"Solicitud Asignada";case 3:return"Solicitud asignada en proceso";case 4:return"Finalizadas sin Venta";case 5:return"Finalizadas con Venta";case 6:return"Rechazadas";case 7:return"Finalizada por sistema";case 8:return"";case 9:return"";case 10:return"Prospección";case 11:return"Interés Real";case 12:return"Proceso de Compra";case 13:return"";case 14:return"En espera de Unidad";case 15:return"Auto Facturado";case 16:return"";case 17:return"";case 18:return"Compró otra Marca";case 19:return"No comprará";default:return null}},d5=e=>{switch(parseInt(String(e??""),10)){case 1:return"Por asignar";case 2:return"Solicitud Asignada";case 3:return"En seguimiento";case 6:return"Rechazada";case 7:return"Finalizada sin enviar a Ventas";case 8:return"Finalizada enviado a Ventas";default:return null}},f5=e=>{switch(parseInt(String(e??""),10)){case 0:return"Sin asignar";case 1:return"Confirmado";case 2:return"Solicitud Asignada";case 3:return"En seguimiento";case 4:return"Confirmado";case 5:return"Finalizada";case 6:return"Rechazada";case 10:return"Reagendado";case 20:return"Seguimiento [Cita Finalizada]";case 30:return"Reenvio";case 40:return"Seguimiento [Mecanico]";case 50:return"Seguimiento";default:return null}};function p5(e){const r=new Date(e),t=r.toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}),n=r.toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"});return`${t.replace(".","")} • ${n}`}function h5(e){return e.replace(/<br\s*\/?>/gi,`
189
189
  `).replace(/\r\n/g,`
190
190
  `).replace(/\r/g,`
191
191
  `)}const m5={Todos:[],"Sin Asignar":["Sin Asignar"],"En prospección":["Prospección"],"Proceso de Compra":["Proceso de Compra"],"En espera de Unidad":["En Espera de Unidad"],"Auto Facturado":["Auto Facturado"],Rechazadas:["Rechazada","Rechazadas"],"Finalizadas sin Venta":["Sin Venta"],"Finalizadas con Venta":["Con Venta"],"En Proceso":["Asignada","Prospección","Sin Asignar","Proceso de Compra","En Espera de Unidad","Auto Facturado","Sin Atender"]},g5={Todos:[],"Selección y presentación de vehículos":["Selección y presentación de vehículos"],"Prueba de Manejo":["Prueba de Manejo"],"Valoración del Auto a cuenta y/o enganche":["Valoración del Auto a cuenta y/o enganche"],"Entrega de vehículo":["Entrega de vehículo"],"Negociación y Cierre":["Negociación y Cierre"]},v5={Todos:[],"Algo interesado":["Algo interesado"],Interesado:["Interesado"],"Muy interesado":["Muy interesado"],"Venta definitiva":["Venta definitiva"],"No sé":["No sé"]};function y5(e,r){switch(e){case"pruebas":return d5(r)??"—";case"servicio":return f5(r)??"—";case"nuevos":case"seminuevos":default:return u5(r)??"—"}}function b5({open:e,onClose:r,customer:t,fields:n=[],header:o,extraSections:a,normalTable:s,normalTableColumns:i=[],history:l=[],advisorHistory:d=[],onRequestEdit:u,searchFilter:f,urlsQA:h,solicitudesNuevos:g=[],solicitudesPrueba:v=[],solicitudesServicio:p=[],solicitudesSeminuevos:y=[],onCreateSolicitud:_,isCrmMode:S=!1,onSolicitudBaseUrl:C,onIframeClose:E,reloadInfo:w,idAdminSistemas:N}){if(!t)return null;const D=3,[k,O]=b.useState(null),I=!!k,[q,H]=b.useState(!1),[W,Z]=b.useState(null),[J,Y]=b.useState(l??[]),[z,ie]=b.useState(null),ue=b.useMemo(()=>[...d].sort((B,Q)=>new Date(Q.FechaAsignacion).getTime()-new Date(B.FechaAsignacion).getTime()),[d]);b.useEffect(()=>{l&&l.length&&Y(l)},[l]);const $=l?.length?l:J,X=o?.title??(B=>B?.Nombre||B?.name||"Sin título"),Se=o?.infoItems??[],we=B=>B.nombreAsesor?.trim()||(B.Email?B.Email:"Sistema"),_e=B=>{const Q=B||"",ye=Q.split(" ").filter(Boolean);return ye.length>=2?(ye[0][0]+ye[1][0]).toUpperCase():(Q[0]||"?").toUpperCase()},oe=B=>B?.SolID??B?.solID??B?.SolId??B?.SOLID??null,le=b.useMemo(()=>{const B=$??[];return Array.isArray(B?.[0])?B.flat():B},[$]),se=b.useMemo(()=>{const B=le;return!z||W==null?B:B.filter(Q=>{const ye=oe(Q);return ye!=null&&String(ye)===String(W)})},[le,z,W]),ge=b.useMemo(()=>[...se].sort((B,Q)=>new Date(Q.fecAlta).getTime()-new Date(B.fecAlta).getTime()),[se]),[De,he]=b.useState(!1),Le=b.useMemo(()=>De?ge:ge.slice(0,D),[De,ge]),L=Math.max(ge.length-D,0),Ne=B=>String(B??"").normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase().trim(),lt=(B,Q)=>Ne(JSON.stringify(B)).includes(Ne(Q)),Ze=(B,Q)=>f?f(B,Q):lt(B,Q),Ie=(B,Q)=>{const ye=Ne(Q).split(/\s+/).filter(Boolean);return ye.length?ye.every(Me=>Ze(B,Me)):!0},[ot,$e]=b.useState(""),[Ce,A]=b.useState([]);b.useMemo(()=>s??[],[s]),b.useMemo(()=>{const B=ot.trim();return B?(s??[]).filter(Q=>Ie(Q,B)):s??[]},[s,ot]);const P=m.useTheme(),U=m.useMediaQuery(P.breakpoints.down("md")),[ce,ae]=b.useState(""),[j,K]=b.useState(!0),[de,Oe]=b.useState(!1),R=new Date().toISOString().slice(0,10),te=new Date(Date.now()-720*3600*1e3).toISOString().slice(0,10),[xe,qe]=b.useState(te),[gt,vt]=b.useState(R),[Kt,er]=b.useState(null),Qt=!!Kt,[re,Pe]=b.useState("En Proceso"),[Ae,ze]=b.useState("Todos"),[Yt,tr]=b.useState("Todos"),Ir=["Algo interesado","Interesado","Muy interesado","Venta definitiva","No sé"],V=["Selección y presentación de vehículos","Prueba de Manejo","Valoración del Auto a cuenta y/o enganche","Entrega de vehículo","Negociación y Cierre"],ee=()=>{ae(""),K(!1),Oe(!1),qe(te),vt(R),Pe("Todos"),ze("Todos"),tr("Todos")},Ee=b.useMemo(()=>(ce??"").trim()!==""||re!=="Todos"||Ae!=="Todos"||j||de||Yt!=="Todos",[ce,re,Ae,j,de,Yt]);function fe(B){if(!B)return"";const Q=new Date(B);if(isNaN(Q.getTime()))return"";const ye=String(Q.getDate()).padStart(2,"0"),Me=String(Q.getMonth()+1).padStart(2,"0"),At=String(Q.getFullYear()).slice(-2);return`${ye}/${Me}/${At}`}function je(B){const Q=B?new Date(B):null;return Q&&!isNaN(Q.getTime())?Q:null}function Ue(B,Q){let ye=null;for(const Me of B){const At=je(Q(Me));if(At){const Ct=At.getTime();(ye===null||Ct>ye)&&(ye=Ct)}}return ye?new Date(ye):null}function yt(B){const Q=Ue(B,ye=>ye.UltimoSeguimiento||ye.FechaCita);return Q?fe(Q.toISOString()):"—"}function ir(B){const Q=(B??"").toLowerCase().trim();return Q==="sin venta"||Q==="con venta"||Q==="rechazada"||Q==="rechazadas"}function Or(B){return B.filter(Q=>ir(Q.EstatusDescripcion)).length}function rn(B){return B.filter(Q=>!ir(Q.EstatusDescripcion)).length}const bc=({progress:B,color:Q})=>{if(!B)return c.jsx(mc,{current:0,total:0,color:Q});const ye=B.split("/").map(Number);if(ye.length!==2||ye.some(Ct=>Number.isNaN(Ct)))return c.jsx(mc,{current:0,total:0,color:Q});const[Me,At]=ye;return c.jsx(mc,{current:Me,total:At,color:Q})};function ii(B){return[{key:"fecha",header:"Fecha",accessor:Q=>fe(Q.Fecha),width:110},{key:"vehiculo",header:"Vehículo",accessor:Q=>c.jsx(m.Tooltip,{title:Q.Vehiculo??"",placement:"top",arrow:!0,children:c.jsx(m.Typography,{component:"span",sx:{fontSize:13,fontWeight:500,display:"block",maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3,cursor:"default"},children:Q.Vehiculo??"—"})}),width:260},{key:"estatus",header:"Estatus",accessor:Q=>c.jsx(m.Typography,{sx:{fontWeight:800,fontSize:13},children:y5(B,Q.IdEstatus)}),width:170},{key:"nivel",header:"Nivel de Interés",accessor:Q=>{const{bg:ye,color:Me}=c5(Q.NivelInteres);return c.jsx(m.Box,{sx:{display:"inline-block",px:1,py:.25,borderRadius:9999,bgcolor:ye,color:Me,fontSize:12,fontWeight:Q.NivelInteres?800:500},children:Q.NivelInteres??"—"})},width:150},{key:"asesor",header:"Asesor",accessor:Q=>{const ye=(Q.Asesor??"").trim(),Me=xc=>{if(!xc)return"";const W5=xc[0]?.toUpperCase()??"",V5=xc[1]?.toLowerCase()??"";return`${W5}${V5}`};if(!ye)return c.jsx(m.Tooltip,{title:"",placement:"top",children:c.jsx(m.Typography,{sx:{fontWeight:700,fontSize:13,textAlign:"center"},children:"—"})});const At=ye.split(/\s+/),Ct=At[0]??"",Pr=At[1]??"",xr=Me(Ct),In=Me(Pr),U5=`${xr}${In}`||"—";return c.jsx(m.Tooltip,{title:ye,placement:"top",children:c.jsx(m.Typography,{sx:{fontWeight:700,fontSize:13,textAlign:"center"},children:U5})})},width:120,align:"center"},{key:"origen",header:"Origen",accessor:Q=>Q.Origen??"—",width:120,align:"center"},{key:"actividad",header:"Actividad",accessor:Q=>c.jsx(m.Tooltip,{title:Q.Actividad??"",placement:"top",arrow:!0,children:c.jsxs(m.Box,{sx:{maxWidth:160,overflow:"hidden",display:"flex",gap:.5,alignItems:"center"},children:[Q.Icon&&c.jsx("span",{style:{color:"#fff",backgroundColor:Q.Color,borderRadius:100,alignItems:"center",justifyContent:"center",display:"flex",padding:3},children:c.jsx("i",{className:Q.Icon})}),c.jsx(m.Typography,{component:"span",noWrap:!0,sx:{fontSize:13,fontWeight:500,display:"block",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3,cursor:(Q.Actividad??"").length?"default":"inherit"},children:Q.Actividad??"—"})]})}),width:180},{key:"avance",header:"Avance",accessor:Q=>c.jsx(bc,{progress:Q.Avance,color:Q.Color}),width:200,align:"left"}]}function T(B){const ye=ii(B).slice(1);return[{key:"fecha",header:"Fecha",accessor:Me=>fe(Me.Fecha),width:110},{key:"fechaCita",header:"Fecha Cita",accessor:Me=>fe(Me.FechaCita),width:120},{key:"horaCita",header:"Hora Cita",accessor:Me=>Me.HoraCita??"—",width:110},...ye]}function ne(B){const Q=B.kind;switch(Q){case"pruebas":case"servicio":return T(Q);case"nuevos":case"seminuevos":default:return ii(Q)}}function ve(B,Q,ye,Me){return{id:B,kind:ye,title:Q,metrics:[{label:"En Proceso",value:rn(Me)},{label:"Finalizadas",value:Or(Me)},{label:"Último seg.",value:yt(Me)}],rows:Me,initiallyOpen:!1}}const Re=[ve("n-1","Cotización de nuevos","nuevos",g),ve("p-1","Prueba de Manejo","pruebas",v),ve("s-1","Cita de Servicio","servicio",p),ve("sn-1","Cotización para Seminuevos","seminuevos",y)],Ge=b.useMemo(()=>{const B=(ce??"").trim().toLowerCase(),Q=(ye,Me)=>{if(B&&!(ye.Vehiculo??"").toLowerCase().includes(B))return!1;const At=de?ye.FechaCita:ye.Fecha;if(j&&At){const Ct=je(At??"");if(!Ct)return!1;const Pr=xe?new Date(`${xe}T00:00:00`):null,xr=gt?new Date(`${gt}T00:00:00`):null;if(xr&&xr.setDate(xr.getDate()+1),Pr&&Ct<Pr||xr&&Ct>=xr)return!1}if(re!=="Todos"){const Ct=(ye.EstatusDescripcion??"").toLowerCase();if(!(m5[re]??[]).some(In=>Ct===In.toLowerCase()))return!1}if(Ae!=="Todos"){const Ct=(ye.Actividad??"").toLowerCase();if(!(g5[Ae]??[]).some(In=>Ct===In.toLowerCase()))return!1}if(Yt!=="Todos"){const Ct=(ye.NivelInteres??"").toLowerCase();if(!(v5[Yt]??[]).some(In=>Ct===In.toLowerCase()))return!1}return!0};return Re.map(ye=>{const Me=(ye.rows??[]).filter(Ct=>Q(Ct,ye.kind)),At=[{label:"En Proceso",value:rn(Me)},{label:"Finalizadas",value:Or(Me)},{label:"Último seg.",value:yt(Me)}];return{...ye,rows:Me,metrics:At}})},[Re,ce,j,xe,gt,de,re,Ae,Yt]),ct={nuevos:"cotizaciones",pruebas:"pruebademanejo",servicio:"citasservicio",seminuevos:"seminuevos"},Ye=(B,Q)=>{const ye=B.SolID;if(!ye)return;const Me=Q.kind,At=ct[Me]??"cotizaciones",Ct=h?`https://qa2.crm.netcar.com.mx/netcar/${At}/${ye}`:`https://crmxs.netcar.com.mx/netcar/${At}/${ye}`,Pr=C?.({row:B,section:Q,slug:At,solId:ye,baseUrl:Ct});if(!S){const xr=Pr??Ct;Z(ye),ie(xr),H(!0)}},We=()=>{E?.(t),Z(null),ie(null),H(!1)},Ft=b.useRef(!1),ht=b.useRef(null),It=b.useCallback(()=>{if(!Ft.current){Ft.current=!0;return}ht.current&&window.clearTimeout(ht.current),ht.current=window.setTimeout(()=>{w?.(t)},500)},[w,t]);return b.useEffect(()=>{Ft.current=!1,ht.current&&window.clearTimeout(ht.current)},[z,W]),c.jsx(m.Dialog,{open:e,onClose:r,fullWidth:!0,fullScreen:U,PaperProps:{sx:{height:{xs:"100dvh",md:"90vh"},maxWidth:{xs:"100vw",md:"92vw"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:c.jsxs(m.Box,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},height:"100%",minHeight:0,overflow:"auto",position:"relative"},children:[c.jsxs(m.Box,{sx:{width:{xs:"100%",md:405},maxWidth:{xs:"100%",md:405},bgcolor:{xs:"transparent",md:"#40404024"},display:"flex",flexDirection:"column",height:{xs:"auto",md:"100%"},borderRight:{xs:"none",md:"1px solid #EBEEF0"}},children:[c.jsxs(m.Box,{children:[c.jsx(m.Stack,{direction:"row",spacing:2,alignItems:"center",mb:1,sx:{px:2.5,pt:2.5},children:c.jsxs(m.Box,{display:"flex",flexDirection:"column",gap:1,width:"100%",children:[c.jsx(m.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",alignItems:"center",children:c.jsx(m.Box,{sx:{flex:1,minWidth:0,pr:1},children:c.jsxs(m.Typography,{component:"span",fontWeight:700,sx:{display:"inline",lineHeight:1.2,wordBreak:"break-word",pr:.5},children:[X(t)," ",c.jsx(m.IconButton,{component:"span",size:"small",disableRipple:!0,onClick:()=>{r?.(),t&&u?.(t)},sx:{p:0,ml:.5,verticalAlign:"text-bottom",color:"#336BE1","&:hover":{bgcolor:"transparent"},"&:focus-visible":{outline:"none"}},"aria-label":"Editar nombre",children:c.jsx(n5,{sx:{fontSize:"1em"}})})]})})}),Se.map((B,Q)=>c.jsxs(m.Box,{sx:{display:"flex",gap:1.2,alignItems:"center",cursor:B.onClick?"pointer":"default"},onClick:()=>{B.onClick&&B.onClick(t)},children:[B.icon,c.jsx(m.Typography,{variant:"body2",sx:{color:B.inLink?"#336BE1":"#070C10"},style:{},children:B.value(t)})]},Q))]})}),c.jsx(m.Stack,{mb:2,sx:{px:2.5,pt:0,gap:2},children:n.map((B,Q)=>{const ye=B.label?.toLowerCase().startsWith("asesor");return c.jsxs(m.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[c.jsx(m.Box,{sx:{width:"50%"},children:c.jsx(m.Typography,{variant:"body2",color:"text.secondary",sx:{color:"#5C6372"},children:B.label})}),c.jsxs(m.Box,{sx:{width:"50%",display:"flex",alignItems:"center",gap:1},children:[c.jsx("div",{children:B?.avatar?B.avatar(t):null}),c.jsx(m.Typography,{variant:"body2",color:"textPrimary",children:B?.value(t)}),ye&&!N&&c.jsx(m.Tooltip,{title:"Historial asesores",placement:"top",arrow:!0,children:c.jsx(m.IconButton,{size:"small",onClick:Me=>O(Me.currentTarget),sx:{ml:.5},disableRipple:!0,children:c.jsx(Q3,{fontSize:"small",sx:{color:"#5C6372"}})})})]})]},Q)})}),c.jsx(m.Divider,{sx:{my:2}})]}),c.jsx(m.Box,{px:2.5,pb:.5,children:c.jsxs(m.Typography,{children:[c.jsx("span",{style:{fontWeight:800},children:"Última actividad"}),!z&&" por solicitud",":"]})}),c.jsxs(m.Box,{sx:{px:2.5,pt:0,gap:2,flex:1,overflowY:"auto",display:"flex",flexDirection:"column",pb:6,maxHeight:{xs:"140px",md:"100%"}},children:[Le.length===0&&c.jsx(m.Typography,{variant:"body2",color:"text.secondary",children:"Sin actividad registrada."}),c.jsxs(m.Box,{children:[Le?.map((B,Q)=>{const ye=we(B),Me=h5(B.comentario||"");return c.jsxs(m.Box,{sx:{pb:1.5},children:[c.jsxs(m.Stack,{direction:"row",spacing:1,alignItems:"center",justifyContent:"space-between",sx:{mb:.75},children:[c.jsx(m.Typography,{variant:"subtitle2",sx:{color:"#5C6372"},children:B.tipo||"Evento"}),c.jsx(m.Chip,{size:"small",label:B.auto!=null?`${B.auto}`:"—",sx:{bgcolor:"#336be1",color:"#fff",height:20}})]}),Me?c.jsx(m.Typography,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line",lineHeight:1.5,mb:.75},children:Me}):null,c.jsxs(m.Stack,{direction:"row",spacing:1.25,alignItems:"center",children:[B?.ImgAsesor!=null?c.jsx(m.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},alt:_e(ye),src:B?.ImgAsesor}):c.jsx(m.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},children:_e(ye)}),c.jsxs(m.Stack,{spacing:0,children:[c.jsx(m.Typography,{variant:"body2",fontWeight:600,children:ye}),c.jsx(m.Typography,{variant:"caption",color:"text.secondary",children:p5(B.fecAlta)})]})]}),Q<Le.length-1&&c.jsx(m.Divider,{sx:{mt:1.25}})]},B.segID??Q)}),ge.length>D&&c.jsx(m.Box,{sx:{mt:1},children:c.jsx(m.Button,{onClick:()=>he(B=>!B),size:"small",sx:{textTransform:"none",px:0,color:"#336BE1","&:hover":{background:"transparent",textDecoration:"underline"}},children:De?"Ver menos":`Ver más (${L})`})})]})]}),c.jsx(m.Menu,{anchorEl:k,open:I,onClose:()=>O(null),TransitionComponent:m.Fade,MenuListProps:{disablePadding:!0},PaperProps:{sx:{width:320,p:0,overflow:"hidden"}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[c.jsx(m.Box,{sx:{position:"sticky",top:0,zIndex:1,px:1.5,py:1,fontWeight:700,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider"},children:"Historial asesores"}),c.jsxs(m.Box,{sx:{overflowY:"auto",py:.5,maxHeight:200},children:[ue.length===0&&c.jsx(m.Box,{sx:{px:1.5,py:1},children:c.jsx(m.Typography,{variant:"body2",color:"text.secondary",children:"Sin registros"})}),ue.map((B,Q)=>{const ye=X3(B),Me=J3(B.FechaBaja??B.FechaAsignacion);return c.jsx(m.Box,{sx:{px:1,py:.75},children:c.jsxs(m.Stack,{direction:"row",alignItems:"center",spacing:1,children:[c.jsx(m.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},src:B?.ImgAsesor??void 0,children:e5(ye)}),c.jsx(m.Box,{sx:{flex:1,minWidth:0},children:c.jsx(m.Typography,{variant:"body2",noWrap:!0,children:ye})}),c.jsx(m.Typography,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:Me})]})},Q)})]})]})})]}),q?c.jsxs(m.Box,{sx:{flex:1,minWidth:0,overflow:"hidden",position:"relative"},children:[c.jsx(m.Box,{sx:{position:"absolute",top:18,left:24,zIndex:10,pointerEvents:"auto"},children:c.jsx(m.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:c.jsx(m.Button,{onClick:We,sx:{backgroundColor:"#2571d6",minWidth:36,minHeight:36,p:.5,borderRadius:"8px",color:"#fff",boxShadow:3,"&:hover":{backgroundColor:"#2074e3"}},children:c.jsx(l5,{fontSize:"medium"})})})}),z&&c.jsx("iframe",{src:z,width:"100%",height:"100%",onLoad:It,style:{border:0}})]}):c.jsxs(m.Box,{sx:{width:"100%",minHeight:0,overflowY:"auto"},children:[c.jsx(m.Box,{sx:{mt:{xs:1.5,md:3}},children:c.jsxs(m.Box,{sx:{mt:3,display:"flex",flexDirection:"column",gap:4,padding:"0 20px 0 20px"},children:[c.jsx(m.Typography,{variant:"h4",sx:{fontWeight:800,textAlign:"center",mb:1,letterSpacing:.2},children:"Solicitudes"}),c.jsxs(m.Stack,{direction:{xs:"column",md:"column"},spacing:1.5,alignItems:{xs:"stretch",md:"center"},justifyContent:"space-between",sx:{mb:1.5},children:[c.jsxs(m.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",sx:{flexWrap:"wrap"},children:[c.jsx(m.TextField,{size:"small",placeholder:"Buscar por vehículo",value:ce,onChange:B=>ae(B.target.value),InputProps:{endAdornment:c.jsx(B3,{fontSize:"small",sx:{color:"#b6afaf"}})},sx:{minWidth:220}}),c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,position:"relative"},children:[c.jsxs(m.Stack,{direction:"row",spacing:1.1,position:"absolute",bottom:48,left:0,alignItems:"center",children:[c.jsx(m.FormControlLabel,{label:c.jsx(m.Typography,{sx:{fontSize:15,fontWeight:600,marginLeft:0},children:"Por fecha"}),labelPlacement:"start",control:c.jsx(m.Checkbox,{checked:j,onChange:B=>K(B.target.checked),size:"small",sx:{p:.3,"& .MuiSvgIcon-root":{fontSize:19},color:"#bab4b4"}}),sx:{ml:0,"& .MuiFormControlLabel-label":{marginRight:0}}}),c.jsx(m.Typography,{sx:{fontSize:15,paddingLeft:.4},children:"De cita"})]}),c.jsxs(m.Stack,{direction:"row",spacing:1,children:[c.jsx(m.TextField,{size:"small",type:"date",label:"Desde",InputLabelProps:{shrink:!0},value:xe,onChange:B=>qe(B.target.value),disabled:!j,sx:{width:170}}),c.jsx(m.TextField,{size:"small",type:"date",label:"Hasta",InputLabelProps:{shrink:!0},value:gt,onChange:B=>vt(B.target.value),disabled:!j,sx:{width:170}})]})]}),c.jsx(m.IconButton,{onClick:B=>er(B.currentTarget),disableRipple:!0,sx:{border:"1px solid #d4d7de",borderRadius:2,width:40,height:40,mt:2},children:c.jsx(L3,{})}),Ee&&c.jsx(m.Button,{variant:"outlined",onClick:ee,disableRipple:!0,sx:{height:40,textTransform:"none",borderColor:"#d4d7de",color:"#333",mt:2},children:"Limpiar filtros"}),c.jsx(m.Tooltip,{title:Ee&&"Crear Solicitud",arrow:!0,placement:"top",disableHoverListener:!Ee,children:c.jsx("span",{children:c.jsxs(m.Button,{variant:"outlined",sx:{height:40,textTransform:"none",borderColor:"none",color:"#fff",backgroundColor:"#1e5bce","&:hover":{backgroundColor:"#1e5bce",boxShadow:"none"}},onClick:()=>{_?.(t)},disableRipple:!0,children:[c.jsx(A0,{sx:{color:"#fff",fontSize:24,paddingRight:.6}}),!Ee&&"Crear Solicitud"]})})})]}),c.jsx(Z3,{sections:Ge,detailColumns:[],getDetailColumns:ne,onRowClick:Ye})]})]})}),c.jsx(m.Menu,{anchorEl:Kt,open:Qt,onClose:()=>er(null),TransitionComponent:m.Fade,PaperProps:{sx:{p:1.5,width:260,borderRadius:2,boxShadow:3}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:c.jsxs(m.Stack,{spacing:1.5,paddingX:1.5,paddingY:1,children:[c.jsx(m.Typography,{variant:"subtitle2",sx:{fontWeight:700,color:"#070C10"},children:"Filtro"}),c.jsxs(m.Box,{children:[c.jsx(m.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Estatus"}),c.jsx(m.RadioGroup,{value:re,onChange:B=>Pe(B.target.value),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos","Sin Asignar","En prospección","Proceso de Compra","En espera de Unidad","Auto Facturado","Rechazadas","Finalizadas sin Venta","Finalizadas con Venta","En Proceso"].map(B=>c.jsx(m.FormControlLabel,{value:B,control:c.jsx(m.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:B},B))})]}),c.jsxs(m.Box,{children:[c.jsx(m.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Actividades"}),c.jsx(m.RadioGroup,{value:Ae,onChange:(B,Q)=>ze(Q),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos",...V].map(B=>c.jsx(m.FormControlLabel,{value:B,sx:{alignItems:"start"},control:c.jsx(m.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:B},B))})]}),c.jsxs(m.Box,{children:[c.jsx(m.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Nivel de interés"}),c.jsx(m.RadioGroup,{value:Yt,onChange:(B,Q)=>tr(Q),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos",...Ir].map(B=>c.jsx(m.FormControlLabel,{value:B,control:c.jsx(m.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:B},B))})]})]})})]})]})})}const T0={tableClientes:"_tableClientes_acwe7_1",tableResponsive:"_tableResponsive_acwe7_1"};function M0(e,r,t){const{fields:n,order:o=["nombreCliente","email","acciones"],header:a={},cells:s={},hide:i={},actions:l}=r,d=l??{},u=d.show??{},f=d.handlers??{},h=d.accessors??{},g=d.icons??{},v=d.className??"d-flex flex-row gap-2 align-items-center ",p=d.tooltip??{},y=g.view??c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",style:{fill:"#070c10"},children:[c.jsx("path",{d:"M18.6,6.3c-3.9-3-9.3-3-13.2,0-1.9,1.5-3.2,3.5-3.9,5.7.7,2.3,2,4.3,3.9,5.7,1.9,1.5,4.2,2.3,6.6,2.3,2.4,0,4.7-.8,6.6-2.3,1.9-1.5,3.2-3.5,3.9-5.7-.7-2.3-2-4.3-3.9-5.7ZM17.2,12.1c0,2.9-2.5,5.3-5.4,5.2-2.9,0-5.3-2.5-5.2-5.4,0-2.9,2.5-5.3,5.4-5.2,2.9,0,5.3,2.4,5.2,5.3,0,0,0,0,0,0Z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),_={nombreCliente:{key:"nombreCliente",header:a.nombreCliente??"Cliente",accessor:I=>I[n.nombreCliente],cell:s.nombreCliente,width:190},email:{key:"email",header:a.email??"Correo",accessor:I=>I[n.email],cell:s.email??(I=>{const q=String(I[n.email]??"");return q?c.jsx("a",{href:`mailto:${q}`,children:q}):c.jsx("span",{className:"text-muted",children:"—"})}),width:230},acciones:i.acciones?void 0:{key:"acciones",header:"",cell:s.acciones??(I=>{const q=pc(u.whatsapp,I,!0),H=pc(u.email,I,!0),W=pc(u.view,I,!0),Z=h.phone?.(I),J=h.email?.(I),Y=ue=>{if(ue.stopPropagation(),f.onWhatsApp)return f.onWhatsApp(I);if(!Z)return;const $=h.countryCode??"52",X=P3(String(Z));typeof window<"u"&&window.open(`https://wa.me/${$}${X}`,"_blank")},z=ue=>{if(ue.stopPropagation(),f.onEmail)return f.onEmail(I);J&&typeof window<"u"&&(window.location.href=`mailto:${J}`)},ie=ue=>{ue.stopPropagation(),f.onView&&f.onView(I)};return c.jsxs("div",{className:v,children:[q&&c.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:p.whatsapp??"WhatsApp",onClick:Y,style:{width:24,height:24},children:c.jsx("img",{src:M3,alt:"WhatsApp"})}),H&&c.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:p.email??"Email",onClick:z,style:{width:24,height:24},children:c.jsx("img",{src:I3,alt:"Email"})}),W&&c.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:p.view??"Ver detalle",onClick:ie,style:{width:24,height:24},children:y})]})}),width:120}},S=Object.values(_).filter(I=>!!I),C=(e??[]).filter(I=>!!I?.key),E=new Map;for(const I of S)E.set(String(I.key),I);for(const I of C)E.set(String(I.key),I);const w=[...S.map(I=>String(I.key)),...C.map(I=>String(I.key))],N=Array.from(new Set(o.map(I=>String(I)).filter(I=>E.has(I)))),D=w.filter(I=>!N.includes(I)),k=[...N,...D],O="acciones";if(E.has(O)){const I=k.filter(q=>q!==O);k.splice(0,k.length,...I,O)}return k.map(I=>E.get(I))}function x5(e){const{rows:r,columns:t,clientSort:n=!0,urlsQA:o=!0,defaultSort:a,minWidth:s=1100,rowKey:i=j3,haveOpenDetailFor:l=!0,defaults:d,detailConfig:u,normalTable:f,onRowClick:h,activityHistory:g,advisorHistory:v,forceOpenDetailFor:p,closeDetailFor:y,onRequestEdit:_,searchFilter:S,solicitudesNuevos:C,solicitudesPrueba:E,solicitudesServicio:w,solicitudesSeminuevos:N,onCreateSolicitud:D,isCrmMode:k,onSolicitudBaseUrl:O,onIframeClose:I,reloadInfo:q,idAdminSistemas:H=!1}=e,[W,Z]=b.useState(a??null),[J,Y]=b.useState({open:!1,customer:null}),[z,ie]=b.useState([]),ue=oe=>{Y({open:!0,customer:oe})},$=oe=>{l&&(h?.(oe),Y({open:!0,customer:oe}))},X=()=>{Y({open:!1,customer:null}),y?.()},Se=b.useMemo(()=>d?M0(t??[],d):M0(t??[],{fields:{},order:[]}),[t,d]),we=b.useMemo(()=>{if(!n||!W)return r;const oe=Se.find(se=>se.key===W.key);if(!oe)return r;const le=[...r];return le.sort((se,ge)=>{const De=fc(oe,se,0),he=fc(oe,ge,0),Le=O3(De,he);return W.direction==="asc"?Le:-Le}),le},[r,Se,W,n]),_e=b.useMemo(()=>{const oe=u?.getCustomerId;return le=>{const se=oe?.(le)??le?.Id_cliente??le?.CliID??le?.id??le?.ID??le?.Id??"";return String(se)}},[u]);return b.useEffect(()=>{if(!J.open||!J.customer)return;const oe=_e(J.customer);if(!oe)return;const le=(r??[]).find(se=>_e(se)===oe);le&&le!==J.customer&&Y(se=>({...se,customer:le}))},[r,J.open,J.customer,_e]),b.useEffect(()=>{p&&ue(p)},[p]),c.jsxs("div",{children:[c.jsx("div",{className:`${T0.tableClientes} back-white rounded-3 shadow-main mt-4 mb-4`,children:c.jsx("div",{className:`${T0.tableResponsive} table-responsive`,children:c.jsxs("table",{className:"table table-hover align-middle mb-0",children:[c.jsx("thead",{children:c.jsx("tr",{children:Se.map(oe=>c.jsx("th",{style:{fontWeight:600,width:oe.width,paddingTop:"20px",paddingBottom:"20px",textAlign:oe.align??"left"},children:oe.header},oe.key))})}),c.jsx("tbody",{children:we.map((oe,le)=>c.jsx("tr",{onClick:()=>$?.(oe),role:"button",tabIndex:0,onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&$?.(oe)},style:{cursor:"pointer"},children:Se.map((se,ge)=>{const De=se.Component?c.jsx(se.Component,{row:oe,index:le}):se.cell?se.cell(oe,le):(()=>{const he=fc(se,oe,le);return he==null||he===""?"":String(he)})();return c.jsx("td",{style:{paddingTop:"20px",paddingBottom:"20px",textAlign:se.align??"left"},children:De},`${String(se.key)}-${ge}`)})},i(oe,le)))})]})})}),J.open&&c.jsx(b5,{open:J.open,onClose:X,customer:J.customer,fields:u?.dynamicFields,header:u?.header,normalTable:f,history:g,advisorHistory:v,urlsQA:o,onRequestEdit:oe=>{X(),_?.(oe)},searchFilter:S,solicitudesNuevos:C,solicitudesPrueba:E,solicitudesServicio:w,solicitudesSeminuevos:N,onCreateSolicitud:D,isCrmMode:k,onSolicitudBaseUrl:O,onIframeClose:I,reloadInfo:q,idAdminSistemas:H})]})}const I0=M.forwardRef(({sx:e,...r},t)=>c.jsx(m.InputBase,{inputRef:t,...r,sx:{height:48,px:1.5,width:"100%",maxWidth:"none",bgcolor:"#EBEEF0",borderRadius:2,border:"1px solid transparent","&:hover":{borderColor:"transparent"},"& .MuiInputBase-input::placeholder":{opacity:.7},...e}}));I0.displayName="SoftInput";function w5({message:e}){return e?c.jsxs(m.Box,{role:"alert",sx:{mt:1,display:"flex",alignItems:"center",gap:1,bgcolor:"#fdeaea",border:"1px solid rgb(253, 237, 237)",color:"#842029",borderRadius:1,px:2,py:1.25},children:[c.jsx(Kl,{fontSize:"small",sx:{color:"rgb(211, 47, 47)"}}),c.jsx("span",{style:{color:"rgb(95, 33, 32)",fontSize:14,fontWeight:"500"},children:e})]}):null}function _5(e){if(e.required)return e.required===!0?"El campo es obligatorio.":e.required}function gc(e,r){const t=_5(e);return t?r?.isArray?{required:t,validate:n=>Array.isArray(n)&&n.length>0||t}:{required:t,validate:n=>n!==""&&n!==null&&n!==void 0||t}:{}}const O0={"& .MuiOutlinedInput-root .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"& .MuiOutlinedInput-root.Mui-error .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},width:"100%"},S5={mb:1,fontWeight:600,color:"#1C1C1D","&.Mui-focused":{color:"#1C1C1D !important"},"&.Mui-error":{color:"#1C1C1D !important"}};function vc({label:e,errorMsg:r,helperText:t,children:n,sx:o}){return c.jsxs(m.FormControl,{fullWidth:!0,error:!!r,sx:o,className:"1- FieldWrapper",children:[c.jsx(m.FormLabel,{sx:S5,children:e}),n,c.jsx(w5,{message:r||t})]})}function C5(e,r){const{register:t,formState:{errors:n}}=r,o={...gc(e)};e.minLength&&(o.minLength={value:e.minLength,message:`El campo espera minimo ${e.minLength} caracteres`}),e.maxLength&&(o.maxLength={value:e.maxLength,message:`El campo espera maximo ${e.maxLength} caracteres`}),e.pattern&&(o.pattern={value:e.pattern,message:"Formato inválido"});const a=e.type==="email";a&&!o.pattern&&(o.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo electrónico inválido"});const s=/[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]/g,i=/[0-9]/g,l=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Escape","Enter"]),d=E=>e.onlyNumbers?(E.match(i)??[]).join(""):e.onlyLetters?(E.match(s)??[]).join(""):E,u=(E,w)=>l.has(E)||w?!0:e.onlyNumbers?/^[0-9]$/.test(E):e.onlyLetters?/^[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]$/.test(E):!0,f=n[e.name]?.message,h=t(e.name,o),g=(e.inputProps&&typeof e.inputProps.maxLength=="number"?e.inputProps.maxLength:void 0)??e.maxLength,v=E=>{u(E.key,E.ctrlKey||E.metaKey)||E.preventDefault()},p=E=>{const w=E.data??null;w!=null&&(e.onlyNumbers&&/[^0-9]/.test(w)&&E.preventDefault(),e.onlyLetters&&/[^A-Za-zÁÉÍÓÚÜÑáéíóúüñ ]/.test(w)&&E.preventDefault())},y=E=>{const w=E.clipboardData.getData("text"),N=d(w);if(N!==w){E.preventDefault();const D=E.target,k=D.selectionStart??D.value.length,O=D.selectionEnd??D.value.length;D.setRangeText(N,k,O,"end"),D.dispatchEvent(new Event("input",{bubbles:!0}))}},_=E=>{const w=d(E.target.value);w!==E.target.value&&(E.target.value=w),g&&E.target.value.length>g&&(E.target.value=E.target.value.slice(0,g)),h.onChange(E)},S={...e.inputProps,...a?{inputMode:"email",autoComplete:"email"}:{},maxLength:g,onKeyDown:v,onBeforeInput:p,onPaste:y,onInvalid:E=>E.preventDefault()},C=e.onlyNumbers||a?"text":e.type??"text";return c.jsx(vc,{label:e.label,errorMsg:f,helperText:e.helperText,sx:O0,children:c.jsx(I0,{placeholder:e.placeholder,type:C,inputProps:S,...h,onChange:_,sx:{width:"100%",maxWidth:"none"},className:"SoftInputData"})})}function E5(e,r){const{control:t}=r,n=!!e.multiple;return c.jsx(Ar,{name:e.name,control:t,rules:gc(e,{isArray:n}),render:({field:o,fieldState:a})=>c.jsx(vc,{label:e.label,errorMsg:a.error?.message,helperText:e.helperText,sx:O0,children:c.jsxs(m.Select,{...o,multiple:n,displayEmpty:!0,sx:{height:48,backgroundColor:"#EBEEF0","& .MuiSelect-select":{display:"flex",alignItems:"center",py:0}},className:"2-SoftInputData",children:[!n&&c.jsx(m.MenuItem,{value:"",disabled:!0,children:"Selecciona…"}),e.options.map(s=>c.jsx(m.MenuItem,{value:s.value,children:s.label},String(s.value)))]})})})}function D5(e,r){return c.jsx(Ar,{name:e.name,control:r.control,rules:gc(e),render:({field:t,fieldState:n})=>c.jsx(vc,{label:e.label,errorMsg:n.error?.message,helperText:e.helperText,children:c.jsx(m.RadioGroup,{row:!0,...t,className:"3-RadioFieldRender",children:e.options.map(o=>c.jsx(m.FormControlLabel,{value:o.value,control:c.jsx(m.Radio,{}),label:o.label},String(o.value)))})})})}function P0(e,r){if(e.render)return e.render(r);switch(e.kind){case"text":return C5(e,r);case"select":return E5(e,r);case"radio":return D5(e,r);default:return null}}function A5(e,{initialPerPage:r=25,perPageOptions:t=[10,25,50,100,"Todos"],onPageChange:n,onPerPageChange:o,scrollTop:a,deps:s=[]}={}){const i=Array.isArray(e)?e:[],[l,d]=b.useState(1),[u,f]=b.useState(r),{currentItems:h,totalPages:g,showingFrom:v,showingTo:p,totalItems:y}=b.useMemo(()=>{const C=i.length,E=u==="Todos"?1/0:Number(u),w=E===1/0?1:Math.max(1,Math.ceil(C/E)),N=Math.min(l,w),D=E===1/0?C:N*E,k=E===1/0?0:D-E;return{currentItems:E===1/0?i:i.slice(k,D),totalPages:w,showingFrom:C===0?0:k+1,showingTo:E===1/0?C:Math.min(D,C),totalItems:C}},[i,l,u]),_=C=>{const E=Math.max(1,Math.min(C,g||1));d(E),n?.(E),a?.()};return{currentItems:h,totalPages:g,showingFrom:v,showingTo:p,totalItems:y,currentPage:l,itemsPerPage:u,perPageOptions:t,goTo:_,next:()=>_(l+1),prev:()=>_(l-1),setItemsPerPage:C=>{f(C),o?.(C),d(1),a?.()},setCurrentPage:_}}var ga={},j0;function k5(){if(j0)return ga;j0=1;var e=st();Object.defineProperty(ga,"__esModule",{value:!0}),ga.default=void 0;var r=e(pt()),t=ut();return ga.default=(0,r.default)((0,t.jsx)("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),ga}var T5=k5();const M5=at(T5);var va={},R0;function I5(){if(R0)return va;R0=1;var e=st();Object.defineProperty(va,"__esModule",{value:!0}),va.default=void 0;var r=e(pt()),t=ut();return va.default=(0,r.default)((0,t.jsx)("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),va}var O5=I5();const P5=at(O5),j5=({currentPage:e,totalPages:r,onPageChange:t,itemsPerPage:n,onItemsPerPageChange:o,itemsPerPageOptions:a,showingFrom:s,showingTo:i,totalItems:l})=>{const d=m.useTheme(),u=m.useMediaQuery(d.breakpoints.down("sm")),f=()=>{if(r<=1)return[1];const v=u?0:2,p=[],y=1,_=r,S=Math.max(y+1,e-v),C=Math.min(_-1,e+v);p.push(y),S>y+1&&p.push("...");for(let E=S;E<=C;E++)E>=y+1&&E<=_-1&&p.push(E);return C<_-1&&p.push("..."),p.push(_),p},h=v=>{const p=v.target.value;o(p)},g=Math.max(1,r);return c.jsxs(m.Box,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:"center",justifyContent:{xs:"center",sm:"space-between"},gap:2,my:0,py:2,borderTop:"#D3D4D5 1px solid",px:3},children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",justifyContent:"center"},children:[c.jsx(m.IconButton,{onClick:()=>t(e-1),disabled:e<=1,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página anterior",children:c.jsx(M5,{fontSize:"large"})}),f().map((v,p)=>v==="..."?c.jsx(m.Box,{sx:{px:1,display:"flex",alignItems:"center",fontSize:"1.1rem"},children:". . ."},`dots-${p}`):c.jsx(m.Button,{onClick:()=>t(v),size:"small",sx:{minWidth:36,height:36,fontSize:"1.05rem",p:1,borderRadius:"10px",backgroundColor:e===v?"primary.main":"transparent",fontWeight:e===v?700:400,color:e===v?"#fff":"#5C6372","&:hover":{backgroundColor:e===v?"primary.dark":"action.hover"},boxShadow:"none",border:"none",mx:.5},children:v},`p-${v}`)),c.jsx(m.IconButton,{onClick:()=>t(e+1),disabled:e>=g,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página siguiente",children:c.jsx(P5,{fontSize:"large"})})]}),c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,justifyContent:{xs:"center",sm:"flex-start"},mt:{xs:1,sm:0}},children:[c.jsx(m.Typography,{variant:"body2",children:"Mostrar"}),c.jsx(m.FormControl,{size:"small",sx:{minWidth:72},children:c.jsx(m.Select,{value:n,onChange:h,renderValue:v=>v==="Todos"?"Todos":String(v),children:a.map(v=>c.jsx(m.MenuItem,{value:v,children:v==="Todos"?"Todos":v},String(v)))})}),c.jsx(m.Typography,{variant:"body2",children:"por página"})]})]})};function R5(e){const{open:r,dataAdd:t,fields:n,onSubmit:o,onCancel:a,defaultValues:s,txtBtnGuardar:i,haveId:l=!1,itemsTable:d,filter:u,getId:f,renderRow:h,selectedIds:g,onSelectedChange:v,onSubmitAddData:p,initialSelectedIds:y=[],showAutosPanel:_}=e,S=Ch({mode:"onSubmit",reValidateMode:"onChange",criteriaMode:"all",shouldUnregister:!1,defaultValues:s});b.useEffect(()=>{s&&S.reset(s)},[s,S]);const[C,E]=b.useState(""),[w,N]=b.useState(y),D=Array.isArray(g)&&!!v,k=D?g:w,O=j=>{const K=typeof j=="function"?j(k):j;D?v(K):N(K)},I=b.useCallback(j=>f?f(j):j?.IdAuto,[f]),q=b.useMemo(()=>{const j=new Map;return(d??[]).forEach((K,de)=>j.set(I(K),de)),j},[d,I]),H=b.useRef(new Set),W=b.useMemo(()=>{const j=new Map;return(d??[]).forEach(K=>j.set(f?f(K):K?.IdAuto,K)),j},[d,f]),Z=b.useMemo(()=>(n??[]).filter(j=>!!j.required).map(j=>j.name),[n]),J=sh({control:S.control,name:Z}),Y=j=>j==null?!1:typeof j=="string"?j.trim().length>0:Array.isArray(j)?j.length>0:typeof j=="number"?!Number.isNaN(j):typeof j=="object"?Object.keys(j).length>0:!0,z=b.useMemo(()=>Z.length?J?.every(Y)??!1:!0,[J,Z]),{handleSubmit:ie,formState:{isSubmitting:ue,isDirty:$,isValid:X}}=S,Se=u??((j,K)=>JSON.stringify(j).toLowerCase().includes(K.toLowerCase())),we=b.useMemo(()=>C.trim()?d?.filter(j=>Se(j,C)):d,[d,C,Se]),_e=b.useMemo(()=>{if(!we)return we;const j=H.current,K=[...we];return K.sort((de,Oe)=>{const R=j.has(I(de))?0:1,te=j.has(I(Oe))?0:1;if(R!==te)return R-te;const xe=q.get(I(de))??0,qe=q.get(I(Oe))??0;return xe-qe}),K},[we,q,I]),{currentItems:oe,totalPages:le,showingFrom:se,showingTo:ge,totalItems:De,currentPage:he,itemsPerPage:Le,perPageOptions:L,goTo:Ne,setItemsPerPage:lt}=A5(_e,{initialPerPage:25,perPageOptions:[10,25,50,100,"Todos"],deps:[C],scrollTop:()=>{}}),Ze=j=>{const K=W.get(j)??null;O([j]),p?.({items:K})},Ie=j=>k.includes(j),ot=async j=>{try{await o?.(j),S.reset(S.getValues())}catch(K){console.error("Error al enviar AddCliente:",K)}},$e=b.useMemo(()=>{const j=new Map;return(n??[]).forEach(K=>j.set(String(K.name),K)),j},[n]),Ce=(j,K)=>{const de=$e.get(String(j));if(!de)return null;const Oe={xs:12,...de.grid,...K||{}};return c.jsx(m.Grid,{item:!0,...Oe,children:de.render?de.render(S):P0(de,S)},`fld-${String(j)}`)},A=_??(e.haveId?"edit":"new"),P=A!=="onlyCars",U=A==="new"||A==="onlyCars",ce=k?.length>0,ae=A==="onlyCars"?ce:e.haveId?z&&$||ce:z&&ce;return c.jsx(m.Dialog,{open:r,onClose:a,maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{height:{xs:"100dvh",md:U?"90vw":"auto"},maxWidth:{xs:"100vw",md:U?"98vw":"50%"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:c.jsx(TD,{...S,children:c.jsxs(m.Box,{component:"form",noValidate:!0,onSubmit:ie(ot),display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",height:"100%",minHeight:0,overflow:"hidden",position:"relative",children:[P&&c.jsxs(m.Box,{sx:{width:{xs:"100%",md:l?"100%":394},maxWidth:{xs:"100%",md:l?"100%":394},boxShadow:{xs:"none",md:l?"none":"2px 0px 8px #40404024"},borderRight:{xs:"none",md:l?"none":"1px solid #EBEEF0"},bgcolor:"background.paper",paddingBottom:3,mx:{xs:0,md:l?"auto":0},position:"relative"},children:[c.jsxs(m.Box,{p:{xs:2,md:2},height:"100%",width:"100%",children:[c.jsx(m.Typography,{fontWeight:700,fontSize:20,children:t.title}),c.jsxs(m.Box,{sx:{flex:1,height:"100%",overflowY:"auto",paddingBottom:10},children:[c.jsx(m.Typography,{fontSize:"18px",mt:2.5,fontWeight:500,children:t.subTitle}),c.jsx(m.Box,{mt:2,display:"flex",flexDirection:"column",width:"100%",gap:2,children:Array.isArray(e.formLayout)&&l?e.formLayout.map((j,K)=>c.jsx(m.Grid,{container:!0,spacing:2,alignItems:"flex-start",wrap:"wrap",width:"100%",children:j.map((de,Oe)=>{const R=typeof de=="string"?{name:de}:de;return R.hidden?.(S)?null:Ce(R.name,R.grid)})},`row-${K}`)):c.jsx(m.Grid,{container:!0,spacing:2,width:"100%",children:n?.map((j,K)=>{const de=j.grid??{xs:12,md:12};return c.jsx(m.Grid,{item:!0,...de,children:j.render?j.render(S):P0(j,S)},`${String(j.name)}-${K}`)})})})]})]}),c.jsx(m.Box,{sx:{position:"absolute",zIndex:j=>j.zIndex.modal+1,bottom:0,width:"100%",borderRadius:2,boxShadow:{xs:"0",md:"0 -8px 8px -6px #0003"},p:1,backgroundColor:"#fff"},children:c.jsx(m.Box,{display:"flex",alignItems:"center",children:c.jsx(m.Box,{display:"flex",gap:1.5,width:"100%",justifyContent:l?"flex-end":"center",children:c.jsx(m.Button,{type:"submit",variant:"contained",disabled:ue||!ae,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:l?"160px":"100%"},children:i})})})})]}),U&&c.jsx(m.Box,{flex:1,display:"flex",flexDirection:"column",minWidth:0,sx:{height:"100%"},children:c.jsx(m.Box,{mt:1,sx:{flex:1,display:"flex",flexDirection:"column",height:"100%"},children:c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[c.jsxs(m.Box,{p:3,sx:{borderBottom:1,borderBottomColor:"#D3D4D5",position:"sticky",top:0,zIndex:1,bgcolor:"#fff",flexDirection:{sm:"row",xs:"column"}},display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:4,children:[c.jsx(m.TextField,{value:C,onChange:j=>E(j.target.value),placeholder:"Buscar marca, modelo, vin...",InputProps:{endAdornment:c.jsx(m.InputAdornment,{position:"start",children:c.jsx(lb,{})}),disableUnderline:!0},variant:"standard",sx:{maxWidth:360,width:"100%",backgroundColor:"#EBEEF0",paddingX:"16px",paddingY:"10px"}}),c.jsx(m.Box,{display:"flex",gap:2,alignItems:"center",sx:{marginTop:{sm:0,xs:2}},children:c.jsx(m.Box,{onClick:a,sx:{cursor:"pointer",position:"absolute",top:0,right:10},display:{xs:"none",md:"block"},children:c.jsx(Er,{sx:{color:"#070C10",fontSize:24}})})}),_=="onlyCars"&&c.jsx(m.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:c.jsx(m.Box,{display:"flex",gap:1.5,width:"100%",children:c.jsxs(m.Button,{type:"submit",variant:"contained",disabled:ue||!ae,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:"100%"},children:[c.jsx(A0,{sx:{color:ue||!ae?"gray":"#fff",fontSize:26,paddingRight:.6}}),"Crear Solicitud"]})})})]}),c.jsx(m.Box,{sx:{flex:1,minHeight:0,overflowY:"auto",overflowX:"auto",padding:0,height:"100%","&::-webkit-scrollbar:horizontal":{display:"none"},"&::-webkit-scrollbar:vertical":{width:8}},children:c.jsx(m.Box,{sx:{minWidth:1150,width:"max(1150px, 100%)",paddingBottom:10},children:c.jsxs(m.List,{disablePadding:!0,sx:{borderColor:"transparent",padding:0},children:[oe?.map((j,K)=>{const de=f?f(j):K,Oe=Ie(de);return c.jsx(m.Box,{sx:{borderBottom:"1px solid #D3D4D5",padding:0},children:c.jsx(m.ListItem,{disableGutters:!0,sx:{paddingTop:0,padding:0,m:0},children:c.jsx(m.ListItemButton,{onClick:()=>Ze(de),disableRipple:!0,sx:{padding:0},children:c.jsx(m.ListItemText,{disableTypography:!0,primary:h?h({item:j,selected:Oe,toggle:()=>Ze(de),index:K}):null})})})},`${String(de)}`)}),!oe?.length&&c.jsx(m.Box,{p:3,children:c.jsxs(m.Typography,{fontSize:14,color:"#5C6372",children:["Sin resultados para “",C,"”."]})})]})})}),c.jsx(m.Box,{sx:{position:"sticky",bottom:0,bgcolor:"#fff"},children:c.jsx(j5,{currentPage:he,totalPages:le,onPageChange:Ne,itemsPerPage:Le,onItemsPerPageChange:lt,itemsPerPageOptions:L,showingFrom:se,showingTo:ge,totalItems:De})})]})})})]})})})}var ya={},N0;function N5(){if(N0)return ya;N0=1;var e=st();Object.defineProperty(ya,"__esModule",{value:!0}),ya.default=void 0;var r=e(pt()),t=ut();return ya.default=(0,r.default)((0,t.jsx)("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6z"}),"AttachFile"),ya}var L5=N5();const $5=at(L5),yc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/i,si=/[,\s;]+/g,mn=e=>e.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase(),gn=(e,r)=>Array.from(new Set([...e,...r.map(t=>t.trim()).filter(Boolean)])),L0=(e,r)=>r?e.filter(t=>mn(t)!==mn(r)):e,z5=(e,r)=>e.filter(t=>!r.some(n=>mn(n)===mn(t)));function Mr(e,r,t){if(t)return typeof t=="function"?t(e,r):e[t]}function B5(e,r){if(r)return!e||/^https?:\/\//i.test(r)?r:e+r}function F5({open:e,onClose:r,value:t,onChange:n,onRequestSend:o,customer:a,itemsSelects:s,renderItem:i,filterFields:l=[],multiSelectAutos:d=!0,imgCorreoSrc:u,baseURLImages:f,itemProps:h,defaultItemImageSrc:g}){const v=b.useRef(null),[p,y]=b.useState("idle"),_=b.useRef(e);b.useEffect(()=>{const R=_.current;e&&!R&&y("entering"),!e&&R&&y("exiting"),_.current=e},[e]),b.useEffect(()=>{if(p==="entering"){const xe=setTimeout(()=>y("idle"),320);return()=>clearTimeout(xe)}if(p==="exiting"){const xe=setTimeout(()=>y("idle"),220);return()=>clearTimeout(xe)}},[p]);const[S,C]=b.useState(""),[E,w]=b.useState(!1),[N,D]=b.useState(!1),[k,O]=b.useState(!1),[I,q]=b.useState(""),[H,W]=b.useState([]),Z=k?H:t.selectedIds,J=()=>{W([...t.selectedIds]),q(""),O(!0)},Y=()=>{O(!1),W([])},z=()=>{const R=new Set($e.map((xe,qe)=>String(Mr(xe,qe,h.id)))),te=H.filter(xe=>R.has(String(xe)));n({...t,selectedIds:te}),O(!1)},ie=(R,te)=>mn(R??"")===mn(te??"");function ue(R,te,xe,qe,gt){const vt=te?R.some(er=>ie(er,te)):!1,Kt=xe.length>0?xe.some(er=>R.some(Qt=>ie(Qt,er))):!1;qe(vt),gt(Kt)}const $=R=>{const te=typeof R=="function"?R(t.recipients):R;n({...t,recipients:te}),ue(te,oe,se,w,D)},X=R=>n({...t,message:R}),Se=R=>n({...t,attachments:[...t.attachments,...R]}),we=R=>n({...t,attachments:t.attachments.filter(te=>te.name!==R)}),_e=R=>{if(k)if(d){const te=new Set(H);te.has(R)?te.delete(R):te.add(R),W(Array.from(te))}else{const te=H.includes(R);W(te?[]:[R])}else if(d){const te=new Set(t.selectedIds);te.has(R)?te.delete(R):te.add(R),n({...t,selectedIds:Array.from(te)})}else{const te=t.selectedIds.includes(R);n({...t,selectedIds:te?[]:[R]})}},oe=b.useMemo(()=>(a?.Correo??"").trim(),[a]),le=b.useMemo(()=>Array.isArray(a?.Asesores)?a.Asesores.filter(R=>R?.EmailAsesor&&R?.Activo):[],[a]),se=b.useMemo(()=>le.map(R=>(R.EmailAsesor??"").trim()).filter(Boolean),[le]),ge=b.useRef(!1);b.useEffect(()=>{if(e&&!ge.current){let R=[];E&&oe&&(R=gn(R,[oe])),N&&se.length&&(R=gn(R,se)),$(te=>gn(te,R)),ue(t.recipients,oe,se,w,D),C(""),ge.current=!0}e||(ge.current=!1)},[e,E,N,oe,se]);const De=R=>{const te=le.find(xe=>mn(xe.EmailAsesor??"")===mn(R));if(te){if(te.ImgAsesor)return c.jsx(m.Avatar,{src:te.ImgAsesor,alt:te.NombreAsesor});const xe=(te.NombreAsesor||"").trim(),qe=(te.ApellidosAsesor||"").trim();return c.jsx(m.Avatar,{children:`${xe[0]??""}${qe[0]??""}`.toUpperCase()})}return c.jsx(m.Avatar,{children:R[0]?.toUpperCase()})},he=()=>{const R=S.trim();if(!R)return;const xe=R.split(si).filter(Boolean).filter(qe=>yc.test(qe));xe.length>0&&$(qe=>gn(qe,xe)),C("")},Le=R=>{w(R),$(te=>R&&oe?gn(te,[oe]):L0(te,oe))},L=R=>{D(R),$(te=>R?gn(te,se):z5(te,se))},Ne=R=>{const te=Array.from(R.target.files||[]);Se(te.map(xe=>({name:xe.name,size:xe.size,file:xe}))),R.target.value=""},lt=Z[0],Ze=b.useMemo(()=>!s||lt===void 0?void 0:s.find((te,xe)=>String(Mr(te,xe,h.id))===String(lt)),[s,lt,h.id]),Ie=b.useMemo(()=>{if(!(!Ze||!h.distributorId))return Mr(Ze,0,h.distributorId)},[Ze,h.distributorId]);console.log("lockedDisId",Ie);const ot=b.useMemo(()=>Ze?(h.distributorTitle?Mr(Ze,0,h.distributorTitle):void 0)??(Ie!=null?String(Ie):void 0):void 0,[Ze,h.distributorTitle,Ie]),$e=b.useMemo(()=>{const R=s??[];return Ie==null||!h.distributorId?R:R.filter((te,xe)=>Mr(te,xe,h.distributorId)==Ie)},[s,Ie,h.distributorId]),Ce=b.useMemo(()=>{if(!I.trim())return $e;const R=I.toLowerCase();return $e.filter(te=>(l??[]).some(xe=>String(te?.[xe]??"").toLowerCase().includes(R)))},[$e,I,l]),A=b.useMemo(()=>{if(!s||!t.selectedIds.length)return[];const R=new Map;return s.forEach((te,xe)=>{R.set(String(Mr(te,xe,h.id)),te)}),t.selectedIds.map(te=>R.get(String(te))).filter(Boolean)},[s,t.selectedIds,h.id]),P=R=>n({...t,selectedIds:t.selectedIds.filter(te=>String(te)!==String(R))}),U=()=>{let R=t.recipients;if(S.trim()){const vt=S.split(si).filter(Kt=>yc.test(Kt));R=gn(R,vt),$(R),C("")}const te=E?oe:"",xe=le.find(vt=>vt?.Activo&&vt?.EmailAsesor)?.EmailAsesor?.trim()??"";o?.({recipients:R,toClient:E,toAdvisor:N,tipoInt:E&&N?2:1,correoCliente:te,correoAsesor:N?xe:"",disIdLocked:Ie}),r?.()},ce=b.useMemo(()=>{const te=S.split(si).filter(Boolean).some(xe=>yc.test(xe));return t.recipients.length>0||te},[t.recipients,S]),ae=(t.selectedIds?.length??0)>0,j=t.message.trim().length>0,K=ce&&ae&&j,de=m.useTheme(),Oe=m.useMediaQuery(de.breakpoints.down("sm"));return c.jsxs(m.Drawer,{anchor:Oe?"bottom":"right",open:e,onClose:r,ModalProps:{keepMounted:!0,BackdropProps:{invisible:!Oe}},transitionDuration:{enter:320,exit:220},SlideProps:{direction:Oe?"up":"left",timeout:{enter:320,exit:220},easing:{enter:"cubic-bezier(0.22, 1, 0.36, 1)",exit:"cubic-bezier(0.4, 0, 1, 1)"}},PaperProps:{sx:{width:{xs:"100vw",sm:420},height:{xs:"85vh",sm:"auto"},maxHeight:{xs:"85vh",sm:"calc(100vh - 32px)"},left:{xs:0,sm:"auto"},right:{xs:0,sm:16},bottom:{xs:0,sm:16},top:{xs:"auto",sm:"auto"},borderRadius:{xs:"12px 12px 0 0",sm:2},boxShadow:6,overflow:"hidden"}},children:[c.jsxs(m.Box,{sx:{display:"flex",flexDirection:"column",height:{xs:"100%",sm:"auto"},position:"relative",overflow:"auto"},children:[c.jsxs(m.Box,{sx:{p:2,pb:1,position:"sticky",top:0,zIndex:1,bgcolor:"#fff",borderBottom:"1px solid #E5E7EB"},children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[u?c.jsx("img",{src:u,alt:"Correo",style:{width:24,height:18}}):null,c.jsxs(m.Typography,{fontWeight:700,children:["Mensaje a"," ",a?`${a.Nombre??""} ${a.ApellidoP??""} ${a.ApellidoM??""}`.trim():"—"]})]}),c.jsx(m.IconButton,{onClick:r,size:"small",children:c.jsx(Er,{})})]}),c.jsx("div",{children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 10px",backgroundColor:"#EBEEF0",border:"1px solid #E5E7EB",borderRadius:8,flexWrap:"wrap"},children:[c.jsx("label",{style:{fontSize:14,fontWeight:600,marginRight:4},children:"Para:"}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",flex:1},children:[t.recipients.map(R=>c.jsx(m.Chip,{avatar:De(R),label:R,onDelete:()=>$(te=>L0(te,R)),size:"small",variant:"outlined",sx:{borderRadius:999,height:28}},R)),c.jsx("input",{type:"text",value:S,onChange:R=>C(R.target.value),onKeyDown:R=>{const te=R.key;te==="Enter"||te===","||te===";"||te===" "||te==="Tab"?(R.preventDefault(),he()):te==="Backspace"&&!S&&t.recipients.length&&$(qe=>qe.slice(0,-1))},onBlur:he,onPaste:R=>{const xe=R.clipboardData.getData("text").split(si).filter(Boolean);xe.length>1&&(R.preventDefault(),$(qe=>gn(qe,xe)),C(""))},placeholder:t.recipients.length?"":"correo@ejemplo.com",style:{flex:1,minWidth:140,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#111827",padding:"4px 0"}})]})]})}),c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1.5},children:[c.jsx(m.FormControlLabel,{control:c.jsx(m.Checkbox,{checked:E,onChange:R=>Le(R.target.checked),size:"small"}),label:"Cliente"}),le.length!==0&&c.jsx(m.FormControlLabel,{control:c.jsx(m.Checkbox,{checked:N,onChange:R=>L(R.target.checked),size:"small"}),label:`Asesor${le.length>1?"es":""}`})]})]}),c.jsx(m.Divider,{}),c.jsxs(m.Box,{p:2,children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1},onClick:J,children:[c.jsx(m.Typography,{fontSize:12,fontWeight:600,sx:{textDecorationLine:"underline",cursor:"pointer"},children:"Selecciona el auto de seguimiento"}),ot!=null&&c.jsx(m.Chip,{size:"small",label:`Distribuidora: ${ot}`})]}),A.length>0?c.jsx(m.Box,{sx:{mt:1.5,display:"flex",gap:1,flexWrap:"wrap"},children:A.map((R,te)=>{const xe=Mr(R,te,h.id),qe=Mr(R,te,h.title)??"",gt=Mr(R,te,h.image),vt=B5(f,gt);return c.jsx(m.Chip,{onDelete:()=>P(xe),label:c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[c.jsx(m.Box,{sx:{width:28,height:20,borderRadius:.8,bgcolor:"#e5e6e8",overflow:"hidden",flex:"0 0 auto"},children:vt?c.jsx("img",{src:vt,alt:qe,style:{width:"100%",height:"100%",objectFit:"cover"}}):c.jsx("img",{src:g,alt:qe,style:{width:"100%",height:"100%",objectFit:"cover"}})}),c.jsx("span",{style:{fontSize:12},children:c.jsx("b",{children:qe})})]}),sx:{pl:.5,pr:.3,py:.2,borderRadius:2,".MuiChip-deleteIcon":{fontSize:18}},variant:"outlined"},String(xe))})}):c.jsx(m.Typography,{fontSize:13,color:"#5C6372",sx:{mt:.5},children:"Aún no has seleccionado autos."})]}),c.jsx(m.Divider,{}),c.jsxs(m.Box,{sx:{p:2},children:[c.jsx(m.TextField,{placeholder:"Escribe aquí tu mensaje...",value:t.message,onChange:R=>X(R.target.value),multiline:!0,minRows:6,fullWidth:!0,sx:{mb:1.5}}),t.attachments.length>0&&c.jsx(m.List,{dense:!0,sx:{display:"flex",flexDirection:"column",gap:2,border:"none"},children:t.attachments.map(R=>c.jsxs(m.ListItem,{sx:{px:0,background:"#EAEBF2",borderRadius:2,paddingX:1},children:[c.jsx(m.ListItemText,{style:{gap:10,fontSize:15,color:"#5285F7",display:"flex",flexWrap:"wrap",flex:"none"},primary:R.name,secondary:R.size<1024?`${R.size} b`:R.size<1024*1024?`${(R.size/1024).toFixed(0)} kb`:`${(R.size/(1024*1024)).toFixed(1)} MB`,secondaryTypographyProps:{sx:{fontSize:12,color:"#64748B",fontWeight:500,mt:.25}},primaryTypographyProps:{noWrap:!0,width:"auto"}}),c.jsx(m.Tooltip,{title:"Quitar",children:c.jsx(m.IconButton,{edge:"end",onClick:()=>we(R.name),size:"small",children:c.jsx(Er,{fontSize:"small"})})})]},R.name))})]}),c.jsxs(m.Box,{sx:{position:{xs:"sticky",sm:"sticky"},bottom:0,bgcolor:"#fff",borderTop:"1px solid #E5E7EB",p:2,display:"flex",alignItems:"center",gap:2},children:[c.jsx("input",{ref:v,hidden:!0,type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.mp4,.pdf,.xlsx,.csv,.docx,.pptx,.txt",onChange:Ne}),c.jsx(m.Button,{startIcon:c.jsx($5,{}),variant:"text",onClick:()=>v.current?.click(),sx:{color:"#5C6372"},children:"Adjuntar archivo"}),c.jsx(m.Box,{sx:{flex:1}}),c.jsx(m.Button,{variant:"contained",onClick:U,disabled:!K,sx:{maxWidth:146,width:"100%",height:53,backgroundColor:"#336BE1"},children:"Enviar"})]})]}),c.jsxs(m.Dialog,{fullWidth:!0,maxWidth:"sm",fullScreen:Oe,open:k,onClose:Y,children:[c.jsxs(m.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:["Selecciona tu auto de seguimiento",c.jsx(m.IconButton,{onClick:Y,size:"small",children:c.jsx(Er,{})})]}),c.jsxs(m.DialogContent,{children:[c.jsxs(m.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[c.jsx(m.TextField,{placeholder:"Buscar...",fullWidth:!0,size:"small",value:I,onChange:R=>q(R.target.value),sx:{mb:2}}),ot!=null&&c.jsx(m.Chip,{size:"small",label:`Distribuidora: ${ot}`})]}),c.jsxs(m.Typography,{variant:"caption",fontWeight:600,children:["RESULTADOS (",Ce.length,")"]}),c.jsxs(m.List,{sx:{p:0},children:[Ce.map((R,te)=>{const xe=Mr(R,te,h.id),qe=Z.includes(String(xe))||Z.includes(xe),gt=Ie==null||Mr(R,te,h.distributorId)==Ie;return c.jsx(m.ListItem,{disableGutters:!0,sx:{p:0,opacity:gt?1:.5},children:c.jsx(m.Box,{onClick:()=>gt&&_e(xe),sx:{cursor:gt?"pointer":"not-allowed",p:.5,backgroundColor:qe?"#e5f0ff":"transparent",width:"100%",borderBottom:"solid 1px #D3D4D5"},children:i?i(R,te):c.jsx("pre",{style:{margin:0},children:JSON.stringify(R,null,2)})})},String(xe))}),Ce.length===0&&c.jsx(m.Box,{p:2,children:c.jsx(m.Typography,{children:"Tu búsqueda no generó resultados"})})]})]}),c.jsxs(m.DialogActions,{sx:{px:3,pb:2},children:[c.jsx(m.Button,{variant:"text",onClick:Y,sx:{color:"#5C6372"},children:"Cancelar"}),c.jsx(m.Button,{variant:"contained",onClick:z,sx:{backgroundColor:"#336BE1"},children:"Guardar selección"})]})]})]})}Ot.AddCliente=R5,Ot.ApiProvider=iw,Ot.AuthProvider=Nb,Ot.Clientes=x5,Ot.CustomSnackbar=dc,Ot.EventsProvider=w3,Ot.ModalCorreo=F5,Ot.MyCalendar=T3,Ot.useAuth=cl,Ot.useAuthRepository=Ts,Ot.useEventRepository=Nl,Object.defineProperty(Ot,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "componentes-exagono",
3
3
  "private": false,
4
- "version": "0.2.70",
4
+ "version": "0.2.72",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
7
7
  "module": "./dist/index.es.js",