{"version":3,"sources":["webpack:///./app/javascript/calendar/undo.js"],"names":["window","calendarUpdateEvent","newEvent","oldEvent","a","options","extendedProps","demoMode","eventId","mockSession","modeId","scheduleeId","schedulerId","typeId","timeZone","isCustomTitle","recurring","afterCommit","newAttrs","setProp","attrs","title","demo_mode","mock_session","all_day_event","allDay","start_time","start","toISOString","end_time","end","split_time","duration","dayjs","diff","scheduler_id","schedulee_id","time_zone","update_type","mode_id","type_id","format","start_time_date","end_time_date","subtract","Number","parseInt","metaValue","add","axios","patch","event","data","remove","calendar","refetchEvents"],"mappings":"q0CAKAA,OAAOC,oBAAP,e,EAAA,G,EAAA,UAA6B,WAAOC,EAAUC,GAAjB,iEAAAC,EAAA,6DAA2BC,EAA3B,+BAAqC,GAArC,EAYvBH,EAASI,cAVXC,EAFyB,EAEzBA,SACAC,EAHyB,EAGzBA,QACAC,EAJyB,EAIzBA,YACAC,EALyB,EAKzBA,OACAC,EANyB,EAMzBA,YACAC,EAPyB,EAOzBA,YACAC,EARyB,EAQzBA,OACAC,EATyB,EASzBA,SACAC,EAVyB,EAUzBA,cACAC,EAXyB,EAWzBA,UAEMC,EAA6BZ,EAA7BY,YAAgBC,EAbG,EAaUb,EAbV,YAiBzBH,EAASiB,QAAQ,YAAY,GACvBC,EAlBmB,GAmBvBC,MAAON,EAAgBZ,EAASkB,MAAQ,KACxCC,UAAWf,EACXgB,aAAcd,EACde,cAAetB,EAASuB,OACxBC,WAAYxB,EAASyB,MAAMC,cAC3BC,SAAQ,UAAE3B,EAAS4B,WAAX,aAAE,EAAcF,cACxBG,WAAY5B,EAASwB,MAAMC,cAC3BI,SAAU9B,EAAS4B,IAAMG,YAAM/B,EAAS4B,KAAKI,KAAKD,YAAM/B,EAASyB,OAAQ,WAAa,KACtFQ,aAAcvB,EACdwB,aAAczB,EACd0B,UAAWvB,EACXwB,YAAatB,EAAY,IAAM,IAC/BuB,QAAS7B,EACT8B,QAAS3B,GACNK,GAIDhB,EAASuB,SACLE,EAAQM,YAAM/B,EAASyB,OAAOc,OAAO,cAC3CrB,EAAMsB,gBAAkBf,EAExBP,EAAMuB,cAAgBzC,EAAS4B,IAAMG,YAAM/B,EAAS4B,KAAKc,SAAS,EAAG,OAAOH,OAAO,cAAgBd,GAIhGzB,EAASuB,QAAWvB,EAAS4B,MAC1BE,EAAWa,OAAOC,SAASC,YAAU,0BAA2B,KAAO,EAC7E3B,EAAMS,SAAWI,YAAM/B,EAASyB,OAAOqB,IAAIhB,EAAU,WAAWJ,cAChER,EAAMY,SAAWA,GAhDM,UAmDFiB,IAAMC,MAAN,kBAAuB1C,GAAW,CAAE2C,MAAO/B,IAnDzC,iBAmDjBgC,EAnDiB,EAmDjBA,KAGRlD,EAASmD,SACE,OAAXpC,QAAW,IAAXA,KAAcmC,GAvDW,kDAyDzBpD,OAAOsD,SAASC,gBAzDS,yD,+KAA7B","file":"js/75-a7e888398d97353ccd6e.chunk.js","sourcesContent":["import axios from 'axios';\nimport { metaValue } from 'helpers/dom-helper';\nimport dayjs from 'lib/dayjs';\n\n// Update a specific event with the server\nwindow.calendarUpdateEvent = async (newEvent, oldEvent, options = {}) => {\n const {\n demoMode,\n eventId,\n mockSession,\n modeId,\n scheduleeId,\n schedulerId,\n typeId,\n timeZone,\n isCustomTitle,\n recurring,\n } = newEvent.extendedProps;\n const { afterCommit, ...newAttrs } = options;\n\n try {\n // Set the event to not be editable while we are updating it.\n newEvent.setProp('editable', false);\n const attrs = {\n title: isCustomTitle ? oldEvent.title : null, // Titles may be custom or a default value that gets set by the event mode and type.\n demo_mode: demoMode,\n mock_session: mockSession,\n all_day_event: newEvent.allDay,\n start_time: newEvent.start.toISOString(),\n end_time: newEvent.end?.toISOString(), // Nullable if dragged to all day section.\n split_time: oldEvent.start.toISOString(),\n duration: newEvent.end ? dayjs(newEvent.end).diff(dayjs(newEvent.start), 'minutes') : null,\n scheduler_id: schedulerId,\n schedulee_id: scheduleeId,\n time_zone: timeZone,\n update_type: recurring ? '1' : '3', // Only update the current instance.\n mode_id: modeId,\n type_id: typeId,\n ...newAttrs,\n };\n\n // If the event is dragged to the all-day section or if an all-day event is resized.\n if (newEvent.allDay) {\n const start = dayjs(newEvent.start).format('YYYY-MM-DD');\n attrs.start_time_date = start;\n // Fullcalendar bug: end date is exclusive, so we need to subtract a day.\n attrs.end_time_date = newEvent.end ? dayjs(newEvent.end).subtract(1, 'day').format('YYYY-MM-DD') : start;\n }\n\n // If the event is dragged from the all-day section to the grid.\n if (!newEvent.allDay && !newEvent.end) {\n const duration = Number.parseInt(metaValue('default-event-duration'), 10) || 0;\n attrs.end_time = dayjs(newEvent.start).add(duration, 'minutes').toISOString();\n attrs.duration = duration;\n }\n\n const { data } = await axios.patch(`/events/${eventId}`, { event: attrs });\n // Replace the old event with the new event. If this gets janky, refetch all events after this using\n // `window.calendar.refetchEvents()`\n newEvent.remove();\n afterCommit?.(data);\n } catch {\n window.calendar.refetchEvents();\n }\n};\n"],"sourceRoot":""}