componentes-exagono 0.1.69 → 0.1.71
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 +8 -4
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -18621,7 +18621,8 @@ const Eh = {
|
|
|
18621
18621
|
},
|
|
18622
18622
|
"& .MuiOutlinedInput-root.Mui-error .MuiOutlinedInput-notchedOutline": {
|
|
18623
18623
|
borderColor: "transparent"
|
|
18624
|
-
}
|
|
18624
|
+
},
|
|
18625
|
+
width: "100%"
|
|
18625
18626
|
}, _E = {
|
|
18626
18627
|
mb: 1,
|
|
18627
18628
|
fontWeight: 600,
|
|
@@ -18636,7 +18637,7 @@ function pl({
|
|
|
18636
18637
|
children: r,
|
|
18637
18638
|
sx: o
|
|
18638
18639
|
}) {
|
|
18639
|
-
return /* @__PURE__ */ d.jsxs(nf, { fullWidth: !0, error: !!n, sx: o, children: [
|
|
18640
|
+
return /* @__PURE__ */ d.jsxs(nf, { fullWidth: !0, error: !!n, sx: o, className: "1- FieldWrapper", children: [
|
|
18640
18641
|
/* @__PURE__ */ d.jsx(Ih, { sx: _E, children: e }),
|
|
18641
18642
|
r,
|
|
18642
18643
|
/* @__PURE__ */ d.jsx(xE, { message: n || t })
|
|
@@ -18715,7 +18716,8 @@ function SE(e, n) {
|
|
|
18715
18716
|
sx: {
|
|
18716
18717
|
width: "100%",
|
|
18717
18718
|
maxWidth: "none"
|
|
18718
|
-
}
|
|
18719
|
+
},
|
|
18720
|
+
className: "SoftInputData"
|
|
18719
18721
|
}
|
|
18720
18722
|
)
|
|
18721
18723
|
}
|
|
@@ -18751,6 +18753,7 @@ function CE(e, n) {
|
|
|
18751
18753
|
py: 0
|
|
18752
18754
|
}
|
|
18753
18755
|
},
|
|
18756
|
+
className: "2-SoftInputData",
|
|
18754
18757
|
children: [
|
|
18755
18758
|
!r && /* @__PURE__ */ d.jsx(Hs, { value: "", disabled: !0, children: "Selecciona…" }),
|
|
18756
18759
|
e.options.map((i) => /* @__PURE__ */ d.jsx(Hs, { value: i.value, children: i.label }, String(i.value)))
|
|
@@ -18775,7 +18778,7 @@ function kE(e, n) {
|
|
|
18775
18778
|
label: e.label,
|
|
18776
18779
|
errorMsg: r.error?.message,
|
|
18777
18780
|
helperText: e.helperText,
|
|
18778
|
-
children: /* @__PURE__ */ d.jsx(Ws, { row: !0, ...t, children: e.options.map((o) => /* @__PURE__ */ d.jsx(
|
|
18781
|
+
children: /* @__PURE__ */ d.jsx(Ws, { row: !0, ...t, className: "3-RadioFieldRender", children: e.options.map((o) => /* @__PURE__ */ d.jsx(
|
|
18779
18782
|
An,
|
|
18780
18783
|
{
|
|
18781
18784
|
value: o.value,
|
|
@@ -19149,6 +19152,7 @@ function s5(e) {
|
|
|
19149
19152
|
spacing: 2,
|
|
19150
19153
|
alignItems: "flex-start",
|
|
19151
19154
|
wrap: "wrap",
|
|
19155
|
+
width: "100%",
|
|
19152
19156
|
children: I.map((ve, Re) => {
|
|
19153
19157
|
const P = typeof ve == "string" ? { name: ve } : ve;
|
|
19154
19158
|
return P.hidden?.(b) ? null : ct(
|
package/dist/index.umd.js
CHANGED
|
@@ -179,4 +179,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${n}Chann
|
|
|
179
179
|
`)}g.write("payload.value = newResult;"),g.write("return payload;");const _=g.compile();return(T,C)=>_(p,T,C)};let s;const i=Gs,a=!Ud.jitless,l=a&&P1.value,u=n.catchall;let f;e._zod.parse=(p,g)=>{f??(f=r.value);const m=p.value;return i(m)?a&&l&&g?.async===!1&&g.jitless!==!0?(s||(s=o(n.shape)),p=s(p,g),u?uf([],m,p,g,f,e):p):t(p,g):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function df(e,n,t,r){for(const s of e)if(s.issues.length===0)return n.value=s.value,n;const o=e.filter(s=>!Rn(s));return o.length===1?(n.value=o[0].value,o[0]):(n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map(s=>s.issues.map(i=>sn(i,r,on())))}),n)}const Sx=G("$ZodUnion",(e,n)=>{at.init(e,n),Ke(e._zod,"optin",()=>n.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Ke(e._zod,"optout",()=>n.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Ke(e._zod,"values",()=>{if(n.options.every(o=>o._zod.values))return new Set(n.options.flatMap(o=>Array.from(o._zod.values)))}),Ke(e._zod,"pattern",()=>{if(n.options.every(o=>o._zod.pattern)){const o=n.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ja(s.source)).join("|")})$`)}});const t=n.options.length===1,r=n.options[0]._zod.run;e._zod.parse=(o,s)=>{if(t)return r(o,s);let i=!1;const a=[];for(const c of n.options){const l=c._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>df(c,o,e,s)):df(a,o,e,s)}}),Cx=G("$ZodIntersection",(e,n)=>{at.init(e,n),e._zod.parse=(t,r)=>{const o=t.value,s=n.left._zod.run({value:o,issues:[]},r),i=n.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,l])=>ff(t,c,l)):ff(t,s,i)}});function La(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e==+n)return{valid:!0,data:e};if(wo(e)&&wo(n)){const t=Object.keys(n),r=Object.keys(e).filter(s=>t.indexOf(s)!==-1),o={...e,...n};for(const s of r){const i=La(e[s],n[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<e.length;r++){const o=e[r],s=n[r],i=La(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};t.push(i.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function ff(e,n,t){if(n.issues.length&&e.issues.push(...n.issues),t.issues.length&&e.issues.push(...t.issues),Rn(e))return e;const r=La(n.value,t.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const kx=G("$ZodEnum",(e,n)=>{at.init(e,n);const t=M1(n.entries),r=new Set(t);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.filter(o=>j1.has(typeof o)).map(o=>typeof o=="string"?Nn(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t,input:i,inst:e}),o}}),Dx=G("$ZodLiteral",(e,n)=>{if(at.init(e,n),n.values.length===0)throw new Error("Cannot create literal schema with no valid values");e._zod.values=new Set(n.values),e._zod.pattern=new RegExp(`^(${n.values.map(t=>typeof t=="string"?Nn(t):t?Nn(t.toString()):String(t)).join("|")})$`),e._zod.parse=(t,r)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:n.values,input:o,inst:e}),t}}),Ex=G("$ZodTransform",(e,n)=>{at.init(e,n),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Wd(e.constructor.name);const o=n.transform(t.value,t);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(t.value=i,t));if(o instanceof Promise)throw new Pn;return t.value=o,t}});function pf(e,n){return e.issues.length&&n===void 0?{issues:[],value:void 0}:e}const Tx=G("$ZodOptional",(e,n)=>{at.init(e,n),e._zod.optin="optional",e._zod.optout="optional",Ke(e._zod,"values",()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,void 0]):void 0),Ke(e._zod,"pattern",()=>{const t=n.innerType._zod.pattern;return t?new RegExp(`^(${ja(t.source)})?$`):void 0}),e._zod.parse=(t,r)=>{if(n.innerType._zod.optin==="optional"){const o=n.innerType._zod.run(t,r);return o instanceof Promise?o.then(s=>pf(s,t.value)):pf(o,t.value)}return t.value===void 0?t:n.innerType._zod.run(t,r)}}),Ax=G("$ZodNullable",(e,n)=>{at.init(e,n),Ke(e._zod,"optin",()=>n.innerType._zod.optin),Ke(e._zod,"optout",()=>n.innerType._zod.optout),Ke(e._zod,"pattern",()=>{const t=n.innerType._zod.pattern;return t?new RegExp(`^(${ja(t.source)}|null)$`):void 0}),Ke(e._zod,"values",()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,null]):void 0),e._zod.parse=(t,r)=>t.value===null?t:n.innerType._zod.run(t,r)}),Mx=G("$ZodDefault",(e,n)=>{at.init(e,n),e._zod.optin="optional",Ke(e._zod,"values",()=>n.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)return t.value=n.defaultValue,t;const o=n.innerType._zod.run(t,r);return o instanceof Promise?o.then(s=>hf(s,n)):hf(o,n)}});function hf(e,n){return e.value===void 0&&(e.value=n.defaultValue),e}const Ix=G("$ZodPrefault",(e,n)=>{at.init(e,n),e._zod.optin="optional",Ke(e._zod,"values",()=>n.innerType._zod.values),e._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=n.defaultValue),n.innerType._zod.run(t,r))}),Ox=G("$ZodNonOptional",(e,n)=>{at.init(e,n),Ke(e._zod,"values",()=>{const t=n.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),e._zod.parse=(t,r)=>{const o=n.innerType._zod.run(t,r);return o instanceof Promise?o.then(s=>mf(s,e)):mf(o,e)}});function mf(e,n){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n}),e}const Px=G("$ZodCatch",(e,n)=>{at.init(e,n),Ke(e._zod,"optin",()=>n.innerType._zod.optin),Ke(e._zod,"optout",()=>n.innerType._zod.optout),Ke(e._zod,"values",()=>n.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);const o=n.innerType._zod.run(t,r);return o instanceof Promise?o.then(s=>(t.value=s.value,s.issues.length&&(t.value=n.catchValue({...t,error:{issues:s.issues.map(i=>sn(i,r,on()))},input:t.value}),t.issues=[]),t)):(t.value=o.value,o.issues.length&&(t.value=n.catchValue({...t,error:{issues:o.issues.map(s=>sn(s,r,on()))},input:t.value}),t.issues=[]),t)}}),jx=G("$ZodPipe",(e,n)=>{at.init(e,n),Ke(e._zod,"values",()=>n.in._zod.values),Ke(e._zod,"optin",()=>n.in._zod.optin),Ke(e._zod,"optout",()=>n.out._zod.optout),Ke(e._zod,"propValues",()=>n.in._zod.propValues),e._zod.parse=(t,r)=>{if(r.direction==="backward"){const s=n.out._zod.run(t,r);return s instanceof Promise?s.then(i=>ni(i,n.in,r)):ni(s,n.in,r)}const o=n.in._zod.run(t,r);return o instanceof Promise?o.then(s=>ni(s,n.out,r)):ni(o,n.out,r)}});function ni(e,n,t){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:e.value,issues:e.issues},t)}const Nx=G("$ZodReadonly",(e,n)=>{at.init(e,n),Ke(e._zod,"propValues",()=>n.innerType._zod.propValues),Ke(e._zod,"values",()=>n.innerType._zod.values),Ke(e._zod,"optin",()=>n.innerType._zod.optin),Ke(e._zod,"optout",()=>n.innerType._zod.optout),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);const o=n.innerType._zod.run(t,r);return o instanceof Promise?o.then(gf):gf(o)}});function gf(e){return e.value=Object.freeze(e.value),e}const Rx=G("$ZodCustom",(e,n)=>{Lt.init(e,n),at.init(e,n),e._zod.parse=(t,r)=>t,e._zod.check=t=>{const r=t.value,o=n.fn(r);if(o instanceof Promise)return o.then(s=>vf(s,t,r,e));vf(o,t,r,e)}});function vf(e,n,t,r){if(!e){const o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),n.issues.push(_o(o))}}class $x{constructor(){this._map=new Map,this._idmap=new Map}add(n,...t){const r=t[0];if(this._map.set(n,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,n)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(n){const t=this._map.get(n);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(n),this}get(n){const t=n._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const o={...r,...this._map.get(n)};return Object.keys(o).length?o:void 0}return this._map.get(n)}has(n){return this._map.has(n)}}function Lx(){return new $x}const oi=Lx();function zx(e,n){return new e({type:"string",...we(n)})}function Bx(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...we(n)})}function yf(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...we(n)})}function Fx(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...we(n)})}function Vx(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...we(n)})}function Yx(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...we(n)})}function Wx(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...we(n)})}function Ux(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...we(n)})}function Hx(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...we(n)})}function Zx(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...we(n)})}function Gx(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...we(n)})}function qx(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...we(n)})}function Kx(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...we(n)})}function Qx(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...we(n)})}function Xx(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...we(n)})}function Jx(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...we(n)})}function ew(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...we(n)})}function tw(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...we(n)})}function rw(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...we(n)})}function nw(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...we(n)})}function ow(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...we(n)})}function sw(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...we(n)})}function iw(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...we(n)})}function aw(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...we(n)})}function cw(e,n){return new e({type:"string",format:"date",check:"string_format",...we(n)})}function lw(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...we(n)})}function uw(e,n){return new e({type:"string",format:"duration",check:"string_format",...we(n)})}function dw(e,n){return new e({type:"number",checks:[],...we(n)})}function fw(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...we(n)})}function pw(e,n){return new e({type:"boolean",...we(n)})}function hw(e){return new e({type:"unknown"})}function mw(e,n){return new e({type:"never",...we(n)})}function bf(e,n){return new nf({check:"less_than",...we(n),value:e,inclusive:!1})}function za(e,n){return new nf({check:"less_than",...we(n),value:e,inclusive:!0})}function xf(e,n){return new of({check:"greater_than",...we(n),value:e,inclusive:!1})}function Ba(e,n){return new of({check:"greater_than",...we(n),value:e,inclusive:!0})}function wf(e,n){return new I2({check:"multiple_of",...we(n),value:e})}function _f(e,n){return new P2({check:"max_length",...we(n),maximum:e})}function si(e,n){return new j2({check:"min_length",...we(n),minimum:e})}function Sf(e,n){return new N2({check:"length_equals",...we(n),length:e})}function gw(e,n){return new R2({check:"string_format",format:"regex",...we(n),pattern:e})}function vw(e){return new $2({check:"string_format",format:"lowercase",...we(e)})}function yw(e){return new L2({check:"string_format",format:"uppercase",...we(e)})}function bw(e,n){return new z2({check:"string_format",format:"includes",...we(n),includes:e})}function xw(e,n){return new B2({check:"string_format",format:"starts_with",...we(n),prefix:e})}function ww(e,n){return new F2({check:"string_format",format:"ends_with",...we(n),suffix:e})}function So(e){return new V2({check:"overwrite",tx:e})}function _w(e){return So(n=>n.normalize(e))}function Sw(){return So(e=>e.trim())}function Cw(){return So(e=>e.toLowerCase())}function kw(){return So(e=>e.toUpperCase())}function Dw(e,n,t){return new e({type:"array",element:n,...we(t)})}function Ew(e,n,t){return new e({type:"custom",check:"custom",fn:n,...we(t)})}function Tw(e){const n=Aw(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(_o(r,t.value,n._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(_o(o))}},e(t.value,t)));return n}function Aw(e,n){const t=new Lt({check:"custom",...we(n)});return t._zod.check=e,t}function Cf(e,n){try{var t=e()}catch(r){return n(r)}return t&&t.then?t.then(void 0,n):t}function Mw(e,n){for(var t={};e.length;){var r=e[0],o=r.code,s=r.message,i=r.path.join(".");if(!t[i])if("unionErrors"in r){var a=r.unionErrors[0].errors[0];t[i]={message:a.message,type:a.code}}else t[i]={message:s,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(u){return u.errors.forEach(function(f){return e.push(f)})}),n){var c=t[i].types,l=c&&c[r.code];t[i]=Da(i,n,t,o,l?[].concat(l,r.message):r.message)}e.shift()}return t}function Iw(e,n){for(var t={};e.length;){var r=e[0],o=r.code,s=r.message,i=r.path.join(".");if(!t[i])if(r.code==="invalid_union"&&r.errors.length>0){var a=r.errors[0][0];t[i]={message:a.message,type:a.code}}else t[i]={message:s,type:o};if(r.code==="invalid_union"&&r.errors.forEach(function(u){return u.forEach(function(f){return e.push(f)})}),n){var c=t[i].types,l=c&&c[r.code];t[i]=Da(i,n,t,o,l?[].concat(l,r.message):r.message)}e.shift()}return t}function Ow(e,n,t){if(t===void 0&&(t={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,o,s){try{return Promise.resolve(Cf(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](r,n)).then(function(i){return s.shouldUseNativeValidation&&Ma({},s),{errors:{},values:t.raw?Object.assign({},r):i}})},function(i){if((function(a){return Array.isArray(a?.issues)})(i))return{values:{},errors:Vd(Mw(i.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw i}))}catch(i){return Promise.reject(i)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,o,s){try{return Promise.resolve(Cf(function(){return Promise.resolve((t.mode==="sync"?H1:Z1)(e,r,n)).then(function(i){return s.shouldUseNativeValidation&&Ma({},s),{errors:{},values:t.raw?Object.assign({},r):i}})},function(i){if((function(a){return a instanceof Ra})(i))return{values:{},errors:Vd(Iw(i.issues,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw i}))}catch(i){return Promise.reject(i)}};throw new Error("Invalid input: not a Zod schema")}const Pw=G("ZodISODateTime",(e,n)=>{rx.init(e,n),nt.init(e,n)});function jw(e){return aw(Pw,e)}const Nw=G("ZodISODate",(e,n)=>{nx.init(e,n),nt.init(e,n)});function Rw(e){return cw(Nw,e)}const $w=G("ZodISOTime",(e,n)=>{ox.init(e,n),nt.init(e,n)});function Lw(e){return lw($w,e)}const zw=G("ZodISODuration",(e,n)=>{sx.init(e,n),nt.init(e,n)});function Bw(e){return uw(zw,e)}const Jt=G("ZodError",(e,n)=>{Ra.init(e,n),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>U1(e,t)},flatten:{value:t=>W1(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ia,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ia,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fw=Qs(Jt),Vw=Xs(Jt),Yw=Js(Jt),Ww=ei(Jt),Uw=K1(Jt),Hw=Q1(Jt),Zw=X1(Jt),Gw=J1(Jt),qw=e2(Jt),Kw=t2(Jt),Qw=r2(Jt),Xw=n2(Jt),ht=G("ZodType",(e,n)=>(at.init(e,n),e.def=n,e.type=n.type,Object.defineProperty(e,"_def",{value:n}),e.check=(...t)=>e.clone({...n,checks:[...n.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(t,r)=>Br(e,t,r),e.brand=()=>e,e.register=((t,r)=>(t.add(e,r),e)),e.parse=(t,r)=>Fw(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Yw(e,t,r),e.parseAsync=async(t,r)=>Vw(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Ww(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>Uw(e,t,r),e.decode=(t,r)=>Hw(e,t,r),e.encodeAsync=async(t,r)=>Zw(e,t,r),e.decodeAsync=async(t,r)=>Gw(e,t,r),e.safeEncode=(t,r)=>qw(e,t,r),e.safeDecode=(t,r)=>Kw(e,t,r),e.safeEncodeAsync=async(t,r)=>Qw(e,t,r),e.safeDecodeAsync=async(t,r)=>Xw(e,t,r),e.refine=(t,r)=>e.check(Z_(t,r)),e.superRefine=t=>e.check(G_(t)),e.overwrite=t=>e.check(So(t)),e.optional=()=>Of(e),e.nullable=()=>Pf(e),e.nullish=()=>Of(Pf(e)),e.nonoptional=t=>B_(e,t),e.array=()=>S_(e),e.or=t=>E_([e,t]),e.and=t=>A_(e,t),e.transform=t=>Nf(e,j_(t)),e.default=t=>$_(e,t),e.prefault=t=>z_(e,t),e.catch=t=>V_(e,t),e.pipe=t=>Nf(e,t),e.readonly=()=>U_(e),e.describe=t=>{const r=e.clone();return oi.add(r,{description:t}),r},Object.defineProperty(e,"description",{get(){return oi.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return oi.get(e);const r=e.clone();return oi.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),kf=G("_ZodString",(e,n)=>{$a.init(e,n),ht.init(e,n);const t=e._zod.bag;e.format=t.format??null,e.minLength=t.minimum??null,e.maxLength=t.maximum??null,e.regex=(...r)=>e.check(gw(...r)),e.includes=(...r)=>e.check(bw(...r)),e.startsWith=(...r)=>e.check(xw(...r)),e.endsWith=(...r)=>e.check(ww(...r)),e.min=(...r)=>e.check(si(...r)),e.max=(...r)=>e.check(_f(...r)),e.length=(...r)=>e.check(Sf(...r)),e.nonempty=(...r)=>e.check(si(1,...r)),e.lowercase=r=>e.check(vw(r)),e.uppercase=r=>e.check(yw(r)),e.trim=()=>e.check(Sw()),e.normalize=(...r)=>e.check(_w(...r)),e.toLowerCase=()=>e.check(Cw()),e.toUpperCase=()=>e.check(kw())}),Jw=G("ZodString",(e,n)=>{$a.init(e,n),kf.init(e,n),e.email=t=>e.check(Bx(e_,t)),e.url=t=>e.check(Ux(t_,t)),e.jwt=t=>e.check(iw(g_,t)),e.emoji=t=>e.check(Hx(r_,t)),e.guid=t=>e.check(yf(Df,t)),e.uuid=t=>e.check(Fx(ii,t)),e.uuidv4=t=>e.check(Vx(ii,t)),e.uuidv6=t=>e.check(Yx(ii,t)),e.uuidv7=t=>e.check(Wx(ii,t)),e.nanoid=t=>e.check(Zx(n_,t)),e.guid=t=>e.check(yf(Df,t)),e.cuid=t=>e.check(Gx(o_,t)),e.cuid2=t=>e.check(qx(s_,t)),e.ulid=t=>e.check(Kx(i_,t)),e.base64=t=>e.check(nw(p_,t)),e.base64url=t=>e.check(ow(h_,t)),e.xid=t=>e.check(Qx(a_,t)),e.ksuid=t=>e.check(Xx(c_,t)),e.ipv4=t=>e.check(Jx(l_,t)),e.ipv6=t=>e.check(ew(u_,t)),e.cidrv4=t=>e.check(tw(d_,t)),e.cidrv6=t=>e.check(rw(f_,t)),e.e164=t=>e.check(sw(m_,t)),e.datetime=t=>e.check(jw(t)),e.date=t=>e.check(Rw(t)),e.time=t=>e.check(Lw(t)),e.duration=t=>e.check(Bw(t))});function lr(e){return zx(Jw,e)}const nt=G("ZodStringFormat",(e,n)=>{rt.init(e,n),kf.init(e,n)}),e_=G("ZodEmail",(e,n)=>{Z2.init(e,n),nt.init(e,n)}),Df=G("ZodGUID",(e,n)=>{U2.init(e,n),nt.init(e,n)}),ii=G("ZodUUID",(e,n)=>{H2.init(e,n),nt.init(e,n)}),t_=G("ZodURL",(e,n)=>{G2.init(e,n),nt.init(e,n)}),r_=G("ZodEmoji",(e,n)=>{q2.init(e,n),nt.init(e,n)}),n_=G("ZodNanoID",(e,n)=>{K2.init(e,n),nt.init(e,n)}),o_=G("ZodCUID",(e,n)=>{Q2.init(e,n),nt.init(e,n)}),s_=G("ZodCUID2",(e,n)=>{X2.init(e,n),nt.init(e,n)}),i_=G("ZodULID",(e,n)=>{J2.init(e,n),nt.init(e,n)}),a_=G("ZodXID",(e,n)=>{ex.init(e,n),nt.init(e,n)}),c_=G("ZodKSUID",(e,n)=>{tx.init(e,n),nt.init(e,n)}),l_=G("ZodIPv4",(e,n)=>{ix.init(e,n),nt.init(e,n)}),u_=G("ZodIPv6",(e,n)=>{ax.init(e,n),nt.init(e,n)}),d_=G("ZodCIDRv4",(e,n)=>{cx.init(e,n),nt.init(e,n)}),f_=G("ZodCIDRv6",(e,n)=>{lx.init(e,n),nt.init(e,n)}),p_=G("ZodBase64",(e,n)=>{ux.init(e,n),nt.init(e,n)}),h_=G("ZodBase64URL",(e,n)=>{fx.init(e,n),nt.init(e,n)}),m_=G("ZodE164",(e,n)=>{px.init(e,n),nt.init(e,n)}),g_=G("ZodJWT",(e,n)=>{mx.init(e,n),nt.init(e,n)}),Ef=G("ZodNumber",(e,n)=>{af.init(e,n),ht.init(e,n),e.gt=(r,o)=>e.check(xf(r,o)),e.gte=(r,o)=>e.check(Ba(r,o)),e.min=(r,o)=>e.check(Ba(r,o)),e.lt=(r,o)=>e.check(bf(r,o)),e.lte=(r,o)=>e.check(za(r,o)),e.max=(r,o)=>e.check(za(r,o)),e.int=r=>e.check(Af(r)),e.safe=r=>e.check(Af(r)),e.positive=r=>e.check(xf(0,r)),e.nonnegative=r=>e.check(Ba(0,r)),e.negative=r=>e.check(bf(0,r)),e.nonpositive=r=>e.check(za(0,r)),e.multipleOf=(r,o)=>e.check(wf(r,o)),e.step=(r,o)=>e.check(wf(r,o)),e.finite=()=>e;const t=e._zod.bag;e.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),e.isFinite=!0,e.format=t.format??null});function Tf(e){return dw(Ef,e)}const v_=G("ZodNumberFormat",(e,n)=>{gx.init(e,n),Ef.init(e,n)});function Af(e){return fw(v_,e)}const y_=G("ZodBoolean",(e,n)=>{vx.init(e,n),ht.init(e,n)});function Fa(e){return pw(y_,e)}const b_=G("ZodUnknown",(e,n)=>{yx.init(e,n),ht.init(e,n)});function Mf(){return hw(b_)}const x_=G("ZodNever",(e,n)=>{bx.init(e,n),ht.init(e,n)});function w_(e){return mw(x_,e)}const __=G("ZodArray",(e,n)=>{xx.init(e,n),ht.init(e,n),e.element=n.element,e.min=(t,r)=>e.check(si(t,r)),e.nonempty=t=>e.check(si(1,t)),e.max=(t,r)=>e.check(_f(t,r)),e.length=(t,r)=>e.check(Sf(t,r)),e.unwrap=()=>e.element});function S_(e,n){return Dw(__,e,n)}const C_=G("ZodObject",(e,n)=>{_x.init(e,n),ht.init(e,n),Ke(e,"shape",()=>n.shape),e.keyof=()=>M_(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Mf()}),e.loose=()=>e.clone({...e._zod.def,catchall:Mf()}),e.strict=()=>e.clone({...e._zod.def,catchall:w_()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>z1(e,t),e.safeExtend=t=>B1(e,t),e.merge=t=>F1(e,t),e.pick=t=>$1(e,t),e.omit=t=>L1(e,t),e.partial=(...t)=>V1(If,e,t[0]),e.required=(...t)=>Y1(jf,e,t[0])});function k_(e,n){const t={type:"object",get shape(){return zr(this,"shape",e?O1(e):{}),this.shape},...we(n)};return new C_(t)}const D_=G("ZodUnion",(e,n)=>{Sx.init(e,n),ht.init(e,n),e.options=n.options});function E_(e,n){return new D_({type:"union",options:e,...we(n)})}const T_=G("ZodIntersection",(e,n)=>{Cx.init(e,n),ht.init(e,n)});function A_(e,n){return new T_({type:"intersection",left:e,right:n})}const Va=G("ZodEnum",(e,n)=>{kx.init(e,n),ht.init(e,n),e.enum=n.entries,e.options=Object.values(n.entries);const t=new Set(Object.keys(n.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(t.has(i))s[i]=n.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Va({...n,checks:[],...we(o),entries:s})},e.exclude=(r,o)=>{const s={...n.entries};for(const i of r)if(t.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Va({...n,checks:[],...we(o),entries:s})}});function M_(e,n){const t=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Va({type:"enum",entries:t,...we(n)})}const I_=G("ZodLiteral",(e,n)=>{Dx.init(e,n),ht.init(e,n),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function O_(e,n){return new I_({type:"literal",values:Array.isArray(e)?e:[e],...we(n)})}const P_=G("ZodTransform",(e,n)=>{Ex.init(e,n),ht.init(e,n),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new Wd(e.constructor.name);t.addIssue=s=>{if(typeof s=="string")t.issues.push(_o(s,t.value,n));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),t.issues.push(_o(i))}};const o=n.transform(t.value,t);return o instanceof Promise?o.then(s=>(t.value=s,t)):(t.value=o,t)}});function j_(e){return new P_({type:"transform",transform:e})}const If=G("ZodOptional",(e,n)=>{Tx.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType});function Of(e){return new If({type:"optional",innerType:e})}const N_=G("ZodNullable",(e,n)=>{Ax.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType});function Pf(e){return new N_({type:"nullable",innerType:e})}const R_=G("ZodDefault",(e,n)=>{Mx.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $_(e,n){return new R_({type:"default",innerType:e,get defaultValue(){return typeof n=="function"?n():qd(n)}})}const L_=G("ZodPrefault",(e,n)=>{Ix.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType});function z_(e,n){return new L_({type:"prefault",innerType:e,get defaultValue(){return typeof n=="function"?n():qd(n)}})}const jf=G("ZodNonOptional",(e,n)=>{Ox.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType});function B_(e,n){return new jf({type:"nonoptional",innerType:e,...we(n)})}const F_=G("ZodCatch",(e,n)=>{Px.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function V_(e,n){return new F_({type:"catch",innerType:e,catchValue:typeof n=="function"?n:()=>n})}const Y_=G("ZodPipe",(e,n)=>{jx.init(e,n),ht.init(e,n),e.in=n.in,e.out=n.out});function Nf(e,n){return new Y_({type:"pipe",in:e,out:n})}const W_=G("ZodReadonly",(e,n)=>{Nx.init(e,n),ht.init(e,n),e.unwrap=()=>e._zod.def.innerType});function U_(e){return new W_({type:"readonly",innerType:e})}const H_=G("ZodCustom",(e,n)=>{Rx.init(e,n),ht.init(e,n)});function Z_(e,n={}){return Ew(H_,e,n)}function G_(e){return Tw(e)}const Rf=/^([01][0-9]|2[0-3]):[0-5][0-9]$/,$f=(e,n)=>{if(!e||!n)return null;const t=e.split("-");if(t.length!==3)return null;const r=parseInt(t[0],10),o=parseInt(t[1],10)-1,s=parseInt(t[2],10),i=n.split(":");if(i.length!==2)return null;const a=parseInt(i[0],10),c=parseInt(i[1],10),l=new Date(r,o,s,a,c);return isNaN(l.getTime())||!x.isValid(l)?null:l},q_=k_({titulo:lr().min(1,"El campo Título es requerido.").refine(e=>!e.startsWith(" "),{message:"El título no puede empezar con un espacio en blanco"}),fechaInicio:lr().min(1,"El campo fecha inicio es requerido."),horaInicio:lr().min(1,"La hora de inicio es requerida.").regex(Rf,{message:"Formato inválido"}),horaFin:lr().min(1,"La hora fin es requerida.").regex(Rf,{message:"Formato inválido"}),todoElDia:Fa(),fechaFin:lr().optional(),showEndDate:Fa().optional(),horaInicio2:lr().optional(),TodoElDia2:Fa().optional(),client:lr().optional().nullable(),repetir:lr().optional(),link:lr().trim().url("Debe ser una URL válida. Ejemplo https://meet.google.com/").or(O_("")).optional().refine(e=>e===void 0?!0:!/\s/.test(e),{message:"El enlace no puede contener espacios en blanco"}),descripcion:lr().optional(),color:lr().optional(),solID:Tf().optional().nullable(),disID:Tf().optional().nullable()}).refine(e=>e.showEndDate?e.fechaFin&&e.fechaFin.length>0:!0,{message:"La fecha de fin es requerida.",path:["fechaFin"]}).refine(e=>e.fechaFin!==void 0?!!e.fechaFin&&!!e.horaInicio2:!0,{message:"La hora de fin son requeridas.",path:["horaInicio2"]}).refine(e=>{if(e.todoElDia||!e.fechaInicio||!e.horaInicio||!e.fechaFin||!e.horaInicio2)return!0;const n=$f(e.fechaInicio,e.horaInicio),t=$f(e.fechaFin,e.horaFin);return!n||!t||!x.isValid(n)||!x.isValid(t)?!0:!(x.isBefore(t,n)&&!x.isSameDay(t,n)||x.isSameDay(n,t)&&x.isBefore(t,n))},{message:"",path:["horaFin"]}),Lf=e=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",...e},re.createElement("path",{fill:"#333",d:"M12 24C5.38 24 0 18.608 0 12S5.38 0 12 0s12 5.38 12 12-5.38 12-12 12"}),re.createElement("path",{fill:"#fff",d:"M16.703 7.275c.52.52.541 1.345.046 1.84l-2.874 2.874 2.874 2.873c.495.496.475 1.32-.046 1.841-.52.52-1.344.54-1.84.045l-2.873-2.873-2.874 2.873c-.496.496-1.32.475-1.84-.045-.521-.521-.541-1.345-.046-1.84l2.874-2.874L7.23 9.116c-.495-.496-.475-1.32.045-1.84.521-.521 1.345-.542 1.841-.046l2.874 2.873 2.873-2.873c.496-.496 1.32-.476 1.84.045"})),K_="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cg%20fill='%23404756'%20clip-path='url(%23a)'%3e%3cpath%20d='M7.288%2022.986h-.147a6.2%206.2%200%200%201-4.28-1.85c-2.404-2.404-2.478-6.24-.16-8.557L4.28%2011a1.228%201.228%200%201%201%201.739%201.739L4.44%2014.317c-1.356%201.357-1.282%203.626.16%205.068a3.82%203.82%200%200%200%202.602%201.135c.95%200%201.825-.32%202.479-.974l1.578-1.579a1.23%201.23%200%200%201%201.739%200c.48.481.48%201.258%200%201.739l-1.579%201.578c-1.097%201.098-2.552%201.69-4.13%201.69zM17.98%2012.998a1.23%201.23%200%200%201%200-1.739l1.578-1.578c.654-.654.986-1.53.974-2.466a3.78%203.78%200%200%200-1.134-2.602c-1.443-1.443-3.712-1.517-5.068-.16L12.75%206.03c-.48.48-1.258.48-1.739%200a1.23%201.23%200%200%201%200-1.739l1.579-1.578c2.318-2.319%206.153-2.245%208.558.16a6.23%206.23%200%200%201%201.85%204.279%205.84%205.84%200%200%201-1.69%204.279l-1.578%201.578c-.481.481-1.258.481-1.74%200z'/%3e%3cpath%20d='M14.172%208.11%208.07%2014.214a1.233%201.233%200%200%200%201.743%201.744l6.104-6.104a1.233%201.233%200%201%200-1.744-1.744'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='a'%3e%3cpath%20fill='%23fff'%20d='M0%200h24v24H0z'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Q_=e=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",...e},re.createElement("g",{clipPath:"url(#a)"},re.createElement("path",{fill:"#404756",d:"M21.24 5.72a2.98 2.98 0 0 0-2.97-2.96l-5.19-.06c-1.06-.03-2.12.41-2.87 1.17l-7.49 7.49c-.66.66-1.03 1.54-1.03 2.47s.36 1.81 1.03 2.47l4.97 4.97a3.5 3.5 0 0 0 2.47 1.02c.89 0 1.79-.34 2.47-1.02l7.49-7.49c.76-.76 1.18-1.81 1.17-2.88l-.06-5.19zm-4.2 4.43c-.44.44-1.02.66-1.6.66a2.256 2.256 0 1 1 0-4.51 2.256 2.256 0 0 1 1.6 3.85"})),re.createElement("defs",null,re.createElement("clipPath",{id:"a"},re.createElement("path",{fill:"#fff",d:"M0 0h24v24H0z"})))),X_="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23404756'%20d='M13.17%2013.68c2.06%200%204%20.8%205.46%202.27a7.7%207.7%200%200%201%202.26%205.47c0%20.79-.64%201.43-1.43%201.43l.01-.01H4.53c-.79%200-1.43-.64-1.43-1.43%200-4.27%203.46-7.73%207.72-7.73zM12%201.9c2.82%200%205.11%202.29%205.11%205.11s-2.29%205.11-5.11%205.11v-.01c-2.82%200-5.11-2.29-5.11-5.11S9.18%201.9%2012%201.9'/%3e%3c/svg%3e",J_=e=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",...e},re.createElement("g",{fill:"#2571D6",clipPath:"url(#a)"},re.createElement("path",{d:"M13.085 7.331a1.096 1.096 0 1 0-2.192 0v9.316a1.096 1.096 0 0 0 2.192 0z"}),re.createElement("path",{d:"M16.647 10.893H7.33a1.096 1.096 0 1 0 0 2.192h9.316a1.096 1.096 0 0 0 0-2.192"}),re.createElement("path",{d:"M12 24C5.38 24 0 18.608 0 12S5.38 0 12 0s12 5.38 12 12-5.38 12-12 12m0-21.808c-5.414 0-9.808 4.394-9.808 9.808S6.586 21.808 12 21.808s9.808-4.394 9.808-9.808S17.403 2.192 12 2.192"})),re.createElement("defs",null,re.createElement("clipPath",{id:"a"},re.createElement("path",{fill:"#fff",d:"M0 0h24v24H0z"})))),eS="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cg%20fill='%23404756'%20clip-path='url(%23a)'%3e%3cpath%20d='M13.789%2017H3.21C2.542%2017%202%2017.56%202%2018.25s.542%201.25%201.211%201.25H13.79c.669%200%201.211-.56%201.211-1.25S14.458%2017%2013.789%2017M20.718%204H3.282C2.574%204%202%204.56%202%205.25S2.574%206.5%203.282%206.5h17.436C21.426%206.5%2022%205.94%2022%205.25S21.426%204%2020.718%204M20.718%2010.5H3.282C2.574%2010.5%202%2011.06%202%2011.75S2.574%2013%203.282%2013h17.436c.708%200%201.282-.56%201.282-1.25s-.574-1.25-1.282-1.25'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='a'%3e%3cpath%20fill='%23fff'%20d='M0%200h24v24H0z'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",tS=e=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",...e},re.createElement("path",{fill:"#2571D6",fillRule:"evenodd",d:"M17.333 11a6.34 6.34 0 0 1 6.334 6.333 6.34 6.34 0 0 1-6.334 6.334c-3.493 0-6.333-2.846-6.333-6.334A6.343 6.343 0 0 1 17.333 11m-.005 2.37c-.437 0-.79.338-.79.754v2.412h-2.414c-.416 0-.754.355-.754.792s.338.792.754.792h2.413v2.412c0 .416.354.754.791.754s.792-.338.792-.754V18.12h2.413c.416 0 .754-.355.754-.792s-.338-.792-.754-.792H18.12v-2.412c0-.416-.355-.754-.792-.754",clipRule:"evenodd"}),re.createElement("path",{fill:"#2571D6",d:"M11.12 12.297a7.97 7.97 0 0 0-1.787 5.036c0 1.763.571 3.392 1.537 4.714H3.044c-.84 0-1.523-.682-1.523-1.523 0-4.544 3.683-8.227 8.217-8.227zM10.995.139c2.925 0 5.3 2.376 5.3 5.3s-2.376 5.3-5.3 5.3v-.01a5.303 5.303 0 0 1-5.3-5.3 5.295 5.295 0 0 1 5.3-5.29"})),zf=ut(d.jsx("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward"),an=ut(d.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),rS={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"},Ya=["#dbe3fe","#fcebc7","#d9f1d2","#fdf5d1","#ebe3d7","#e1d6fb","#f7c7cc","#f9e7fb","#eaedf2","#d5d8dd"],$n=(()=>{const e=[];for(let n=0;n<24;n++)for(let t=0;t<60;t+=15){const r=n.toString().padStart(2,"0"),o=t.toString().padStart(2,"0");e.push(`${r}:${o}`)}return e})(),Co=(e,n)=>{if(!e||!n)return null;const t=e.split("-");if(t.length!==3)return null;const r=parseInt(t[0],10),o=parseInt(t[1],10)-1,s=parseInt(t[2],10),i=n.split(":");if(i.length!==2)return null;const a=parseInt(i[0],10),c=parseInt(i[1],10),l=new Date(s,o,r,a,c);return isNaN(l.getTime())||!x.isValid(l)?null:l},nS=({isVisible:e,onClose:n,onSave:t,onDelete:r,selectedDate:o,initialEvent:s,userId:i,masNombreBD:a,disId:c})=>{const[l,u]=y.useState(!1),[f,p]=y.useState(!1),g=x.format(new Date,"yyyy-MM-dd"),[m,h]=y.useState(""),[w,S]=y.useState([]),[_,T]=y.useState(!1),C=ya(),[k,A]=y.useState([]),[P,V]=y.useState(""),{control:U,handleSubmit:B,reset:K,formState:{errors:v,isValid:N},watch:I,setValue:z}=Bd({resolver:Ow(q_),defaultValues:{titulo:"",fechaInicio:x.format(new Date,"yyyy-MM-dd"),horaInicio:x.format(new Date,"HH:mm"),horaFin:x.format(x.addHours(new Date,1),"HH:mm"),todoElDia:!1,client:"",repetir:"No repetir",link:"",descripcion:"",color:Ya[0],solID:null},mode:"onChange"}),Z=I("fechaInicio"),J=I("fechaFin"),te=I("todoElDia");y.useEffect(()=>{if(m.trim()===""||!i||!c||!a){S([]),A([]),z("solID",null),T(!1),V("");return}console.log("medo"),T(!0);const M=setTimeout(()=>{C.getClients(m,c,a,i).then(oe=>{if(T(!1),oe){const Se=oe.map(Te=>Te.solID);A([...new Set(Se)])}else A([]);const Ce=Array.from(new Map(oe.map(Se=>[Se.nombreCliente,Se])).values());if(Ce.length>0)S(Ce),V("");else if(s?.client&&s.solID!==null){const Se=[{solID:s.solID,nombreCliente:s.client}];S(Se),V("Sin resultados")}else S([]),V("Sin resultados")}).catch(oe=>{console.error("Error al buscar clientes:",oe),T(!1)})},500);return()=>clearTimeout(M)},[m,i,c,a]),y.useEffect(()=>{if(Z&&J){const M=new Date(Z),oe=new Date(J);(M===oe||M>oe)&&z("fechaFin",Z)}},[Z,J,z]),y.useEffect(()=>{Z&&z("fechaFin",Z)},[Z]),y.useEffect(()=>{z("showEndDate",l)},[l,z]),y.useEffect(()=>{if(s){const M=x.format(s.fechaInicio,"yyyy-MM-dd")===x.format(s.fechaFin,"yyyy-MM-dd");u(!M),z("titulo",s?.titulo),z("fechaInicio",x.format(s.fechaInicio,"yyyy-MM-dd")),z("fechaFin",x.format(s.fechaFin,"yyyy-MM-dd")),z("horaInicio",x.format(s.fechaInicio,"HH:mm")),z("horaFin",x.format(s.fechaFin,"HH:mm")),z("horaInicio2",x.format(s.fechaFin,"HH:mm")),z("descripcion",s.descripcion),z("link",s.link),z("repetir","false"),z("color",s.color),z("todoElDia",s.todoElDia),z("solID",s.solID),z("client",s.client),s.solID?p(!0):p(!1)}else{const M=o||new Date,oe=new Date,Ce=new Date(M.getFullYear(),M.getMonth(),M.getDate(),oe.getHours(),oe.getMinutes()),Se=x.addHours(Ce,1);K({titulo:"",fechaInicio:x.format(Ce,"yyyy-MM-dd"),horaInicio:x.format(Ce,"HH:mm"),fechaFin:x.format(Se,"yyyy-MM-dd"),horaFin:x.format(Se,"HH:mm"),horaInicio2:x.format(Se,"HH:mm"),todoElDia:!1,client:"",repetir:"No repetir",link:"",descripcion:"",color:Ya[0],solID:null}),u(!1),p(!1)}},[s,e,o]);const me=B(M=>{t(M,s?.eventoID),n(),K(),u(!1)},M=>{console.log("Errores de validación:",M)});y.useEffect(()=>{te&&(z("horaInicio","00:00"),z("horaFin","23:59"))},[te,z,I]);const Y=()=>{const M=I("fechaInicio");if(M){const oe=new Date(`${M}T00:00:00`),Ce=x.addDays(oe,1);z("fechaFin",x.format(Ce,"yyyy-MM-dd"))}u(!0)},H=I("fechaInicio"),ae=I("horaInicio"),le=I("fechaFin"),pe=I("horaFin"),[he,fe]=y.useState(null),[de,_e]=y.useState(null);y.useEffect(()=>{(he===null||he!==ae)&&fe(ae)},[ae,he]),y.useEffect(()=>{(de===null||de!==pe)&&_e(pe??"")},[pe,de]);const ke=I("todoElDia");y.useEffect(()=>{if(ke||!ae||!pe||!H||!le)return;const M=Co(H,ae),oe=Co(le,pe);if(!M||!oe||!x.isValid(M)||!x.isValid(oe))return;const Ce=x.isSameDay(M,oe),Se=Ce&&(x.isAfter(M,oe)||M.getTime()===oe.getTime()),Te=x.isBefore(oe,M)&&!Ce;(Se||Te)&&(z("horaFin",""),_e(""))},[ae,H]);const xe=y.useMemo(()=>{if(!ae||!H)return $n;const M=Co(H,ae),oe=Co(le,"00:00");return!M||!oe||!x.isValid(M)||!x.isValid(oe)||x.isBefore(oe,M)&&!x.isSameDay(oe,M)?$n:x.isSameDay(M,oe)?$n.filter(Ce=>{const Se=Co(le,Ce);return Se&&x.isAfter(Se,M)}):(x.isAfter(oe,M),$n)},[ae,H,le]),se=y.useMemo(()=>$n,[]);return d.jsx(b.Modal,{open:e,onClose:n,children:d.jsx("form",{onSubmit:me,children:d.jsxs(b.Box,{sx:rS,children:[d.jsx(b.IconButton,{"aria-label":"close",onClick:n,sx:{position:"absolute",right:8,top:12},children:d.jsx(an,{})}),d.jsx(b.Typography,{variant:"h6",mb:2,children:s?"Editar evento":"Agregar evento"}),d.jsxs(b.Grid,{container:!0,spacing:1,marginBottom:l?0:1,children:[d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(Ht,{name:"titulo",control:U,render:({field:M})=>d.jsx(b.TextField,{...M,label:"Título",fullWidth:!0,variant:"outlined",size:"small",error:!!v.titulo,helperText:v.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"}}})})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(b.Divider,{})}),d.jsx(b.Grid,{size:{xs:12,md:4},children:d.jsx(Ht,{name:"fechaInicio",control:U,render:({field:M})=>d.jsx(b.TextField,{fullWidth:!0,...M,type:"date",placeholder:"Fecha de inicio",size:"small",InputLabelProps:{shrink:!0},error:!!v.fechaInicio,helperText:v.fechaInicio?.message})})}),l?d.jsxs(d.Fragment,{children:[d.jsx(b.Grid,{size:{xs:1,md:3},sx:{display:{xs:"none",sm:"block"}}}),d.jsx(b.Grid,{size:{xs:11,md:4},children:d.jsx(Ht,{name:"fechaFin",control:U,render:({field:M})=>d.jsx(b.TextField,{...M,type:"date",placeholder:"Fecha de fin",fullWidth:!!l,size:"small",InputLabelProps:{shrink:!0},inputProps:{min:Z||g},error:!!v.fechaFin,helperText:v.fechaFin?.message})})}),!s&&d.jsx(b.Grid,{size:{xs:1,md:1},children:d.jsx(b.IconButton,{onClick:()=>u(!1),sx:{fontSize:18},children:d.jsx(Lf,{})})})]}):d.jsx(b.Grid,{size:{xs:12,md:7}})]}),l&&d.jsx(d.Fragment,{children:d.jsxs(b.Grid,{container:!0,spacing:0,sx:{margin:0,padding:0,width:"100%"},children:[d.jsx(b.Grid,{size:{xs:6,md:5}}),d.jsx(b.Grid,{size:{xs:12,md:6},sx:{margin:0,padding:0,width:"100%",display:{xs:"none",sm:"block"}},children:d.jsx(zf,{sx:{color:"#757575",margin:0,padding:0}})})]})}),d.jsxs(b.Grid,{container:!0,spacing:1,marginBottom:1,marginTop:1,children:[d.jsx(b.Grid,{size:{xs:12,md:4},children:d.jsx(Ht,{name:"horaInicio",control:U,render:({field:{onChange:M,value:oe,...Ce}})=>d.jsx(b.Autocomplete,{freeSolo:!0,options:se,value:oe||"",onChange:(Se,Te)=>M(Te||""),onInputChange:(Se,Te)=>M(Te),renderInput:Se=>d.jsx(b.TextField,{...Se,...Ce,size:"small",error:!!v.horaInicio,helperText:v.horaInicio?.message,InputProps:{...Se.InputProps,endAdornment:d.jsx(b.InputAdornment,{position:"end",sx:{position:"absolute",right:"10px"},children:d.jsx(gd,{})})}}),disabled:I("todoElDia")})})}),d.jsx(b.Grid,{size:{xs:1,md:1},sx:{display:"flex",alignItems:v.horaInicio?"start":"center",marginTop:v.horaInicio?"5px":"0px"},children:!l&&d.jsx(zf,{sx:{color:"#757575"}})}),l&&d.jsx(b.Grid,{size:{xs:2,md:2}}),d.jsx(b.Grid,{size:{xs:12,md:4},children:d.jsx(Ht,{name:"horaFin",control:U,render:({field:{onChange:M,value:oe,...Ce}})=>d.jsx(b.Autocomplete,{freeSolo:!0,options:xe,value:oe||"",onChange:(Se,Te)=>M(Te||""),onInputChange:(Se,Te)=>M(Te),renderInput:Se=>d.jsx(b.TextField,{...Se,...Ce,size:"small",error:!!v.horaFin,helperText:v.horaFin?.message,InputProps:{...Se.InputProps,endAdornment:d.jsx(b.InputAdornment,{position:"end",sx:{position:"absolute",right:"10px"},children:d.jsx(gd,{})})}}),disabled:I("todoElDia")})})}),d.jsx(b.Grid,{size:{xs:12,md:3},hidden:l,children:d.jsx(Ht,{name:"todoElDia",control:U,render:({field:M})=>d.jsx(b.FormControlLabel,{control:d.jsx(b.Checkbox,{checked:M.value,onChange:oe=>M.onChange(oe.target.checked)}),label:d.jsx("label",{style:{fontSize:"0.7rem",fontWeight:"normal"},children:"Todo el día"}),sx:{whiteSpace:"nowrap"}})})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:!l&&d.jsx(d.Fragment,{children:d.jsxs(b.Button,{onClick:Y,size:"small",sx:{textTransform:"none",fontSize:16},children:[d.jsx(J_,{})," Agregar fecha final"]})})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(b.Divider,{})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:!f&&d.jsxs(b.Button,{onClick:()=>p(!0),size:"small",sx:{textTransform:"none",fontSize:16},children:[d.jsx(tS,{})," Vincular cliente"]})}),f&&d.jsxs(d.Fragment,{children:[d.jsx(b.Grid,{size:{xs:12,md:7},children:d.jsx(Ht,{name:"client",control:U,render:({field:M})=>d.jsx(b.Autocomplete,{options:w,loading:_,loadingText:"Buscando coincidencias...",getOptionLabel:oe=>oe.nombreCliente?.trim()||"",value:w.find(oe=>oe.nombreCliente===M.value)||(M.value&&typeof M.value=="string"?{solID:-1,nombreCliente:M.value}:null),noOptionsText:P,onInputChange:(oe,Ce)=>{h(Ce)},onChange:(oe,Ce)=>{M.onChange(Ce?Ce.nombreCliente:"")},renderInput:oe=>d.jsx(b.TextField,{...oe,placeholder:"Buscar cliente...",size:"small",InputProps:{...oe.InputProps,startAdornment:d.jsx("img",{src:X_,width:20,style:{alignSelf:"flex-start",marginRight:"8px",marginTop:"5px"}}),endAdornment:d.jsxs(d.Fragment,{children:[_?d.jsx(b.CircularProgress,{color:"inherit",size:20}):null,oe.InputProps.endAdornment]})}})})})}),d.jsx(b.Grid,{size:{xs:11,md:4},children:d.jsx(Ht,{name:"solID",control:U,render:({field:M})=>d.jsx(b.Autocomplete,{options:k,noOptionsText:"Sin resultados",getOptionLabel:oe=>oe.toString(),value:M.value??null,onChange:(oe,Ce)=>M.onChange(Ce),renderInput:oe=>d.jsx(b.TextField,{...oe,label:"#Registro",variant:"outlined",size:"small",sx:{"& .MuiInputLabel-root":{backgroundColor:"transparent !important",padding:"0 !important"}}}),disabled:!w})})}),d.jsx(b.Grid,{size:{xs:1,md:1},children:d.jsx(b.IconButton,{onClick:()=>p(!1),sx:{fontSize:18},children:d.jsx(Lf,{})})})]}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(b.Divider,{})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(Ht,{name:"link",control:U,render:({field:M})=>d.jsx(b.TextField,{...M,placeholder:" Agregar enlace de reunión",fullWidth:!0,variant:"outlined",size:"small",error:!!v.link,helperText:v.link?.message,InputProps:{startAdornment:d.jsx("img",{src:K_,width:20,style:{alignSelf:"flex-start",marginRight:"8px",marginTop:"8px"}})}})})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsx(Ht,{name:"descripcion",control:U,render:({field:M})=>d.jsx(b.TextField,{...M,placeholder:" Agregar descripción aquí...",fullWidth:!0,multiline:!0,rows:3,inputProps:{maxLength:500},variant:"outlined",size:"small",InputProps:{startAdornment:d.jsx("img",{src:eS,width:20,style:{alignSelf:"flex-start",marginRight:"8px"}})}})})}),d.jsx(b.Grid,{size:{xs:12,md:12},children:d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap"},children:[d.jsx(Q_,{}),Ya.map(M=>d.jsx(Ht,{name:"color",control:U,render:({field:oe})=>d.jsx(b.IconButton,{onClick:()=>oe.onChange(M),sx:{width:24,height:24,borderRadius:"50%",bgcolor:M,border:oe.value===M?"2px solid":"none",borderColor:oe.value===M?"primary.main":"transparent"}})},M))]})})]}),d.jsxs(b.Box,{sx:{display:"flex",justifyContent:"flex-end",mt:3,gap:2},children:[s&&d.jsx(b.Button,{onClick:r,variant:"outlined",color:"error",sx:{textTransform:"none"},children:"Eliminar"}),d.jsx(b.Button,{onClick:n,variant:"outlined",sx:{textTransform:"none"},children:"Cancelar"}),d.jsx(b.Button,{onClick:me,variant:"contained",sx:{textTransform:"none"},disabled:!N,children:"Guardar"})]})]})})})},oS="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",sS={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",boxShadow:24,p:4,borderRadius:2,textAlign:"center"},iS=({isOpen:e,onClose:n,onConfirm:t,title:r,message:o})=>d.jsx(b.Modal,{open:e,onClose:n,children:d.jsxs(b.Box,{sx:sS,children:[d.jsx("img",{src:oS}),d.jsx(b.Typography,{variant:"h6",component:"h2",sx:{mt:1},children:r}),d.jsx(b.Typography,{sx:{mt:2},children:o}),d.jsxs(b.Box,{sx:{mt:4,display:"flex",justifyContent:"center",gap:2},children:[d.jsx(b.Button,{variant:"outlined",onClick:n,sx:{textTransform:"none"},children:"Regresar"}),d.jsxs(b.Button,{variant:"contained",color:"error",onClick:t,sx:{textTransform:"none"},children:[d.jsx("span",{className:"icon-eliminar",children:" "})," Eliminar"]})]})]})}),aS={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:450,bgcolor:"background.paper",boxShadow:24,p:2,borderRadius:2},cS=({isOpen:e,onClose:n,events:t,date:r,onEventClick:o})=>{if(!r)return null;const s=i=>{o(i),n()};return d.jsx(b.Modal,{open:e,onClose:n,children:d.jsxs(b.Box,{sx:aS,children:[d.jsxs(b.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},children:[d.jsxs(b.Typography,{sx:{fontSize:"20px"},component:"h2",children:["Eventos del"," ",r.toLocaleDateString("es-ES",{weekday:"long",day:"numeric",month:"long"})]}),d.jsx(b.IconButton,{onClick:n,children:d.jsx(an,{})})]}),d.jsx(b.Divider,{}),d.jsx(b.List,{children:t.map(i=>d.jsx(b.ListItem,{disablePadding:!0,children:d.jsxs(b.ListItemButton,{onClick:()=>s(i),sx:{py:.5},children:[d.jsx(b.Box,{sx:{width:"15px",height:"15px",borderRadius:"50%",backgroundColor:i.color||"#ccc",mr:2,flexShrink:0,minWidth:"10px"}}),d.jsx(b.ListItemText,{primary:i.titulo,secondary:`${x.format(i.fechaInicio,"HH:mm")} - ${x.format(i.fechaFin,"HH:mm")}`,sx:{my:0,"& .MuiListItemText-primary":{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},"& .MuiListItemText-secondary":{display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",fontSize:"12px"}}})]})},i.eventoID))})]})})},lS=ut(d.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"),uS=ut(d.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"),dS="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3cpath%20fill='%23E40B1C'%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",fS="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",Bf=y.forwardRef(({id:e,message:n,variant:t},r)=>{const{closeSnackbar:o}=To.useSnackbar(),s={success:{color:"#fff",icon:d.jsx("img",{width:25,src:fS,style:{borderRadius:"50%",backgroundColor:"#4caf50",color:"white",fontSize:"12px",padding:3}})},error:{color:"#f44336",icon:d.jsx(lS,{sx:{color:"#f44336"}})},info:{color:"#2196f3",icon:d.jsx(uS,{sx:{color:"#2196f3"}})},delete:{color:"#fff",icon:d.jsx("img",{src:dS,width:25,style:{borderRadius:"50%",backgroundColor:"#ffdfd4",color:"red",fontSize:"16px",padding:3}})}},i=s[t]||s.info;return d.jsx(To.SnackbarContent,{ref:r,children:d.jsxs(b.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 ${i.color}`},children:[d.jsx(b.Box,{sx:{mr:1.5},children:i.icon}),d.jsx(b.Typography,{variant:"body2",sx:{flexGrow:1},children:n}),d.jsx(b.IconButton,{size:"small",onClick:()=>o(e),children:d.jsx(an,{fontSize:"small"})})]})})}),Ff=y.createContext(void 0),pS=({children:e})=>{const[n,t]=y.useState([]),[r,o]=y.useState(!1);return d.jsx(Ff.Provider,{value:{googleEvents:n,setGoogleEvents:t,isLoadingGoogleEvents:r,setIsLoadingGoogleEvents:o},children:e})},hS=()=>{const e=y.useContext(Ff);if(e===void 0)throw new Error("useEvents must be used within an EventsProvider");return e},mS=(e,n,t,r)=>{const o=e.start.dateTime?new Date(e.start.dateTime):e.start.date?new Date(e.start.date):new Date;let s=e.end.dateTime?new Date(e.end.dateTime):e.end.date?new Date(e.end.date):new Date;return e.end.date&&!e.end.dateTime&&s.setDate(s.getDate()-1),{eventoID:Math.abs(gS(e.id)),titulo:e.summary||"(Sin título)",descripcion:e.description,fechaInicio:o,fechaFin:s,todoElDia:!!(e.start.date&&!e.start.dateTime),color:"#4285F4",hasVideoCall:!!e.conferenceData,link:e.htmlLink,repetir:void 0,solID:null,disID:n,client:null,usrID:t,solicitudRelacionada:[],isGoogleEvent:!0}};function gS(e){let n=0;for(let t=0;t<e.length;t++){const r=e.charCodeAt(t);n=(n<<5)-n+r,n|=0}return n}const vS=({userId:e,leads30Days:n,leads90Days:t,disId:r,masNombreBD:o})=>{const[s,i]=y.useState(new Date),[a,c]=y.useState([]),[l,u]=y.useState(!1),[f,p]=y.useState(null),[g,m]=y.useState(!1),[h,w]=y.useState(null),[S,_]=y.useState([]),{enqueueSnackbar:T}=To.useSnackbar(),C=ya();Bs();const[k,A]=y.useState(!1),[P,V]=y.useState([]),[U,B]=y.useState(null),{session:K}=sa(),{googleEvents:v,setGoogleEvents:N}=hS(),[I,z]=y.useState([]),Z=(se,M)=>{V(se),B(M),A(!0)},J=y.useRef(null);y.useEffect(()=>{const se=async()=>{try{if(e){const M=await C.getEventsByUser(e);c(M)}}catch{console.log("No se pudieron cargar los eventos. Revisa la consola para más detalles.")}};return se(),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{se()},4e3),()=>{J.current&&clearTimeout(J.current)}},[s,e,v]),y.useEffect(()=>{const se=new Date,M=x.startOfDay(se),oe=x.endOfDay(x.addDays(M,6)),Ce={start:M,end:oe},Se=a.filter(Te=>{const yt={start:Te.fechaInicio,end:Te.fechaFin};return vu(yt,Ce)}).sort((Te,yt)=>Te.fechaInicio.getTime()-yt.fechaInicio.getTime());_(Se)},[a]);const te=async se=>{try{const M=await C.getEventById(se.eventoID);p(M),u(!0)}catch(M){console.error(M)}},me=()=>{u(!1),p(null)},Y=async(se,M)=>{let oe,Ce;se.todoElDia?(oe=new Date(`${se.fechaInicio}T${se.horaInicio}`),Ce=new Date(`${se.fechaInicio}T${se.horaFin}`)):(oe=new Date(`${se.fechaInicio}T${se.horaInicio}`),Ce=se.fechaFin&&se.horaFin?new Date(`${se.fechaFin}T${se.horaFin}`):new Date(`${se.fechaInicio}T${se.horaFin}`));const Se=x.format(oe,"yyyy-MM-dd HH:mm:ss.SSS"),Te=x.format(Ce,"yyyy-MM-dd HH:mm:ss.SSS");if(M){const bt={...se,eventoID:M,fechaInicio:Se,fechaFin:Te,solID:se.solID??null,disID:r??null,client:se.client};try{const ot=await C.updateEvent(bt);var yt=a.map(D=>D.eventoID===ot.eventoID?ot:D);c(yt),T("El evento se ha actualizado correctamente.",{variant:"success"}),me()}catch{T("Error al actualizar Evento",{variant:"error"})}}else{const bt={...se,fechaInicio:Se,fechaFin:Te,todoElDia:se.todoElDia,solID:se.solID??null,disID:r??null,client:se.client};try{const ot=await C.createEvent(bt,e);c(D=>[...D,ot]),T("El evento se ha creado con éxito",{variant:"success"}),me()}catch{T("Error al guardar Evento",{variant:"error"})}}if(e){const bt=await C.getEventsByUser(e);c(bt)}},H=()=>{i(se=>new Date(se.getFullYear(),se.getMonth()-1,1))},ae=()=>{i(se=>new Date(se.getFullYear(),se.getMonth()+1,1))},le=()=>{m(!0)},pe=()=>{w(new Date),u(!0)},he=()=>alert("Sincronizar con Outlook Calendar"),fe=se=>{se&&i(se)},de=se=>{w(se),u(!0),p(null)},_e=async()=>{if(f)try{await C.deleteEvent(f.eventoID),c(a.filter(se=>se.eventoID!==f.eventoID)),T("El evento se ha eliminado de tu calendario",{content:(se,M)=>d.jsx(Bf,{id:se,message:String(M),variant:"delete"})})}catch{T("Error al eliminar Evento",{variant:"error"})}finally{me(),m(!1)}};y.useEffect(()=>{const se=[...a];if(console.log("mergedEvents",se),v.length>0&&K.userEmail&&(K.userEmail,r&&e)){const M=v.map(oe=>mS(oe,r,e));se.push(...M)}z(se)},[a,v]);const[ke,xe]=y.useState([]);return r===void 0||e===void 0?d.jsx("div",{children:"Cargando configuración de usuario..."}):d.jsxs("div",{id:"Agenda",style:{height:"100%",width:"100%"},children:[d.jsx(C0,{header:d.jsx(Wv,{currentDate:s,onPrevMonth:H,onNextMonth:ae,onAddEvent:pe,onDateChange:fe}),sidebar:d.jsx(t1,{onEventClick:te,upcomingEvents:S,onSyncOutlook:he,leads30Days:n,leads90Days:t,disID:r,usrID:e}),mainContent:d.jsx(u1,{onSeeMoreClick:Z,currentDate:s,events:I,onDayClick:de,onEventClick:te})}),l&&d.jsx(nS,{isVisible:l,onClose:me,onSave:Y,onDelete:le,selectedDate:h,initialEvent:f,userId:e,masNombreBD:o,disId:r}),d.jsx(iS,{isOpen:g,onClose:()=>m(!1),onConfirm:_e,title:"Eliminar evento",message:"¿De verdad deseas eliminar este evento? Esta acción no se puede deshacer."}),d.jsx(cS,{isOpen:k,onClose:()=>A(!1),events:P,date:U,onEventClick:te})]})},yS="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",bS="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 Wa(e,n,t){return e.accessor?e.accessor(n,t):e.field?n?.[e.field]:n?.[e?.key||""]}function xS(e,n){const t=e??"",r=n??"";return t instanceof Date&&r instanceof Date?t.getTime()-r.getTime():typeof t=="number"&&typeof r=="number"?t-r:typeof t=="boolean"&&typeof r=="boolean"?Number(t)-Number(r):String(t).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"})}function Ua(e,n,t=!0){return typeof e=="function"?e(n):e??t}function wS(e){return e.replace(/[^\d]/g,"")}function _S(e,n){return n}const SS=ut(d.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"),CS=ut(d.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 0s.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"),kS=ut(d.jsx("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown"),DS=ut(d.jsx("path",{d:"M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp");function Vf(e){return e==="right"?"end":e==="center"?"center":"start"}function Yf(e){const n=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/n}fr)`).join(" ")}const ES=1060,Ha=(e,n)=>e.metrics.find(t=>String(t.label).toLowerCase()===n.toLowerCase())?.value??"";function TS({sections:e,detailColumns:n,summaryWidths:t=["1fr",120,120,150],minWidth:r=ES,getDetailColumns:o,onRowClick:s}){function c(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 l(u){const f=u.reduce((m,h)=>m+c(h.width),0),p=Math.max(u.length-1,0)*16;return f+p+32}return d.jsx(b.Box,{sx:{border:"1px solid rgba(0,0,0,0.15)",overflow:"hidden",bgcolor:"background.paper",width:"100%"},children:d.jsxs(b.Box,{children:[d.jsx(b.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=>d.jsx(b.Typography,{sx:{fontSize:13,fontWeight:800},children:u},u))}),e.map((u,f)=>{const[p,g]=re.useState(!!u.initiallyOpen),m=f%2===1,h=o?o(u):n,w=Math.max(r,l(h));return d.jsxs(b.Box,{children:[d.jsxs(b.Box,{sx:{display:"grid",gridTemplateColumns:t.map(S=>typeof S=="number"?`${S}px`:S).join(" "),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:m?"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(S=>!S),children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[d.jsx(b.IconButton,{size:"small",disableRipple:!0,children:p?d.jsx(DS,{}):d.jsx(kS,{})}),d.jsx(b.Typography,{sx:{fontWeight:700,fontSize:14,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(u.title),children:u.title})]}),d.jsx(b.Typography,{sx:{fontSize:13.5,fontWeight:800},children:Ha(u,"En Proceso")}),d.jsx(b.Typography,{sx:{fontSize:13.5,fontWeight:800},children:Ha(u,"Finalizadas")}),d.jsx(b.Typography,{sx:{fontSize:13.5,fontWeight:800},children:Ha(u,"Último seg.")})]}),d.jsx(b.Collapse,{in:p,unmountOnExit:!0,children:d.jsxs(b.Box,{sx:{overflowX:"auto","&::-webkit-scrollbar":{height:"5px"}},children:[d.jsx(b.Box,{sx:{minWidth:w,display:"grid",gridTemplateColumns:Yf(h),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:h.map(S=>d.jsx(b.Typography,{sx:{justifySelf:Vf(S.align),textAlign:S.align??"left",fontSize:12.5,fontWeight:800,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:S.header},S.key))}),(u.rows??[]).map((S,_)=>d.jsx(b.Box,{sx:{minWidth:w,display:"grid",gridTemplateColumns:Yf(h),columnGap:"16px",alignItems:"center",px:"16px",py:1,bgcolor:_%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:()=>s?.(S,u),children:h.map((T,C)=>{const k=T.accessor?T.accessor(S,_):T.field?S[T.field]:null;return d.jsx(b.Box,{sx:{justifySelf:Vf(T.align),textAlign:T.align??"left",minWidth:0},children:typeof k=="string"||typeof k=="number"?d.jsx(b.Typography,{sx:{fontSize:13,fontWeight:/^(estatus|seg|avance|nivel|asesor|fecha)$/i.test(T.key)?700:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:String(k),children:k}):k},T.key??C)})},S.id??_))]})})]},u.id)})]})})}const AS=ut(d.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"),MS=e=>e?new Date(e).toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}).replace(".",""):"",IS=e=>{const n=`${e?.Nombre??""} ${e?.Apellido??""}`.trim();return n||(e?.IdAsesor?e?.Correo??"Usuario":"Sin asesor asignado")},OS=e=>{const n=(e||"").split(" ").filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():(e?.[0]??"?").toUpperCase()},PS=ut(d.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.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Create"),Za=({current:e,total:n,color:t="#4caf50"})=>d.jsx("div",{style:{display:"flex",gap:"1px",width:"100%",height:"100%",justifyContent:"center"},children:Array.from({length:n}).map((r,o)=>d.jsx("div",{style:{width:"7px",height:"7px",borderRadius:"2px",backgroundColor:o<e?t:"#e0e0e0",display:"flex"}},o))}),jS=ut(d.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),NS=ut(d.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack");function RS(e){const n=new Date(e),t=n.toLocaleDateString("es-MX",{day:"2-digit",month:"short",year:"numeric"}),r=n.toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"});return`${t.replace(".","")} • ${r}`}function $S(e){return e.replace(/<br\s*\/?>/gi,`
|
|
180
180
|
`).replace(/\r\n/g,`
|
|
181
181
|
`).replace(/\r/g,`
|
|
182
|
-
`)}function LS({open:e,onClose:n,customer:t,fields:r=[],header:o,extraSections:s,normalTable:i,normalTableColumns:a=[],history:c=[],advisorHistory:l=[],onRequestEdit:u,searchFilter:f,solicitudesNuevos:p=[],solicitudesPrueba:g=[],solicitudesServicio:m=[],solicitudesSeminuevos:h=[],onCreateSolicitud:w,isCrmMode:S=!1,onSolicitudBaseUrl:_}){if(!t)return null;const T=3,[C,k]=y.useState(null),A=!!C,P=y.useMemo(()=>[...l].sort((L,ve)=>new Date(ve.FechaAsignacion).getTime()-new Date(L.FechaAsignacion).getTime()),[l]),V=o?.title??(L=>L?.Nombre||L?.name||"Sin título"),U=o?.infoItems??[],B=L=>{if(!L)return{bg:"#E0E0E0",color:"#333"};const ve=L.toLowerCase();return ve.includes("actualiz")?{bg:"#E8F1FF",color:"#1E60D1"}:ve.includes("recorda")?{bg:"#F5E7FF",color:"#7A3DB8"}:{bg:"#EEE",color:"#333"}},K=L=>L.NombreAsesor?.trim()||(L.Email?L.Email:"Sistema"),v=L=>{const ve=L||"",Ie=ve.split(" ").filter(Boolean);return Ie.length>=2?(Ie[0][0]+Ie[1][0]).toUpperCase():(ve[0]||"?").toUpperCase()},N=[...c].sort((L,ve)=>new Date(ve.FecAlta).getTime()-new Date(L.FecAlta).getTime()),[I,z]=y.useState(!1),Z=y.useMemo(()=>I?N:N.slice(0,T),[I,N]),J=Math.max(N.length-T,0),te=L=>String(L??"").normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase().trim(),me=(L,ve)=>te(JSON.stringify(L)).includes(te(ve)),Y=(L,ve)=>f?f(L,ve):me(L,ve),H=(L,ve)=>{const Ie=te(ve).split(/\s+/).filter(Boolean);return Ie.length?Ie.every(Xe=>Y(L,Xe)):!0},[ae,le]=y.useState(""),[pe,he]=y.useState([]);y.useMemo(()=>i??[],[i]),y.useMemo(()=>{const L=ae.trim();return L?(i??[]).filter(ve=>H(ve,L)):i??[]},[i,ae]);const fe=b.useTheme(),de=b.useMediaQuery(fe.breakpoints.down("md")),[_e,ke]=y.useState(""),[xe,se]=y.useState(!1),[M,oe]=y.useState(!1),Ce=new Date().toISOString().slice(0,10),Se=new Date(Date.now()-720*3600*1e3).toISOString().slice(0,10),[Te,yt]=y.useState(Se),[bt,ot]=y.useState(Ce),[D,O]=y.useState(null),F=!!D,[ne,ee]=y.useState("Todos"),j=["Selección y presentación","Ingreso del Vehículo","En reparación","Entrega de vehículo","Agendar Cita"],[Q,ye]=y.useState("Todos"),Ae=()=>{ke(""),se(!1),oe(!1),yt(Se),ot(Ce),ee("Todos"),ye("Todos")};function R(L){if(!L)return"";const ve=new Date(L);if(isNaN(ve.getTime()))return"";const Ie=String(ve.getDate()).padStart(2,"0"),Xe=String(ve.getMonth()+1).padStart(2,"0"),Je=String(ve.getFullYear()).slice(-2);return`${Ie}/${Xe}/${Je}`}function X(L){const ve=L?new Date(L):null;return ve&&!isNaN(ve.getTime())?ve:null}function ge(L,ve){let Ie=null;for(const Xe of L){const Je=X(ve(Xe));if(Je){const Et=Je.getTime();(Ie===null||Et>Ie)&&(Ie=Et)}}return Ie?new Date(Ie):null}function He(L){const ve=ge(L,Ie=>Ie.UltimoSeguimiento||Ie.FechaCita);return ve?R(ve.toISOString()):"—"}function St(L){return L.filter(ve=>/finalizad/i.test(ve.EstatusDescripcion??"")).length}function Ct(L){return L.length-St(L)}const Ir=({progress:L,color:ve})=>{if(!L)return d.jsx(Za,{current:0,total:0,color:ve});const Ie=L.split("/").map(Number);if(Ie.length!==2||Ie.some(Et=>Number.isNaN(Et)))return d.jsx(Za,{current:0,total:0,color:ve});const[Xe,Je]=Ie;return d.jsx(Za,{current:Xe,total:Je,color:ve})},er=[{key:"fecha",header:"Fecha",accessor:L=>R(L.Fecha),width:110},{key:"vehiculo",header:"Vehículo",accessor:L=>d.jsx(b.Tooltip,{title:L.Vehiculo??"",placement:"top",arrow:!0,children:d.jsx(b.Typography,{component:"span",sx:{fontSize:13,fontWeight:500,display:"block",maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3,cursor:"default"},children:L.Vehiculo??"—"})}),width:260},{key:"estatus",header:"Estatus",accessor:L=>d.jsx(b.Typography,{sx:{fontWeight:800,fontSize:13},children:L.EstatusDescripcion||"—"}),width:170},{key:"nivel",header:"Nivel de Interés",accessor:L=>d.jsx(b.Box,{sx:{display:"inline-block",px:1,py:.25,borderRadius:9999,bgcolor:"#F59E0B",color:"#fff",fontSize:12,fontWeight:800},children:L.NivelInteres??"—"}),width:150},{key:"asesor",header:"Asesor",accessor:L=>d.jsx(b.Tooltip,{title:L.Asesor??"",placement:"top",children:d.jsx(b.Typography,{sx:{fontWeight:700,fontSize:13,textAlign:"center"},children:(L.Asesor??"").split(" ").filter(Boolean).map(ve=>ve[0]?.toUpperCase()).slice(0,2).join("")||"—"})}),width:120,align:"center"},{key:"origen",header:"Origen",accessor:L=>L.Origen??"—",width:90,align:"center"},{key:"actividad",header:"Actividad",accessor:L=>L.Actividad??"—",width:220},{key:"avance",header:"Avance",accessor:L=>d.jsx(Ir,{progress:L.Avance}),width:200,align:"left"}],cn=[{key:"fecha",header:"Fecha",accessor:L=>R(L.Fecha),width:110},{key:"fechaCita",header:"Fecha Cita",accessor:L=>R(L.FechaCita),width:120},{key:"horaCita",header:"Hora Cita",accessor:L=>L.HoraCita??"—",width:110},...er.slice(1)];function Yr(L){switch(L.kind){case"pruebas":case"servicio":return cn;default:return er}}function ln(L,ve,Ie,Xe){return{id:L,kind:Ie,title:ve,metrics:[{label:"En Proceso",value:Ct(Xe)},{label:"Finalizadas",value:St(Xe)},{label:"Último seg.",value:He(Xe)}],rows:Xe,initiallyOpen:!1}}const Or=[ln("n-1","Cotización de nuevos","nuevos",p),ln("p-1","Prueba de Manejo","pruebas",g),ln("s-1","Cita de Servicio","servicio",m),ln("sn-1","Cotización para Seminuevos","seminuevos",h)],ko=y.useMemo(()=>{const L=xe?new Date(Te):null,ve=xe?new Date(bt):null,Ie=(_e??"").trim().toLowerCase(),Xe=(Je,Et)=>{if(Ie&&!(Je.Vehiculo??"").toLowerCase().includes(Ie))return!1;const un=M?Je.FechaCita:Je.Fecha;if(xe&&(L||ve)){const _r=X(un??"");if(!_r)return!1;const Ln=L?new Date(L):null,E=ve?new Date(ve):null;if(Ln&&Ln.setHours(0,0,0,0),E&&E.setHours(23,59,59,999),Ln&&_r<Ln||E&&_r>E)return!1}return!(ne!=="Todos"&&!(Je.EstatusDescripcion??"").toLowerCase().includes(ne.toLowerCase())||Q!=="Todos"&&(Je.Actividad??"")!==Q)};return Or.map(Je=>{const Et=(Je.rows??[]).filter(_r=>Xe(_r,Je.kind)),un=[{label:"En Proceso",value:Ct(Et)},{label:"Finalizadas",value:St(Et)},{label:"Último seg.",value:He(Et)}];return{...Je,rows:Et,metrics:un}})},[Or,_e,xe,Te,bt,M,ne,Q]),[Do,Eo]=y.useState(!1),[ci,li]=y.useState(null),Qa={nuevos:"cotizaciones",pruebas:"pruebademanejo",servicio:"citasservicio",seminuevos:"seminuevos"},ui=(L,ve)=>{const Ie=L.SolID;if(!Ie)return;const Xe=ve.kind,Je=Qa[Xe]??"cotizaciones",Et=`https://qa2.crm.netcar.com.mx/netcar/${Je}/${Ie}`,un=_?.({row:L,section:ve,slug:Je,solId:Ie,baseUrl:Et});if(!S){const _r=un??`https://qa2.crm.netcar.com.mx/netcar/${Je}/${Ie}`;li(_r),Eo(!0)}};return d.jsx(b.Dialog,{open:e,onClose:n,fullWidth:!0,fullScreen:de,PaperProps:{sx:{height:{xs:"100dvh",md:"90vh"},maxWidth:{xs:"100vw",md:"92vw"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},height:"100%",minHeight:0,overflow:"auto",position:"relative"},children:[d.jsxs(b.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:[d.jsxs(b.Box,{children:[d.jsx(b.Stack,{direction:"row",spacing:2,alignItems:"center",mb:1,sx:{px:2.5,pt:2.5},children:d.jsxs(b.Box,{display:"flex",flexDirection:"column",gap:1,width:"100%",children:[d.jsx(b.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",alignItems:"center",children:d.jsx(b.Box,{sx:{flex:1,minWidth:0,pr:1},children:d.jsxs(b.Typography,{component:"span",fontWeight:700,sx:{display:"inline",lineHeight:1.2,wordBreak:"break-word",pr:.5},children:[V(t)," ",d.jsx(b.IconButton,{component:"span",size:"small",disableRipple:!0,onClick:()=>{n?.(),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:d.jsx(PS,{sx:{fontSize:"1em"}})})]})})}),U.map((L,ve)=>d.jsxs(b.Box,{sx:{display:"flex",gap:1.2,alignItems:"center",cursor:L.onClick?"pointer":"default"},onClick:()=>{L.onClick&&L.onClick(t),n()},children:[L.icon,d.jsx(b.Typography,{variant:"body2",sx:{color:L.inLink?"#336BE1":"#070C10"},style:{},children:L.value(t)})]},ve))]})}),d.jsx(b.Stack,{mb:2,sx:{px:2.5,pt:0,gap:2},children:r.map((L,ve)=>{const Ie=L.label?.toLowerCase().startsWith("asesor");return d.jsxs(b.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[d.jsx(b.Box,{sx:{width:"50%"},children:d.jsx(b.Typography,{variant:"body2",color:"text.secondary",sx:{color:"#5C6372"},children:L.label})}),d.jsxs(b.Box,{sx:{width:"50%",display:"flex",alignItems:"center",gap:1},children:[d.jsx("div",{children:L?.avatar?L.avatar(t):null}),d.jsx(b.Typography,{variant:"body2",color:"textPrimary",children:L?.value(t)}),Ie&&d.jsx(b.Tooltip,{title:"Historial asesores",placement:"top",arrow:!0,children:d.jsx(b.IconButton,{size:"small",onClick:Xe=>k(Xe.currentTarget),sx:{ml:.5},disableRipple:!0,children:d.jsx(AS,{fontSize:"small",sx:{color:"#5C6372"}})})})]})]},ve)})}),d.jsx(b.Divider,{sx:{my:2}})]}),d.jsx(b.Box,{px:2.5,pb:.5,children:d.jsx(b.Typography,{fontWeight:800,children:"Historial Actividad:"})}),d.jsxs(b.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:[Z.length===0&&d.jsx(b.Typography,{variant:"body2",color:"text.secondary",children:"Sin actividad registrada."}),d.jsxs(b.Box,{children:[Z?.map((L,ve)=>{const Ie=K(L),{bg:Xe,color:Je}=B(L.TipoComentario),Et=$S(L.Comentario||"");return d.jsxs(b.Box,{sx:{pb:1.5},children:[d.jsxs(b.Stack,{direction:"row",spacing:1,alignItems:"center",justifyContent:"space-between",sx:{mb:.75},children:[d.jsx(b.Typography,{variant:"subtitle2",sx:{color:"#5C6372"},children:L.TipoComentario||"Evento"}),d.jsx(b.Chip,{size:"small",label:L.DisID!=null?`${L.NombreDistribuidora}`:"—",sx:{bgcolor:Xe,color:Je,height:20}})]}),Et?d.jsx(b.Typography,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line",lineHeight:1.5,mb:.75},children:Et}):null,d.jsxs(b.Stack,{direction:"row",spacing:1.25,alignItems:"center",children:[L?.ImgAsesor!=null?d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},alt:v(Ie),src:L?.ImgAsesor}):d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},children:v(Ie)}),d.jsxs(b.Stack,{spacing:0,children:[d.jsx(b.Typography,{variant:"body2",fontWeight:600,children:Ie}),d.jsx(b.Typography,{variant:"caption",color:"text.secondary",children:RS(L.FecAlta)})]})]}),ve<N.length-1&&d.jsx(b.Divider,{sx:{mt:1.25}})]},L.SegID??ve)}),N.length>T&&d.jsx(b.Box,{sx:{mt:1},children:d.jsx(b.Button,{onClick:()=>z(L=>!L),size:"small",sx:{textTransform:"none",px:0,color:"#336BE1","&:hover":{background:"transparent",textDecoration:"underline"}},children:I?"Ver menos":`Ver más (${J})`})})]})]}),d.jsx(b.Menu,{anchorEl:C,open:A,onClose:()=>k(null),TransitionComponent:b.Fade,MenuListProps:{disablePadding:!0},PaperProps:{sx:{width:320,p:0,overflow:"hidden"}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[d.jsx(b.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"}),d.jsxs(b.Box,{sx:{overflowY:"auto",py:.5,maxHeight:200},children:[P.length===0&&d.jsx(b.Box,{sx:{px:1.5,py:1},children:d.jsx(b.Typography,{variant:"body2",color:"text.secondary",children:"Sin registros"})}),P.map((L,ve)=>{const Ie=IS(L),Xe=MS(L.FechaBaja??L.FechaAsignacion);return d.jsx(b.Box,{sx:{px:1,py:.75},children:d.jsxs(b.Stack,{direction:"row",alignItems:"center",spacing:1,children:[d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},src:L?.ImgAsesor??void 0,children:OS(Ie)}),d.jsx(b.Box,{sx:{flex:1,minWidth:0},children:d.jsx(b.Typography,{variant:"body2",noWrap:!0,children:Ie})}),d.jsx(b.Typography,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:Xe})]})},ve)})]})]})})]}),Do?d.jsxs(b.Box,{sx:{flex:1,minWidth:0,overflow:"hidden",position:"relative"},children:[d.jsx(b.Box,{sx:{position:"absolute",top:18,left:24,zIndex:10,pointerEvents:"auto"},children:d.jsx(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:d.jsx(b.Button,{onClick:()=>Eo(!1),sx:{backgroundColor:"#2571d6",minWidth:36,minHeight:36,p:.5,borderRadius:"8px",color:"#fff",boxShadow:3,"&:hover":{backgroundColor:"#2074e3"}},children:d.jsx(NS,{fontSize:"medium"})})})}),ci&&d.jsx("iframe",{src:ci,width:"100%",height:"100%"})]}):d.jsxs(b.Box,{sx:{width:"100%",minHeight:0,overflowY:"auto"},children:[d.jsx(b.Box,{sx:{mt:{xs:1.5,md:3}},children:d.jsxs(b.Box,{sx:{mt:3,display:"flex",flexDirection:"column",gap:4,padding:"0 20px 0 20px"},children:[d.jsx(b.Typography,{variant:"h4",sx:{fontWeight:800,textAlign:"center",mb:1,letterSpacing:.2},children:"Solicitudes"}),d.jsxs(b.Stack,{direction:{xs:"column",md:"column"},spacing:1.5,alignItems:{xs:"stretch",md:"center"},justifyContent:"space-between",sx:{mb:1.5},children:[d.jsxs(b.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",sx:{flexWrap:"wrap"},children:[d.jsx(b.TextField,{size:"small",placeholder:"Buscar por vehículo",value:_e,onChange:L=>ke(L.target.value),InputProps:{endAdornment:d.jsx(CS,{fontSize:"small",sx:{color:"#b6afaf"}})},sx:{minWidth:220}}),d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,position:"relative"},children:[d.jsxs(b.Stack,{direction:"row",spacing:1.2,position:"absolute",bottom:48,left:0,alignItems:"center",children:[d.jsx(b.FormControlLabel,{label:d.jsx(b.Typography,{sx:{fontSize:15,fontWeight:700,marginLeft:0},children:"Por fecha"}),labelPlacement:"start",control:d.jsx(b.Checkbox,{checked:xe,onChange:L=>se(L.target.checked),size:"small",sx:{p:.3,"& .MuiSvgIcon-root":{fontSize:20}}}),sx:{ml:0,"& .MuiFormControlLabel-label":{marginRight:0}}}),d.jsx(b.Typography,{sx:{fontSize:15,fontWeight:700},children:"De cita"})]}),d.jsxs(b.Stack,{direction:"row",spacing:1,children:[d.jsx(b.TextField,{size:"small",type:"date",label:"Desde",InputLabelProps:{shrink:!0},value:Te,onChange:L=>yt(L.target.value),disabled:!xe,sx:{width:170}}),d.jsx(b.TextField,{size:"small",type:"date",label:"Hasta",InputLabelProps:{shrink:!0},value:bt,onChange:L=>ot(L.target.value),disabled:!xe,sx:{width:170}})]})]}),d.jsx(b.IconButton,{onClick:L=>O(L.currentTarget),disableRipple:!0,sx:{border:"1px solid #d4d7de",borderRadius:2,width:40,height:40,mt:2},children:d.jsx(SS,{})}),d.jsx(b.Button,{variant:"outlined",onClick:Ae,disableRipple:!0,sx:{height:40,textTransform:"none",borderColor:"#d4d7de",color:"#333",mt:2},children:"Limpiar filtros"}),d.jsxs(b.Button,{variant:"outlined",sx:{height:40,textTransform:"none",borderColor:"none",color:"#fff",backgroundColor:"#1e5bce","&:hover":{backgroundColor:"#1e5bce",boxShadow:"none"},mt:2},onClick:()=>{w?.(t)},disableRipple:!0,children:[d.jsx(jS,{sx:{color:"#fff",fontSize:24,paddingRight:.6}}),"Crear Solicitud"]})]}),d.jsx(TS,{sections:ko,detailColumns:er,getDetailColumns:Yr,onRowClick:ui})]})]})}),d.jsx(b.Menu,{anchorEl:D,open:F,onClose:()=>O(null),TransitionComponent:b.Fade,PaperProps:{sx:{p:1.5,width:260,borderRadius:2,boxShadow:3}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:d.jsxs(b.Stack,{spacing:1.5,paddingX:1.5,paddingY:1,children:[d.jsx(b.Typography,{variant:"subtitle2",sx:{fontWeight:700,color:"#070C10"},children:"Filtro"}),d.jsxs(b.Box,{children:[d.jsx(b.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Estatus"}),d.jsx(b.RadioGroup,{value:ne,onChange:L=>ee(L.target.value),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos","Sin Asignar","Sin Atender","Asignada","Confirmadas","En seguimiento","Rechazadas","Finalizadas"].map(L=>d.jsx(b.FormControlLabel,{value:L,control:d.jsx(b.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:L},L))})]}),d.jsxs(b.Box,{children:[d.jsx(b.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Actividades"}),d.jsx(b.RadioGroup,{value:Q,onChange:L=>ye(L.target.value),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos",...j].map(L=>d.jsx(b.FormControlLabel,{value:L,control:d.jsx(b.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:L},L))})]})]})})]})]})})}const Wf={tableClientes:"_tableClientes_acwe7_1",tableResponsive:"_tableResponsive_acwe7_1"};function Uf(e,n,t){const{fields:r,order:o=["nombreCliente","email","acciones"],header:s={},cells:i={},hide:a={},actions:c}=n,l=c??{},u=l.show??{},f=l.handlers??{},p=l.accessors??{},g=l.icons??{},m=l.className??"d-flex flex-row gap-2 align-items-center ",h=l.tooltip??{},w=g.view??d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",style:{fill:"#070c10"},children:[d.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"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),S={nombreCliente:{key:"nombreCliente",header:s.nombreCliente??"Cliente",accessor:B=>B[r.nombreCliente],cell:i.nombreCliente,width:190},email:{key:"email",header:s.email??"Correo",accessor:B=>B[r.email],cell:i.email??(B=>{const K=String(B[r.email]??"");return K?d.jsx("a",{href:`mailto:${K}`,children:K}):d.jsx("span",{className:"text-muted",children:"—"})}),width:230},acciones:a.acciones?void 0:{key:"acciones",header:"",cell:i.acciones??(B=>{const K=Ua(u.whatsapp,B,!0),v=Ua(u.email,B,!0),N=Ua(u.view,B,!0),I=p.phone?.(B),z=p.email?.(B),Z=me=>{if(me.stopPropagation(),f.onWhatsApp)return f.onWhatsApp(B);if(!I)return;const Y=p.countryCode??"52",H=wS(String(I));typeof window<"u"&&window.open(`https://wa.me/${Y}${H}`,"_blank")},J=me=>{if(me.stopPropagation(),f.onEmail)return f.onEmail(B);z&&typeof window<"u"&&(window.location.href=`mailto:${z}`)},te=me=>{me.stopPropagation(),f.onView&&f.onView(B)};return d.jsxs("div",{className:m,children:[K&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.whatsapp??"WhatsApp",onClick:Z,style:{width:24,height:24},children:d.jsx("img",{src:yS,alt:"WhatsApp"})}),v&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.email??"Email",onClick:J,style:{width:24,height:24},children:d.jsx("img",{src:bS,alt:"Email"})}),N&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.view??"Ver detalle",onClick:te,style:{width:24,height:24},children:w})]})}),width:120}},_=Object.values(S).filter(B=>!!B),T=(e??[]).filter(B=>!!B?.key),C=new Map;for(const B of _)C.set(String(B.key),B);for(const B of T)C.set(String(B.key),B);const k=[..._.map(B=>String(B.key)),...T.map(B=>String(B.key))],A=Array.from(new Set(o.map(B=>String(B)).filter(B=>C.has(B)))),P=k.filter(B=>!A.includes(B)),V=[...A,...P],U="acciones";if(C.has(U)){const B=V.filter(K=>K!==U);V.splice(0,V.length,...B,U)}return V.map(B=>C.get(B))}function zS(e){const{rows:n,columns:t,clientSort:r=!0,defaultSort:o,minWidth:s=1100,rowKey:i=_S,defaults:a,detailConfig:c,extraSections:l,normalTableColumns:u,normalTable:f,onRowClick:p,activityHistory:g,advisorHistory:m,forceOpenDetailFor:h,closeDetailFor:w,onRequestEdit:S,searchFilter:_,solicitudesNuevos:T,solicitudesPrueba:C,solicitudesServicio:k,solicitudesSeminuevos:A,onCreateSolicitud:P,isCrmMode:V,onSolicitudBaseUrl:U}=e,[B,K]=y.useState(o??null),[v,N]=y.useState({open:!1,customer:null}),[I,z]=y.useState([]),Z=H=>{N({open:!0,customer:H});const ae=c?.vehiclesProvider?.(H)??[];z(Array.isArray(ae)?ae:[])},J=H=>{p?.(H),N({open:!0,customer:H});const ae=c?.vehiclesProvider?.(H)??[];z(Array.isArray(ae)?ae:[])},te=()=>{N({open:!1,customer:null}),w?.()},me=y.useMemo(()=>a?Uf(t??[],a):Uf(t??[],{fields:{},order:[]}),[t,a]),Y=y.useMemo(()=>{if(!r||!B)return n;const H=me.find(le=>le.key===B.key);if(!H)return n;const ae=[...n];return ae.sort((le,pe)=>{const he=Wa(H,le,0),fe=Wa(H,pe,0),de=xS(he,fe);return B.direction==="asc"?de:-de}),ae},[n,me,B,r]);return y.useEffect(()=>{h&&Z(h)},[h]),d.jsxs("div",{children:[d.jsx("div",{className:`${Wf.tableClientes} back-white rounded-3 shadow-main mt-4 mb-4`,children:d.jsx("div",{className:`${Wf.tableResponsive} table-responsive`,children:d.jsxs("table",{className:"table table-hover align-middle mb-0",children:[d.jsx("thead",{children:d.jsx("tr",{children:me.map(H=>d.jsx("th",{style:{fontWeight:600,width:H.width,paddingTop:"20px",paddingBottom:"20px",textAlign:H.align??"left"},children:H.header},H.key))})}),d.jsx("tbody",{children:Y.map((H,ae)=>d.jsx("tr",{onClick:()=>J?.(H),role:"button",tabIndex:0,onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&J?.(H)},style:{cursor:"pointer"},children:me.map((le,pe)=>{const he=le.Component?d.jsx(le.Component,{row:H,index:ae}):le.cell?le.cell(H,ae):(()=>{const fe=Wa(le,H,ae);return fe==null||fe===""?"":String(fe)})();return d.jsx("td",{style:{paddingTop:"20px",paddingBottom:"20px",textAlign:le.align??"left"},children:he},`${String(le.key)}-${pe}`)})},i(H,ae)))})]})})}),v.open&&d.jsx(LS,{open:v.open,onClose:te,customer:v.customer,fields:c?.dynamicFields,header:c?.header,extraSections:l,normalTableColumns:u,normalTable:f,history:g,advisorHistory:m,onRequestEdit:H=>{te(),S?.(H)},searchFilter:_,solicitudesNuevos:T,solicitudesPrueba:C,solicitudesServicio:k,solicitudesSeminuevos:A,onCreateSolicitud:P,isCrmMode:V,onSolicitudBaseUrl:U})]})}const Hf=re.forwardRef(({sx:e,...n},t)=>d.jsx(b.InputBase,{inputRef:t,...n,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}}));Hf.displayName="SoftInput";const BS=ut(d.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"ErrorOutline");function FS({message:e}){return e?d.jsxs(b.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:[d.jsx(BS,{fontSize:"small",sx:{color:"rgb(211, 47, 47)"}}),d.jsx("span",{style:{color:"rgb(95, 33, 32)",fontSize:14,fontWeight:"500"},children:e})]}):null}function VS(e){if(e.required)return e.required===!0?"El campo es obligatorio.":e.required}function Ga(e,n){const t=VS(e);return t?n?.isArray?{required:t,validate:r=>Array.isArray(r)&&r.length>0||t}:{required:t,validate:r=>r!==""&&r!==null&&r!==void 0||t}:{}}const Zf={"& .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"}},YS={mb:1,fontWeight:600,color:"#1C1C1D","&.Mui-focused":{color:"#1C1C1D !important"},"&.Mui-error":{color:"#1C1C1D !important"}};function qa({label:e,errorMsg:n,helperText:t,children:r,sx:o}){return d.jsxs(b.FormControl,{fullWidth:!0,error:!!n,sx:o,children:[d.jsx(b.FormLabel,{sx:YS,children:e}),r,d.jsx(FS,{message:n||t})]})}function WS(e,n){const{register:t,formState:{errors:r}}=n,o={...Ga(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 s=e.type==="email";s&&!o.pattern&&(o.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo electrónico inválido"});const i=/[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]/g,a=/[0-9]/g,c=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Escape","Enter"]),l=C=>e.onlyNumbers?(C.match(a)??[]).join(""):e.onlyLetters?(C.match(i)??[]).join(""):C,u=(C,k)=>c.has(C)||k?!0:e.onlyNumbers?/^[0-9]$/.test(C):e.onlyLetters?/^[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]$/.test(C):!0,f=r[e.name]?.message,p=t(e.name,o),g=(e.inputProps&&typeof e.inputProps.maxLength=="number"?e.inputProps.maxLength:void 0)??e.maxLength,m=C=>{u(C.key,C.ctrlKey||C.metaKey)||C.preventDefault()},h=C=>{const k=C.data??null;k!=null&&(e.onlyNumbers&&/[^0-9]/.test(k)&&C.preventDefault(),e.onlyLetters&&/[^A-Za-zÁÉÍÓÚÜÑáéíóúüñ ]/.test(k)&&C.preventDefault())},w=C=>{const k=C.clipboardData.getData("text"),A=l(k);if(A!==k){C.preventDefault();const P=C.target,V=P.selectionStart??P.value.length,U=P.selectionEnd??P.value.length;P.setRangeText(A,V,U,"end"),P.dispatchEvent(new Event("input",{bubbles:!0}))}},S=C=>{const k=l(C.target.value);k!==C.target.value&&(C.target.value=k),g&&C.target.value.length>g&&(C.target.value=C.target.value.slice(0,g)),p.onChange(C)},_={...e.inputProps,...s?{inputMode:"email",autoComplete:"email"}:{},maxLength:g,onKeyDown:m,onBeforeInput:h,onPaste:w,onInvalid:C=>C.preventDefault()},T=e.onlyNumbers||s?"text":e.type??"text";return d.jsx(qa,{label:e.label,errorMsg:f,helperText:e.helperText,sx:Zf,children:d.jsx(Hf,{placeholder:e.placeholder,type:T,inputProps:_,...p,onChange:S,sx:{width:"100%",maxWidth:"none"}})})}function US(e,n){const{control:t}=n,r=!!e.multiple;return d.jsx(Ht,{name:e.name,control:t,rules:Ga(e,{isArray:r}),render:({field:o,fieldState:s})=>d.jsx(qa,{label:e.label,errorMsg:s.error?.message,helperText:e.helperText,sx:Zf,children:d.jsxs(b.Select,{...o,multiple:r,displayEmpty:!0,sx:{height:48,backgroundColor:"#EBEEF0","& .MuiSelect-select":{display:"flex",alignItems:"center",py:0}},children:[!r&&d.jsx(b.MenuItem,{value:"",disabled:!0,children:"Selecciona…"}),e.options.map(i=>d.jsx(b.MenuItem,{value:i.value,children:i.label},String(i.value)))]})})})}function HS(e,n){return d.jsx(Ht,{name:e.name,control:n.control,rules:Ga(e),render:({field:t,fieldState:r})=>d.jsx(qa,{label:e.label,errorMsg:r.error?.message,helperText:e.helperText,children:d.jsx(b.RadioGroup,{row:!0,...t,children:e.options.map(o=>d.jsx(b.FormControlLabel,{value:o.value,control:d.jsx(b.Radio,{}),label:o.label},String(o.value)))})})})}function Gf(e,n){if(e.render)return e.render(n);switch(e.kind){case"text":return WS(e,n);case"select":return US(e,n);case"radio":return HS(e,n);default:return null}}function ZS(e,{initialPerPage:n=25,perPageOptions:t=[10,25,50,100,"Todos"],onPageChange:r,onPerPageChange:o,scrollTop:s,deps:i=[]}={}){const a=Array.isArray(e)?e:[],[c,l]=y.useState(1),[u,f]=y.useState(n),{currentItems:p,totalPages:g,showingFrom:m,showingTo:h,totalItems:w}=y.useMemo(()=>{const T=a.length,C=u==="Todos"?1/0:Number(u),k=C===1/0?1:Math.max(1,Math.ceil(T/C)),A=Math.min(c,k),P=C===1/0?T:A*C,V=C===1/0?0:P-C;return{currentItems:C===1/0?a:a.slice(V,P),totalPages:k,showingFrom:T===0?0:V+1,showingTo:C===1/0?T:Math.min(P,T),totalItems:T}},[a,c,u]),S=T=>{const C=Math.max(1,Math.min(T,g||1));l(C),r?.(C),s?.()};return{currentItems:p,totalPages:g,showingFrom:m,showingTo:h,totalItems:w,currentPage:c,itemsPerPage:u,perPageOptions:t,goTo:S,next:()=>S(c+1),prev:()=>S(c-1),setItemsPerPage:T=>{f(T),o?.(T),l(1),s?.()},setCurrentPage:S}}const GS=ut(d.jsx("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),qS=ut(d.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),KS=({currentPage:e,totalPages:n,onPageChange:t,itemsPerPage:r,onItemsPerPageChange:o,itemsPerPageOptions:s,showingFrom:i,showingTo:a,totalItems:c})=>{const l=b.useTheme(),u=b.useMediaQuery(l.breakpoints.down("sm")),f=()=>{if(n<=1)return[1];const m=u?0:2,h=[],w=1,S=n,_=Math.max(w+1,e-m),T=Math.min(S-1,e+m);h.push(w),_>w+1&&h.push("...");for(let C=_;C<=T;C++)C>=w+1&&C<=S-1&&h.push(C);return T<S-1&&h.push("..."),h.push(S),h},p=m=>{const h=m.target.value;o(h)},g=Math.max(1,n);return d.jsxs(b.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:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",justifyContent:"center"},children:[d.jsx(b.IconButton,{onClick:()=>t(e-1),disabled:e<=1,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página anterior",children:d.jsx(GS,{fontSize:"large"})}),f().map((m,h)=>m==="..."?d.jsx(b.Box,{sx:{px:1,display:"flex",alignItems:"center",fontSize:"1.1rem"},children:". . ."},`dots-${h}`):d.jsx(b.Button,{onClick:()=>t(m),size:"small",sx:{minWidth:36,height:36,fontSize:"1.05rem",p:1,borderRadius:"10px",backgroundColor:e===m?"primary.main":"transparent",fontWeight:e===m?700:400,color:e===m?"#fff":"#5C6372","&:hover":{backgroundColor:e===m?"primary.dark":"action.hover"},boxShadow:"none",border:"none",mx:.5},children:m},`p-${m}`)),d.jsx(b.IconButton,{onClick:()=>t(e+1),disabled:e>=g,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página siguiente",children:d.jsx(qS,{fontSize:"large"})})]}),d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,justifyContent:{xs:"center",sm:"flex-start"},mt:{xs:1,sm:0}},children:[d.jsx(b.Typography,{variant:"body2",children:"Mostrar"}),d.jsx(b.FormControl,{size:"small",sx:{minWidth:72},children:d.jsx(b.Select,{value:r,onChange:p,renderValue:m=>m==="Todos"?"Todos":String(m),children:s.map(m=>d.jsx(b.MenuItem,{value:m,children:m==="Todos"?"Todos":m},String(m)))})}),d.jsx(b.Typography,{variant:"body2",children:"por página"})]})]})};function QS(e){const{open:n,dataAdd:t,fields:r,onSubmit:o,onCancel:s,defaultValues:i,txtBtnGuardar:a,haveId:c=!1,itemsTable:l,filter:u,getId:f,renderRow:p,selectedIds:g,onSelectedChange:m,onSubmitAddData:h,initialSelectedIds:w=[],showAutosPanel:S}=e,_=Bd({mode:"onSubmit",reValidateMode:"onChange",criteriaMode:"all",shouldUnregister:!1,defaultValues:i});y.useEffect(()=>{i&&_.reset(i)},[i,_]);const[T,C]=y.useState(""),[k,A]=y.useState(w),P=Array.isArray(g)&&!!m,V=P?g:k,U=j=>{const Q=typeof j=="function"?j(V):j;P?m(Q):A(Q)},B=y.useCallback(j=>f?f(j):j?.IdAuto,[f]),K=y.useMemo(()=>{const j=new Map;return(l??[]).forEach((Q,ye)=>j.set(B(Q),ye)),j},[l,B]),v=y.useRef(new Set),N=y.useMemo(()=>{const j=new Map;return(l??[]).forEach(Q=>j.set(f?f(Q):Q?.IdAuto,Q)),j},[l,f]),I=y.useMemo(()=>(r??[]).filter(j=>!!j.required).map(j=>j.name),[r]),z=_d({control:_.control,name:I}),Z=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,J=y.useMemo(()=>I.length?z?.every(Z)??!1:!0,[z,I]),{handleSubmit:te,formState:{isSubmitting:me,isDirty:Y,isValid:H}}=_,ae=u??((j,Q)=>JSON.stringify(j).toLowerCase().includes(Q.toLowerCase())),le=y.useMemo(()=>T.trim()?l?.filter(j=>ae(j,T)):l,[l,T,ae]),pe=y.useMemo(()=>{if(!le)return le;const j=v.current,Q=[...le];return Q.sort((ye,Ae)=>{const R=j.has(B(ye))?0:1,X=j.has(B(Ae))?0:1;if(R!==X)return R-X;const ge=K.get(B(ye))??0,He=K.get(B(Ae))??0;return ge-He}),Q},[le,K,B]),{currentItems:he,totalPages:fe,showingFrom:de,showingTo:_e,totalItems:ke,currentPage:xe,itemsPerPage:se,perPageOptions:M,goTo:oe,setItemsPerPage:Ce}=ZS(pe,{initialPerPage:25,perPageOptions:[10,25,50,100,"Todos"],deps:[T],scrollTop:()=>{}}),Se=j=>{const Q=N.get(j)??null;U([j]),h?.({items:Q})},Te=j=>V.includes(j),yt=async j=>{try{await o?.(j),_.reset(_.getValues())}catch(Q){console.error("Error al enviar AddCliente:",Q)}},bt=y.useMemo(()=>{const j=new Map;return(r??[]).forEach(Q=>j.set(String(Q.name),Q)),j},[r]),ot=(j,Q)=>{const ye=bt.get(String(j));if(!ye)return null;const Ae={xs:12,...ye.grid,...Q||{}};return d.jsx(b.Grid,{item:!0,...Ae,children:ye.render?ye.render(_):Gf(ye,_)},`fld-${String(j)}`)},D=S??(e.haveId?"edit":"new"),O=D!=="onlyCars",F=D==="new"||D==="onlyCars",ne=V?.length>0,ee=D==="onlyCars"?ne:e.haveId?J&&Y||ne:J&≠return d.jsx(b.Dialog,{open:n,onClose:s,maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{height:{xs:"100dvh",md:F?"90vw":"auto"},maxWidth:{xs:"100vw",md:F?"98vw":"50%"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:d.jsx(p1,{..._,children:d.jsxs(b.Box,{component:"form",noValidate:!0,onSubmit:te(yt),display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",height:"100%",overflow:{xs:"auto",md:"unset"},position:"relative",children:[O&&d.jsxs(b.Box,{sx:{width:{xs:"100%",md:c?"100%":394},maxWidth:{xs:"100%",md:c?"100%":394},boxShadow:{xs:"none",md:c?"none":"2px 0px 8px #40404024"},borderRight:{xs:"none",md:c?"none":"1px solid #EBEEF0"},bgcolor:"background.paper",paddingBottom:3,mx:{xs:0,md:c?"auto":0},"& .form-body":{maxWidth:c?760:"unset",margin:"0 auto"},position:"relative"},children:[d.jsxs(b.Box,{p:{xs:2,md:2},height:"100%",sx:{"& .MuiFormControl-root, & .MuiTextField-root":{width:"100%",maxWidth:"none"}},children:[d.jsx(b.Typography,{fontWeight:700,fontSize:20,children:t.title}),d.jsxs(b.Box,{sx:{flex:1,height:"100%",overflowY:"auto",paddingBottom:10},children:[d.jsx(b.Typography,{fontSize:"18px",mt:2.5,fontWeight:500,children:t.subTitle}),d.jsx(b.Box,{mt:2,display:"flex",flexDirection:"column",width:"100%",gap:2,children:Array.isArray(e.formLayout)&&c?e.formLayout.map((j,Q)=>d.jsx(b.Grid,{container:!0,spacing:2,alignItems:"flex-start",wrap:"wrap",children:j.map((ye,Ae)=>{const R=typeof ye=="string"?{name:ye}:ye;return R.hidden?.(_)?null:ot(R.name,R.grid)})},`row-${Q}`)):d.jsx(b.Grid,{container:!0,spacing:2,width:"100%",children:r?.map((j,Q)=>{const ye=j.grid??{xs:12,md:12};return d.jsx(b.Grid,{item:!0,...ye,width:"100%",children:j.render?j.render(_):Gf(j,_)},`${String(j.name)}-${Q}`)})})})]})]}),d.jsx(b.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:d.jsx(b.Box,{display:"flex",alignItems:"center",children:d.jsx(b.Box,{display:"flex",gap:1.5,width:"100%",justifyContent:c?"flex-end":"center",children:d.jsx(b.Button,{type:"submit",variant:"contained",disabled:me||!ee,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:c?"160px":"100%"},children:a})})})})]}),F&&d.jsx(b.Box,{flex:1,display:"flex",flexDirection:"column",minWidth:0,sx:{height:"100%"},children:d.jsx(b.Box,{mt:1,sx:{flex:1,display:"flex",flexDirection:"column",height:"100%"},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[d.jsxs(b.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:[d.jsx(b.TextField,{value:T,onChange:j=>C(j.target.value),placeholder:"Buscar marca, modelo, vin...",InputProps:{endAdornment:d.jsx(b.InputAdornment,{position:"start",children:d.jsx(ey,{})}),disableUnderline:!0},variant:"standard",sx:{maxWidth:360,width:"100%",backgroundColor:"#EBEEF0",paddingX:"16px",paddingY:"10px"}}),d.jsx(b.Box,{display:"flex",gap:2,alignItems:"center",sx:{marginTop:{sm:0,xs:2}},children:d.jsx(b.Box,{onClick:s,sx:{cursor:"pointer",position:"absolute",top:0,right:10},display:{xs:"none",md:"block"},children:d.jsx(an,{sx:{color:"#070C10",fontSize:24}})})}),S=="onlyCars"&&d.jsx(b.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:d.jsx(b.Box,{display:"flex",gap:1.5,width:"100%",children:d.jsx(b.Button,{type:"submit",variant:"contained",disabled:me||!ee,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:"100%"},children:"Crear Cotización"})})})]}),d.jsx(b.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:d.jsx(b.Box,{sx:{minWidth:1150,width:"max(1150px, 100%)",paddingBottom:10},children:d.jsxs(b.List,{disablePadding:!0,sx:{borderColor:"transparent",padding:0},children:[he?.map((j,Q)=>{const ye=f?f(j):Q,Ae=Te(ye);return d.jsx(b.Box,{sx:{borderBottom:"1px solid #D3D4D5",padding:0},children:d.jsx(b.ListItem,{disableGutters:!0,sx:{paddingTop:0,padding:0,m:0},children:d.jsx(b.ListItemButton,{onClick:()=>Se(ye),disableRipple:!0,sx:{padding:0},children:d.jsx(b.ListItemText,{disableTypography:!0,primary:p?p({item:j,selected:Ae,toggle:()=>Se(ye),index:Q}):null})})})},`${String(ye)}`)}),!he?.length&&d.jsx(b.Box,{p:3,children:d.jsxs(b.Typography,{fontSize:14,color:"#5C6372",children:["Sin resultados para “",T,"”."]})})]})})}),d.jsx(b.Box,{sx:{position:"sticky",bottom:0,bgcolor:"#fff"},children:d.jsx(KS,{currentPage:xe,totalPages:fe,onPageChange:oe,itemsPerPage:se,onItemsPerPageChange:Ce,itemsPerPageOptions:M,showingFrom:de,showingTo:_e,totalItems:ke})})]})})})]})})})}const XS=ut(d.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"),Ka=/^[^\s@]+@[^\s@]+\.[^\s@]+$/i,ai=/[,\s;]+/g,Fr=e=>e.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase(),Vr=(e,n)=>Array.from(new Set([...e,...n.map(t=>t.trim()).filter(Boolean)])),qf=(e,n)=>n?e.filter(t=>Fr(t)!==Fr(n)):e,JS=(e,n)=>e.filter(t=>!n.some(r=>Fr(r)===Fr(t)));function ur(e,n,t){if(t)return typeof t=="function"?t(e,n):e[t]}function eC(e,n){if(n)return!e||/^https?:\/\//i.test(n)?n:e+n}function tC({open:e,onClose:n,value:t,onChange:r,onRequestSend:o,customer:s,itemsSelects:i,renderItem:a,filterFields:c=[],multiSelectAutos:l=!0,imgCorreoSrc:u,baseURLImages:f,itemProps:p,defaultItemImageSrc:g}){const m=y.useRef(null),[h,w]=y.useState("idle"),S=y.useRef(e);y.useEffect(()=>{const R=S.current;e&&!R&&w("entering"),!e&&R&&w("exiting"),S.current=e},[e]),y.useEffect(()=>{if(h==="entering"){const ge=setTimeout(()=>w("idle"),320);return()=>clearTimeout(ge)}if(h==="exiting"){const ge=setTimeout(()=>w("idle"),220);return()=>clearTimeout(ge)}},[h]);const[_,T]=y.useState(""),[C,k]=y.useState(!1),[A,P]=y.useState(!1),[V,U]=y.useState(!1),[B,K]=y.useState(""),[v,N]=y.useState([]),I=V?v:t.selectedIds,z=()=>{N([...t.selectedIds]),K(""),U(!0)},Z=()=>{U(!1),N([])},J=()=>{const R=new Set(bt.map((ge,He)=>String(ur(ge,He,p.id)))),X=v.filter(ge=>R.has(String(ge)));r({...t,selectedIds:X}),U(!1)},te=(R,X)=>Fr(R??"")===Fr(X??"");function me(R,X,ge,He,St){const Ct=X?R.some(er=>te(er,X)):!1,Ir=ge.length>0?ge.some(er=>R.some(cn=>te(cn,er))):!1;He(Ct),St(Ir)}const Y=R=>{const X=typeof R=="function"?R(t.recipients):R;r({...t,recipients:X}),me(X,he,de,k,P)},H=R=>r({...t,message:R}),ae=R=>r({...t,attachments:[...t.attachments,...R]}),le=R=>r({...t,attachments:t.attachments.filter(X=>X.name!==R)}),pe=R=>{if(V)if(l){const X=new Set(v);X.has(R)?X.delete(R):X.add(R),N(Array.from(X))}else{const X=v.includes(R);N(X?[]:[R])}else if(l){const X=new Set(t.selectedIds);X.has(R)?X.delete(R):X.add(R),r({...t,selectedIds:Array.from(X)})}else{const X=t.selectedIds.includes(R);r({...t,selectedIds:X?[]:[R]})}},he=y.useMemo(()=>(s?.Correo??"").trim(),[s]),fe=y.useMemo(()=>Array.isArray(s?.Asesores)?s.Asesores.filter(R=>R?.EmailAsesor&&R?.Activo):[],[s]),de=y.useMemo(()=>fe.map(R=>(R.EmailAsesor??"").trim()).filter(Boolean),[fe]),_e=y.useRef(!1);y.useEffect(()=>{if(e&&!_e.current){let R=[];C&&he&&(R=Vr(R,[he])),A&&de.length&&(R=Vr(R,de)),Y(X=>Vr(X,R)),me(t.recipients,he,de,k,P),T(""),_e.current=!0}e||(_e.current=!1)},[e,C,A,he,de]);const ke=R=>{const X=fe.find(ge=>Fr(ge.EmailAsesor??"")===Fr(R));if(X){if(X.ImgAsesor)return d.jsx(b.Avatar,{src:X.ImgAsesor,alt:X.NombreAsesor});const ge=(X.NombreAsesor||"").trim(),He=(X.ApellidosAsesor||"").trim();return d.jsx(b.Avatar,{children:`${ge[0]??""}${He[0]??""}`.toUpperCase()})}return d.jsx(b.Avatar,{children:R[0]?.toUpperCase()})},xe=()=>{const R=_.trim();if(!R)return;const ge=R.split(ai).filter(Boolean).filter(He=>Ka.test(He));ge.length>0&&Y(He=>Vr(He,ge)),T("")},se=R=>{k(R),Y(X=>R&&he?Vr(X,[he]):qf(X,he))},M=R=>{P(R),Y(X=>R?Vr(X,de):JS(X,de))},oe=R=>{const X=Array.from(R.target.files||[]);ae(X.map(ge=>({name:ge.name,size:ge.size,file:ge}))),R.target.value=""},Ce=I[0],Se=y.useMemo(()=>!i||Ce===void 0?void 0:i.find((X,ge)=>String(ur(X,ge,p.id))===String(Ce)),[i,Ce,p.id]),Te=y.useMemo(()=>{if(!(!Se||!p.distributorId))return ur(Se,0,p.distributorId)},[Se,p.distributorId]);console.log("lockedDisId",Te);const yt=y.useMemo(()=>Se?(p.distributorTitle?ur(Se,0,p.distributorTitle):void 0)??(Te!=null?String(Te):void 0):void 0,[Se,p.distributorTitle,Te]),bt=y.useMemo(()=>{const R=i??[];return Te==null||!p.distributorId?R:R.filter((X,ge)=>ur(X,ge,p.distributorId)==Te)},[i,Te,p.distributorId]),ot=y.useMemo(()=>{if(!B.trim())return bt;const R=B.toLowerCase();return bt.filter(X=>(c??[]).some(ge=>String(X?.[ge]??"").toLowerCase().includes(R)))},[bt,B,c]),D=y.useMemo(()=>{if(!i||!t.selectedIds.length)return[];const R=new Map;return i.forEach((X,ge)=>{R.set(String(ur(X,ge,p.id)),X)}),t.selectedIds.map(X=>R.get(String(X))).filter(Boolean)},[i,t.selectedIds,p.id]),O=R=>r({...t,selectedIds:t.selectedIds.filter(X=>String(X)!==String(R))}),F=()=>{let R=t.recipients;if(_.trim()){const Ct=_.split(ai).filter(Ir=>Ka.test(Ir));R=Vr(R,Ct),Y(R),T("")}const X=C?he:"",ge=fe.find(Ct=>Ct?.Activo&&Ct?.EmailAsesor)?.EmailAsesor?.trim()??"";o?.({recipients:R,toClient:C,toAdvisor:A,tipoInt:C&&A?2:1,correoCliente:X,correoAsesor:A?ge:"",disIdLocked:Te}),n?.()},ne=y.useMemo(()=>{const X=_.split(ai).filter(Boolean).some(ge=>Ka.test(ge));return t.recipients.length>0||X},[t.recipients,_]),ee=(t.selectedIds?.length??0)>0,j=t.message.trim().length>0,Q=ne&&ee&&j,ye=b.useTheme(),Ae=b.useMediaQuery(ye.breakpoints.down("sm"));return d.jsxs(b.Drawer,{anchor:Ae?"bottom":"right",open:e,onClose:n,ModalProps:{keepMounted:!0,BackdropProps:{invisible:!Ae}},transitionDuration:{enter:320,exit:220},SlideProps:{direction:Ae?"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:[d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",height:{xs:"100%",sm:"auto"},position:"relative",overflow:"auto"},children:[d.jsxs(b.Box,{sx:{p:2,pb:1,position:"sticky",top:0,zIndex:1,bgcolor:"#fff",borderBottom:"1px solid #E5E7EB"},children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[u?d.jsx("img",{src:u,alt:"Correo",style:{width:24,height:18}}):null,d.jsxs(b.Typography,{fontWeight:700,children:["Mensaje a"," ",s?`${s.Nombre??""} ${s.ApellidoP??""} ${s.ApellidoM??""}`.trim():"—"]})]}),d.jsx(b.IconButton,{onClick:n,size:"small",children:d.jsx(an,{})})]}),d.jsx("div",{children:d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 10px",backgroundColor:"#EBEEF0",border:"1px solid #E5E7EB",borderRadius:8,flexWrap:"wrap"},children:[d.jsx("label",{style:{fontSize:14,fontWeight:600,marginRight:4},children:"Para:"}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",flex:1},children:[t.recipients.map(R=>d.jsx(b.Chip,{avatar:ke(R),label:R,onDelete:()=>Y(X=>qf(X,R)),size:"small",variant:"outlined",sx:{borderRadius:999,height:28}},R)),d.jsx("input",{type:"text",value:_,onChange:R=>T(R.target.value),onKeyDown:R=>{const X=R.key;X==="Enter"||X===","||X===";"||X===" "||X==="Tab"?(R.preventDefault(),xe()):X==="Backspace"&&!_&&t.recipients.length&&Y(He=>He.slice(0,-1))},onBlur:xe,onPaste:R=>{const ge=R.clipboardData.getData("text").split(ai).filter(Boolean);ge.length>1&&(R.preventDefault(),Y(He=>Vr(He,ge)),T(""))},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"}})]})]})}),d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1.5},children:[d.jsx(b.FormControlLabel,{control:d.jsx(b.Checkbox,{checked:C,onChange:R=>se(R.target.checked),size:"small"}),label:"Cliente"}),fe.length!==0&&d.jsx(b.FormControlLabel,{control:d.jsx(b.Checkbox,{checked:A,onChange:R=>M(R.target.checked),size:"small"}),label:`Asesor${fe.length>1?"es":""}`})]})]}),d.jsx(b.Divider,{}),d.jsxs(b.Box,{p:2,children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},onClick:z,children:[d.jsx(b.Typography,{fontSize:12,fontWeight:600,sx:{textDecorationLine:"underline",cursor:"pointer"},children:"Selecciona el auto de seguimiento"}),yt!=null&&d.jsx(b.Chip,{size:"small",label:`Distribuidora: ${yt}`})]}),D.length>0?d.jsx(b.Box,{sx:{mt:1.5,display:"flex",gap:1,flexWrap:"wrap"},children:D.map((R,X)=>{const ge=ur(R,X,p.id),He=ur(R,X,p.title)??"",St=ur(R,X,p.image),Ct=eC(f,St);return d.jsx(b.Chip,{onDelete:()=>O(ge),label:d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(b.Box,{sx:{width:28,height:20,borderRadius:.8,bgcolor:"#e5e6e8",overflow:"hidden",flex:"0 0 auto"},children:Ct?d.jsx("img",{src:Ct,alt:He,style:{width:"100%",height:"100%",objectFit:"cover"}}):d.jsx("img",{src:g,alt:He,style:{width:"100%",height:"100%",objectFit:"cover"}})}),d.jsx("span",{style:{fontSize:12},children:d.jsx("b",{children:He})})]}),sx:{pl:.5,pr:.3,py:.2,borderRadius:2,".MuiChip-deleteIcon":{fontSize:18}},variant:"outlined"},String(ge))})}):d.jsx(b.Typography,{fontSize:13,color:"#5C6372",sx:{mt:.5},children:"Aún no has seleccionado autos."})]}),d.jsx(b.Divider,{}),d.jsxs(b.Box,{sx:{p:2},children:[d.jsx(b.TextField,{placeholder:"Escribe aquí tu mensaje...",value:t.message,onChange:R=>H(R.target.value),multiline:!0,minRows:6,fullWidth:!0,sx:{mb:1.5}}),t.attachments.length>0&&d.jsx(b.List,{dense:!0,sx:{display:"flex",flexDirection:"column",gap:2,border:"none"},children:t.attachments.map(R=>d.jsxs(b.ListItem,{sx:{px:0,background:"#EAEBF2",borderRadius:2,paddingX:1},children:[d.jsx(b.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"}}),d.jsx(b.Tooltip,{title:"Quitar",children:d.jsx(b.IconButton,{edge:"end",onClick:()=>le(R.name),size:"small",children:d.jsx(an,{fontSize:"small"})})})]},R.name))})]}),d.jsxs(b.Box,{sx:{position:{xs:"sticky",sm:"sticky"},bottom:0,bgcolor:"#fff",borderTop:"1px solid #E5E7EB",p:2,display:"flex",alignItems:"center",gap:2},children:[d.jsx("input",{ref:m,hidden:!0,type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.mp4,.pdf,.xlsx,.csv,.docx,.pptx,.txt",onChange:oe}),d.jsx(b.Button,{startIcon:d.jsx(XS,{}),variant:"text",onClick:()=>m.current?.click(),sx:{color:"#5C6372"},children:"Adjuntar archivo"}),d.jsx(b.Box,{sx:{flex:1}}),d.jsx(b.Button,{variant:"contained",onClick:F,disabled:!Q,sx:{maxWidth:146,width:"100%",height:53,backgroundColor:"#336BE1"},children:"Enviar"})]})]}),d.jsxs(b.Dialog,{fullWidth:!0,maxWidth:"sm",fullScreen:Ae,open:V,onClose:Z,children:[d.jsxs(b.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:["Selecciona tu auto de seguimiento",d.jsx(b.IconButton,{onClick:Z,size:"small",children:d.jsx(an,{})})]}),d.jsxs(b.DialogContent,{children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(b.TextField,{placeholder:"Buscar...",fullWidth:!0,size:"small",value:B,onChange:R=>K(R.target.value),sx:{mb:2}}),yt!=null&&d.jsx(b.Chip,{size:"small",label:`Distribuidora: ${yt}`})]}),d.jsxs(b.Typography,{variant:"caption",fontWeight:600,children:["RESULTADOS (",ot.length,")"]}),d.jsxs(b.List,{sx:{p:0},children:[ot.map((R,X)=>{const ge=ur(R,X,p.id),He=I.includes(String(ge))||I.includes(ge),St=Te==null||ur(R,X,p.distributorId)==Te;return d.jsx(b.ListItem,{disableGutters:!0,sx:{p:0,opacity:St?1:.5},children:d.jsx(b.Box,{onClick:()=>St&&pe(ge),sx:{cursor:St?"pointer":"not-allowed",p:.5,backgroundColor:He?"#e5f0ff":"transparent",width:"100%",borderBottom:"solid 1px #D3D4D5"},children:a?a(R,X):d.jsx("pre",{style:{margin:0},children:JSON.stringify(R,null,2)})})},String(ge))}),ot.length===0&&d.jsx(b.Box,{p:2,children:d.jsx(b.Typography,{children:"Tu búsqueda no generó resultados"})})]})]}),d.jsxs(b.DialogActions,{sx:{px:3,pb:2},children:[d.jsx(b.Button,{variant:"text",onClick:Z,sx:{color:"#5C6372"},children:"Cancelar"}),d.jsx(b.Button,{variant:"contained",onClick:J,sx:{backgroundColor:"#336BE1"},children:"Guardar selección"})]})]})]})}ct.AddCliente=QS,ct.ApiProvider=Jb,ct.AuthProvider=Ey,ct.Clientes=zS,ct.CustomSnackbar=Bf,ct.EventsProvider=pS,ct.ModalCorreo=tC,ct.MyCalendar=vS,ct.useAuth=sa,ct.useAuthRepository=Bs,ct.useEventRepository=ya,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})}));
|
|
182
|
+
`)}function LS({open:e,onClose:n,customer:t,fields:r=[],header:o,extraSections:s,normalTable:i,normalTableColumns:a=[],history:c=[],advisorHistory:l=[],onRequestEdit:u,searchFilter:f,solicitudesNuevos:p=[],solicitudesPrueba:g=[],solicitudesServicio:m=[],solicitudesSeminuevos:h=[],onCreateSolicitud:w,isCrmMode:S=!1,onSolicitudBaseUrl:_}){if(!t)return null;const T=3,[C,k]=y.useState(null),A=!!C,P=y.useMemo(()=>[...l].sort((L,ve)=>new Date(ve.FechaAsignacion).getTime()-new Date(L.FechaAsignacion).getTime()),[l]),V=o?.title??(L=>L?.Nombre||L?.name||"Sin título"),U=o?.infoItems??[],B=L=>{if(!L)return{bg:"#E0E0E0",color:"#333"};const ve=L.toLowerCase();return ve.includes("actualiz")?{bg:"#E8F1FF",color:"#1E60D1"}:ve.includes("recorda")?{bg:"#F5E7FF",color:"#7A3DB8"}:{bg:"#EEE",color:"#333"}},K=L=>L.NombreAsesor?.trim()||(L.Email?L.Email:"Sistema"),v=L=>{const ve=L||"",Ie=ve.split(" ").filter(Boolean);return Ie.length>=2?(Ie[0][0]+Ie[1][0]).toUpperCase():(ve[0]||"?").toUpperCase()},N=[...c].sort((L,ve)=>new Date(ve.FecAlta).getTime()-new Date(L.FecAlta).getTime()),[I,z]=y.useState(!1),Z=y.useMemo(()=>I?N:N.slice(0,T),[I,N]),J=Math.max(N.length-T,0),te=L=>String(L??"").normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase().trim(),me=(L,ve)=>te(JSON.stringify(L)).includes(te(ve)),Y=(L,ve)=>f?f(L,ve):me(L,ve),H=(L,ve)=>{const Ie=te(ve).split(/\s+/).filter(Boolean);return Ie.length?Ie.every(Xe=>Y(L,Xe)):!0},[ae,le]=y.useState(""),[pe,he]=y.useState([]);y.useMemo(()=>i??[],[i]),y.useMemo(()=>{const L=ae.trim();return L?(i??[]).filter(ve=>H(ve,L)):i??[]},[i,ae]);const fe=b.useTheme(),de=b.useMediaQuery(fe.breakpoints.down("md")),[_e,ke]=y.useState(""),[xe,se]=y.useState(!1),[M,oe]=y.useState(!1),Ce=new Date().toISOString().slice(0,10),Se=new Date(Date.now()-720*3600*1e3).toISOString().slice(0,10),[Te,yt]=y.useState(Se),[bt,ot]=y.useState(Ce),[D,O]=y.useState(null),F=!!D,[ne,ee]=y.useState("Todos"),j=["Selección y presentación","Ingreso del Vehículo","En reparación","Entrega de vehículo","Agendar Cita"],[Q,ye]=y.useState("Todos"),Ae=()=>{ke(""),se(!1),oe(!1),yt(Se),ot(Ce),ee("Todos"),ye("Todos")};function R(L){if(!L)return"";const ve=new Date(L);if(isNaN(ve.getTime()))return"";const Ie=String(ve.getDate()).padStart(2,"0"),Xe=String(ve.getMonth()+1).padStart(2,"0"),Je=String(ve.getFullYear()).slice(-2);return`${Ie}/${Xe}/${Je}`}function X(L){const ve=L?new Date(L):null;return ve&&!isNaN(ve.getTime())?ve:null}function ge(L,ve){let Ie=null;for(const Xe of L){const Je=X(ve(Xe));if(Je){const Et=Je.getTime();(Ie===null||Et>Ie)&&(Ie=Et)}}return Ie?new Date(Ie):null}function He(L){const ve=ge(L,Ie=>Ie.UltimoSeguimiento||Ie.FechaCita);return ve?R(ve.toISOString()):"—"}function St(L){return L.filter(ve=>/finalizad/i.test(ve.EstatusDescripcion??"")).length}function Ct(L){return L.length-St(L)}const Ir=({progress:L,color:ve})=>{if(!L)return d.jsx(Za,{current:0,total:0,color:ve});const Ie=L.split("/").map(Number);if(Ie.length!==2||Ie.some(Et=>Number.isNaN(Et)))return d.jsx(Za,{current:0,total:0,color:ve});const[Xe,Je]=Ie;return d.jsx(Za,{current:Xe,total:Je,color:ve})},er=[{key:"fecha",header:"Fecha",accessor:L=>R(L.Fecha),width:110},{key:"vehiculo",header:"Vehículo",accessor:L=>d.jsx(b.Tooltip,{title:L.Vehiculo??"",placement:"top",arrow:!0,children:d.jsx(b.Typography,{component:"span",sx:{fontSize:13,fontWeight:500,display:"block",maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3,cursor:"default"},children:L.Vehiculo??"—"})}),width:260},{key:"estatus",header:"Estatus",accessor:L=>d.jsx(b.Typography,{sx:{fontWeight:800,fontSize:13},children:L.EstatusDescripcion||"—"}),width:170},{key:"nivel",header:"Nivel de Interés",accessor:L=>d.jsx(b.Box,{sx:{display:"inline-block",px:1,py:.25,borderRadius:9999,bgcolor:"#F59E0B",color:"#fff",fontSize:12,fontWeight:800},children:L.NivelInteres??"—"}),width:150},{key:"asesor",header:"Asesor",accessor:L=>d.jsx(b.Tooltip,{title:L.Asesor??"",placement:"top",children:d.jsx(b.Typography,{sx:{fontWeight:700,fontSize:13,textAlign:"center"},children:(L.Asesor??"").split(" ").filter(Boolean).map(ve=>ve[0]?.toUpperCase()).slice(0,2).join("")||"—"})}),width:120,align:"center"},{key:"origen",header:"Origen",accessor:L=>L.Origen??"—",width:90,align:"center"},{key:"actividad",header:"Actividad",accessor:L=>L.Actividad??"—",width:220},{key:"avance",header:"Avance",accessor:L=>d.jsx(Ir,{progress:L.Avance}),width:200,align:"left"}],cn=[{key:"fecha",header:"Fecha",accessor:L=>R(L.Fecha),width:110},{key:"fechaCita",header:"Fecha Cita",accessor:L=>R(L.FechaCita),width:120},{key:"horaCita",header:"Hora Cita",accessor:L=>L.HoraCita??"—",width:110},...er.slice(1)];function Yr(L){switch(L.kind){case"pruebas":case"servicio":return cn;default:return er}}function ln(L,ve,Ie,Xe){return{id:L,kind:Ie,title:ve,metrics:[{label:"En Proceso",value:Ct(Xe)},{label:"Finalizadas",value:St(Xe)},{label:"Último seg.",value:He(Xe)}],rows:Xe,initiallyOpen:!1}}const Or=[ln("n-1","Cotización de nuevos","nuevos",p),ln("p-1","Prueba de Manejo","pruebas",g),ln("s-1","Cita de Servicio","servicio",m),ln("sn-1","Cotización para Seminuevos","seminuevos",h)],ko=y.useMemo(()=>{const L=xe?new Date(Te):null,ve=xe?new Date(bt):null,Ie=(_e??"").trim().toLowerCase(),Xe=(Je,Et)=>{if(Ie&&!(Je.Vehiculo??"").toLowerCase().includes(Ie))return!1;const un=M?Je.FechaCita:Je.Fecha;if(xe&&(L||ve)){const _r=X(un??"");if(!_r)return!1;const Ln=L?new Date(L):null,E=ve?new Date(ve):null;if(Ln&&Ln.setHours(0,0,0,0),E&&E.setHours(23,59,59,999),Ln&&_r<Ln||E&&_r>E)return!1}return!(ne!=="Todos"&&!(Je.EstatusDescripcion??"").toLowerCase().includes(ne.toLowerCase())||Q!=="Todos"&&(Je.Actividad??"")!==Q)};return Or.map(Je=>{const Et=(Je.rows??[]).filter(_r=>Xe(_r,Je.kind)),un=[{label:"En Proceso",value:Ct(Et)},{label:"Finalizadas",value:St(Et)},{label:"Último seg.",value:He(Et)}];return{...Je,rows:Et,metrics:un}})},[Or,_e,xe,Te,bt,M,ne,Q]),[Do,Eo]=y.useState(!1),[ci,li]=y.useState(null),Qa={nuevos:"cotizaciones",pruebas:"pruebademanejo",servicio:"citasservicio",seminuevos:"seminuevos"},ui=(L,ve)=>{const Ie=L.SolID;if(!Ie)return;const Xe=ve.kind,Je=Qa[Xe]??"cotizaciones",Et=`https://qa2.crm.netcar.com.mx/netcar/${Je}/${Ie}`,un=_?.({row:L,section:ve,slug:Je,solId:Ie,baseUrl:Et});if(!S){const _r=un??`https://qa2.crm.netcar.com.mx/netcar/${Je}/${Ie}`;li(_r),Eo(!0)}};return d.jsx(b.Dialog,{open:e,onClose:n,fullWidth:!0,fullScreen:de,PaperProps:{sx:{height:{xs:"100dvh",md:"90vh"},maxWidth:{xs:"100vw",md:"92vw"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},height:"100%",minHeight:0,overflow:"auto",position:"relative"},children:[d.jsxs(b.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:[d.jsxs(b.Box,{children:[d.jsx(b.Stack,{direction:"row",spacing:2,alignItems:"center",mb:1,sx:{px:2.5,pt:2.5},children:d.jsxs(b.Box,{display:"flex",flexDirection:"column",gap:1,width:"100%",children:[d.jsx(b.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",alignItems:"center",children:d.jsx(b.Box,{sx:{flex:1,minWidth:0,pr:1},children:d.jsxs(b.Typography,{component:"span",fontWeight:700,sx:{display:"inline",lineHeight:1.2,wordBreak:"break-word",pr:.5},children:[V(t)," ",d.jsx(b.IconButton,{component:"span",size:"small",disableRipple:!0,onClick:()=>{n?.(),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:d.jsx(PS,{sx:{fontSize:"1em"}})})]})})}),U.map((L,ve)=>d.jsxs(b.Box,{sx:{display:"flex",gap:1.2,alignItems:"center",cursor:L.onClick?"pointer":"default"},onClick:()=>{L.onClick&&L.onClick(t),n()},children:[L.icon,d.jsx(b.Typography,{variant:"body2",sx:{color:L.inLink?"#336BE1":"#070C10"},style:{},children:L.value(t)})]},ve))]})}),d.jsx(b.Stack,{mb:2,sx:{px:2.5,pt:0,gap:2},children:r.map((L,ve)=>{const Ie=L.label?.toLowerCase().startsWith("asesor");return d.jsxs(b.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[d.jsx(b.Box,{sx:{width:"50%"},children:d.jsx(b.Typography,{variant:"body2",color:"text.secondary",sx:{color:"#5C6372"},children:L.label})}),d.jsxs(b.Box,{sx:{width:"50%",display:"flex",alignItems:"center",gap:1},children:[d.jsx("div",{children:L?.avatar?L.avatar(t):null}),d.jsx(b.Typography,{variant:"body2",color:"textPrimary",children:L?.value(t)}),Ie&&d.jsx(b.Tooltip,{title:"Historial asesores",placement:"top",arrow:!0,children:d.jsx(b.IconButton,{size:"small",onClick:Xe=>k(Xe.currentTarget),sx:{ml:.5},disableRipple:!0,children:d.jsx(AS,{fontSize:"small",sx:{color:"#5C6372"}})})})]})]},ve)})}),d.jsx(b.Divider,{sx:{my:2}})]}),d.jsx(b.Box,{px:2.5,pb:.5,children:d.jsx(b.Typography,{fontWeight:800,children:"Historial Actividad:"})}),d.jsxs(b.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:[Z.length===0&&d.jsx(b.Typography,{variant:"body2",color:"text.secondary",children:"Sin actividad registrada."}),d.jsxs(b.Box,{children:[Z?.map((L,ve)=>{const Ie=K(L),{bg:Xe,color:Je}=B(L.TipoComentario),Et=$S(L.Comentario||"");return d.jsxs(b.Box,{sx:{pb:1.5},children:[d.jsxs(b.Stack,{direction:"row",spacing:1,alignItems:"center",justifyContent:"space-between",sx:{mb:.75},children:[d.jsx(b.Typography,{variant:"subtitle2",sx:{color:"#5C6372"},children:L.TipoComentario||"Evento"}),d.jsx(b.Chip,{size:"small",label:L.DisID!=null?`${L.NombreDistribuidora}`:"—",sx:{bgcolor:Xe,color:Je,height:20}})]}),Et?d.jsx(b.Typography,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line",lineHeight:1.5,mb:.75},children:Et}):null,d.jsxs(b.Stack,{direction:"row",spacing:1.25,alignItems:"center",children:[L?.ImgAsesor!=null?d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},alt:v(Ie),src:L?.ImgAsesor}):d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},children:v(Ie)}),d.jsxs(b.Stack,{spacing:0,children:[d.jsx(b.Typography,{variant:"body2",fontWeight:600,children:Ie}),d.jsx(b.Typography,{variant:"caption",color:"text.secondary",children:RS(L.FecAlta)})]})]}),ve<N.length-1&&d.jsx(b.Divider,{sx:{mt:1.25}})]},L.SegID??ve)}),N.length>T&&d.jsx(b.Box,{sx:{mt:1},children:d.jsx(b.Button,{onClick:()=>z(L=>!L),size:"small",sx:{textTransform:"none",px:0,color:"#336BE1","&:hover":{background:"transparent",textDecoration:"underline"}},children:I?"Ver menos":`Ver más (${J})`})})]})]}),d.jsx(b.Menu,{anchorEl:C,open:A,onClose:()=>k(null),TransitionComponent:b.Fade,MenuListProps:{disablePadding:!0},PaperProps:{sx:{width:320,p:0,overflow:"hidden"}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[d.jsx(b.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"}),d.jsxs(b.Box,{sx:{overflowY:"auto",py:.5,maxHeight:200},children:[P.length===0&&d.jsx(b.Box,{sx:{px:1.5,py:1},children:d.jsx(b.Typography,{variant:"body2",color:"text.secondary",children:"Sin registros"})}),P.map((L,ve)=>{const Ie=IS(L),Xe=MS(L.FechaBaja??L.FechaAsignacion);return d.jsx(b.Box,{sx:{px:1,py:.75},children:d.jsxs(b.Stack,{direction:"row",alignItems:"center",spacing:1,children:[d.jsx(b.Avatar,{sx:{width:28,height:28,bgcolor:"#EAEBF2",color:"#5C6372",fontSize:14},src:L?.ImgAsesor??void 0,children:OS(Ie)}),d.jsx(b.Box,{sx:{flex:1,minWidth:0},children:d.jsx(b.Typography,{variant:"body2",noWrap:!0,children:Ie})}),d.jsx(b.Typography,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:Xe})]})},ve)})]})]})})]}),Do?d.jsxs(b.Box,{sx:{flex:1,minWidth:0,overflow:"hidden",position:"relative"},children:[d.jsx(b.Box,{sx:{position:"absolute",top:18,left:24,zIndex:10,pointerEvents:"auto"},children:d.jsx(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:d.jsx(b.Button,{onClick:()=>Eo(!1),sx:{backgroundColor:"#2571d6",minWidth:36,minHeight:36,p:.5,borderRadius:"8px",color:"#fff",boxShadow:3,"&:hover":{backgroundColor:"#2074e3"}},children:d.jsx(NS,{fontSize:"medium"})})})}),ci&&d.jsx("iframe",{src:ci,width:"100%",height:"100%"})]}):d.jsxs(b.Box,{sx:{width:"100%",minHeight:0,overflowY:"auto"},children:[d.jsx(b.Box,{sx:{mt:{xs:1.5,md:3}},children:d.jsxs(b.Box,{sx:{mt:3,display:"flex",flexDirection:"column",gap:4,padding:"0 20px 0 20px"},children:[d.jsx(b.Typography,{variant:"h4",sx:{fontWeight:800,textAlign:"center",mb:1,letterSpacing:.2},children:"Solicitudes"}),d.jsxs(b.Stack,{direction:{xs:"column",md:"column"},spacing:1.5,alignItems:{xs:"stretch",md:"center"},justifyContent:"space-between",sx:{mb:1.5},children:[d.jsxs(b.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",sx:{flexWrap:"wrap"},children:[d.jsx(b.TextField,{size:"small",placeholder:"Buscar por vehículo",value:_e,onChange:L=>ke(L.target.value),InputProps:{endAdornment:d.jsx(CS,{fontSize:"small",sx:{color:"#b6afaf"}})},sx:{minWidth:220}}),d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,position:"relative"},children:[d.jsxs(b.Stack,{direction:"row",spacing:1.2,position:"absolute",bottom:48,left:0,alignItems:"center",children:[d.jsx(b.FormControlLabel,{label:d.jsx(b.Typography,{sx:{fontSize:15,fontWeight:700,marginLeft:0},children:"Por fecha"}),labelPlacement:"start",control:d.jsx(b.Checkbox,{checked:xe,onChange:L=>se(L.target.checked),size:"small",sx:{p:.3,"& .MuiSvgIcon-root":{fontSize:20}}}),sx:{ml:0,"& .MuiFormControlLabel-label":{marginRight:0}}}),d.jsx(b.Typography,{sx:{fontSize:15,fontWeight:700},children:"De cita"})]}),d.jsxs(b.Stack,{direction:"row",spacing:1,children:[d.jsx(b.TextField,{size:"small",type:"date",label:"Desde",InputLabelProps:{shrink:!0},value:Te,onChange:L=>yt(L.target.value),disabled:!xe,sx:{width:170}}),d.jsx(b.TextField,{size:"small",type:"date",label:"Hasta",InputLabelProps:{shrink:!0},value:bt,onChange:L=>ot(L.target.value),disabled:!xe,sx:{width:170}})]})]}),d.jsx(b.IconButton,{onClick:L=>O(L.currentTarget),disableRipple:!0,sx:{border:"1px solid #d4d7de",borderRadius:2,width:40,height:40,mt:2},children:d.jsx(SS,{})}),d.jsx(b.Button,{variant:"outlined",onClick:Ae,disableRipple:!0,sx:{height:40,textTransform:"none",borderColor:"#d4d7de",color:"#333",mt:2},children:"Limpiar filtros"}),d.jsxs(b.Button,{variant:"outlined",sx:{height:40,textTransform:"none",borderColor:"none",color:"#fff",backgroundColor:"#1e5bce","&:hover":{backgroundColor:"#1e5bce",boxShadow:"none"},mt:2},onClick:()=>{w?.(t)},disableRipple:!0,children:[d.jsx(jS,{sx:{color:"#fff",fontSize:24,paddingRight:.6}}),"Crear Solicitud"]})]}),d.jsx(TS,{sections:ko,detailColumns:er,getDetailColumns:Yr,onRowClick:ui})]})]})}),d.jsx(b.Menu,{anchorEl:D,open:F,onClose:()=>O(null),TransitionComponent:b.Fade,PaperProps:{sx:{p:1.5,width:260,borderRadius:2,boxShadow:3}},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:d.jsxs(b.Stack,{spacing:1.5,paddingX:1.5,paddingY:1,children:[d.jsx(b.Typography,{variant:"subtitle2",sx:{fontWeight:700,color:"#070C10"},children:"Filtro"}),d.jsxs(b.Box,{children:[d.jsx(b.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Estatus"}),d.jsx(b.RadioGroup,{value:ne,onChange:L=>ee(L.target.value),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos","Sin Asignar","Sin Atender","Asignada","Confirmadas","En seguimiento","Rechazadas","Finalizadas"].map(L=>d.jsx(b.FormControlLabel,{value:L,control:d.jsx(b.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:L},L))})]}),d.jsxs(b.Box,{children:[d.jsx(b.Typography,{variant:"body2",sx:{fontWeight:700,mb:.5,color:"#5C6372"},children:"Actividades"}),d.jsx(b.RadioGroup,{value:Q,onChange:L=>ye(L.target.value),sx:{"& .MuiFormControlLabel-root":{m:0,py:.3},"& .MuiFormControlLabel-label":{fontSize:14,fontWeight:400,ml:0}},children:["Todos",...j].map(L=>d.jsx(b.FormControlLabel,{value:L,control:d.jsx(b.Radio,{size:"small",sx:{p:.2,"& .MuiSvgIcon-root":{fontSize:18}}}),label:L},L))})]})]})})]})]})})}const Wf={tableClientes:"_tableClientes_acwe7_1",tableResponsive:"_tableResponsive_acwe7_1"};function Uf(e,n,t){const{fields:r,order:o=["nombreCliente","email","acciones"],header:s={},cells:i={},hide:a={},actions:c}=n,l=c??{},u=l.show??{},f=l.handlers??{},p=l.accessors??{},g=l.icons??{},m=l.className??"d-flex flex-row gap-2 align-items-center ",h=l.tooltip??{},w=g.view??d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",style:{fill:"#070c10"},children:[d.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"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),S={nombreCliente:{key:"nombreCliente",header:s.nombreCliente??"Cliente",accessor:B=>B[r.nombreCliente],cell:i.nombreCliente,width:190},email:{key:"email",header:s.email??"Correo",accessor:B=>B[r.email],cell:i.email??(B=>{const K=String(B[r.email]??"");return K?d.jsx("a",{href:`mailto:${K}`,children:K}):d.jsx("span",{className:"text-muted",children:"—"})}),width:230},acciones:a.acciones?void 0:{key:"acciones",header:"",cell:i.acciones??(B=>{const K=Ua(u.whatsapp,B,!0),v=Ua(u.email,B,!0),N=Ua(u.view,B,!0),I=p.phone?.(B),z=p.email?.(B),Z=me=>{if(me.stopPropagation(),f.onWhatsApp)return f.onWhatsApp(B);if(!I)return;const Y=p.countryCode??"52",H=wS(String(I));typeof window<"u"&&window.open(`https://wa.me/${Y}${H}`,"_blank")},J=me=>{if(me.stopPropagation(),f.onEmail)return f.onEmail(B);z&&typeof window<"u"&&(window.location.href=`mailto:${z}`)},te=me=>{me.stopPropagation(),f.onView&&f.onView(B)};return d.jsxs("div",{className:m,children:[K&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.whatsapp??"WhatsApp",onClick:Z,style:{width:24,height:24},children:d.jsx("img",{src:yS,alt:"WhatsApp"})}),v&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.email??"Email",onClick:J,style:{width:24,height:24},children:d.jsx("img",{src:bS,alt:"Email"})}),N&&d.jsx("button",{type:"button",className:"btn p-0 border-0 bg-transparent",title:h.view??"Ver detalle",onClick:te,style:{width:24,height:24},children:w})]})}),width:120}},_=Object.values(S).filter(B=>!!B),T=(e??[]).filter(B=>!!B?.key),C=new Map;for(const B of _)C.set(String(B.key),B);for(const B of T)C.set(String(B.key),B);const k=[..._.map(B=>String(B.key)),...T.map(B=>String(B.key))],A=Array.from(new Set(o.map(B=>String(B)).filter(B=>C.has(B)))),P=k.filter(B=>!A.includes(B)),V=[...A,...P],U="acciones";if(C.has(U)){const B=V.filter(K=>K!==U);V.splice(0,V.length,...B,U)}return V.map(B=>C.get(B))}function zS(e){const{rows:n,columns:t,clientSort:r=!0,defaultSort:o,minWidth:s=1100,rowKey:i=_S,defaults:a,detailConfig:c,extraSections:l,normalTableColumns:u,normalTable:f,onRowClick:p,activityHistory:g,advisorHistory:m,forceOpenDetailFor:h,closeDetailFor:w,onRequestEdit:S,searchFilter:_,solicitudesNuevos:T,solicitudesPrueba:C,solicitudesServicio:k,solicitudesSeminuevos:A,onCreateSolicitud:P,isCrmMode:V,onSolicitudBaseUrl:U}=e,[B,K]=y.useState(o??null),[v,N]=y.useState({open:!1,customer:null}),[I,z]=y.useState([]),Z=H=>{N({open:!0,customer:H});const ae=c?.vehiclesProvider?.(H)??[];z(Array.isArray(ae)?ae:[])},J=H=>{p?.(H),N({open:!0,customer:H});const ae=c?.vehiclesProvider?.(H)??[];z(Array.isArray(ae)?ae:[])},te=()=>{N({open:!1,customer:null}),w?.()},me=y.useMemo(()=>a?Uf(t??[],a):Uf(t??[],{fields:{},order:[]}),[t,a]),Y=y.useMemo(()=>{if(!r||!B)return n;const H=me.find(le=>le.key===B.key);if(!H)return n;const ae=[...n];return ae.sort((le,pe)=>{const he=Wa(H,le,0),fe=Wa(H,pe,0),de=xS(he,fe);return B.direction==="asc"?de:-de}),ae},[n,me,B,r]);return y.useEffect(()=>{h&&Z(h)},[h]),d.jsxs("div",{children:[d.jsx("div",{className:`${Wf.tableClientes} back-white rounded-3 shadow-main mt-4 mb-4`,children:d.jsx("div",{className:`${Wf.tableResponsive} table-responsive`,children:d.jsxs("table",{className:"table table-hover align-middle mb-0",children:[d.jsx("thead",{children:d.jsx("tr",{children:me.map(H=>d.jsx("th",{style:{fontWeight:600,width:H.width,paddingTop:"20px",paddingBottom:"20px",textAlign:H.align??"left"},children:H.header},H.key))})}),d.jsx("tbody",{children:Y.map((H,ae)=>d.jsx("tr",{onClick:()=>J?.(H),role:"button",tabIndex:0,onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&J?.(H)},style:{cursor:"pointer"},children:me.map((le,pe)=>{const he=le.Component?d.jsx(le.Component,{row:H,index:ae}):le.cell?le.cell(H,ae):(()=>{const fe=Wa(le,H,ae);return fe==null||fe===""?"":String(fe)})();return d.jsx("td",{style:{paddingTop:"20px",paddingBottom:"20px",textAlign:le.align??"left"},children:he},`${String(le.key)}-${pe}`)})},i(H,ae)))})]})})}),v.open&&d.jsx(LS,{open:v.open,onClose:te,customer:v.customer,fields:c?.dynamicFields,header:c?.header,extraSections:l,normalTableColumns:u,normalTable:f,history:g,advisorHistory:m,onRequestEdit:H=>{te(),S?.(H)},searchFilter:_,solicitudesNuevos:T,solicitudesPrueba:C,solicitudesServicio:k,solicitudesSeminuevos:A,onCreateSolicitud:P,isCrmMode:V,onSolicitudBaseUrl:U})]})}const Hf=re.forwardRef(({sx:e,...n},t)=>d.jsx(b.InputBase,{inputRef:t,...n,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}}));Hf.displayName="SoftInput";const BS=ut(d.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"ErrorOutline");function FS({message:e}){return e?d.jsxs(b.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:[d.jsx(BS,{fontSize:"small",sx:{color:"rgb(211, 47, 47)"}}),d.jsx("span",{style:{color:"rgb(95, 33, 32)",fontSize:14,fontWeight:"500"},children:e})]}):null}function VS(e){if(e.required)return e.required===!0?"El campo es obligatorio.":e.required}function Ga(e,n){const t=VS(e);return t?n?.isArray?{required:t,validate:r=>Array.isArray(r)&&r.length>0||t}:{required:t,validate:r=>r!==""&&r!==null&&r!==void 0||t}:{}}const Zf={"& .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%"},YS={mb:1,fontWeight:600,color:"#1C1C1D","&.Mui-focused":{color:"#1C1C1D !important"},"&.Mui-error":{color:"#1C1C1D !important"}};function qa({label:e,errorMsg:n,helperText:t,children:r,sx:o}){return d.jsxs(b.FormControl,{fullWidth:!0,error:!!n,sx:o,className:"1- FieldWrapper",children:[d.jsx(b.FormLabel,{sx:YS,children:e}),r,d.jsx(FS,{message:n||t})]})}function WS(e,n){const{register:t,formState:{errors:r}}=n,o={...Ga(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 s=e.type==="email";s&&!o.pattern&&(o.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo electrónico inválido"});const i=/[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]/g,a=/[0-9]/g,c=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Escape","Enter"]),l=C=>e.onlyNumbers?(C.match(a)??[]).join(""):e.onlyLetters?(C.match(i)??[]).join(""):C,u=(C,k)=>c.has(C)||k?!0:e.onlyNumbers?/^[0-9]$/.test(C):e.onlyLetters?/^[A-Za-zÁÉÍÓÚÜÑáéíóúüñ\s'.-]$/.test(C):!0,f=r[e.name]?.message,p=t(e.name,o),g=(e.inputProps&&typeof e.inputProps.maxLength=="number"?e.inputProps.maxLength:void 0)??e.maxLength,m=C=>{u(C.key,C.ctrlKey||C.metaKey)||C.preventDefault()},h=C=>{const k=C.data??null;k!=null&&(e.onlyNumbers&&/[^0-9]/.test(k)&&C.preventDefault(),e.onlyLetters&&/[^A-Za-zÁÉÍÓÚÜÑáéíóúüñ ]/.test(k)&&C.preventDefault())},w=C=>{const k=C.clipboardData.getData("text"),A=l(k);if(A!==k){C.preventDefault();const P=C.target,V=P.selectionStart??P.value.length,U=P.selectionEnd??P.value.length;P.setRangeText(A,V,U,"end"),P.dispatchEvent(new Event("input",{bubbles:!0}))}},S=C=>{const k=l(C.target.value);k!==C.target.value&&(C.target.value=k),g&&C.target.value.length>g&&(C.target.value=C.target.value.slice(0,g)),p.onChange(C)},_={...e.inputProps,...s?{inputMode:"email",autoComplete:"email"}:{},maxLength:g,onKeyDown:m,onBeforeInput:h,onPaste:w,onInvalid:C=>C.preventDefault()},T=e.onlyNumbers||s?"text":e.type??"text";return d.jsx(qa,{label:e.label,errorMsg:f,helperText:e.helperText,sx:Zf,children:d.jsx(Hf,{placeholder:e.placeholder,type:T,inputProps:_,...p,onChange:S,sx:{width:"100%",maxWidth:"none"},className:"SoftInputData"})})}function US(e,n){const{control:t}=n,r=!!e.multiple;return d.jsx(Ht,{name:e.name,control:t,rules:Ga(e,{isArray:r}),render:({field:o,fieldState:s})=>d.jsx(qa,{label:e.label,errorMsg:s.error?.message,helperText:e.helperText,sx:Zf,children:d.jsxs(b.Select,{...o,multiple:r,displayEmpty:!0,sx:{height:48,backgroundColor:"#EBEEF0","& .MuiSelect-select":{display:"flex",alignItems:"center",py:0}},className:"2-SoftInputData",children:[!r&&d.jsx(b.MenuItem,{value:"",disabled:!0,children:"Selecciona…"}),e.options.map(i=>d.jsx(b.MenuItem,{value:i.value,children:i.label},String(i.value)))]})})})}function HS(e,n){return d.jsx(Ht,{name:e.name,control:n.control,rules:Ga(e),render:({field:t,fieldState:r})=>d.jsx(qa,{label:e.label,errorMsg:r.error?.message,helperText:e.helperText,children:d.jsx(b.RadioGroup,{row:!0,...t,className:"3-RadioFieldRender",children:e.options.map(o=>d.jsx(b.FormControlLabel,{value:o.value,control:d.jsx(b.Radio,{}),label:o.label},String(o.value)))})})})}function Gf(e,n){if(e.render)return e.render(n);switch(e.kind){case"text":return WS(e,n);case"select":return US(e,n);case"radio":return HS(e,n);default:return null}}function ZS(e,{initialPerPage:n=25,perPageOptions:t=[10,25,50,100,"Todos"],onPageChange:r,onPerPageChange:o,scrollTop:s,deps:i=[]}={}){const a=Array.isArray(e)?e:[],[c,l]=y.useState(1),[u,f]=y.useState(n),{currentItems:p,totalPages:g,showingFrom:m,showingTo:h,totalItems:w}=y.useMemo(()=>{const T=a.length,C=u==="Todos"?1/0:Number(u),k=C===1/0?1:Math.max(1,Math.ceil(T/C)),A=Math.min(c,k),P=C===1/0?T:A*C,V=C===1/0?0:P-C;return{currentItems:C===1/0?a:a.slice(V,P),totalPages:k,showingFrom:T===0?0:V+1,showingTo:C===1/0?T:Math.min(P,T),totalItems:T}},[a,c,u]),S=T=>{const C=Math.max(1,Math.min(T,g||1));l(C),r?.(C),s?.()};return{currentItems:p,totalPages:g,showingFrom:m,showingTo:h,totalItems:w,currentPage:c,itemsPerPage:u,perPageOptions:t,goTo:S,next:()=>S(c+1),prev:()=>S(c-1),setItemsPerPage:T=>{f(T),o?.(T),l(1),s?.()},setCurrentPage:S}}const GS=ut(d.jsx("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),qS=ut(d.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),KS=({currentPage:e,totalPages:n,onPageChange:t,itemsPerPage:r,onItemsPerPageChange:o,itemsPerPageOptions:s,showingFrom:i,showingTo:a,totalItems:c})=>{const l=b.useTheme(),u=b.useMediaQuery(l.breakpoints.down("sm")),f=()=>{if(n<=1)return[1];const m=u?0:2,h=[],w=1,S=n,_=Math.max(w+1,e-m),T=Math.min(S-1,e+m);h.push(w),_>w+1&&h.push("...");for(let C=_;C<=T;C++)C>=w+1&&C<=S-1&&h.push(C);return T<S-1&&h.push("..."),h.push(S),h},p=m=>{const h=m.target.value;o(h)},g=Math.max(1,n);return d.jsxs(b.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:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",justifyContent:"center"},children:[d.jsx(b.IconButton,{onClick:()=>t(e-1),disabled:e<=1,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página anterior",children:d.jsx(GS,{fontSize:"large"})}),f().map((m,h)=>m==="..."?d.jsx(b.Box,{sx:{px:1,display:"flex",alignItems:"center",fontSize:"1.1rem"},children:". . ."},`dots-${h}`):d.jsx(b.Button,{onClick:()=>t(m),size:"small",sx:{minWidth:36,height:36,fontSize:"1.05rem",p:1,borderRadius:"10px",backgroundColor:e===m?"primary.main":"transparent",fontWeight:e===m?700:400,color:e===m?"#fff":"#5C6372","&:hover":{backgroundColor:e===m?"primary.dark":"action.hover"},boxShadow:"none",border:"none",mx:.5},children:m},`p-${m}`)),d.jsx(b.IconButton,{onClick:()=>t(e+1),disabled:e>=g,size:"medium",sx:{"&:hover":{backgroundColor:"action.hover"}},"aria-label":"Página siguiente",children:d.jsx(qS,{fontSize:"large"})})]}),d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,justifyContent:{xs:"center",sm:"flex-start"},mt:{xs:1,sm:0}},children:[d.jsx(b.Typography,{variant:"body2",children:"Mostrar"}),d.jsx(b.FormControl,{size:"small",sx:{minWidth:72},children:d.jsx(b.Select,{value:r,onChange:p,renderValue:m=>m==="Todos"?"Todos":String(m),children:s.map(m=>d.jsx(b.MenuItem,{value:m,children:m==="Todos"?"Todos":m},String(m)))})}),d.jsx(b.Typography,{variant:"body2",children:"por página"})]})]})};function QS(e){const{open:n,dataAdd:t,fields:r,onSubmit:o,onCancel:s,defaultValues:i,txtBtnGuardar:a,haveId:c=!1,itemsTable:l,filter:u,getId:f,renderRow:p,selectedIds:g,onSelectedChange:m,onSubmitAddData:h,initialSelectedIds:w=[],showAutosPanel:S}=e,_=Bd({mode:"onSubmit",reValidateMode:"onChange",criteriaMode:"all",shouldUnregister:!1,defaultValues:i});y.useEffect(()=>{i&&_.reset(i)},[i,_]);const[T,C]=y.useState(""),[k,A]=y.useState(w),P=Array.isArray(g)&&!!m,V=P?g:k,U=j=>{const Q=typeof j=="function"?j(V):j;P?m(Q):A(Q)},B=y.useCallback(j=>f?f(j):j?.IdAuto,[f]),K=y.useMemo(()=>{const j=new Map;return(l??[]).forEach((Q,ye)=>j.set(B(Q),ye)),j},[l,B]),v=y.useRef(new Set),N=y.useMemo(()=>{const j=new Map;return(l??[]).forEach(Q=>j.set(f?f(Q):Q?.IdAuto,Q)),j},[l,f]),I=y.useMemo(()=>(r??[]).filter(j=>!!j.required).map(j=>j.name),[r]),z=_d({control:_.control,name:I}),Z=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,J=y.useMemo(()=>I.length?z?.every(Z)??!1:!0,[z,I]),{handleSubmit:te,formState:{isSubmitting:me,isDirty:Y,isValid:H}}=_,ae=u??((j,Q)=>JSON.stringify(j).toLowerCase().includes(Q.toLowerCase())),le=y.useMemo(()=>T.trim()?l?.filter(j=>ae(j,T)):l,[l,T,ae]),pe=y.useMemo(()=>{if(!le)return le;const j=v.current,Q=[...le];return Q.sort((ye,Ae)=>{const R=j.has(B(ye))?0:1,X=j.has(B(Ae))?0:1;if(R!==X)return R-X;const ge=K.get(B(ye))??0,He=K.get(B(Ae))??0;return ge-He}),Q},[le,K,B]),{currentItems:he,totalPages:fe,showingFrom:de,showingTo:_e,totalItems:ke,currentPage:xe,itemsPerPage:se,perPageOptions:M,goTo:oe,setItemsPerPage:Ce}=ZS(pe,{initialPerPage:25,perPageOptions:[10,25,50,100,"Todos"],deps:[T],scrollTop:()=>{}}),Se=j=>{const Q=N.get(j)??null;U([j]),h?.({items:Q})},Te=j=>V.includes(j),yt=async j=>{try{await o?.(j),_.reset(_.getValues())}catch(Q){console.error("Error al enviar AddCliente:",Q)}},bt=y.useMemo(()=>{const j=new Map;return(r??[]).forEach(Q=>j.set(String(Q.name),Q)),j},[r]),ot=(j,Q)=>{const ye=bt.get(String(j));if(!ye)return null;const Ae={xs:12,...ye.grid,...Q||{}};return d.jsx(b.Grid,{item:!0,...Ae,children:ye.render?ye.render(_):Gf(ye,_)},`fld-${String(j)}`)},D=S??(e.haveId?"edit":"new"),O=D!=="onlyCars",F=D==="new"||D==="onlyCars",ne=V?.length>0,ee=D==="onlyCars"?ne:e.haveId?J&&Y||ne:J&≠return d.jsx(b.Dialog,{open:n,onClose:s,maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{height:{xs:"100dvh",md:F?"90vw":"auto"},maxWidth:{xs:"100vw",md:F?"98vw":"50%"},overflow:"hidden",display:"flex",flexDirection:"column",borderRadius:{xs:0,md:3}}},children:d.jsx(p1,{..._,children:d.jsxs(b.Box,{component:"form",noValidate:!0,onSubmit:te(yt),display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",height:"100%",overflow:{xs:"auto",md:"unset"},position:"relative",children:[O&&d.jsxs(b.Box,{sx:{width:{xs:"100%",md:c?"100%":394},maxWidth:{xs:"100%",md:c?"100%":394},boxShadow:{xs:"none",md:c?"none":"2px 0px 8px #40404024"},borderRight:{xs:"none",md:c?"none":"1px solid #EBEEF0"},bgcolor:"background.paper",paddingBottom:3,mx:{xs:0,md:c?"auto":0},"& .form-body":{maxWidth:c?760:"unset",margin:"0 auto"},position:"relative"},children:[d.jsxs(b.Box,{p:{xs:2,md:2},height:"100%",sx:{"& .MuiFormControl-root, & .MuiTextField-root":{width:"100%",maxWidth:"none"}},children:[d.jsx(b.Typography,{fontWeight:700,fontSize:20,children:t.title}),d.jsxs(b.Box,{sx:{flex:1,height:"100%",overflowY:"auto",paddingBottom:10},children:[d.jsx(b.Typography,{fontSize:"18px",mt:2.5,fontWeight:500,children:t.subTitle}),d.jsx(b.Box,{mt:2,display:"flex",flexDirection:"column",width:"100%",gap:2,children:Array.isArray(e.formLayout)&&c?e.formLayout.map((j,Q)=>d.jsx(b.Grid,{container:!0,spacing:2,alignItems:"flex-start",wrap:"wrap",width:"100%",children:j.map((ye,Ae)=>{const R=typeof ye=="string"?{name:ye}:ye;return R.hidden?.(_)?null:ot(R.name,R.grid)})},`row-${Q}`)):d.jsx(b.Grid,{container:!0,spacing:2,width:"100%",children:r?.map((j,Q)=>{const ye=j.grid??{xs:12,md:12};return d.jsx(b.Grid,{item:!0,...ye,width:"100%",children:j.render?j.render(_):Gf(j,_)},`${String(j.name)}-${Q}`)})})})]})]}),d.jsx(b.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:d.jsx(b.Box,{display:"flex",alignItems:"center",children:d.jsx(b.Box,{display:"flex",gap:1.5,width:"100%",justifyContent:c?"flex-end":"center",children:d.jsx(b.Button,{type:"submit",variant:"contained",disabled:me||!ee,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:c?"160px":"100%"},children:a})})})})]}),F&&d.jsx(b.Box,{flex:1,display:"flex",flexDirection:"column",minWidth:0,sx:{height:"100%"},children:d.jsx(b.Box,{mt:1,sx:{flex:1,display:"flex",flexDirection:"column",height:"100%"},children:d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[d.jsxs(b.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:[d.jsx(b.TextField,{value:T,onChange:j=>C(j.target.value),placeholder:"Buscar marca, modelo, vin...",InputProps:{endAdornment:d.jsx(b.InputAdornment,{position:"start",children:d.jsx(ey,{})}),disableUnderline:!0},variant:"standard",sx:{maxWidth:360,width:"100%",backgroundColor:"#EBEEF0",paddingX:"16px",paddingY:"10px"}}),d.jsx(b.Box,{display:"flex",gap:2,alignItems:"center",sx:{marginTop:{sm:0,xs:2}},children:d.jsx(b.Box,{onClick:s,sx:{cursor:"pointer",position:"absolute",top:0,right:10},display:{xs:"none",md:"block"},children:d.jsx(an,{sx:{color:"#070C10",fontSize:24}})})}),S=="onlyCars"&&d.jsx(b.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:d.jsx(b.Box,{display:"flex",gap:1.5,width:"100%",children:d.jsx(b.Button,{type:"submit",variant:"contained",disabled:me||!ee,sx:{backgroundColor:"#336BE1",color:"#fff",borderColor:"transparent",height:48,fontSize:15,textTransform:"none",fontWeight:"400",paddingX:5,width:"100%"},children:"Crear Cotización"})})})]}),d.jsx(b.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:d.jsx(b.Box,{sx:{minWidth:1150,width:"max(1150px, 100%)",paddingBottom:10},children:d.jsxs(b.List,{disablePadding:!0,sx:{borderColor:"transparent",padding:0},children:[he?.map((j,Q)=>{const ye=f?f(j):Q,Ae=Te(ye);return d.jsx(b.Box,{sx:{borderBottom:"1px solid #D3D4D5",padding:0},children:d.jsx(b.ListItem,{disableGutters:!0,sx:{paddingTop:0,padding:0,m:0},children:d.jsx(b.ListItemButton,{onClick:()=>Se(ye),disableRipple:!0,sx:{padding:0},children:d.jsx(b.ListItemText,{disableTypography:!0,primary:p?p({item:j,selected:Ae,toggle:()=>Se(ye),index:Q}):null})})})},`${String(ye)}`)}),!he?.length&&d.jsx(b.Box,{p:3,children:d.jsxs(b.Typography,{fontSize:14,color:"#5C6372",children:["Sin resultados para “",T,"”."]})})]})})}),d.jsx(b.Box,{sx:{position:"sticky",bottom:0,bgcolor:"#fff"},children:d.jsx(KS,{currentPage:xe,totalPages:fe,onPageChange:oe,itemsPerPage:se,onItemsPerPageChange:Ce,itemsPerPageOptions:M,showingFrom:de,showingTo:_e,totalItems:ke})})]})})})]})})})}const XS=ut(d.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"),Ka=/^[^\s@]+@[^\s@]+\.[^\s@]+$/i,ai=/[,\s;]+/g,Fr=e=>e.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"").toLowerCase(),Vr=(e,n)=>Array.from(new Set([...e,...n.map(t=>t.trim()).filter(Boolean)])),qf=(e,n)=>n?e.filter(t=>Fr(t)!==Fr(n)):e,JS=(e,n)=>e.filter(t=>!n.some(r=>Fr(r)===Fr(t)));function ur(e,n,t){if(t)return typeof t=="function"?t(e,n):e[t]}function eC(e,n){if(n)return!e||/^https?:\/\//i.test(n)?n:e+n}function tC({open:e,onClose:n,value:t,onChange:r,onRequestSend:o,customer:s,itemsSelects:i,renderItem:a,filterFields:c=[],multiSelectAutos:l=!0,imgCorreoSrc:u,baseURLImages:f,itemProps:p,defaultItemImageSrc:g}){const m=y.useRef(null),[h,w]=y.useState("idle"),S=y.useRef(e);y.useEffect(()=>{const R=S.current;e&&!R&&w("entering"),!e&&R&&w("exiting"),S.current=e},[e]),y.useEffect(()=>{if(h==="entering"){const ge=setTimeout(()=>w("idle"),320);return()=>clearTimeout(ge)}if(h==="exiting"){const ge=setTimeout(()=>w("idle"),220);return()=>clearTimeout(ge)}},[h]);const[_,T]=y.useState(""),[C,k]=y.useState(!1),[A,P]=y.useState(!1),[V,U]=y.useState(!1),[B,K]=y.useState(""),[v,N]=y.useState([]),I=V?v:t.selectedIds,z=()=>{N([...t.selectedIds]),K(""),U(!0)},Z=()=>{U(!1),N([])},J=()=>{const R=new Set(bt.map((ge,He)=>String(ur(ge,He,p.id)))),X=v.filter(ge=>R.has(String(ge)));r({...t,selectedIds:X}),U(!1)},te=(R,X)=>Fr(R??"")===Fr(X??"");function me(R,X,ge,He,St){const Ct=X?R.some(er=>te(er,X)):!1,Ir=ge.length>0?ge.some(er=>R.some(cn=>te(cn,er))):!1;He(Ct),St(Ir)}const Y=R=>{const X=typeof R=="function"?R(t.recipients):R;r({...t,recipients:X}),me(X,he,de,k,P)},H=R=>r({...t,message:R}),ae=R=>r({...t,attachments:[...t.attachments,...R]}),le=R=>r({...t,attachments:t.attachments.filter(X=>X.name!==R)}),pe=R=>{if(V)if(l){const X=new Set(v);X.has(R)?X.delete(R):X.add(R),N(Array.from(X))}else{const X=v.includes(R);N(X?[]:[R])}else if(l){const X=new Set(t.selectedIds);X.has(R)?X.delete(R):X.add(R),r({...t,selectedIds:Array.from(X)})}else{const X=t.selectedIds.includes(R);r({...t,selectedIds:X?[]:[R]})}},he=y.useMemo(()=>(s?.Correo??"").trim(),[s]),fe=y.useMemo(()=>Array.isArray(s?.Asesores)?s.Asesores.filter(R=>R?.EmailAsesor&&R?.Activo):[],[s]),de=y.useMemo(()=>fe.map(R=>(R.EmailAsesor??"").trim()).filter(Boolean),[fe]),_e=y.useRef(!1);y.useEffect(()=>{if(e&&!_e.current){let R=[];C&&he&&(R=Vr(R,[he])),A&&de.length&&(R=Vr(R,de)),Y(X=>Vr(X,R)),me(t.recipients,he,de,k,P),T(""),_e.current=!0}e||(_e.current=!1)},[e,C,A,he,de]);const ke=R=>{const X=fe.find(ge=>Fr(ge.EmailAsesor??"")===Fr(R));if(X){if(X.ImgAsesor)return d.jsx(b.Avatar,{src:X.ImgAsesor,alt:X.NombreAsesor});const ge=(X.NombreAsesor||"").trim(),He=(X.ApellidosAsesor||"").trim();return d.jsx(b.Avatar,{children:`${ge[0]??""}${He[0]??""}`.toUpperCase()})}return d.jsx(b.Avatar,{children:R[0]?.toUpperCase()})},xe=()=>{const R=_.trim();if(!R)return;const ge=R.split(ai).filter(Boolean).filter(He=>Ka.test(He));ge.length>0&&Y(He=>Vr(He,ge)),T("")},se=R=>{k(R),Y(X=>R&&he?Vr(X,[he]):qf(X,he))},M=R=>{P(R),Y(X=>R?Vr(X,de):JS(X,de))},oe=R=>{const X=Array.from(R.target.files||[]);ae(X.map(ge=>({name:ge.name,size:ge.size,file:ge}))),R.target.value=""},Ce=I[0],Se=y.useMemo(()=>!i||Ce===void 0?void 0:i.find((X,ge)=>String(ur(X,ge,p.id))===String(Ce)),[i,Ce,p.id]),Te=y.useMemo(()=>{if(!(!Se||!p.distributorId))return ur(Se,0,p.distributorId)},[Se,p.distributorId]);console.log("lockedDisId",Te);const yt=y.useMemo(()=>Se?(p.distributorTitle?ur(Se,0,p.distributorTitle):void 0)??(Te!=null?String(Te):void 0):void 0,[Se,p.distributorTitle,Te]),bt=y.useMemo(()=>{const R=i??[];return Te==null||!p.distributorId?R:R.filter((X,ge)=>ur(X,ge,p.distributorId)==Te)},[i,Te,p.distributorId]),ot=y.useMemo(()=>{if(!B.trim())return bt;const R=B.toLowerCase();return bt.filter(X=>(c??[]).some(ge=>String(X?.[ge]??"").toLowerCase().includes(R)))},[bt,B,c]),D=y.useMemo(()=>{if(!i||!t.selectedIds.length)return[];const R=new Map;return i.forEach((X,ge)=>{R.set(String(ur(X,ge,p.id)),X)}),t.selectedIds.map(X=>R.get(String(X))).filter(Boolean)},[i,t.selectedIds,p.id]),O=R=>r({...t,selectedIds:t.selectedIds.filter(X=>String(X)!==String(R))}),F=()=>{let R=t.recipients;if(_.trim()){const Ct=_.split(ai).filter(Ir=>Ka.test(Ir));R=Vr(R,Ct),Y(R),T("")}const X=C?he:"",ge=fe.find(Ct=>Ct?.Activo&&Ct?.EmailAsesor)?.EmailAsesor?.trim()??"";o?.({recipients:R,toClient:C,toAdvisor:A,tipoInt:C&&A?2:1,correoCliente:X,correoAsesor:A?ge:"",disIdLocked:Te}),n?.()},ne=y.useMemo(()=>{const X=_.split(ai).filter(Boolean).some(ge=>Ka.test(ge));return t.recipients.length>0||X},[t.recipients,_]),ee=(t.selectedIds?.length??0)>0,j=t.message.trim().length>0,Q=ne&&ee&&j,ye=b.useTheme(),Ae=b.useMediaQuery(ye.breakpoints.down("sm"));return d.jsxs(b.Drawer,{anchor:Ae?"bottom":"right",open:e,onClose:n,ModalProps:{keepMounted:!0,BackdropProps:{invisible:!Ae}},transitionDuration:{enter:320,exit:220},SlideProps:{direction:Ae?"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:[d.jsxs(b.Box,{sx:{display:"flex",flexDirection:"column",height:{xs:"100%",sm:"auto"},position:"relative",overflow:"auto"},children:[d.jsxs(b.Box,{sx:{p:2,pb:1,position:"sticky",top:0,zIndex:1,bgcolor:"#fff",borderBottom:"1px solid #E5E7EB"},children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[u?d.jsx("img",{src:u,alt:"Correo",style:{width:24,height:18}}):null,d.jsxs(b.Typography,{fontWeight:700,children:["Mensaje a"," ",s?`${s.Nombre??""} ${s.ApellidoP??""} ${s.ApellidoM??""}`.trim():"—"]})]}),d.jsx(b.IconButton,{onClick:n,size:"small",children:d.jsx(an,{})})]}),d.jsx("div",{children:d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 10px",backgroundColor:"#EBEEF0",border:"1px solid #E5E7EB",borderRadius:8,flexWrap:"wrap"},children:[d.jsx("label",{style:{fontSize:14,fontWeight:600,marginRight:4},children:"Para:"}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",flex:1},children:[t.recipients.map(R=>d.jsx(b.Chip,{avatar:ke(R),label:R,onDelete:()=>Y(X=>qf(X,R)),size:"small",variant:"outlined",sx:{borderRadius:999,height:28}},R)),d.jsx("input",{type:"text",value:_,onChange:R=>T(R.target.value),onKeyDown:R=>{const X=R.key;X==="Enter"||X===","||X===";"||X===" "||X==="Tab"?(R.preventDefault(),xe()):X==="Backspace"&&!_&&t.recipients.length&&Y(He=>He.slice(0,-1))},onBlur:xe,onPaste:R=>{const ge=R.clipboardData.getData("text").split(ai).filter(Boolean);ge.length>1&&(R.preventDefault(),Y(He=>Vr(He,ge)),T(""))},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"}})]})]})}),d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:2,mb:1.5},children:[d.jsx(b.FormControlLabel,{control:d.jsx(b.Checkbox,{checked:C,onChange:R=>se(R.target.checked),size:"small"}),label:"Cliente"}),fe.length!==0&&d.jsx(b.FormControlLabel,{control:d.jsx(b.Checkbox,{checked:A,onChange:R=>M(R.target.checked),size:"small"}),label:`Asesor${fe.length>1?"es":""}`})]})]}),d.jsx(b.Divider,{}),d.jsxs(b.Box,{p:2,children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},onClick:z,children:[d.jsx(b.Typography,{fontSize:12,fontWeight:600,sx:{textDecorationLine:"underline",cursor:"pointer"},children:"Selecciona el auto de seguimiento"}),yt!=null&&d.jsx(b.Chip,{size:"small",label:`Distribuidora: ${yt}`})]}),D.length>0?d.jsx(b.Box,{sx:{mt:1.5,display:"flex",gap:1,flexWrap:"wrap"},children:D.map((R,X)=>{const ge=ur(R,X,p.id),He=ur(R,X,p.title)??"",St=ur(R,X,p.image),Ct=eC(f,St);return d.jsx(b.Chip,{onDelete:()=>O(ge),label:d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(b.Box,{sx:{width:28,height:20,borderRadius:.8,bgcolor:"#e5e6e8",overflow:"hidden",flex:"0 0 auto"},children:Ct?d.jsx("img",{src:Ct,alt:He,style:{width:"100%",height:"100%",objectFit:"cover"}}):d.jsx("img",{src:g,alt:He,style:{width:"100%",height:"100%",objectFit:"cover"}})}),d.jsx("span",{style:{fontSize:12},children:d.jsx("b",{children:He})})]}),sx:{pl:.5,pr:.3,py:.2,borderRadius:2,".MuiChip-deleteIcon":{fontSize:18}},variant:"outlined"},String(ge))})}):d.jsx(b.Typography,{fontSize:13,color:"#5C6372",sx:{mt:.5},children:"Aún no has seleccionado autos."})]}),d.jsx(b.Divider,{}),d.jsxs(b.Box,{sx:{p:2},children:[d.jsx(b.TextField,{placeholder:"Escribe aquí tu mensaje...",value:t.message,onChange:R=>H(R.target.value),multiline:!0,minRows:6,fullWidth:!0,sx:{mb:1.5}}),t.attachments.length>0&&d.jsx(b.List,{dense:!0,sx:{display:"flex",flexDirection:"column",gap:2,border:"none"},children:t.attachments.map(R=>d.jsxs(b.ListItem,{sx:{px:0,background:"#EAEBF2",borderRadius:2,paddingX:1},children:[d.jsx(b.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"}}),d.jsx(b.Tooltip,{title:"Quitar",children:d.jsx(b.IconButton,{edge:"end",onClick:()=>le(R.name),size:"small",children:d.jsx(an,{fontSize:"small"})})})]},R.name))})]}),d.jsxs(b.Box,{sx:{position:{xs:"sticky",sm:"sticky"},bottom:0,bgcolor:"#fff",borderTop:"1px solid #E5E7EB",p:2,display:"flex",alignItems:"center",gap:2},children:[d.jsx("input",{ref:m,hidden:!0,type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.mp4,.pdf,.xlsx,.csv,.docx,.pptx,.txt",onChange:oe}),d.jsx(b.Button,{startIcon:d.jsx(XS,{}),variant:"text",onClick:()=>m.current?.click(),sx:{color:"#5C6372"},children:"Adjuntar archivo"}),d.jsx(b.Box,{sx:{flex:1}}),d.jsx(b.Button,{variant:"contained",onClick:F,disabled:!Q,sx:{maxWidth:146,width:"100%",height:53,backgroundColor:"#336BE1"},children:"Enviar"})]})]}),d.jsxs(b.Dialog,{fullWidth:!0,maxWidth:"sm",fullScreen:Ae,open:V,onClose:Z,children:[d.jsxs(b.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:1},children:["Selecciona tu auto de seguimiento",d.jsx(b.IconButton,{onClick:Z,size:"small",children:d.jsx(an,{})})]}),d.jsxs(b.DialogContent,{children:[d.jsxs(b.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(b.TextField,{placeholder:"Buscar...",fullWidth:!0,size:"small",value:B,onChange:R=>K(R.target.value),sx:{mb:2}}),yt!=null&&d.jsx(b.Chip,{size:"small",label:`Distribuidora: ${yt}`})]}),d.jsxs(b.Typography,{variant:"caption",fontWeight:600,children:["RESULTADOS (",ot.length,")"]}),d.jsxs(b.List,{sx:{p:0},children:[ot.map((R,X)=>{const ge=ur(R,X,p.id),He=I.includes(String(ge))||I.includes(ge),St=Te==null||ur(R,X,p.distributorId)==Te;return d.jsx(b.ListItem,{disableGutters:!0,sx:{p:0,opacity:St?1:.5},children:d.jsx(b.Box,{onClick:()=>St&&pe(ge),sx:{cursor:St?"pointer":"not-allowed",p:.5,backgroundColor:He?"#e5f0ff":"transparent",width:"100%",borderBottom:"solid 1px #D3D4D5"},children:a?a(R,X):d.jsx("pre",{style:{margin:0},children:JSON.stringify(R,null,2)})})},String(ge))}),ot.length===0&&d.jsx(b.Box,{p:2,children:d.jsx(b.Typography,{children:"Tu búsqueda no generó resultados"})})]})]}),d.jsxs(b.DialogActions,{sx:{px:3,pb:2},children:[d.jsx(b.Button,{variant:"text",onClick:Z,sx:{color:"#5C6372"},children:"Cancelar"}),d.jsx(b.Button,{variant:"contained",onClick:J,sx:{backgroundColor:"#336BE1"},children:"Guardar selección"})]})]})]})}ct.AddCliente=QS,ct.ApiProvider=Jb,ct.AuthProvider=Ey,ct.Clientes=zS,ct.CustomSnackbar=Bf,ct.EventsProvider=pS,ct.ModalCorreo=tC,ct.MyCalendar=vS,ct.useAuth=sa,ct.useAuthRepository=Bs,ct.useEventRepository=ya,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})}));
|