react-calendar-agenda 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DayView.d.ts.map +1 -1
- package/dist/WeekView.d.ts.map +1 -1
- package/dist/components/EventCard.d.ts +3 -1
- package/dist/components/EventCard.d.ts.map +1 -1
- package/dist/components/HourCell.d.ts +2 -1
- package/dist/components/HourCell.d.ts.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1538 -1057
- package/dist/index.es.js.map +1 -1
- package/dist/stories/components/CalendarEventDialog.d.ts.map +1 -1
- package/dist/stories/components/EventDialog.d.ts +3 -2
- package/dist/stories/components/EventDialog.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/layoutUtils.d.ts +23 -0
- package/dist/utils/layoutUtils.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/DayView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayView.d.ts","sourceRoot":"","sources":["../src/DayView.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,+
|
|
1
|
+
{"version":3,"file":"DayView.d.ts","sourceRoot":"","sources":["../src/DayView.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,+CAgHnB,CAAA"}
|
package/dist/WeekView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WeekView.d.ts","sourceRoot":"","sources":["../src/WeekView.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,+
|
|
1
|
+
{"version":3,"file":"WeekView.d.ts","sourceRoot":"","sources":["../src/WeekView.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,+CA8GpB,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CalendarEvent } from '../types';
|
|
2
|
+
import { EventWithOverlap } from '../utils';
|
|
2
3
|
|
|
3
4
|
interface EventCardProps {
|
|
4
5
|
event: CalendarEvent;
|
|
5
6
|
hourHeight: number;
|
|
6
7
|
onClick: (event: CalendarEvent) => void;
|
|
8
|
+
overlapInfo?: EventWithOverlap;
|
|
7
9
|
}
|
|
8
|
-
export declare const EventCard: ({ event, hourHeight, onClick }: EventCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const EventCard: ({ event, hourHeight, onClick, overlapInfo }: EventCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
10
12
|
//# sourceMappingURL=EventCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventCard.d.ts","sourceRoot":"","sources":["../../src/components/EventCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"EventCard.d.ts","sourceRoot":"","sources":["../../src/components/EventCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAsE,gBAAgB,EAAyB,MAAM,UAAU,CAAA;AAEtI,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACvC,WAAW,CAAC,EAAE,gBAAgB,CAAA;CAC/B;AAkBD,eAAO,MAAM,SAAS,GAAI,6CAA6C,cAAc,4CAoGpF,CAAA"}
|
|
@@ -12,7 +12,8 @@ interface HourCellProps {
|
|
|
12
12
|
onEventClick: (event: CalendarEvent) => void;
|
|
13
13
|
gridSize?: number;
|
|
14
14
|
showRightBorder?: boolean;
|
|
15
|
+
allEvents?: Array<CalendarEvent>;
|
|
15
16
|
}
|
|
16
|
-
export declare const HourCell: ({ hour, events, hourHeight, selection, date, onMouseDown, onClick, onEventClick, gridSize, showRightBorder, }: HourCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const HourCell: ({ hour, events, hourHeight, selection, date, onMouseDown, onClick, onEventClick, gridSize, showRightBorder, allEvents, }: HourCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=HourCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HourCell.d.ts","sourceRoot":"","sources":["../../src/components/HourCell.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"HourCell.d.ts","sourceRoot":"","sources":["../../src/components/HourCell.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,aAAa,GAAG,IAAI,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IAC1C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CACjC;AAED,eAAO,MAAM,QAAQ,GAAI,0HAYtB,aAAa,4CAgEf,CAAA"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react"),t=require("@mui/material"),r=require("@mui/icons-material"),n=(e=>e&&e.__esModule?e:{default:e})(e);var o,i={exports:{}},a={};var s,l={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/"production"===process.env.NODE_ENV?o.exports=function(){if(n)return i;n=1;var t=e,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var o,i={},c=null,u=null;for(o in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,o)&&!l.hasOwnProperty(o)&&(i[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===i[o]&&(i[o]=t[o]);return{$$typeof:r,type:e,key:c,ref:u,props:i,_owner:s.current}}return i.Fragment=o,i.jsx=c,i.jsxs=c,i}():o.exports=(a||(a=1,"production"!==process.env.NODE_ENV&&function(){var t,r=e,n=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),v=Symbol.iterator,x=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=x.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map(function(e){return String(e)});o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}function b(e){return e.displayName||"Context"}function T(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case i:return"Fragment";case o:return"Portal";case l:return"Profiler";case a:return"StrictMode";case p:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case u:return b(e)+".Consumer";case c:return b(e._context)+".Provider";case d:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case f:var t=e.displayName||null;return null!==t?t:T(e.type)||"Memo";case h:var r=e,n=r._payload,s=r._init;try{return T(s(n))}catch(g){return null}}return null}t=Symbol.for("react.module.reference");var D,E,w,j,S,C,k,M=Object.assign,N=0;function R(){}R.__reactDisabledLog=!0;var I,_=x.ReactCurrentDispatcher;function H(e,t,r){if(void 0===I)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);I=n&&n[1]||""}return"\n"+I+e}var O,$=!1,B="function"==typeof WeakMap?WeakMap:Map;function F(e,t){if(!e||$)return"";var r,n=O.get(e);if(void 0!==n)return n;$=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=_.current,_.current=null,function(){if(0===N){D=console.log,E=console.info,w=console.warn,j=console.error,S=console.group,C=console.groupCollapsed,k=console.groupEnd;var e={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(f){r=f}Reflect.construct(e,[],a)}else{try{a.call()}catch(f){r=f}e.call(a.prototype)}}else{try{throw Error()}catch(f){r=f}e()}}catch(h){if(h&&r&&"string"==typeof h.stack){for(var s=h.stack.split("\n"),l=r.stack.split("\n"),c=s.length-1,u=l.length-1;c>=1&&u>=0&&s[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(s[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||s[c]!==l[u]){var d="\n"+s[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{$=!1,_.current=o,function(){if(0===--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},e,{value:D}),info:M({},e,{value:E}),warn:M({},e,{value:w}),error:M({},e,{value:j}),group:M({},e,{value:S}),groupCollapsed:M({},e,{value:C}),groupEnd:M({},e,{value:k})})}N<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var p=e?e.displayName||e.name:"",m=p?H(p):"";return"function"==typeof e&&O.set(e,m),m}function P(e,t,r){if(null==e)return"";if("function"==typeof e)return F(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return H(e);switch(e){case p:return H("Suspense");case m:return H("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return F(e.render,!1);case f:return P(e.type,t,r);case h:var o=e,i=o._payload,a=o._init;try{return P(a(i),t,r)}catch(s){}}return""}O=new B;var A=Object.prototype.hasOwnProperty,V={},z=x.ReactDebugCurrentFrame;function L(e){if(e){var t=e._owner,r=P(e.type,e._source,t?t.type:null);z.setExtraStackFrame(r)}else z.setExtraStackFrame(null)}var W=Array.isArray;function Y(e){return W(e)}function U(e){return""+e}function G(e){if(function(e){try{return U(e),!1}catch(t){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),U(e)}var K,q,J=x.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,r,o,i){var a,s={},l=null,c=null;for(a in void 0!==r&&(G(r),l=""+r),function(e){if(A.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(G(t.key),l=""+t.key),function(e){if(A.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&J.current}(t)),t)A.call(t,a)&&!X.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===s[a]&&(s[a]=u[a])}if(l||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var r=function(){K||(K=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(s,d),c&&function(e,t){var r=function(){q||(q=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(s,d)}return function(e,t,r,o,i,a,s){var l={$$typeof:n,type:e,key:t,ref:r,props:s,_owner:a,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,i,o,J.current,s)}var Z,ee=x.ReactCurrentOwner,te=x.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=P(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function oe(){if(ee.current){var e=T(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ie={};function ae(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=oe();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!ie[r]){ie[r]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+T(e._owner.type)+"."),re(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),re(null)}}}function se(e,t){if("object"==typeof e)if(Y(e))for(var r=0;r<e.length;r++){var n=e[r];ne(n)&&ae(n,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var i,a=o.call(e);!(i=a.next()).done;)ne(i.value)&&ae(i.value,t)}}function le(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==d&&r.$$typeof!==f)return;t=r.propTypes}if(t){var n=T(r);!function(e,t,r,n,o){var i=Function.call.bind(A);for(var a in e)if(i(e,a)){var s=void 0;try{if("function"!=typeof e[a]){var l=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}s=e[a](t,a,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){s=c}!s||s instanceof Error||(L(o),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,a,typeof s),L(null)),s instanceof Error&&!(s.message in V)&&(V[s.message]=!0,L(o),y("Failed %s type: %s",r,s.message),L(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||Z||(Z=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ce={};function ue(e,r,o,s,v,x){var b=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===a||e===p||e===m||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===f||e.$$typeof===c||e.$$typeof===u||e.$$typeof===d||e.$$typeof===t||void 0!==e.getModuleId)}(e);if(!b){var D,E="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),E+=oe(),null===e?D="null":Y(e)?D="array":void 0!==e&&e.$$typeof===n?(D="<"+(T(e.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):D=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,E)}var w=Q(e,r,o,v,x);if(null==w)return w;if(b){var j=r.children;if(void 0!==j)if(s)if(Y(j)){for(var S=0;S<j.length;S++)se(j[S],e);Object.freeze&&Object.freeze(j)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(j,e)}if(A.call(r,"key")){var C=T(e),k=Object.keys(r).filter(function(e){return"key"!==e}),M=k.length>0?"{key: someKey, "+k.join(": ..., ")+": ...}":"{key: someKey}";ce[C+M]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',M,C,k.length>0?"{"+k.join(": ..., ")+": ...}":"{}",C),ce[C+M]=!0)}return e===i?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){re(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),re(null);break}}null!==e.ref&&(re(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(w):le(w),w}var de=function(e,t,r){return ue(e,t,r,!1)},pe=function(e,t,r){return ue(e,t,r,!0)};s.Fragment=i,s.jsx=de,s.jsxs=pe}()),s);var l=o.exports;const c={DAY:80,WEEK:60,MONTH:120},u={DAY_LABEL:3,DAY_CONTENT:9,WEEK_LABEL:1,WEEK_DAY:11/7},d=["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],p={title:"",description:"",startTime:"",endTime:"",date:"",customData:{}},m=(e,t,r)=>new Date(e,t,r,12,0,0,0),f=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,h=e=>{const[t,r,n]=e.split("-").map(Number);return m(t,r-1,n)},g=e=>{const[t,r]=e.split(":");return`${t}:${r}`},v=e=>{const t=e.getFullYear(),r=e.getMonth(),n=e.getDate()-e.getDay(),o=[];for(let i=0;i<7;i++){const e=n+i;o.push(m(t,r,e))}return o},x=()=>{const e=[];for(let t=0;t<24;t++)e.push(t);return e},y=e=>e.toDateString()===(new Date).toDateString(),b=(e,t)=>{switch(t){case"month":return new Intl.DateTimeFormat("pt-BR",{year:"numeric",month:"long"}).format(e);case"week":{const t=v(e),r=t[0],n=t[6];if(r.getMonth()===n.getMonth()){return`${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short"}).format(r)} - ${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short",year:"numeric"}).format(n)}`}return`${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short"}).format(r)} - ${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short",year:"numeric"}).format(n)}`}case"day":return new Intl.DateTimeFormat("pt-BR",{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(e);default:return""}},T=e=>{const t=e.getFullYear(),r=e.getMonth(),n=new Date(t,r,1),o=new Date(t,r+1,0).getDate(),i=n.getDay(),a=[];for(let s=0;s<i;s++)a.push(null);for(let s=1;s<=o;s++)a.push(m(t,r,s));return a},D=(e,t)=>{const r=e.getFullYear(),n=e.getMonth();switch(t){case"day":{const t=f(e);return{startDate:t,endDate:t}}case"week":{const t=v(e);return{startDate:f(t[0]),endDate:f(t[6])}}case"month":{const e=m(r,n,1),t=m(r,n+1,0);return{startDate:f(e),endDate:f(t)}}default:return{startDate:f(e),endDate:f(e)}}},E=e.createContext(void 0),w=({children:t,events:r=[],isLoading:n=!1,onEventAdd:o,onEventEdit:i,onEventDelete:a,onDateRangeChange:s})=>{const[c,u]=e.useState(new Date),[d,m]=e.useState("week"),[f,h]=e.useState(!1),[g,v]=e.useState(!1),[x,y]=e.useState(null),[b,T]=e.useState(p),w=e.useRef(s);e.useEffect(()=>{w.current=s},[s]),e.useEffect(()=>{if(w.current){const e=D(c,d);w.current(e)}},[c,d]);const j=e.useMemo(()=>({currentDate:c,setCurrentDate:u,view:d,setView:m,isEventDialogOpen:f,setIsEventDialogOpen:h,isEditing:g,setIsEditing:v,selectedEvent:x,setSelectedEvent:y,eventForm:b,setEventForm:T,events:r,isLoading:n,onEventAdd:o,onEventEdit:i,onEventDelete:a}),[c,d,f,g,x,b,r,n,o,i,a]);return l.jsx(E.Provider,{value:j,children:t})},j=()=>{const t=e.useContext(E);if(void 0===t)throw new Error("useCalendar must be used within a CalendarProvider");return t},S=({view:t,setCurrentDate:r})=>({handlePrevious:e.useCallback(()=>{switch(t){case"month":r(e=>new Date(e.getFullYear(),e.getMonth()-1,1));break;case"week":r(e=>new Date(e.getTime()-6048e5));break;case"day":r(e=>new Date(e.getTime()-864e5))}},[t,r]),handleNext:e.useCallback(()=>{switch(t){case"month":r(e=>new Date(e.getFullYear(),e.getMonth()+1,1));break;case"week":r(e=>new Date(e.getTime()+6048e5));break;case"day":r(e=>new Date(e.getTime()+864e5))}},[t,r]),handleToday:e.useCallback(()=>{r(new Date)},[r])}),C=({setSelectedEvent:t,setIsEditing:r,setEventForm:n,setIsEventDialogOpen:o})=>({handleEditEvent:e.useCallback(e=>{let i=60;if(e.startTime&&e.endTime){const[t,r]=e.startTime.split(":").map(Number),[n,o]=e.endTime.split(":").map(Number),a=new Date;a.setHours(t,r,0,0);const s=new Date;s.setHours(n,o,0,0);const l=s.getTime()-a.getTime();i=Math.floor(l/6e4)}t(e),r(!0),n({title:e.title,description:e.description,startTime:e.startTime,endTime:e.endTime,date:e.date,duration:i,customData:e.customData||{}}),o(!0)},[t,r,n,o]),handleCreateEvent:(e,i,a)=>{t(null),r(!1);const s=Boolean(i&&a&&e);let l=60;if(i&&a){const[e,t]=i.split(":").map(Number),[r,n]=a.split(":").map(Number),o=new Date;o.setHours(e,t,0,0);const s=new Date;s.setHours(r,n,0,0);const c=s.getTime()-o.getTime();l=Math.floor(c/6e4)}n({title:s?"Novo Evento":"",description:"",startTime:i||"",endTime:a||"",date:e||"",duration:l,customData:{}}),o(!0)}}),k=[{value:15,label:"15 minutos"},{value:30,label:"30 minutos"},{value:45,label:"45 minutos"},{value:60,label:"1 hora"},{value:120,label:"2 horas"},{value:180,label:"3 horas"}],M=e=>{if(!e||!e.includes(":"))return NaN;const[t,r]=e.split(":").map(Number);return 60*t+r},N=e=>e<=0?{isValid:!1,errorMessage:"A duração deve ser maior que zero"}:{isValid:!0},R=(e,t)=>{if(!e||!t)return{isValid:!1,errorMessage:"Horário de início e fim são obrigatórios"};const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);if(isNaN(r)||isNaN(n)||isNaN(o)||isNaN(i))return{isValid:!1,errorMessage:"Formato de horário inválido"};return 60*r+n>=60*o+i?{isValid:!1,errorMessage:"O horário de início deve ser antes do horário de fim"}:{isValid:!0}},I=e=>{if(!e)return{isValid:!1,errorMessage:"Data é obrigatória"};if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return{isValid:!1,errorMessage:"Formato de data inválido (esperado: YYYY-MM-DD)"};const[t,r,n]=e.split("-").map(Number),o=new Date(t,r-1,n);return o.getFullYear()!==t||o.getMonth()!==r-1||o.getDate()!==n?{isValid:!1,errorMessage:"Data inválida"}:{isValid:!0}},_=e=>{if(!e)return{isValid:!1,errorMessage:"Horário é obrigatório"};return/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{isValid:!0}:{isValid:!1,errorMessage:"Formato de horário inválido (esperado: HH:MM)"}},H=(e,t)=>{const r=I(e);if(!r.isValid)return r;const n=_(t);if(!n.isValid)return n;const[o,i,a]=e.split("-").map(Number),[s,l]=t.split(":").map(Number);return new Date(o,i-1,a,s,l)<new Date?{isValid:!1,errorMessage:"O evento não pode ser criado no passado"}:{isValid:!0}},O=(e,t=5)=>{const r=I(e);if(!r.isValid)return r;const[n,o,i]=e.split("-").map(Number),a=new Date(n,o-1,i),s=new Date;return s.setFullYear(s.getFullYear()+t),a>s?{isValid:!1,errorMessage:`A data não pode ser mais de ${t} anos no futuro`}:{isValid:!0}},$=(e,t)=>t.filter(t=>{const r=h(t.date);return f(r)===f(e)}),B=(e,t,r)=>r.filter(r=>{const n=h(r.date),[o]=r.startTime.split(":").map(Number);return f(n)===f(e)&&o===t}),F=(e,t=60)=>{const[r,n]=e.split(":").map(Number);return(60*r+n)/60*t},P=(e,t,r=60)=>{const[n,o]=e.split(":").map(Number),[i,a]=t.split(":").map(Number),s=60*i+a-(60*n+o);return Math.max(s/60*r,10)},A=(e,t,r=60)=>{const n=P(e,t,r);return n<=10?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.50rem",WebkitLineClamp:1}:n<30?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.70rem",padding:1,WebkitLineClamp:1}:n<40?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:1}:n<=60?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:3}:{height:n,showTitle:!0,showTime:!0,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:3}},V=(e,t=60)=>{const[,r]=e.split(":").map(Number);return r/60*t},z=()=>{const{currentDate:e,setCurrentDate:n,view:o,setView:i,setSelectedEvent:a,setIsEditing:s,setEventForm:c,setIsEventDialogOpen:u}=j(),{handlePrevious:d,handleNext:p,handleToday:m}=S({view:o,setCurrentDate:n}),{handleCreateEvent:f}=C({setSelectedEvent:a,setIsEditing:s,setEventForm:c,setIsEventDialogOpen:u});return l.jsxs(t.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:[l.jsx(t.Typography,{variant:"h4",component:"h1",children:b(e,o)}),l.jsxs(t.Box,{display:"flex",gap:2,alignItems:"center",children:[l.jsxs(t.ToggleButtonGroup,{value:o,exclusive:!0,onChange:(e,t)=>t&&i(t),size:"small",children:[l.jsx(t.ToggleButton,{value:"month",children:"Mês"}),l.jsx(t.ToggleButton,{value:"week",children:"Semana"}),l.jsx(t.ToggleButton,{value:"day",children:"Dia"})]}),l.jsxs(t.Box,{display:"flex",gap:1,children:[l.jsx(t.Button,{variant:"outlined",onClick:d,children:"Anterior"}),l.jsx(t.Button,{variant:"outlined",onClick:m,children:"Hoje"}),l.jsx(t.Button,{variant:"outlined",onClick:p,children:"Próximo"}),l.jsx(t.Button,{variant:"contained",startIcon:l.jsx(r.Add,{}),onClick:()=>f(),children:"Novo Evento"})]})]})]})},L=({hourHeight:r,limitToDay:n=!1,currentDayIndex:o=0,totalDays:i=1})=>{const[a,s]=e.useState(new Date);e.useEffect(()=>{const e=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(e)},[]);const c=a.getHours(),u=a.getMinutes(),d=`${c.toString().padStart(2,"0")}:${u.toString().padStart(2,"0")}`,p=F(d,r),m=(()=>{if(!n)return{left:0,right:0};const e=11/12*100/i;return{left:`calc(${1/12*100+o*e}% + 4px)`,width:`calc(${e}% - 8px)`}})();return l.jsxs(l.Fragment,{children:[l.jsx(t.Box,{sx:{position:"absolute",...m,top:`${p}px`,height:"2px",backgroundColor:"error.main",zIndex:100,pointerEvents:"none","&::before":{content:'""',position:"absolute",left:"4px",top:"50%",transform:"translateY(-50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"error.main"}}}),l.jsx(t.Box,{sx:{position:"absolute",left:n?`calc(${m.left} + 16px)`:0,top:p-10+"px",backgroundColor:"error.main",color:"white",fontSize:"0.65rem",fontWeight:"bold",padding:"2px 4px",borderRadius:"4px",zIndex:101,pointerEvents:"none"},children:d})]})},W=({day:e,gridSize:r=9})=>{const n=y(e);return l.jsx(t.Grid,{item:!0,xs:r,children:l.jsx(t.Box,{sx:{p:2,textAlign:"center",fontWeight:"bold",minHeight:80,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:n?"primary.main":"background.paper",color:n?"primary.contrastText":"text.primary",borderRight:"2px solid",borderColor:"divider"},children:l.jsx(t.Typography,{variant:"h6",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{weekday:"long",day:"2-digit",month:"2-digit"}).format(e)})})})},Y=({event:e,hourHeight:r,onClick:n})=>{const o=V(e.startTime,r),i=P(e.startTime,e.endTime,r),a=A(e.startTime,e.endTime,r),s=e.color||"#2196F3",c=(e=>{const t=e.replace(/^#/,""),r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=e=>Math.max(0,e-30);return`#${i(r).toString(16).padStart(2,"0")}${i(n).toString(16).padStart(2,"0")}${i(o).toString(16).padStart(2,"0")}`})(s);return l.jsxs(t.Box,{sx:{position:"absolute",top:`${o}px`,left:4,right:4,height:`${i}px`,backgroundColor:s,color:"white",borderRadius:1,p:(null==a?void 0:a.padding)?a.padding/8:0,cursor:"pointer",fontSize:a.fontSize,overflow:"hidden",zIndex:10,display:"flex",flexDirection:"column",justifyContent:a.height<30?"center":"flex-start",border:"1px solid rgba(255,255,255,0.2)","&:hover":{backgroundColor:c}},onClick:t=>{t.stopPropagation(),n(e)},children:[a.showTitle&&l.jsx(t.Typography,{variant:"body2",sx:{fontSize:a.fontSize,color:"white",lineHeight:1.2,mb:a.showTime?.25:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:a.WebkitLineClamp,WebkitBoxOrient:"vertical"},children:e.title}),a.showTime&&l.jsxs(t.Typography,{variant:"caption",sx:{fontSize:.9*parseFloat(a.fontSize)+"rem",color:"rgba(255,255,255,0.9)",lineHeight:1,mb:a.showDescription?.25:0,overflow:"hidden",textOverflow:"ellipsis"},children:[g(e.startTime)," - ",g(e.endTime)]}),a.showDescription&&e.description&&l.jsx(t.Typography,{variant:"caption",sx:{fontSize:.85*parseFloat(a.fontSize)+"rem",color:"rgba(255,255,255,0.8)",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.description})]})},U=({selection:e,hourHeight:r=60,currentHour:n})=>{if(!e||!e.isSelecting)return null;if(void 0!==n){const o=e.startHour,i=e.endHour;if(n<o||n>i)return null;if(n===o){const o=e.startMinute,a=n===i?e.endMinute:60;return l.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:o/60*r+"px",height:(a-o)/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}if(n===i){const n=e.endMinute;return l.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:0,height:n/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}return l.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:0,height:`${r}px`,backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}const o=60*e.startHour+e.startMinute,i=60*e.endHour+e.endMinute,a=Math.min(o,i),s=Math.abs(i-o),c=Math.max(s,15);return l.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:a/60*r+"px",height:c/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})},G=({hour:e,events:r,hourHeight:n,selection:o,date:i,onMouseDown:a,onClick:s,onEventClick:c,gridSize:u=9,showRightBorder:d=!1})=>{const p=[10,20,30,40,50].map(e=>({minute:e,top:e/60*n}));return l.jsx(t.Grid,{item:!0,xs:u,children:l.jsxs(t.Box,{sx:{p:1,minHeight:n,cursor:"crosshair",position:"relative",borderTop:"2px solid",borderRight:d?"2px solid":"1px solid",borderColor:e=>e.palette.divider,borderColorRight:e=>d?e.palette.divider:`${e.palette.divider}40`,"&:hover":{backgroundColor:"action.hover"}},onMouseDown:a,onClick:()=>null==s?void 0:s(),children:[p.map(({minute:e,top:r})=>l.jsx(t.Box,{sx:{position:"absolute",left:0,right:0,top:`${r}px`,height:"1px",backgroundColor:e=>e.palette.divider,opacity:.3,pointerEvents:"none",zIndex:1}},e)),r.map(e=>l.jsx(Y,{event:e,hourHeight:n,onClick:c},e.id)),o&&o.date===i&&l.jsx(U,{selection:o,hourHeight:n,currentHour:e})]})})},K=({hour:e,hourHeight:r=60,gridSize:n=3})=>l.jsx(t.Grid,{item:!0,xs:n,children:l.jsx(t.Box,{sx:{p:1,textAlign:"center",minHeight:r,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"background.default",borderTop:"2px solid",borderRight:"1px solid",borderColor:"divider"},children:l.jsx(t.Typography,{variant:"body2",children:`${e.toString().padStart(2,"0")}:00`})})}),q=({days:e})=>l.jsxs(l.Fragment,{children:[l.jsx(t.Grid,{item:!0,xs:1,children:l.jsx(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:"background.paper",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid",borderColor:"divider"},children:"Hora"})}),e.map((r,n)=>{const o=y(r),i=n===e.length-1;return l.jsx(t.Grid,{item:!0,xs:11/7,children:l.jsxs(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:o?"primary.main":"background.paper",color:o?"primary.contrastText":"text.primary",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRight:i?"2px solid":"1px solid",borderColor:e=>`${e.palette.divider}40`,borderColorRight:e=>i?e.palette.divider:`${e.palette.divider}40`},children:[l.jsx(t.Typography,{variant:"body2",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{weekday:"short"}).format(r)}),l.jsx(t.Typography,{variant:"h6",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{day:"2-digit"}).format(r)})]})},n)})]}),J=({containerRef:t,hourHeight:r,enabled:n=!0})=>{e.useEffect(()=>{if(!n||!t.current)return;const e=setTimeout(()=>{var e;const n=new Date,o=(n.getHours()+n.getMinutes()/60)*r,i=null==(e=t.current)?void 0:e.parentElement;if(!i)return;const a=o-i.clientHeight/2;i.scrollTo({top:Math.max(0,a),behavior:"smooth"})},100);return()=>clearTimeout(e)},[t,r,n])},X=({onTimeSelected:t,events:r=[]}={})=>{const[n,o]=e.useState(null),i=e.useRef(!1),a=e.useRef(null),s=(e,t)=>`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`,l=(e,t,r=60)=>{const n=e-t.top,o=Math.floor(n/r),i=n%r/r,a=(e=>10*Math.round(e/10))(Math.round(60*i));return{hour:Math.max(0,Math.min(23,o)),minute:Math.max(0,Math.min(59,a))}},c=e.useCallback(()=>{if(!i.current||!n)return;i.current=!1,a.current=null;const e=60*n.startHour+n.startMinute,r=60*n.endHour+n.endMinute-e;if(0===r)return void o(null);let l=n.endHour,c=n.endMinute;if(r<10){const e=((e,t,r)=>{const n=60*e+t+r;return{hour:Math.floor(n/60)%24,minute:n%60}})(n.startHour,n.startMinute,10);l=e.hour,c=e.minute}const u={startTime:s(n.startHour,n.startMinute),endTime:s(l,c),date:n.date,startHour:n.startHour,startMinute:n.startMinute,endHour:l,endMinute:c};t&&t(u),o(null)},[n,t]),u=e.useCallback(()=>{o(null),i.current=!1,a.current=null},[]);return{selection:n,handleMouseDown:({event:e,date:t,containerRect:n,hourHeight:c=60})=>{e.preventDefault();const{hour:u,minute:d}=l(e.clientY,n,c);r.some(e=>{if(e.date!==t)return!1;const[r,n]=e.startTime.split(":").map(Number),[o,i]=e.endTime.split(":").map(Number),a=60*u+d;return a>=60*r+n&&a<60*o+i})||(i.current=!0,a.current={hour:u,minute:d},o({startTime:s(u,d),endTime:s(u,d),date:t,isSelecting:!0,startHour:u,startMinute:d,endHour:u,endMinute:d}))},handleMouseMove:(e,t,r=60)=>{if(!i.current||!a.current||!n)return;const{hour:c,minute:u}=l(e.clientY,t,r);let d,p,m,f;60*c+u>=60*a.current.hour+a.current.minute?(d=a.current.hour,p=a.current.minute,m=c,f=u):(d=c,p=u,m=a.current.hour,f=a.current.minute),o(e=>e?{...e,startTime:s(d,p),endTime:s(m,f),startHour:d,startMinute:p,endHour:m,endMinute:f}:null)},handleMouseUp:c,clearSelection:u,isDragging:i.current}},Q=()=>{const{currentDate:r,events:n,setEventForm:o,setIsEventDialogOpen:i,setSelectedEvent:a,setIsEditing:s}=j(),d=e.useRef(null),p=x(),m=c.DAY,{handleEditEvent:h,handleCreateEvent:g}=C({setSelectedEvent:a,setIsEditing:s,setEventForm:o,setIsEventDialogOpen:i}),{selection:v,handleMouseDown:y,handleMouseMove:b,handleMouseUp:T,clearSelection:D}=X({onTimeSelected:e=>{g(e.date,e.startTime,e.endTime),D()},events:n});return J({containerRef:d,hourHeight:m}),l.jsx(t.Card,{children:l.jsxs(t.CardContent,{sx:{p:0,position:"relative"},children:[l.jsxs(t.Grid,{container:!0,children:[l.jsx(t.Grid,{item:!0,xs:u.DAY_LABEL,children:l.jsx(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:"background.paper",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid",borderColor:"divider"},children:"Hora"})}),l.jsx(W,{day:r,gridSize:u.DAY_CONTENT})]}),l.jsx(t.Box,{sx:{maxHeight:"calc(100vh - 280px)",overflow:"auto",position:"relative"},children:l.jsxs("div",{ref:d,onMouseMove:e=>{if(d.current){const t=d.current.getBoundingClientRect();b(e,t,m)}},onMouseUp:e=>{e.preventDefault(),e.stopPropagation(),T()},onMouseLeave:D,style:{position:"relative"},children:[l.jsx(L,{hourHeight:m}),p.map(e=>{const o=B(r,e,n),i=f(r);return l.jsxs(t.Grid,{container:!0,children:[l.jsx(K,{hour:e,hourHeight:m,gridSize:u.DAY_LABEL}),l.jsx(G,{hour:e,events:o,hourHeight:m,selection:v,date:i,onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),d.current){const t=d.current.getBoundingClientRect();y({event:e,date:i,containerRect:t,hourHeight:m})}},onEventClick:h,gridSize:u.DAY_CONTENT,showRightBorder:!0})]},e)})]})})]})})},Z=()=>{const{currentDate:e,events:r,setEventForm:n,setIsEventDialogOpen:o,setSelectedEvent:i,setIsEditing:a}=j(),s=T(e),{handleEditEvent:c}=C({setSelectedEvent:i,setIsEditing:a,setEventForm:n,setIsEventDialogOpen:o});return l.jsx(t.Card,{children:l.jsxs(t.CardContent,{sx:{p:0},children:[l.jsx(t.Grid,{container:!0,children:d.map(e=>l.jsx(t.Grid,{item:!0,xs:12/7,children:l.jsx(t.Box,{sx:{p:2,textAlign:"center",fontWeight:"bold",backgroundColor:"primary.main",borderRight:"1px solid",borderColor:"divider",color:"primary.contrastText"},children:e})},e))}),l.jsx(t.Grid,{container:!0,children:s.map((e,n)=>{const o=e?$(e,r):[],i=!!e&&y(e);return l.jsx(t.Grid,{item:!0,xs:12/7,children:l.jsxs(t.Box,{sx:{minHeight:120,p:1,borderRight:"1px solid",borderBottom:"1px solid",borderColor:"divider",backgroundColor:i?"primary.light":"transparent"},children:[e&&l.jsx(t.Typography,{variant:"body2",sx:{fontWeight:i?"bold":"normal",color:i?"primary.contrastText":"text.primary"},children:e.getDate()}),l.jsxs(t.Box,{sx:{mt:.5,position:"relative",minHeight:80},children:[o.slice(0,5).map((e,r)=>{const n=18*r;return l.jsx(t.Box,{sx:{position:"absolute",top:`${n}px`,left:0,right:0,backgroundColor:e.color||"primary.main",color:e.color?"white":"primary.contrastText",borderRadius:.5,px:.5,py:.25,cursor:"pointer",fontSize:"0.7rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",zIndex:5,"&:hover":{backgroundColor:e.color?`${e.color}CC`:"primary.dark"}},onClick:t=>{t.stopPropagation(),c(e)},children:l.jsxs(t.Typography,{variant:"caption",sx:{fontSize:"0.7rem"},children:[g(e.startTime)," ",e.title]})},e.id)}),o.length>5&&l.jsxs(t.Typography,{variant:"caption",color:"text.secondary",sx:{position:"absolute",top:"90px",left:0,fontSize:"0.65rem"},children:["+",o.length-5," mais"]})]})]})},n)})})]})})},ee=()=>{const{currentDate:r,events:n,setEventForm:o,setIsEventDialogOpen:i,setSelectedEvent:a,setIsEditing:s}=j(),d=e.useRef(null),p=v(r),m=x(),h=c.WEEK,{handleEditEvent:g,handleCreateEvent:y}=C({setSelectedEvent:a,setIsEditing:s,setEventForm:o,setIsEventDialogOpen:i}),{selection:b,handleMouseDown:T,handleMouseMove:D,handleMouseUp:E,clearSelection:w}=X({onTimeSelected:e=>{y(e.date,e.startTime,e.endTime),w()},events:n});J({containerRef:d,hourHeight:h});const S=f(new Date),k=p.findIndex(e=>f(e)===S);return l.jsx(t.Card,{children:l.jsxs(t.CardContent,{sx:{p:0,position:"relative"},children:[l.jsx(t.Grid,{container:!0,children:l.jsx(q,{days:p})}),l.jsx(t.Box,{sx:{maxHeight:"calc(100vh - 280px)",overflow:"auto",position:"relative"},children:l.jsxs("div",{ref:d,onMouseMove:e=>{if(d.current){const t=d.current.getBoundingClientRect();D(e,t,h)}},onMouseUp:e=>{e.preventDefault(),e.stopPropagation(),E()},onMouseLeave:w,style:{position:"relative"},children:[k>=0&&l.jsx(L,{hourHeight:h,limitToDay:!0,currentDayIndex:k,totalDays:7}),m.map(e=>l.jsxs(t.Grid,{container:!0,children:[l.jsx(K,{hour:e,hourHeight:h,gridSize:u.WEEK_LABEL}),p.map((t,r)=>{const o=B(t,e,n),i=f(t),a=r===p.length-1;return l.jsx(G,{hour:e,events:o,hourHeight:h,selection:b,date:i,onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),d.current){const t=d.current.getBoundingClientRect();T({event:e,date:i,containerRect:t,hourHeight:h})}},onEventClick:g,gridSize:u.WEEK_DAY,showRightBorder:a},r)})]},e))]})})]})})},te=({headerActions:e,dialog:r})=>{const{view:n,isLoading:o}=j();return l.jsxs(t.Box,{sx:{position:"relative"},children:[e,l.jsx(z,{}),(()=>{switch(n){case"month":default:return l.jsx(Z,{});case"week":return l.jsx(ee,{});case"day":return l.jsx(Q,{})}})(),r,o&&l.jsx(t.Box,{sx:{position:"absolute",top:64,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.8)",zIndex:1e3},children:l.jsxs(t.Stack,{spacing:2,alignItems:"center",children:[l.jsx(t.CircularProgress,{size:48}),l.jsx(t.Typography,{variant:"body1",color:"text.secondary",children:"Carregando eventos..."})]})})]})},re=e.createContext(void 0);exports.Calendar=({events:e=[],isLoading:t=!1,onEventAdd:r,onEventEdit:n,onEventDelete:o,onDateRangeChange:i,headerActions:a,dialog:s})=>l.jsx(w,{events:e,isLoading:t,onEventAdd:r,onEventEdit:n,onEventDelete:o,onDateRangeChange:i,children:l.jsx(te,{headerActions:a,dialog:s})}),exports.CalendarHeader=z,exports.CalendarProvider=w,exports.CalendarRecordProvider=({children:e,record:t})=>l.jsx(re.Provider,{value:{record:t},children:e}),exports.CurrentTimeLine=L,exports.DEFAULT_EVENT_FORM=p,exports.DayHeader=W,exports.DayView=Q,exports.EventCard=Y,exports.EventView=({customFields:e})=>{const{selectedEvent:r}=j();return r?l.jsx(t.Box,{sx:{pt:1},children:l.jsxs(t.Stack,{spacing:2.5,children:[l.jsxs(t.Box,{children:[l.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Título"}),l.jsx(t.Typography,{variant:"body1",fontWeight:500,children:r.title||"-"})]}),l.jsxs(t.Box,{children:[l.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Horário"}),l.jsxs(t.Typography,{variant:"body1",fontWeight:500,children:[r.startTime," - ",r.endTime]})]}),l.jsxs(t.Box,{children:[l.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Data"}),l.jsx(t.Typography,{variant:"body1",children:new Date(r.date).toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"})})]}),r.description&&l.jsxs(t.Box,{children:[l.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Descrição"}),l.jsx(t.Typography,{variant:"body1",children:r.description})]}),e]})}):null},exports.GRID_SIZE=u,exports.HOUR_HEIGHT=c,exports.HourCell=G,exports.HourLabel=K,exports.MIN_EVENT_DURATION_MINUTES=10,exports.MIN_EVENT_HEIGHT=20,exports.MonthView=Z,exports.TIME_SNAP_MINUTES=10,exports.TimeSelectionOverlay=U,exports.WEEK_DAYS_PT=d,exports.WeekHeader=q,exports.WeekView=ee,exports.calculateAvailableDurations=({date:e,startTime:t,events:r,currentEventId:n})=>{if(!e||!t)return k.map(e=>({...e,available:!1}));const o=(({date:e,startTime:t,events:r,currentEventId:n})=>{const o=new Date(`${e}T${t}`),i=r.filter(t=>(!n||t.id!==n)&&(t.date===e&&new Date(`${t.date}T${t.startTime}`)>o)).sort((e,t)=>{const r=new Date(`${e.date}T${e.startTime}`),n=new Date(`${t.date}T${t.startTime}`);return r.getTime()-n.getTime()});if(0===i.length)return null;const a=i[0],s=new Date(`${a.date}T${a.startTime}`).getTime()-o.getTime();return Math.floor(s/6e4)})({date:e,startTime:t,events:r,currentEventId:n});if(null===o)return[...k.map(e=>({...e,available:!0})),{value:-1,label:"Customizado",available:!0}];const i=k.map(e=>({...e,available:e.value<=o}));return o>180&&i.push({value:-1,label:"Customizado",available:!0}),i},exports.calculateDuration=(e,t)=>{const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);if(isNaN(r)||isNaN(n)||isNaN(o)||isNaN(i))return 0;const a=new Date;a.setHours(r,n,0,0);const s=new Date;s.setHours(o,i,0,0),s<a&&s.setTime(s.getTime()+864e5);const l=s.getTime()-a.getTime(),c=Math.floor(l/6e4);return Math.max(c,1)},exports.calculateEndTime=(e,t)=>{const[r,n]=e.split(":").map(Number),o=new Date;o.setHours(r,n,0,0),o.setMinutes(o.getMinutes()+t);return`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`},exports.calculateEventHeight=P,exports.calculateEventPosition=F,exports.checkEventConflict=({eventId:e,date:t,startTime:r,endTime:n,existingEvents:o})=>o.find(o=>{const i=o.date.trim()===t.trim(),a=o.id!==e;return!(!i||!a)&&(({startTimeA:e,endTimeA:t,startTimeB:r,endTimeB:n})=>{const o=M(e),i=M(t),a=M(r),s=M(n);return!(isNaN(o)||isNaN(i)||isNaN(a)||isNaN(s))&&o<s&&a<i})({startTimeA:r,endTimeA:n,startTimeB:o.startTime,endTimeB:o.endTime})})??null,exports.createLocalDate=m,exports.createLocalDateFromString=h,exports.formatDateRange=b,exports.formatDateToLocalString=f,exports.formatTime=g,exports.getDateRangeForView=D,exports.getDaysInMonth=T,exports.getDaysInWeek=v,exports.getEventLayout=A,exports.getEventPosition=V,exports.getEventsForDate=$,exports.getEventsForDateAndTime=(e,t,r)=>r.filter(r=>{const n=h(r.date),o=parseInt(r.startTime.split(":")[0]);return f(n)===f(e)&&o===t}),exports.getEventsForHour=B,exports.getGridLines=(e=60)=>{const t=[];for(let r=0;r<24;r++){t.push({top:r*e,type:"hour",hour:r});for(let n=10;n<60;n+=10)t.push({top:r*e+n/60*e,type:"minute",hour:r,minute:n})}return t},exports.getHoursInDay=x,exports.isToday=y,exports.useCalendar=j,exports.useCalendarNavigation=S,exports.useCalendarRecordContext=()=>{const t=e.useContext(re);if(void 0===t)throw new Error("useCalendarRecordContext must be used within a CalendarRecordProvider");return t},exports.useCalendarUtils=(t={})=>{const{allowPastEvents:r=!1}=t;return e.useMemo(()=>({validateEventDatesAndTimes:e=>{const{date:t,startTime:n,endTime:o,duration:i}=e;if(!(t&&n&&o&&i))return{isValid:!1,errorMessage:"Todos os campos de data e hora são obrigatórios"};const a=new Date(t);if(isNaN(a.getTime()))return{isValid:!1,errorMessage:"Data inválida"};const s=/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;if(!s.test(n)||!s.test(o))return{isValid:!1,errorMessage:"Horários inválidos"};const[l,c]=n.split(":").map(Number),[u,d]=o.split(":").map(Number),p=60*l+c,m=60*u+d;if(m<=p)return{isValid:!1,errorMessage:"O horário de fim deve ser posterior ao de início"};const f=m-p;if(Math.abs(f-i)>1)return{isValid:!1,errorMessage:"A duração não confere com os horários informados"};if(!r){const e=new Date;if(new Date(`${t}T${n}:00`)<e)return{isValid:!1,errorMessage:"Não é possível agendar eventos no passado"}}return{isValid:!0}},checkForTimeConflictsWithExistingEvents:e=>{const{eventId:t,date:r,startTime:n,endTime:o,existingEvents:i}=e,[a,s]=n.split(":").map(Number),[l,c]=o.split(":").map(Number),u=60*a+s,d=60*l+c;for(const p of i){if(t&&p.id===t)continue;if(p.date!==r)continue;const[e,n]=p.startTime.split(":").map(Number),[o,i]=p.endTime.split(":").map(Number);if(u<60*o+i&&d>60*e+n)return{hasConflict:!0,conflictingEvent:p}}return{hasConflict:!1}},calculateDurationBetweenTwoTimes:(e,t)=>{const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);return 60*o+i-(60*r+n)},calculateEndTimeFromStartTimeAndDuration:(e,t)=>{const[r,n]=e.split(":").map(Number),o=60*r+n+t,i=o%60;return`${Math.floor(o/60).toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`},formatDateForDisplay:e=>("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR"),formatTimeForDisplay:e=>e,createISOStringFromDateAndTime:(e,t)=>{const[r,n,o]=e.split("-").map(Number),[i,a]=t.split(":").map(Number);return new Date(r,n-1,o,i,a).toISOString()}}),[r])},exports.useEventHandlers=C,exports.useTimeSelection=X,exports.validateDateFormat=I,exports.validateDateRange=O,exports.validateDuration=N,exports.validateEventDates=({date:e,startTime:t,endTime:r,duration:n,allowPastEvents:o=!1})=>{const i=I(e);if(!i.isValid)return i;const a=_(t);if(!a.isValid)return a;const s=_(r);if(!s.isValid)return s;const l=R(t,r);if(!l.isValid)return l;const c=N(n);if(!c.isValid)return c;const u=O(e);if(!u.isValid)return u;if(!o){const r=H(e,t);if(!r.isValid)return r}return{isValid:!0}},exports.validateNotInPast=H,exports.validateTimeFormat=_,exports.validateTimeOrder=R;
|
|
10
|
+
*/"production"===process.env.NODE_ENV?i.exports=function(){if(o)return a;o=1;var e=n.default,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,r,n){var o,a={},c=null,u=null;for(o in void 0!==n&&(c=""+n),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(u=r.ref),r)i.call(r,o)&&!l.hasOwnProperty(o)&&(a[o]=r[o]);if(e&&e.defaultProps)for(o in r=e.defaultProps)void 0===a[o]&&(a[o]=r[o]);return{$$typeof:t,type:e,key:c,ref:u,props:a,_owner:s.current}}return a.Fragment=r,a.jsx=c,a.jsxs=c,a}():i.exports=(s||(s=1,"production"!==process.env.NODE_ENV&&function(){var e,t=n.default,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),v=Symbol.iterator,x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=x.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map(function(e){return String(e)});o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}function b(e){return e.displayName||"Context"}function T(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case i:return"Fragment";case o:return"Portal";case s:return"Profiler";case a:return"StrictMode";case p:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case u:return b(e)+".Consumer";case c:return b(e._context)+".Provider";case d:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case f:var t=e.displayName||null;return null!==t?t:T(e.type)||"Memo";case h:var r=e,n=r._payload,l=r._init;try{return T(l(n))}catch(g){return null}}return null}e=Symbol.for("react.module.reference");var D,E,w,j,S,C,k,M=Object.assign,N=0;function R(){}R.__reactDisabledLog=!0;var I,_=x.ReactCurrentDispatcher;function O(e,t,r){if(void 0===I)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);I=n&&n[1]||""}return"\n"+I+e}var H,$=!1,B="function"==typeof WeakMap?WeakMap:Map;function F(e,t){if(!e||$)return"";var r,n=H.get(e);if(void 0!==n)return n;$=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=_.current,_.current=null,function(){if(0===N){D=console.log,E=console.info,w=console.warn,j=console.error,S=console.group,C=console.groupCollapsed,k=console.groupEnd;var e={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(f){r=f}Reflect.construct(e,[],a)}else{try{a.call()}catch(f){r=f}e.call(a.prototype)}}else{try{throw Error()}catch(f){r=f}e()}}catch(h){if(h&&r&&"string"==typeof h.stack){for(var s=h.stack.split("\n"),l=r.stack.split("\n"),c=s.length-1,u=l.length-1;c>=1&&u>=0&&s[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(s[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||s[c]!==l[u]){var d="\n"+s[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&H.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{$=!1,_.current=o,function(){if(0===--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},e,{value:D}),info:M({},e,{value:E}),warn:M({},e,{value:w}),error:M({},e,{value:j}),group:M({},e,{value:S}),groupCollapsed:M({},e,{value:C}),groupEnd:M({},e,{value:k})})}N<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var p=e?e.displayName||e.name:"",m=p?O(p):"";return"function"==typeof e&&H.set(e,m),m}function P(e,t,r){if(null==e)return"";if("function"==typeof e)return F(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return O(e);switch(e){case p:return O("Suspense");case m:return O("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return F(e.render,!1);case f:return P(e.type,t,r);case h:var o=e,i=o._payload,a=o._init;try{return P(a(i),t,r)}catch(s){}}return""}H=new B;var A=Object.prototype.hasOwnProperty,V={},z=x.ReactDebugCurrentFrame;function L(e){if(e){var t=e._owner,r=P(e.type,e._source,t?t.type:null);z.setExtraStackFrame(r)}else z.setExtraStackFrame(null)}var W=Array.isArray;function Y(e){return W(e)}function U(e){return""+e}function G(e){if(function(e){try{return U(e),!1}catch(t){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),U(e)}var K,q,J=x.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,n,o,i){var a,s={},l=null,c=null;for(a in void 0!==n&&(G(n),l=""+n),function(e){if(A.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(G(t.key),l=""+t.key),function(e){if(A.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&J.current}(t)),t)A.call(t,a)&&!X.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===s[a]&&(s[a]=u[a])}if(l||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var r=function(){K||(K=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(s,d),c&&function(e,t){var r=function(){q||(q=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(s,d)}return function(e,t,n,o,i,a,s){var l={$$typeof:r,type:e,key:t,ref:n,props:s,_owner:a,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,i,o,J.current,s)}var Z,ee=x.ReactCurrentOwner,te=x.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=P(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function oe(){if(ee.current){var e=T(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ie={};function ae(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=oe();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!ie[r]){ie[r]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+T(e._owner.type)+"."),re(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),re(null)}}}function se(e,t){if("object"==typeof e)if(Y(e))for(var r=0;r<e.length;r++){var n=e[r];ne(n)&&ae(n,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var i,a=o.call(e);!(i=a.next()).done;)ne(i.value)&&ae(i.value,t)}}function le(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==d&&r.$$typeof!==f)return;t=r.propTypes}if(t){var n=T(r);!function(e,t,r,n,o){var i=Function.call.bind(A);for(var a in e)if(i(e,a)){var s=void 0;try{if("function"!=typeof e[a]){var l=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}s=e[a](t,a,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){s=c}!s||s instanceof Error||(L(o),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,a,typeof s),L(null)),s instanceof Error&&!(s.message in V)&&(V[s.message]=!0,L(o),y("Failed %s type: %s",r,s.message),L(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||Z||(Z=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ce={};function ue(t,n,o,l,v,x){var b=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===s||t===a||t===p||t===m||t===g||"object"==typeof t&&null!==t&&(t.$$typeof===h||t.$$typeof===f||t.$$typeof===c||t.$$typeof===u||t.$$typeof===d||t.$$typeof===e||void 0!==t.getModuleId)}(t);if(!b){var D,E="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),E+=oe(),null===t?D="null":Y(t)?D="array":void 0!==t&&t.$$typeof===r?(D="<"+(T(t.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):D=typeof t,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,E)}var w=Q(t,n,o,v,x);if(null==w)return w;if(b){var j=n.children;if(void 0!==j)if(l)if(Y(j)){for(var S=0;S<j.length;S++)se(j[S],t);Object.freeze&&Object.freeze(j)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(j,t)}if(A.call(n,"key")){var C=T(t),k=Object.keys(n).filter(function(e){return"key"!==e}),M=k.length>0?"{key: someKey, "+k.join(": ..., ")+": ...}":"{key: someKey}";ce[C+M]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',M,C,k.length>0?"{"+k.join(": ..., ")+": ...}":"{}",C),ce[C+M]=!0)}return t===i?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){re(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),re(null);break}}null!==e.ref&&(re(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(w):le(w),w}var de=function(e,t,r){return ue(e,t,r,!1)},pe=function(e,t,r){return ue(e,t,r,!0)};l.Fragment=i,l.jsx=de,l.jsxs=pe}()),l);var c=i.exports;const u={DAY:80,WEEK:60,MONTH:120},d={DAY_LABEL:3,DAY_CONTENT:9,WEEK_LABEL:1,WEEK_DAY:11/7},p=["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],m={title:"",description:"",startTime:"",endTime:"",date:"",customData:{}},f=(e,t,r)=>new Date(e,t,r,12,0,0,0),h=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,g=e=>{const[t,r,n]=e.split("-").map(Number);return f(t,r-1,n)},v=e=>{const[t,r]=e.split(":");return`${t}:${r}`},x=e=>{const t=e.getFullYear(),r=e.getMonth(),n=e.getDate()-e.getDay(),o=[];for(let i=0;i<7;i++){const e=n+i;o.push(f(t,r,e))}return o},y=()=>{const e=[];for(let t=0;t<24;t++)e.push(t);return e},b=e=>e.toDateString()===(new Date).toDateString(),T=(e,t)=>{switch(t){case"month":return new Intl.DateTimeFormat("pt-BR",{year:"numeric",month:"long"}).format(e);case"week":{const t=x(e),r=t[0],n=t[6];if(r.getMonth()===n.getMonth()){return`${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short"}).format(r)} - ${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short",year:"numeric"}).format(n)}`}return`${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short"}).format(r)} - ${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"short",year:"numeric"}).format(n)}`}case"day":return new Intl.DateTimeFormat("pt-BR",{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(e);default:return""}},D=e=>{const t=e.getFullYear(),r=e.getMonth(),n=new Date(t,r,1),o=new Date(t,r+1,0).getDate(),i=n.getDay(),a=[];for(let s=0;s<i;s++)a.push(null);for(let s=1;s<=o;s++)a.push(f(t,r,s));return a},E=(e,t)=>{const r=e.getFullYear(),n=e.getMonth();switch(t){case"day":{const t=h(e);return{startDate:t,endDate:t}}case"week":{const t=x(e);return{startDate:h(t[0]),endDate:h(t[6])}}case"month":{const e=f(r,n,1),t=f(r,n+1,0);return{startDate:h(e),endDate:h(t)}}default:return{startDate:h(e),endDate:h(e)}}},w=e.createContext(void 0),j=({children:t,events:r=[],isLoading:n=!1,onEventAdd:o,onEventEdit:i,onEventDelete:a,onDateRangeChange:s})=>{const[l,u]=e.useState(new Date),[d,p]=e.useState("week"),[f,h]=e.useState(!1),[g,v]=e.useState(!1),[x,y]=e.useState(null),[b,T]=e.useState(m),D=e.useRef(s);e.useEffect(()=>{D.current=s},[s]),e.useEffect(()=>{if(D.current){const e=E(l,d);D.current(e)}},[l,d]);const j=e.useMemo(()=>({currentDate:l,setCurrentDate:u,view:d,setView:p,isEventDialogOpen:f,setIsEventDialogOpen:h,isEditing:g,setIsEditing:v,selectedEvent:x,setSelectedEvent:y,eventForm:b,setEventForm:T,events:r,isLoading:n,onEventAdd:o,onEventEdit:i,onEventDelete:a}),[l,d,f,g,x,b,r,n,o,i,a]);return c.jsx(w.Provider,{value:j,children:t})},S=()=>{const t=e.useContext(w);if(void 0===t)throw new Error("useCalendar must be used within a CalendarProvider");return t},C=({view:t,setCurrentDate:r})=>({handlePrevious:e.useCallback(()=>{switch(t){case"month":r(e=>new Date(e.getFullYear(),e.getMonth()-1,1));break;case"week":r(e=>new Date(e.getTime()-6048e5));break;case"day":r(e=>new Date(e.getTime()-864e5))}},[t,r]),handleNext:e.useCallback(()=>{switch(t){case"month":r(e=>new Date(e.getFullYear(),e.getMonth()+1,1));break;case"week":r(e=>new Date(e.getTime()+6048e5));break;case"day":r(e=>new Date(e.getTime()+864e5))}},[t,r]),handleToday:e.useCallback(()=>{r(new Date)},[r])}),k=({setSelectedEvent:t,setIsEditing:r,setEventForm:n,setIsEventDialogOpen:o})=>({handleEditEvent:e.useCallback(e=>{let i=60;if(e.startTime&&e.endTime){const[t,r]=e.startTime.split(":").map(Number),[n,o]=e.endTime.split(":").map(Number),a=new Date;a.setHours(t,r,0,0);const s=new Date;s.setHours(n,o,0,0);const l=s.getTime()-a.getTime();i=Math.floor(l/6e4)}t(e),r(!0),n({title:e.title,description:e.description,startTime:e.startTime,endTime:e.endTime,date:e.date,duration:i,customData:e.customData||{}}),o(!0)},[t,r,n,o]),handleCreateEvent:(e,i,a)=>{t(null),r(!1);const s=Boolean(i&&a&&e);let l=60;if(i&&a){const[e,t]=i.split(":").map(Number),[r,n]=a.split(":").map(Number),o=new Date;o.setHours(e,t,0,0);const s=new Date;s.setHours(r,n,0,0);const c=s.getTime()-o.getTime();l=Math.floor(c/6e4)}n({title:s?"Novo Evento":"",description:"",startTime:i||"",endTime:a||"",date:e||"",duration:l,customData:{}}),o(!0)}}),M=[{value:15,label:"15 minutos"},{value:30,label:"30 minutos"},{value:45,label:"45 minutos"},{value:60,label:"1 hora"},{value:120,label:"2 horas"},{value:180,label:"3 horas"}],N=e=>{if(!e||!e.includes(":"))return NaN;const[t,r]=e.split(":").map(Number);return 60*t+r},R=e=>e<=0?{isValid:!1,errorMessage:"A duração deve ser maior que zero"}:{isValid:!0},I=(e,t)=>{if(!e||!t)return{isValid:!1,errorMessage:"Horário de início e fim são obrigatórios"};const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);if(isNaN(r)||isNaN(n)||isNaN(o)||isNaN(i))return{isValid:!1,errorMessage:"Formato de horário inválido"};return 60*r+n>=60*o+i?{isValid:!1,errorMessage:"O horário de início deve ser antes do horário de fim"}:{isValid:!0}},_=e=>{if(!e)return{isValid:!1,errorMessage:"Data é obrigatória"};if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return{isValid:!1,errorMessage:"Formato de data inválido (esperado: YYYY-MM-DD)"};const[t,r,n]=e.split("-").map(Number),o=new Date(t,r-1,n);return o.getFullYear()!==t||o.getMonth()!==r-1||o.getDate()!==n?{isValid:!1,errorMessage:"Data inválida"}:{isValid:!0}},O=e=>{if(!e)return{isValid:!1,errorMessage:"Horário é obrigatório"};return/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{isValid:!0}:{isValid:!1,errorMessage:"Formato de horário inválido (esperado: HH:MM)"}},H=(e,t)=>{const r=_(e);if(!r.isValid)return r;const n=O(t);if(!n.isValid)return n;const[o,i,a]=e.split("-").map(Number),[s,l]=t.split(":").map(Number);return new Date(o,i-1,a,s,l)<new Date?{isValid:!1,errorMessage:"O evento não pode ser criado no passado"}:{isValid:!0}},$=(e,t=5)=>{const r=_(e);if(!r.isValid)return r;const[n,o,i]=e.split("-").map(Number),a=new Date(n,o-1,i),s=new Date;return s.setFullYear(s.getFullYear()+t),a>s?{isValid:!1,errorMessage:`A data não pode ser mais de ${t} anos no futuro`}:{isValid:!0}},B=(e,t)=>t.filter(t=>{const r=g(t.date);return h(r)===h(e)}),F=(e,t,r)=>r.filter(r=>{const n=g(r.date),[o]=r.startTime.split(":").map(Number);return h(n)===h(e)&&o===t}),P=(e,t=60)=>{const[r,n]=e.split(":").map(Number);return(60*r+n)/60*t},A=(e,t,r=60)=>{const[n,o]=e.split(":").map(Number),[i,a]=t.split(":").map(Number),s=60*i+a-(60*n+o);return Math.max(s/60*r,10)},V=(e,t,r=60)=>{const n=A(e,t,r);return n<=10?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.50rem",WebkitLineClamp:1}:n<30?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.70rem",padding:1,WebkitLineClamp:1}:n<40?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:1}:n<=60?{height:n,showTitle:!0,showTime:!1,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:3}:{height:n,showTitle:!0,showTime:!0,showDescription:!1,fontSize:"0.75rem",padding:6,WebkitLineClamp:3}},z=(e,t=60)=>{const[,r]=e.split(":").map(Number);return r/60*t},L=(e,t)=>{const r=e=>{const[t,r]=e.split(":").map(Number);return 60*t+r},n=r(e.startTime),o=r(e.endTime),i=r(t.startTime);return n<r(t.endTime)&&i<o},W=e=>{const t=[];for(let r=0;r<e.length;r++){const n=e[r];let o=0,i=1;const a=e.filter((e,t)=>t!==r&&L(n,e));i=a.length+1;const s=[n,...a];s.sort((e,t)=>{const r=e.startTime,n=t.startTime;return r.localeCompare(n)}),o=s.findIndex(e=>e.id===n.id),t.push({id:n.id,startTime:n.startTime,endTime:n.endTime,overlapIndex:o,totalOverlapping:i})}return t},Y=e=>{if(1===e.totalOverlapping)return{width:"calc(100% - 8px)",left:"4px"};const t=100/e.totalOverlapping,r=100/e.totalOverlapping*e.overlapIndex;return{width:`calc(${t}% - ${8/e.totalOverlapping}px)`,left:`calc(${r}% + 4px)`}},U=()=>{const{currentDate:e,setCurrentDate:n,view:o,setView:i,setSelectedEvent:a,setIsEditing:s,setEventForm:l,setIsEventDialogOpen:u}=S(),{handlePrevious:d,handleNext:p,handleToday:m}=C({view:o,setCurrentDate:n}),{handleCreateEvent:f}=k({setSelectedEvent:a,setIsEditing:s,setEventForm:l,setIsEventDialogOpen:u});return c.jsxs(t.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:[c.jsx(t.Typography,{variant:"h4",component:"h1",children:T(e,o)}),c.jsxs(t.Box,{display:"flex",gap:2,alignItems:"center",children:[c.jsxs(t.ToggleButtonGroup,{value:o,exclusive:!0,onChange:(e,t)=>t&&i(t),size:"small",children:[c.jsx(t.ToggleButton,{value:"month",children:"Mês"}),c.jsx(t.ToggleButton,{value:"week",children:"Semana"}),c.jsx(t.ToggleButton,{value:"day",children:"Dia"})]}),c.jsxs(t.Box,{display:"flex",gap:1,children:[c.jsx(t.Button,{variant:"outlined",onClick:d,children:"Anterior"}),c.jsx(t.Button,{variant:"outlined",onClick:m,children:"Hoje"}),c.jsx(t.Button,{variant:"outlined",onClick:p,children:"Próximo"}),c.jsx(t.Button,{variant:"contained",startIcon:c.jsx(r.Add,{}),onClick:()=>f(),children:"Novo Evento"})]})]})]})},G=({hourHeight:r,limitToDay:n=!1,currentDayIndex:o=0,totalDays:i=1})=>{const[a,s]=e.useState(new Date);e.useEffect(()=>{const e=setInterval(()=>{s(new Date)},6e4);return()=>clearInterval(e)},[]);const l=a.getHours(),u=a.getMinutes(),d=`${l.toString().padStart(2,"0")}:${u.toString().padStart(2,"0")}`,p=P(d,r),m=(()=>{if(!n)return{left:0,right:0};const e=11/12*100/i;return{left:`calc(${1/12*100+o*e}% + 4px)`,width:`calc(${e}% - 8px)`}})();return c.jsxs(c.Fragment,{children:[c.jsx(t.Box,{sx:{position:"absolute",...m,top:`${p}px`,height:"2px",backgroundColor:"error.main",zIndex:100,pointerEvents:"none","&::before":{content:'""',position:"absolute",left:"4px",top:"50%",transform:"translateY(-50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"error.main"}}}),c.jsx(t.Box,{sx:{position:"absolute",left:n?`calc(${m.left} + 16px)`:0,top:p-10+"px",backgroundColor:"error.main",color:"white",fontSize:"0.65rem",fontWeight:"bold",padding:"2px 4px",borderRadius:"4px",zIndex:101,pointerEvents:"none"},children:d})]})},K=({day:e,gridSize:r=9})=>{const n=b(e);return c.jsx(t.Grid,{item:!0,xs:r,children:c.jsx(t.Box,{sx:{p:2,textAlign:"center",fontWeight:"bold",minHeight:80,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:n?"primary.main":"background.paper",color:n?"primary.contrastText":"text.primary",borderRight:"2px solid",borderColor:"divider"},children:c.jsx(t.Typography,{variant:"h6",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{weekday:"long",day:"2-digit",month:"2-digit"}).format(e)})})})},q=({event:e,hourHeight:r,onClick:n,overlapInfo:o})=>{const i=z(e.startTime,r),a=A(e.startTime,e.endTime,r),s=V(e.startTime,e.endTime,r),l=e.color||"#2196F3",u=(e=>{const t=e.replace(/^#/,""),r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=e=>Math.max(0,e-30);return`#${i(r).toString(16).padStart(2,"0")}${i(n).toString(16).padStart(2,"0")}${i(o).toString(16).padStart(2,"0")}`})(l),d=o?Y(o):{width:"calc(100% - 8px)",left:"4px"};return c.jsx(t.Tooltip,{title:e.tooltip||e.title,arrow:!0,placement:"top",children:c.jsxs(t.Box,{sx:{position:"absolute",top:`${i}px`,left:d.left,width:d.width,height:`${a}px`,backgroundColor:l,color:"white",borderRadius:1,p:s?.padding?s.padding/8:0,cursor:"pointer",fontSize:s.fontSize,overflow:"hidden",zIndex:10,display:"flex",flexDirection:"column",justifyContent:s.height<30?"center":"flex-start",border:"1px solid rgba(255,255,255,0.2)","&:hover":{backgroundColor:u}},onClick:t=>{t.stopPropagation(),n(e)},children:[s.showTitle&&c.jsx(t.Typography,{variant:"body2",sx:{fontSize:s.fontSize,color:"white",lineHeight:1.2,mb:s.showTime?.25:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:s.WebkitLineClamp,WebkitBoxOrient:"vertical",cursor:"inherit"},children:e.title}),s.showTime&&c.jsxs(t.Typography,{variant:"caption",sx:{fontSize:.9*parseFloat(s.fontSize)+"rem",color:"rgba(255,255,255,0.9)",lineHeight:1,mb:s.showDescription?.25:0,overflow:"hidden",textOverflow:"ellipsis"},children:[v(e.startTime)," - ",v(e.endTime)]}),s.showDescription&&e.description&&c.jsx(t.Typography,{variant:"caption",sx:{fontSize:.85*parseFloat(s.fontSize)+"rem",color:"rgba(255,255,255,0.8)",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.description})]})})},J=({selection:e,hourHeight:r=60,currentHour:n})=>{if(!e||!e.isSelecting)return null;if(void 0!==n){const o=e.startHour,i=e.endHour;if(n<o||n>i)return null;if(n===o){const o=e.startMinute,a=n===i?e.endMinute:60;return c.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:o/60*r+"px",height:(a-o)/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}if(n===i){const n=e.endMinute;return c.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:0,height:n/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}return c.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:0,height:`${r}px`,backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})}const o=60*e.startHour+e.startMinute,i=60*e.endHour+e.endMinute,a=Math.min(o,i),s=Math.abs(i-o),l=Math.max(s,15);return c.jsx(t.Box,{"data-testid":"time-selection-overlay",sx:{position:"absolute",left:0,right:0,top:a/60*r+"px",height:l/60*r+"px",backgroundColor:"primary.main",opacity:.3,borderRadius:1,border:"1px solid",borderColor:"primary.main",pointerEvents:"none",zIndex:10}})},X=({hour:e,events:r,hourHeight:n,selection:o,date:i,onMouseDown:a,onClick:s,onEventClick:l,gridSize:u=9,showRightBorder:d=!1,allEvents:p=r})=>{const m=[10,20,30,40,50].map(e=>({minute:e,top:e/60*n})),f=W(p);return c.jsx(t.Grid,{item:!0,xs:u,children:c.jsxs(t.Box,{sx:{p:1,minHeight:n,cursor:"crosshair",position:"relative",borderTop:"2px solid",borderRight:d?"2px solid":"1px solid",borderColor:e=>e.palette.divider,borderColorRight:e=>d?e.palette.divider:`${e.palette.divider}40`,"&:hover":{backgroundColor:"action.hover"}},onMouseDown:a,onClick:()=>s?.(),children:[m.map(({minute:e,top:r})=>c.jsx(t.Box,{sx:{position:"absolute",left:0,right:0,top:`${r}px`,height:"1px",backgroundColor:e=>e.palette.divider,opacity:.3,pointerEvents:"none",zIndex:1}},e)),r.map(e=>{const t=f.find(t=>t.id===e.id);return c.jsx(q,{event:e,hourHeight:n,onClick:l,overlapInfo:t},e.id)}),o&&o.date===i&&c.jsx(J,{selection:o,hourHeight:n,currentHour:e})]})})},Q=({hour:e,hourHeight:r=60,gridSize:n=3})=>c.jsx(t.Grid,{item:!0,xs:n,children:c.jsx(t.Box,{sx:{p:1,textAlign:"center",minHeight:r,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"background.default",borderTop:"2px solid",borderRight:"1px solid",borderColor:"divider"},children:c.jsx(t.Typography,{variant:"body2",children:`${e.toString().padStart(2,"0")}:00`})})}),Z=({days:e})=>c.jsxs(c.Fragment,{children:[c.jsx(t.Grid,{item:!0,xs:1,children:c.jsx(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:"background.paper",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid",borderColor:"divider"},children:"Hora"})}),e.map((r,n)=>{const o=b(r),i=n===e.length-1;return c.jsx(t.Grid,{item:!0,xs:11/7,children:c.jsxs(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:o?"primary.main":"background.paper",color:o?"primary.contrastText":"text.primary",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRight:i?"2px solid":"1px solid",borderColor:e=>`${e.palette.divider}40`,borderColorRight:e=>i?e.palette.divider:`${e.palette.divider}40`},children:[c.jsx(t.Typography,{variant:"body2",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{weekday:"short"}).format(r)}),c.jsx(t.Typography,{variant:"h6",sx:{color:"inherit"},children:new Intl.DateTimeFormat("pt-BR",{day:"2-digit"}).format(r)})]})},n)})]}),ee=({containerRef:t,hourHeight:r,enabled:n=!0})=>{e.useEffect(()=>{if(!n||!t.current)return;const e=setTimeout(()=>{const e=new Date,n=(e.getHours()+e.getMinutes()/60)*r,o=t.current?.parentElement;if(!o)return;const i=n-o.clientHeight/2;o.scrollTo({top:Math.max(0,i),behavior:"smooth"})},100);return()=>clearTimeout(e)},[t,r,n])},te=({onTimeSelected:t,events:r=[]}={})=>{const[n,o]=e.useState(null),i=e.useRef(!1),a=e.useRef(null),s=(e,t)=>`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`,l=(e,t,r=60)=>{const n=e-t.top,o=Math.floor(n/r),i=n%r/r,a=(e=>10*Math.round(e/10))(Math.round(60*i));return{hour:Math.max(0,Math.min(23,o)),minute:Math.max(0,Math.min(59,a))}},c=e.useCallback(()=>{if(!i.current||!n)return;i.current=!1,a.current=null;const e=60*n.startHour+n.startMinute,r=60*n.endHour+n.endMinute-e;if(0===r)return void o(null);let l=n.endHour,c=n.endMinute;if(r<10){const e=((e,t,r)=>{const n=60*e+t+r;return{hour:Math.floor(n/60)%24,minute:n%60}})(n.startHour,n.startMinute,10);l=e.hour,c=e.minute}const u={startTime:s(n.startHour,n.startMinute),endTime:s(l,c),date:n.date,startHour:n.startHour,startMinute:n.startMinute,endHour:l,endMinute:c};t&&t(u),o(null)},[n,t]),u=e.useCallback(()=>{o(null),i.current=!1,a.current=null},[]);return{selection:n,handleMouseDown:({event:e,date:t,containerRect:n,hourHeight:c=60})=>{e.preventDefault();const{hour:u,minute:d}=l(e.clientY,n,c);r.some(e=>{if(e.date!==t)return!1;const[r,n]=e.startTime.split(":").map(Number),[o,i]=e.endTime.split(":").map(Number),a=60*u+d;return a>=60*r+n&&a<60*o+i}),i.current=!0,a.current={hour:u,minute:d},o({startTime:s(u,d),endTime:s(u,d),date:t,isSelecting:!0,startHour:u,startMinute:d,endHour:u,endMinute:d})},handleMouseMove:(e,t,r=60)=>{if(!i.current||!a.current||!n)return;const{hour:c,minute:u}=l(e.clientY,t,r);let d,p,m,f;60*c+u>=60*a.current.hour+a.current.minute?(d=a.current.hour,p=a.current.minute,m=c,f=u):(d=c,p=u,m=a.current.hour,f=a.current.minute),o(e=>e?{...e,startTime:s(d,p),endTime:s(m,f),startHour:d,startMinute:p,endHour:m,endMinute:f}:null)},handleMouseUp:c,clearSelection:u,isDragging:i.current}},re=()=>{const{currentDate:r,events:n,setEventForm:o,setIsEventDialogOpen:i,setSelectedEvent:a,setIsEditing:s}=S(),l=e.useRef(null),p=y(),m=u.DAY,{handleEditEvent:f,handleCreateEvent:g}=k({setSelectedEvent:a,setIsEditing:s,setEventForm:o,setIsEventDialogOpen:i}),{selection:v,handleMouseDown:x,handleMouseMove:b,handleMouseUp:T,clearSelection:D}=te({onTimeSelected:e=>{g(e.date,e.startTime,e.endTime),D()},events:n});return ee({containerRef:l,hourHeight:m}),c.jsx(t.Card,{children:c.jsxs(t.CardContent,{sx:{p:0,position:"relative"},children:[c.jsxs(t.Grid,{container:!0,children:[c.jsx(t.Grid,{item:!0,xs:d.DAY_LABEL,children:c.jsx(t.Box,{sx:{p:2,textAlign:"center",minHeight:80,fontWeight:"bold",backgroundColor:"background.paper",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid",borderColor:"divider"},children:"Hora"})}),c.jsx(K,{day:r,gridSize:d.DAY_CONTENT})]}),c.jsx(t.Box,{sx:{maxHeight:"calc(100vh - 280px)",overflow:"auto",position:"relative"},children:c.jsxs("div",{ref:l,onMouseMove:e=>{if(l.current){const t=l.current.getBoundingClientRect();b(e,t,m)}},onMouseUp:e=>{e.preventDefault(),e.stopPropagation(),T()},onMouseLeave:D,style:{position:"relative"},children:[c.jsx(G,{hourHeight:m}),p.map(e=>{const o=F(r,e,n),i=h(r),a=B(r,n);return c.jsxs(t.Grid,{container:!0,children:[c.jsx(Q,{hour:e,hourHeight:m,gridSize:d.DAY_LABEL}),c.jsx(X,{hour:e,events:o,hourHeight:m,selection:v,date:i,onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),l.current){const t=l.current.getBoundingClientRect();x({event:e,date:i,containerRect:t,hourHeight:m})}},onEventClick:f,gridSize:d.DAY_CONTENT,showRightBorder:!0,allEvents:a})]},e)})]})})]})})},ne=()=>{const{currentDate:e,events:r,setEventForm:n,setIsEventDialogOpen:o,setSelectedEvent:i,setIsEditing:a}=S(),s=D(e),{handleEditEvent:l}=k({setSelectedEvent:i,setIsEditing:a,setEventForm:n,setIsEventDialogOpen:o});return c.jsx(t.Card,{children:c.jsxs(t.CardContent,{sx:{p:0},children:[c.jsx(t.Grid,{container:!0,children:p.map(e=>c.jsx(t.Grid,{item:!0,xs:12/7,children:c.jsx(t.Box,{sx:{p:2,textAlign:"center",fontWeight:"bold",backgroundColor:"primary.main",borderRight:"1px solid",borderColor:"divider",color:"primary.contrastText"},children:e})},e))}),c.jsx(t.Grid,{container:!0,children:s.map((e,n)=>{const o=e?B(e,r):[],i=!!e&&b(e);return c.jsx(t.Grid,{item:!0,xs:12/7,children:c.jsxs(t.Box,{sx:{minHeight:120,p:1,borderRight:"1px solid",borderBottom:"1px solid",borderColor:"divider",backgroundColor:i?"primary.light":"transparent"},children:[e&&c.jsx(t.Typography,{variant:"body2",sx:{fontWeight:i?"bold":"normal",color:i?"primary.contrastText":"text.primary"},children:e.getDate()}),c.jsxs(t.Box,{sx:{mt:.5,position:"relative",minHeight:80},children:[o.slice(0,5).map((e,r)=>{const n=18*r;return c.jsx(t.Box,{sx:{position:"absolute",top:`${n}px`,left:0,right:0,backgroundColor:e.color||"primary.main",color:e.color?"white":"primary.contrastText",borderRadius:.5,px:.5,py:.25,cursor:"pointer",fontSize:"0.7rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",zIndex:5,"&:hover":{backgroundColor:e.color?`${e.color}CC`:"primary.dark"}},onClick:t=>{t.stopPropagation(),l(e)},children:c.jsxs(t.Typography,{variant:"caption",sx:{fontSize:"0.7rem"},children:[v(e.startTime)," ",e.title]})},e.id)}),o.length>5&&c.jsxs(t.Typography,{variant:"caption",color:"text.secondary",sx:{position:"absolute",top:"90px",left:0,fontSize:"0.65rem"},children:["+",o.length-5," mais"]})]})]})},n)})})]})})},oe=()=>{const{currentDate:r,events:n,setEventForm:o,setIsEventDialogOpen:i,setSelectedEvent:a,setIsEditing:s}=S(),l=e.useRef(null),p=x(r),m=y(),f=u.WEEK,{handleEditEvent:g,handleCreateEvent:v}=k({setSelectedEvent:a,setIsEditing:s,setEventForm:o,setIsEventDialogOpen:i}),{selection:b,handleMouseDown:T,handleMouseMove:D,handleMouseUp:E,clearSelection:w}=te({onTimeSelected:e=>{v(e.date,e.startTime,e.endTime),w()},events:n});ee({containerRef:l,hourHeight:f});const j=h(new Date),C=p.findIndex(e=>h(e)===j);return c.jsx(t.Card,{children:c.jsxs(t.CardContent,{sx:{p:0,position:"relative"},children:[c.jsx(t.Grid,{container:!0,children:c.jsx(Z,{days:p})}),c.jsx(t.Box,{sx:{maxHeight:"calc(100vh - 280px)",overflow:"auto",position:"relative"},children:c.jsxs("div",{ref:l,onMouseMove:e=>{if(l.current){const t=l.current.getBoundingClientRect();D(e,t,f)}},onMouseUp:e=>{e.preventDefault(),e.stopPropagation(),E()},onMouseLeave:w,style:{position:"relative"},children:[C>=0&&c.jsx(G,{hourHeight:f,limitToDay:!0,currentDayIndex:C,totalDays:7}),m.map(e=>c.jsxs(t.Grid,{container:!0,children:[c.jsx(Q,{hour:e,hourHeight:f,gridSize:d.WEEK_LABEL}),p.map((t,r)=>{const o=F(t,e,n),i=h(t),a=r===p.length-1,s=B(t,n);return c.jsx(X,{hour:e,events:o,hourHeight:f,selection:b,date:i,onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),l.current){const t=l.current.getBoundingClientRect();T({event:e,date:i,containerRect:t,hourHeight:f})}},onEventClick:g,gridSize:d.WEEK_DAY,showRightBorder:a,allEvents:s},r)})]},e))]})})]})})},ie=({headerActions:e,dialog:r})=>{const{view:n,isLoading:o}=S();return c.jsxs(t.Box,{sx:{position:"relative"},children:[e,c.jsx(U,{}),(()=>{switch(n){case"month":default:return c.jsx(ne,{});case"week":return c.jsx(oe,{});case"day":return c.jsx(re,{})}})(),r,o&&c.jsx(t.Box,{sx:{position:"absolute",top:64,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.8)",zIndex:1e3},children:c.jsxs(t.Stack,{spacing:2,alignItems:"center",children:[c.jsx(t.CircularProgress,{size:48}),c.jsx(t.Typography,{variant:"body1",color:"text.secondary",children:"Carregando eventos..."})]})})]})},ae=e.createContext(void 0);exports.Calendar=({events:e=[],isLoading:t=!1,onEventAdd:r,onEventEdit:n,onEventDelete:o,onDateRangeChange:i,headerActions:a,dialog:s})=>c.jsx(j,{events:e,isLoading:t,onEventAdd:r,onEventEdit:n,onEventDelete:o,onDateRangeChange:i,children:c.jsx(ie,{headerActions:a,dialog:s})}),exports.CalendarHeader=U,exports.CalendarProvider=j,exports.CalendarRecordProvider=({children:e,record:t})=>c.jsx(ae.Provider,{value:{record:t},children:e}),exports.CurrentTimeLine=G,exports.DEFAULT_EVENT_FORM=m,exports.DayHeader=K,exports.DayView=re,exports.EventCard=q,exports.EventView=({customFields:e})=>{const{selectedEvent:r}=S();return r?c.jsx(t.Box,{sx:{pt:1},children:c.jsxs(t.Stack,{spacing:2.5,children:[c.jsxs(t.Box,{children:[c.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Título"}),c.jsx(t.Typography,{variant:"body1",fontWeight:500,children:r.title||"-"})]}),c.jsxs(t.Box,{children:[c.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Horário"}),c.jsxs(t.Typography,{variant:"body1",fontWeight:500,children:[r.startTime," - ",r.endTime]})]}),c.jsxs(t.Box,{children:[c.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Data"}),c.jsx(t.Typography,{variant:"body1",children:new Date(r.date).toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"})})]}),r.description&&c.jsxs(t.Box,{children:[c.jsx(t.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Descrição"}),c.jsx(t.Typography,{variant:"body1",children:r.description})]}),e]})}):null},exports.GRID_SIZE=d,exports.HOUR_HEIGHT=u,exports.HourCell=X,exports.HourLabel=Q,exports.MIN_EVENT_DURATION_MINUTES=10,exports.MIN_EVENT_HEIGHT=20,exports.MonthView=ne,exports.TIME_SNAP_MINUTES=10,exports.TimeSelectionOverlay=J,exports.WEEK_DAYS_PT=p,exports.WeekHeader=Z,exports.WeekView=oe,exports.calculateAvailableDurations=({date:e,startTime:t,events:r,currentEventId:n})=>{if(!e||!t)return M.map(e=>({...e,available:!1}));const o=(({date:e,startTime:t,events:r,currentEventId:n})=>{const o=new Date(`${e}T${t}`),i=r.filter(t=>(!n||t.id!==n)&&(t.date===e&&new Date(`${t.date}T${t.startTime}`)>o)).sort((e,t)=>{const r=new Date(`${e.date}T${e.startTime}`),n=new Date(`${t.date}T${t.startTime}`);return r.getTime()-n.getTime()});if(0===i.length)return null;const a=i[0],s=new Date(`${a.date}T${a.startTime}`).getTime()-o.getTime();return Math.floor(s/6e4)})({date:e,startTime:t,events:r,currentEventId:n});if(null===o)return[...M.map(e=>({...e,available:!0})),{value:-1,label:"Customizado",available:!0}];const i=M.map(e=>({...e,available:e.value<=o}));return o>180&&i.push({value:-1,label:"Customizado",available:!0}),i},exports.calculateDuration=(e,t)=>{const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);if(isNaN(r)||isNaN(n)||isNaN(o)||isNaN(i))return 0;const a=new Date;a.setHours(r,n,0,0);const s=new Date;s.setHours(o,i,0,0),s<a&&s.setTime(s.getTime()+864e5);const l=s.getTime()-a.getTime(),c=Math.floor(l/6e4);return Math.max(c,1)},exports.calculateEndTime=(e,t)=>{const[r,n]=e.split(":").map(Number),o=new Date;o.setHours(r,n,0,0),o.setMinutes(o.getMinutes()+t);return`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`},exports.calculateEventHeight=A,exports.calculateEventOverlaps=W,exports.calculateEventPosition=P,exports.checkEventConflict=({eventId:e,date:t,startTime:r,endTime:n,existingEvents:o})=>o.find(o=>{const i=o.date.trim()===t.trim(),a=o.id!==e;return!(!i||!a)&&(({startTimeA:e,endTimeA:t,startTimeB:r,endTimeB:n})=>{const o=N(e),i=N(t),a=N(r),s=N(n);return!(isNaN(o)||isNaN(i)||isNaN(a)||isNaN(s))&&o<s&&a<i})({startTimeA:r,endTimeA:n,startTimeB:o.startTime,endTimeB:o.endTime})})??null,exports.createLocalDate=f,exports.createLocalDateFromString=g,exports.eventsOverlap=L,exports.formatDateRange=T,exports.formatDateToLocalString=h,exports.formatTime=v,exports.getDateRangeForView=E,exports.getDaysInMonth=D,exports.getDaysInWeek=x,exports.getEventLayout=V,exports.getEventOverlapLayout=Y,exports.getEventPosition=z,exports.getEventsForDate=B,exports.getEventsForDateAndTime=(e,t,r)=>r.filter(r=>{const n=g(r.date),o=parseInt(r.startTime.split(":")[0]);return h(n)===h(e)&&o===t}),exports.getEventsForHour=F,exports.getGridLines=(e=60)=>{const t=[];for(let r=0;r<24;r++){t.push({top:r*e,type:"hour",hour:r});for(let n=10;n<60;n+=10)t.push({top:r*e+n/60*e,type:"minute",hour:r,minute:n})}return t},exports.getHoursInDay=y,exports.isToday=b,exports.useCalendar=S,exports.useCalendarNavigation=C,exports.useCalendarRecordContext=()=>{const t=e.useContext(ae);if(void 0===t)throw new Error("useCalendarRecordContext must be used within a CalendarRecordProvider");return t},exports.useCalendarUtils=(t={})=>{const{allowPastEvents:r=!1}=t;return e.useMemo(()=>({validateEventDatesAndTimes:e=>{const{date:t,startTime:n,endTime:o,duration:i}=e;if(!(t&&n&&o&&i))return{isValid:!1,errorMessage:"Todos os campos de data e hora são obrigatórios"};const a=new Date(t);if(isNaN(a.getTime()))return{isValid:!1,errorMessage:"Data inválida"};const s=/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/;if(!s.test(n)||!s.test(o))return{isValid:!1,errorMessage:"Horários inválidos"};const[l,c]=n.split(":").map(Number),[u,d]=o.split(":").map(Number),p=60*l+c,m=60*u+d;if(m<=p)return{isValid:!1,errorMessage:"O horário de fim deve ser posterior ao de início"};const f=m-p;if(Math.abs(f-i)>1)return{isValid:!1,errorMessage:"A duração não confere com os horários informados"};if(!r){const e=new Date;if(new Date(`${t}T${n}:00`)<e)return{isValid:!1,errorMessage:"Não é possível agendar eventos no passado"}}return{isValid:!0}},checkForTimeConflictsWithExistingEvents:e=>{const{eventId:t,date:r,startTime:n,endTime:o,existingEvents:i}=e,[a,s]=n.split(":").map(Number),[l,c]=o.split(":").map(Number),u=60*a+s,d=60*l+c;for(const p of i){if(t&&p.id===t)continue;if(p.date!==r)continue;const[e,n]=p.startTime.split(":").map(Number),[o,i]=p.endTime.split(":").map(Number);if(u<60*o+i&&d>60*e+n)return{hasConflict:!0,conflictingEvent:p}}return{hasConflict:!1}},calculateDurationBetweenTwoTimes:(e,t)=>{const[r,n]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);return 60*o+i-(60*r+n)},calculateEndTimeFromStartTimeAndDuration:(e,t)=>{const[r,n]=e.split(":").map(Number),o=60*r+n+t,i=o%60;return`${Math.floor(o/60).toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`},formatDateForDisplay:e=>("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR"),formatTimeForDisplay:e=>e,createISOStringFromDateAndTime:(e,t)=>{const[r,n,o]=e.split("-").map(Number),[i,a]=t.split(":").map(Number);return new Date(r,n-1,o,i,a).toISOString()}}),[r])},exports.useEventHandlers=k,exports.useTimeSelection=te,exports.validateDateFormat=_,exports.validateDateRange=$,exports.validateDuration=R,exports.validateEventDates=({date:e,startTime:t,endTime:r,duration:n,allowPastEvents:o=!1})=>{const i=_(e);if(!i.isValid)return i;const a=O(t);if(!a.isValid)return a;const s=O(r);if(!s.isValid)return s;const l=I(t,r);if(!l.isValid)return l;const c=R(n);if(!c.isValid)return c;const u=$(e);if(!u.isValid)return u;if(!o){const r=H(e,t);if(!r.isValid)return r}return{isValid:!0}},exports.validateNotInPast=H,exports.validateTimeFormat=O,exports.validateTimeOrder=I;
|
|
11
11
|
//# sourceMappingURL=index.cjs.js.map
|