1import{jsxRuntimeExports as e,reactExports as r,requireReact as Lb,reactDomExports as Ab}from"./react-core-chunk-B2r03cU8.js";import{toI18n as p,startOfWeek as so,addDays as kt,formatDate as Oe,getTimeDifference as cr,subtractDays as pn,STANDARD_DATE_FORMAT as Je,trackUxEvent as Rt,hooks as lt,displayTimeRange as Ut,capitalize as fu,moment as Ie,dayOfWeekFromDate as dr,datesInRange as rl,endOfWeek as ol,today as ms,addWeeks as Ob,endOfWeekDate as _c,startOfWeekDate as fc,endOfMonthDate as Nb,startOfMonthDate as Mb,updateLocale as Pb,df as es,dateFromTime as Co,trackGrowthEvent as $b,momentDate as ur,duration as Bb,tomorrow as Ub,datePickerFormat as Qr,normalizeTimeString as bc,isDateInPast as Hb,workWeekContaining as bu,getTimeDifferenceInHours as Fb,STANDARD_DATE_FORMAT_WITH_TIME_TO_MIN as Wb,compareDateTime as gu,isDateRangesOverlapping as Vb,prettyDayAtTime as Kb,shortDayCommaMonthDateNoYear as xu,displayFullTimeRange as qb,displayTime as zb,shortDayCommaMonthDate as Gb,clockFromTime as no,displayWeekday as Bt,displayMonthAndDay as al,formatDateToMsgTime as gc,shortDayNameMonthDayFromDate as Yb,isToday as Cu,displayShortWeekday as Jb,dayOfMonthFromDate as ll,monthFromDate as xc,add as Ta,momentWithCustomLocale as Cc}from"./tracking-chunk-Cdw_Cfie.js";import{baseAssignValue as Xb,getConfig as Qb,EVENT_ACTIONS as w,TRACK_ACTION_TYPES as k,PRODUCT_AREAS as ae,EVENT_CATEGORIES as U,getEmbeddedAvatarImage as kl,TRACK_PROPERTIES as Rn,postJSON as Eo,getIsEmbedded as Sn,queryString as Rl,PG_TRACK_EVENTS as Zb,putJSON as eg,fetchJSON as tg,resolveApiUrl as sg,NonJsonResponseError as ng}from"./app-bundle-B0YfsjKz.js";import{createAggregator as rg,MobileAndTablet as Eu,Drawer as Ll,Box_default as i,Button_default as V,IconButton_default as be,cxHelpers as O,useTrackUx as K,formatShortDateRange as og,RadioButton_default as Ec,partial as lr,Text_default as j,useGoToManagePlanPage as So,Link_default as Nt,useParams as ze,getCurrentLocationTierName as hs,getCurrentUserIsManagerial as He,getPredictiveSchedulingEnabled as ag,getCurrentLocationPublishedCount as lg,RANGE_TYPES as J,SB_ASSISTANT_TRIAL_END_DATE as Su,TIER_NAMES as _n,CardSelectable_default as Al,Checkbox_default as ro,Icon_default as Q,withUxPartition as ut,getCurrentLocationIsCloverEmbedded as ig,selectCurrentDateRange as it,getLocationStartOfWeek as rs,fetchSchedule as il,copySchedule as ju,showPredictiveGenerationModal as jo,BUTTON_TEXT$1 as yu,showNotification as oo,formatLongDateRange as Sc,withUxRoot as Ge,hideDrawer as Ln,TextInput as An,TEMPLATE_DETAILS_PATH as $s,selectTemplatesIsLoading as vu,getTemplateDetails as cg,selectFormattedTemplates as dg,deleteTemplate as ug,updateTemplate as hg,applyTemplate as mg,createTemplate as pg,Box_default$1 as as,TextInput_default as yo,Snackbar as _g,selectScheduleRoster as vo,getImageToScheduleSuccessSummaryDismissed as fg,getImageToSchedulePartialSummaryDismissed as bg,createOneTimeEvent as jr,List_default as Ol,selectSliceAttribute as Es,selectIsJumpstartClosed as Nl,useIsEmbedded as Io,selectAllTemplates as gg,insideEssentialsTrial as Iu,selectIsScheduleInsightsModalDismissed as Tu,closeJumpstartDrawer as Ml,openSchedulingInsightsModal as xg,selectEmployees as To,ACTION_ITEM_TYPES as le,EMPTY_RESOLUTION_TYPES as On,Dialog_default as Mt,selectTimelineActionItemGroups as yr,getCurrentUserFirstName as wu,getCurrentUserLastName as Du,setDialogOpen as Tt,setAvailabilityStatus as ws,updateAvailabilityState as Ws,AVAILABILITY_STATUS as It,resolveActionItems as Ot,RESOLUTION_TYPES as fe,Formik as Ht,TextField as hr,useLocalStorage as At,LS_AGENT_CANVAS_OPTED_IN as Gs,LS_AGENT_CANVAS_OPTED_OUT as Nn,setCanvasOptedIn as Mn,selectDraftCanvasShifts as Pl,transitionShift as $l,setOptOutDialogOpen as Ys,selectOptOutDialogOpen as Cg,selectCurrentSessionUnpublishedCanvasShifts as Eg,selectStartDate as _t,selectCanvasIsPublished as Pn,selectCanvasUnpublishedShiftsCount as Bl,deleteDraftShift as wo,deleteCanvasShift as mr,clearCanvas as Ul,CLEAR_CANVAS_SCOPES as Hl,selectAllCanvasShifts as ku,buildReplacementCandidates as Sg,selectActionItem as Ru,selectPendingActionItemStatus as jg,selectPendingActionItemIds as yg,updateActionItemStatus as Vs,ACTION_ITEM_STATUS as vt,setPendingActionItemStatus as jn,setPendingActionItemIds as yn,setPendingActionItemJobId as pr,setActionItem as _r,formatHours as fn,useSpring as Do,animated as bn,CircularInfinite_default as $n,selectBootstrapStatus as Fl,selectCanvasShiftsError as vg,selectRolesError as Ig,selectEmployeesError as Tg,selectDepartmentsError as wg,selectSchedulesError as Dg,selectAssigningShiftsStatus as Bn,selectPublishingStatus as ko,selectScheduleGeneratedEvent as Ro,selectScheduleBootstrappedEvent as Lo,selectSchedulePublishedEvent as Wl,getCurrentLocationId as ct,BUILDER_LOAD_FAILED_BANNER_VERSION as wa,initializeCanvasSchedule as Ao,fetchCanvasOverview as Lu,fetchCanvasShifts as Oo,fetchRoles$1 as Vl,fetchEmployees$1 as Kl,fetchDepartments$1 as Au,Alert_default as dt,selectAssignmentC
1onflictErrorToastVisible as kg,dismissCanvasErrorToast as No,selectClearScheduleErrorToastVisible as Rg,selectScheduleLabor as ql,selectPrePublishNotificationGroup as Ou,setPrePublishReviewOpen as Mo,publishSchedulingAgentCanvas as jc,fetchScheduleLaborTotals as Po,fetchEmployeeWages as zl,fetchScheduleEvents as Nu,fetchTimeline as Gl,selectPublishScheduleErrorToastVisible as Lg,selectShiftSaveErrorToastVisible as Ag,groupBy as vr,selectCanvasShiftById as $o,selectColorMappingVersion as ks,selectRoleById as Mu,selectShiftFlagsByShiftId as Og,selectEmployeeFullName as Ng,getDefaultShiftColor as Bo,Tooltip_default as Ae,colorOnShift as ao,stopCopyPaste as Pu,cxFunction as Mg,ActionButtons_default as fr,COLORMAP_CLASSNAMES as lo,COLOR_PICKER_OPTIONS_V1 as Yl,COLOR_PICKER_MAPPING_V1 as Pg,COLOR_PICKER_OPTIONS_V2 as Jl,COLOR_PICKER_MAPPING_V2 as $g,useField as $u,OPEN_SHIFT_OPTION as Js,Box as Zr,colors as Xl,defaultWageLabel as Bu,NumberFormat as Bg,TEAM_ROLE_TYPE as Ss,INBUILT_ROLE_TYPE as vn,EMPLOYEE_ROLE_TYPE as Uo,selectRoles as Ho,getCanManageRoles as Uu,getRoleColor as Fo,TEAM_ROLE_LABEL as Hu,getInbuiltRoleOptions as Ug,CREATE_ROLE_LABEL as br,useFormikContext as Wo,useAppDispatch as Hg,getShiftNoteQuotaId as Vo,getCanManageShiftNotes as Fu,selectIsShiftNoteAllowed as Ko,selectTierPlus as Wu,selectShiftNotesQuotaAttribute as io,changeToPlusTier as Vu,BILLING_CYCLES as Ql,capitalizeFirstLetter as Ir,UNSELECTED_RADIO_STATE as In,Form as Qs,Field as Ct,getInitials as Zl,Avatar_default as Un,DeprecatedTabs as Fg,selectEmployeeByJobId as Wg,compact as Vg,getDefaultRoleSelection as Kg,createRole as yc,calculateShiftStartEnd as cl,createCanvasShift as vc,createDraftShift as Da,updateDraftShift as dl,updateCanvasShift as ul,startCopyPaste as Ku,Divider_default as gn,toCurrency as pt,selectScheduleLaborStatus as qu,WAGE_TOTALS_BAR_HEIGHT as ka,Grid as Hn,GRID_COLUMNS as Tr,Skeleton_default as cs,NavIcon_default as zu,FDBDatePickerField as Tn,CheckboxField as qg,selectScheduleEvents as Gu,createScheduleEvent as zg,updateScheduleEvent as Gg,deleteScheduleEvent as Yg,selectRangeType as Yu,Select_default as Qt,I18N_SHOW_HIDE_FILTER_PATH as Yt,I18N_SB_HEADER_PATH as js,selectPreviouslyBootstrapped as Ju,selectPrePublishReviewOpen as Xu,selectTimelineStatus as qo,featureFeedback as Jg,showReadonlyModal as zo,sanitizeUserInput as Xg,FEATURE_NAME as Qg,Modal as Fn,useIsXXLargeScreen as Qu,toggleSidebarCollapsed as Zu,navigateToScheduleAction as Go,getScheduleRangeLabel as Zs,PageWithSubcomponents as wn,Pill_default as wr,getCanManageSchedule as Dr,getFeaturePermission as Yo,scheduleFetchIsPending as eh,selectAgentSortByWeek as th,selectAgentViewType as sh,VIEW_BY as mt,SORT_BY_WEEK_OPTIONS as Lt,getObjectFromLocalStorage as ts,VIEW_BY_DAY as gr,setSortByWeek as Zg,setObjectInLocalStorage as at,LS_AGENT_SORT_BY_WEEK as ex,setSortByDay as tx,LS_AGENT_SORT_BY_DAY as sx,VIEW_TYPES as de,showPaywallsModal as ei,setViewType as hl,LS_AGENT_VIEW_TYPE as Ic,selectCopiedShiftId as nh,pasteCopiedCanvasShift as nx,useDragType as Jo,useDroppable as kr,CA
1NVAS_DND_TYPES as Zt,useDraggable as rh,selectCanvasShiftsStatus as ti,ContextMenu as si,ISO_DATE_START_INDEX as oh,ISO_DATE_END_INDEX as ah,ROW_GROUP_EVENTS as xn,ROW_GROUP_OPEN_SHIFTS as Pt,ROW_GROUP_TEAM_MEMBERS as ss,SKELETON_MOCK_ROLES as co,sumShiftHours as Xo,sortByAttribute as Tc,selectAutoAssignEnabled as Rs,selectOpenUnpublishedCanvasShiftsForAssignment as rx,predictSchedulingAgentCanvas as ox,setAssigningShiftsStatus as ml,fetchShiftFlags as lh,selectPendingScheduleLaborJobIds as ax,ISO_TIME_START_INDEX as wc,reassignCanvasShift as Dc,useDndMonitor as ih,selectJobLaborSummary as lx,TIME_OFF_HEIGHT as kc,selectTimeOffs$1 as ch,selectScheduleEventsStatus as ix,CALENDAR_DAYS as Rc,selectInitialLoadComplete as ni,selectBuildingDraftVisible as ri,selectTimelineError as cx,PANEL_LOAD_FAILED_BANNER_VERSION as Lc,selectAssignableCanvasShifts as dh,setFillShiftsCardDismissed as dx,setAutoAssignEnabled as oi,LS_AGENT_AUTO_ASSIGN_ENABLED as ai,selectCanvasShiftsByDateRange as uh,useTrackUxOnMount as ps,selectAvailabilityEntry as hh,fetchTimeOffs$2 as xr,COMPACT_LIST_THRESHOLD as Rr,DECISION_CARD_FADE_IN_DELAY_MS as mh,getLatestResolutionType as Us,selectSchedulePublishedSummary as ux,selectNotifiedEmployeesCount as hx,selectPrePublishReviewSummary as mx,selectEmployeesMissingContactInfoCount as px,setPrePublishNotificationGroup as _x,RadioButtonGroup as li,RadioButtonField as ii,AlertText_default as pl,mapNoCoverageRequests as fx,selectActionItemStatus as ci,selectNarrations as di,ToggleSwitch_default as ph,selectSidebarCollapsed as bx,selectSchedulesStatus as gx,selectCanvasHasDraftShifts as xx,selectCanvasIsEmpty as Cx,selectPendingAutoBootstrap as Ex,setPendingAutoBootstrap as _h,selectFillShiftsCardDismissed as Sx,selectAutoAssignedByBootstrap as jx,setBuildingDraftVisible as yx,useTransition as vx,useHistory as Qo,selectLeftNavCollapsed as Ix,setCollapsed as Ac,selectDepartments as Tx,selectDialogOpen as wx,selectIsCopyPasteModeEnabled as Dx,selectAvailabilityStatus as kx,selectRolesStatus as Rx,selectEmployeesStatus as Lx,setStartDate as Ax,resetForDateChange as Ox,selectDepartmentsStatus as Nx,useVirtualizer as fh,TEAM_MEMBER_DIALOGS as Mx,DragOverlay as bh,NAV_DEBOUNCE_MS as Px,estimateRowHeight as $x,defaultDropAnimationSideEffects as Bx,getExperimentVersion as gh,getProductGrowthImageToScheduleWebEnrolled as xh,getSchedulingInsightsExperimentEnabled as Ux,useExtendUx as en,selectPredictionBaseStartDate as Ch,selectPredictionBaseEndDate as Eh,selectNarrativeMessages as Hx,hideDialog as Fx,SLICE_NAME$9 as Wx,setSchedulePredictionGeneration as Ra,setPredictedShiftsCount as Oc,setPredictionBaseEndDate as _l,setPredictionBaseStartDate as fl,setPredictionManualBaseStartDate as Vx,setPredictionManualBaseEndDate as Kx,predictScheduleBuilderScheduleRoute as qx,pollWorkerStatus as zx,PREDICTION_TIMEOUT as Gx,captureException as eo,PREDICTIVE_REQUEST_SLEEP_TIMEOUT as Nc,setPredictionError as un,navigateToSchedule as Yx,setNarrativeMessages as Jx,BASE_END_DELTA_DAYS as Xx,showPredictiveGenerationFeedbackDialog as Qx,reloadSchedule as ui,selectManualBaseStartDate as Zx,hideModal$1 as Mc,Toast as Sh,selectIsScheduleUsersOnly as hi,selectViewType as jh,selectCurrentDateRangeEnd as Lr,selectCurrentDateRangeStart as Wn,selectDepartmentId as Zo,selectDrawerUxContext as yh,selectPrintScheduleDrawerShown as eC,actions$16 as ie,getCurrentUserId as tC,selectSchedulingInsightsModalIsOpen as sC,selectSchedulingInsightsEvents as nC,selectSendToPartnerSyncErrors as Vn,ConfirmationSuccess as vh,ErrorGeneric as rC,selectPartnerSyncState as mi,selectSyncShiftStatuses as pi,selectUnpublishedShiftsCount as ea,syncShifts as Ih,selectSendToPartnerDrawerShown as oC,fetchTemplates as aC,selectAllShifts as ta,containsShiftsInCurrentLocation as Th,selectJobIdsForCurrentLocation as wh,selectDepartmentAttribute as _i,DEPARTMENT_NOT_SET$1 as Dh,selectSortedRolesByDepartmentId as bl,selectShiftIdsByRoleAndDate as kh,selectDepartmentHoursByDate as fi,selectTotalHoursForAllDepartments as Rh,selectDepartmentWagesByDate as bi,selectTotalWagesForAllDepartments as gi,getCanViewWages as Ls,getCanViewLabor as Lh,selectAllDepartments as lC,setPublishChildLaborCheck as iC,EMPTY_PUBLISH_CHILD_LABOR_CHECK as cC,checkChildLaborViolationsForPublish as dC,colors_default as xi,ChildLaborWarnings as Ah,selectPublishDrawerShown as Oh,selectShiftsInCurrentDateRangeForCurrentLocation as uC,selectHasConflicts as Nh,selectChildLaborComplianceSettingsEnabled as _s,SelectInput as Mh,createMonet
1izationCtaEvent as hC,Tablet as mC,selectPublishLoading as pC,selectHasPublishedShifts as _C,selectHasUnpublishedShifts as fC,selectJobsWhereAttribute as bC,repeatSchedule as gC,publishSchedule as xC,selectPublishChildLaborCheck as CC,publishChildLaborViolationUxFields as La,createCachedSelector as Te,selectPropertiesAttribute as Le,selectAll as Ci,selectAll$1 as EC,selectDatesInCurrentRange as Ft,shiftSortCompare as Ei,selectJobRelationshipId as wt,selectUserFullName as Pc,selectAllScheduleAvailabilities as SC,selectJobsForCurrentLocation as Ph,selectJobIdArchivedAtMap as $h,selectScheduleAvailabilitiesWhereAttribute as Bh,selectScheduleAvailabilityRelationshipId as Si,selectAllTimeOffs as sa,selectJobById as Uh,selectIsTimeOffsVisible as na,selectJobAttribute as uo,selectTimeOffAttribute as Xt,selectTimeOffRelationshipId as Hh,isNil as ds,range as jC,selectOpenTime as ra,getEarliestStartTime as yC,selectClosingTime as Fh,getLatestEndTime as vC,isOvernight as ji,formatCollection as Ar,fullDayPeriod as Ks,selectBlackoutOnDate as yi,selectIsAvailabilitiesVisible as oa,selectAllShiftsOnDate as IC,adjustOvernightClosingTime as TC,getOvernightShiftHour as wC,getUrlParamValue as DC,kebabCase as $c,selectJobIdsForUserScheduled as kC,selectShouldShowConsecutiveDayWarning as RC,selectRoleLaborTotalsFetchIsPending as aa,selectHasOvertimeForWeekByUserId as LC,selectHasOvertimeForWeekByJobId as AC,selectFullNameByJobId as Or,selectUserAgeInfoByJobId as OC,selectUserAttribute as Cr,getCloverBaseUrl as vi,browserHistory as Wh,employeeFirstCellProps as NC,LinearProgress_default as Ii,DND_ITEM_TYPES as Xs,immutableExports as MC,daysOfWeek as Vh,COMMON_SHIFT_LEVELS as Aa,COMMON_SHIFT_DOW as PC,CURRENT_TAB as $C,NOTES_TAB as BC,APPROVALS_TAB as UC,ADD_SHIFT_TAB as HC,TIME_OFF_TAB as FC,ObjectSchema as Cn,StringSchema as Kt,ArraySchema as WC,cloneDeep as VC,zIndex_default as ho,ref as Bc,DateSchema as ir,BooleanSchema as KC,selectReassignmentRecommendations as Kh,useExtendUxPartition as qC,selectReassignmentStatus as zC,clearRecommendations as Uc,fetchReassignmentRecommendations as Hc,Link as la,selectTeamRoles as GC,selectEmployeeRoleWages as YC,selectUserNameWithLastInitial as ia,getInbuiltOptions as JC,userRolesLabel as XC,SHIFT_INDICATOR_STATUSES as Bs,getCurrentLocationActiveTrialEndDate as QC,getHasActiveTrialPeriod as ZC,ImmutablePropTypes as eE,selectRoleEmployeeOptions as tE,selectEmployeeOptions as sE,selectUserFirstNameByJobId as nE,selectCommonShifts as qh,COMMON_SHIFT_VERSION as zh,selectCommonShiftsStatus as rE,getSmartCoverRequestsExperiment as Gh,selectShiftAttribute as Se,selectChildLaborPolicyForUser as oE,selectWeeklyDataForJob as aE,countJobShiftsOnDate as lE,selectWorkedDayIndicesForJobInWeek as iE,calculateProspectiveWeeklyData as cE,timeFromDatetime as Fc,useTrackUxHandler as Yh,resolvePolicy as dE,checkChildLaborViolations as uE,AVAILABILITY_BLOCK_I18N as Wc,clearCommonShifts as Jh,fetchCommonShifts as hE,createTimeOff as mE,TAB as ys,selectAvailableForCoverage as pE,selectAvailableForCoverageLoading as _E,selectShiftRelationshipEntity as fE,selectShiftById as Xh,selectUserNameByShiftId as Ti,selectCurrentDateRange$1 as bE,selectLocationAttribute as Dn,fetchAvailableForCoverage as gE,fetchTrades as xE,selectClaimRequestRelationshipId as Vc,upsertOne as CE,CONFLICT_TYPES as EE,setMany as SE,actions$17 as jE,removeClaimRequest as yE,processClaimRequestApprovalResponse as vE,conflictCheck as IE,showConflictModal as TE,hideModal as Oa,captureHydrationException as wE,selectAllClaimRequests as DE,hasShiftConflict as kE,selectUserIdFromJobId as RE,selectClaimRequestTotalsAttribute as Na,selectClaimRequestTotalsFetchIsPending as LE,selectUserAvatarUrlByJobId as AE,trackLinkClickEvents as OE,LINK_TEXT as NE,flashNotice as Qh,selectAllProducts as ME,selectShouldShowApprovalsPaywall as PE,changeToEssentialsTier as $E,planPricing as BE,Icon as Zh,TIER_NAMES$1 as UE,selectShiftsFetchIsPending as wi,selectShiftEventData as HE,Loader as Di,selectShiftRelationshipEntity$1 as vs,selectShiftNoteById as ca,getLocationCanAccessShiftReassignment as FE,selectSyncShiftError as em,fetchClaimRequestTotals as WE,fetchShift as VE,deleteShift as tm,isEqual as sm,SB_ASSISTANT_TRIAL_TIERS as KE,getCurrentLocationStateName as qE,selectShiftChildLaborViolationData as nm,selectShiftTimeRange as zE,selectShiftRoleOption as GE,selectNumLimitedNotesLeftInQuota as YE,selectShiftNoteTextByShiftId as JE,selectDefaultRoleOption as XE,updateShifts as ki,useUxContext as Kn,selectChildLaborComplianceSchoolSession as rm,calculateAge as QE,ADD_SHIFT_TYPE as Kc,NumberField as ZE,NumberSchema as eS,deleteTimeOffBlackout as tS,updateTimeOffBlackout as sS,createTimeOffBlackout as nS,selectTimeOffBlackoutEmployeesCount as rS,selectTimeOffBlackoutEndDate as oS,selectTimeOffBlackoutStartDate as aS,selectEventAttribute as Is,deleteEvent as lS,updateEvent as iS,createEvent as cS,showConfirmModal as dS,ModalCloseIcon as om,changeLocation as uS,I18N_SB_SHIFTS_PATH as gl,SHIFT_INDICATOR_STATUS_PRIORITY as Ma,selectScheduleAvailabilityAttribute as Hs,getAccountIsHub as am,claimShift as hS,LoadingIndicator as da,selectFindCoverShiftId as lm,selectCopyPasteShift as tn,getUserOneTimeEventDone as im,SB_ONE_TIME_EVENTS as cm,selectUserIdByS
1hiftId as mS,selectHideWithNoConflicts as pS,selectShiftLaborTotalsAttribute as _S,selectShiftConflictType as fS,SHIFT_INDICATOR_TRANSLATION_MAP as bS,declineTimeOff$1 as gS,approveTimeOff$1 as xS,deleteTimeOff$2 as CS,fetchTimeOffPayrollImpact as ES,POPUP_I18N_PATH as qs,formatTimeOffHours as qc,CATEGORIES_I18N_PATH as SS,REASONS_I18N_PATH as jS,selectTimeOffUpdateIsPending as yS,fetchTimeOff as vS,selectDayWagesForJob as IS,selectDailyOvertime as TS,selectCompanyLaborHoursByJobId as dm,selectDayHoursForJob as wS,selectEnabledDailyOvertime as DS,HOURS_IN_DAY as kS,FIRST_CELL_MIN_WIDTH as Ri,DEFAULT_CELL_HEIGHT as ua,debounce as um,SEARCH_DEBOUNCE_TIME as RS,selectSortByWeek as LS,selectCustomJobIds as AS,updateSortByDay as OS,updateSortByWeek as NS,VIEW_BY_OPTIONS as MS,EMPLOYEE_HUB_VIEW_BY_OPTIONS as PS,selectSearchTerm as $S,HOURS as BS,getCurrentCompanyHasMultipleLocations as US,selectUserIdsInOtherLocations as HS,selectOtherJobLocationIds as FS,selectFilteredJobIds as Li,selectHourEmployees as WS,selectHoursWages as VS,selectHourHours as KS,selectSummaryEmployees as qS,selectSummarysWages as zS,selectSummaryHours as GS,selectSortByDay as YS,selectAllLocationIdsForUser as Ai,selectJobIdsSortedByStartTime as JS,Portal$1 as XS,selectShiftIdsForJobOnDate as QS,selectWeeklyOvertime as ZS,selectEnabledWeeklyOvertime as ej,selectHoursForWeekByJobId as tj,selectWagesForWeekByJobId as sj,FIRST_CELL_MIN_WIDTH$1 as sn,CSS as nj,selectAllEmployeeIds as Pa,sortJobPositions as rj,selectOptInDialogOpen as hm,LS_AGENT_OPT_IN_DIALOG_SEEN as xl,getScheduleBuilderAgentExperimentEnabled as Oi,selectScheduleStartDate as oj,selectScheduleEndDate as aj,selectAllShiftsInCurrentDateRangeForCurrentLocation as lj,setOptInDialogOpen as hn,setOptInTooltipSuppressedForSession as zc,fetchEstimatedSales as ij,fetchLaborTargets as cj,selectDepartmentPercentageByDate as dj,selectDepartmentIds as mm,FontAwesomeIcon as uj,selectLaborTargetAttribute as hj,selectActualLaborForDate as mj,updateLaborTarget as pm,selectSummarySales as _m,selectLaborTargetsByAttribute as fm,selectDateWages as bm,selectEstimatedSalesValueByDate as gm,selectSummaryLaborTargets as pj,selectLaborTargetsFetchIsPending as _j,selectEstimatedSalesFetchIsPending as xm,selectIsPastWeek as fj,selectEstimatedSalesManualByDate as bj,updateEstimatedSales as gj,selectNumEmployeesScheduledOnDate as xj,selectDateHours as Cj,selectWeatherForec
1astFetchIsPending as Cm,selectWeatherForecastForDate as Ej,getCanViewReports as Sj,fetchWeatherForecast as jj,updateScheduleProperties as Em,selectCanManageEmployees as Ni,selectCanCloseEnforcementDialog as Sm,selectShouldShowEnforcementDialog as jm,showEnforcementDialog as ym,setAddTeamPageContext as vm,showAddEmployeeModal as Im,useAddTeamPageEnabled as Tm,ADD_TEAM_MEMBER_PAGE_PATH as wm,selectHasBlackoutOnDateRange as yj,VIRTUALIZER_OVERSCAN as vj,useLocation as Dm,selectRoleById$1 as km,selectDayTotalWagesByRoleId as Ij,selectDayTotalHoursByRoleId as Tj,clearEntireSchedule as wj,revertSchedule as Dj,selectDepartmentsWhereAttribute as kj,selectSortedDepartmentIds as Rj,selectShiftIdsByDate as Lj,DAYS_OF_WEEK as $a,selectRoleIds as Aj,selectOptInTooltipDismissedRangeKey as Oj,selectOptInTooltipOpen as Nj,selectOptInTooltipSuppressedForSession as Mj,selectHasPublishedBeforeCurrentDate as Pj,setOptInTooltipOpen as ln,setOptInTooltipDismissedRangeKey as Ba,selectConflictsEnabled as $j,selectShiftsWithConflicts as Bj,Badge_default as Uj,Chip_default as Hj,selectPublishHistoryFetchIsLoading as Fj,selectAllPublishHistoryEvents as Wj,clearPublishHistoryEvents as Vj,fetchPublishHistoryEvents as Kj,selectTeamMemberOptions as qj,selectRoleOptionsWithDepartment as zj,selectDepartmentOptions as Gj,selectDepartmentNotSetId as Yj,selectCopyWeekModalIsOpen as Jj,COPY_WEEK_MODAL as bt,COPY_WEEK_DIRECTION as Xj,SelectField as Ua,INITIAL_VALUES_COPY_WEEK as Qj,NestedMenu_default as Rm,SimpleMenuItem_default as gt,selectIsChildLaborComplianceTooltipNextClicked as Zj,getChildLaborSchoolSessionEnabledForCurrentLocation as Lm,selectDepartmentIdsToClear as ey,selectScheduleHasShiftsInCurrentDateRangeAndLocation as ty,selectShouldAllowResendNotifications as sy,getCurrentUserIsGM as ny,toggleSchoolSession as ry,resendNotifications as oy,scheduleFetchIsSuccess as ay,selectHasPendingData as Am,setChildLaborComplianceTooltipNextClicked as ly,FILTERS as yt,FORECAST_FILTERS as iy,MONTH_FILTERS as cy,WEEK_FILTERS as dy,getCurrentCompanyLocations as uy,selectIsShiftsAtThisLocationOnly as hy,selectPropertiesIsLoaded as my,getCanManageJobs as py,EMPLOYEE_VIEW_FILTERS as Gc,showSendToPartnerDrawer as Yc,setDepartmentId as _y,getCurrentLocationPartner as fy,selectJobPositionIdsBySortWeek as by,setSortByDay$1 as gy,THIS_MONTH_LABEL as xy,NEXT_MONTH_LABEL as Cy,areDatesStartAndEndOfSameMonth as Ey,areDatesInSameWeek as Sy,NEXT_2_WEEKS_LABEL as jy,getThisWeek as yy,getNextWeek as vy,getNext2Weeks as Iy,getThisMonth as Ty,getNextMonth as wy,syncShiftStatusRoute as Dy,selectNotificationIsAI as ky,selectNotificationType as Ry,selectNotificationMessage as Ly,urlParamsToReduxProps as Om,REACT_SCHEDULE_BUILDER_VERSION as Ay,selectPendingJobLaborTotalsIds as Oy,selectMinorJobIds as Ny,fetchLocationsData as My,fetchChildLaborPoliciesForMinors as Py,fetchWeeklyDataPerMinor as $y,fetchSchedulingInsightsEvents as By,fetchRoleLaborTotals as Uy,fetchCompanyHours as Hy,setSchoolSession as Fy,selectPublishedCount as Wy,selectTemplatesDrawerOpen as Vy,selectCopyWeekDrawerShown as Ky,selectPredictionError as qy,selectSchedulePredictionGeneration as zy,selectIsPredictiveGenerationFeedbackDialogOpen as Gy,selectIsPredictiveSchedulingModalActive as Yy,selectSessionStatus as Jy,getCanManageTier as Xy,fetchSession as Qy,getSchedulingFtuxSeen as Zy,selectIsCanvasOptedIn as ev,LS_RANGE_START as tv,LS_RANGE_END as sv,LS_VIEW_TYPE as Nm,LS_RANGE_TYPE as nv,fetchScheduleProperties as rv,fetchScheduleRosterStatusCount as ov,pageUrl as Mm,updateQuery as av,Switch as lv,Route as Jc,ROUTES$4 as Hr,BASE_ROUTE as iv,Redirect as cv}from"./app-init-chunk-kk_CZVyp.js";import{useSelector as I,connect as F,useDispatch as X,PropTypes as d,createSelector as os,useStore as dv,createAsyncThunk as Nr,unwrapResult as uv,propTypesExports as hv,shallowEqual as mv}from"./redux-core-chunk-DgWMjMkF.js";import{linkTo as pv,FloatingPanelWrapper as _v,ONE_TIME_EVENTS as fv}from"./util-chunk-j37xjdVD.js";import{IMAGE_TO_SCHEDULE_STATUS as Xc,STATUS_SUCCEEDED as En,VERSIONS as Pm,STATUS_FAILED as bv}from"./constants-chunk-DZWnmBCB.js";import{FDBPayPeriodPicker as $m}from"./FDBPayPeriodPicker-chunk-DNtqqBQD.js";import{UpgradeWrapper as Fs}from"./UpgradeWrapper-chunk-CbcWUw7S.js";import{Text as Y,H4 as gv}from"./Text-chunk-DaUt9cvI.js";import{ClickAwayWrapper as nn}from"./ClickAwayWrapper-chunk-l_eQc18P.js";import{trackManageTemplatesDrawerUxEvents as xv,SHIFT_MODAL_FIELDS as Cs}from"./tracking-chunk-AuSskk9x.js";import{TimeOff as Cv}from"./TimeOff-chunk-BvRXdo_p.js";import{Card_default as mo}from"./Card-chunk-DKm6_3cq.js";import{isBasicTier as Bm,isEssentialsTier as Um}from"./locationTiers-chunk-DYwrQOdV.js";import{NavIcon as ns}from"./NavIcon-chunk-D2Ex4SW5.js";import{windowDocument as po}from"./windowDocument-chunk-BCGMfOuG.js";import{Popper as Ev}from"./Popper-chunk-C42cXHcS.js";import{Zoom as Qc}from"./Zoom-chunk-B123sES5.js";import{TimeRangePicker as ha,CATEGORIES as Hm,useDisplayTotalHours as Fm,createDurations as Sv,overrideDurations as
1jv,REASONS as Cl}from"./useDisplayTotalHours-chunk-Cs4chtkD.js";import{Popover as Wm}from"./Popover-chunk-DF156c8O.js";import{materialUiPopupStateExports as _o,PopupState as yv,requireCore as vv}from"./index-chunk-DxIU2S5T.js";import{FormikInput as ma}from"./FormikInput-chunk-D5VmmewH.js";import{requireInteropRequireDefault as Iv}from"./interopRequireDefault-chunk-FU168bks.js";import{require_typeof as Tv}from"./withStyles-chunk-CTOkN3nI.js";import{requireSlicedToArray as wv}from"./slicedToArray-chunk-CCe2njNC.js";import{GoToManagePlanPageLink as Mi,GoToManagePlanPageButton as Dv}from"./GoToManagePlanPageLink-chunk-1FRgVtsI.js";import{WeekDayPicker as Vm,daysOfWeek as Zc}from"./WeekDayPicker-chunk-B8Amm0pA.js";import{withCx as kv}from"./withCx-chunk-2ED4uz6s.js";import{useClickOutside as Rv}from"./useClickOutside-chunk-CptD_XW9.js";import{moment as ed}from"./moment-chunk-Ct8dlBEo.js";import{TimeOffAvailability as Lv}from"./TimeOffAvailability-chunk-CiGw9TXo.js";import{Tabs as Km}from"./Tabs-chunk-jHo727ke.js";import{ToggleSwitchField as Av}from"./ToggleSwitchField-chunk-BWQxZKco.js";import{Label as Jt}from"./Label-chunk-CZwkeQMm.js";import{NumberInput as td}from"./NumberInput-chunk-DPD_qMpC.js";import{ReassignmentSelectorCard as Ov}from"./helpers-chunk-B3OnalmE.js";import{Image as qm}from"./Image-chunk-Cn_Tax2_.js";import{PaidFeatureIcon as Nv}from"./PaidFeatureIcon-chunk-DQRimA5-.js";import{convertFrom12HourFormat as sd}from"./TimePicker-chunk-5rnNyw1v.js";import{SmartCoverRequestScheduleModal as Mv}from"./index-chunk-DwFF2HFf.js";import{useMeasure as Pv}from"./useMeasure-chunk-CbGDSKAf.js";import{CheckboxInput as $v}from"./CheckboxInput-chunk-BZdvfgKf.js";import{formatTimeOffDateRange as Bv}from"./formatTimeOffDateRange-chunk-Cmad4oEf.js";import{TimeOffDeleteDialog as Uv}from"./TimeOffDeleteDialog-chunk-DRpuXafJ.js";import{Avatar as Hv}from"./Avatar-chunk-mlyFRj6q.js";import{useSortable as Fv,arrayMove as Wv,SortableContext as Vv,verticalListSortingStrategy as Kv}from"./sortable.esm-chunk-BQe8mpgQ.js";import{EnforcementTooltip as qv}from"./EnforcementTooltip-chunk-DsJg0IMK.js";import{mainExports as zv}from"./main-chunk-DvN4KXj2.js";import{FDBRangePicker as Gv}from"./FDBRangePicker-chunk-DwngoN0y.js";import{CUSTOM_LABEL as Yv}from"./CommonPresetConstants-chunk-BNvXgbB8.js";try{(function(){var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="1f0f49db-196d-4d7a-9a67-470baea24a4a",t._sentryDebugIdIdentifier="sentry-dbid-1f0f49db-196d-4d7a-9a67-470baea24a4a")})()}catch{}var Jv=rg(function(t,s,n){Xb(t,n,s)});function Xv(){return Qb().env.name==="production"}function nd(t){Xv()&&window.DD_RUM.onReady(()=>{t()})}const Qv=()=>{window.scheduleBuilderDataDogShiftsRenderedFlag=null},Zv=()=>{window.scheduleBuilderDataDogInitLoadFlag=null,window.scheduleBuilderDataDogShiftsRenderedFlag=!0},eI=()=>{window.scheduleBuilderDataDogInitLoadFlag?window.scheduleBuilderDataDogShiftsRenderedFlag||(window.scheduleBuilderDataDogShiftsRenderedFlag=!0,nd(()=>{window.DD_RUM.addTiming("schedule_shifts_rendered",Date.now())})):(window.scheduleBuilderDataDogInitLoadFlag=!0,nd(()=>{window.DD_RUM.addTiming("schedule_route_change",Date.now())}))},{cx:tI}=O("DrawerContainer"),sI="schedule_builder.previous_weeks_on_jumpstart_drawer",pa=({open:t,onClose:s,onBack:n,children:o})=>e.jsx(Eu,{children:(a,l)=>e.jsxs(Ll,{className:tI(),open:!!t,width:a||l?"100%":"480px",children:[e.jsxs(i,{ph:32,pt:32,pb:0,flex:!0,justifyContentSpaceBetween:n,justifyContentEnd:!n,children:[n&&e.jsx(i,{gap:3,flex:!0,alignItemsCenter:!0,pointer:!0,onClick:n,justifyContentEnd:!0,children:e.jsx(V,{size:"small",onClick:n,startIcon:"ArrowLeft",variant:"tertiary",children:p(`${sI}.back`)})}),e.jsx(be,{icon:"Close",size:"small",onClick:s,label:p("schedule_builder.actions.close")})]}),e.jsx(i,{ph:32,h:"100%",alignCenter:!0,alignItemsCenter:!0,column:!0,children:o})]})}),{cx:nI,cxEl:rd}=O("DateSelectionView"),zm=({setDate:t,setCustomDate:s,startOfWeekDay:n,drawerDate:o,displayOptions:a=!0,displayArrows:l=!1,padding:c=!0,leftArrowDisabled:u,rightArrowDisabled:h,blockDatesAfter:m,blockDates
1Before:_,displayedMonths:f,defaultStartDate:g,defaultEndDate:b})=>{const x=K(),[E,S]=r.useState(""),[y,C]=r.useState(g||null),[v,T]=r.useState(b||null),D=r.useCallback(N=>{x(w.PRE_DETERMINED_INTERVAL_SELECTED,k.CLICK,{numWeeksAgo:N})},[x]),L=r.useCallback((N,H)=>{S(N),N&&N!=="other"?(t?.(N),s(""),D(H+1)):t?.("")},[s,t,D]),A=r.useMemo(()=>so(o),[o]),P=r.useMemo(()=>[1,2,3,4].map(N=>{const H=kt(A,-N*7),q=kt(H,6);return{label:og(H,q,Je),value:Oe(H,"parsable_reversed")}}),[A]),M=r.useCallback(N=>{C(N.startDate),T(N.endDate),s(N.startDate),x(w.OTHER_INTERVAL_SELECTED,k.CLICK,{numWeeksAgo:cr(N.startDate,o,"weeks")})},[o,s,x]),R=!!_&&new Date(pn(A,7))<new Date(_),$=!!m&&new Date(kt(v,7))>new Date(m),B=r.useCallback(()=>{const N=kt(A,-7),H=kt(N,6);C(N),T(H),s(N),x(w.BUTTON_CLICKED,k.CLICK,{direction:"left",buttonText:"previous_week",productArea:ae.SCHEDULE_BUILDER})},[A,C,T,s,x]),W=r.useCallback(()=>{const N=kt(A,7),H=kt(N,6);C(N),T(H),s(N),x(w.BUTTON_CLICKED,k.CLICK,{direction:"right",buttonText:"next_week",productArea:ae.SCHEDULE_BUILDER})},[A,C,T,s,x]);return e.jsxs(i,{ml:c?16:0,className:nI(),children:[a&&P.map((N,H)=>e.jsxs(i,{tag:"label",pt:16,ph:16,mb:12,pointer:!0,onClick:lr(L,N.value,H),hleft:!0,className:rd("option"),children:[e.jsx(Ec,{name:N.value,checked:E===N.value,onChange:lr(L,N.value,H)}),e.jsx(i,{vcenter:!0,children:e.jsx(j,{children:N.label})})]},N.value)),e.jsxs(i,{tag:"label",pt:c?16:0,mb:c?12:0,pointer:!0,column:!0,onClick:lr(L,"other"),className:rd("option"),children:[a&&e.jsxs(i,{vcenter:!0,row:!0,pr:8,ph:16,children:[e.jsx(Ec,{name:"other",checked:E==="other",onChange:lr(L,"other",0)}),e.jsx(j,{children:p("schedule_builder.previous_weeks_on_jumpstart_drawer.copy_week.other")})]}),e.jsxs(i,{flex:!0,row:!0,w:380,mt:c?16:0,children:[e.jsx($m,{name:"Week Picker",placeholder:p("schedule_builder.previous_weeks_on_jumpstart_drawer.copy_week.select_week"),payrollInfo:[n],payrollPeriod:"week",displayedMonths:f,twiceWeekPayrollInfo:null,startOfWorkWeek:n,startDate:y,endDate:v,onApplyRange:M,blockDatesAfter:m,blockDatesBefore:_}),l&&B&&W&&e.jsxs(i,{row:!0,children:[e.jsx(be,{dataTestId:"left-arrow",disabled:u||R,onClick:B,icon:"ChevronLeft",size:"small",label:p("schedule_builder.actions.previous_week")}),e.jsx(be,{dataTestId:"right-arrow",disabled:h||$,onClick:W,icon:"ChevronRight",size:"small",label:p("schedule_builder.actions.next_week")})]})]})]})]})},rI="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",oI="schedule_builder.schedule_assistants_cta",{cx:aI}=O("PredictSchedulePaywall"),lI=({onDismiss:t,recommendedSchedulingCTA:s})=>{const{handleOnClick:n}=So({planName:"plus",focusedFeature:"predictive_scheduling"});return e.jsx(i,{cx:aI(),bs:"solid",bcolor:"mono300",mt:32,shadow:"z1",bw:"1px",overflow:"hidden",className:"PredictSchedulePaywall",bradiusm:!0,children:e.jsxs(i,{dataTestId:"prediction-paywall",row:!0,flex:!0,h:127,children:[e.jsx(i,{flex:!0,w:181,bgcolor:"mono100",h:127,children:e.jsx("img",{src:new URL("https://cdn.joinhomebase.com/assets/shifts-bundle-E3sbqise.png",import.meta.url).href,alt:"shifts"})}),e.jsxs(i,{relative:!0,ph:12,pv:16,w:214,bg:"mono200",children:[e.jsx(i,{absolute:!0,top:4,right:4,children:e.jsx(be,{size:"small",onClick:t,icon:"Close",label:p("schedule_builder.actions.close")})}),e.jsxs(i,{column:!0,children:[e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${rI}.title`)}),e.jsx(j,{variant:"bodySm",color:"mono700",children:s&&p(s)})]}),e.jsx(i,{mt:8,children:e.jsx(Nt,{onClick:n,size:"small",endIcon:"ArrowRight",children:p(`${oI}.unlock_with_plus`)})})]})]})})},iI="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",Er=({children:t=null,paywallEnabled:s,paywallDismissed:n,handleDismiss:o})=>{const{rangeType:a}=ze(),l=I(hs),c=I(He),u=I(ag),h=I(lg);if(!(a===J.week)||!c)return null;const _=l===_n.BASIC,f=l===_n.ESSENTIALS,g=f&&new Date<Su,b=h>0;return s&&(_||f&&!g)&&!n?e.jsx(lI,{onDismiss:o,recommendedSchedulingCTA:`${iI}.right_people_cta`}):(u||g)&&b?e.jsx(e.Fragment,{children:t}):null},Gm=7,Ym=3,cI=[{primary:p("schedule_builder.predictive_scheduling.generation_modal.steps.step_one"),loading:!0},{primary:p("schedule_builder.predictive_scheduling.generation_modal.steps.step_two"),loading:!1},{primary:p("schedule_builder.predictive_scheduling.generation_modal.steps.step_three"),loading:!1}],od="schedule_builder.previous_weeks_on_jumpstart_drawer.copy_week",dI=({disabled:t=!0,onClick:s,isChecked:n=!1})=>{const o=r.useCallback(()=>{s?.(!n)},[s,n]);return e.jsx(Al,{isAI:!t,disabled:t,selected:n&&!t,onClick:o,variant:"checkbox",title:e.jsx(i,{w:290,justifyContentSpaceBetween:!0,alignItemsCenter:!0,flex:!0,children:e.jsxs(i,{gap:3,flex:!0,children:[e.jsx(Q,{w:"16px",iconName:"Sparkle",color:"mono900"}),e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${od}.enhance_schedule`)})]})}),rightContent:e.jsx(i,{flex:!0,alignItemsStart:!0,justifyContentStart:!0,mt:33,h:"100%",children:e.jsx(ro,{checked:n,onClick:o,name:"enhance"})}),leftContentNoPadding:!0,subtitle:e.jsx(i,{pl:20,column:!0,gap:8,children:e.jsx(j,{variant:"bodySm",color:"mono700",children:p(`${od}.enhance_schedule_desc`)})})})},uI="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",Jn="schedule_builder.previous_weeks_on_jumpstart_drawer.copy_week",hI=({onClose:t,startOfWeek:s,currentWeek:n,onCopySchedule:o,onLoadSchedule:a,isCloverEmbedded:l})=>{const c=K(),[u,h]=r.useState(!1);r.useEffect(()=>{c(w.DRAWER_SHOWN,k.VIEW)},[]);const m=n?.start,_=r.useMemo(()=>pn(new Date(m),6),[m]),f=r.useMemo(()=>pn(new Date(m),0),[m]),[g,b]=r.useState(!1),[x,E]=r.useState(_),S=x,y=r.useMemo(()=>kt(S,6),[S]),C=X(),v=r.useMemo(()=>{const L=pn(new Date(_),Ym*Gm),A=new Date(x)>=new Date(L);return A||h(!1),A},[x,_]),T=r.useCallback(()=>
1{if(u&&v){c(w.BUTTON_CLICKED,k.CLICK,{buttonText:p(`${uI}.title`),element:"generate_schedule",buttonAction:"generate_predictive_schedule",buttonLocation:"jumpstart_drawer"}),C(jo({startDate:x}));return}b(!0),c(w.BUTTON_CLICKED,k.CLICK,{button_text:yu.APPLY}),o({start_date:S,end_date:y,target_start_date:n.start,target_end_date:n.end,noSuccessBanner:!0,noRedirect:!0}).then(L=>{c(w.JUMPSTART_PAST_WEEK_SUCCESS_BANNER_SHOWN,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER}),b(!1),parseInt(L?.copied_shifts_count,10)===0?C(oo({message:p(`${Jn}.copy_empty_schedule`,{props:{date:Sc(S,y,Je)}}),type:"info"})):(C(oo({message:p(`${Jn}.success_message`,{props:{date:Sc(S,y,Je)}}),type:"success"})),t(),a({startDate:n.start,endDate:n.end})),t()})},[c,S,y,n,t,o,a,C,v,u,x]),D=r.useCallback(L=>{h(L)},[]);return e.jsxs(i,{w:"100%",pt:32,flex:!0,column:!0,children:[e.jsxs(i,{gap:32,flex:!0,column:!0,children:[e.jsxs(i,{flex:!0,column:!0,gap:12,children:[e.jsx(j,{variant:"heading2",children:"Copy week"}),e.jsx(j,{variant:"body",children:p(`${Jn}.subtitle`)})]}),e.jsxs(i,{flex:!0,column:!0,gap:8,w:"100%",children:[e.jsx(j,{variant:"bodySmBoldTight",className:"required",color:"mono700",children:p(`${Jn}.copy_from`)}),e.jsx(zm,{setCustomDate:E,drawerDate:x,startOfWeekDay:s,displayOptions:!1,displayArrows:!0,padding:!1,leftArrowDisabled:!x,rightArrowDisabled:!x,blockDatesAfter:n.start,displayedMonths:1,defaultStartDate:_,defaultEndDate:f})]}),!l&&e.jsx(Er,{children:e.jsx(dI,{isChecked:u,onClick:D,disabled:!v})})]}),e.jsx(i,{mt:32,children:e.jsx(V,{fullWidth:!0,onClick:T,disabled:g||m===x||new Date(x)>new Date(n.start),children:p(`${Jn}.paste_schedule`)})})]})},Jm=ut({eventCategory:U.JUMPSTART_PAST_WEEK_DRAWER_COPY})(F(t=>({startOfWeek:rs(t),currentWeek:it(t),isCloverEmbedded:ig(t)}),{onCopySchedule:ju,onLoadSchedule:il})(hI)),mI=()=>{const t=X(),s=K(),n=r.useCallback(()=>{t(Ln())},[t]);return r.useEffect(()=>{s(w.ELEMENT_SHOWN,k.VIEW,{elementType:"drawer",elementName:"copy_week_drawer",elementLocation:"schedule_builder"})},[]),e.jsx(pa,{onBack:void 0,onClose:n,open:!0,children:e.jsx(Jm,{onClose:n})})},pI=Ge({productArea:ae.SCHEDULE_BUILDER,eventCategory:U.SCHEDULE_BUILDER_REPEAT_SCHEDULE_DRAWER})(mI),{cxEl:_I}=O("Template"),Xm=({label:t,value:s})=>e.jsxs(i,{className:_I("detail"),spacebetween:!0,vcenter:!0,mb:9,children:[e.jsx(Y,{fs12:!0,grayXdark:!0,i18n:t}),e.jsx(Y,{fs12:!0,grayXdark:!0,children:s})]});Xm.propTypes={label:d.string.isRequired,value:d.oneOfType([d.string,d.number]).isRequired};const{cxEl:ad}=O("Template"),Pi=({id:t,expanded:s,title:n,username:o,onClick:a,onUpdate:l})=>{const c=K(),u=s?"ChevronDown":"ChevronRight",[h,m]=r.useState(!1),[_,f]=r.useState();r.useEffect(()=>{f(n)},[n]);const g=r.useCallback(y=>{f(y.target.value)},[]),b=r.useCallback(()=>{_?(c(w.EDIT_TEMPLATE_NAME_CHANGED,k.BLUR),l({id:t,name:_}).then(()=>m(!1))):f(n)},[c,t,_,l,n]),x=r.useCallback(()=>f(""),[]),E=r.useCallback(y=>{h||c(w.EDIT_TEMPLATE_NAME_CLICKED,k.CLICK),m(!h),y?.stopPropagation&&y.stopPropagation()},[c,h]),S=r.useCallback(y=>{y.keyCode===13&&b()},[b]);return e.jsxs(i,{spacebetween:!0,vcenter:!0,children:[e.jsxs(i,{className:ad("summary"),w:"100%",children:[!h&&e.jsxs(i,{onClick:a,vcenter:!0,children:[e.jsx(Y,{fs14:!0,neutral600:!0,fw600:!0,className:ad("title"),children:n}),s&&e.jsx(Q,{iconName:"Edit",size:"small",color:"brand",onClick:E})]}),h&&e.jsx(nn,{onClickAway:b,children:e.jsx(An,{value:_,name:"name",onChange:g,onClear:x,size:"fullwidth",focusOnMount:!0,onKeyDown:S})}),o&&e.jsx(i,{onClick:a,children:e.jsx(Y,{fs12:!0,grayXdark:!0,i18n:`${$s}.modified_by`,i18nProps:{username:o}})})]}),!h&&e.jsx(Q,{iconName:u,size:"small",color:"brand",onClick:a})]})};Pi.defaultProps={onClick:()=>{}};Pi.propTypes={expanded:d.bool.isRequired,title:d.string.isRequired,username:d.string,onClick:d.func,onUpdate:d.func};const{cx:fI}=O("Template"),Qm=({id:t,lastModified:s,totalShifts:n,totalHours:o,departments:a,username:l,title:c,onDelete:u,onApply:h,onUpdate:m,isDrawerOpen:_})=>{const f=K(),[g,b]=r.useState(!1),[x,E]=r.useState(!1),S=I(vu);r.useEffect(()=>{_||b(!1)},[_]);const y=r.useMemo(()=>cg({lastModified:s,totalShifts:n,totalHours:o,departments:a}),[s,n,o,a]),C=r.useCallback(()=>{x?f(w.DELETE_TEMPLATE_CANCEL_CLICKED,k.CLICK):f(w.DELETE_TEMPLATE_CLICKED,k.CLICK),E(!x)},[f,x,E]),v=r.useCallback(()=>{g||f(w.EXISTING_TEMPLATE_CLICKED,k.CLICK),b(!g)},[f,b,g]),T=r.useCallback(()=>{f(w.DELETE_TEMPLATE_CONFIRM_CLICKED,k.CLICK),Promise.resolve(u(t)).then(()=>{E(!1),b(!1)})},[f,u,t,E,b]),D=r.useCallback(()=>
1{f(w.APPLY_TEMPLATE_CLICKED,k.CLICK),h({id:t,name:c})},[f,h,t,c]);return e.jsxs(i,{bradiuss:!0,pv:15,ph:10,className:fI(),pointer:!0,children:[!x&&e.jsx(Pi,{id:t,expanded:g,title:c,username:l,onClick:v,onUpdate:m}),!x&&g&&e.jsxs(i,{children:[e.jsx(i,{mv:"xs",children:e.jsx(V,{variant:"tertiaryPlain",onClick:D,isLoading:S,children:p(`${$s}.apply`)})}),y.map(([L,A])=>e.jsx(Xm,{label:L,value:A},L)),e.jsx(V,{variant:"secondaryDestructive",size:"small",onClick:C,children:p(`${$s}.delete`)})]}),x&&e.jsxs(i,{column:!0,children:[e.jsx(Y,{i18n:`${$s}.confirm_delete.title`,color:"red",fs14:!0,fw600:!0}),e.jsx(i,{mv:10,children:e.jsxs(Y,{fs14:!0,children:[p(`${$s}.confirm_delete.desc`),e.jsx("br",{}),e.jsx("b",{children:c}),"?"]})}),e.jsxs(i,{spacebetween:!0,children:[e.jsx(V,{variant:"secondary",onClick:C,isLoading:S,children:p(`${$s}.confirm_delete.cancel`)}),e.jsx(V,{variant:"primary",onClick:T,isLoading:S,children:p(`${$s}.confirm_delete.confirm`)})]})]})]})};Qm.propTypes={lastModified:d.string.isRequired,totalShifts:d.number.isRequired,totalHours:d.number.isRequired,departments:d.string.isRequired,username:d.string,title:d.string.isRequired,id:d.number.isRequired,onDelete:d.func.isRequired,onApply:d.func.isRequired,onUpdate:d.func.isRequired,isDrawerOpen:d.bool.isRequired};const bI=()=>{const[t,s]=r.useState(""),n=I(dg)||[],o=I(it),a=I(vu),l=X(),c=r.useCallback(async f=>{await l(ug(f))},[l]),u=r.useCallback(async f=>{f.name&&f.name.length>0&&await l(hg({templateId:f.id,name:f.name}))},[l]),h=r.useCallback(async f=>{await l(mg({id:f.id,payload:{start_date:o?.start,end_date:o?.end}}))},[o,l]),m=r.useCallback(()=>{xv({eventAction:w.CREATE_TEMPLATE_CLICKED,actionType:k.CLICK}),l(pg({date:{start_date:o?.start,end_date:o?.end},name:t})),s("")},[o,l,t]),_=r.useCallback(f=>{s(f.target.value)},[]);return n?e.jsxs(as,{w:"100%",h:"100%",gap:8,flex:!0,column:!0,children:[e.jsx(as,{gap:18,children:e.jsx(j,{variant:"heading2",children:p("schedule_builder.empty_state.select_template")})}),e.jsxs(as,{phxl:!0,pbs:!0,grow:!0,children:[e.jsxs(as,{mbm:!0,children:[e.jsx(as,{mb:2,mbxs:!0,children:e.jsx(j,{variant:"body",children:p("schedule_builder.templates_drawer.create.title")})}),e.jsxs(as,{gap:3,row:!0,children:[e.jsx(as,{grow:3,basis:0,prm:!0,children:e.jsx(yo,{value:t,placeholder:p("schedule_builder.templates_drawer.create.placeholder"),onChange:_,name:"newTemplateName"})}),e.jsx(as,{mb:3,mbxs:!0,grow:1,basis:0,children:e.jsx(Fs,{feature:"templates",children:e.jsx(V,{variant:"primary",onClick:m,disabled:!t,isLoading:a,children:p("schedule_builder.templates_drawer.create.button")})})})]})]}),e.jsx(as,{children:e.jsx(j,{variant:"body",children:p("schedule_builder.templates_drawer.your_templates",{props:{count:n.length}})})})]}),n.map((f,g)=>e.jsx(Qm,{id:Number(f.id),lastModified:f.lastModified,totalShifts:f.totalShifts,totalHours:f.totalHours,title:f.title,username:f.username,departments:f.departments,onDelete:c,onApply:h,onUpdate:u,isDrawerOpen:!1},`TemplateDetailsRow-${g}`))]}):null},Zm=ut({eventCategory:U.JUMPSTART_TEMPLATE_DRAWER})(bI),gI=()=>{const t=X(),s=K(),n=r.useCallback(()=>{t(Ln())},[t]);return r.useEffect(()=>{s(w.ELEMENT_SHOWN,k.VIEW,{elementType:"drawer",elementName:"templates_drawer",elementLocation:"schedule_builder"})},[]),e.jsx(pa,{onBack:void 0,onClose:n,open:!0,children:e.jsx(Zm,{onClose:n})})},xI=Ge({productArea:ae.SCHEDULE_BUILDER,eventCategory:U.SCHEDULE_BUILDER_MANAGE_TEMPLATES_DRAWER})(gI),{cx:ld}=O("NarrativeMessageContainer"),_a=({className:t,open:s,title:n,noPadding:o,hideCloseIcon:a,onClose:l,bgcolor:c,children:u,uxContext:h,isAI:m=!1,isAIAnimating:_=!1})=>{const f=r.useId(),g=r.useId(),b=()=>{if(!h)return u;const S=ut(h)(()=>u);return e.jsx(S,{})},x=r.useMemo(()=>({"& .MuiSnackbar-container":{alignItems:"flex-end"}}),[]),E=r.useCallback(()=>{l&&l()},[l]);return e.jsx(i,{relative:!0,zIndex:1e3,children:e.jsx(_g,{className:`${ld()}${t?` ${t}`:""}`,open:s,onClose:l,"aria-labelledby":f,"aria-describedby":g,sx:x,id:"narrative-message-container-snackbar",children:e.jsxs(i,{p:o?0:32,bgcolor:c,isAI:m,isAIAnimating:_,bradiusl:!0,className:ld({isAI:m,isAIAnimating:_}),children:[!a&&e.jsx(i,{absolute:!0,top:8,right:8,children:e.jsx(be,{onClick:E,icon:"Close",size:"small",dataTestId:"NarrativeMessageContainer-close-icon",label:p("schedule_builder.actions.close")})}),n&&e.jsx(i,{mt:32,mb:24,children:e.jsx(j,{id:f,variant:"heading2",children:n})}),e.jsx("div",{id:g,children:b()})]})})})},CI=()=>{const t=X(),[s,n]=r.useState(!0),{scheduleStatus:o,scheduleCount:a,rosterCount:l}=I(vo)||{},c=o===En,u=c?"image_to_schedule_success_summary_dismissed":"image_to_schedule_partial_summary_dismissed",h=I(fg),m=I(bg),_=c?h:m,f=K(),g=r.useCallback(()=>{n(!1),t(jr(u,"Company"))},[t,u]),b=c?Xc.ROSTER_SCHEDULE_IMPORTED:Xc.ONLY_ROSTER_IMPORTED;f(w.ELEMENT_SHOWN,k.VIEW,{image_to_schedule_status:b,productArea:ae.SCHEDULE_BUILDER,eventCategory:U.I2S_WEB});const x=c?"ready_for_review":"couldnt_extract_schedule",E=c?"created_shifts":"shifts_created";return e.jsx(_a,{open:s&&!_,hideCloseIcon:!0,noPadding:!0,isAI:!0,isAIAnimating:!0,children:e.jsxs(i,{w:628,p:16,column:!0,gap:20,children:[e.jsxs(i,{alignItemsCenter:!0,gap:8,flex:!0,justifyContentSpaceBetween:!0,children:[e.jsxs(i,{flex:!0,gap:8,children:[e.jsx(Q,{color:"primary500",iconName:"Sparkle",size:"large"}),e.jsx(j,{variant:"heading4",children:p(`image_to_schedule.first_schedule.dialog.title.${x}`)})]}),e.jsx(i,{children:e.jsx(be,{onClick:g,icon:"Close",size:"small",dataTestId:"close-button",label:p("schedule_builder.actions.close")})})]}),e.jsx(i,{children:e.jsxs(i,{pl:32,flex:!0,column:!0,gap:20,maxh:368,overflowY:"auto",children:[e.jsxs(i,{row:!0,gap:8,children:[e.jsx(Q,{color:"primary500",iconName:"AddUser",size:"large"}),e.jsx(j,{variant:"heading4",children:p("image_to_schedule.first_schedule.dialog.added_team_members",{props:{count:l||0}})})]}),e.jsxs(i,{row:!0,gap:8,children:[e.jsx(Q,{color:"primary500",iconName:"AddTime",size:"large"}),e.jsx(j,{variant:"heading4",children:p(`image_to_schedule.first_schedule.dialog.${E}`,{props:{count:a||0}})})]})]})})]})})},{cxEl:EI}=O("ScheduleBuilderFirstTimeUserExperience"),SI=()=>{const{scheduleCount:t,rosterCount:s}=I(vo)||{},n=r.useCallback(()=>{Rt({productArea:ae.SCHEDULE,eventCategory:U.FTUX_PANEL,eventAction:w.LINK_CLICKED,properties:{ftuxPanelType:ae.SCHEDULE,element:"add_contact_info",linkText:p("image_to_schedule.floating_panel.steps.two.link"),linkUrl:`${window.location.origin}/team`}})},[]);return e.jsxs(e.Fragment,{children:[e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(i,{className:EI("isAIAnimating"),children:e.jsx(Q,{size:"large",iconName:"Sparkle"})}),e.jsx(j,{variant:"heading1",children:p("image_to_schedule.floating_panel.title")})]}),e.jsx(i,{mt:8,children:e.jsx(j,{variant:"body",children:p("image_to_schedule.floating_panel.subtitle")})}),e.jsxs(i,{mt:16,mb:4,gap:16,row:!0,children:[e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Q,{size:"small",color:"purple500",iconName:"Schedule"}),e.jsx(j,{variant:"bodySm",children:p("image_to_schedule.floating_panel.shifts_added",{props:{count:t||0}})})]}),e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Q,{size:"small",color:"purple500",iconName:"User"}),e.jsx(j,{variant:"bodySm",children:p("image_to_schedule.floating_panel.team_members_created",{props:{count:s||0}})})]})]}),e.jsx("hr",{}),e.jsx(i,{mt:4,children:e.jsx(j,{variant:"heading3",children:p("image_to_schedule.floating_panel.next_steps")})}),e.jsx(i,{mt:20,mb:4,children:e.jsx(Ol,{variant:"number",asHTML:!0,data:[{primary:p("image_to_schedule.floating_panel.steps.one")},{primary:e.jsxs(e.Fragment,{children:[e.jsx(Nt,{onClick:n,href:"/team",target:"_blank",children:p("image_to_schedule.floating_panel.steps.two.link")})," ",p("image_to_schedule.floating_panel.steps.two.notify_them")]})},{primary:p("image_to_schedule.floating_panel.steps.three")}],gapOverride:"20px"})}),e.jsx("hr",{}),e.jsxs(i,{mt:4,children:[e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Q,{size:"small",color:"purple500",iconName:"Boost"}),e.jsx(j,{variant:"bodyBold",children:p("image_to_schedule.floating_panel.schedule_smarter_than_last")})]}),e.jsx(i,{mt:8,children:e.jsx(j,{variant:"body",children:p("image_to_schedule.floating_panel.learn_your_business")})})]})]})},ep=os(t=>Es({state:t,attribute:"isJumpstartVisible",sliceName:"schedule"}),Nl,(t,s)=>t&&!s),Ha="schedule_builder.schedule_assistants_cta",jI=({isEssentialsLocation:t,onClick:s})=>e.jsxs(i,{alignItemsCenter:!0,row:!0,children:[e.jsx(j,{variant:"captions",color:"mono700",children:p(`${Ha}.free_trial_cta`)}
1),"Â ",e.jsx(Nt,{onClick:s,size:"xs",children:t?p(`${Ha}.upgrade_to_plus`):p(`${Ha}.unlock_with_plus`)})]}),tp=r.memo(jI),id="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",yI=({handlePaywallClick:t,isAi:s,onClick:n,shouldShowCTA:o})=>e.jsxs(i,{children:[e.jsx(mo,{dataTestId:"prediction-card",isAI:s,pointer:!0,rightContentNoPadding:!0,leftContent:e.jsx(i,{mt:-47,children:e.jsx(Q,{w:32,h:32,iconName:"Sparkle",color:"mono900"})}),rightContent:e.jsx(e.Fragment,{}),title:e.jsx(i,{flex:!0,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${id}.title`)})}),subtitle:e.jsx(i,{column:!0,children:e.jsx(j,{variant:"bodySm",color:"mono700",children:p(`${id}.subtitle`)})}),onClick:n}),o&&e.jsx(i,{mt:4,children:e.jsx(tp,{isEssentialsLocation:!0,onClick:t})})]}),cd="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",vI="schedule_builder.schedule_assistants_cta",II=()=>{const{handleOnClick:t}=So({planName:"plus",focusedFeature:"predictive_scheduling"});return e.jsx(mo,{dataTestId:"prediction-card",pointer:!0,rightContentNoPadding:!0,leftContent:e.jsx(i,{mt:-47,children:e.jsx(Q,{w:32,h:32,iconName:"Sparkle",color:"mono900"})}),rightContent:e.jsx(e.Fragment,{}),title:e.jsxs(i,{column:!0,children:[e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${cd}.title`)}),e.jsx(j,{variant:"bodySm",color:"mono700",children:p(`${cd}.save_time_cta`)})]}),subtitle:e.jsx(Nt,{onClick:t,size:"small",endIcon:"ArrowRight",children:p(`${vI}.unlock_with_plus`)})})},dd="schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling",ud="schedule_builder.previous_weeks_on_jumpstart_drawer",TI=({setScreen:t})=>{const s=Io(),n=I(gg)||[],o=I(hs),[a,l]=r.useState(!1),c=X(),u=K(),{handleOnClick:h}=So({planName:"plus",focusedFeature:"predictive_scheduling"}),m=r.useCallback(()=>{if(Bm(o)){h();return}u(w.BUTTON_CLICKED,k.CLICK,{buttonText:p(`${dd}.title`),element:"generate_schedule",buttonAction:"generate_predictive_schedule",buttonLocation:"jumpstart_drawer"}),c(jo({}))},[c,u,o]),_=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{buttonAction:"copy_schedule",buttonText:"copy_from_past_week",buttonLocation:"jumpstart_drawer"}),t("copyWeek")},[t,u]),f=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{buttonAction:"apply_template_drawer",buttonText:"apply",buttonLocation:"jumpstart_drawer"}),t("templates")},[t,u]),g=r.useMemo(()=>Um(o),[o]),b=r.useCallback(()=>{l(!0)},[]);return e.jsxs(i,{gap:32,column:!0,justifyContentCenter:!0,children:[e.jsx(i,{mb:24,flex:!0,column:!0,w:"100%",alignItemsCenter:!0,justifyContentCenter:!0,children:e.jsx(Cv,{w:100})}),e.jsx(j,{textAlign:"left",variant:"heading2",children:p(`${dd}.drawer_title`)}),e.jsxs(i,{flex:!0,column:!0,gap:16,children:[!s&&e.jsx(Er,{paywallEnabled:!0,paywallDismissed:a,handleDismiss:b,children:e.jsx(yI,{isAi:!0,handlePaywallClick:h,onClick:m,shouldShowCTA:g&&Iu()})}),e.jsx(i,{pointer:!0,flex:!0,w:"100%",children:e.jsx(mo,{pointer:!0,leftContent:e.jsx(Q,{w:32,iconName:"Copy",color:"black"}),rightContent:e.jsx(e.Fragment,{}),title:e.jsx(i,{flex:!0,w:308,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${ud}.empty_state.copy_from_past_week`)})}),onClick:_})}),n.length>0&&e.jsx(i,{pointer:!0,children:e.jsx(mo,{dataTestId:"template-card",leftContent:e.jsx(Q,{w:32,iconName:"Group",color:"black"}),rightContent:e.jsx(e.Fragment,{}),title:e.jsx(i,{flex:!0,w:308,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${ud}.empty_state.apply_template`)})}),onClick:f})}),a&&e.jsx(II,{})]})]})},wI=()=>{const t=X(),[s,n]=r.useState("zeroState"),o=I(ep),a=I(Nl),l=I(Tu),c=K(),u=r.useCallback(()=>{t(Ml()),s==="zeroState"&&!l&&t(xg())},[t,l,s]),h=r.useCallback(()=>{n("zeroState")},[n]),m=r.useCallback(_=>{n(_)},[n]);return r.useEffect(()=>{a||(c(w.ELEMENT_SHOWN,k.VIEW,{elementType:"drawer",elementName:"jumpstart_drawer",elementLocation:"schedule_builder"}),n("zeroState"))},[a,t,c]),e.jsxs(pa,{onBack:s!=="zeroState"?h:void 0,onClose:u,open:o&&!a,children:[s==="zeroState"&&e.jsx(TI,{setScreen:m}),s==="templates"&&e.jsx(Zm,{}),s==="copyWeek"&&e.jsx(Jm,{onClose:u})]})},DI=Ge({productArea:ae.SCHEDULE_BUILDER,eventCategory:U.SCHEDULE_BUILDER_JUMPSTART_DRAWER})(wI),qn=()=>{const t=I(To);return r.useMemo(()=>{const s={};for(const n of t)s[n.job_id]=`${n.first_name?.trim()||""} ${n.last_name?.trim()||""}`.trim();return s},[t])},sp=t=>{const s=qn();return r.useMemo(()=>{const n=t.find(c=>c.group_type===le.MISSING_AVAILABILITY),a=(n?.items||[]).map(c=>{const h=(c.meta??null)?.employee_id??"";return{id:c.id,jobId:h,userName:h?s[h]??"":"",open:c.open,resolutionType:c.resolution_type}}),l=a.filter(c=>c.open).length;return{items:a,availableResolutionTypes:n?.available_resolution_types??On,openCount:l}},[t,s])},np=({cancelLabel:t,fromLabel:s,message:n,messagePreviewLabel:o,onClose:a,onSend:l,open:c,recipientsLabel:u,senderName:h,sendingToLabel:m,sendLabel:_,title:f})=>e.jsx(Mt,{open:c,onClose:a,hideCloseIcon:!0,noPadding:!0,children:()=>e.jsxs(i,{w:556,column:!0,borderbox:!0,ph:32,pt:24,pb:32,children:[e.jsxs(i,{flex:!0,spacebetween:!0,vcenter:!0,w:"100%",pb:16,children:[e.jsx(j,{variant:"heading2",children:f}),e.jsx(Q,{iconName:"Close",size:"medium",color:"purple500",onClick:a,alt:p("schedule_builder.actions.close"),screenReadable:!0})]}),e.jsxs(i,{pv:24,children:[e.jsxs(i,{column:!0,gap:4,children:[e.jsxs(i,{flex:!0,children:[e.jsx(j,{variant:"captions",children:s}),e.jsx(i,{pl:4,children:e.jsx(j,{variant:"captionBold",children:h})})]}),e.jsxs(i,{flex:!0,children:[e.jsx(j,{variant:"captions",children:m}),e.jsx(i,{pl:4,children:e.jsx(j,{variant:"captionBold",children:u})})]})]}),e.jsx(i,{mt:24,children:e.jsx(j,{variant:"bodySmBold",children:o})}),e.jsx(i,{mt:8,children:e.jsx(j,{variant:"bodySm",children:n})})]}),e.jsxs(i,{w:"100%",flex:!0,row:!0,gap:16,justifyContentEnd:!0,pt:18,children:[e.jsx(V,{variant:"tertiary",onClick:a,children:t}),e.jsx(V,{variant:"primary",onClick:l,children:_})]})]})}),kI=({open:t})=>{const s=K(),n=I(yr),{items:o,openCount:a}
1=sp(n),l=I(wu),c=I(Du),u=[l,c].filter(Boolean).join(" "),h=X(),m=p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.default_message"),_=o.filter(b=>b.open).map(b=>b.id),f=r.useCallback(()=>{s(w.BUTTON_CLICKED,k.CLICK,{element:"send_reminder",button_text:"Send",conflict_type:"missing_availability",message_edited:"false"}),h(Tt(!1)),h(ws("")),h(Ws({status:It.MISSING,sendingIsProcessing:!0})),h(Ot({action_item_ids:_,resolution_type:fe.REQUEST_AVAILABILITY,resolution_payload:{message:m}})).then(()=>{h(Ws({status:It.MISSING,messageSent:!0,sendingIsProcessing:!1}))}).catch(()=>{h(Ws({status:It.MISSING,sendingIsProcessing:!1}))})},[m,h,_]),g=r.useCallback(()=>{s(w.BUTTON_CLICKED,k.CLICK,{element:"missing_availability_reminder_modal",button_text:"Cancel"}),h(Tt(!1)),h(ws(""))},[h,s]);return e.jsx(np,{open:t,onClose:g,onSend:f,title:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.title"),fromLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.from"),senderName:u,sendingToLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.sending_to"),recipientsLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.sending_to_count",{props:{count:a}}),messagePreviewLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.message_preview"),message:m,cancelLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.cancel"),sendLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.dialog.send")})},RI=[{userName:"Shaun Henderson"},{userName:"James Sparks"}],LI=({open:t})=>{const s=X(),n=r.useCallback(()=>{s(Tt(!1)),s(ws("")),s(Ws({status:It.NEW_TEAM_MEMBER,sendingIsProcessing:!0})),setTimeout(()=>{s(Ws({status:It.NEW_TEAM_MEMBER,messageSent:!0,sendingIsProcessing:!1}))},2e3)},[s]),o=r.useCallback(()=>{s(Tt(!1)),s(ws(""))},[s]),a=r.useCallback(l=>{console.log(l)},[]);return e.jsx(Mt,{title:p("schedule_builder.agent.sidebar.pre_flight_checks.new_team_member_availability_card.dialog.title"),open:t,onClose:o,buttons:[{label:p("schedule_builder.agent.sidebar.pre_flight_checks.new_team_member_availability_card.dialog.send"),onClick:n},{label:p("schedule_builder.agent.sidebar.pre_flight_checks.new_team_member_availability_card.dialog.cancel"),variant:"tertiary",onClick:o}],children:()=>e.jsx(Ht,{initialValues:{missing_availability_message:p("schedule_builder.agent.sidebar.pre_flight_checks.new_team_member_availability_card.dialog.placeholder_text")},onSubmit:a,children:e.jsxs(i,{children:[e.jsxs(i,{flex:!0,w:500,children:[e.jsx(i,{children:e.jsx(j,{variant:"captions",children:p("schedule_builder.agent.sidebar.pre_flight_checks.new_team_member_availability_card.dialog.sending_to")})}),e.jsx(i,{pl:4,children:e.jsx(j,{variant:"captionBold",children:RI.map(l=>l.userName).join(", ")})})]}),e.jsx(i,{mt:12,children:e.jsx(hr,{name:"missing_availability_message",type:"text",fullWidth:!0,textArea:!0})})]})})})},rp=()=>{const t=X(),[,s]=At(Gs,!1),[,n]=At(Nn,!1);return r.useCallback(()=>{s(!1),n(!0),t(Mn(!1))},[t,s,n])},op=()=>{const t=X(),s=I(Pl),n=rp(),[o,a]=r.useState(!1);return{saveDraftAndExit:r.useCallback(async()=>{a(!0);try{await Promise.all(s.map(c=>t($l({oldShiftId:c.id,originalShift:c,source_type:"draft_shift",source_uuid:c.id,start_at:c.start_at,end_at:c.end_at,...c.role_id&&{role_uuid:c.role_id}})).unwrap())),n(),t(Ys(!1))}catch{a(!1)}},[t,s,n]),isSaving:o}},AI=()=>{const t=K(),s=X(),n=I(v=>Cg(v)),o=I(v=>Pl(v)),a=I(v=>Eg(v)),l=I(v=>_t(v)),c=I(v=>Pn(v)),u=I(v=>Bl(v)),h=c||u===0,[m,_]=r.useState(!1),{saveDraftAndExit:f,isSaving:g}=op(),b=m||g;r.useEffect(()=>{n&&t(w.MODAL_VIEWED,k.VIEW,{modal_source:"schedule_builder_menu"})},[n,t]);const[,x]=At(Gs,!1),[,E]=At(Nn,!1),S=r.useCallback(()=>{b||(t(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"exit_sba_modal"}),s(Ys(!1)))},[s,b,t]),y=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"confirm_exit_and_save_sba",button_text:"Exit and save"}),f()},[f,t]),C=r.useCallback(async()=>
1{if(!h){t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"confirm_exit_and_remove_sba",button_text:"Exit and remove"}),_(!0);try{await Promise.all([...o.map(v=>s(wo({shiftId:v.id})).unwrap()),...a.map(v=>s(mr({shiftId:v.id})).unwrap())]),await s(Ul({startDate:l,scope:Hl.DRAFTS_ONLY})).unwrap(),x(!1),E(!0),s(Mn(!1)),s(Ys(!1))}catch{_(!1)}}},[a,s,o,h,x,E,l,t]);return e.jsx(Mt,{open:n,onClose:S,hideCloseIcon:!0,noPadding:!0,children:()=>e.jsxs(i,{w:556,column:!0,borderbox:!0,ph:32,pt:24,pb:32,children:[e.jsxs(i,{flex:!0,spacebetween:!0,vcenter:!0,w:"100%",pb:16,children:[e.jsx(j,{variant:"heading2",children:p("schedule_builder.agent.opt_out.dialog.title")}),e.jsx(Q,{iconName:"Close",size:"medium",color:"purple500",onClick:S,alt:p("schedule_builder.actions.close"),screenReadable:!0})]}),e.jsx(i,{pv:24,children:e.jsx(j,{variant:"body",children:p("schedule_builder.agent.opt_out.dialog.content")})}),e.jsxs(i,{w:"100%",flex:!0,row:!0,gap:16,justifyContentEnd:!0,pt:18,children:[e.jsx(V,{variant:"secondaryDestructive",onClick:C,isLoading:m,disabled:b||h,children:p("schedule_builder.agent.opt_out.dialog.exit_and_remove")}),e.jsx(V,{variant:"primary",onClick:y,isLoading:g,disabled:b,children:p("schedule_builder.agent.opt_out.dialog.exit_and_save")})]})]})})},OI=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(AI),NI=({open:t,openIds:s,userNames:n})=>{const o=X(),a=I(wu),l=I(Du),c=[a,l].filter(Boolean).join(" "),u=p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.default_message"),h=n.length===1?n[0]:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.employees_count",{props:{count:n.length}}),m=r.useCallback(()=>{o(Tt(!1)),o(ws("")),o(Ws({status:It.STALE,sendingIsProcessing:!0})),o(Ot({action_item_ids:s,resolution_type:fe.REQUEST_AVAILABILITY,resolution_payload:{message:u}})).then(()=>{o(Ws({status:It.STALE,messageSent:!0,sendingIsProcessing:!1}))})},[u,o,s]),_=r.useCallback(()=>{o(Tt(!1)),o(ws(""))},[o]);return e.jsx(np,{open:t,onClose:_,onSend:m,title:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.title"),fromLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.from"),senderName:c,sendingToLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.sending_to"),recipientsLabel:h,messagePreviewLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.message_preview"),message:u,cancelLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.cancel"),sendLabel:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.dialog.send")})},MI=()=>{const t=I(To),s=I(ku),n=I(_t);return r.useMemo(()=>Sg(t,s,n),[t,s,n])},PI={[vt.OPENING_SHIFT_REASSIGNED]:fe.REASSIGN_OPENING_SHIFT,[vt.CLOSING_SHIFT_REASSIGNED]:fe.REASSIGN_CLOSING_SHIFT,[vt.REPLACEMENT_FOUND]:fe.FIND_REPLACEMENT},$I=({open:t,title:s})=>{const n=X(),o=I(Ru),a=I(jg),l=I(yg),c=MI(),u=r.useCallback(m=>()=>{if(!o||!a)return;const _=PI[a];n(Tt(!1)),n(Vs({actionItem:o,status:vt.PROCESSING})),n(Ot({action_item_ids:l,resolution_type:_??a,resolution_payload:{job_id:m}})).unwrap().then(()=>n(Vs({actionItem:o,status:a}))).catch(()=>n(Vs({actionItem:o,status:""}))).finally(()=>{n(jn("")),n(yn([])),n(pr(""))})},[n,o,a,l]),h=r.useCallback(()=>{n(Tt(!1)),n(_r("")),n(jn("")),n(yn([])),n(pr(""))},[n]);return e.jsx(Mt,{open:t,onClose:h,noPadding:!0,width:380,children:()=>e.jsxs(i,{children:[e.jsx(i,{p:16,children:e.jsx(j,{variant:"bodySm",children:s})}),c.map(m=>e.jsxs(i,{spacebetween:!0,alignItemsCenter:!0,btw:1,bcolor:"mono300",p:16,children:[e.jsx(i,{children:e.jsx(j,{variant:"bodySmTight",children:m.name})}),e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.sidebar.dialog.hrs_scheduled",{props:{hrs:fn(m.scheduledHours)}})}),e.jsx(V,{variant:"secondary",size:"small",onClick:u(m.jobId),children:p("schedule_builder.agent.sidebar.dialog.select")})]})]},m.jobId)),e.jsx(i,{btw:1,bcolor:"mono300",p:16,children:e.jsx(V,{fullWidth:!0,variant:"secondary",onClick:h,children:p("schedule_builder.agent.sidebar.dialog.cancel")})})]})})},As=({children:t,delay:s=0})=>{const n=Do({from:{opacity:0}
1,to:{opacity:1},config:{duration:400},delay:s});return e.jsx(bn.div,{style:n,children:t})},BI=2e3,$i=t=>{const[s,n]=r.useState(!1),o=r.useRef(null),a=r.useRef(null),l=r.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),c=r.useCallback(()=>{if(o.current===null){n(!1);return}const u=BI-(Date.now()-o.current);if(l(),u<=0){n(!1),o.current=null;return}a.current=setTimeout(()=>{n(!1),o.current=null,a.current=null},u)},[l]);return r.useEffect(()=>{if(t==="pending"){l(),o.current=Date.now(),n(!0);return}if(o.current!==null)return c(),l},[t,c,l]),s},UI=t=>p(`schedule_builder.agent.schedule_published.${t}`),HI=()=>(r.useEffect(()=>{const t=document.querySelector("[data-sidebar-scroll]");t&&t.scrollTo({top:t.scrollHeight,behavior:"smooth"})},[]),e.jsx(i,{id:!0,minh:"100%",flex:!0,column:!0,gap:4,alignItemsCenter:!0,justifyContentCenter:!0,children:e.jsx(As,{delay:100,children:e.jsxs(i,{flex:!0,column:!0,alignItemsCenter:!0,gap:8,children:[e.jsx($n,{variant:"dark",size:"medium"}),e.jsx(j,{color:"mono700",variant:"bodySm",children:UI("publishing")})]})})})),FI=()=>{const t=K(),s=X(),n=I(_t),o=I(Fl),a=I(vg),l=I(Ig),c=I(Tg),u=I(wg),h=I(Dg),m=I(Pl),_=I(Bn),f=I(ko),g=$i(f),b=I(Ro),x=I(Lo),E=I(Wl),S=I(M=>ct(M)),y=!!a||!!l||!!c||!!u||!!h,C=r.useMemo(()=>E||g?"pre_publish":b||_==="pending"?"post_assign":x?"structure":"pre_assign",[E,g,b,_,x]),v=p("schedule_builder.agent.load_error.try_again"),T=p("schedule_builder.agent.load_error.use_classic_scheduler"),[,D]=At(Gs,!1),[,L]=At(Nn,!1);r.useEffect(()=>{y&&t(w.BANNER_VIEWED,k.VIEW,{banner_version:wa,sba_phase:C,eventCategory:U.SCHEDULE_BUILDER})},[y,S,C,t]);const A=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{element:"retry_load_builder",button_text:v,banner_version:wa,eventCategory:U.SCHEDULE_BUILDER}),n&&(h&&s(o==="pending"?Ao({startDate:n}):Lu({startDate:n})),a&&s(Oo({startDate:n,type:"all"})),l&&s(Vl()),c&&s(Kl({date:n})),u&&s(Au()))},[o,a,u,s,c,l,h,n,t,v]),P=r.useCallback(()=>{if(t(w.BUTTON_CLICKED,k.CLICK,{element:"use_classic_scheduler",button_text:T,banner_version:wa,eventCategory:U.SCHEDULE_BUILDER}),m.length>0){s(Ys(!0));return}D(!1),L(!0),s(Mn(!1))},[s,m.length,D,L,t,T]);return y?e.jsx(i,{p:16,children:e.jsx(dt,{variant:"error",title:p("schedule_builder.agent.load_error.title"),action:e.jsx(Nt,{onClick:P,children:T}),secondaryAction:e.jsx(V,{size:"small",variant:"tertiary",onClick:A,children:v}),children:p("schedule_builder.agent.load_error.message")})}):null},WI=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(FI),fa=({message:t,actionLabel:s,onClose:n,onAction:o})=>e.jsx(i,{pointerEvents:"auto",maxw:600,w:"100%",children:e.jsx(dt,{variant:"error",isToast:!0,onClose:n,action:s&&e.jsx(V,{size:"small",variant:"secondary",onClick:o,children:s}),children:t})}),VI=()=>{const t=X(),s=I(kg),n=r.useCallback(()=>{t(No("assignmentConflict"))},[t]);return s?e.jsx(fa,{message:p("schedule_builder.agent.toast_errors.assignment_conflict"),onClose:n}):null},KI=()=>{const t=X(),s=I(Rg),n=I(_t),o=r.useCallback(()=>{t(No("clearScheduleFailed"))},[t]),a=r.useCallback(()=>{n&&t(Ul({startDate:n,scope:Hl.UNPUBLISHED_ONLY}))},[t,n]);return s?e.jsx(fa,{message:p("schedule_builder.agent.toast_errors.clear_schedule_failed"),actionLabel:p("schedule_builder.agent.toast_errors.try_again"),onClose:o,onAction:a}):null},Bi=()=>{const t=K(),s=X(),n=I(_t),o=I(ql),a=I(Ou),c=I(ko)==="pending";return{handlePublish:r.useCallback(()=>{s(Mo(!1)),!(!n||c)&&(t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_PUBLISH,element:"publish_schedule",button_text:"Publish schedule",notification_group:a,total_shifts:o.length}),s(jc({startDate:n,notificationGroup:a})).then(h=>{jc.fulfilled.match(h)&&(s(Po({startDate:n})),s(zl()),s(Oo({startDate:n,type:"all"})),s(Kl({date:n})),s(Vl()),s(Nu(n)),s(Gl({startDate:n})),s(Ao({startDate:n})))}))},[s,c,a,o,n,t]),isPublishing:c}},qI=()=>{const t=X(),s=I(Lg),{handlePublish:n}=Bi(),o=r.useCallback(()=>{t(No("publishFailed"))},[t]),a=r.useCallback(()=>{n()},[n]);return s?e.jsx(fa,{message:p("schedule_builder.agent.toast_errors.publish_failed"),actionLabel:p("schedule_builder.agent.toast_errors.try_again"),onClose:o,onAction:a}):null},zI=()=>{const t=X(),s=I(Ag),n=r.useCallback(()=>{t(No("shiftSaveFailed"))},[t]);return s?e.jsx(fa,{message:p("schedule_builder.agent.toast_errors.shift_save_failed"),onClose:n}):null},GI=()=>e.jsxs(i,{absolute:!0,bottom:24,left:0,right:0,zIndex:20,flex:!0,column:!0,alignItemsCenter:!0,gap:8,pointerEvents:"none",ph:16,children:[e.jsx(qI,{}),e.jsx(KI,{}),e.jsx(zI,{}),e.jsx(VI,{})]}),ap=t=>{const s=qn();return r.useMemo(()=>{const n=t.find(h=>h.group_type===le.STALE_AVAILABILITY),o=n?.items||[],a=lt().startOf("day"),l=o.map(h=>{const m=h.meta??null,_=m?.job_id??h.subject_id??"",f=m?.last_updated_at?Math.max(0,a.diff(lt(m.last_updated_at).startOf("day"),"days")):0;return{id:h.id,open:h.open,jobId:_,userName:_?s[_]??"":"",numOfDays:f,resolutionType:h.resolution_type}}),c=vr(l,h=>h.jobId);return{itemsByEmployee:Object.values(c).map(h=>
1({jobId:h[0].jobId,userName:h[0].userName,numOfDays:h[0].numOfDays,open:h[0].open,openRequestIds:h.filter(m=>m.open).map(m=>m.id),resolutionType:h[0].resolutionType})),availableResolutionTypes:n?.available_resolution_types??On}},[t,s])},{cx:YI}=O("ShiftCell"),Xn="schedule_builder.react_page.shifts.tooltips",JI=(t,s)=>{switch(t){case"ShiftConflict":return p(`${Xn}.shift_conflict`,{props:{name:s}});case"TimeOffConflict":return p(`${Xn}.time_off_conflict`,{props:{name:s}});case"AvailabilityConflict":return p(`${Xn}.availability_conflict`,{props:{name:s}});case"Overtime":return p(`${Xn}.overtime`);case"Overnight":return p(`${Xn}.overnight`);default:return}},lp=({shiftId:t,bgcolor:s,isDropTarget:n,isHighlighted:o})=>{const a=I(S=>$o(S,t)),l=I(S=>ks(S)===1),c=I(S=>a?.role_id?Mu(S,{roleId:a.role_id}):void 0),u=I(S=>Og(S,{shiftId:t})),h=I(S=>a?.job_id?Ng(S,{jobId:a.job_id}):"");if(!a)return null;const _=u?[u.has_shift_conflict&&"ShiftConflict",u.time_off_conflict&&"TimeOffConflict",u.availability_conflict&&"AvailabilityConflict",u.is_overtime&&"Overtime",u.is_overnight&&"Overnight"].filter(S=>!!S).slice(0,2):[],f=a.color||Bo(l),g=!!a.is_published,x=(g?ao(l,f):"purple900")==="purple900"?"mono900":"mono0",E=Ut(a.start_at,a.end_at);return e.jsx(i,{className:YI({[l?`${f}`:`${f}-v2`]:!0,[`${ao(l,f)}`]:!0,published:g,unpublished:!g,highlighted:!!o}),relative:!0,bgcolor:n?"blue500":s,maxh:40,minh:40,pt:4,ph:8,bradiuss:!0,overflow:"hidden",children:e.jsxs(i,{w:"100%",flex:!0,row:!0,children:[e.jsx(i,{mt:3,mr:3,flex:!0,gap:3,id:"flags",children:_.map(S=>{const y=JI(S,h),C=e.jsx(ns,{size:"xsmall",iconName:S,color:x});return y?e.jsx(Ae,{placement:"top",content:y,children:C},S):e.jsx(i,{children:C},S)})}),e.jsxs(i,{w:"100%",flex:!0,column:!0,children:[e.jsx(i,{flex:!0,column:!0,id:"time",children:e.jsx(j,{noWrap:!0,variant:"captions",color:x,children:E})}),e.jsxs(i,{flex:!0,gap:3,alignItemsCenter:!0,children:[a.note&&e.jsx(ns,{size:"xsmall",iconName:"ShiftNotes",color:x}),e.jsx(j,{noWrap:!0,variant:"captions",color:x,children:c?c.name:"â"})]})]})]})})},hd=28,XI=({dragData:t})=>{const s=r.useRef(null),[n,o]=Do(()=>({rotate:0,config:{tension:180,friction:14}}));return r.useEffect(()=>{const a=c=>{if(s.current!==null){const u=c.clientX-s.current,h=Math.max(-hd,Math.min(hd,-u*.6));o.start({rotate:-h})}s.current=c.clientX},l=()=>{o.start({rotate:0}),s.current=null};return window.addEventListener("mousemove",a),window.addEventListener("mouseup",l),()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",l)}},[o]),e.jsx("div",{className:"CanvasShiftDragOverlay__wrapper",children:e.jsx(bn.div,{style:{transformOrigin:"top center",rotate:n.rotate.to(a=>`${a}deg`)},children:e.jsx(lp,{shiftId:t.shiftId})})})},{cx:QI}=O("CanvasLockOverlay"),ZI=({locked:t})=>t?e.jsx(i,{className:QI(),"aria-hidden":!0,absolute:!0,top:0,left:0,w:"100%",h:"100%"}):null,e0={tension:140,friction:22},t0={tension:175,friction:22},s0=({isCollapsing:t,isExpanding:s,children:n})=>{const o=r.useRef(null),[a,l]=Do(()=>({height:s?0:"auto",opacity:s?0:1}));return r.useLayoutEffect(()=>{const c=o.current?.offsetHeight??0;t?(l.set({height:c}),l.start({to:{height:0,opacity:0},config:t0})):s?l.start({from:{height:0,opacity:0},to:{height:c,opacity:1},config:e0}):l.set({height:"auto",opacity:1})},[t,s,l]),e.jsx(bn.div,{style:{...a,overflow:"hidden",contain:"layout paint"},children:e.jsx("div",{ref:o,children:n})})},{cx:n0}=O("AgentCopyPasteModeOverlay"),r0=()=>{const t=X(),s=r.useCallback(()=>{t(Pu())},[t]),n=r.useCallback(o=>{o.key==="Escape"&&s()},[s]);return r.useEffect(()=>(po().addEventListener("keydown",n),()=>po().removeEventListener("keydown",n)),[n]),e.jsx("div",{className:n0(),children:e.jsx(dt,{variant:"info",title:p("schedule_builder.copy_mode_banner.alert.title"),action:e.jsx(V,{variant:"secondary",onClick:s,size:"small",children:p("schedule_builder.copy_mode_banner.alert.exit")}),children:p("schedule_builder.copy_mode_banner.alert.desc")})})},o0=r.memo(r0),md={zIndex:999},ip=({cx:t,open:s,children:n,customStyle:o={},showArrow:a=!1,stickToViewport:l=!1,...c})=>{const[u,h]=r.useState(null),m=r.useMemo(()=>{let _;a&&(_={arrow:{enabled:!0,element:u}});let f;return l&&(f={preventOverflow:{enabled:!0,boundariesElement:"viewport"}}),_||f?{..._,...f}:null},[a,l,u]);return e.jsx(Ev,{open:s,style:{...md,...o},modifiers:m,...c,className:t(),children:({TransitionProps:_})=>e.jsxs(e.Fragment,{children:[a&&e.jsx(Qc,{in:!0,..._,timeout:200,children:e.jsx("div",{id:"arrow",ref:h,style:md})}),e.jsx(Qc,{in:!0,..._,timeout:200,children:e.jsx("div",{children:n})})]})})};ip.propTypes={customStyle:d.object,open:d.bool.isRequired,children:d.node.isRequired,cx:d.func.isRequired};const zn=Mg("Popper",ip),a0=({shiftId:t,onCancel:s,isSubmitting:n,isValid:o})=>{const a=K(),l=r.useCallback(()=>{a(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:t?"edit_shift_modal":"add_shift_modal"}),s?.()},[s,a,t]),c=t?[{variant:"secondary",onClick:l,label:p("schedule_builder.shift_form.cancel")},{variant:"primary",type:"submit",isLoading:n,disabled:!o,label:p("schedule_builder.shift_form.cta_save")}]:[{variant:"primary",type:"submit",isLoading:n,disabled:!o,label:p("schedule_builder.common.add_shift_button")},{variant:"tertiary",onClick:l,label:p("schedule_builder.shift_form.cancel")}];return e.jsx(fr,{buttons:c})},l0=({name:t,value:s,onChange:n,selectedShift:o,disabled:a})=>e.jsx(ha,{name:t,value:s,onChange:n,selectedShift:o,interval:15,i18nFromLabel:null,i18nToLabel:null,fromError:null,toError:null,disabled:a,divider:!1}),to=t=>t?lo.V1:lo.V2,cp=t=>t?lo.ROLE_V1:lo.ROLE_V2,i0=(t,s,n)=>{if(!n){const o=["green2","green3"],a=["orange"];o.includes(s)&&(s="green"),a.includes(s)&&(s="orange2")}return t===s},{cxEl:pd}=O("ColorPicker"),c0=({isColorMappingV1:t,popupState:s,selected:n})=>e.jsxs(i,{"data-testid":"color-picker-button",spacebetween:!0,vcenter:!0,w:80,className:pd("trigger"),..._o.bindTrigger(s),children:[e.jsx(i,{"data-testid":"color-selected",style:{borderRadius:"50%"},h:30,w:30,bradiuss:!0,className:pd(`${to(t)}--${n}`)}
1),e.jsx(Q,{size:"xsmall",iconName:"CaretDown",color:"mono700"})]}),{cxEl:Fa}=O("ColorPicker"),d0=({isColorMappingV1:t,selected:s,onChange:n,onClose:o})=>{const[a,l]=t?[Yl,Pg]:[Jl,$g],c=r.useMemo(()=>a.map(u=>({value:u,onClick:()=>{n(u),o()}})),[a,n,o]);return e.jsx(i,{className:Fa("list"),children:c.map(({value:u,onClick:h})=>e.jsx(Ae,{placement:"top",content:`${fu(l[u])}`,children:e.jsx(i,{className:`${Fa(`${to(t)}`)} ${Fa(`${to(t)}--${u}`)}`,h:30,w:30,bradiuss:!0,onClick:h,vcenter:!0,hcenter:!0,dataTestId:`${to(t)}--${u}`,children:i0(u,s,t)&&e.jsx(Q,{iconName:"Success",color:"mono0"})},u)},u))})},{cx:u0}=O("ColorPicker"),Ui=({isColorMappingV1:t,onChange:s,value:n,name:o,onDropdownClick:a,disabled:l})=>{const c=r.useRef(),u=r.useCallback(m=>{s({target:{name:o,value:m}})},[o,s]),h=r.useCallback(()=>{a&&a()},[a]);return e.jsx(i,{className:u0(),relative:!0,ref:c,children:e.jsx(yv,{variant:"popover",popupId:"color-picker",children:m=>e.jsxs(e.Fragment,{children:[e.jsx(c0,{popupState:m,selected:n,isColorMappingV1:t,disabled:l}),!l&&e.jsx(Wm,{..._o.bindPopover(m),anchorEl:c.current,anchorOrigin:{vertical:"bottom",horizontal:"left"},disableScrollLock:!0,onEnter:h,children:e.jsx(d0,{isColorMappingV1:t,selected:n,onChange:u,onClose:m.close})})]})})})};Ui.propTypes={isColorMappingV1:d.bool.isRequired,onChange:d.func.isRequired,value:d.oneOf(Yl.concat(Jl)).isRequired,name:d.string.isRequired,onDropdownClick:d.func,disabled:d.bool};const{cx:h0}=O("EmployeeSelectInput"),m0={label:p("schedule_builder.react_page.open_shifts.label"),value:Js},p0=({name:t,value:s,onChange:n,onOpen:o,disabled:a})=>{const l=I(To),[,,{setValue:c}]=$u(t),u=r.useCallback(m=>{if(!m?.target?.value){c(Js),n?.({...m,target:{...m?.target,name:t,value:Js}});return}n?.(m)},[t,n,c]),h=r.useMemo(()=>l.map(m=>({label:`${m.first_name?.trim()||""} ${m.last_name?.trim()||""}`.trim(),value:m.job_id})).sort((m,_)=>m.label.localeCompare(_.label)),[l]);return e.jsx(ma,{className:h0(),component:"SelectInput",name:t,onChange:u,onOpen:o,value:s,hideClear:!s,options:[...h,m0],placeholder:p("schedule_builder.shift_form.select_employee"),disabled:a})},_0=r.memo(p0);var Wa={},_d;function f0(){return _d||(_d=1,(function(t){var s=Iv();Object.defineProperty(t,"__esModule",{value:!0}),t.usePopupState=c,Object.defineProperty(t,"anchorRef",{enumerable:!0,get:function(){return l.anchorRef}}),Object.defineProperty(t,"bindTrigger",{enumerable:!0,get:function(){return l.bindTrigger}}),Object.defineProperty(t,"bindContextMenu",{enumerable:!0,get:function(){return l.bindContextMenu}}),Object.defineProperty(t,"bindToggle",{enumerable:!0,get:function(){return l.bindToggle}}),Object.defineProperty(t,"bindHover",{enumerable:!0,get:function(){return l.bindHover}}),Object.defineProperty(t,"bindFocus",{enumerable:!0,get:function(){return l.bindFocus}}),Object.defineProperty(t,"bindMenu",{enumerable:!0,get:function(){return l.bindMenu}}),Object.defineProperty(t,"bindPopover",{enumerable:!0,get:function(){return l.bindPopover}}),Object.defineProperty(t,"bindPopper",{enumerable:!0,get:function(){return l.bindPopper}});var n=s(Tv()),o=s(wv()),a=Lb(),l=vv();if(!a.useState)throw new Error("React.useState (added in 16.8.0) must be defined to use the hooks API");function c(u){var h=u.parentPopupState,m=u.popupId,_=u.variant,f=u.disableAutoFocus,g=(0,a.useState)(l.initCoreState),b=(0,o.default)(g,2),x=b[0],E=b[1];return(0,a.useEffect)(function(){if(!f&&m&&(typeof document>"u"?"undefined":(0,n.default)(document))==="object"){var S=document.getElementById(m);S&&S.focus()}},[m,x.anchorEl]),(0,a.useMemo)(function(){return(0,l.createPopupState)({state:x,setState:E,parentPopupState:h,popupId:m,variant:_,disableAutoFocus:f})},[x,E,h,m,_,f])}})(Wa)),Wa}var b0=f0();const{cxEl:g0}=O("RolePicker"),dp=({isTeam:t,label:s,employeeName:n,wage:o})=>{const a=r.useMemo(()=>t&&n,[t,n]),l=r.useMemo(()=>({column:!0,mb:a?10:"initial"}),[a]);return e.jsxs(Zr,{...l,children:[e.jsx(Zr,{bg:"primary050",ph:15,pb:1,children:e.jsx(Y,{className:g0("label"),fs12:!0,color:Xl.neutral600,children:s?.toUpperCase()})}),a?e.jsx(Zr,{mh:15,mt:6,children:e.jsx(Y,{"gray-dark":!0,fs14:!0,children:Bu({name:n,wage:o})})}):null]})};dp.propTypes={isTeam:d.bool.isRequired,label:d.string.isRequired,employeeName:d.string.isRequired,wage:d.number};const Hi=({wage:t,label:s})=>e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:s}),e.jsx(Bg,{displayType:"text",value:t,prefix:"$",thousandSeparator:!0,fixedDecimalScale:!0,decimalScale:2})]});Hi.propTypes={label:d.string.isRequired,wage:d.number.isRequired};const{cx:fd}=O("RolePicker"),Fi=({label:t,optionValue:s,value:n})=>{const o=r.useCallback(a=>`${a===n?fd("selected"):""} ${fd("inbuilt")}`,[n]);return e.jsx(Y,{className:o(s),children:t})};Fi.propTypes={label:d.string.isRequired,optionValue:d.string,value:d.string};const{cx:x0,cxEl:bd}=O("RolePicker"),up=({name:t,value:s,optionValue:n,children:o,onChange:a,isEmployee:l,isInbuilt:c,color:u,id:h,isColorMappingV1:m})=>{const _=r.useCallback(()=>{a({target:{name:t,value:n,color:u,id:h}})},[a,t,n,u,h]),f=r.useMemo(()=>`${bd("hover")} ${c?"":bd("role")} ${n===s?x0("selected"):""} ${cp(m)}`,[m,n,s,c]),g=r.useMemo(()=>({h:44,ph:15,pointer:!0,spacebetween:l,vcenter:!0}),[l]);return e.jsx(i,{onClick:_,className:f,...g,children:o})};up.propTypes={name:d.string.isRequired,color:d.string,optionValue:d.string,value:d.string,onChange:d.func.isRequired,isEmployee:d.bool.isRequired,isInbuilt:d.bool.isRequired,isColorMappingV1:d.bool.isRequired};const{cxEl:Va}=O("RolePicker"),ba=({color:t,label:s,isColorMappingV1:n,showColor:o})=>o?e.jsxs(e.Fragment,{children:[e.jsx(i,{h:18,w:22,className:Va(`${cp(n)}--${t}`),mr:10}),e.jsx(j,{className:Va("role-label"),children:s})]}):e.jsx(j,{className:Va("role-label"),children:s});ba.defaultProps={showColor:!0};ba.propTypes={color:d.string.isRequired,label:d.string.isRequired,isColorMappingV1:d.bool.isRequired,showColor:d.bool};const hp=({color:t,value:s,label:n,optionValue:o,wage:a,isInbuilt:l,isEmployee:c,name:u,onChange:h,isColorMappingV1:m,id:_})=>{const f=()=>c?e.jsx(Hi,{wage:a,label:n}):l?e.jsx(Fi,{label:n,optionValue:o,value:s}):e.jsx(ba,{color:t,label:n,isColorMappingV1:m});return e.jsx(up,{name:u,value:s,optionValue:o,onChange:h,isEmployee:c,isInbuilt:l,color:t,id:_,isColorMappingV1:m,children:f()})};hp.propTypes={color:d.string,label:d.string.isRequired,optionValue:d.oneOfType([d.string,d.oneOf([null])]),value:d.string,wage:d.number,onChange:d.func.isRequired,isInbuilt:d.bool.isRequired,isTeam:d.bool,isEmployee:d.bool.isRequired,name:d.string.isRequired};const mp=({type:t,options:s,label:n,employeeName:o,defaultWage:a,value:l,onCh
1ange:c,name:u,isColorMappingV1:h})=>{const m=r.useMemo(()=>t===Ss,[t]),_=r.useMemo(()=>t===vn,[t]),f=r.useMemo(()=>t===Uo,[t]);return(m?m&&!!s.length:!0)?e.jsxs(i,{minw:260,maxw:350,children:[_?null:e.jsx(dp,{label:n,employeeName:o,wage:a,isTeam:m}),s.map(({color:b,label:x,value:E,wage:S,id:y})=>e.jsx(hp,{name:u,value:l,color:b,label:x,optionValue:E,wage:S,onChange:c,isInbuilt:_,isEmployee:f,isTeam:m,isColorMappingV1:h,id:y},E))]}):null};mp.propTypes={type:d.oneOf([Uo,Ss,vn]).isRequired,options:d.array.isRequired,value:d.string,label:d.string,name:d.string.isRequired,employeeName:d.string.isRequired,onChange:d.func.isRequired,defaultWage:d.number};const{cx:gd,cxEl:Gt}=O("RolePicker"),C0=r.forwardRef(({name:t,value:s,onChange:n,onColorChange:o,disabled:a,onDropdownClick:l})=>{const c=r.useRef(null),u=r.useRef(null),h=b0.usePopupState({variant:"popover",popupId:"agent-role-picker"}),[m,_]=r.useState(!1),[f,g]=r.useState(""),[b,x]=r.useState(""),E=I(Ho),S=I(Uu),y=I(N=>ks(N)===1),C=r.useMemo(()=>{const N=b.trim().toLowerCase();return E.filter(H=>!H.archived_at).filter(H=>H.name.toLowerCase().includes(N)).map(H=>({value:H.name,label:H.name,color:Fo(H),id:H.id}))},[E,b]),v=r.useMemo(()=>[[vn,{options:Ug(S,y)}],[Ss,{options:C,label:Hu}]],[C,S,y]),T=b.trim()!==""&&C.length===0,D=r.useCallback(()=>{x(""),l&&l()},[l]),L=r.useCallback(N=>x(N.target.value),[]),A=r.useCallback(()=>{u.current?.focus()},[]),P=r.useCallback(N=>{if(N?.target?.value===br){h.close(),g(""),_(!0);return}N?.target?.color&&o(N.target.color),n(N),N.target.tagName!=="INPUT"&&h.close()},[n,o,h]),M=r.useCallback(N=>g(N.target.value),[]),R=r.useCallback(()=>{const N=f.trim();N&&n({target:{name:t,value:N}}),_(!1)},[f,t,n]),$=r.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),R()):N.key==="Escape"&&_(!1)},[R]),B=r.useCallback(()=>{_(!1)},[]),W=r.useCallback(N=>N.preventDefault(),[]);if(m){const N=f.trim();return e.jsxs(i,{className:gd(),relative:!0,children:[e.jsxs(i,{className:Gt("popup-trigger"),spacebetween:!0,vcenter:!0,children:[e.jsx("input",{className:Gt("role-input"),name:t,value:f,autoFocus:!0,maxLength:255,placeholder:br,onChange:M,onBlur:R,onKeyDown:$}),e.jsx(i,{className:Gt("clear"),onMouseDown:W,onClick:B,ph:2,role:"button","aria-label":p("actions.clear"),children:e.jsx(Q,{size:"xsmall",iconName:"Clear",color:"mono700"})})]}),N&&e.jsx(i,{className:Gt("create-suggestion"),children:e.jsx(i,{className:Gt("create-option"),onMouseDown:W,onClick:R,role:"button",children:e.jsx(j,{asHTML:!0,children:p("roles_select.add_new",{props:{name:N}})})})})]})}return e.jsxs(i,{dataTestId:"role-picker-selected",className:gd(),ref:c,relative:!0,children:[e.jsxs(i,{className:Gt("popup-trigger",{disabled:a}),spacebetween:!0,vcenter:!0,...a?{}:_o.bindTrigger(h),children:[e.jsx("input",{ref:u,className:Gt("role-input"),value:h.isOpen?b:s??"",placeholder:s||p("schedule_builder.shift_form.select_role"),disabled:a,"aria-label":p("schedule_builder.shift_form.search_roles_aria"),onChange:L}),e.jsx(Q,{size:"xsmall",iconName:"CaretDown",color:"mono700"})]}),e.jsx(Wm,{..._o.bindPopover(h),anchorOrigin:{vertical:"bottom",horizontal:"left"},anchorEl:c.current,PaperProps:{className:Gt("paper")},disableScrollLock:!0,disableAutoFocus:!0,disableEnforceFocus:!0,TransitionProps:{onEnter:D,onEntered:A},children:e.jsxs(i,{className:Gt("list-scroll"),children:[v.map(([N,{label:H,defaultWage:q,options:G}])=>e.jsx(mp,{type:N,options:G,label:H,employeeName:"",defaultWage:q,value:s,onChange:P,name:t,isColorMappingV1:y},N)),T&&e.jsx(i,{className:Gt("no-matching"),children:e.jsx(j,{color:"mono700",children:p("schedule_builder.shift_form.no_matching_roles")})})]})})]})}),El={CUSTOM:"custom"};p("schedule_builder.react_page.shift_form.add_shift");p("schedule_builder.react_page.shift_form.current");p("schedule_builder.react_page.shift_form.notes");p("schedule_builder.react_page.shift_form.approvals");p("schedule_builder.react_page.shift_form.time_off");const xd="schedule_builder.react_page.availability_block",E0=72,S0=({shiftDate:t})=>{const s=Wo(),n=Hg(),o=K(),a=s.values.note,[l,c]=r.useState(()=>!!a),u=Vo(t),h=I(Fu),m=I(S=>Ko(S,{shiftNoteQuotaId:u})),_=I(Wu),f=I(S=>io({state:S,attribute:"used",id:u}))||0,g=I(S=>io({state:S,attribute:"allowed",id:u}))||0,b=g&&f<g,x=r.useCallback(()=>{c(!0)},[]),E=r.useCallback(()=>{o(w.LINK_CLICKED,k.CLICK,{linkText:"upgrade now"}),n(Vu({billingFrequency:Ql.monthly,workflowSource:"paywall_modal"}))},[n,o]);return h?e.jsxs(e.Fragment,{children:[l&&e.jsxs(i,{mb:8,children:[e.jsx(i,{mb:8,children:e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.shift_form.shift_notes_label")})}),m?e.jsxs(e.Fragment,{children:[e.jsx(yo,{placeholder:p("schedule_builder.shift_form.shift_notes_placeholder"),textArea:!0,textAreaHeight:E0,name:"note",dataTestId:Cs.NOTES,value:a,onChange:s.handleChange}),!!b&&e.jsxs(i,{row:!0,mt:8,alignItemsCenter:!0,children:[e.jsx(i,{mr:3,children:e.jsx(j,{variant:"bodySm",children:p("schedule_builder.shift_form.notes.limit_warning",{props:{used:f,allowed:g}})})}),e.jsx(Mi,{size:"small",children:p("schedule_builder.shift_form.notes.limit_warning_cta")})]})]}):e.jsxs(dt,{variant:"info",title:p("schedule_builder.shift_form.notes.paywall_title"),children:[e.jsx(j,{variant:"bodySm",children:p("schedule_builder.shift_form.notes.paywall_desc",{props:{tier:Ir(_?.get("name"))}})}),e.jsx(i,{tright:!0,children:e.jsx(Nt,{size:"small",onClick:E,children:p("schedule_builder.shift_form.notes.cta")})})]})]}),!l&&e.jsxs(i,{mt:16,flex:!0,gap:8,onClick:x,pointer:!0,ml:12,alignItemsCenter:!0,children:[e.jsx(Q,{color:"accent",size:"small",iconName:"Add"}),e.jsx(j,{variant:"bodySmBold",color:"accent",children:p("schedule_builder.shift_form.add_shift_notes")})]})]}):null},j0="calc(min(736px, 90vh) - 150px)",y0=24,pp=({handleCancel:t,handleEmployeeSelection:s,isSubmitting:n,isValid:o,roleId:a,selectedShift:l,setCommonShift:c,setFieldValue:u,shiftId:h,startOfWeek:m,disabled:_,jobId:f,isOpenShift:g,isAssignedShift:b,currentShiftDate:x})=>{const{rangeType:E}=ze(),S=Io(),y=I(A=>ks(A)===1),C=r.useCallback(()=>{c&&c(In)},[c]),v=r.useCallback(A=>{u("color",A),C()},[C,u]),T=r.useMemo(()=>{const A=!!h,P=!!a,M=E===J.month||E===J.custom;return A||P||M},[h,a,E]),D=!!a&&!h,L=r.useCallback(A=>{u(A.target.name,{from:A.target.value.from,to:A.target.value.to}),C()},[C,u]);return e.jsx(Qs,{children:e.jsxs(i,{flex:!0,column:!0,h:"100%",children:[e.jsxs(i,{grow:1,maxh:j0,overflowY:"auto",scrollY:!0,pt:y0,children:[T&&!g&&e.jsx(i,{mb:12,alignItemsCenter:!0,justifyContentSpaceBetween:!0,flex:!0,children:e.jsx(i,{w:"100%",children:e.jsx(Ct,{as:_0,name:"owner",onChange:s,disabled:_,jobId:f})})}),e.jsxs(i,{children:[e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.shift_form.time_range")}),e.jsx(i,{grow:1,mt:8,mb:12,children:e.jsx(Ct,{as:l0,name:"shiftTimes",selectedShift:l,onChange:L,disabled:_})})]}),e.jsxs(i,{mb:12,children:[e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.shift_form.role")}),e.jsxs(i,{mt:8,row:!0,spacebetween:!0,children:[e.jsx(i,{mr:8,grow:1,children:e.jsx(Ct,{as:C0,name:"roleName",disabled:D||_,onColorChange:v})}),e.jsx(Ct,{as:Ui,name:"color",isColorMappingV1:y,disabled:_})]})]}),e.jsxs(i,{mb:12,children:[e.jsx(i,{mb:8,children:e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.shift_form.apply_to")})}),e.jsx(i,{grow:1,children:e.jsx(Ct,{name:"days",children:({field:A})=>e.jsx(Vm,{name:A.name,value:A.value,startOfWeek:m,onChange:A.onChange,disabled:_,embedded:S})})})]})]}),b&&e.jsx(S0,{shiftDate:x}),e.jsx(i,{mt:16,children:e.jsx(a0,{shiftId:h,onCancel:t,isSubmitting:n,isValid:o&&!_})})]})})},_p=({employeeName:t,userAvatar:s,scheduleAvailabilities:n})=>{const o=Zl(t),a=r.useMemo(()=>kl(s),[s]);return t?e.jsxs(i,{row:!0,vcenter:!0,children:[e.jsx(Un,{size:"large",image:a,initials:o}),e.jsxs(i,{ml:8,ellipsis:!0,maxw:400,children:[e.jsx(j,{variant:"heading2",color:"mono900",children:t}),e.jsx(i,{column:!0,children:n?.map(({id:l,title:c,startAt:u,endAt:h,allDay:m,job:{id:_}})=>{const f=p(`${xd}.${c?.toLowerCase()}`),g=m?p(`${xd}.whole_day`):Ut(u,h);return e.jsx("div",{children:e.jsx(j,{variant:"captions",children:`${f}: ${g}`})},`jobAvailability-${_}-${l}`)})})]})]}):null},{cx:v0}=O("ShiftFormAdd"),I0=({currentShiftDate:t,employeeName:s,initialValues:n,isRoleOrDepartment:o,onClose:a,rangeType:l,roleId:c,scheduleAvailabilities:u,selectedShift:h,setCommonShift:m,isOpenShift:_,setFormikValues:f,setTab:g,startOfWeek:b,submitShift:x,tab:E=El.CUSTOM,tabs:S,userAvatar:y,jobId:C,isAssignedShift:v})=>{const T=r.useCallback(()=>{},[]),D=r.useCallback((L,A)=>{g?.(A)},[g]);return e.jsxs(i,{className:v0(),w:"100%",children:[s&&e.jsx(_p,{employeeName:s,userAvatar:y,scheduleAvailabilities:u}),l!==J.month&&S&&e.jsx(i,{bbw:1,bcolor:"mono300",mb:15,children:e.jsx(i,{w:"fit-content",children:e.jsx(Fg,{options:S,tabValue:E,onChange:D})})}),E===El.CUSTOM&&e.jsx(Ht,{onSubmit:x,initialValues:{...n,...C&&{owner:C}},validateOnMount:!0,children:L=>(f?.(L.values),e.jsx(pp,{...L,currentShiftDate:t,handleCancel:a,handleEmployeeSelection:T,isMobile:!1,isRoleOrDepartment:o,selectedShift:h,setCommonShift:m,startOfWeek:b,roleId:c,jobId:C,isOpenShift:_,isAssignedShift:v}))})]})},T0=({open:t,shiftId:s,loading:n=!1,onCancel:o,onConfirm:a})=>{const l=K();r.useEffect(()=>{t&&l(w.MODAL_VIEWED,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,modal_source:"delete_shift_
1confirmation",shift_id:s})},[t,s,l]);const c=r.useCallback(()=>{l(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"cancel_delete_shift",button_text:"No",shift_id:s}),o()},[o,s,l]),u=r.useCallback(()=>{l(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"confirm_delete_shift",button_text:"Yes, Delete",shift_id:s}),a()},[a,s,l]);return e.jsx(Mt,{open:t,onClose:c,noPadding:!0,width:611,hideCloseIcon:!0,children:()=>e.jsxs(i,{flex:!0,column:!0,justifyContentEnd:!0,alignItemsEnd:!0,w:611,borderbox:!0,pt:16,pr:16,pb:24,pl:16,gap:16,bradiusl:!0,children:[e.jsx(i,{flex:!0,justifyContentEnd:!0,w:"100%",children:e.jsx(Q,{iconName:"Close",size:"medium",color:"purple500",onClick:c,alt:p("schedule_builder.actions.close"),screenReadable:!0,dataTestId:"close-delete-shift-dialog"})}),e.jsx(i,{w:"100%",pl:24,borderbox:!0,children:e.jsx(j,{variant:"heading2",color:"mono900",children:"Delete shift"})}),e.jsx(i,{w:"100%",pl:24,borderbox:!0,children:e.jsx(j,{variant:"body",color:"mono900",children:"Are you sure?"})}),e.jsxs(i,{flex:!0,justifyContentEnd:!0,gap:12,w:"100%",pr:24,borderbox:!0,children:[e.jsx(V,{type:"button",variant:"secondary",onClick:c,disabled:n,children:"No"}),e.jsx(V,{type:"button",variant:"primary",onClick:u,isLoading:n,disabled:n,children:"Yes, delete"})]})]})})},{cx:w0}=O("ShiftFormEdit"),D0=({currentShiftDate:t,employeeName:s,hasTimecard:n,initialValues:o,isRoleOrDepartment:a,onClose:l,onCopy:c,rangeType:u,roleId:h,scheduleAvailabilities:m,setFormikValues:_,shiftId:f,startOfWeek:g,updateShift:b,syncError:x,isOpenShift:E,isAssignedShift:S,userAvatar:y,setReassignmentCardSelected:C,handleDelete:v})=>{const T=r.useCallback(()=>{c?.(f),l()},[c,l,f]);return e.jsxs(i,{className:w0(),children:[s&&e.jsx(_p,{employeeName:s,userAvatar:y,scheduleAvailabilities:m}),e.jsx(i,{absolute:!0,top:16,right:u===J.day?64:112,children:e.jsx(Ae,{placement:"top",content:p("actions.delete"),children:e.jsx(be,{onClick:v,icon:"Delete",destructive:!0,label:p("actions.delete"),disabled:n})})}),u!==J.day&&e.jsx(i,{absolute:!0,top:16,right:64,children:e.jsx(Ae,{placement:"top",content:p("actions.copy"),children:e.jsx(be,{onClick:T,icon:"Copy",label:p("actions.copy")})})}),x&&e.jsx(i,{mv:16,children:e.jsxs(i,{vcenter:!0,children:[e.jsx(Q,{iconName:"Info",size:"small",color:"error300",mr:5}),e.jsx(j,{variant:"bodySm",color:"error300",children:x})]})}),e.jsxs(i,{w:"100%",children:[n&&e.jsxs(i,{vcenter:!0,mv:20,children:[e.jsx(Q,{iconName:"Info",size:"small",color:"info300",mr:5}),e.jsx(j,{variant:"bodySm",color:"info300",children:p("schedule_builder.react_page.shift_form.disabled_state.shift_has_timecard")})]}),e.jsx(Ht,{onSubmit:b,initialValues:o,validateOnMount:!0,children:D=>(_?.(D.values),e.jsx(pp,{...D,employeeName:s,currentShiftDate:t,handleCancel:l,isMobile:!1,isRoleOrDepartment:a,shiftId:f,startOfWeek:g,roleId:h,isOpenShift:E,isAssignedShift:S,setReassignmentCardSelected:C,disabled:n}))})]})]})},{cx:k0}=O("ShiftFormContainer"),R0=({currentShiftDate:t,defaultTab:s,employeeName:n,handlerId:o,isAdding:a=!1,isOpenShift:l,rowType:c,isRoleOrDepartment:u,jobId:h,onClose:m,onShowTooltipForCopy:_,onShowTooltipForDelete:f,roleId:g,shiftId:b,startAt:x,endAt:E,roleName:S,userAvatar:y,color:C,hasTimecard:v,initialValues:T={},startOfWeek:D,scheduleAvailabilities:L,syncError:A,tabs:P})=>{const M=K(),R=X(),$=!a,{rangeType:B}=ze(),W=l?"open_shift":"assigned",N=c==="employee"&&!!h,H=I(Ee=>b?$o(Ee,b):void 0),q=H?.is_draft??c!=="employee",G=I(Ee=>h?Wg(Ee,{jobId:h}):void 0),re=G?Vg([G.first_name?.trim(),G.last_name?.trim()]).join(" "):n,ue=Kg({roleId:g,canvasShiftRoleId:H?.role_id??void 0,defaultRoleId:G?.default_role_id,isAdding:a,rowType:c}),je=I(Ee=>ue?Mu(Ee,{roleId:ue}):void 0),ce=I(Ho),oe=I(Ee=>ks(Ee)===1),ge=r.useMemo(()=>{const Ee=Zc(D??0);let Re={from:"09:00",to:"17:00"};H&&(Re={from:Ie(H.start_at).format("HH:mm"),to:Ie(H.end_at).format("HH:mm")});const Me=H?.color??Fo(je)??Bo(oe);return{days:[Ee.indexOf(dr(t))],shiftTimes:Re,roleName:je?.name??null,color:Me,owner:h??null,note:H?.note??"",...T}},[H,t,T,je,D,h,oe]),[te,Z]=r.useState(In),[ee,he]=r.useState(s||El.CUSTOM),[Ye,De]=r.useState(),[,Pe]=r.useState(!1),[ke,me]=r.useState(!1);r.useEffect(()=>{M(w.MODAL_VIEWED,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,modal_source:$?"shift_click":"add_shift_button",shift_type:W,shift_id:b})},[$,W,b,M]);const Fe=r.useCallback(Ee=>{Ee?.stopPropagation(),$||M(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:$?"edit_shift_modal":"add_shift_modal"}),m()},[$,m,M]),We=r.useCallback(async Ee=>{if(!Ee)return{roleId:null,ok:!0};const Re=ce.find(we=>we.name===Ee);if(Re)return{roleId:Re.id,ok:!0};const Me=await R(yc({name:Ee}));return yc.fulfilled.match(Me)?{roleId:Me.payload.id,ok:!0}:(R(oo({message:p("schedule_builder.react_page.shifts.error_message.unable_to_save"),type:"error"})),{roleId:null,ok:!1})},[R,ce]),Xe=r.useCallback(async Ee=>{const{days:Re,shiftTimes:Me,color:we,roleName:Ke,note:Qe}=Ee,{roleId:Ze,ok:et}=await We(Ke);if(!et)return;const tt=rl(so(t),ol(t));Re.forEach(st=>{const nt=tt[st],{startAt:Be,endAt:ve}=cl({date:nt,start:Me.from,end:Me.to});if(c==="employee"){h&&R(vc({job_uuid:h,start_at:Be,end_at:ve,role_uuid:Ze??void 0,color:we??void 0,note:Qe||void 0}));return}R(Da({role_id:Ze,start_at:Be,end_at:ve,color:we}))}),M(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"save_new_shift",button_text:"Save",shift_type:W}
1),m()},[R,m,t,We,c,h,W,M]),se=r.useCallback(async Ee=>{const{days:Re,shiftTimes:Me,color:we,roleName:Ke,owner:Qe,note:Ze}=Ee,{roleId:et,ok:tt}=await We(Ke);if(!tt)return;const st=rl(so(t),ol(t)),nt=Zc(D??0).indexOf(dr(t)),Be=!Qe||Qe===Js,ve=Be?void 0:Qe||h,xt=q||Be;Re.forEach(ne=>{const _e=st[ne],{startAt:xe,endAt:Ce}=cl({date:_e,start:Me.from,end:Me.to});if(ne===nt)if(xt){if(!q){R(mr({shiftId:b})),R(Da({role_id:et,start_at:xe,end_at:Ce,color:we}));return}R(dl({shiftId:b,role_id:et,start_at:xe,end_at:Ce,color:we}))}else R(ul({shiftId:b,...ve&&{job_uuid:ve},start_at:xe,end_at:Ce,role_uuid:et??void 0,color:we??void 0,note:Ze||void 0}));else R(xt?Da({role_id:et,start_at:xe,end_at:Ce,color:we}):vc({...ve&&{job_uuid:ve},start_at:xe,end_at:Ce,role_uuid:et??void 0,color:we??void 0,note:Ze||void 0}))}),M(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"save_shift_edit",button_text:"Save",shift_id:b}),m()},[R,m,b,t,We,q,h,D,M]),Ne=r.useCallback(()=>{M(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"delete_shift",button_text:"Delete",shift_id:b}),me(!0)},[b,M]),ye=r.useCallback(()=>{me(!1)},[]),Ve=r.useCallback(()=>{if(!b)return;R((q?wo:mr)({shiftId:b})),m()},[R,b,q,m]),$e=r.useCallback(()=>{b&&R(Ku(b))},[R,b]);return e.jsxs(e.Fragment,{children:[e.jsxs(i,{relative:!0,minh:"min(350px, 50vh)",maxh:"min(736px, 90vh)",p:20,className:k0(),bgcolor:"white",bradiusl:!0,shadow:"z3",maxw:500,minw:456,children:[e.jsx(i,{absolute:!0,top:16,right:16,zIndex:1,children:e.jsx(be,{onClick:Fe,icon:"Close",dataTestId:"close-agent-shift-modal",label:p("schedule_builder.actions.close")})}),e.jsxs(i,{mb:12,children:[l&&!b&&e.jsx(j,{variant:"heading2",color:"mono900",children:p("schedule_builder.react_page.shift_form.add_open_shift")}),b&&e.jsx(j,{variant:"heading2",color:"mono900",children:p("schedule_builder.react_page.shift_form.edit_shift")}),!l&&!b&&e.jsx(j,{variant:"heading2",color:"mono900",children:N&&re?p("schedule_builder.react_page.shift_form.add_to_employee",{props:{employeeName:re}}):p("schedule_builder.react_page.shift_form.add_to_schedule")})]}),e.jsx(i,{children:e.jsx(gn,{})}),$&&b&&e.jsx(D0,{currentShiftDate:t,employeeName:n,formikValues:Ye,handlerId:o,initialValues:ge,isRoleOrDepartment:u,jobId:h,onClose:m,onShowTooltipForCopy:_,onShowTooltipForDelete:f,rangeType:B,roleId:g,scheduleAvailabilities:L,setFormikValues:De,shiftId:b,startOfWeek:D,updateShift:se,syncError:A,color:C,roleName:S,startAt:x,endAt:E,isOpenShift:l,isAssignedShift:N,userAvatar:y,setReassignmentCardSelected:Pe,hasTimecard:v,handleDelete:Ne,onCopy:$e}),!$&&e.jsx(I0,{isOpenShift:l,isAssignedShift:N,currentShiftDate:t,employeeName:n,initialValues:ge,isRoleOrDepartment:u,rowType:c,jobId:h,onClose:m,rangeType:B,roleId:g,scheduleAvailabilities:L,selectedShift:te!==In?te:void 0,setCommonShift:Z,setFormikValues:De,setTab:he,startOfWeek:D,submitShift:Xe,tab:ee,tabs:P,userAvatar:y})]}),e.jsx(T0,{open:ke,shiftId:b,onCancel:ye,onConfirm:Ve})]})},L0=({isOpen:t,anchorEl:s,selectedDayIndex:n,startDate:o,rowType:a,roleId:l,jobId:c,shiftId:u,onClose:h,onShowTooltipForDelete:m})=>{const _=I(rs);if(!t||n===null)return null;const f=kt(o,n);return e.jsx(zn,{open:t,anchorEl:s,showArrow:!0,stickToViewport:!0,placement:"left-end",children:e.jsx(nn,{onClickAway:h,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsx(i,{shadow:"z3",bradiusm:!0,children:e.jsx(R0,{isAdding:!u,isOpenShift:a==="open",rowType:a,roleId:l,jobId:c,shiftId:u,onClose:h,onShowTooltipForDelete:m,currentShiftDate:f,startOfWeek:_})})})})},Sr=t=>t===0?"0":t.toFixed(2),Cd=t=>t===0?pt(0,{precision:0}):pt(t),{cx:A0,cxEl:O0}=O("WageTotalsBar"),N0=({startDate:t})=>{const s=I(ql),o=I(qu)==="pending",a=r.useMemo(()=>{const[c,u,h]=t.split("-").map(Number);return Array.from({length:7},(m,_)=>new Date(c,u-1,h+_).toISOString().slice(0,10))},[t]),l=r.useMemo(()=>{const c=new Map(a.map(m=>[m,{hours:0,wages:0,jobIdsWithHours:new Set,requesterHasWagePermission:null}]));s.forEach(m=>{const _=c.get(m.date);_&&(_.hours+=m.hours||0,_.wages+=m.wages||0,m.requester_has_wage_permission!=null&&(_.requesterHasWagePermission=m.requester_has_wage_permission),m.hours>0&&_.jobIdsWithHours.add(m.job_id))});const u=a.map(m=>{const _=c.get(m);return _?{date:m,hours:_.hours,wages:_.wages,employeesCount:_.jobIdsWithHours.size,requesterHasWagePermission:_.requesterHasWagePermission}:{date:m,hours:0,wages:0,employeesCount:0,requesterHasWagePermission:null}}),h=u.some(m=>m.requesterHasWagePermission===!0);return{dailyTotals:u,summary:{hours:u.reduce((m,_)=>m+_.hours,0),wages:u.reduce((m,_)=>m+_.wages,0),employeesCount:u.reduce((m,_)=>m+_.employeesCount,0),requesterHasWagePermission:h}}},[s,a]);return e.jsx(i,{className:A0(),maxh:ka,h:ka,minh:ka,bgcolor:"mono0",shadow:"z1",shadowDirection:"top",zIndex:11,children:e.jsxs(Hn,{className:O0("grid"),columnGap:0,rowGap:0,columns:{sm:Tr},children:[e.jsx(i,{blw:0,brw:1,bcolor:"mono100",flex:!0,alignItemsCenter:!0,ml:16,children:e.jsxs(i,{flex:!0,column:!0,w:"90%",justifyContentSpaceCenter:!0,children:[e.jsxs(i,{flex:!0,justifyContentSpaceBetween:!0,alignItemsCenter:!0,children:[e.jsx(j,{color:"mono500",variant:"captionBold",children:p("schedule_builder.agent.labor_totals.title")}
1),o?e.jsx(cs,{bradiusm:!0,width:"64px",height:"14px"}):e.jsx(j,{color:"mono700",variant:"captionBold",children:Cd(l.summary.wages)})]}),e.jsxs(i,{flex:!0,justifyContentSpaceBetween:!0,alignItemsCenter:!0,children:[e.jsx(j,{color:"mono500",variant:"captionBold",children:p("schedule_builder.agent.labor_totals.hours")}),o?e.jsx(cs,{bradiusm:!0,width:"64px",height:"14px"}):e.jsx(j,{variant:"captionBold",color:"mono500",children:Sr(l.summary.hours)})]})]})}),l.dailyTotals.map(({date:c,hours:u,wages:h,employeesCount:m},_)=>e.jsxs(i,{brw:1,bcolor:"mono100",column:!0,ph:4,gap:1,justifyContentCenter:!0,children:[e.jsxs(i,{color:"mono500",flex:!0,justifyContentSpaceBetween:!0,children:[e.jsxs(i,{alignItemsCenter:!0,flex:!0,gap:2,children:[e.jsx(zu,{iconName:"UserCircle",w:12}),o?e.jsx(cs,{bradiusm:!0,width:"16px",height:"12px"}):e.jsx(j,{variant:"captions",color:"mono500",children:m})]}),e.jsx(i,{children:o?e.jsx(cs,{bradiusm:!0,width:"56px",height:"12px"}):e.jsx(j,{color:"mono700",variant:"captionBold",children:Cd(h)})})]}),e.jsx(i,{justifyContentEnd:!0,children:o?e.jsx(cs,{bradiusm:!0,width:"56px",height:"12px"}):e.jsx(j,{variant:"captions",color:"mono500",children:Sr(u)})})]},`${c}-${_}`))]})})},fp=r.createContext(!1),M0=({readOnly:t,children:s})=>e.jsx(fp.Provider,{value:t,children:s}),rn=()=>r.useContext(fp),Fr="schedule_builder.react_page.events.form.delete_dialog",P0=({open:t,loading:s=!1,onCancel:n,onConfirm:o})=>{const a=K(),l=r.useCallback(()=>{a(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"edit_event_modal"}),n()},[n,a]),c=r.useCallback(()=>{a(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"delete_event",button_text:"Delete"}),o()},[o,a]);return e.jsx(Mt,{open:t,onClose:l,noPadding:!0,width:611,hideCloseIcon:!0,children:()=>e.jsxs(i,{flex:!0,column:!0,justifyContentEnd:!0,alignItemsEnd:!0,w:611,borderbox:!0,pt:16,pr:16,pb:24,pl:16,gap:16,bradiusl:!0,children:[e.jsx(i,{flex:!0,justifyContentEnd:!0,w:"100%",children:e.jsx(Q,{iconName:"Close",size:"medium",color:"purple500",onClick:l,alt:p("schedule_builder.actions.close"),screenReadable:!0,dataTestId:"close-delete-event-dialog"})}),e.jsx(i,{w:"100%",pl:24,borderbox:!0,children:e.jsx(j,{variant:"heading2",color:"mono900",children:p(`${Fr}.title`)})}),e.jsx(i,{w:"100%",pl:24,borderbox:!0,children:e.jsx(j,{variant:"body",color:"mono900",children:p(`${Fr}.body`)})}),e.jsxs(i,{flex:!0,justifyContentEnd:!0,gap:12,w:"100%",pr:24,borderbox:!0,children:[e.jsx(V,{type:"button",variant:"secondary",onClick:l,disabled:s,children:p(`${Fr}.cancel`)}),e.jsx(V,{type:"button",variant:"primary",onClick:c,isLoading:s,disabled:s,children:p(`${Fr}.confirm`)})]})]})})},Vt="schedule_builder.react_page.events.form",$0=({values:t,isValid:s,unlimited:n,allowed:o,used:a,onDelete:l,onClose:c,isHolidaySettingEnabled:u,loading:h,showHeaderDate:m,showDateField:_})=>{const{id:f,date:g,holiday:b}=t,x=!s,E=n||a<o||!!f;return e.jsx(Qs,{children:e.jsx(i,{className:"EventForm",children:E?e.jsxs(e.Fragment,{children:[e.jsxs(i,{mb:20,column:!0,children:[e.jsxs(i,{pb:8,mb:8,bbw:1,bs:"solid",bcolor:"mono300",row:!0,justifyContentSpaceBetween:!0,vcenter:!0,children:[e.jsx(j,{variant:"heading2",color:"mono900",children:p(`${Vt}.${f?"edit_title":"add_title"}`)}),e.jsxs(i,{flex:!0,gap:24,vcenter:!0,children:[f&&e.jsx(Q,{iconName:"Delete",size:"medium",color:"error",onClick:l,alt:p(`${Vt}.delete`),screenReadable:!0,dataTestId:"delete-agent-event"}),e.jsx(Q,{iconName:"Close",size:"medium",color:"purple500",onClick:c,alt:p("schedule_builder.actions.close"),screenReadable:!0,dataTestId:"close-agent-shift-modal"})]})]}),m&&g&&e.jsx(j,{variant:"heading3",color:"mono900",children:Ie(g).format("ddd, MMM D")})]}),!n&&e.jsx(i,{mb:20,p:12,bgcolor:"primary300",bradiusm:!0,children:e.jsxs(j,{variant:"body",color:"mono900",children:["Free Events: ",a,"/",o]})}),_&&e.jsx(i,{mb:16,children:e.jsx(Tn,{name:"date",label:p(`${Vt}.date`),hasAsterisk:!0,hideClearIcon:!0})}),e.jsx(i,{mb:16,children:e.jsx(Ct,{as:hr,name:"title",label:p(`${Vt}.title`),required:!0,hasAsterisk:!0})}),e.jsx(i,{mb:16,children:e.jsx(hr,{name:"description",label:p(`${Vt}.desc`),textArea:!0,minRows:2,maxRows:4})}),u&&e.jsx(i,{mb:20,row:!0,children:e.jsx(qg,{name:"holiday",value:b?"true":"false",label:e.jsx(e.Fragment,{children:e.jsxs(i,{column:!0,children:[e.jsx(i,{mb:1,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:p(`${Vt}.mark_as_holiday_label`)})}),e.jsxs(j,{variant:"body",color:"mono900",children:[p(`${Vt}.mark_as_holiday_desc`)," ",e.jsx(Nt,{href:"/settings/time_tracking/overtime",children:p(`${Vt}.settings`)})]})]})})})}),e.jsxs(i,{flex:!0,justifyContentEnd:!0,gap:12,children:[e.jsx(V,{type:"button",variant:"tertiary",onClick:c,disabled:h,children:p(`${Vt}.cancel`)}),e.jsx(V,{type:"submit",variant:"primary",isLoading:h,disabled:h||x,children:f?p(`${Vt}.save`):p(`${Vt}.add`)})]})]}):e.jsx(i,{p:20,textAlign:"center",children:e.jsx(j,{variant:"body",color:"mono700",children:"You've reached your free event limit. Upgrade to add more events."})})})})},bp=({id:t="",date:s="",title:n="",description:o="",holiday:a=!1,isHolidaySettingEnabled:l=!1,onClose:c,showDateField:u=!0})=>{const h=X(),m=K(),[_,f]=r.useState(!1),g=!!t;r.useEffect(()=>{m(w.MODAL_VIEWED,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,modal_source:g?"edit_event":"add_event",...g&&{event_id:t}}
1)},[g,t,m]);const b=s.length>0,x=I(Gu),E=!0,S=10,y=x.length,C=r.useCallback(({title:$,date:B})=>{const W={};return $?.trim()||(W.no_title=!0),!s&&!B&&(W.no_date=!0),W},[s]),v=r.useCallback($=>{const{id:B,...W}=$;h(zg(W)),c()},[h,c]),T=r.useCallback(({id:$,payload:B})=>{h(Gg({id:$,...B})),c()},[h,c]),D=r.useCallback(({id:$})=>{h(Yg({id:$})),c()},[h,c]),L=r.useCallback($=>{m(t?w.SAVE_EVENT_CTA_CLICKED:w.ADD_EVENT_CTA_CLICKED,k.CLICK),m(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"save_event",button_text:"Save",...t&&{event_id:t}}),t?T({id:t,payload:$}):v($)},[m,t,T,v]),A=r.useCallback(()=>{m(w.BUTTON_CLICKED,k.CLICK,{buttonText:Rn.DELETE}),m(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:"delete_event",button_text:"Delete",event_id:t}),f(!0)},[m,t]),P=r.useCallback(()=>{m(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_SHIFTS,element:g?"edit_event_modal":"add_event_modal"}),c()},[g,c,m]),M=r.useCallback(()=>{f(!1)},[]),R=r.useCallback(()=>{D({id:t})},[t,D]);return e.jsxs(e.Fragment,{children:[e.jsx(Ht,{validateOnMount:!0,initialValues:{id:t,date:s||ms(Je),title:n,description:o,holiday:a},onSubmit:L,validate:C,children:$=>e.jsx($0,{...$,unlimited:E,allowed:S,used:y,onDelete:A,onClose:P,isHolidaySettingEnabled:l,loading:!1,showHeaderDate:b,showDateField:u})}),e.jsx(P0,{open:_,loading:!1,onCancel:M,onConfirm:R})]})},B0=({open:t,startDate:s,selectedDayIndex:n,selectedEvent:o,onClose:a})=>{const l=kt(s,n);return e.jsx(Mt,{open:t,onClose:a,noPadding:!0,width:556,hideCloseIcon:!0,children:()=>e.jsx(i,{className:"EventDialog",flex:!0,column:!0,w:556,borderbox:!0,pt:24,pr:32,pb:32,pl:32,gap:24,bradiusl:!0,children:e.jsx(bp,{id:o?.id,date:l,title:o?.title,description:o?.description,holiday:o?.holiday,onClose:a,isHolidaySettingEnabled:!0})})})},Mr=({rangeStartOverride:t}={})=>{const s=I(it),n=I(Yu),o=s?.start,a=s?.end,l=t||o,c=r.useMemo(()=>n===J.month?Ie(l,Je).startOf("month"):Ie(o,Je),[o,l,n]),u=r.useMemo(()=>n===J.month?Ie(l,Je).endOf("month"):Ie(a,Je),[a,l,n]);return{rangeStartMoment:c,rangeEndMoment:u}},gp=(t,s=null,n=null)=>{switch(t){case J.month:return{startDate:Mb().format(Je),endDate:Nb().format(Je)};case J.week:return{startDate:fc().format(Je),endDate:_c().format(Je)};case J.day:{const o=ms(Je);return{startDate:o,endDate:o}}case J.custom:{const o=cr(s,n,"weeks");return{startDate:fc().format(Je),endDate:Ob(_c(),o).format(Je)}}}},{cx:U0,cxEl:H0}=O("Filters"),F0=({showEvents:t,onShowEventsChange:s})=>{const n=r.useRef(null),o=r.useCallback(()=>{s(!t)},[s,t]),a=r.useCallback(()=>{n?.current?.click()},[]),l=r.useMemo(()=>[{label:"Show events",value:"show_events"}],[]),c=r.useMemo(()=>{const m=[];return t&&m.push("show_events"),m},[t]),u=r.useMemo(()=>"",[]),h=r.useCallback(m=>{(m?.target?.value??[]).includes("show_events")!==t&&o()},[t,o]);return e.jsxs(i,{className:U0(),relative:!0,children:[e.jsx(i,{absolute:!0,l:0,r:0,style:{visibility:"hidden"},children:e.jsx(Qt,{ref:n,className:H0("select"),name:"agent-filters",dataTestId:"AgentFilters",uxElement:"agent_filters",startIcon:"Filter",placeholder:p(`${Yt}.placeholder`),options:l,multiple:!0,value:c,onChange:h,displayAsText:!0,menuMaxWidth:280})}),e.jsx(V,{variant:"secondary",size:"small",endIcon:"CaretDown",onClick:a,children:`${p(`${js}.filters`)}${u}`})]})},W0=()=>{const t=X(),s=I(_t),n=I(Bl),o=I(Pn),a=I(Ju),l=I(Lo),c=I(Xu),u=a||!!l,m=I(qo)==="succeeded",{handlePublish:_,isPublishing:f}=Bi(),g=r.useCallback(()=>{if(!(!s||f)){if(c){_();return}t(Mo(!0))}},[t,_,f,c,s]);return e.jsx(i,{mr:5,children:e.jsx(V,{variant:"primary",size:"small",onClick:g,isLoading:f,disabled:f||!m||!u||o||n===0,children:p("schedule_builder.agent.actions.publish",{props:{count:o?0:n}})})})},pe="schedule_builder.react_page.tools_menu",cn="schedule_builder.react_page.clear_schedule",V0=({featureName:t,rating:s,comments:n,categories:o})=>Eo(Jg(),{feature_feedback:{feature_name:t,rating:s,comments:n,categories:o}}),{cx:K0,cxEl:Ed}=O("ShareFeedback"),bs="schedule_builder.react_page.share_feedback_modal",Sd=5,jd=1,xp=({onCloseModal:t,onShowReadOnlyModal:s,title:n=`${bs}.share_feedback`,subtitle:o=`${bs}.feedback_subtitle`,question:a=`${bs}.feedback_question`,confirmText:l=`${bs}.share_feedback`,cancelText:c=`${bs}.cancel`})=>{const u=K({eventCategory:U.SCHEDULE_BUILDER_SHARE_FEEDBACK_MODAL}),[h,m]=r.useState(""),[_,f]=r.useState(null),[g,b]=r.useState(!1);r.useEffect(()=>{u(w.SHARE_FEEDBACK_MODAL_SHOWN,k.VIEW)},[]);const x=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{buttonText:p(l),rating:_}),b(!0);const{value:C}=Xg(h);V0({comments:C,featureName:Qg,rating:_}).then(()=>{b(!1),t(),s({text:p(`${bs}.thank_you`),persist:!1,timeoutDelay:3e3})}).catch(()=>{b(!1)})},[u,l,s,t,h,_]),E=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{buttonText:p(c),rating:_}),t()},[u,c,t,_]),S=r.useCallback(()=>f(Sd),[f]),y=r.useCallback(()=>f(jd),[f]);return e.jsxs(i,{column:!0,gap:16,className:K0({embedded:Sn()}),children:[e.jsx(j,{variant:"heading3",children:p(n)}),e.jsx(j,{variant:"bodySm",children:p(o)}),e.jsx(j,{variant:"bodyBold",children:p(a)}),e.jsxs(i,{vcenter:!0,hcenter:!0,row:!0,h:106,w:"100%",pv:12,gap:50,children:[e.jsx(i,{className:Ed("thumb",{active:_===Sd}),onClick:S,"data-testid":"icon-like",children:e.jsx(Q,{iconName:"Like",color:"primary700",size:"xlarge"})}),e.jsx(i,{className:Ed("thumb",{active:_===jd}),onClick:y,"data-testid":"icon-dislike",children:e.jsx(Q,{iconName:"Dislike",color:"primary700",size:"xlarge"})})]}),e.jsxs(i,{column:!0,gap:8,children:[e.jsx(j,{variant:"bodyBold",children:p(`${bs}.tell_us_more`)}),e.jsx(An,{type:"textarea",placeholder:p(`${bs}.comment_placeholder`),fontSize:"12px",value:h,onChange:m,valueOnChange:!0,focusOnMount:!0})]}),e.jsxs(i,{column:!0,gap:4,children:[e.jsx(V,{fullWidth:!0,variant:"primary",onClick:x,isLoading:g,disabled:!_,children:p(l)}),e.jsx(V,{fullWidth:!0,variant:"tertiary",onClick:E,disabled:g,children:p(c)})]})]})};xp.propTypes={onCloseModal:d.func.isRequired,onShowReadOnlyModal:d.func.isRequired,subtitle:d.string,question:d.string,confirmText:d.string,cancelText:d.string};const q0=F(null,{onShowReadOnlyModal:zo})(xp),Cp=({onClose:t,isOpen:s})=>{const n=K({eventCategory:U.SCHEDULE_BUILDER_MANAGE_YOUR_EXPERIENCE});r.useEffect(()=>{s&&n(w.MANAGE_YOUR_EXPERIENCE_MODAL_SHOWN,k.VIEW)},[s]);const o=r.useCallback(()=>
1{n(w.DISMISS_CLICKED,k.CLICK),t()},[n,t]);return e.jsx(Fn,{auto:!0,hideCloseIcon:!0,isOpen:s,onRequestClose:t,onDismiss:o,children:e.jsx(q0,{onCloseModal:t})})};Cp.propTypes={onClose:d.func.isRequired,isOpen:d.bool.isRequired};const Wi=r.memo(Cp),{cx:z0,cxEl:G0}=O("Tools"),Y0=({onAddEvent:t})=>{const s=X(),n=I(_t),o=I(Pn),a=I(Bl),l=r.useRef(null),c=o||a===0,[u,h]=r.useState(!1),m=K(),_=r.useCallback(()=>{t()},[t]),f=r.useCallback(()=>{c||s(Ul({startDate:n,scope:Hl.UNPUBLISHED_ONLY}))},[c,s,n]),g=r.useCallback(()=>{m(w.LINK_CLICKED,k.CLICK,{linkText:p(`${pe}.share_feedback`)}),h(!0)},[m]),b=r.useCallback(()=>{h(!1)},[]),x=r.useMemo(()=>[{label:p(`${pe}.add_event`),value:"add_event"},{label:p(`${pe}.delete_unpublished_changes`),value:"delete_unpublished",disabled:c},{divider:!0},{label:p(`${pe}.share_feedback`),value:"share_feedback"}],[c]),E=r.useCallback(y=>{const C=y?.target?.value;C&&(C==="add_event"&&_(),C==="delete_unpublished"&&f(),C==="share_feedback"&&g())},[_,f,g]),S=r.useCallback(()=>{l?.current?.click()},[]);return e.jsxs(i,{className:z0(),relative:!0,children:[e.jsx(i,{absolute:!0,l:0,r:0,style:{visibility:"hidden"},children:e.jsx(Qt,{ref:l,name:"agent-tools",dataTestId:"AgentTools",className:G0("select"),uxElement:"agent_tools",placeholder:p(`${pe}.tools`),options:x,onChange:E,displayAsText:!0,menuMaxWidth:300})}),e.jsx(be,{icon:"Settings",size:"small",label:p(`${pe}.tools`),dataTestId:"AgentToolsMenu",onClick:S}),e.jsx(Wi,{isOpen:u,onClose:b})]})},{cx:J0}=O("CanvasHeader"),X0=({showEvents:t,onShowEventsChange:s,onAddEvent:n})=>{const o=X(),a=Qu(),l=K(),c=I(it),u=I(Yu),{rangeStartMoment:h,rangeEndMoment:m}=Mr(),_=I(Pn),f=r.useCallback(()=>{o(Zu())},[o]),g=r.useCallback(y=>{o(Go(y))},[o]),b=r.useCallback(()=>{const y=gp(u,h,m);y&&g({rangeStart:y.startDate,rangeEnd:y.endDate}),l(w.TODAY_BUTTON_CLICKED,k.CLICK)},[g,m,h,u,l]),x=r.useCallback(()=>{g({rangeStart:h.clone().subtract(1,"week").format("YYYY-MM-DD"),rangeEnd:m.clone().subtract(1,"week").format("YYYY-MM-DD")})},[g,m,h]),E=r.useCallback(()=>{g({rangeStart:h.clone().add(1,"week").format("YYYY-MM-DD"),rangeEnd:m.clone().add(1,"week").format("YYYY-MM-DD")})},[g,m,h]),S=r.useMemo(()=>Zs(h,m),[m,h]);return c?e.jsx(wn.Toolbar,{filters:e.jsxs(i,{className:J0({small:!a}),row:!0,gap:"xs",vcenter:!0,grow:1,children:[e.jsx(V,{variant:"secondary",onClick:b,size:a?"medium":"small",children:p(`${js}.today`)}),e.jsxs(i,{row:!0,gap:"2xs",alignItemsCenter:!0,flex:!0,children:[e.jsx(be,{icon:"ChevronLeft",size:a?"medium":"small",dataTestId:"AgentHeader__left-button",label:p("schedule_builder.actions.previous_period"),onClick:x}),e.jsx(be,{icon:"ChevronRight",size:a?"medium":"small",dataTestId:"AgentHeader__right-button",label:p("schedule_builder.actions.next_period"),onClick:E}),e.jsx(j,{variant:"heading4",children:S}),e.jsx(wr,{variant:_?"success":"warning",children:_?"Published":"Draft"})]})]}),viewOptions:e.jsxs(i,{row:!0,gap:"sm",alignItemsCenter:!0,shrink:0,children:[e.jsx(F0,{showEvents:t,onShowEventsChange:s}),e.jsx(Y0,{onAddEvent:n})]}),actions:e.jsxs(i,{row:!0,gap:"sm",alignItemsCenter:!0,shrink:0,children:[e.jsx(W0,{}),e.jsx(i,{onClick:f,pointer:!0,children:e.jsx(ns,{iconName:"ScheduleBuilder",size:"large",color:"purple500"})})]})}):null},Q0=r.memo(X0),{cx:Z0,cxEl:eT}=O("ViewBy"),Wr="schedule_builder.react_page.view_by_select",tT={week:[{label:p(`${Wr}.first_name`),value:mt.firstName},{label:p(`${Wr}.last_name`),value:mt.lastName},{divider:!0},{label:p(`${Wr}.department`),value:mt.department},{label:p(`${Wr}.role`),value:mt.role}]},sT=()=>{const t=X(),s=K(),{rangeType:n,viewType:o}=ze(),a=r.useRef(null),l=I(Dr),c=I(T=>Yo(T,{name:"departments"})),u=I(eh),h=I(th),_=I(sh)??o,f=r.useMemo(()=>h===Lt.POSITION?mt.firstName:h,[h]),g=r.useMemo(()=>n===J.week?f:ts(gr),[n,f]);let b=_;_===de.department&&!c&&(b=de.employee),_===de.employee&&(b=g||mt.firstName);const[x,E]=r.useState(b);r.useEffect(()=>{u||E(b)},[u,b]);const S=r.useCallback(()=>{a?.current?.click()},[]),y=r.useCallback(T=>{const D=T.target.value;if(l&&n===J.week&&[mt.firstName,mt.lastName,mt.custom].includes(D)){const L=D===mt.custom?Lt.POSITION:D;t(Zg(L)),at(ex,L)}if(n===J.day&&(t(tx(D)),at(sx,D)),!c&&D===de.department){t(ei({minTier:"plus",feature:"departments",locationProperty:void 0,serverKey:void 0,mppFocusViewProps:{focusedFeature:"permissionAndDepartments"}}));return}t(Pu()),s(w.DROPDOWN_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,dropdown_selection:D,element:"schedule_sort"}),D==="first_name"||D==="last_name"?(t(hl(de.employee)),at(Ic,de.employee)):(D==="department"||D==="role"||D==="start_time")&&(t(hl(D)),at(Ic,D)),E(D)},[l,t,c,n,s]),C={first_name:"First Name",last_name:"Last Name",department:"Department",role:"Role"},v=r.useMemo(()=>{const T=tT;return T[n]||T.week},[n]);return e.jsx(i,{"data-testid":"agent-view-by",w:"100%",h:29,pl:12,alignItemsCenter:!0,justifyContentStart:!0,children:e.jsxs(i,{className:Z0(),relative:!0,children:[e.jsx(i,{absolute:!0,l:0,r:0,style:{visibility:"hidden"},children:e.jsx(Qt,{ref:a,className:eT("select"),name:"agent-view-by",dataTestId:"agent-view-by-select",onChange:y,options:v,value:x,displayAsText:!0,menuMaxWidth:280})}),e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",endIcon:"CaretDown",onClick:S,children:p("schedule_builder.agent.sort_by_label",{props:{value:C[x]}})})]})})},nT=r.memo(sT),rT=["mon","tue","wed","thu","fri","sat","sun"],oT=t=>p(`schedule_builder.agent.weekday_header.${t}`),aT=()=>{const t=I(_t),n=(o=>
1{if(!o)return rT.map(h=>({weekday:oT(h),dayNumber:""}));const[a,l,c]=o.split("-").map(Number),u=[];for(let h=0;h<7;h++){const m=new Date(a,l-1,c+h),_=m.toLocaleDateString("en-US",{weekday:"short"}),f=m.getDate();u.push({weekday:_.toUpperCase(),dayNumber:String(f)})}return u})(t);return e.jsxs(Hn,{columnGap:0,columns:{sm:"210px repeat(7, minmax(35px, 1fr))"},children:[e.jsx(i,{className:"WeekdayHeader__cell",w:210,h:56,bcolor:"mono100",justifyContentCenter:!0,alignItemsCenter:!0,children:e.jsx(nT,{})}),n.map((o,a)=>e.jsxs(i,{className:"WeekdayHeader__cell",h:56,blw:1,bcolor:"mono100",flex:!0,column:!0,alignItemsCenter:!0,justifyContentCenter:!0,children:[e.jsx(j,{variant:"captions",color:"tertiary",children:o.weekday}),e.jsx(j,{variant:"heading4",color:"mono900",children:o.dayNumber})]},`${o.weekday}-${o.dayNumber}-${a}`))]})},lT=(t,s)=>{const n=r.useRef([]);r.useEffect(()=>(n.current.forEach(o=>o.abort?.()),n.current=t(),()=>{n.current.forEach(o=>o.abort?.())}),s)},Vi=({date:t,rowType:s="open",jobId:n,roleId:o,isPasteTarget:a,onClick:l})=>{const c=rn(),u=X(),h=I(nh),m=!!h;return r.useCallback(_=>{if(!c){if(m){_.stopPropagation(),a&&h&&u(nx({targetDate:t,rowType:s,targetJobId:n,targetRoleId:o}));return}l?.(_)}},[c,m,a,h,u,t,s,n,o,l])},iT=({jobId:t,date:s,suffix:n,roleId:o,roleColor:a})=>{const l=Jo(),c=rn(),u=t??"open",h=o?`-role-${o}`:"",m=`canvas-cell-${u}${h}-${s}${n?`-${n}`:""}`,{setNodeRef:_,isOver:f}=kr({id:m,disabled:c,data:{type:Zt.CELL,jobId:t,date:s,roleId:o,roleColor:a}});return{isOver:f&&l===Zt.SHIFT,setNodeRef:_}},{cx:cT}=O("DayCellDropZone"),Ep=({jobId:t,date:s,roleId:n=null,roleColor:o=null,rowType:a="open",className:l,children:c,onClick:u,...h})=>{const m=rn(),{isOver:_,setNodeRef:f}=iT({jobId:t,date:s,roleId:n,roleColor:o}),g=Vi({date:s,rowType:a,jobId:t??void 0,roleId:n??void 0,isPasteTarget:!0,onClick:u});return e.jsx(i,{ref:f,className:cT({over:_},l),onClick:m?void 0:g,pointer:!m,...h,children:c})},Sp="schedule-builder:scroll-to-shift",dT="schedule-builder:highlight-shift-cell",jp=()=>r.useCallback((t,s,n)=>{window.dispatchEvent(new CustomEvent(Sp,{detail:{shiftId:t,roleId:s,jobId:n}}))},[]),yd=Sp,Sl=dT,uT=3e3,hT=t=>({type:Zt.SHIFT,shiftId:t.id,jobId:t.job_id,isDraft:t.is_draft,date:t.start_at.slice(0,10),startAt:t.start_at,endAt:t.end_at,roleId:t.role_id,color:t.color??""}),mT=r.memo(({shiftId:t,bgcolor:s,isDropTarget:n})=>{const o=I(g=>t?$o(g,t):void 0),a=o?hT(o):void 0,l=rn(),[c,u]=r.useState(!1);r.useEffect(()=>{const g=b=>{const{shiftId:x}=b.detail;x===t&&u(!0)};return window.addEventListener(Sl,g),()=>window.removeEventListener(Sl,g)},[t]),r.useEffect(()=>{if(!c)return;const g=window.setTimeout(()=>u(!1),uT);return()=>window.clearTimeout(g)},[c]);const{attributes:h,listeners:m,setNodeRef:_,isDragging:f}=rh({id:o?.id||"empty",data:a,disabled:l||!a});return o?e.jsx("div",{id:`shift-cell-${o.id}`,ref:_,...h,...m,style:{opacity:f?.54:1},children:e.jsx(lp,{shiftId:o.id,bgcolor:s,isDropTarget:n,isHighlighted:c})}):e.jsx(i,{maxh:40,minh:40,w:"70%",ph:4,mt:4,bgcolor:"purple500"})}),{cx:pT}=O("OpenShiftDropCell"),yp=r.memo(({date:t,shift:s,isEmptySlot:n,rowType:o="open",refHandler:a,onClick:l,onDeleteShift:c,jobId:u,roleId:h})=>{const m=rn(),_=X(),g=I(ti)==="pending",[b,x]=r.useState(null),E=r.useCallback(L=>{L.preventDefault(),x(L.currentTarget)},[]),S=r.useCallback(()=>{x(null)},[]),y=r.useCallback(()=>{s&&_(Ku(s.id)),x(null)},[s,_]),C=r.useCallback(()=>{s&&c&&c(s.id),x(null)},[s,c]),v=Vi({date:t,rowType:o,jobId:u,roleId:h,isPasteTarget:n||!s,onClick:l}),T=r.useCallback(L=>{L.stopPropagation(),v(L)},[v]),D=[[{label:p("schedule_builder.react_page.shift_context_menu.copy"),iconName:"Copy",onClick:y},{label:p("schedule_builder.react_page.shift_context_menu.delete"),iconName:"Delete",onClick:C,redText:!0}]];return g&&u?e.jsx(i,{w:"100%",flex:!0,justifyContentCenter:!0,p:4,children:e.jsx(cs,{bradiusm:!0,width:"90%",height:"33px"})}):s?e.jsx(i,{className:pT(),ref:a,w:"100%",flex:!0,justifyContentCenter:!0,children:e.jsxs(i,{w:"100%",onClick:m?void 0:T,onContextMenu:m?void 0:E,pointer:!m,id:`open-shift-drop-cell-${s.id}`,children:[e.jsx(mT,{shiftId:s.id}),e.jsx(si,{open:!!b,onClose:S,anchorEl:b,menuItemSections:D})]})}):null}),{cx:_T}=O("AddButton"),vp=({onClick:t,fullHeight:s,refHandler:n,date:o,roleId:a,jobId:l,rowType:c="open"})=>{const u=rn(),m=!!I(nh),[_,f]=r.useState(!1),g=r.useCallback(()=>f(!0),[]),b=r.useCallback(()=>f(!1),[]),x=Vi({date:o,rowType:c,jobId:l,roleId:a,isPasteTarget:!0,onClick:t});return u?null:e.jsx(i,{ref:n,className:_T({copyPasteMode:m}),h:s?46:19,w:"100%",mb:3,pointer:!0,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,onClick:x,onMouseEnter:g,onMouseLeave:b,children:m&&_&&e.jsx(j,{variant:"captionBold",color:"mono700",children:p("schedule_builder.agent.paste")})})},{cxEl:fT}=O("OpenShiftRow"),Ip=600,Ki=50,bT=({shifts:t,startDate:s,roleId:n,isA
1ssigning:o,animationOffset:a=0,createRefHandler:l,createClickHandler:c})=>{const u=X(),h=r.useCallback(g=>{const b=t.find(E=>E.id===g);if(!b)return;const x=b.is_draft?wo:mr;u(x({shiftId:g}))},[u,t]),m=r.useMemo(()=>Array.from({length:7},(g,b)=>lt(s).add(b,"days").format("YYYY-MM-DD")),[s]),_=r.useMemo(()=>{const g=Array.from({length:7},()=>[]);return t.filter(b=>!b.job_id).forEach(b=>{const x=b.start_at.slice(oh,ah),E=m.indexOf(x);E>=0&&g[E].push(b)}),g.forEach(b=>b.sort((x,E)=>x.start_at.localeCompare(E.start_at)||x.end_at.localeCompare(E.end_at))),g},[t,m]),f=r.useMemo(()=>Math.max(..._.map(g=>g.length)),[_]);return e.jsxs(Hn,{dataTestId:"open-shift-row",columnGap:0,columns:{sm:Tr},children:[e.jsx(i,{bcolor:"mono100",minh:20,flex:!0,alignItemsCenter:!0,gap:8}),e.jsx(e.Fragment,{children:_.map((g,b)=>{const x=m[b];return e.jsxs(Ep,{jobId:null,date:x,roleId:n,rowType:"open",onClick:c(b,void 0,n),className:fT("day-column",{falling:!!o}),style:{"--falloff-delay":`${a+b*Ki}ms`},id:`open-shift-day-${b}`,blw:1,bcolor:"mono100",column:!0,alignItemsCenter:!0,gap:3,pt:4,ph:4,children:[g.map((E,S)=>e.jsx(yp,{date:x,shift:E,rowType:"open",roleId:n,refHandler:l(b,S),onClick:c(b,E.id,n),onDeleteShift:h},`open-shift-${E.id}`)),e.jsx(i,{flex:!0,column:!0,alignItemsCenter:!0,w:"100%",grow:1,children:e.jsx(vp,{date:x,roleId:n,rowType:"open",fullHeight:g.length<f,refHandler:l(b,g.length),onClick:c(b,void 0,n)},`add-button-${b}`)})]},`open-shift-day-${b}`)})})]})},gT=r.memo(bT),$t="no-department",zs=t=>`open-shifts:${t??"no-role"}`,Ts=t=>`team-members:${t??"no-role"}`,ga=t=>`open-shifts:dept:${t}`,xa=t=>`team-members:dept:${t}`,mn=t=>{switch(t.kind){case"event-row":return"event-row";case"row-group-header":return t.groupKey;case"department-group-header":return t.groupKey;case"role-group-header":return t.groupKey;case"open-shifts-row":return`open-shifts-row:${t.roleId??"no-role"}`;case"employee-row":return`employee-row:${t.roleId??"no-role"}:${t.employee.job_id}`;case"team-members-skeleton-row":return`team-members-skeleton-row:${t.roleId}`;case"wage-totals-spacer":return"wage-totals-spacer"}},xT=(t,s,n)=>{const o=s.length>0?s.slice(0,co.length):co;for(const a of o){const l=Ts(a.id);n[l]&&t.push({kind:"team-members-skeleton-row",roleId:a.id})}},Tp=(t,s,n)=>s===$t?t.filter(o=>!o.department_id||!n.has(o.department_id)):t.filter(o=>o.department_id===s),wp=(t,s,n,o=!1)=>{const a=zs(),l=!!n[a];t.push({kind:"role-group-header",groupKey:a,label:"Role not defined",expanded:l,nested:o,totalOpenShiftHours:Xo(s)}),l&&s.length>0&&t.push({kind:"open-shifts-row",shifts:s})},Dp=(t,s,n,o,a=!1)=>{for(const l of s){const c=zs(l.id),u=!!o[c],h=n.filter(m=>m.role_id===l.id);t.push({kind:"role-group-header",groupKey:c,label:l.name,badgeColor:Fo(l),expanded:u,nested:a,totalOpenShiftHours:Xo(h)}),u&&t.push({kind:"open-shifts-row",roleId:l.id,shifts:h})}},CT=(t,s,n,o)=>{const a=n.filter(l=>!l.role_id);wp(t,a,o),Dp(t,s,n,o)},ET=(t,s,n,o,a)=>{const l=new Set(s.map(h=>h.id)),c=o.filter(h=>!h.role_id),u=[...s.map(h=>({id:h.id,label:h.name})),{id:$t,label:"Role not defined"}];for(const h of u){const m=Tp(n,h.id,l),_=o.filter(x=>x.role_id&&m.some(E=>E.id===x.role_id)),f=h.id===$t;if(m.length===0&&_.length===0&&!f)continue;const g=ga(h.id),b=!!a[g];t.push({kind:"department-group-header",groupKey:g,label:h.label,expanded:b,totalOpenShiftHours:Xo([..._,...f?c:[]])}),b&&(f&&wp(t,c,a,!0),Dp(t,m,o,a,!0))}},kp=(t,s,n,o,a=!1)=>{if(s.length===0)return;const l=Ts(),c=!!o[l];if(t.push({kind:"role-group-header",groupKey:l,label:"Role not defined",expanded:c,nested:a}),c)for(const u of s)t.push({kind:"employee-row",employee:u,shifts:n.filter(h=>h.job_id===u.job_id)})},Rp=(t,s,n,o,a,l=!1)=>{for(const c of s){const u=Ts(c.id),h=!!a[u];if(t.push({kind:"role-group-header",groupKey:u,label:c.name,badgeColor:Fo(c),expanded:h,nested:l}),h)for(const m of n)m.default_role_id===c.id&&t.push({kind:"employee-row",employee:m,roleId:c.id,shifts:o.filter(_=>_.job_id===m.job_id)})}},ST=(t,s,n,o,a)=>{const l=n.filter(c=>!c.default_role_id);kp(t,l,o,a),Rp(t,s,n,o,a)},jT=(t,s,n,o,a,l)=>{const c=new Set(s.map(m=>m.id)),u=o.filter(m=>!m.default_role_id),h=[...s.map(m=>({id:m.id,label:m.name})),{id:$t,label:"Role not defined"}];for(const m of h){const _=Tp(n,m.id,c),f=o.filter(E=>E.default_role_id?_.some(S=>S.id===E.default_role_id):m.id===$t),g=m.id===$t;if(_.length===0&&f.length===0&&!(g&&u.length>0))continue;const b=xa(m.id),x=!!l[b];t.push({kind:"department-group-header",groupKey:b,label:m.label,expanded:x}),x&&(g&&kp(t,u,a,l,!0),Rp(t,_,o,a,l,!0))}},yT=({showSkeletons:t,employeesLoading:s,showEvents:n,expandedGroups:o,shifts:a,roles:l,departments:c,employees:u,viewBy:h,viewType:m})=>
1{if(t)return[];const _=a.filter(x=>!x.job_id),f=[];if(n){const x=!!o[xn];f.push({kind:"row-group-header",groupKey:xn,section:"events",label:"Events",bottomBorder:!1,expanded:x}),x&&f.push({kind:"event-row"})}const g=!!o[Pt];f.push({kind:"row-group-header",groupKey:Pt,section:"open-shifts",label:"Open Shifts",bottomBorder:!1,expanded:g,openShiftCount:_.length,totalOpenShiftHours:Xo(_)}),g&&(m===de.department?ET(f,c,l,_,o):CT(f,l,_,o));const b=!!o[ss];if(f.push({kind:"row-group-header",groupKey:ss,section:"team-members",label:"Team Members",expanded:b,forceBottomBorder:m==="employee"}),b){if(s)return xT(f,l,o),f;if(m==="employee"&&(h==="first_name"||h==="last_name")){const x=[...u].sort((E,S)=>{const y=(E.first_name||"").toLowerCase(),C=(S.first_name||"").toLowerCase(),v=(E.last_name||"").toLowerCase(),T=(S.last_name||"").toLowerCase();return h==="first_name"?Tc(y,C,v,T):Tc(v,T,y,C)});for(const E of x)f.push({kind:"employee-row",employee:E,shifts:a.filter(S=>S.job_id===E.job_id)});return f.push({kind:"wage-totals-spacer"}),f}m===de.department?jT(f,c,l,u,a,o):ST(f,l,u,a,o)}return f.push({kind:"wage-totals-spacer"}),f},vT=650,vd=(t,s,n)=>{if(!t)return $t;const o=s.find(l=>l.id===t);return o?.department_id&&new Set(n.map(l=>l.id)).has(o.department_id)?o.department_id:$t},fo=(t,{roleId:s,roles:n,departments:o,viewType:a,section:l})=>{const c=l==="open-shifts"?zs:Ts,u=l==="open-shifts"?ga:xa;if(a===de.department){if(s!==void 0){t(u(vd(s,n,o))),t(c(s));return}t(u($t)),t(c()),n.forEach(h=>{t(u(vd(h.id,n,o))),t(c(h.id))});return}s!==void 0?t(c(s)):(t(c()),n.forEach(h=>t(c(h.id))))},Id=(t,s,n,o="open-shifts")=>{if(n!==de.department)return;const a=o==="open-shifts"?ga:xa;[...s.map(l=>l.id),$t].forEach(l=>t(a(l)))},IT=[],TT=({showSkeletons:t,employeesLoading:s,shifts:n,roles:o,departments:a,employees:l,showEvents:c,initialExpandedGroups:u,forcedCollapsedGroups:h=IT,viewBy:m,viewType:_,canvasIsPublished:f=!1})=>{const[g,b]=r.useState(u??{}),[x,E]=r.useState(!1),S=r.useRef([]),y=r.useRef();r.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const C=r.useRef(!1);r.useEffect(()=>{f&&!C.current&&b(B=>({...B,[Pt]:!1,[xn]:!1})),C.current=f},[f]);const v=r.useMemo(()=>{const B={...g};Pt in B||(B[Pt]=!0),ss in B||(B[ss]=!0);const W=zs();W in B||(B[W]=!0),o.forEach(H=>{const q=zs(H.id);q in B||(B[q]=!0)});const N=Ts();return N in B||(B[N]=!0),o.forEach(H=>{const q=Ts(H.id);q in B||(B[q]=!0)}),co.forEach(H=>{const q=zs(H.id);q in B||(B[q]=!0);const G=Ts(H.id);G in B||(B[G]=!0)}),_===de.department&&[...a.map(q=>q.id),$t].forEach(q=>{const G=ga(q),re=xa(q);G in B||(B[G]=!0),re in B||(B[re]=!0)}),h.forEach(H=>{B[H]=!1}),B},[g,h,o,a,_]),T=r.useMemo(()=>yT({showSkeletons:t,employeesLoading:s,showEvents:c,expandedGroups:v,shifts:n,roles:o,departments:a,employees:l,viewBy:m,viewType:_}),[t,s,v,n,o,a,l,m,c,_]),D=r.useRef(T);D.current=T;const L=r.useMemo(()=>x!=="collapsing"?T:S.current.map(B=>{if(B.kind==="row-group-header"||B.kind==="department-group-header"||B.kind==="role-group-header"){const W=!!v[B.groupKey];if(B.expanded!==W)return{...B,expanded:W}}return B}),[x,T,v]),A=r.useMemo(()=>{if(x!=="collapsing")return new Set;const B=new Set(T.map(mn));return new Set(S.current.map(mn).filter(W=>!B.has(W)))},[x,T]),P=r.useMemo(()=>{if(x!=="expanding")return new Set;const B=new Set(S.current.map(mn));return new Set(T.map(mn).filter(W=>!B.has(W)))},[x,T]),M=r.useCallback((B,W)=>b(N=>N[B]===W?N:{...N,[B]:W}),[]),R=r.useCallback(B=>{const W=!!v[B];
1S.current=D.current,E(W?"collapsing":"expanding"),b(N=>({...N,[B]:!W})),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>E(!1),vT)},[v]),$=r.useCallback(B=>b(W=>({...W,[B]:!0})),[]);return{rows:L,departingKeys:A,arrivingKeys:P,expandedGroups:v,toggleGroup:R,expandGroup:$,setGroupExpanded:M}},wT=20,DT=50,kT=3e3,RT=({rowsRef:t,parentRef:s,virtualizer:n,roles:o,departments:a,viewType:l,expandGroup:c})=>{const u=r.useRef(!1),h=X(),m=I(_t),_=I(Rs),f=I(rx),g=r.useCallback((S,y=0)=>{if(y>wT)return;const C=t.current.findIndex(v=>v.kind==="row-group-header"&&v.groupKey===S);C<0||(n.scrollToIndex(C,{align:"start",behavior:"auto"}),requestAnimationFrame(()=>{const v=n.measurementsCache[C],T=s.current;if(!v||!T){setTimeout(()=>g(S,y+1),150);return}const D=v.start;if(Math.abs(T.scrollTop-D)>DT){setTimeout(()=>g(S,y+1),150);return}T.scrollTo({top:D,behavior:"smooth"})}))},[n,t,s]),b=r.useCallback(S=>new Promise((y,C)=>{setTimeout(()=>{u.current?C(new Error("aborted")):y()},S)}),[]),x=r.useCallback(async()=>{u.current=!1;try{let S=null;if(m&&(await Promise.all(f.map(C=>h($l({oldShiftId:C.id,originalShift:C,source_type:"shift",source_uuid:C.id,start_at:C.start_at,end_at:C.end_at,...C.role_id&&{role_uuid:C.role_id}})).unwrap())),_||(S=h(ox({startDate:m})).unwrap())),c(ss),!_){c(Pt);const C=t.current.findIndex(D=>D.kind==="row-group-header"&&D.groupKey===Pt);C>=0&&n.scrollToIndex(C,{align:"start",behavior:"smooth"}),await b(1e3),Id(c,a,l,"open-shifts"),fo(c,{roles:o,departments:a,viewType:l,section:"open-shifts"}),await b(500),await b(300),h(ml("pending"));const v=t.current.filter(D=>D.kind==="open-shifts-row"&&D.shifts.length>0).length,T=Math.min(kT,v*(6*Ki+Ip));await b(T)}g(ss),Id(c,a,l,"team-members"),fo(c,{roles:o,departments:a,viewType:l,section:"team-members"});let y=!1;S&&(y=(await S)?.status==="done"),m&&y&&await Promise.all([h(Oo({startDate:m,type:"all"})),h(Po({startDate:m})),h(zl()),h(Gl({startDate:m})),h(lh({startDate:m}))]),await b(1e3),h(ml("succeeded"))}catch(S){console.error("Error assigning shifts:",S)}},[c,_,o,a,l,g,h,m,f,t,n,b]),E=r.useCallback(()=>{u.current=!0},[]);return{handleAssignShifts:x,cancel:E}},LT=(t,s)=>{const[n,o]=r.useState(t);return r.useEffect(()=>{const a=setTimeout(()=>o(t),s);return()=>clearTimeout(a)},[t,s]),n},AT=()=>{const t=X(),s=I(_t),n=I(ax),o=I(qu);r.useEffect(()=>{!s||n.length===0||o!=="pending"&&t(Po({startDate:s,canvasJobUuids:n}))},[n,o,s,t])},Lp="schedule-builder:scroll-to-employee",OT="schedule-builder:highlight-employee",Os=()=>r.useCallback(t=>{window.dispatchEvent(new CustomEvent(Lp,{detail:{jobId:t}}))},[]),Td=Lp,jl=OT,NT=({rowsRef:t,parentRef:s,virtualizer:n,roles:o,departments:a,viewType:l,expandGroup:c})=>{const u=r.useCallback((h,m=0)=>{if(h<0||m>20)return;const _=s.current;if(!_)return;const f=_.scrollTop;n.scrollToIndex(h,{align:"start",behavior:"auto"}),requestAnimationFrame(()=>{const g=n.measurementsCache[h];if(!g||g.start===0){setTimeout(()=>u(h,m+1),150);return}_.scrollTop=f,_.scrollTo({top:g.start,behavior:"smooth"})})},[n,s]);r.useEffect(()=>{const h=m=>{const{jobId:_}=m.detail;c(ss);const f=t.current.find(x=>x.kind==="employee-row"&&x.employee.job_id===_);f&&f.kind==="employee-row"&&fo(c,{roleId:f.roleId,roles:o,departments:a,viewType:l,section:"team-members"});let g=0;const b=()=>{const x=t.current.findIndex(E=>E.kind==="employee-row"&&E.employee.job_id===_);if(x>=0){u(x);let E=0;const S=()=>{document.getElementById(`employee-row-header-${_}`)?window.dispatchEvent(new CustomEvent(jl,{detail:{jobId:_}})):E<20&&(E+=1,setTimeout(S,100))};setTimeout(S,100)}else g<10&&(g+=1,setTimeout(b,50))};setTimeout(b,50)};return window.addEventListener(Td,h),()=>window.removeEventListener(Td,h)},[c,u,t,o,a,l])},MT=20,PT=150,$T=650,BT=t=>{if(t<.5)return 2*t*t;const n=1-t;return 1-2*n*n},Ap=({parentRef:t,virtualizer:s})=>{const n=r.useRef(null),o=r.useCallback((a,l)=>{n.current!==null&&cancelAnimationFrame(n.current);const c=a.scrollTop,u=l-c;if(u===0)return;let h=null;const m=_=>{h===null&&(h=_);const f=Math.min((_-h)/$T,1);a.scrollTop=c+u*BT(f),f<1?n.current=requestAnimationFrame(m):n.current=null};n.current=requestAnimationFrame(m)},[]);return r.useCallback(function a(l,c=0){if(l<0||c>MT)return;const u=t.current;if(!u)return;const h=u.scrollTop;s.scrollToIndex(l,{align:"start",behavior:"auto"}),u.scrollTop=h,requestAnimationFrame(()=>{const m=s.measurementsCache[l];if(!m||m.start===0){setTimeout(()=>a(l,c+1),PT);return}o(u,m.start)})},[s,t,o])},UT=10,wd=50,HT=({rowsRef:t,parentRef:s,virtualizer:n,hasPublishedSchedule:o,initialLoadComplete:a,showSkeletons:l,startDate:c})=>{const u=Ap({parentRef:s,virtualizer:n}),h=r.useRef(null),m=r.useRef(!1);r.useEffect(()=>{if(h.current!==c&&(h.current=c,m.current=!0),!m.current||!o||!a||l)return;m.current=!1;let _=0,f;const g=()=>{const b=t.current.findIndex(x=>x.kind==="row-group-header"&&x.groupKey===ss);b>=0?u(b):_<UT&&(_+=1,f=setTimeout(g,wd))};return f=setTimeout(g,wd),()=>clearTimeout(f)},[c,o,a,l,t,u])},FT=10,Dd=50,WT=20,kd=100,VT=(t,s)=>t.findIndex(n=>(n.kind==="open-shifts-row"||n.kind==="employee-row")&&n.shifts.some(o=>o.id===s)),KT=({rowsRef:t,parentRef:s,virtualizer:n,roles:o,departments:a,viewType:l,expandGroup:c})=>{const u=Ap({parentRef:s,virtualizer:n});r.useEffect(()=>{const h=m=>
1{const{shiftId:_,roleId:f,jobId:g}=m.detail,b=!!g;c(b?ss:Pt),fo(c,{roleId:f,roles:o,departments:a,viewType:l,section:b?"team-members":"open-shifts"});let E=0;const S=()=>{const y=VT(t.current,_);if(y>=0){u(y);let C=0;const v=()=>{document.getElementById(`shift-cell-${_}`)?window.dispatchEvent(new CustomEvent(Sl,{detail:{shiftId:_}})):C<WT&&(C+=1,setTimeout(v,kd))};setTimeout(v,kd)}else E<FT&&(E+=1,setTimeout(S,Dd))};setTimeout(S,Dd)};return window.addEventListener(yd,h),()=>window.removeEventListener(yd,h)},[c,u,t,o,a,l])};function bo(t,s){return t?.type===s}function Op(t,s){return t?.type===s}const qT=()=>{const t=X(),s=dv(),n=r.useRef(new Map),o=r.useCallback(l=>{const c=l.active.data.current;return bo(c,Zt.SHIFT)?c:null},[]),a=r.useCallback((l,c,u)=>{const{over:h}=l;if(!h){u?.();return}const m=c,_=h.data.current;if(!bo(m,Zt.SHIFT)||!Op(_,Zt.CELL)){u?.();return}const f=m.date!==_.date,g=m.jobId!==_.jobId,b=m.roleId!==_.roleId;if(!f&&!g&&!b){u?.();return}const E=m.startAt.slice(wc),S=m.endAt.slice(wc),{startAt:y,endAt:C}=cl({date:_.date,start:E,end:S});n.current.get(m.shiftId)?.abort();const v=$o(s.getState(),m.shiftId);t(Dc({shiftId:m.shiftId,newJobId:_.jobId,newDate:_.date,newRoleId:_.roleId??void 0,newColor:_.roleColor??void 0}));const T=()=>{v&&t(Dc({shiftId:m.shiftId,newJobId:v.job_id,newDate:v.start_at.slice(0,10),newRoleId:v.role_id,newColor:v.color}))},D=m.isDraft,L=_.jobId!==null,A=D===L,P=_.roleId??m.roleId;let M;A?M=t($l({oldShiftId:m.shiftId,originalShift:v,source_type:D?"draft_shift":"shift",source_uuid:m.shiftId,...L&&{job_uuid:_.jobId},start_at:y,end_at:C,...P&&{role_uuid:P}})):D?(M=t(dl({shiftId:m.shiftId,start_at:y,end_at:C,role_id:P})),M.then(R=>{n.current.get(m.shiftId)===M&&(n.current.delete(m.shiftId),dl.rejected.match(R)&&!R.meta.aborted&&T())})):(M=t(ul({shiftId:m.shiftId,job_uuid:_.jobId,start_at:y,end_at:C,..._.roleColor!==void 0&&{color:_.roleColor??void 0}})),M.then(R=>{n.current.get(m.shiftId)===M&&(n.current.delete(m.shiftId),ul.rejected.match(R)&&!R.meta.aborted&&T())})),n.current.set(m.shiftId,M),u?.()},[t,s]);return{handleDragStart:o,handleDragEnd:a}},zT=()=>{const[t,s]=r.useState(null),n=r.useRef(null),{handleDragStart:o,handleDragEnd:a}=qT();return ih({onDragStart(l){const c=o(l);n.current=c,s(c)},onDragEnd(l){a(l,n.current),n.current=null,s(null)},onDragCancel(){n.current=null,s(null)}}),{activeDragData:t}},Np=()=>{const[t,s]=r.useState(null),[n,o]=r.useState(null),[a,l]=r.useState(),[c,u]=r.useState(),[h,m]=r.useState(),[_,f]=r.useState("open"),g=r.useRef([]),b=!!t&&n!==null,x=r.useCallback((C,v)=>{s(v??g.current[C]),o(C)},[]),E=r.useCallback(()=>{s(null),o(null),l(void 0),u(void 0),m(void 0),f("open")},[]),S=r.useCallback((C,v)=>T=>{v===0&&(g.current[C]=T)},[]),y=r.useCallback((C,v,T,D="open",L)=>A=>{l(v),u(T),m(L),f(D),x(C,A.currentTarget)},[x]);return{anchorEl:t,selectedDayIndex:n,selectedShiftId:a,selectedRoleId:c,selectedJobId:h,selectedRowType:_,isOpen:b,cellRefs:g,openPopper:x,closePopper:E,createRefHandler:S,createClickHandler:y}},{cx:GT}=O("AnimatedArrow"),on=({expanded:t,color:s="mono500",size:n="small",label:o})=>e.jsx(i,{className:GT({expanded:t}),children:e.jsx(zu,{iconName:"ArrowDown",size:n,color:s,label:o})}),qi=({isOver:t,isExpanded:s,onExpand:n,delay:o=300})=>{const a=Jo(),l=r.useRef(),c=t&&!s&&a===Zt.SHIFT;return r.useEffect(()=>(c&&(l.current=setTimeout(()=>{n()},o)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}),[c,n,o]),{isShiftDragOver:c}},{cx:YT}=O("DepartmentGroupHeader"),JT=({label:t,groupKey:s,expanded:n,totalOpenShiftHours:o,onToggle:a,onDragExpand:l})=>{const c=r.useCallback(()=>a(s),[a,s]),{setNodeRef:u,isOver:h}=kr({id:`department-group-header-droppable:${s}`,data:{type:Zt.GROUP_HEADER,groupKey:s}}),m=r.useCallback(()=>{l?.(s)},[l,s]),{isShiftDragOver:_}=qi({isOver:h,isExpanded:n,onExpand:m,delay:600});return e.jsxs(i,{id:`department-group-header-${s}`,ref:u,className:YT(),pointer:!0,minh:33,btw:1,bbw:1,bcolor:"mono100",bgcolor:_?"purple100":void 0,flex:!0,alignItemsCenter:!0,onClick:c,gap:8,ph:16,pl:16,children:[e.jsx(on,{expanded:n,label:t}),e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:4,children:[e.jsx(j,{variant:"captionBold",children:t}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.separator")}),e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.open_shifts.hours",{props:{hours:Sr(o)}})})]})]})]})},XT=({children:t,bgcolor:s="mono100",maxh:n=28,minh:o=28,withBorder:a=!1,withDottedBorder:l=!1,colorClass:c,bcolor:u="mono400",cx:h})=>e.jsx(i,{id:"draft-cell-container",className:h({[c||""]:!!c,withDottedBorder:l}
1),bgcolor:c?void 0:s,bradiuss:!0,minh:o,maxh:n,bs:l?"dashed":"solid",ph:4,alignItemsCenter:!0,justifyContentCenter:!0,w:"100%",bw:l||a?1:0,bcolor:u,children:t}),QT=kv("ContainerCell")(XT),ZT=({employee:t})=>{const s=r.useMemo(()=>{const l=t.first_name?.charAt(0)?.toUpperCase()||"",c=t.last_name?.charAt(0)?.toUpperCase()||"";return`${l}${c}`},[t.first_name,t.last_name]),n=r.useMemo(()=>{const l=t.first_name?.trim()||"",c=t.last_name?.trim()||"";return`${l} ${c}`.trim()},[t.first_name,t.last_name]),o=I(l=>t.job_id?lx(l,{jobId:t.job_id}):{totalHours:0,totalWages:0,hasWagePermission:null},(l,c)=>l.totalHours===c.totalHours&&l.totalWages===c.totalWages&&l.hasWagePermission===c.hasWagePermission),a=r.useMemo(()=>!o.hasWagePermission||o.totalWages===0?null:pt(o.totalWages),[o.totalWages,o.hasWagePermission]);return e.jsx(QT,{bgcolor:null,maxh:44,minh:44,children:e.jsxs(i,{ml:8,w:"100%",h:"100%",flex:!0,alignItemsCenter:!0,gap:4,children:[e.jsx(Un,{size:"medium",initials:s,image:t.avatar_url}),e.jsxs(i,{w:"80%",flex:!0,column:!0,children:[e.jsx(j,{noWrap:!0,variant:"captionBold",children:n}),o.totalHours>0&&e.jsxs(j,{variant:"captions",noWrap:!0,color:"mono500",children:[o.totalHours.toFixed(1),"h",a&&` / ${a}`]})]})]})})},{cx:ew,cxEl:Rd}=O("TimeOffCell"),Mp=107,tw=1e4/Mp,sw=r.memo(({timeOff:t,position:s="single",spanDays:n=1})=>{const o=t.day_durations.map(_=>_.date).sort(),a=o[0]??t.start_at.slice(0,10),l=o[o.length-1]??t.end_at.slice(0,10),c=t.state==="approved",u=c?p("schedule_builder.agent.canvas.time_offs.pto"):p("schedule_builder.agent.canvas.time_offs.pto_request"),h=(()=>{const _=lt(a,"YYYY-MM-DD"),f=lt(l,"YYYY-MM-DD");return!_.isValid()||!f.isValid()?`${u}: ${a}-${l}`:_.isSame(f,"day")?`${u}: ${_.format("MMM D")}`:_.isSame(f,"month")?`${u}: ${_.format("MMM D")}-${f.format("D")}`:`${u}: ${_.format("MMM D")}-${f.format("MMM D")}`})(),m=s==="first"||s==="single";return e.jsx(i,{className:ew(s),maxh:40,minh:40,w:`${Mp}%`,ml:s==="first"?"5%":"0",mr:s==="last"?"5%":"0",flex:!0,alignItemsCenter:!0,children:e.jsx(i,{className:Rd("bar",{[s]:!0,pending:!c}),maxh:kc,minh:kc,w:"100%",title:`${a} - ${l}`,flex:!0,alignItemsCenter:!0,ph:m?8:0,children:m&&e.jsx("span",{className:Rd("label"),style:{maxWidth:`calc(${n} * ${tw}%)`},children:e.jsx(j,{variant:"captions",color:"mono900",children:h})})})})}),{cxEl:Ld}=O("EmployeeRow"),nw=3e3,rw=({employee:t,shifts:s,startDate:n,roleId:o,createRefHandler:a,createClickHandler:l})=>{const c=X(),u=I(C=>ch(C)),m=I(ti)==="pending",[_,f]=r.useState(!1);r.useEffect(()=>{const C=v=>{const{jobId:T}=v.detail;T===t.job_id&&f(!0)};return window.addEventListener(jl,C),()=>window.removeEventListener(jl,C)},[t.job_id]),r.useEffect(()=>{if(!_)return;const C=window.setTimeout(()=>f(!1),nw);return()=>window.clearTimeout(C)},[_]);const g=r.useCallback(C=>{const v=s.find(D=>D.id===C);if(!v)return;const T=v.is_draft?wo:mr;c(T({shiftId:C}))},[c,s]),b=r.useMemo(()=>Array.from({length:7},(C,v)=>lt(n).add(v,"days").format("YYYY-MM-DD")),[n]),x=r.useMemo(()=>{const C=Array.from({length:7},()=>[]);return s.forEach(v=>{const T=v.start_at.slice(oh,ah),D=b.indexOf(T);D>=0&&C[D].push(v)}),C.forEach(v=>v.sort((T,D)=>T.start_at.localeCompare(D.start_at)||T.end_at.localeCompare(D.end_at))),C},[s,b]),E=r.useMemo(()=>{const C=Array.from({length:7},()=>[]);return u.filter(v=>String(v.job_id)===t.job_id).forEach(v=>{v.day_durations.forEach(T=>{const D=b.indexOf(T.date);D>=0&&C[D].push(v)})}),C.forEach(v=>v.sort((T,D)=>T.start_at.localeCompare(D.start_at)||T.end_at.localeCompare(D.end_at))),C},[t.job_id,u,b]),S=r.useMemo(()=>{const C={};return E.forEach((v,T)=>{const D=b[T];v.forEach(L=>{const A=L.day_durations.map(q=>q.date).sort(),P=A[0]??L.start_at.slice(0,10),M=A[A.length-1]??L.end_at.slice(0,10),R=P<b[0]?b[0]:P,$=M>b[6]?b[6]:M,B=D===R,W=D===$;let N;B&&W?N="single":B?N="first":W?N="last":N="middle";const H=b.indexOf($)-b.indexOf(R)+1;C[`${L.id}-${T}`]={position:N,spanDays:H}})}),C},[E,b]),y=r.useMemo(()=>Math.max(...x.map((C,v)=>C.length+E[v].length)),[x,E]);return e.jsxs(Hn,{dataTestId:"employee-row",columnGap:0,columns:{sm:Tr},children:[e.jsx(i,{id:`employee-row-header-${t.job_id}`,bbw:1,brw:1,bcolor:"mono100",minh:20,flex:!0,alignItemsStart:!0,bgcolor:_?"primary100":void 0,gap:8,className:Ld("cell"),children:e.jsx(ZT,{employee:t})}),e.jsx(e.Fragment,{children:x.map((C,v)=>e.jsxs(Ep,{jobId:t.job_id,date:b[v],roleId:o,rowType:"employee",onClick:l(v,void 0,o,"employee",t.job_id),id:`employee-${t.job_id}-day-${v}`,brw:v===x.length-1?0:1,bbw:1,bcolor:"mono100",column:!0,alignItemsCenter:!0,pt:4,ph:4,gap:3,bgcolor:_?"primary100":void 0,className:Ld("cell"),children:[E[v].map(T=>e.jsx(sw,{timeOff:T,position:S[`${T.id}-${v}`].position,spanDays:S[`${T.id}-${v}`].spanDays},`timeoff-${T.id}`)),C.map((T,D)=>e.jsx(yp,{date:b[v],shift:T,rowType:"employee",jobId:t.job_id,roleId:o,onClick:l(v,T.id,T.role_id??void 0,"employee",t.job_id),refHandler:a(v,D),onDeleteShift:g},T.id)),e.jsx(i,{flex:!0,column:!0,alignItemsCenter:!0,justifyContentStart:!0,w:"100%",grow:1,children:!(m&&t.job_id)&&e.jsx(vp,{jobId:t.job_id,date:b[v],roleId:o,rowType:"employee",refHandler:a(v,C.length),fullHeight:C.length+E[v].length<y,onClick:l(v,void 0,o,"employee",t.job_id)},`add-button-${v}`)})]},`employee-${t.job_id}-day-${v}`))})]})},ow=r.memo(rw),{cx:aw}=O("EventAddButton"),lw=({onClick:t,fullHeight:s,refHandler:n})=>rn()?null:e.jsx(i,{ref:n,className:aw(),h:s?38:19,w:"100%",mb:3,pointer:!0,onClick:t}),iw=({isOpen:t,anchorEl:s,selectedDayIndex:n,startDate:o,selectedEvent:a,onClose:l})=>
1{if(!t||n===null)return null;const c=kt(o,n);return e.jsx(zn,{open:t,anchorEl:s,showArrow:!0,stickToViewport:!0,placement:"bottom-end",children:e.jsx(nn,{onClickAway:l,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsx(i,{minh:"min(350px, 50vh)",maxh:"min(736px, 90vh)",p:20,bgcolor:"white",bradiusm:!0,maxw:500,minw:456,shadow:"z3",children:e.jsx(bp,{id:a?.id,date:c,title:a?.title,description:a?.description,holiday:a?.holiday,onClose:l,isHolidaySettingEnabled:!0,showDateField:!1})})})})},Ad=({events:t,startDate:s,showSkeletons:n=!1})=>{const a=I(ix)==="pending",[l,c]=r.useState(null),{anchorEl:u,selectedDayIndex:h,isOpen:m,createRefHandler:_,createClickHandler:f,closePopper:g}=Np(),b=r.useCallback(()=>{g(),c(null)},[g]),x=r.useCallback((S,y)=>C=>{C.stopPropagation(),c(y||null),f(S)(C)},[f]),E=r.useMemo(()=>{const S=new Date(s),y=[];for(let v=0;v<Rc-1;v++){const T=new Date(S);T.setDate(S.getDate()+v),y.push(T.toISOString().split("T")[0])}const C=Array.from({length:Rc},()=>[]);return t.forEach(v=>{const T=v.date,D=y.indexOf(T);D!==-1&&C[D].push(v)}),C},[t,s]);return e.jsxs(e.Fragment,{children:[e.jsxs(Hn,{dataTestId:"event-row",columnGap:0,rowGap:0,columns:{sm:Tr},children:[e.jsx(i,{id:"event-row-header",bcolor:"mono100",flex:!0,alignItemsCenter:!0,gap:8,pv:8,btw:1}),E.map((S,y)=>e.jsxs(i,{blw:1,btw:1,bcolor:"mono100",column:!0,justifyContentEnd:!0,alignItemsCenter:!0,pt:4,gap:3,w:"100%",minh:26,children:[n&&e.jsx(i,{w:"91%",pv:3,children:e.jsx(cs,{bradiusm:!0,width:"90%",height:"33px"})}),!n&&!a&&S.map(C=>e.jsx(i,{onClick:x(y,C),pointer:!0,bradiuss:!0,bgcolor:"mono100",w:"80%",pv:2,ph:8,overflow:"hidden",truncate:!0,ellipsis:!0,title:C.title,children:e.jsx(j,{variant:"bodySm",color:C.holiday?"error500":"mono900",children:C.title})},`event-${C.id}`)),!(n||a)&&e.jsx(i,{w:"91%",justifyContentCenter:!0,alignItemsCenter:!0,children:e.jsx(lw,{refHandler:_(y,0),onClick:x(y),fullHeight:!1})})]},`event-day-${y}`))]}),e.jsx(iw,{isOpen:m,anchorEl:u,selectedDayIndex:h,startDate:s,selectedEvent:l,onClose:b})]})},{cx:cw,cxEl:dw}=O("AnimatedCollapse"),Gn=({isExpanded:t,children:s})=>e.jsx(i,{className:cw({expanded:t}),children:e.jsx(i,{className:dw("inner"),children:s})}),{cxEl:Od}=O("RoleGroup"),Pp=({label:t,badgeColor:s,groupKey:n,expanded:o,totalOpenShiftHours:a,onToggle:l,onDragExpand:c})=>{const u=r.useCallback(()=>l(n),[l,n]),h=I(E=>ks(E)===1),m=s||Bo(h),_=h?m:`${m}-v2`,{setNodeRef:f,isOver:g}=kr({id:`role-group-header-droppable:${n}`,data:{type:Zt.GROUP_HEADER,groupKey:n}}),b=r.useCallback(()=>{c?.(n)},[c,n]),{isShiftDragOver:x}=qi({isOver:g,isExpanded:o,onExpand:b});return e.jsxs(i,{ref:f,className:Od("header"),pointer:!0,minh:33,btw:1,bbw:o?1:0,bcolor:"mono100",bgcolor:x?"purple100":void 0,flex:!0,alignItemsCenter:!0,onClick:u,gap:8,ph:16,pl:16,children:[e.jsx(on,{expanded:o,label:t}),e.jsx(i,{className:Od("badge",_)}),e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:4,children:[e.jsx(j,{variant:"captionBold",children:t}),a!=null&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.separator")}),e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.open_shifts.hours",{props:{hours:Sr(a)}})})]})]})]})},Nd=({label:t,children:s,bottomBorder:n=!0,badgeColor:o,groupKey:a,expanded:l,onToggle:c})=>{const u=I(ni),h=I(ri),m=l||!u||h;return e.jsxs(e.Fragment,{children:[e.jsx(Pp,{label:t,bottomBorder:n,badgeColor:o,groupKey:a,expanded:m,onToggle:c}),e.jsx(Gn,{isExpanded:m,children:s})]})},$p=({label:t,bottomBorder:s=!0,forceBottomBorder:n=!1,groupKey:o,expanded:a,openShiftCount:l,totalOpenShiftHours:c,onToggle:u,onDragExpand:h})=>{const m=r.useCallback(()=>u(o),[u,o]),{setNodeRef:_,isOver:f}=kr({id:`row-group-header-droppable:${o}`,data:{type:Zt.GROUP_HEADER,groupKey:o}}),g=r.useCallback(()=>{h?.(o)},[h,o]),{isShiftDragOver:b}=qi({isOver:f,isExpanded:a,onExpand:g,delay:600});return e.jsxs(i,{id:`row-group-header-${o}`,ref:_,pointer:!0,btw:1,bbw:n||s&&!a?1:0,bcolor:"mono100",bgcolor:b?"purple100":void 0,flex:!0,alignItemsCenter:!0,onClick:m,gap:8,ph:16,pv:13,children:[e.jsx(on,{exp
1anded:a,label:t}),e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:4,children:[e.jsx(j,{variant:"heading4",children:t}),l!=null&&c!=null&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.separator")}),e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.open_shifts.shift_count",{props:{count:l}})}),e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.separator")}),e.jsx(j,{variant:"captions",color:"mono500",children:p("schedule_builder.agent.canvas.open_shifts.hours",{props:{hours:Sr(c)}})})]})]})]})},Ka=({label:t,children:s,bottomBorder:n=!0,groupKey:o,expanded:a,onToggle:l})=>{const c=I(ni),u=I(ri),h=a||!c||u;return e.jsxs(e.Fragment,{children:[e.jsx($p,{label:t,bottomBorder:n,groupKey:o,expanded:h,onToggle:l}),e.jsx(Gn,{isExpanded:h,children:s})]})},Vr=({showLeftSkeleton:t=!1})=>e.jsxs(Hn,{columnGap:0,columns:{sm:Tr},children:[e.jsx(i,{brw:1,bbw:1,bcolor:"mono100",minh:20,flex:!0,alignItemsCenter:!0,ml:8,children:t&&e.jsx(cs,{bradiusm:!0,width:"70%",height:"20px"})}),Array.from({length:7},(s,n)=>e.jsx(i,{blw:1,brw:1,bbw:1,bcolor:"mono100",column:!0,alignItemsCenter:!0,justifyContentCenter:!0,pt:4,pb:4,children:e.jsx(cs,{bradiusm:!0,width:"90%",height:"33px"})},n))]}),uw=()=>{const t=K(),s=X(),n=I(_t),o=I(qo),a=I(cx),l=I(Bn),c=I(ko),u=$i(c),h=I(Ro),m=I(Lo),_=I(Wl),f=I(S=>ct(S)),g=o==="failed"||!!a,b=r.useMemo(()=>_||u?"pre_publish":h||l==="pending"?"post_assign":m?"structure":"pre_assign",[_,u,h,l,m]),x=p("schedule_builder.agent.toast_errors.try_again");r.useEffect(()=>{g&&t(w.BANNER_VIEWED,k.VIEW,{banner_version:Lc,sba_phase:b,eventCategory:U.SCHEDULE_BUILDER,location_id:f})},[g,f,b,t]);const E=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{element:"retry_load_panel",button_text:x,banner_version:Lc,eventCategory:U.SCHEDULE_BUILDER}),n&&s(Gl({startDate:n}))},[s,n,t,x]);return g?e.jsx(i,{p:16,bbw:1,bcolor:"mono100",children:e.jsx(dt,{forceStacked:!0,variant:"error",action:e.jsx(V,{size:"small",variant:"tertiary",onClick:E,children:x}),children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:p("schedule_builder.agent.sidebar.review_panel_error")})})}):null},hw=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(uw),Kr="schedule_builder.agent.fill_shifts",mw=({handleAssignShifts:t,showFillChoice:s})=>{const n=X(),o=K(),a=I(Bn),l=I(dh),[c,u]=r.useState(!1),h=l.length>0,m=a==="pending",_=r.useCallback(()=>{o(w.BUTTON_CLICKED,k.CLICK,{element:"continue_to_review",button_text:p(`${Kr}.continue_to_review`),eventCategory:U.SCHEDULE_BUILDER_STRUCTURE}),n(dx(!0)),n(Mo(!0))},[n,o]),f=r.useCallback(b=>{o(b?w.CHECKBOX_SELECTED:w.CHECKBOX_UNSELECTED,k.CLICK,{element:"sba_auto_assign_shifts",eventCategory:U.SCHEDULE_BUILDER_STRUCTURE}),u(b)},[o]),g=r.useCallback(()=>{c&&(n(oi(!0)),at(ai,!0)),t()},[c,n,t]);return e.jsx(i,{btw:1,bcolor:"mono300",children:e.jsx(i,{p:16,flex:!0,column:!0,gap:8,children:s?e.jsxs(e.Fragment,{children:[e.jsx(V,{fullWidth:!0,variant:"primary",onClick:g,isLoading:m,disabled:m||!h,children:p(`${Kr}.assign_to_team`)}),e.jsx(V,{fullWidth:!0,variant:"secondary",onClick:_,children:p(`${Kr}.continue_to_review`)}),e.jsx(ro,{name:"assign-automatically-next-time",checked:c,onClick:f,label:p(`${Kr}.assign_automatically_next_time`)})]}):e.jsx(V,{fullWidth:!0,onClick:t,variant:"primary",isLoading:m,disabled:m||!h,children:p("schedule_builder.agent.assign_shifts")})})})},{cxEl:pw}=O("DoneFooter"),_w=({onClick:t})=>e.jsx(i,{btw:1,bcolor:"mono300",p:16,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,children:e.jsx(V,{fullWidth:!0,onClick:t,variant:"primary",className:pw("button"),children:p("schedule_builder.agent.done")})}),fw=()=>{const t=K(),{handlePublish:s,isPublishing:n}=Bi(),{saveDraftAndExit:o,isSaving:a}=op(),l=n||a,c=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"save_draft_and_exit",button_text:p("schedule_builder.agent.pre_publish_review.save_draft_and_exit")}),o()},[o,t]);return e.jsxs(i,{btw:1,bcolor:"mono300",p:16,flex:!0,column:!0,gap:8,alignItemsCenter:!0,justifyContentCenter:!0,children:[e.jsx(V,{fullWidth:!0,variant:"primary",onClick:s,isLoading:n,disabled:l,children:p("schedule_builder.agent.pre_publish_review.publish_button")}),e.jsx(V,{fullWidth:!0,variant:"secondary",onClick:c,isLoading:a,disabled:l,children:p("schedule_builder.agent.pre_publish_review.save_draft_and_exit")})]})},bw=()=>{const t=K(),s=X(),n=I(_t),o=I(ql),{totalWages:a,totalHours:l}=r.useMemo(()=>{let h=0,m=0;return o.forEach(_=>{h+=_.wages||0,m+=_.hours||0}),{totalWages:h,totalHours:m}},[o]),c=r.useCallback(()=>{n&&(t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_PUBLISH,element:"review",button_text:p("schedule_builder.agent.review"),total_shifts:o.length,total_hours:l,total_wages:a}),s(Mo(!0)))},[s,n,o.length,l,a,t]),u=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"save_as_a_draft",button_text:p("schedule_builder.agent.save_as_a_draft")}),s(Ys(!0))},[s,t]);return r.useEffect(()=>{t(w.PANEL_VIEWED,k.VIEW,{sba_phase:"pre_publish",eventCategory:U.SCHEDULE_BUILDER_PUBLISH,total_shifts:o.length,total_hours:l,total_wages:a})},[t,o.length,l,a]),e.jsx(i,{btw:1,bcolor:"mono300",children:e.jsxs(i,{children:[e.jsxs(i,{gap:8,ph:16,pt:16,alignItemsStart:!0,bcolor:"mono300",column:!0,children:[e.jsxs(i,{flex:!0,w:"100%",justifyContentSpaceBetween:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySm",children:p("schedule_builder.agent.labor_totals.title")}),e.jsx(j,{variant:"bodySmBold",children:pt(a)})]}),e.jsxs(i,{flex:!0,w:"100%",justifyContentSpaceBetween:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySm",children:p("schedule_builder.agent.labor_totals.hours")}),e.jsxs(j,{variant:"bodySm",children:[l.toFixed(2)," hrs"]})]})]}),e.jsxs(i,{p:16,flex:!0,column:!0,gap:8,alignItemsCenter:!0,justifyContentCenter:!0,bcolor:"mono300",children:[e.jsx(V,{fullWidth:!0,onClick:c,variant:"primary",children:p("schedule_builder.agent.review")}),e.jsx(V,{fullWidth:!0,onClick:u,variant:"secondary",children:p("schedule_builder.agent.save_as_a_draft")})]})]})})},gw=({onClick:t,onOpenSettings:s,settingsLinkRef:n})=>{const o=K(),a=X(),l=I(_t),c=I(Rs),[,u]=At(Gs,!1),[,h]=At(Nn,!1),m=r.useMemo(()=>l?Ie(l,Je).add(6,"days").format(Je):"",[l]),_=I(y=>uh(y,{startDate:l,endDate:m}));ps(w.PAGE_VIEWED,k.VIEW,{sba_phase:"ready",schedule_week:l});const f=r.useCallback(()=>{o(w.BUTTON_CLICKED,k.CLICK,{element:"start_draft",button_text:"Build schedule",schedule_week:l}),l&&a(Ao({startDate:l})),t()},[a,t,l,o]),g=r.useCallback(()=>
1{if(o(w.BUTTON_CLICKED,k.CLICK,{element:"start_manual",button_text:"Build Manually",schedule_week:l}),_.length>0){a(Ys(!0));return}u(!1),h(!0),a(Mn(!1))},[a,u,h,l,o,_]),{rangeStartMoment:b,rangeEndMoment:x}=Mr(),E=r.useMemo(()=>Zs(b,x),[x,b]),S=r.useCallback(()=>{o(w.LINK_CLICKED,k.CLICK,{element:"sba_zero_state_settings",linkText:p("schedule_builder.agent.zero_state.auto_assign_settings")}),s()},[s,o]);return e.jsxs(i,{h:"100%",flex:!0,column:!0,gap:4,alignItemsCenter:!0,justifyContentCenter:!0,w:"100%",children:[e.jsxs(i,{w:"90%",mb:18,flex:!0,column:!0,gap:8,children:[e.jsx(j,{textAlign:"left",variant:"heading3",children:p("schedule_builder.agent.zero_state.title")}),e.jsx(j,{textAlign:"left",variant:"bodySm",color:"secondary",children:p("schedule_builder.agent.zero_state.description",{props:{range:E}})})]}),e.jsxs(i,{w:"90%",gap:8,flex:!0,column:!0,children:[e.jsx(V,{fullWidth:!0,variant:"primary",size:"medium",onClick:f,children:p("schedule_builder.agent.zero_state.cta")}),e.jsx(V,{fullWidth:!0,variant:"secondary",size:"medium",onClick:g,children:p("schedule_builder.agent.zero_state.manual_cta")}),e.jsx(i,{p:9,children:e.jsxs(j,{variant:"bodySmTight",children:[p(c?"schedule_builder.agent.zero_state.auto_assign_on":"schedule_builder.agent.zero_state.auto_assign_off"),e.jsx("span",{ref:n,children:e.jsx(i,{pointer:!0,onClick:S,children:e.jsx(j,{color:"primary500",variant:"bodySmTight",children:p("schedule_builder.agent.zero_state.auto_assign_settings")})})})]})})]})]})},xw=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(gw),Cw=t=>{const s=I(ch),n=qn(),o=r.useMemo(()=>{const a={};for(const l of s)a[l.id]=l;return a},[s]);return r.useMemo(()=>{const a=t.find(m=>m.group_type===le.PENDING_PTO),c=(a?.items||[]).map(m=>{const _=m.meta??null,f=o[m.subject_id],g=_?.job_id??f?.job_id??"",b=_?.start_date??f?.start_at??"",x=_?.end_date??f?.end_at??"",E=_?.notes??f?.notes??null;return{id:m.id,requestId:m.subject_id,open:m.open,resolutionType:m.resolution_type,userName:g?n[g]??"":"",jobId:g,startDate:b,endDate:x,notes:E}}),u=vr(c,m=>m.requestId);return{itemsByEmployee:Object.values(u).map(m=>({requestId:m[0].requestId,jobId:m[0].jobId,userName:m[0].userName,startDate:m[0].startDate,endDate:m[0].endDate,notes:m[0].notes,open:m[0].open,resolutionType:m[0].resolutionType,openRequestIds:m.filter(_=>_.open).map(_=>_.id)})),availableResolutionTypes:a?.available_resolution_types??On}},[t,n,o])},Ew=2e3,Sw=2e3,Bp=({actionItemGroups:t,isRenderable:s,onCardExpanded:n,autoExpand:o=!0})=>{const[a,l]=r.useState(null),[c,u]=r.useState(!1),[h,m]=r.useState(!1),_=r.useRef(!1),f=r.useRef(!1);r.useEffect(()=>{const v=window.setTimeout(()=>m(!0),Ew);return()=>window.clearTimeout(v)},[]);const g=t.some(s),b=t.find(v=>s(v)&&v.open)?.group_type??null,x=a?t.find(v=>v.group_type===a):void 0,E=!!x,S=!!x&&!x.open,y=(()=>{if(!a)return null;const v=t.findIndex(D=>D.group_type===a);return v===-1?null:t.slice(v+1).find(s)?.group_type??null})();r.useEffect(()=>{_.current||o&&h&&g&&(_.current=!0,u(!!b),l(b))},[o,h,g,b]),r.useEffect(()=>{f.current=S,a&&!c&&n?.(a)},[a]),r.useEffect(()=>{if(!a)return;if(!E){u(!1),l(y);return}if(!S||f.current)return;const v=window.setTimeout(()=>{u(!1),l(y)},Sw);return()=>window.clearTimeout(v)},[a,E,S,y]);const C=r.useCallback(v=>T=>{u(!1),l(T?v:null)},[]);return{expandedCard:a,handleToggle:C}},an=({processingText:t})=>e.jsx(i,{pv:16,btw:1,bcolor:"mono300",children:e.jsxs(i,{flex:!0,pt:8,alignItemsCenter:!0,children:[e.jsx(i,{w:16,h:16,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,style:{transform:"scale(0.75)",transformOrigin:"center"},children:e.jsx($n,{variant:"dark",size:"small"})}),e.jsx(i,{pl:8,children:e.jsx(j,{variant:"bodySmTight",children:t})})]})}),Pr=()=>e.jsx(i,{id:"success-icon",minw:16,h:16,bgcolor:"green100",bradiusl:!0,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,children:e.jsx(i,{style:{transform:"scale(0.75)",transformOrigin:"center"},children:e.jsx(Q,{iconName:"Success",color:"green300",size:"xsmall"})})}),zt=({text:t})=>e.jsxs(i,{flex:!0,gap:8,children:[e.jsx(i,{pt:4,children:e.jsx(Pr,{})}),e.jsx(i,{children:e.jsx(j,{variant:"bodySmTight",color:"mono700",children:t})})]}),jw=3,Ds=({items:t,initialCount:s=jw})=>{const[n,o]=r.useState(!1),a=r.useCallback(()=>{o(h=>!h)},[]),l=n?t:t.slice(0,s),c=t.length>s,u=t.length-s;return e.jsxs(i,{column:!0,gap:4,pt:16,children:[l,c&&e.jsxs(i,{alignItemsCenter:!0,pointer:!0,pt:4,onClick:a,flex:!0,children:[e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:n?p("schedule_builder.agent.sidebar.pre_flight_checks.show_less"):p("schedule_builder.agent.sidebar.pre_flight_checks.show_more",{props:{count:u}})}),e.jsx(Q,{ml:8,size:"xsmall",color:"accent",iconName:n?"SortUp":"SortDown"})]})]})},Md=({item:t,onClick:s})=>{const n=r.useCallback(()=>{s(t.jobId)},[s,t.jobId]);return e.jsx(i,{pointer:!0,onClick:n,children:e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:t.userName})})},yw=({items:t,availableResolutionTypes:s})=>{const n=K(),o=X(),a=Os(),l=I(_t),{sendingIsProcessing:c,messageSent:u}=I(C=>hh(C,It.MISSING)),h=new Set(s),m=t.filter(C=>C.open),_=m.map(C=>C.id),f=_.length>0,[g,b]=r.useState(!1);ps(w.PAGE_VIEWED,k.VIEW,{conflict_type:"missing_availability",conflict_count:_.length,card_prominence:"standard"});const x=r.useMemo(()=>u?p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.messages_sent_text",{props:{date:Oe(l,"month_day_ordinal")}}):m.length===1?p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.default_text_one",{props:{name:m[0].userName}}):p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.default_text_many",{props:{count:m.length}}),[u,l,m]),E=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"resolve_conflict",button_text:"Send Reminder",conflict_type:"missing_availability"}),o(ws(It.MISSING)),o(Tt(!0))},[o,n]),S=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"dismiss_conflict",button_text:"Skip",conflict_type:"no_availability"}),b(!0),o(Ot({action_item_ids:_,resolution_type:fe.SKIP,resolution_payload:{}})).finally(()=>b(!1))},[o,_,n]),y=r.useCallback(C=>{a(C)},[a]);if(c||g)return e.jsx(an,{processingText:p(g?"schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.updating":"schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.sending_reminder")});if(!f){const C=u?p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.messages_sent_text",{props:{date:Oe(l,"month_day_ordinal")}}):p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.ignored_text");return e.jsxs(i,{pv:16,children:[e.jsx(zt,{text:C}),e.jsx(Ds,{items:t.map(v=>e.jsx(Md,{item:v,onClick:y},v.id))})]})}return e.jsxs(i,{pv:16,children:[e.jsxs(i,{flex:!0,maxw:240,gap:8,children:[u&&e.jsx(i,{mt:3,children:e.jsx(Pr,{})}),e.jsx(j,{variant:"bodySmTight",children:x})]}),e.jsx(Ds,{items:m.map(C=>e.jsx(Md,{item:C,onClick:y},C.id))}),e.jsxs(i,{column:!0,gap:8,pt:16,children:[h.has(fe.REQUEST_AVAILABILITY)&&e.jsx(V,{fullWidth:!0,size:"small",onClick:E,children:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.send_reminder")}),h.has(fe.SKIP)&&e.jsx(V,{variant:"secondary",fullWidth:!0,size:"small",onClick:S,children:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.ignore")})]})]})},vw=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(yw),Iw=t=>t===fe.APPROVE?p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.pto_status",{props:{status:"approved"}}):t===fe.DECLINE?p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.pto_status",{props:{status:"declined"}}):t===fe.SKIP?p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.pto_kept_scheduled"):null,Tw=({index:t,group:s,canApprove:n,canDecline:o,showNotes:a=!0,isBulkProcessing:l=!1,nextJobId:c})=>{const u=K(),h=X(),m=I(_t),_=Os(),[f,g]=r.useState(!1),{jobId:b,userName:x,startDate:E,endDate:S,notes:y,resolutionType:C,openRequestIds:v}=s,T=v.length>0,D=f||l&&T,L=Iw(C),A=r.useCallback(()=>{_(b)},[_,b]),P=r.useCallback(()=>{c&&_(c)},[c,_]),M=r.useCallback(()=>{T&&(u(w.BUTTON_CLICKED,k.CLICK,{element:"resolve_conflict",button_text:"Approve",conflict_type:"pending_pto",resolution:"approve",employee_id:b}),g(!0),P(),h(Ot({action_item_ids:v,resolution_type:fe.APPROVE,resolution_payload:{}})).then(()=>{m&&h(xr({startDate:m}))}).finally(()=>g(!1)))},[h,T,b,v,P,m,u]),R=r.useCallback(()=>{T&&(u(w.BUTTON_CLICKED,k.CLICK,{element:"resolve_conflict",button_text:"Decline",conflict_type:"pending_pto",resolution:"decline",employee_id:b}),g(!0),P(),h(Ot({action_item_ids:v,resolution_type:fe.DECLINE,resolution_payload:{}})).then(()=>{m&&h(xr({startDate:m}))}).finally(()=>g(!1)))},[h,T,b,v,P,m,u]);return D?e.jsx(an,{processingText:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.processing")}):e.jsxs(i,{pt:t===0?0:16,pb:16,btw:t===0?0:1,bcolor:"mono300",children:[e.jsx(i,{pointer:!0,onClick:A,inline:!0,children:e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:x})}),e.jsx(j,{variant:"bodySm",children:Zs(ed(E),ed(S))}),!T&&L!==null?e.jsx(i,{pt:8,children:e.jsx(zt,{text:L})}):e.jsxs(e.Fragment,{children:[a&&y&&e.jsx(i,{mt:8,blw:3,bcolor:"mono100",children:e.jsx(i,{pl:12,maxw:240,children:e.jsx(j,{variant:"bodySm",children:y})})}),e.jsxs(i,{pt:16,spacebetween:!0,gap:8,children:[n&&e.jsx(V,{size:"small",grow:!0,onClick:M,children:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.approve")}),o&&e.jsx(V,{variant:"secondary",size:"small",grow:!0,onClick:R,children:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.decline")})]})]})]})},ww=({itemsByEmployee:t,availableResolutionTypes:s})=>{const n=K(),o=X(),a=I(_t),[l,c]=r.useState(!1),u=new Set(s),h=t.flatMap(b=>b.openRequestIds),m=h.length>0,_=t.length<Rr;ps(w.PAGE_VIEWED,k.VIEW,{conflict_type:"pending_pto",conflict_count:h.length,card_prominence:"blocking"});const f=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"resolve_conflict",button_text:"Approve all",conflict_type:"pending_pto",resolution:"approve_all",pto_count:h.length}),c(!0),o(Ot({action_item_ids:h,resolution_type:fe.APPROVE,resolution_payload:{}})).then(()=>{a&&o(xr({startDate:a}))}).finally(()=>c(!1))},[o,h,a,n]),g=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"dismiss_conflict",button_text:"Skip",conflict_type:"pending_pto",unresolved_pto_count:h.length}),c(!0),o(Ot({action_item_ids:h,resolution_type:fe.SKIP,resolution_payload:{}})).then(()=>{a&&o(xr({startDate:a}))}).finally(()=>c(!1))},[o,h,a,n]);return e.jsx(i,{children:e.jsxs(i,{pt:16,children:[h.length>1&&u.has(fe.APPROVE)&&e.jsx(i,{pb:16,btw:1,bcolor:"mono300",children:e.jsx(V,{fullWidth:!0,size:"small",onClick:f,children:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.approve_all")})}),t.map((b,x)=>{const E=t.slice(x+1).find(S=>S.openRequestIds.length>0);return e.jsx(Tw,{index:x,group:b,canApprove:u.has(fe.APPROVE),canDecline:u.has(fe.DECLINE),nextJobId:E?.jobId,isBulkProcessing:l,showNotes:_},b.requestId)}),m&&u.has(fe.SKIP)&&e.jsx(i,{pv:16,btw:1,bcolor:"mono300",children:e.jsx(V,{variant:"secondary",fullWidth:!0,size:"small",onClick:g,children:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.skip")})})]})})},Dw=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(ww),Pd=({group:t,onClick:s,showDays:n=!0})=>{const o=r.useCallback(()=>{s(t.jobId)},[s,t.jobId]);return e.jsxs(i,{spacebetween:!0,onClick:o,pointer:!0,children:[e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:t.userName}),n&&e.jsx(j,{variant:"bodySmTight",color:"mono500",children:`${t.numOfDays} days`})]})},kw=({itemsByEmployee:t,availableResolutionTypes:s})=>{const n=K(),o=X(),a=Os(),[l,c]=r.useState(!1),u=new Set(s),{sendingIsProcessing:h,messageSent:m}=I(S=>hh(S,It.STALE)),_=t.flatMap(S=>S.openRequestIds),f=_.length>0,g=m||t.some(S=>S.resolutionType===fe.REQUEST_AVAILABILITY),b=r.useCallback(()=>{o(ws(It.STALE)),o(Tt(!0))},[o]),x=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"dismiss_conflict",button_text:"Skip",conflict_type:"stale_availability"}),c(!0),o(Ot({action_item_ids:_,resolution_type:fe.IGNORE,resolution_payload:{}})).finally(()=>c(!1))},[o,_,n]),E=r.useCallback(S=>{a(S)},[a]);if(l||h)return e.jsx(an,{processingText:p(l?"schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.updating":"schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.sending_reminders")});if(!f){const S=g?p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.messages_sent_text"):p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.ignored_text");return e.jsxs(i,{pv:16,children:[e.jsx(zt,{text:S}),e.jsx(Ds,{items:t.map(y=>e.jsx(Pd,{group:y,onClick:E,showDays:!1},y.jobId))})]})}return e.jsxs(i,{pv:16,children:[e.jsx(i,{flex:!0,maxw:240,children:e.jsx(i,{pl:8,children:e.jsx(j,{variant:"bodySmTight",children:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.default_text")})})}),e.jsx(Ds,{items:t.map(S=>e.jsx(Pd,{group:S,onClick:E},S.jobId))}),e.jsxs(i,{column:!0,gap:8,pt:16,children:[u.has(fe.REQUEST_AVAILABILITY)&&e.jsx(V,{fullWidth:!0,size:"small",onClick:b,children:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.send_reminder")}),u.has(fe.IGNORE)&&e.jsx(V,{variant:"secondary",fullWidth:!0,size:"small",onClick:x,children:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.ignore")})]})]})},{cx:Rw}=O("AgentActionCard"),Lw=({title:t,count:s,children:n,iconName:o,collapsible:a=!0,initiallyExpanded:l
1=!1,resolved:c=!1,previousResolution:u,onToggle:h})=>{const m=K(),[_,f]=r.useState(l),g=r.useCallback(()=>{f(b=>{c&&m(w.BUTTON_CLICKED,k.CLICK,{element:"reopen_decision_card ",conflict_type:t,previous_resolution:u??void 0});const x=!b;return h?.(x),x})},[h,t,c,u,m]);return r.useEffect(()=>{f(l)},[l]),e.jsxs(i,{bradiusm:!0,bw:1,bcolor:"mono100",children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,pointer:a,onClick:a?g:void 0,ph:16,pv:12,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[o&&e.jsx(i,{className:Rw({icon:!c,"icon-resolved":c,"icon-expanded":a&&!c&&_,"icon-collapsed":a&&!c&&!_}),children:c?e.jsx(i,{bgcolor:"green100",p:4,bradiusm:!0,opacity:c&&!_?.5:1,children:e.jsx(i,{style:{transform:"scale(0.75)",transformOrigin:"center"},children:e.jsx(Q,{iconName:"Success",color:"green300",size:"xsmall"})})}):o?e.jsx(ns,{iconName:o,size:"small"}):null}),e.jsx(j,{variant:"bodySmBold",color:c&&a&&!_?"mono500":"mono900",children:t})]}),e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[!!s&&e.jsx(wr,{variant:"mono",children:String(s)}),a&&e.jsx(on,{expanded:_,size:"small"})]})]}),e.jsx(Gn,{isExpanded:_,children:e.jsx(i,{btw:1,bcolor:"mono100",children:e.jsx(i,{ph:16,children:n})})})]})},us=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(Lw),Up=()=>{const t=I(yr),s=I(Rs),{itemsByEmployee:n,availableResolutionTypes:o}=Cw(t),{items:a,availableResolutionTypes:l,openCount:c}=sp(t),u=a.length>0,h=n.filter(T=>T.open).length,m=n.length>0,{itemsByEmployee:_,availableResolutionTypes:f}=ap(t),g=_.filter(T=>T.open).length,b=_.length>0,x=Os(),E=r.useCallback(T=>T.group_type===le.PENDING_PTO?m:T.group_type===le.MISSING_AVAILABILITY?u:T.group_type===le.STALE_AVAILABILITY?b:!1,[u,m,b]),S=r.useMemo(()=>t.filter(E),[t,E]),y=r.useCallback(T=>{if(T==="pending_pto"){const D=n.find(L=>L.open);D&&x(D.jobId)}if(T==="missing_availability"){const D=a.find(L=>L.open);D&&x(D.jobId)}},[n,a,x]),{expandedCard:C,handleToggle:v}=Bp({actionItemGroups:t,isRenderable:E,onCardExpanded:y,autoExpand:!s});return e.jsx(i,{flex:!0,column:!0,gap:12,children:e.jsx(i,{flex:!0,column:!0,gap:8,children:S.map((T,D)=>e.jsxs(As,{delay:mh,children:[T.group_type===le.PENDING_PTO&&m&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.pre_flight_checks.pto_requests_card.title"),iconName:"Calendar",count:h,initiallyExpanded:C===le.PENDING_PTO,resolved:!T.open,previousResolution:Us(T),onToggle:v(le.PENDING_PTO),children:e.jsx(Dw,{itemsByEmployee:n,availableResolutionTypes:o})}),T.group_type===le.MISSING_AVAILABILITY&&u&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.pre_flight_checks.missing_availability_card.title"),iconName:"Clock",count:c,initiallyExpanded:C===le.MISSING_AVAILABILITY,resolved:!T.open,previousResolution:Us(T),onToggle:v(le.MISSING_AVAILABILITY),children:e.jsx(vw,{items:a,availableResolutionTypes:l})}),T.group_type===le.STALE_AVAILABILITY&&b&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.pre_flight_checks.stale_availability_card.title"),iconName:"Hourglass",count:g,initiallyExpanded:C===le.STALE_AVAILABILITY,resolved:!T.open,previousResolution:Us(T),onToggle:v(le.STALE_AVAILABILITY),children:e.jsx(kw,{itemsByEmployee:_,availableResolutionTypes:f})})]},`${T.group_type}-${D}`))})})},qr=["schedule_builder.agent.sidebar.building_draft.checking_pto","schedule_builder.agent.sidebar.building_draft.reviewing_missing_availability","schedule_builder.agent.sidebar.building_draft.reviewing_stale_availability","schedule_builder.agent.sidebar.building_draft.matching_roles","schedule_builder.agent.sidebar.building_draft.applying_preferences"],yl=1e3,Aw=4,Ow=yl*Aw,Nw=()=>{const t=X(),s=K(),n=I(qo),[o,a]=r.useState(1);return r.useEffect(()=>{s(w.PAGE_VIEWED,k.VIEW,{panel_type:"SBA",thinking_phase:"pre_assign"})},[s]),r.useEffect(()=>{if(o<qr.length){const l=window.setTimeout(()=>{a(c=>c+1)},yl);return()=>{window.clearTimeout(l)}}if(n==="pending"){const l=window.setTimeout(()=>{a(1)},yl);return()=>{window.clearTimeout(l)}}},[t,o,n]),e.jsxs(i,{flex:!0,column:!0,gap:8,id:"building-draft-step",children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(i,{w:16,h:16,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,style:{transform:"scale(0.75)",transformOrigin:"center"},children:e.jsx($n,{size:"small",variant:"dark"})}),e.jsx(j,{variant:"bodySmBold",color:"mono900",children:p("schedule_builder.agent.sidebar.building_draft.title")})]}),e.jsx(i,{flex:!0,column:!0,gap:4,ml:33,children:o>0&&o<=qr.length&&e.jsx(As,{children:e.jsx(j,{isAIAnimating:!0,variant:"bodySm",color:"secondary",children:p(qr[o-1])})},qr[o-1])})]})},{cx:Mw}=O("SidebarStep"),Hp=({children:t})=>e.jsx(i,{className:Mw(),flex:!0,column:!0,gap:8,children:t}),$d={pending_pto:"schedule_builder.agent.draft_ready.pending_pto",missing_availability:"schedule_builder.agent.draft_ready.missing_availability",stale_availability:"schedule_builder.agent.draft_ready.stale_availability"},Pw=()=>{const t=K(),s=I(yr),n=r.useMemo(()=>s.filter(c=>$d[c.group_type]).map(c=>p($d[c.group_type],{props:{count:c.subject_count}})),[s]),[o,a]=r.useState(!1),l=r.useCallback(()=>{a(c=>!c)},[]);return r.useEffect(()=>{t(w.PAGE_VIEWED,k.VIEW,{panel_type:"SBA",thinking_phase:"structure"})},[t]),e.jsxs(Hp,{children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,pointer:!0,onClick:l,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Pr,{}),e.jsx(i,{flex:!0,column:!0,gap:2,children:e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.agent.draft_ready.title")})})]}),e.jsx(i,{flex:!0,alignItemsCenter:!0,gap:4,children:n.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"bodySm",color:"mono700",children:p("schedule_builder.agent.draft_ready.steps_count",{props:{count:n.length}})}
1),e.jsx(on,{expanded:o,label:"Expand",size:"small"})]})})]}),e.jsx(Gn,{isExpanded:o,children:e.jsx(i,{flex:!0,column:!0,gap:4,pl:28,children:n.map(c=>e.jsx(j,{variant:"bodySm",color:"secondary",children:c},c))})})]})},$w=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_STRUCTURE})(Pw),Bd="â",ls=(t,s)=>p(`schedule_builder.agent.schedule_published.${t}`,s),qt=({label:t,value:s,bold:n=!1})=>e.jsxs(i,{flex:!0,w:"100%",justifyContentSpaceBetween:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySm",children:t}),e.jsx(j,{color:n?"mono900":"mono700",variant:n?"bodySmBold":"bodySm",children:s})]}),Bw=({loading:t=!1})=>{const s=K(),n=I(ux),o=I(hx),a=r.useRef(null);r.useEffect(()=>{s(w.PANEL_VIEWED,k.VIEW,{sba_phase:"published",eventCategory:U.SCHEDULE_BUILDER_PUBLISH,shift_count:n?.shifts||0,employee_count:n?.teamMembers||0})},[s,n?.shifts,n?.teamMembers]);const l=t&&!n;return r.useEffect(()=>{if(l)return;const c=setTimeout(()=>{const u=a.current?.closest("[data-sidebar-scroll]");u&&u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},100);return()=>clearTimeout(c)},[l]),l?null:e.jsx(i,{ref:a,minh:"101%",flex:!0,column:!0,gap:4,children:e.jsxs(As,{children:[e.jsx(us,{title:ls("title"),resolved:!0,collapsible:!1,initiallyExpanded:!0,children:n?e.jsxs(i,{flex:!0,column:!0,gap:8,mt:8,mb:12,children:[e.jsx(qt,{label:ls("labor_cost"),value:pt(n.laborCost),bold:!0}),e.jsx(qt,{label:ls("hours"),value:`${n.totalHours.toFixed(2)} hrs`}),e.jsx(qt,{label:ls("shifts"),value:String(n.shifts)}),e.jsx(qt,{label:ls("team_members"),value:String(n.teamMembers)}),e.jsx(qt,{label:ls("week"),value:n.windowStartDate&&n.windowEndDate?Zs(lt(n.windowStartDate),lt(n.windowEndDate)):Bd}),e.jsx(qt,{label:ls("published"),value:n.publishedAt?lt(n.publishedAt).format("MMM D, YYYY, h:mm A"):Bd})]}):e.jsx(i,{mt:8,mb:12,children:e.jsx(j,{color:"mono700",variant:"captions",children:ls("no_summary")})})}),n&&o>0&&e.jsx(i,{mt:12,children:e.jsx(dt,{variant:"success",children:ls("notifications_sent",{props:{count:o}})})})]})})},Uw=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(Bw),Qn="â",Zn=t=>p(`schedule_builder.agent.schedule_published.${t}`),Hw={location:{buttonText:"Notify everyone",notificationType:"all"},job:{buttonText:"Only members with changes",notificationType:"changes_only"},nobody:{buttonText:"Don't notify anyone",notificationType:"none"}},Ps=(t,s)=>p(`schedule_builder.agent.pre_publish_review.${t}`,s),Fw=()=>{const t=K(),s=I(mx),n=I(px),o=I(Ou),a=I(h=>ct(h)),l=X();ps(w.MODAL_VIEWED,k.VIEW,{modal_source:"publish_notification_selection",eventCategory:U.SCHEDULE_BUILDER,location_id:a});const c=r.useMemo(()=>[{value:"location",label:Ps("notify_options.location")},{value:"job",label:Ps("notify_options.job")},{value:"nobody",label:Ps("notify_options.nobody")}],[]),u=r.useCallback(h=>{if(h===o)return;const{buttonText:m,notificationType:_}=Hw[h];t(w.BUTTON_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER,element:"notification_option",button_text:m,notification_type:_,location_id:a}),l(_x(h))},[l,a,o,t]);return r.useEffect(()=>{const h=document.querySelector("[data-sidebar-scroll]");h&&h.scrollTo({top:h.scrollHeight,behavior:"smooth"})},[]),e.jsx(i,{flex:!0,column:!0,grow:1,minh:"100%",gap:12,children:e.jsx(As,{delay:100,children:e.jsxs(i,{grow:1,children:[e.jsx(us,{title:Ps("title"),collapsible:!1,initiallyExpanded:!0,children:e.jsxs(i,{flex:!0,column:!0,gap:8,mt:8,mb:12,children:[e.jsx(qt,{label:Zn("labor_cost"),value:s?pt(s.laborCost):Qn,bold:!0}),e.jsx(qt,{label:Zn("hours"),value:s?`${s.totalHours.toFixed(2)} hrs`:Qn}),e.jsx(qt,{label:Zn("shifts"),value:s?String(s.shifts):Qn}),e.jsx(qt,{label:Zn("team_members"),value:s?String(s.teamMembers):Qn}),e.jsx(qt,{label:Zn("week"),value:s?.windowStartDate&&s?.windowEndDate?Zs(lt(s.windowStartDate),lt(s.windowEndDate)):Qn})]})}),e.jsxs(i,{mt:20,column:!0,gap:8,mb:20,children:[e.jsx(j,{variant:"bodySmBold",children:Ps("notifications")}),e.jsx(j,{variant:"bodySm",color:"mono700",children:Ps("notify_subtitle")})]}),e.jsx(Ht,{initialValues:{notificationGroup:o},onSubmit:void 0,children:()=>e.jsx(li,{name:"notification-group",children:c.map(h=>e.jsx(i,{onClick:()=>
1u(h.value),children:e.jsx(ii,{label:e.jsx(j,{variant:"bodySm",color:"mono900",children:h.label}),name:"notification-group",checked:o===h.value},h.value)},h.value))})}),n>0&&e.jsx(i,{ml:2,mt:16,children:e.jsx(pl,{message:Ps("missing_contact_info",{props:{count:n}}),variant:"warning"})})]})})})},Ww=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER})(Fw),Vw=t=>{const s=qn();return r.useMemo(()=>{const n=t.find(u=>u.group_type===le.USER_OVER_HOURS),a=(n?.items||[]).map(u=>{const h=u.meta??null,m=h?.job_id??u.subject_id??"";return{id:u.id,jobId:m,userName:m?s[m]??"":"",overTimeHours:h?.overtime_hours??0,usualAverageHours:h?.usual_average_hours??0,open:u.open,resolutionType:u.resolution_type}}),l=vr(a,u=>u.jobId);return{itemsByEmployee:Object.values(l).map(u=>({jobId:u[0].jobId,userName:u[0].userName,overTimeHours:u[0].overTimeHours,usualAverageHours:u[0].usualAverageHours,open:u.some(h=>h.open),openItemIds:u.filter(h=>h.open).map(h=>h.id),resolutionType:u[0].resolutionType})),availableResolutionTypes:n?.available_resolution_types??On}},[t,s])},Ud=t=>t?lt(t).format("ddd"):"",Hd=t=>t?lt(t).format("ha"):"",Kw=t=>{const s=qn();return r.useMemo(()=>{const n=t.find(u=>u.group_type===le.INSUFFICIENT_REST),a=(n?.items||[]).map(u=>{const h=u.meta??null,m=h?.employee_id??u.subject_id??"";return{id:u.id,jobId:m,userName:m?s[m]??"":"",closingDay:Ud(h?.closing_at),closingTime:Hd(h?.closing_at),closingShiftId:h?.closing_shift_id??"",openingDay:Ud(h?.opening_at),openingTime:Hd(h?.opening_at),openingShiftId:h?.opening_shift_id??"",hoursBetweenShifts:h?.hours_between_shifts??0,open:u.open,resolutionType:u.resolution_type}}),l=vr(a,u=>u.jobId);return{itemsByEmployee:Object.values(l).map(u=>({jobId:u[0].jobId,userName:u[0].userName,closingDay:u[0].closingDay,closingTime:u[0].closingTime,closingShiftId:u[0].closingShiftId,openingDay:u[0].openingDay,openingTime:u[0].openingTime,openingShiftId:u[0].openingShiftId,hoursBetweenShifts:u[0].hoursBetweenShifts,open:u.some(h=>h.open),openItemIds:u.filter(h=>h.open).map(h=>h.id),resolutionType:u[0].resolutionType})),availableResolutionTypes:n?.available_resolution_types??On}},[t,s])},Fd=t=>t.minutes()===0?t.format("ha"):t.format("h:mma"),qw=(t,s)=>{if(!t||!s)return"";const n=Ie(t),o=Ie(s);return`${n.format("ddd")} ${Fd(n)} â ${Fd(o)}`},zw=t=>{const s=qn();return r.useMemo(()=>{const n=t.find(l=>l.group_type===le.SHIFT_NEEDS_REVIEW);return{items:(n?.items||[]).map(l=>{const c=l.meta??null,u=c?.employee_id??l.subject_id??"";return{id:l.id,jobId:u,userName:u?s[u]??"":"",shiftLabel:qw(c?.shift_start_at,c?.shift_end_at),reason:c?.reason??"",open:l.open,resolutionType:l?.resolution_type}}),availableResolutionTypes:n?.available_resolution_types??On}},[t,s])},Gw=[],Yw=t=>{const s=I(ku),n=I(Ho);return r.useMemo(()=>{const o=Jv(s,"id"),a={};for(const c of n)a[c.id]=c.name;const l=t.find(c=>c.group_type===le.NO_COVERAGE_AVAILABLE);return{requests:fx(l?.items||[],o,a),availableResolutionTypes:l?.available_resolution_types??Gw}},[t,s,n])},Fp=({onClick:t,children:s})=>e.jsx(i,{pointer:!0,onClick:t,children:e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:s})}),Jw=({item:t,index:s,resolutionTypes:n})=>{const o=X(),[a,l]=r.useState(!1),[c,u]=r.useState(""),[h,m]=r.useState(!t.open),_=Os(),f=new Set(n),{jobId:g,openItemIds:b}=t,x=t.overTimeHours+t.usualAverageHours,E=r.useCallback(()=>{_(g)},[_,g]),S=r.useCallback(()=>{l(!0),u(p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.acknowledging")),o(Ot({action_item_ids:b,resolution_type:fe.ACKNOWLEDGE_AND_PROCEED,resolution_payload:{}})).then(()=>{l(!1),m(!0)})},[o,b]),y=()=>h?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.acknowledged")}):e.jsx(i,{column:!0,gap:8,pt:16,children:f.has(fe.ACKNOWLEDGE_AND_PROCEED)&&e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",onClick:S,children:p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.got_it")})});return a?e.jsx(an,{processingText:c}):e.jsxs(i,{pv:16,btw:s===0?0:1,bcolor:"mono300",children:[e.jsx(Fp,{onClick:E,children:t.userName}),e.jsxs(i,{column:!0,gap:4,pv:8,children:[e.jsx(j,{variant:"bodySm",color:"mono500",children:p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.hours_above_usual",{props:{hours:fn(t.overTimeHours)}})}),e.jsx(j,{variant:"bodySm",color:"mono500",noWrap:!0,children:p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.hours_summary",{props:{assignedHours:fn(x),usualHours:fn(t.usualAverageHours,0)}})})]}),y()]})},Xw=2,Qw=({itemsByEmployee:t,availableResolutionTypes:s})=>{const n=t.map((o,a)=>e.jsx(Jw,{index:a,item:o,resolutionTypes:s},a));return t.length<Rr?e.jsx(i,{children:n}):e.jsx(i,{pb:16,children:e.jsx(Ds,{items:n,initialCount:Xw})})}
1,Zw=({item:t,index:s,isActiveRow:n,onActivateRow:o,resolutionTypes:a})=>{const l=X(),[c,u]=r.useState(!1),[h,m]=r.useState(""),[_,f]=r.useState(!t.open&&t.resolutionType===fe.KEEP_ASSIGNMENT),[g,b]=r.useState(!t.open&&t.resolutionType===fe.REASSIGN_OPENING_SHIFT),[x,E]=r.useState(!t.open&&t.resolutionType===fe.REASSIGN_CLOSING_SHIFT),S=I(q=>ci(q,le.INSUFFICIENT_REST)),y=new Set(a),C=Os(),{jobId:v,openItemIds:T}=t,{userName:D,closingDay:L,closingTime:A,openingDay:P,openingTime:M,hoursBetweenShifts:R}=t;r.useEffect(()=>{n&&(S===vt.PROCESSING?(u(!0),m(p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.finding_replacement"))):S===vt.OPENING_SHIFT_REASSIGNED?(u(!1),b(!0)):S===vt.CLOSING_SHIFT_REASSIGNED&&(u(!1),E(!0)))},[S,n]);const $=r.useCallback(()=>{C(v)},[C,v]),B=r.useCallback(()=>{u(!0),m(p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.updating_schedule")),l(Ot({action_item_ids:T,resolution_type:fe.KEEP_ASSIGNMENT,resolution_payload:{}})).then(()=>{f(!0)}).finally(()=>{u(!1)})},[l,T]),W=r.useCallback(()=>{o(s),l(Vs({actionItem:le.INSUFFICIENT_REST,status:""})),l(_r(le.INSUFFICIENT_REST)),l(jn(vt.OPENING_SHIFT_REASSIGNED)),l(yn(T)),l(pr(v)),l(Tt(!0))},[l,s,o,T,v]),N=r.useCallback(()=>{o(s),l(Vs({actionItem:le.INSUFFICIENT_REST,status:""})),l(_r(le.INSUFFICIENT_REST)),l(jn(vt.CLOSING_SHIFT_REASSIGNED)),l(yn(T)),l(pr(v)),l(Tt(!0))},[l,s,o,T,v]),H=()=>_?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.assignment_kept",{props:{hrs:fn(R)}})}):g?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.opening_shift_reassigned")}):x?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.closing_shift_reassigned")}):e.jsxs(i,{column:!0,gap:8,pt:16,children:[y.has(fe.KEEP_ASSIGNMENT)&&e.jsx(V,{fullWidth:!0,size:"small",onClick:B,children:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.keep_assignment")}),y.has(fe.REASSIGN_OPENING_SHIFT)&&e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",onClick:W,children:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.reassign_opening_shift")}),y.has(fe.REASSIGN_CLOSING_SHIFT)&&e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",onClick:N,children:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.reassign_closing_shift")})]});return c?e.jsx(an,{processingText:h}):e.jsxs(i,{pt:s===0?0:16,pb:16,btw:s===0?0:1,bcolor:"mono300",children:[e.jsx(i,{pointer:!0,onClick:$,children:e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:D})}),e.jsxs(i,{flex:!0,gap:8,pv:8,children:[e.jsx(j,{variant:"bodySm",color:"mono500",children:`${L} close ${A} -> ${P} open ${M}`}),e.jsx(j,{variant:"bodySm",color:"mono500",children:`${fn(R)} hrs`})]}),H()]})},eD=2,tD=({itemsByEmployee:t,availableResolutionTypes:s})=>{const[n,o]=r.useState(null),a=r.useCallback(c=>{o(c)},[]),l=t.map((c,u)=>e.jsx(Zw,{index:u,item:c,isActiveRow:n===u,onActivateRow:a,resolutionTypes:s},c.jobId));return t.length<Rr?e.jsx(i,{children:l}):e.jsx(i,{pb:16,children:e.jsx(Ds,{items:l,initialCount:eD})})},sD=(t,s,n)=>{const o=new Set(s),a=n===void 0?0:t.indexOf(n)+1;for(let l=a;l<t.length;l+=1)if(!o.has(t[l]))return t[l];return null},nD=({noCoverageAvailable:t,index:s,isActiveRow:n,onActivateRow:o,onResolved:a,resolutionTypes:l})=>{const c=X(),{id:u,shiftId:h,roleId:m,jobId:_,shiftLabel:f,open:g,resolutionType:b}=t,x=jp(),[E,S]=r.useState(!1),y=I(W=>ci(W,le.NO_COVERAGE_AVAILABLE)),C=!g,v=new Set(l),T=C&&b===fe.POST_AS_OPEN_SHIFT,D=C&&b===fe.FIND_REPLACEMENT,L=n&&y===vt.PROCESSING,A=(E||L)&&!C,P=E?p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.posting_open_shift"):p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.reassigning");r.useEffect(()=>{C&&(S(!1),a(s))},[C,s,a]);const M=r.useCallback(()=>{x(h,m,_)},[x,h,m,_]),R=r.useCallback(()=>{o(s),S(!0),c(Ot({action_item_ids:[u],resolution_type:fe.POST_AS_OPEN_SHIFT,resolution_payload:{}})).unwrap().catch(()=>S(!1))},[c,u,s,o]),$=r.useCallback(()=>{o(s),c(Vs({actionItem:le.NO_COVERAGE_AVAILABLE,status:""})),c(_r(le.NO_COVERAGE_AVAILABLE)),c(jn(vt.REPLACEMENT_FOUND)),c(yn([u])),c(Tt(!0))},[c,u,s,o]),B=()=>T?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.posted_confirmation")}):D?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.reassigned_confirmation")}):e.jsxs(i,{column:!0,gap:8,pt:16,children:[v.has(fe.POST_AS_OPEN_SHIFT)&&e.jsx(V,{fullWidth:!0,size:"small",onClick:R,children:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.post_as_open_shift")}),v.has(fe.FIND_REPLACEMENT)&&e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",onClick:$,children:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.reassign_shift")})]});return A?e.jsx(an,{processingText:P}):e.jsxs(i,{pv:16,btw:s===0?0:1,bcolor:"mono300",children:[e.jsx(Fp,{onClick:M,children:f}),e.jsx(i,{flex:!0,gap:8,children:e.jsx(j,{variant:"bodySmTight",color:"mono500",children:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.entity_sub")})}),B()]})},rD=2,oD=({actionItems:t,availableResolutionTypes:s})=>{const[n,o]=r.useState(null),a=r.useRef(new Set),l=jp(),c=r.useMemo(()=>t.map(f=>f.shiftId),[t]),u=r.useCallback(()=>Array.from(a.current).map(f=>t[f]?.shiftId),[t]),h=r.useCallback(f=>{o(f)},[]),m=r.useCallback(f=>{if(a.current.has(f))return;a.current.add(f);const g=sD(c,u(),t[f]?.shiftId);if(g){const b=c.indexOf(g);o(b);const x=t.find(E=>E.shiftId===g)?.roleId;l(g,x)}},[c,u,t,l]),_=t.map((f,g)=>e.jsx(nD,{index:g,noCoverageAvailable:f,isActiveRow:n===g,onActivateRow:h,onRes
1olved:m,resolutionTypes:s},g));return t.length<Rr?e.jsx(i,{children:_}):e.jsx(i,{pb:16,children:e.jsx(Ds,{items:_,initialCount:rD})})},aD=({item:t,index:s,isActiveRow:n,onActivateRow:o,onResolved:a,resolutionTypes:l})=>{const c=X(),[u,h]=r.useState(!1),[m,_]=r.useState(!t.open),[f,g]=r.useState(!1),[b,x]=r.useState(""),E=Os(),S=new Set(l),{jobId:y,id:C}=t,v=I(P=>ci(P,le.SHIFT_NEEDS_REVIEW));r.useEffect(()=>{n&&(v===vt.PROCESSING?(h(!0),x(p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.finding_replacement"))):v===vt.REPLACEMENT_FOUND&&(h(!1),g(!0)))},[v,n]),r.useEffect(()=>{(m||f)&&a(s)},[m,f,s,a]);const T=r.useCallback(()=>{E(y)},[E,y]),D=r.useCallback(()=>{h(!0),x(p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.updating_schedule")),c(Ot({action_item_ids:[C],resolution_type:fe.ACCEPT,resolution_payload:{}})).then(()=>{h(!1),_(!0)})},[c,C]),L=r.useCallback(()=>{o(s),c(Vs({actionItem:le.SHIFT_NEEDS_REVIEW,status:""})),c(_r(le.SHIFT_NEEDS_REVIEW)),c(jn(vt.REPLACEMENT_FOUND)),c(yn([C])),c(pr(y)),c(Tt(!0))},[c,s,o,C,y]),A=()=>m?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.shift_accepted")}):f?e.jsx(zt,{text:p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.shift_swapped",{props:{time:t.shiftLabel}})}):e.jsxs(i,{column:!0,gap:8,pt:16,children:[S.has(fe.ACCEPT)&&e.jsx(V,{fullWidth:!0,size:"small",onClick:D,children:p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.accept")}),S.has(fe.FIND_REPLACEMENT)&&e.jsx(V,{fullWidth:!0,variant:"secondary",size:"small",onClick:L,children:p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.swap")})]});return u?e.jsx(an,{processingText:b}):e.jsxs(i,{pv:16,btw:s===0?0:1,bcolor:"mono300",children:[e.jsx(i,{pointer:!0,onClick:T,children:e.jsx(j,{variant:"bodySmBoldTight",color:"primary500",children:t.userName})}),e.jsxs(i,{flex:!0,gap:8,pt:4,children:[e.jsx(j,{variant:"bodySmTight",color:"mono700",children:t.shiftLabel}),t.reason&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"bodySmTight",color:"mono700",children:p("schedule_builder.agent.canvas.separator")}),e.jsx(j,{variant:"bodySmTight",color:"mono700",children:t.reason})]})]}),e.jsx(i,{pt:8,children:A()})]})},lD=2,iD=({items:t,availableResolutionTypes:s,onAllResolved:n})=>{const[o,a]=r.useState(null),[l,c]=r.useState(()=>new Set),u=r.useRef(!1),h=r.useCallback(f=>{a(f)},[]),m=r.useCallback(f=>{c(g=>{if(g.has(f))return g;const b=new Set(g);return b.add(f),b})},[]);r.useEffect(()=>{t.length>0&&l.size===t.length&&!u.current&&(u.current=!0,n?.())},[l,t.length,n]);const _=t.map((f,g)=>e.jsx(aD,{index:g,item:f,isActiveRow:o===g,onActivateRow:h,onResolved:m,resolutionTypes:s},f.id));return t.length<Rr?e.jsx(i,{children:_}):e.jsx(i,{pb:16,children:e.jsx(Ds,{items:_,initialCount:lD})})},Wd=le.SHIFT_NEEDS_REVIEW,cD=new Set([le.NO_COVERAGE_AVAILABLE,le.INSUFFICIENT_REST,le.USER_OVER_HOURS,le.SHIFT_NEEDS_REVIEW]),dD=()=>{const t=I(yr),s=r.useMemo(()=>{const T=D=>D.group_type===le.NO_COVERAGE_AVAILABLE;return[...t.filter(T),...t.filter(D=>!T(D))]},[t]),{requests:n,availableResolutionTypes:o}=Yw(s),a=s.find(T=>T.group_type===le.NO_COVERAGE_AVAILABLE),l=n.filter(T=>T.open).length,{itemsByEmployee:c,availableResolutionTypes:u}=Vw(s),h=c.filter(T=>T.open).length,{itemsByEmployee:m,availableResolutionTypes:_}=Kw(s),f=m.filter(T=>T.open).length,{items:g,availableResolutionTypes:b}=zw(s),x=Os(),E=r.useMemo(()=>({[le.USER_OVER_HOURS]:c.find(T=>T.open)?.jobId,[le.INSUFFICIENT_REST]:m.find(T=>T.open)?.jobId}),[c,m]),S=r.useCallback(T=>{const D=E[T];D&&x(D)},[E,x]),y=r.useCallback(T=>cD.has(T.group_type),[]),{expandedCard:C,handleToggle:v}=Bp({actionItemGroups:s,isRenderable:y,onCardExpanded:S});return e.jsx(i,{flex:!0,column:!0,gap:12,children:e.jsx(i,{flex:!0,column:!0,gap:8,children:s.filter(y).map((T,D)=>e.jsxs(As,{delay:mh,children:[T.group_type===le.NO_COVERAGE_AVAILABLE&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.post_flight_checks.no_coverage_available_card.title"),iconName:"NoCoverageAvailable",count:l,resolved:!a?.open,previousResolution:a?Us(a):null,initiallyExpanded:C===le.NO_COVERAGE_AVAILABLE,onToggle:v(le.NO_COVERAGE_AVAILABLE),children:e.jsx(oD,{actionItems:n,availableResolutionTypes:o})}),T.group_type===le.INSUFFICIENT_REST&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.post_flight_checks.insufficient_rest_card.title"),iconName:"Moon",count:f,resolved:!T.open,previousResolution:Us(T),initiallyExpanded:C===le.INSUFFICIENT_REST,onToggle:v(le.INSUFFICIENT_REST),children:e.jsx(tD,{itemsByEmployee:m,availableResolutionTypes:_})}),T.group_type===le.USER_OVER_HOURS&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.post_flight_checks.hours_above_usual_card.title"),iconName:"HoursAboveUsual",count:h,resolved:!T.open,previousResolution:Us(T),initiallyExpanded:C===le.USER_OVER_HOURS,onToggle:v(le.USER_OVER_HOURS),children:e.jsx(Qw,{itemsByEmployee:c,availableResolutionTypes:u})}),T.group_type===le.SHIFT_NEEDS_REVIEW&&e.jsx(us,{title:p("schedule_builder.agent.sidebar.post_flight_checks.shift_needs_review_card.title"),iconName:"NeedsReview",count:T.subject_count,resolved:!T.open,previousResolution:Us(T),initiallyExpanded:C===Wd,onToggle:v(Wd),children:e.jsx(iD,{items:g,availableResolutionTypes:b})})]},`${T.group_type}-${D}`))})})},zr=[p("schedule_builder.agent.thinking.assignment.reviewing_hours_and_overtime"),p("schedule_builder.agent.thinking.assignment.checking_role_assignments"),p("schedule_builder.agent.thinking.assignment.reviewing_rest_periods"),p("schedule_builder.agent.thinking.assignment.checking_overall_coverage"),p("schedule_builder.agent.thinking.assignment.checking_unavailable_employees"),p("schedule_builder.agent.thinking.assignment.checking_role_swaps"),p("schedule_builder.agent.thinking.assignment.checking_hours_balance"),p("schedule_builder.agent.thinking.assignment.checking_low_confidence_matches"),p("schedule_builder.agent.thinking.assignment.checking_for_unqualified_roles"),p("schedule_builder.agent.thinking.assignment.checking_hours_limit_gaps"),p("schedule_builder.agent.thinking.assignment.reviewing_hours_over_usual")],uD=({loading:t})=>{const s=K(),n=r.useRef(null),[o,a]=r.useState(0);if(r.useEffect(()=>{s(w.PAGE_VIEWED,k.VIEW,{sba_phase:"post_assign",eventCategory:U.SCHEDULE_BUILDER_POST_ASSIGN})},[s]),r.useEffect(()=>{if(!t)return;const l=setTimeout(()=>{const c=n.current?.closest("[data-sidebar-scroll]");c&&c.scrollTo({top:c.scrollHeight,behavior:"smooth"})},1500);return()=>clearTimeout(l)},[t]),r.useEffect(()=>{if(t&&o<zr.length){const l=window.setTimeout(()=>{a(c=>c+1)},1e3);return()=>window.clearTimeout(l)}},[t,o]),r.useEffect(()=>{t||a(0)},[t]),t)return e.jsxs(i,{ref:n,minh:"100%",flex:!0,column:!0,gap:8,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(i,{w:16,h:16,flex:!0,alignItemsCenter:!0,justifyContentCenter:!0,style:{transform:"scale(0.75)",transformOrigin:"center"},children:e.jsx($n,{size:"small",variant:"dark"})}),e.jsx(j,{variant:"bodySmBold",color:"mono900",children:p("schedule_builder.agent.thinking.assignment.reviewing_schedule")})]}),e.jsx(i,{flex:!0,column:!0,gap:4,ml:33,children:o>0&&o<=zr.length&&e.jsx(As,{children:e.jsx(j,{isAIAnimating:!0,variant:"bodySm",color:"secondary",children:zr[o-1]})},zr[o-1])})]})},{cx:hD}=O("AssignmentThinkingBlock"),mD=()=>{const t=K(),s=I(di),[n,o]=r.useState(!1),a=r.useCallback(()=>{o(l=>
1!l),t(w.DOWN_CARET_CLICKED,k.CLICK,{element:"narration_group",caret_direction:n?"close":"open",narration_categories:s.map(l=>l.key),eventCategory:U.SCHEDULE_BUILDER_PUBLISH})},[t,n,s]);return e.jsx(As,{delay:0,children:e.jsxs(i,{className:hD(),flex:!0,column:!0,gap:8,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,pointer:!0,onClick:a,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Pr,{}),e.jsx(i,{flex:!0,column:!0,gap:2,children:e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.agent.assignment.changes_reviewed")})})]}),s.length>0&&e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:4,children:[e.jsxs(j,{variant:"bodySm",color:"secondary",children:[s.length," steps"]}),e.jsx(on,{expanded:n,label:"Expand",size:"xsmall"})]})]}),e.jsx(Gn,{isExpanded:n,children:e.jsx(i,{flex:!0,column:!0,gap:8,pl:28,children:s.map((l,c)=>e.jsxs(i,{flex:!0,column:!0,gap:2,children:[e.jsx(j,{variant:"bodySmBold",color:"secondary",children:l.title}),l.narrations.map((u,h)=>e.jsx(j,{variant:"bodySm",color:"secondary",children:u},h))]},c))})})]})},"assignment_thinking")},pD=({fillHeight:t=!1})=>{const s=K(),n=I(Ro),o=I(di),l=I(Bn)==="pending",c=r.useRef(null),u=r.useRef(!1),h=I(Rs);r.useEffect(()=>{n&&s(w.PAGE_VIEWED,k.VIEW,{panel_type:"SBA",thinking_phase:"post_assign",eventCategory:U.SCHEDULE_BUILDER_POST_ASSIGN})},[s,n]),r.useEffect(()=>{!n||!t||u.current||h||(u.current=!0,c.current?.scrollIntoView({block:"start",behavior:"smooth"}))},[n,t,h]);const[m,_]=r.useState(!1),f=r.useCallback(()=>{_(x=>!x)},[]),g=n?.metadata?.assignment_count??0,b=l&&!n&&o.length===0;return e.jsxs(i,{ref:c,flex:!0,column:!0,gap:12,minh:t?"100%":void 0,children:[n&&e.jsxs(Hp,{children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,pointer:!0,onClick:f,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(Pr,{}),e.jsx(i,{flex:!0,column:!0,gap:2,children:e.jsx(j,{variant:"bodySmBold",children:p("schedule_builder.agent.schedule_generated.title")})})]}),g>0&&e.jsx(on,{expanded:m,label:"Expand",size:"small"})]}),e.jsx(Gn,{isExpanded:m,children:g>0&&e.jsx(i,{flex:!0,column:!0,gap:4,pl:28,children:e.jsx(j,{variant:"bodySm",color:"secondary",children:p("schedule_builder.agent.schedule_generated.shifts_assigned",{props:{count:g}})})})})]}),o.length>0&&e.jsx(mD,{}),h&&e.jsx(Up,{}),e.jsx(dD,{}),b&&e.jsx(uD,{loading:l})]})},{cx:_D}=O("Sidebar"),fD=({sbaPhase:t,onClickSwitchBack:s,onClickGiveFeedback:n})=>{const o=K(),a=X(),l=I(Rs);r.useEffect(()=>{o(w.BUTTON_CLICKED,k.CLICK,{element:"sba_overflow_menu",button_text:p("schedule_builder.agent.opt_out.switch_back"),eventCategory:U.SCHEDULE_BUILDER,sba_phase:t})},[o,t]);const c=r.useCallback(({target:{checked:h}})=>{o(w.TOGGLE_CLICKED,k.CLICK,{element:"sba_auto_assign_shifts",eventCategory:U.SCHEDULE_BUILDER,sba_phase:t,enabled:h}),a(oi(h)),at(ai,h)},[a,t,o]),u=r.useCallback(()=>{o(w.LINK_CLICKED,k.CLICK,{element:"sba_give_feedback",linkText:p("schedule_builder.agent.give_feedback"),eventCategory:U.SCHEDULE_BUILDER,sba_phase:t}),n()},[n,t,o]);return e.jsxs(i,{absolute:!0,top:56,zIndex:1e4,bgcolor:"mono0",bradiusm:!0,right:4,left:4,className:_D("more-text"),children:[e.jsxs(i,{p:16,flex:!0,column:!0,gap:4,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,gap:16,children:[e.jsx(j,{variant:"bodyBold",children:p("schedule_builder.agent.auto_assign.title")}),e.jsx(ph,{name:"auto-assign-shifts",checked:l,onChange:c})]}),e.jsx(j,{variant:"bodySmTight",color:"secondary",children:p("schedule_builder.agent.auto_assign.description")})]}),e.jsxs(i,{p:16,btw:1,bcolor:"mono300",pointer:!0,flex:!0,alignItemsCenter:!0,gap:12,onClick:s,children:[e.jsx(ns,{iconName:"SwitchBack",size:"medium"}),e.jsx(j,{variant:"bodySmTight",children:p("schedule_builder.agent.opt_out.switch_back")})]}),e.jsxs(i,{p:16,pointer:!0,flex:!0,alignItemsCenter:!0,gap:12,onClick:u,children:[e.jsx(ns,{iconName:"GiveFeedback",size:"medium"}),e.jsx(j,{variant:"bodySmTight",children:p("schedule_builder.agent.give_feedback")})]})]})},bD=({canvasShiftsStatus:t,schedulesStatus:s,timelineStatus:n,bootstrapStatus:o,assigningShiftsStatus:a,previouslyBootstrapped:l,canvasIsPublished:c,canvasHasDraftShifts:u,canvasIsEmpty:h,buildInProgress:m,showPublishingState:_,prePublishReviewOpen:f,hasSchedulePublishedEvent:g,hasScheduleGeneratedEvent:b,hasScheduleBootstrappedEvent:x,hasAssignableShifts:E,fillShiftsCardDismissed:S,autoAssignEnabled:y,autoAssignedByBootstrap:C})=>{const v=t!=="idle"&&t!=="pending"&&o!=="pending",T=a==="pending",D=C&&o==="succeeded",L=f&&!g,A=c&&!g&&t==="succeeded",P=s==="succeeded"&&(!l||n==="succeeded"),M=g||A,R=v&&!m&&!T&&!M&&!u&&(h||!b),$=!S&&n==="succeeded"&&!R&&!L&&!M&&!_&&!T&&!D&&!b;return{canvasIsReady:v,isAssigning:T,showPrePublishReview:L,publishedWithoutSbaEvent:A,publishedSummaryResolved:P,
1showPublishedState:M,showZeroState:R,showFillShiftsCard:$&&!y,shouldAutoAssignShifts:$&&y&&E,autoAssignmentCompleted:D,fillGeneratedHeight:!L&&!_&&!g,sbaPhase:M||_?"pre_publish":b||T||D?"post_assign":x?"structure":"pre_assign"}},{cxEl:Vd}=O("Sidebar"),er=320,gD=({onAssignShifts:t})=>{const s=K(),n=X(),o=I(bx),[a,l]=r.useState(!o),[c,u]=r.useState(o),h=r.useRef(o),m=r.useRef(null),_=I(Ju),f=I(Fl),g=I(ti),b=I(gx),x=I(xx),E=I(Cx),S=I(Pn),y=I(Ex),C=I(_t),[v,T]=r.useState(!1),D=r.useCallback(()=>T(!0),[]);r.useEffect(()=>{!y||!C||(n(_h(!1)),T(!0),n(Ao({startDate:C})))},[n,y,C]),r.useEffect(()=>{(g==="idle"||x)&&T(!1)},[g,x]);const L=I(Bn),A=I(qo),P=I(Ro),[M,R]=r.useState(!1),$=r.useRef(null),B=r.useRef(null),W=r.useRef(null),N=I(Lo),H=I(Wl),q=I(ko),G=$i(q),re=I(Xu),ue=I(di),je=I(Sx),ce=I(Rs),oe=I(jx),te=I(dh).length>0,{isAssigning:Z,showPrePublishReview:ee,publishedWithoutSbaEvent:he,publishedSummaryResolved:Ye,showPublishedState:De,showZeroState:Pe,showFillShiftsCard:ke,shouldAutoAssignShifts:me,autoAssignmentCompleted:Fe,fillGeneratedHeight:We,sbaPhase:Xe}=r.useMemo(()=>bD({canvasShiftsStatus:g,schedulesStatus:b,timelineStatus:A,bootstrapStatus:f,assigningShiftsStatus:L,previouslyBootstrapped:_,canvasIsPublished:S,canvasHasDraftShifts:x,canvasIsEmpty:E,buildInProgress:v,showPublishingState:G,prePublishReviewOpen:re,hasSchedulePublishedEvent:!!H,hasScheduleGeneratedEvent:!!P,hasScheduleBootstrappedEvent:!!N,hasAssignableShifts:te,fillShiftsCardDismissed:je,autoAssignEnabled:ce,autoAssignedByBootstrap:oe}),[g,b,A,f,L,_,S,x,E,v,G,re,H,P,N,te,je,ce,oe]),se=!_&&!N&&f==="pending",[Ne,ye]=r.useState(!1),Ve=r.useRef(null);r.useEffect(()=>{if(se){Ve.current===null&&(Ve.current=Date.now()),ye(!0);return}if(Ve.current===null){ye(!1);return}const qe=Ow-(Date.now()-Ve.current);if(qe<=0){Ve.current=null,ye(!1);return}const ft=window.setTimeout(()=>{Ve.current=null,ye(!1)},qe);return()=>window.clearTimeout(ft)},[se]),r.useEffect(()=>{n(yx(Ne))},[n,Ne]),r.useEffect(()=>{!G||!m.current||m.current.scrollTo({top:m.current.scrollHeight,behavior:"smooth"})},[G]),r.useEffect(()=>{!Z||!m.current||m.current.scrollTo({top:m.current.scrollHeight,behavior:"smooth"})},[Z]);const $e=r.useCallback(()=>{n(ml("pending")),t?.()},[n,t]),Ee=r.useCallback(()=>{s(w.BUTTON_CLICKED,k.CLICK,{element:"assign_shifts",button_text:"Assign shifts",eventCategory:U.SCHEDULE_BUILDER_STRUCTURE}),$e()},[$e,s]),Re=r.useRef();r.useEffect(()=>{!me||Ne||Re.current!==C&&(Re.current=C,$e())},[me,Ne,C,$e]);const Me=r.useCallback(()=>{n(Zu())},[n]),we=r.useCallback(()=>{R(qe=>!qe)},[]),Ke=r.useCallback(()=>{R(!1)},[]);Rv([$,B,W],()=>{M&&Ke()});const Qe=r.useCallback(()=>{R(!0)},[]),Ze=r.useCallback(()=>{Ke(),n(Ys(!0))},[n,Ke]),[et,tt]=r.useState(!1),st=r.useCallback(()=>{Ke(),tt(!0)},[Ke]),nt=r.useCallback(()=>{tt(!1)},[]),Be=rp(),ve=r.useCallback(()=>{s(w.BUTTON_CLICKED,k.CLICK,{element:"close_sba",button_text:"Done & Exit",eventCategory:U.SCHEDULE_BUILDER_PUBLISH}),Ke(),Be()},[Ke,Be,s]);r.useEffect(()=>{h.current=o},[o]);const xt=vx(M,{from:{opacity:0}
1,enter:{opacity:1},leave:{opacity:0},config:{duration:250}}),[{width:ne,x:_e},xe]=Do(()=>({width:o?0:er,x:o?er:0,config:{tension:250,friction:30}}));if(r.useEffect(()=>{if(!o){l(!0),u(!1),xe.start({width:er,x:0});return}xe.start({width:0,x:er,onRest:()=>{h.current&&u(!0)}})},[o,xe]),!a)return null;const Ce=[{key:"review_panel_error",when:A==="failed",render:()=>e.jsx(hw,{})},{key:"building_draft",when:Ne,render:()=>e.jsx(Nw,{})},{key:"draft_ready",when:!!N&&!ce,render:()=>e.jsx($w,{})},{key:"preassignment_checks",when:!he&&!ce,render:()=>e.jsx(Up,{})},{key:"schedule_generated",when:Z||!!P||ue.length>0||Fe,render:()=>e.jsx(pD,{fillHeight:We})},{key:"pre_publish_review",when:ee,render:()=>e.jsx(Ww,{})},{key:"publishing",when:G,render:()=>e.jsx(HI,{})},{key:"schedule_published",when:De&&!G,render:()=>e.jsx(Uw,{loading:!Ye})}],ht=Ne?Ce.filter(qe=>qe.key==="building_draft"):Ce.filter(qe=>qe.when),St=()=>Ne||Pe||A!=="succeeded"&&!he?null:ee?e.jsx(fw,{}):De&&!G&&!ee?e.jsx(_w,{onClick:ve}):P||Fe?G?null:e.jsx(bw,{}):L==="pending"||G?null:e.jsx(mw,{handleAssignShifts:Ee,showFillChoice:ke});return e.jsxs(bn.div,{"aria-hidden":o||void 0,"data-testid":"sba-sidebar",style:{height:"100%",width:ne,overflow:"hidden",flexShrink:0,visibility:c?"hidden":"visible"},children:[e.jsx(bn.div,{style:{height:"100%",transform:_e.to(qe=>`translateX(${qe}px)`)},children:e.jsxs(i,{h:"100%",w:er,zIndex:1,bgcolor:"mono0",blw:1,bcolor:"mono100",flex:!0,column:!0,children:[e.jsxs(i,{minh:57,bbw:1,flex:!0,alignItemsCenter:!0,ph:8,justifyContentSpaceBetween:!0,bcolor:"mono100",children:[e.jsx(i,{p:8,flex:!0,alignItemsCenter:!0,gap:8,children:e.jsx(j,{noWrap:!0,variant:"heading4",children:p("schedule_builder.agent.sidebar.title")})}),e.jsxs(i,{row:!0,children:[e.jsx(i,{ref:$,className:Vd("more-btn"),p:8,bradiusfull:!0,pointer:!0,onClick:we,children:e.jsx(ns,{iconName:"More",size:"large"})}),e.jsx(i,{className:Vd("collapse-btn"),p:8,bradiusfull:!0,onClick:Me,pointer:!0,children:e.jsx(ns,{iconName:"Collapse",size:"large"})})]})]}),xt((qe,ft)=>ft&&e.jsx(bn.div,{ref:B,style:qe,children:e.jsx(fD,{sbaPhase:Xe,onClickSwitchBack:Ze,onClickGiveFeedback:st})})),e.jsx(i,{overflowX:"hidden",flex:!0,column:!0,id:"sidebar-content",grow:1,children:e.jsx(i,{ref:m,"data-sidebar-scroll":!0,p:16,gap:12,flex:!0,column:!0,grow:1,h:"100%",overflowX:"hidden",overflowY:"auto",children:Pe&&!Ne?e.jsx(xw,{onClick:D,onOpenSettings:Qe,settingsLinkRef:W}):ht.map(qe=>e.jsx(r.Fragment,{children:qe.render()},qe.key))})}),St()]})}),et&&e.jsx(Wi,{isOpen:!0,onClose:nt})]})},xD=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(gD),{cx:CD,cxEl:Gr}=O("CanvasList"),ED=6,SD=30,jD={duration:220,easing:"cubic-bezier(0.18, 0.67, 0.6, 1.22)",sideEffects:Bx({styles:{active:{opacity:"0.4"}}})},yD=()=>{const t=X();ps(w.PAGE_VIEWED,k.VIEW,{sba_phase:"pre_assign"});const{rangeStart:s,viewType:n}=ze(),o=Qo(),a=I(sh);r.useEffect(()=>{a===null&&n&&t(hl(n))},[]);const l=a??n,c=I(Ix),u=r.useRef(c);r.useEffect(()=>{const z=u.current;return t(Ac(!0)),()=>{t(Ac(z))}},[t]);const h=I(rs);r.useEffect(()=>{h!=null&&Pb("en",{week:{dow:h}})},[h]);const m=r.useMemo(()=>h==null?s:lt(s).startOf("week").format("YYYY-MM-DD"),[s,h]);r.useEffect(()=>{if(m!==s){const z=window.location.pathname.split("/"),rt=z.indexOf(s);rt>=0&&(z[rt]=m,o.replace(z.join("/")))}},[m,s,o]);const[_,f]=r.useState(!0),g=r.useCallback(z=>{f(z)},[]),[b,x]=r.useState(!1),E=r.useCallback(()=>{x(!0)},[]),S=r.useCallback(()=>{x(!1)},[]),{anchorEl:y,selectedDayIndex:C,selectedShiftId:v,selectedRoleId:T,selectedJobId:D,selectedRowType:L,isOpen:A,createRefHandler:P,createClickHandler:M,closePopper:R}=Np(),$=I(Gu),B=I(Ho),W=I(Tx),N=lt(m).add(6,"days").format("YYYY-MM-DD"),H=r.useMemo(()=>({startDate:m,endDate:N}),[m,N]),q=I(z=>uh(z,H)),G=I(To),re=I(wx),ue=I(Pn),je=I(Dx),ce=I(kx),oe=I(Ru),ge=I(yr),{itemsByEmployee:te}=ap(ge),Z=te.filter(z=>z.openRequestIds.length>0),ee=Z.flatMap(z=>z.openRequestIds),he=Z.map(z=>z.userName),Ye=I(th),De=r.useMemo(()=>p("schedule_builder.agent.sidebar.dialog.title"),[]),Pe=I(ni),ke=I(Rx),me=I(Lx),Fe=I(ri),We=I(Fl),Xe=Fe||We==="pending"||!Pe&&ke!=="succeeded"&&me!=="succeeded",se=me==="pending",{activeDragData:Ne}=zT(),ye=LT(m,Px),[Ve,$e]=r.useState(0),Ee=r.useRef(ye),Re=r.useRef(!0);r.useEffect(()=>{t(Ax(m)),t(Ox())},[t,m]),r.useEffect(()=>{if(m===ye){if(Ee.current!==ye){Ee.current=ye;return}if(Re.current){Re.current=!1;return}$e(z=>z+1)}},[m,ye]);const Me=r.useRef(me);Me.current=me;const we=r.useRef(ke);we.current=ke;const Ke=I(Nx),Qe=r.useRef(Ke);Qe.current=Ke,lT(()=>{const z=[t(Po({startDate:ye})),t(zl()),t(xr({startDate:ye})),t(Oo({startDate:ye,type:"all"})),t(lh({startDate:ye})),t(Nu(ye)),t(Lu({startDate:ye}))];
1return Me.current!=="succeeded"&&z.push(t(Kl({date:ye}))),we.current!=="succeeded"&&z.push(t(Vl())),Qe.current!=="succeeded"&&z.push(t(Au())),z},[t,ye,Ve]),AT();const Ze=co,tt=I(Bn)==="pending",st=I(Rs),nt=st&&(tt||We==="pending"||Fe),Be=r.useMemo(()=>nt?[Pt]:[],[nt]),{rows:ve,departingKeys:xt,arrivingKeys:ne,toggleGroup:_e,expandGroup:xe,setGroupExpanded:Ce}=TT({showSkeletons:Xe,employeesLoading:se,showEvents:_,shifts:q,roles:B,departments:W,employees:G,initialExpandedGroups:{[xn]:!0,[Pt]:!0},forcedCollapsedGroups:Be,viewBy:Ye,viewType:l,canvasIsPublished:ue});r.useEffect(()=>{nt&&(Ce(Pt,!1),Ce(xn,!1))},[nt,Ce]);const ht=xt.size>0,St=r.useRef(null),qe=r.useRef(ve);r.useEffect(()=>{qe.current=ve},[ve]);const ft=fh({count:ve.length,getScrollElement:()=>St.current,getItemKey:z=>mn(ve[z]),estimateSize:z=>$x(ve[z]),overscan:ht?SD:ED}),va=r.useMemo(()=>{const z=Ne?.shiftId;return z?ve.findIndex(rt=>(rt.kind==="employee-row"||rt.kind==="open-shifts-row")&&rt.shifts.some(Wt=>Wt.id===z)):-1},[Ne?.shiftId,ve]),{handleAssignShifts:wb,cancel:hc}=RT({rowsRef:qe,parentRef:St,virtualizer:ft,roles:B,departments:W,viewType:l,expandGroup:xe});NT({rowsRef:qe,parentRef:St,virtualizer:ft,roles:B,departments:W,viewType:l,expandGroup:xe}),KT({rowsRef:qe,parentRef:St,virtualizer:ft,roles:B,departments:W,viewType:l,expandGroup:xe}),HT({rowsRef:qe,parentRef:St,virtualizer:ft,hasPublishedSchedule:ue,initialLoadComplete:Pe,showSkeletons:Xe,startDate:m}),r.useEffect(()=>{const z=St.current;if(!z||!y)return;const rt=()=>{const Wt=z.getBoundingClientRect(),fs=y.getBoundingClientRect();(fs.bottom<=Wt.top||fs.top>=Wt.bottom||!document.body.contains(y))&&R()};return z.addEventListener("scroll",rt,{passive:!0}),()=>z.removeEventListener("scroll",rt)},[y,R]),r.useEffect(()=>{hc()},[hc]);const Db=r.useMemo(()=>{const z=new Map;let rt=0;for(const Wt of ve)if(Wt.kind==="open-shifts-row"){z.set(Wt.roleId,rt);const fs=6*Ki+Ip;rt+=fs}return z},[ve]),kb=z=>{switch(z.kind){case"event-row":return e.jsx(Ad,{events:$,startDate:m},"event-row");case"row-group-header":return e.jsx($p,{label:z.label,bottomBorder:z.bottomBorder,forceBottomBorder:z.forceBottomBorder,groupKey:z.groupKey,expanded:z.expanded,openShiftCount:z.openShiftCount,totalOpenShiftHours:z.totalOpenShiftHours,onToggle:_e,onDragExpand:xe},z.groupKey);case"department-group-header":return e.jsx(JT,{label:z.label,groupKey:z.groupKey,expanded:z.expanded,totalOpenShiftHours:z.totalOpenShiftHours,onToggle:_e,onDragExpand:xe},z.groupKey);case"role-group-header":return e.jsx(Pp,{label:z.label,badgeColor:z.badgeColor,groupKey:z.groupKey,expanded:z.expanded,totalOpenShiftHours:z.totalOpenShiftHours,onToggle:_e,onDragExpand:xe},z.groupKey);case"open-shifts-row":return e.jsx(gT,{shifts:z.shifts,startDate:m,isAssigning:tt,animationOffset:Db.get(z.roleId)??0,createRefHandler:P,createClickHandler:M,roleId:z.roleId},`open-shifts-row:${z.roleId??"no-role"}`);case"employee-row":return e.jsx(ow,{employee:z.employee,shifts:z.shifts,startDate:m,createRefHandler:P,createClickHandler:M,roleId:z.roleId},`employee-row:${z.roleId??"no-role"}:${z.employee.job_id}`);case"team-members-skeleton-row":return e.jsx(Vr,{showLeftSkeleton:!0},`team-members-skeleton-row:${z.roleId}`);case"wage-totals-spacer":return e.jsx(i,{w:"100%",minh:28,maxh:48},"wage-totals-spacer")}},Ia=ft.getVirtualItems(),mc=va>=0&&!Ia.some(z=>z.index===va)?ft.measurementsCache[va]:void 0,Rb=mc?[...Ia,mc]:Ia;return e.jsx(wn,{classNames:{root:Gr("page"),childrenWrapper:Gr("page-content")},title:p("nav_links.schedule.top_level"),fullWidthOpts:{hideHeader:!0},children:e.jsx(wn.FullWidth,{classNames:{root:Gr("full-width"),childrenWrapper:Gr("full-width-content")},toolbar:e.jsx(Q0,{showEvents:_,onShowEventsChange:g,onAddEvent:E}),children:e.jsxs(i,{bgcolor:"mono0",w:"100%",h:"100%",flex:!0,column:!0,overflow:"hidden",minh:0,className:CD(),id:"canvas-assistant",children:[e.jsxs(i,{flex:!0,row:!0,justifyContentSpaceBetween:!0,grow:1,minh:0,children:[e.jsxs(i,{flex:!0,column:!0,w:"100%",children:[e.jsx(WI,{}),e.jsx(M0,{readOnly:ue,children:e.jsxs(i,{flex:!0,column:!0,grow:1,minh:0,children:[e.jsxs(i,{relative:!0,flex:!0,column:!0,grow:1,minh:0,children:[e.jsx(GI,{}),e.jsx(aT,{}),e.jsxs(i,{relative:!0,flex:!0,column:!0,grow:1,minh:0,children:[e.jsx(i,{ref:St,id:"scrollable-inner-canvas",overflowY:"auto",grow:1,minh:0,children:Xe?e.jsxs(e.Fragment,{children:[_&&e.jsx(Ka,{label:"Events",bottomBorder:!0,groupKey:xn,expanded:!st,onToggle:_e,children:!st&&e.jsx(Ad,{showSkeletons:!0,events:$,startDate:m})}),e.jsx(Ka,{label:"Open Shifts",bottomBorder:!1,groupKey:Pt,expanded:!st,onToggle:_e,children:!st&&Ze.map(z=>{const rt=zs(z.id);return e.jsxs(Nd,{label:z.name,badgeColor:z.color||z.new_color||void 0,groupKey:rt,expanded:!0,onToggle:_e,children:[e.jsx(Vr,{}),e.jsx(Vr,{})]},z.id)})}),e.jsx(Ka,{label:"Team Members",groupKey:ss,expanded:!0,onToggle:_e,children:Ze.map(z=>{const rt=Ts(z.id);return e.jsx(Nd,{label:z.name,badgeColor:z.color,groupKey:rt,expanded:!0,onToggle:_e,children:Array.from({length:1},(Wt,fs)=>e.jsx(i,{children:e.jsx(Vr,{showLeftSkeleton:!0})},fs))},z.id)})})]}):e.jsxs(e.Fragment,{children:[e.jsx(i,{w:"100%",relative:!0,style:{height:ft.getTotalSize()},children:Rb.map(z=>{const rt=ve[z.index],Wt=mn(rt),fs=xt.has(Wt),pc=ne.has(Wt);return e.jsx(i,{"data-index":z.index,ref:ft.measureElement,absolute:!0,style:{to
1p:0,left:0,width:"100%",transform:`translateY(${z.start}px)`},children:e.jsx(s0,{isCollapsing:fs,isExpanding:pc,children:kb(rt)})},z.key)})}),e.jsx(L0,{isOpen:A,anchorEl:y,selectedDayIndex:C,startDate:m,rowType:L,roleId:T,jobId:D,shiftId:v,onClose:R})]})}),e.jsx(ZI,{locked:ue})]})]}),e.jsx(N0,{startDate:m})]})})]}),e.jsx(xD,{onAssignShifts:wb})]}),e.jsx(kI,{open:re&&ce===It.MISSING}),e.jsx(NI,{open:re&&ce===It.STALE,openIds:ee,userNames:he}),e.jsx(LI,{open:re&&ce===It.NEW_TEAM_MEMBER}),e.jsx(B0,{open:b,selectedDayIndex:0,startDate:m,selectedEvent:null,onClose:S}),e.jsx($I,{open:re&&Mx.includes(oe),title:De}),e.jsx(OI,{}),e.jsx(bh,{dropAnimation:jD,children:Ne&&e.jsx(XI,{dragData:Ne})}),je&&e.jsx(o0,{})]})})})},vD=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(yD),ID=({children:t})=>{const{rangeType:s}=ze(),n=I(_=>gh(_,"productgrowth_imagetoschedule_web")),o=I(xh),{rosterStatus:a,scheduleStatus:l}=I(vo)||{},c=I(He),u=s===J.week;return c&&u&&o&&(n===Pm.DIALOG&&a===En&&l===En||a===En&&l===bv)?e.jsx(e.Fragment,{children:t}):null},Wp=({children:t})=>{const{rangeType:s}=ze(),n=I(Ux),o=I(He),a=I(hs),l=r.useMemo(()=>Bm(a),[a]),c=s===J.week;return n&&o&&!l&&c?e.jsx(e.Fragment,{children:t}):null},TD=({onClose:t})=>{const s=X(),n=K();en()({eventCategory:U.CHANGE_BASE_WEEK,productArea:ae.SCHEDULE_BUILDER});const a=I(it),l=I(Ch)||a?.start,c=I(Eh)||a?.end,[u,h]=r.useState(""),m=r.useMemo(()=>Oe(l,"month_day_short"),[l]),_=r.useMemo(()=>pn(a?.start,Ym*Gm),[a]),f=r.useMemo(()=>pn(a?.start,1),[a]),g=r.useMemo(()=>Oe(c,"month_day_short"),[c]),b=r.useMemo(()=>Oe(c,"year"),[c]),x=I(rs),E=a?.start,[S,y]=r.useState(E),C=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{productArea:ae.SCHEDULE_BUILDER,buttonText:p("schedule_builder.previous_weeks_on_jumpstart_drawer.predictive_scheduling.title"),element:"generate_schedule",buttonAction:"generate_predictive_schedule",buttonLocation:"jumpstart_drawer"}),s(jo({startDate:S})),t()},[n,s,t,S]),v=r.useCallback(()=>{t()},[t]);return e.jsx(Mt,{disableBackdropClick:!0,open:!0,onClose:v,children:()=>e.jsxs(i,{w:611,h:330,flex:!0,column:!0,children:[e.jsx(i,{gap:32,mt:32,children:e.jsxs(i,{column:!0,gap:24,children:[e.jsx(j,{variant:"heading2",color:"mono900",children:p("schedule_builder.predictive_scheduling.change_base_week.title")}),e.jsx(j,{variant:"body",color:"mono900",children:p("schedule_builder.predictive_scheduling.change_base_week.description",{props:{baseWeek:`${m} - ${g}, ${b}`}})})]})}),e.jsxs(i,{flex:!0,column:!0,mt:32,children:[e.jsx(i,{flex:!0,alignItemsCenter:!0,row:!0,children:e.jsxs(i,{gap:8,flex:!0,column:!0,children:[e.jsx(j,{variant:"bodySmBold",color:"mono700",children:p("schedule_builder.predictive_scheduling.change_base_week.base_week_label")}),e.jsx(i,{row:!0,grow:!0,children:e.jsx(zm,{setDate:h,setCustomDate:y,drawerDate:S||u,startOfWeekDay:x,displayOptions:!1,displayArrows:!0,padding:!1,blockDatesBefore:_,blockDatesAfter:f,displayedMonths:1,defaultStartDate:void 0,defaultEndDate:f})})]})}),e.jsx(i,{mt:24,flex:!0,justifyContentEnd:!0,children:e.jsx(V,{dataTestId:"change-base-week-button",disabled:E===S,onClick:C,children:p("schedule_builder.predictive_scheduling.change_base_week.change_base_week_cta")})})]})]})})},wD=({message:t})=>{const[s,n]=r.useState(!0),o=r.useCallback(()=>{n(!s)},[s]),a=t.subMessages??[];return e.jsx(i,{component:"li",children:e.jsx(i,{alignItemsStart:!0,children:e.jsxs(i,{column:!0,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:3,children:[a.length>0&&e.jsx(i,{flex:!0,children:e.jsx(be,{onClick:o,icon:s?"CaretDown":"CaretRight",size:"small",label:s?p("schedule_builder.actions.hide_details"):p("schedule_builder.actions.show_details")})}),e.jsx(j,{variant:"body",color:"mono900",children:t.message})]}),e.jsx(i,{flex:!0,column:!0,gap:5,ml:33,children:s&&a.map(l=>e.jsx(i,{flex:!0,gap:5,row:!0,children:e.jsxs(j,{variant:"bodySm",color:"mono700",children:["⢠",l]})},l))})]})})})},DD=1500,kD=()=>{const[t,s]=r.useState(!1),[n,o]=r.useState(!0),[a,l]=r.useState(!0),c=I(it),u=X(),h=I(Ch)||c?.start,m=I(Eh)||c?.end,_=r.useMemo(()=>Oe(h,"month_day_short"),[h]),f=r.useMemo(()=>Oe(m,"month_day_short"),[m]),g=r.useMemo(()=>Oe(m,"year"),[m]),b=I(Hx)||[];en()({eventCategory:U.PREDICTIVE_SCHEDULING_SUCCESS,elementType:"narrative",eventAction:w.ELEMENT_SHOWN,productArea:ae.SCHEDULE_BUILDER}),ps(w.ELEMENT_SHOWN,k.VIEW,{bullets:b.length});const E=r.useCallback(()=>{Rt({eventCategory:U.PREDICTIVE_SCHEDULING_SUCCESS,eventAction:w.BUTTON_CLICKED,productArea:ae.SCHEDULE_BUILDER,properties:{elementType:"narrative",elementName:"change_base_week",buttonText:p("schedule_builder.predictive_scheduling.feedback_dialog.change_base_week_cta")}}),s(!0)},[]),S=r.useCallback(()=>{s(!1),Rt({eventCategory:U.PREDICTIVE_SCHEDULING_SUCCESS,eventAction:w.DISM
1ISS_CLICKED,productArea:ae.SCHEDULE_BUILDER})},[]),y=r.useCallback(()=>{u(Fx()),Rt({eventCategory:U.PREDICTIVE_SCHEDULING,eventAction:w.DISMISS_CLICKED,productArea:ae.SCHEDULE_BUILDER,properties:{elementName:"predictive_schedule_success"}})},[u]),C=r.useMemo(()=>!b.length||b.length===1&&b[0]?.subMessages?.length===0,[b]);r.useEffect(()=>{const T=setTimeout(()=>l(!1),DD);return()=>clearTimeout(T)},[]);const v=r.useCallback(()=>{o(!n),Rt({eventAction:n?w.UP_CARET_CLICKED:w.DOWN_CARET_CLICKED,actionType:k.CLICK,eventCategory:U.PREDICTIVE_SCHEDULING_SUCCESS,productArea:ae.SCHEDULE_BUILDER,properties:{buttonText:n?"Minimize":"Maximize"}})},[n,o]);return e.jsxs(e.Fragment,{children:[t&&e.jsx(TD,{onClose:S}),e.jsx(_a,{open:!0,hideCloseIcon:!0,noPadding:!0,isAI:!0,isAIAnimating:a,children:e.jsxs(i,{w:628,p:16,column:!0,gap:20,children:[e.jsxs(i,{alignItemsCenter:!0,flex:1,justifyContentSpaceBetween:!0,children:[e.jsxs(i,{alignItemsCenter:!0,gap:8,flex:!0,children:[e.jsx(Q,{color:"primary500",iconName:"Sparkle",size:"large"}),e.jsx(j,{variant:"heading4",children:p("schedule_builder.predictive_scheduling.feedback_dialog.title",{props:{baseWeek:`${_} - ${f}, ${g}`}})})]}),e.jsxs(i,{flex:!0,gap:3,children:[e.jsx(V,{onClick:E,variant:"secondary",size:"small",children:p("schedule_builder.predictive_scheduling.feedback_dialog.change_base_week_cta")}),e.jsx(be,{onClick:v,icon:n?"ChevronDown":"ChevronUp",size:"small",dataTestId:"toggle-messages-button",label:n?p("schedule_builder.actions.minimize_feedback"):p("schedule_builder.actions.maximize_feedback")}),e.jsx(be,{onClick:y,icon:"Close",size:"small",dataTestId:"close-button",label:p("schedule_builder.actions.close")})]})]}),n&&e.jsx(i,{ml:-10,children:e.jsx(i,{maxh:167,ml:C?7:0,gap:8,overflowY:"scroll",column:!0,component:"ul",p:5,children:b.map((T,D)=>e.jsx(wD,{message:T},D))})})]})})]})},RD=t=>new Promise((s,n)=>setTimeout(()=>n(new Error("Polling timed out")),t)),LD=Nr(`${Wx}/predictSchedule`,async(t,{dispatch:s,getState:n})=>{s(Ra({status:!0}));const{target_start_date:o,target_end_date:a,baseline_start_date:l,baseline_end_date:c}=t,u=n();s(Oc({count:0})),s(_l({date:void 0})),s(fl({date:void 0})),s(Vx(l)),s(Kx(c));try{const m=(await Eo(qx(),{start_date:o,end_date:a,baseline_start_date:l}))?.data?.id;if(m)try{const _=Date.now(),f=await Promise.race([zx(m),RD(Gx)]),b=Date.now()-_;let x=[];const E=f?.baseline_start_date,S=f?.predicted_shifts_count;try{x=JSON.parse(f?.narrative_messages||"").map(y=>({message:y.message,subMessages:y.sub_messages}))}catch(y){eo("Failed to parse narrative messages",y),x=[]}if(b<Nc&&await new Promise(y=>setTimeout(y,Nc-b)),!S||S==="0")s(un(!0));else return Yx(u,{rangeStart:o,rangeEnd:a}),s(Oc({count:S})),x.length>0?(s(Jx({messages:x})),E&&(s(fl({date:E})),s(_l({date:kt(E,Xx)}))),s(Qx())):s(oo({message:p("schedule_builder.predictive_scheduling.generation_modal.success_notification",{props:{count:S}}),type:"success",isAI:!0})),"success"}catch(_){return eo(_),_?.message==="Polling timed out"?s(un(!0)):s(un(!0)),"fail"}finally{s(Ra({status:!1})),s(ui({startDate:o,endDate:a,force:!0}))}}catch(h){s(un(!0)),eo(h),s(Ra({status:!1}))}}),Kd=1500,AD=()=>{const[t,s]=r.useState(cI),n=K(),o=X(),a=I(it),l=I(Zx),[c,u]=r.useState(!1);ps(w.ELEMENT_SHOWN,k.VIEW,{elementType:"modal",elementName:"generating_schedule",elementLocation:"schedule_builder"});const h=async()=>{for(let f=0;f<t.length;f++)s(g=>g.map((b,x)=>x===f?{...b,loading:!0}:b)),await new Promise(g=>setTimeout(g,Kd)),s(g=>g.map((b,x)=>x===f?{...b,loading:!1,success:!0}:b));await new Promise(f=>setTimeout(f,Kd)),u(!0)};r.useEffect(()=>{h(),o(Ml())},[o]),r.useEffect(()=>{c&&o(Mc())},[o,c]);const m=r.useCallback(async()=>{n(w.BUTTON_CLICKED,k.CLICK,{});const f=l;o(fl(a.start)),o(_l(a.end)),(await o(LD({target_start_date:a.start,target_end_date:a.end,baseline_start_date:f})))?.payload==="success"?n(w.ELEMENT_SHOWN,k.VIEW,{elementType:"success_message",elementName:"predictive_schedule_success",elementLocation:"schedule_builder",outcome:"success"}):n(w.ERROR_MESSAGE_SHOWN,k.VIEW,{elementType:"failure_message",elementName:"predictive_schedule_failure",elementLocation:"schedule_builder",outcome:"failure"})},[n,a,o,l]);r.useEffect(()=>{m()},[m]);const _=r.useCallback(()=>{o(Mc())},[]);return e.jsx(Mt,{disableBackdropClick:!0,open:!0,hideCloseIcon:!0,onClose:_,children:()=>e.jsxs(i,{p:12,w:420,children:[e.jsx(j,{variant:"heading2",color:"mono900",children:p("schedule_builder.predictive_scheduling.generation_modal.title_full")}),e.jsx(i,{ml:3,children:e.jsx(j,{variant:"body",color:"mono900",children:p("schedule_builder.predictive_scheduling.generation_modal.hang_on")})}),e.jsx(i,{mt:24,children:e.jsx(Ol,{variant:"checklist",data:t})})]})})},OD=Ge({productArea:ae.SCHEDULE_BUILDER,eventCategory:U.PREDICTIVE_SCHEDULING})(AD),ND=5e3,MD=()=>{const t=X(),s=r.useCallback(()=>{t(jo({})),t(un(!1))},[t]);return r.useEffect(()=>{setTimeout(()=>{t(un(!1))},ND)},[t]),e.jsx(Sh,{open:!0,autoHide:!0,hideCloseIcon:!0,variant:"error",onClose:s,action:e.jsx(V,{onClick:s,variant:"secondary",size:"small",children:p("schedule_builder.predictive_scheduling.generation_modal.refresh")}),children:p("schedule_builder.predictive_scheduling.generation_modal.refresh_error")})},PD=({startDate:t,endDate:s,color:n,type:o,isScheduleUsersOnly:a,departmentId:l})=>{const c="/schedule_builder/schedule/download",u={start_date:t,end_date:s,color:n,type:o,filter:a?"scheduled":"all",department_id:l};return`${c}?${Rl.stringify(u,Object.keys(u).sort())}`},Vp=({title:t,description:s,color:n,type:o,startDate:a,endDate:l,onClick:c,isScheduleUsersOnly:u,departmentId:h})=>{const m=K({color:n,is_by_department:!!h}),_=r.useMemo(()=>PD({startDate:a,endDate:l,color:n,type:o,isScheduleUsersOnly:u,departmentId:h}),[a,l,n,o,u,h]),f=r.useCallback(()=>{m(w.PRINT_OPTION_CLICKED,k.CLICK),c()},[c,m]);return e.jsx("a",{href:_,onClick:f,target:"_blank",children:e.jsxs(i,{pointer:!0,bw:1,bs:"solid",bcolor:"mono300",bradiuss:!0,p:16,children:[e.jsx(i,{children:e.jsx(j,{variant:"bodyBold",color:"primary500",children:t})}),e.jsx(i,{children:e.jsx(j,{variant:"captions",children:s})})]})})};Vp.propTypes={onClick:d.func,title:d.string,description:d.string,color:d.string,type:d.string,
1startDate:d.string,endDate:d.string,isScheduleUsersOnly:d.bool};const $D=r.memo(Vp),{cx:BD}=O("PrintSchedule"),Kp=({onClose:t,viewType:s,startDate:n,endDate:o,isScheduleUsersOnly:a,departmentId:l})=>{const c=K({is_by_department:!!l}),u=[{title:p("schedule_builder.react_page.print_drawer.options.white_bg_and_black_text.title"),description:p("schedule_builder.react_page.print_drawer.options.white_bg_and_black_text.description"),color:"no_bg"},{title:p("schedule_builder.react_page.print_drawer.options.full_color_background.title"),description:p("schedule_builder.react_page.print_drawer.options.full_color_background.description"),color:"bg"},{title:p("schedule_builder.react_page.print_drawer.options.with_colored_borders.title"),description:p("schedule_builder.react_page.print_drawer.options.with_colored_borders.description"),color:"border"}],h=r.useCallback(()=>{c(w.DISMISS_CLICKED,k.CLICK),t()},[t,c]);return e.jsxs(i,{column:!0,className:BD(null,"bootstrap"),children:[e.jsxs(i,{row:!0,vcenter:!0,spacebetween:!0,p:16,bcolor:"mono300",children:[e.jsx(Y,{fw600:!0,fs18:!0,i18n:"schedule_builder.react_page.print_drawer.title"}),e.jsx(be,{onClick:h,icon:"Close",size:"small",label:p("actions.close")})]}),e.jsx(i,{p:16,children:e.jsx(Y,{fs14:!0,i18n:"schedule_builder.react_page.print_drawer.description"})}),e.jsx(i,{p:16,column:!0,gap:16,children:u.map(m=>e.jsx($D,{onClick:t,title:m.title,description:m.description,color:m.color,type:s,startDate:n,endDate:o,isScheduleUsersOnly:a,departmentId:l},m.title))})]})};Kp.propTypes={onClose:d.func,viewType:d.string,startDate:d.string,endDate:d.string};const UD=F((t,s)=>({departmentId:Zo(t),startDate:Wn(t,s),endDate:Lr(t,s),viewType:jh(t,s),isScheduleUsersOnly:hi(t)}))(r.memo(Kp)),qp=({isOpen:t,onHideDrawer:s,uxContext:n,departmentId:o})=>{const a=K({is_by_department:!!o});return en()({...n,eventCategory:U.SCHEDULE_BUILDER_PRINT_DRAWER}),r.useEffect(()=>{t&&a(w.PRINT_DRAWER_SHOWN,k.CLICK)},[t]),e.jsx(Ll,{open:t,children:e.jsx(UD,{onClose:s})})};qp.propTypes={onHideDrawer:d.func,isOpen:d.bool,uxContext:d.object};const HD=F(t=>({departmentId:Zo(t),isOpen:eC(t),uxContext:yh(t)}),{onHideDrawer:ie.hideDrawer})(r.memo(Ge({})(qp))),FD=({schedulingInsightsModalIsOpen:t,handleModalClose:s})=>(r.useEffect(()=>{t&&Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_INSIGHTS_EMPTY,eventAction:w.MODAL_VIEWED,actionType:k.VIEW})},[t]),e.jsx(_a,{open:t,hideCloseIcon:!0,noPadding:!0,isAI:!0,isAIAnimating:!0,children:e.jsx(i,{w:628,p:16,column:!0,gap:20,children:e.jsxs(i,{alignItemsCenter:!0,gap:8,flex:!0,justifyContentSpaceBetween:!0,children:[e.jsxs(i,{flex:!0,gap:8,children:[e.jsx(Q,{color:"primary500",iconName:"Sparkle",size:"large"}),e.jsx(j,{variant:"heading4",children:p("schedule_builder.scheduling_insights.dialog.empty_state")})]}),e.jsx(be,{onClick:s,icon:"Close",size:"small",dataTestId:"close-button",label:p("schedule_builder.actions.close")})]})})})),WD=({date:t,events:s})=>{const[n,o]=r.useState(!0),a=r.useCallback(()=>{o(!n)},[n]),l=u=>u.is_whole_day?u.title:`${u.event_start} - ${u.event_end}, ${u.title}.`,c=u=>{const h=u.address?`${u.address}.`:"",m=u.predicted_attendance?`Expected attendance: ${u.predicted_attendance.toLocaleString()}`:"";return u.is_whole_day?`${m}`:`${h} ${m}`};return e.jsxs(e.Fragment,{children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,children:[e.jsx(be,{onClick:a,icon:n?"CaretDown":"CaretRight",size:"small",label:p("schedule_builder.actions.show_details")}),e.jsx(j,{variant:"body",color:"mono900",children:Oe(t,"pretty_full_no_year")})]}),e.jsx(i,{flex:!0,column:!0,gap:12,ml:33,children:n&&s.length>0&&e.jsx(e.Fragment,{children:s.map(u=>e.jsx(i,{flex:!0,row:!0,children:e.jsxs(i,{flex:!0,gap:5,column:!0,children:[e.jsx(i,{children:e.jsxs(j,{variant:"bodySmBold",color:"mono700",children:["⢠",l(u)]})}),e.jsx(i,{children:e.jsx(j,{variant:"bodySm",color:"mono700",children:c(u)})})]})},u.event_id))})})]})},{cx:VD}=O("SchedulingInsightsFeedback"),KD=5,qD=({createOTE:t,currentUserId:s})=>{const[n,o]=r.useState(!1),[a,l]=r.useState(""),[c,u]=r.useState(!0),h=r.useCallback(()=>`dislikeFeedbackCount-${s}`,[s]),m=r.useCallback(()=>parseInt(localStorage.getItem(h())||"0",10),[h]),_=r.useCallback(S=>{localStorage.setItem(h(),S.toString())},[h]),[f,g]=r.useState(m());r.useEffect(()=>{n&&setTimeout(()=>{l("slide-down")},3e3)},[n]);const b=r.useCallback(()=>{o(!0),localStorage.removeItem(h()),Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_INSIGHTS,eventAction:w.BUTTON_CLICKED,actionType:k.CLICK,properties:{rating:"positive"}})},[h]),x=r.useCallback(()=>{o(!0);const S=f+1;g(S),_(S),m()===KD&&(t("schedule_insights_modal_dismissed","Account"),localStorage.removeItem(h())),Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_INSIGHTS,eventAction:w.BUTTON_CLICKED,actionType:k.CLICK,properties:{rating:"negative"}})},[f,_,m,t,h]),E=r.useCallback(()=>{setTimeout(()=>{u(!1)},500)},[]);return e.jsx(e.Fragment,{children:n?e.jsx(e.Fragment,{children:c&&e.jsxs(i,{className:VD(a),onAnimationEnd:E,flex:!0,alignItemsCenter:!0,gap:8,pt:16,children:[e.jsx(Q,{iconName:"Success",color:"green300",size:"small"}),e.jsx(j,{variant:"captions",color:"mono700",children:p("schedule_builder.scheduling_insights.dialog.feedback")})]})}):e.jsxs(i,{flex:!0,gap:10,pt:16,children:[e.jsx(i,{children:e.jsx(j,{variant:"captions",color:"mono700",children:p("schedule_builder.scheduling_insights.dialog.information_helpful")})}),e.jsx(i,{children:e.jsx(Q,{iconName:"Like",color:"primary500",size:"small",onClick:b})}),e.jsx(i,{children:e.jsx(Q,{iconName:"Dislike",color:"primary500",size:"small",onClick:x})})]})})},zD=F(t=>({currentUserId:tC(t)}),{createOTE:jr})(r.memo(qD)),GD=({onCloseSchedulingInsightsModalIcon:t,onCloseSchedulingInsightsModal:s,schedulingInsightsEvents:n,schedulingInsightsModalIsOpen:o})=>{const[a,l]=r.useState(!0),c=Object.values(n).flat();r.useEffect(()=>{o&&c.length>0&&Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_INSIGHTS,eventAction:w.MODAL_VIEWED,actionType:k.VIEW})},[o,c.length]);const u=r.useCallback(()=>{s(),t(),Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_INSIGHTS,eventAction:w.DISM
1ISS_CLICKED,actionType:k.CLICK})},[s,t]),h=r.useCallback(()=>{a?Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_EVENT_MODAL_COLLAPSE,eventAction:w.BUTTON_CLICKED,actionType:k.CLICK}):Rt({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_EVENT_MODAL_UNCOLLAPSE,eventAction:w.BUTTON_CLICKED,actionType:k.CLICK}),l(!a)},[a]);return e.jsxs(e.Fragment,{children:[c.length===0&&o&&e.jsx(FD,{schedulingInsightsModalIsOpen:o,handleModalClose:u}),c.length>0&&e.jsx(_a,{open:o,hideCloseIcon:!0,noPadding:!0,isAI:!0,isAIAnimating:!0,children:e.jsxs(i,{w:628,p:16,column:!0,gap:20,children:[e.jsxs(i,{alignItemsCenter:!0,gap:8,flex:!0,justifyContentSpaceBetween:!0,children:[e.jsxs(i,{flex:!0,gap:8,children:[e.jsx(Q,{color:"primary500",iconName:"Sparkle",size:"large"}),e.jsx(j,{variant:"heading4",children:p("schedule_builder.scheduling_insights.dialog.title")})]}),e.jsxs(i,{children:[e.jsx(be,{onClick:h,icon:a?"ChevronDown":"ChevronUp",size:"small",dataTestId:"toggle-messages-button",label:"close_dialog"}),e.jsx(be,{onClick:u,icon:"Close",size:"small",dataTestId:"close-button",label:p("schedule_builder.actions.close")})]})]}),a&&e.jsxs(i,{children:[e.jsx(i,{flex:!0,column:!0,gap:10,maxh:368,overflowY:"auto",children:Object.entries(n).map(([m,_])=>e.jsx(WD,{date:m,events:_},m))}),e.jsx(zD,{})]})]})})]})},YD=F(t=>{const s=it(t);return{schedulingInsightsEvents:nC(t,{start:s.start,end:s.end}),schedulingInsightsModalIsOpen:sC(t)}},{onCloseSchedulingInsightsModal:ie.closeSchedulingInsightsModal,onCloseSchedulingInsightsModalIcon:ie.closeSchedulingInsightsModalIcon})(r.memo(GD)),JD=({translationForKey:t,onHideDrawer:s})=>e.jsxs(i,{w:"100%",gap:24,column:!0,justifyContentCenter:!0,children:[e.jsx(i,{flex:!0,justifyContentCenter:!0,w:"100%",children:e.jsx(vh,{w:"120px"})}),e.jsx(j,{textAlign:"center",variant:"heading2",children:t("title_all_shifts_synced")}),e.jsx(V,{onClick:s,uxElement:"done",children:t("done")})]}),XD=F(t=>({sendToPartnerSyncErrors:Vn(t)}),{onHideDrawer:Ln})(JD),QD=({onHideDrawer:t,translationForKey:s})=>e.jsxs(i,{gap:24,column:!0,justifyContentCenter:!0,children:[e.jsx(i,{flex:!0,justifyContentCenter:!0,w:"100%",children:e.jsx(rC,{w:"120px"})}),e.jsx(j,{textAlign:"left",variant:"heading2",children:s("title_no_shifts_synced")}),e.jsxs(dt,{variant:"warning",children:[e.jsx(j,{variant:"bodyBold",children:s("description_no_shifts_synced")}),e.jsx(j,{children:s("link_message")})]}),e.jsx(V,{onClick:t,uxElement:"done",children:s("done")})]}),ZD=F(t=>({sendToPartnerSyncErrors:Vn(t)}),{onHideDrawer:Ln})(QD),ek=({translationForKey:t,hideDrawer:s})=>e.jsxs(i,{gap:24,column:!0,justifyContentCenter:!0,children:[e.jsx(i,{flex:!0,justifyContentCenter:!0,w:"100%",children:e.jsx(Lv,{w:"120px"})}),e.jsx(j,{textAlign:"left",variant:"heading2",children:t("title_some_shifts_synced")}),e.jsx(dt,{variant:"success",children:e.jsx(j,{variant:"bodyBold",children:t("success_some_shifts_synced")})}),e.jsxs(dt,{variant:"warning",children:[e.jsx(j,{variant:"bodyBold",children:t("warning_some_shifts_synced")}),e.jsx(j,{children:t("link_message")})]}),e.jsx(V,{onClick:s,uxElement:"done",children:t("done")})]}),tk=F(t=>({currentWeek:it(t)}),{hideDrawer:Ln})(ek),sk=({currentWeek:t,sendToPartnerSyncErrors:s,shiftSyncStatuses:n=[],partner
1SyncState:o,handleSyncShifts:a,translationForKey:l})=>{const c=r.useCallback(()=>{const u=s.length,h=n.length;return l(u===0?"error_title":u===h?"error_syncing_all_shifts":"error_syncing_some_shifts")},[l,s.length,n.length]);return e.jsxs(i,{gap:24,column:!0,justifyContentCenter:!0,children:[e.jsx(j,{textAlign:"left",variant:"heading2",children:l("title")}),e.jsx(j,{variant:"body",children:l("description")}),e.jsxs(dt,{variant:"error",children:[e.jsx(j,{variant:"bodyBold",children:c()}),e.jsx(j,{children:l("error_message")})]}),e.jsxs(i,{bw:1,bcolor:"mono300",bradiusm:!0,p:20,children:[e.jsx(j,{variant:"bodyBoldTight",color:"mono900",children:l("shifts_being_sent")}),e.jsx(j,{color:"mono700",children:`${lt(t?.start).format(es("pretty_no_wday"))} - ${lt(t?.end).format(es("pretty_no_wday"))}`})]}),Vn.length>0&&e.jsxs(dt,{variant:"warning",children:[e.jsx(j,{variant:"bodyBold",children:l("warning_message")}),e.jsx(j,{children:l("warning_message")}),e.jsxs(i,{mt:16,gap:16,flex:!0,justifyContentStart:!0,children:[e.jsx(V,{size:"small",variant:"secondary",children:l("link_team_members_button")}),e.jsx(Nt,{endIcon:"ExternalLink",children:l("roles_link")})]})]}),e.jsx(V,{isLoading:o==="LOADING",disabled:o==="LOADING",onClick:a,uxElement:"send_shifts_to_partner_cta",children:l(o==="ERROR"?"retry_send_shifts_to_partner_cta":"send_shifts_to_partner_cta")})]})},nk=F(t=>({unpublishedShiftsCount:ea(t),currentWeek:it(t),sendToPartnerSyncErrors:Vn(t),shiftSyncStatuses:pi(t),partnerSyncState:mi(t)}),{syncShiftsAction:Ih,setPartnerSyncState:ie.setPartnerSyncState})(sk),rk=({currentWeek:t,partnerSyncState:s,handleSyncShifts:n,translationForKey:o})=>e.jsxs(i,{gap:24,column:!0,justifyContentCenter:!0,children:[e.jsx(j,{textAlign:"left",variant:"heading2",children:o("title")}),e.jsx(j,{variant:"body",children:o("description")}),e.jsxs(i,{bw:1,bcolor:"mono300",bradiusm:!0,p:20,children:[e.jsx(j,{variant:"bodyBoldTight",color:"mono900",children:o("shifts_being_sent")}),e.jsx(j,{color:"mono700",children:`${lt(t?.start).format(es("pretty_no_wday"))} - ${lt(t?.end).format(es("pretty_no_wday"))}`})]}),e.jsx(V,{isLoading:s==="LOADING",disabled:s==="LOADING",onClick:n,uxElement:"send_shifts_to_partner_cta",children:o(s==="ERROR"?"retry_send_shifts_to_partner_cta":"send_shifts_to_partner_cta")})]}),ok=F(t=>({partnerSyncState:mi(t),currentWeek:it(t),sendToPartnerSyncErrors:Vn(t)}),{})(rk),{cx:ak}=O("SendToPartnerDrawerView"),lk=({partner:t,currentWeek:s,shiftSyncStatuses:n=[],partner
1SyncState:o,setPartnerSyncState:a,sendToPartnerSyncErrors:l,syncShiftsAction:c,isShown:u,onHideDrawer:h,onFetchTemplates:m,isManager:_})=>{const f=X(),g=en(),b=Ir(t);r.useEffect(()=>{_&&u&&m()},[_,m,u]);const x=r.useCallback(y=>p(`schedule_builder.react_page.send_to_partner_drawer.${y}`,{props:{count:n.length,partner:b,syncErrors:l.length}}),[n.length,b,l.length]);g({eventCategory:U.SCHEDULE_BUILDER_SYNC_SHIFTS,productArea:ae.SCHEDULE_BUILDER,properties:{partner:t}}),ps(w.DRAWER_SHOWN,k.VIEW);const E=r.useCallback(()=>{h()},[h]),S=r.useCallback(async()=>{f(a("LOADING")),await c({payload:{start_date:s?.start,end_date:s?.end,notification_group:"everyone",partner:t,syncedShifts:n.length}})},[f,a,s,t,n.length,c]);return u?e.jsx(Eu,{children:(y,C)=>{const v=!(y||C);return e.jsxs(Ll,{className:ak(),open:!0,width:v?"480px":"100%",children:[e.jsx(i,{onClick:E,p:32,justifyContentEnd:!0,children:e.jsx(Q,{iconName:"Close",color:"purple500"})}),e.jsxs(i,{ph:v?40:0,pt:v?24:0,pb:v?96:0,alignCenter:!0,alignItemsCenter:!0,column:!0,children:[o==="FULLY_SENT"&&e.jsx(XD,{translationForKey:x,partner:t}),o==="PARTIALLY_SENT"&&e.jsx(tk,{translationForKey:x,partner:t}),o==="NONE_SENT"&&e.jsx(ZD,{translationForKey:x,partner:t}),o==="ERROR"&&e.jsx(nk,{translationForKey:x,handleSyncShifts:S,partner:t}),(o===void 0||o==="LOADING")&&e.jsx(ok,{translationForKey:x,handleSyncShifts:S,partner:t})]})]})}}):null},ik=F(t=>({unpublishedShiftsCount:ea(t),currentWeek:it(t),sendToPartnerSyncErrors:Vn(t),isShown:oC(t),shiftSyncStatuses:pi(t),partnerSyncState:mi(t)}),{syncShiftsAction:Ih,onHideDrawer:Ln,setPartnerSyncState:ie.setPartnerSyncState,onFetchTemplates:aC})(lk),{cx:ck}=O("ScheduleBuilderPreloader"),qa=()=>e.jsxs(e.Fragment,{children:[e.jsx(i,{className:ck(),bgcolor:"mono0",opacity:.5,absolute:!0,top:0,left:0,w:"100%",h:"100%",zIndex:98}),e.jsx(i,{zIndex:99,fixed:!0,left:"50%",top:"50%",children:e.jsx($n,{size:"large",variant:"dark"})})]}),dk=os((t,s)=>{const{departmentId:n}=s,o=it(t),a=new Date(o.start),l=new Date(o.end);if(!n)return ta(t).filter(m=>{const _=new Date(Co(m.startAt));return _>=a&&_<=l&&Th(m,wh(t))}).length;const c=rl(o.start,o.end);return(_i({state:t,id:n,attribute:"name"})===Dh?[...bl(t,{departmentId:n}),"uncategorized"]:bl(t,{departmentId:n})).reduce((m,_)=>m+c.reduce((f,g)=>f+kh(t,{roleId:_,date:g}).length,0),0)},(t,{departmentId:s,...n})=>s?fi(t,{departmentId:s}):Rh(t,n),(t,{departmentId:s,...n})=>s?bi(t,{departmentId:s}):gi(t,n),Ls,Lh,t=>lC(t).length,(t,s,n,o,a,l)=>{const c=[{title:p("schedule_builder.react_page.publish_drawer.stats.shifts"),value:t},{title:p("schedule_builder.react_page.publish_drawer.stats.hours"),value:s.toFixed(2)}];return o&&a&&c.push({title:p("schedule_builder.react_page.publish_drawer.stats.wages"),value:pt(n)}),l>1&&c.push({title:p("schedule_builder.publish_drawer.scheduled_departments"),value:l}),c}),uk=({childLaborComplianceSettingsEnabled:t,hasConflicts:s,startRange:n,endRange:o,stats:a,shiftsInRange:l,isDrawerOpen:c})=>{const u=X(),[h,m]=r.useState(!1),_=r.useMemo(()=>{const b=Oe(n,"month_day_year_short"),x=Oe(o,"month_day_year_short");return`${b} - ${x}`},[n,o]);r.useEffect(()=>{if(c){if(!t||l.length===0){u(iC(cC)),m(!1);return}u(dC({shifts:l})).then(b=>{m(b.payload?.has_violations||!1)})}},[c,t,u,l]);const{cx:f}=O("PublishDrawerSummary");let g;return s&&h?g=p("schedule_builder.publish_drawer.has_both_conflicts_and_violations"):s?g=p("schedule_builder.publish_drawer.has_conflicts"):h&&(g=p("schedule_builder.publish_drawer.has_child_labor_violations")),e.jsxs(i,{mb:32,bw:1,bcolor:"mono400",bradiusm:!0,column:!0,flex:!0,p:12,children:[e.jsxs(i,{borderbox:!0,bcolor:xi.grayMediumLight,column:!0,flex:!0,mb:20,children:[e.jsx(j,{variant:"heading3",children:p("schedule_builder.publish_drawer.summary")}),e.jsx(j,{variant:"body",color:"mono700",children:_}),g&&e.jsx(Ah,{warningText:g})]}),e.jsx("div",{children:a?.map(({title:b,value:x},E)=>e.jsxs(e.Fragment,{children:[e.jsxs(i,{row:!0,spacebetween:!0,children:[e.jsx(j,{variant:"body",children:b.substring(0,b.length-1)}),e.jsx(j,{className:f("number-column"),color:"mono900",variant:"bodyBold",children:x})]},E),E!==a.length-1&&e.jsx(i,{mv:16,children:e.jsx(gn,{})})]}))})]})},hk=(t,s)=>({childLaborComplianceSettingsEnabled:_s(t),hasConflicts:Nh(t),startRange:Wn(t),endRange:Lr(t),stats:dk(t,{...s,departmentId:Zo(t)}),shiftsInRange:uC(t),isDrawerOpen:Oh(t)}),mk=F(hk),zp=mk(r.memo(uk)),pk=({onDone:t,onRepeat:s,notifyType:n,isByDepartment:o=!1,rangeType:a})=>{const l=K(),c=a===J.week;r.useEffect(()=>{l(w.PUBLISH_SUCCESS_DRAWER_SHOWN,k.VIEW)},[l]);const u=r.useCallback(()=>
1{l(w.DONE_CTA_CLICKED,k.CLICK),t()},[t,l]),h=r.useCallback(()=>{l(w.REPEAT_SCHEDULE_CTA_CLICKED,k.CLICK),s()},[s,l]);return e.jsxs(i,{tleft:!0,flex:!0,column:!0,w:"100%","data-testid":"PublishSuccessView",children:[e.jsx(i,{mb:48,flex:!0,column:!0,w:"100%",alignItemsCenter:!0,justifyContentCenter:!0,children:e.jsx(vh,{w:164})}),e.jsx(i,{tleft:!0,mb:12,children:e.jsx(j,{variant:"heading2",children:p(o?"schedule_builder.publish_drawer.published.title":"schedule_builder.publish_drawer.published_success.title")})}),e.jsxs(i,{tleft:!0,mb:32,children:[e.jsx(j,{variant:"body",children:p(o?`schedule_builder.publish_drawer.published.notify_desc_options.${n}`:`schedule_builder.publish_drawer.published_success.notify.${n}`)}),o&&e.jsx(j,{variant:"body",children:p("schedule_builder.publish_drawer.published.notify_desc")})]}),o&&e.jsx(i,{tleft:!0,mb:10,children:e.jsx(j,{variant:"body",children:p("schedule_builder.publish_drawer.published.summary")})}),o&&e.jsx(zp,{}),!o&&e.jsxs(i,{children:[e.jsx(i,{mb:12,children:e.jsx(V,{fullWidth:!0,onClick:u,children:p("schedule_builder.publish_drawer.published_success.done")})}),c&&e.jsx(i,{children:e.jsx(V,{fullWidth:!0,onClick:h,variant:"secondary",startIcon:"Refresh",children:p("schedule_builder.publish_drawer.published_success.repeat")})})]})]})},_k=r.memo(pk),qd=[1,2,3,4].map(t=>({value:t,label:p("schedule_builder.publish_drawer.repeat_schedule.options",{props:{count:t}})})),fk=({onApply:t,isLoading:s})=>{const n=K(),[o,a]=r.useState(0);r.useEffect(()=>{n(w.REPEAT_SCHEDULE_DRAWER_SHOWN,k.VIEW)},[n]);const l=r.useCallback(()=>{n(w.REPEAT_INTERVAL_DROPDOWN_CLICKED,k.CLICK)},[n]),c=r.useCallback(h=>{a(h);const m=qd.find(_=>_.value===h)?.label;n(w.REPEAT_INTERVAL_SELECTED,k.CLICK,{repeatOption:m})},[n]),u=r.useCallback(()=>{n(w.APPLY_CTA_CLICKED,k.CLICK),t(o)},[n,t,o]);return e.jsxs(i,{pt:70,relative:!0,children:[e.jsx(i,{mb:16,children:e.jsx(Y,{navy:!0,fs:16,fw600:!0,i18n:"schedule_builder.publish_drawer.repeat_schedule.label"})}),e.jsx(i,{mb:16,dataTestId:"repeat-week-selector",children:e.jsx(Mh,{onChange:c,onOpen:l,value:o,placeholder:p("schedule_builder.publish_drawer.repeat_schedule.placeholder"),options:qd,searchable:!1,hideClear:!0})}),e.jsx(i,{mb:24,children:e.jsx(Y,{fs:12,lh:"16px",i18n:"schedule_builder.publish_drawer.repeat_schedule.desc"})}),e.jsx("div",{children:e.jsx(i,{mb:12,children:e.jsx(V,{variant:"primary",fullWidth:!0,disabled:o===null,onClick:u,dataTestId:"apply-button",isLoading:s,children:p("actions.apply")})})})]})},bk=r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_REPEAT_SCHEDULE_DRAWER})(fk)),{cx:gk}=O("ShiftNoteDiscoverability"),xk={background:`url(${new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='288'%20height='215'%20fill='none'%20viewBox='0%200%20288%20215'%3e%3cpath%20fill='%23F3EEF6'%20d='M0%208a8%208%200%200%201%208-8h272a8%208%200%200%201%208%208v199a8%208%200%200%201-8%208H8a8%208%200%200%201-8-8V8z'%20opacity='.5'/%3e%3cmask%20id='a'%20width='288'%20height='215'%20x='0'%20y='0'%20maskUnits='userSpaceOnUse'%3e%3cpath%20fill='%2370CAD9'%20d='M0%200h288v212a3%203%200%200%201-3%203H3a3%203%200%200%201-3-3V0z'/%3e%3c/mask%3e%3cg%20mask='url(%23a)'%3e%3cpath%20fill='%23D0B6E0'%20fill-rule='evenodd'%20d='M225%2097h-3.166c-1.458%200-2.666.931-3.145%202.228-.034.094-.027.202-.054.303-.081.277-.176.547-.176.844v81.182a3.372%203.372%200%200%200%203.375%203.375h46.164l-17.807%2017.598a3.377%203.377%200%200%200-.027%204.772%203.394%203.394%200%200%200%202.396.999c.857%200%201.715-.324%202.376-.972l23.625-23.349a3.354%203.354%200%200%200%20.999-2.396c0-.904-.358-1.761-.992-2.403l-23.625-23.395a3.398%203.398%200%200%200-4.779.027%203.383%203.383%200%200%200%20.02%204.772l17.78%2017.597h-42.755V103.75c40.851.115%2074.041%2033.379%2074.041%2074.25%200%2040.939-33.311%2074.25-74.25%2074.25s-74.25-33.311-74.25-74.25c0-28.296%2016.47-54.553%2041.958-66.879a3.378%203.378%200%200%200%201.573-4.509%203.384%203.384%200%200%200-4.509-1.573C161.969%20118.492%20144%20147.125%20144%20178c0%2044.665%2036.335%2081%2081%2081s81-36.335%2081-81-36.335-81-81-81z'%20clip-rule='evenodd'%20opacity='.14'/%3e%3c/g%3e%3c/svg%3e",import.meta.url).href})`,backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundPosition:"0% 100%"},zd=t=>$b({productArea:"schedule_builder",eventCategory:"publish_drawer_reminder",eventAction:t,experimentName:"shift_note_discoverability"}),Ck=({isShiftNoteDiscoverabilityEnabled:t})=>{r.useEffect(()=>{t&&zd("view")},[]);const s=r.useCallback(()=>{hC(Zb.SHIFT_NOTE_DISCOVERABILITY),t&&zd("click")},[t]);return e.jsx(i,{className:gk(),borderbox:!0,w:"100%",ph:20,mb:12,children:e.jsxs(i,{style:xk,minh:144,pv:8,ph:20,column:!0,spacebetween:!0,children:[e.jsx("div",{children:e.jsx("div",{children:e.jsx(Y,{i18n:"schedule_builder.publish_drawer.shift_notes_discoverability.title",fs16:!0,fw600:!0})})}),e.jsx("div",{children:e.jsx("div",{children:e.jsx(Y,{i18n:"schedule_builder.publish_drawer.shift_notes_discoverability.content",fs14:!0})})}),e.jsx("div",{children:e.jsx(V,{variant:"tertiaryPlain",onClick:s,children:p("schedule_builder.publish_drawer.shift_notes_discoverability.cta")})})]})})},Ek=r.memo(Ck),Sk=({hasAlreadyPublishedShifts:t,hasUnpublishedShifts:s,withoutContactInfoCount:n=0,showAddShiftNotesReminder:o,hasCreatedNote:a,onPublish:l,isLoading:c})=>{const[u,h]=r.useState("location"),m=K();r.useEffect(()=>{t&&s&&h("job")},[]);const _=r.useCallback(()=>{m(w.PUBLISH_CLICKED,k.CLICK,{notifyType:u,isViaSms:!1}),l(u)},[l,m,u]),f=r.useMemo(()=>{const x=[];return x.push({label:p("schedule_builder.publish_drawer.notify_options.location"),value:"location"}),s&&(x.push({label:p("schedule_builder.publish_drawer.notify_options.job"),value:"job"}),x.push({label:p("schedule_builder.publish_drawer.notify_options.nobody"),value:"nobody"})),x},[s]),g=r.useCallback(()=>
1o&&!a?e.jsx(Ek,{isShiftNoteDiscoverabilityEnabled:!0}):null,[o,a]),b=r.useCallback(x=>{h(x)},[h]);return e.jsxs(e.Fragment,{children:[e.jsx(i,{w:"100%",tleft:!0,flex:!0,row:!0,justifyContentStart:!0,alignItemsNormal:!0,children:e.jsx(j,{variant:"heading2",children:p("schedule_builder.publish_drawer.title")})}),e.jsxs(i,{mt:32,mb:20,w:"100%",alignItemsNormal:!0,children:[e.jsx(zp,{}),e.jsx(Ht,{initialValues:{notifyType:u},onSubmit:void 0,children:()=>e.jsxs("div",{children:[e.jsxs(i,{gap:8,mb:20,children:[e.jsx(j,{variant:"heading3",children:p("schedule_builder.publish_drawer.notifications")}),e.jsx(j,{color:"mono700",variant:"bodySm",children:p("schedule_builder.publish_drawer.notify_subtitle")})]}),e.jsx(li,{name:"notify-type",children:f.map(x=>e.jsx(i,{onClick:()=>b(x.value),children:e.jsx(ii,{label:x.label,name:"notify-type",checked:u===x.value},x.value)},x.value))})]})})]}),n>0&&e.jsx(dt,{variant:"warning",children:p("schedule_builder.publish_drawer.without_contact_info",{props:{count:n}})}),e.jsx(mC,{children:x=>{const E=window.innerWidth>window.innerHeight&&x;return e.jsxs(i,{left:E?void 0:0,w:"100%",children:[g(),e.jsx(i,{pv:20,children:e.jsx("div",{children:e.jsx(V,{fullWidth:!0,onClick:_,isLoading:c,disabled:c,startIcon:"Send",children:p("schedule_builder.publish_drawer.publish_button")})})})]})}})]})},jk=r.memo(Sk),{cx:yk}=O("PublishDrawerView"),{SCHEDULE_BUILDER_PUBLISH_DRAWER:za}=U,vk=({isOpen:t,onPublishSchedule:s,weekStart:n,weekEnd:o,onHideDrawer:a,showAddShiftNotesReminder:l,withoutContactInfoCount:c,hasUnpublishedShifts:u,hasAlreadyPublishedShifts:h,onRepeatSchedule:m,departmentId:_,hasCreatedNote:f,hasConflicts:g,isPublishLoading:b,uxContext:x={},exitCopyPasteMode:E})=>{const[S,y]=r.useState(""),[C,v]=r.useState(!1),[T,D]=r.useState("publish"),L=I(CC),A=I(_s),P=r.useRef(!1),M=en(),R=K(),{rangeType:$}=ze();M({...x,eventCategory:za,hasConflicts:g}),r.useEffect(()=>{if(!t){y(""),P.current=!1;return}D("publish"),!(!(!A||L!=null)||P.current)&&(P.current=!0,R(w.PUBLISH_SCHEDULE_DRAWER_SHOWN,k.VIEW,{productArea:ae.SCHEDULE,eventCategory:za,...A?La(L):{}}))},[t,R,A,L]),r.useEffect(()=>{t&&a()},[n]);const B=r.useCallback(()=>{const re=(ue=>{switch(ue){case"publish":return w.PUBLISH_SCHEDULE_DRAWER_CLOSED;case"repeat":return w.REPEAT_SCHEDULE_DRAWER_CLOSED;case"success":return w.PUBLISH_SUCCESS_DRAWER_CLOSED;default:return w.PUBLISH_SCHEDULE_DRAWER_CLOSED}})(T);R(re,k.CLICK,re===w.PUBLISH_SCHEDULE_DRAWER_CLOSED?{productArea:ae.SCHEDULE,eventCategory:za,...A?La(L):{}}:{}),a()},[a,R,T,L,A]),W=r.useCallback(()=>D("repeat"),[]),N=r.useCallback(G=>{v(!0),m({weekStart:n,weekEnd:o,numberOfWeeks:G}).then(()=>{R(w.REPEAT_SCHEDULE_SUCCESS_BANNER_SHOWN,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER}),a()}).finally(()=>{t&&v(!1)})},[m,R,n,o,a,t]),H=r.useCallback(G=>{y(G),R(w.BUTTON_CLICKED,k.CLICK,{productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER,buttonAction:"publish_schedule",buttonText:"publish",buttonLocation:"schedule_builder_publish_drawer",...A?La(L):{}}),s({payload:{start_date:n,end_date:o,department_id:_,notification_group:G}}).unwrap().then(()=>{E(),D("success")}).catch(()=>{})},[_,s,n,o,E,R,L,A]),q=()=>T==="success"?e.jsx(_k,{rangeType:$,notifyType:S,onRepeat:W,onDone:a,isByDepartment:!!_}):T==="repeat"?e.jsx(bk,{onApply:N,isLoading:C}):e.jsx(jk,{hasAlreadyPublishedShifts:h,hasUnpublishedShifts:u,withoutContactInfoCount:c,showAddShiftNotesReminder:l,hasCreatedNote:f,onPublish:H,isLoading:b});return e.jsx(i,{cx:yk(),children:e.jsx(pa,{open:t,onClose:B,children:q()})})},Ik=F(t=>({isOpen:Oh(t),weekStart:Wn(t),weekEnd:Lr(t),withoutContactInfoCount:bC(t,{attribute:"scheduleConfirmation",value:"missing_contact_info"})?.length||0,showAddShiftNotesReminder:Es({state:t,attribute:"isAddShiftNotesReminderEnabled",sliceName:"schedule"}),hasUnpublishedShifts:fC(t),hasAlreadyPublishedShifts:_C(t),hasConflicts:Nh(t),isPublishLoading:pC(t),uxContext:yh(t),departmentId:Zo(t)}),{onHideDrawer:ie.hideDrawer,onPublishSchedule:xC,onRepeatSchedule:gC,exitCopyPasteMode:ie.stopCopyPaste})(Ge({})(vk)),Tk=({dragData:t})=>
1{const{startAt:s,endAt:n,color:o,roleName:a}=t,l=Ut(s,n);return e.jsxs(i,{className:`ShiftDragOverlay ShiftDragOverlay--${o||"blue2"}-v2`,bradiuss:!0,pv:2,ph:8,column:!0,children:[e.jsx(j,{variant:"captionBold",noWrap:!0,children:l}),e.jsx(i,{ellipsis:!0,children:e.jsx(j,{noWrap:!0,variant:"captions",color:a?void 0:"mono700",children:a||p("schedule_builder.react_page.shifts.no_role")})})]})},zi=Te(EC,(t,s)=>ur(s.date).year(),(t,s)=>ur(s.date).month()+1,(t,s,n)=>t?.find(o=>o.month===n&&o.year===s)||{})((t,s)=>`selectEventQuota-${s.date}`),wk=os(Ci,t=>Ft(t),(t,s)=>t.filter(o=>s.includes(o.date)).length),Dk=Te(Ci,(t,s)=>s,(t,s)=>((vr(t,o=>o.date)||{})[s]||[]).map(o=>o.id))((t,s)=>`selectEventIdsOnDate-${s}`),Gp=Te(t=>Le({state:t,attribute:"isEventsVisible"}),(t,s)=>Ci(t).filter(n=>n.date===s.date),(t,s)=>t?s:[])((t,{date:s})=>`selectEventsForDay-${s}`),kk=Te((t,s)=>Gp(t,s).map(n=>n.id).join(","),t=>t.length?t.split(","):[])((t,{date:s})=>`selectEventIdsForDay-${s}`),Gi=os(t=>ct(t)||t.get("session")?.currentLocation?.id,t=>ta(t),(t,s)=>s.filter(n=>{const o=n?.owner?.type==="location"?n?.owner?.id:void 0;return String(o)===String(t)})),Rk=os(Gi,t=>Ft(t),(t,s)=>t.filter(o=>s.includes(Co(o.startAt))).length),Lk=os(Gi,t=>{const s=t.reduce((n,o)=>{const a="YYYY-MM-DD HH:mm",l=ur(o.startAt,a),c=ur(o.endAt,a),u=Bb(c.diff(l)).asHours();return n+=u},0);return(Math.round(s*100)/100).toFixed(2)}),Ak=Te(Gi,(t,s)=>s.date,(t,s)=>t.filter(n=>Co(n.startAt)===s))((t,{date:s})=>`selectOpenShiftsOnDate-${s}`),Yp=os(Ak,t=>t.sort(Ei)),Jp=[];function Xp({state:t,selectJobId:s}){return function(n,o){const a=s({state:t,id:n.id,relationship:"job"}),l=s({state:t,id:o.id,relationship:"job"}),c=wt({state:t,relationship:"user",id:a}),u=wt({state:t,relationship:"user",id:l}),h=(Pc(t,c)||"").toLowerCase(),m=(Pc(t,u)||"").toLowerCase();return h<m?-1:h>m?1:parseInt(n.id,10)<parseInt(o.id,10)?-1:1}}const Ca=Te((t,{jobId:s})=>s,SC,(t,{date:s})=>s,(t,s,n)=>s.filter(o=>o.job?.id===t).filter(o=>o.date===n))((t,{jobId:s,date:n})=>`schedule-availabilities-job-${s}-date-${n}`),Gd=Te((t,{jobId:s,date:n})=>{const o=Ca(t,{jobId:s,date:n});return o.length===0?Jp:o},(t,{title:s})=>s,(t,s)=>t.filter(n=>n.title===s).map(n=>n.id))((t,{jobId:s,date:n,title:o})=>`preferred-schedule-availabilities-job-${s}-date-${n}-title-${o}`),Ok=Te((t,{date:s})=>{const n=Ph(t).map(u=>u.id),o=Object.keys($h(t));return Bh(t,{attribute:"date",value:s}).filter(u=>u.title==="Unavailable"&&u.allDay&&n.includes(u?.job?.id)&&!o.includes(u?.job?.id)).sort(Xp({state:t,selectJobId:Si})).map(u=>u.id).join(",")},t=>t.length?t.split(","):[])((t,{date:s})=>`selectUnavailabilitiesForWholeDay-${s}`),Nk=Te((t,{date:s})=>{const n=Ph(t).map(l=>l.id),o=Object.keys($h(t));return Bh(t,{attribute:"date",value:s}).filter(l=>l.title==="Unavailable"&&!l.allDay&&n.includes(l?.job?.id)&&!o.includes(l?.job?.id)).sort((l,c)=>new Date(l.startAt)<new Date(c.startAt)?-1:1).map(l=>l.id).join(",")},t=>t.length?t.split(","):[])((t,{date:s})=>`selectUnavailabilitiesForPartialDay-${s}`),Mk=Te((t,s)=>Xt({state:t,id:s,attribute:"dayDurations"}),t=>t?.reduce((s,n)=>n?.duration+s,0))((t,s)=>`selectTimeOffDuration-${s}`),Pk=Te((t,s)=>uo({state:t,id:s,attribute:"ptoCategories"}),t=>Hm.filter(s=>t?.includes(s.value)))((t,s)=>`time-off-job-categories-${s}`),Qp=Te(sa,(t,{jobId:s,date:n})=>({jobId:s,date:n}),(t,{jobId:s,date:n})=>t.filter(o=>{const a=o.dayDurations?.some(c=>c.date===n),l=o.job?.id===s;return a&&l}))((t,{jobId:s,date:n})=>`selectTimeOffsForJobOnDate-${s}-${n}`),$k=Te((t,s)=>{const n=Qp(t,s);return n.length===0?Jp:n},t=>t.map(({id:s})=>s))((t,{jobId:s,date:n})=>`selectTimeOffIdsForJobOnDate-${s}-${n}`),Bk=Te((t,{date:s})=>sa(t).filter(n=>{if(!n.isWholeDay||!n.dayDurations?.some(c=>c.date===s))return!1;const o=n.job?.id;if(!o)return!1;const a=Uh(t,o),l=ct(t)||t.getIn(["session"])?.currentLocation?.id;return a?.location?.id===String(l)}).sort(Xp({state:t,selectJobId:Hh})).map(({id:n})=>n).join(","),na,(t,s)=>s&&t.length?t.split(","):[])((t,{date:s})=>`selectTimeOffsWholeDayForDate-${s}`),Uk=Te((t,{date:s})=>sa(t).filter(n=>{if(n.isWholeDay||!n.dayDurations?.some(c=>
1c.date===s))return!1;const o=n.job?.id;if(!o)return!1;const a=Uh(t,o),l=ct(t)||t.getIn(["session"])?.currentLocation?.id;return a?.location?.id===String(l)}).sort((n,o)=>new Date(n.startAt)<new Date(o.startAt)?-1:1).map(({id:n})=>n).join(","),na,(t,s)=>s&&t.length?t.split(","):[])((t,{date:s})=>`selectTimeOffsPartialDayForDate-${s}`),Yi=Te(ta,(t,{date:s})=>s,(t,s)=>t.filter(n=>Co(n.startAt)===s).sort(Ei))((t,s)=>`dayView-selectShiftsForDay-${s.date}`);Te(Yi,t=>t.filter(s=>ji(s.startAt,s.endAt)).sort(Ei))((t,s)=>`dayView-selectOvernightShiftsForDay-${s.date}`);const Ea=Te(t=>ra(t),(t,s)=>Yi(t,s),(t,s)=>{const n=yC(s);if(n){const o=new Date(n).getHours();if(o<t)return o}return t})((t,s)=>`dayView-selectStartHour-${s.date}`),$r=Te(t=>ra(t),t=>Fh(t),(t,s)=>Yi(t,s),(t,s,n)=>{s<t&&(s=TC(s));const a=vC(n);if(a){const l=n[0]?.startAt,c=ji(l,a),u=new Date(a);let h=u.getHours();if(u.getMinutes()>0&&h++,c&&(h=wC(h)),h>s)return h}return s})((t,s)=>`dayView-selectEndHour-${s.date}`),Hk=Te(Ea,$r,(t,s)=>ds(t)||ds(s)?[]:jC(t,s))((t,s)=>`dayView-selectBusinessHours-${s.date}`),Zp=Te(wh,IC,Qp,Ca,na,oa,Ea,$r,(t,s,n,o,a,l,c,u)=>Ar([...s.map(h=>Ks({id:h.id,type:Th(h,t)?h.type:"multiLocationShift",startAt:h.startAt,endAt:h.endAt})),...(a?n:[]).map(h=>Ks({id:h.id,type:h.type,startAt:h.startAt,endAt:h.endAt,isFullDay:h.isWholeDay,openTime:c,closingTime:u})),...(l?o:[]).filter(h=>h.title==="Unavailable").map(h=>Ks({id:h.id,type:h.type,startAt:h.startAt,endAt:h.endAt,isFullDay:h.allDay,openTime:c,closingTime:u}))],c,u,!0))((t,s)=>`dayView-selectEmployeeSquares-${s.userId}-${s.date}`),e_=Te(Yp,Ea,Fh,(t,s,n)=>Ar(t.map(o=>Ks({id:o.id,type:"openShift",startAt:o.startAt,endAt:o.endAt})),s,n,!1))((t,s)=>`dayView-selectOpenShifts-${s.jobId}-${s.date}`),t_=Te(Gp,ra,$r,(t,s,n)=>Ar(t.map(o=>Ks({id:o.id,type:"event",isFullDay:!0,openTime:s,closingTime:n})),s,n,!1))((t,s)=>`dayView-selectEvents-${s.jobId}-${s.date}`),s_=Te(yi,ra,$r,(t,s,n)=>t?Ar([Ks({id:t,type:"timeOffBlackout",isFullDay:!0,openTime:s,closingTime:n})],s,n,!1):[])((t,s)=>`dayView-selectBlackouts-${s.jobId}-${s.date}`),n_=Te(Ca,oa,Ea,$r,(t,s,n,o)=>Ar([...(s?t:[]).filter(a=>a.title==="Preferred").map(a=>Ks({id:a.id,type:"preferred",startAt:a.startAt,endAt:a.endAt,isFullDay:a.allDay,openTime:n,closingTime:o}))],n,o,!0))((t,s)=>`dayView-selectPreferredTimeSquares-${s.jobId}-${s.date}`),Ji=(t,s)=>{if(!t)return;const n=DC("instanceId"),o=JSON.stringify(s);window.parent.postMessage(`cdk/${n} message navigation ${o}`,t)};function Fk(){return e.jsx(Ae,{content:p("schedule_builder.react_page.shift.consecutive_day_tooltip"),placement:"top",children:e.jsx(i,{hcenter:!0,mt:"2xs",children:e.jsx(Q,{iconName:"Warning",color:"error",size:"small"})})})}const Wk=r.memo(Fk),{cx:Vk}=O("EmployeeScheduleConfirmation"),r_={missing_contact_info:"error",not_viewed:"placeholder",viewed:"primary"};function o_({employeeScheduleConfirmation:t,onClick:s}){return!!t&&e.jsx("div",{className:Vk({[$c(t)]:$c(t)}),children:e.jsx(Ae,{placement:"top",content:p(`schedule_builder.schedule_confirmations.${t}`),children:e.jsx("span",{children:e.jsx(Q,{iconName:"Show",size:"small",color:r_[t],onClick:s})})})})}o_.propTypes={employeeScheduleConfirmation:d.oneOf(Object.keys(r_)),onClick:d.func};const Kk=r.memo(o_),Yd=24,qk=13,Xi=({ageInfo:t,canViewWages:s,childLaborComplianceSettingsEnabled:n,className:o,dragRef:a,dragAttributes:l,dragListeners:c,employeeScheduleConfirmation:u,enabledOvertimeHours:h,hasOvertime:m,hasOvertimeAllLocations:_,hours:f,hoursInAllLocations:g,isHoursForecastVisible:b,isLoadingLaborTotals:x,isManager:E,isWageForecastVisible:S,isScheduledAtOtherLocations:y,cloverPartnerId:C,cloverBaseUrl:v,noDnD:T,overtimeHours:D,shouldShowConsecutiveDayWarning:L,sortByWeek:A,userAvatar:P,userId:M,userName:R,wages:$})=>{const B=K(),[W,N]=r.useState(E),[H,q]=r.useState(!1),G=Sn(),re=r.useCallback(me=>{!G||!C||(me?.preventDefault(),Ji(v,{location:"employee_profile",cloverEmployeeId:C}))},[G,C,v]),ue=r.useCallback(()=>{B(w.MISSING_CONTACT_INFO_CLICKED,k.CLICK,{iconDescription:u}),G?re():u==="missing_contact_info"&&Wh.push(`/team/${M}/personal_information`)},[u,re,G,B,M]),je=r.useMemo(()=>A===Lt.POSITION,[A]),ce=r.useMemo(()=>{const me=R.split(" ");return`${me[0]?.[0]??""}${me[me.length-1]?.[0]??""}`.toUpperCase()},[R]),oe=r.useMemo(()=>{const me=P?.startsWith("https://cdn.joinhomebase.com/avatars/");return Sn()&&me?void 0:P},[P]),ge=h&&g>D,te=r.useCallback(()=>{B(w.EMPLOYEE_AVATAR_CLICKED,k.CLICK)},[B]),Z=r.useMemo(()=>`/team/${M}/personal_information`,[M]),ee=r.useCallback(()=>{q(!0)},[]),he=r.useCallback(()=>{q(!1)},[]);r.useEffect(()=>{W&&!x&&N(!1)},[W,x]);const{otherLocationsTextColor:Ye,forecastTextColor:De,userNameTextColor:Pe,tag:ke}=r.useMemo(()=>NC({isScheduledAtOtherLocations:y,isHoursForecastVisible:b,hasOvertimeAllLocations:_,hasOvertimeHours:ge,hasOvertime:m,isHovered:H,isManager:E}),[y,b,_,ge,m,H,E]);return e.jsxs(i,{style:{paddingBottom:0,marginLeft:je||T?0:24},className:o,spacebetween:!0,row:!0,vcenter:!0,children:[!T&&je&&e.jsx(i,{className:"drag-handle",dataTestId:`dragUser-${M}`,ref:a,...l,...c,vcenter:!0,w:Yd,h:Yd,children:e.jsx(Q,{size:"small",iconName:"Grip",color:"mono500"})}),e.jsxs(i,{row:!0,overflowX:"hidden",grow:1,children:[e.jsx(i,{vcenter:!0,mr:8,minw:24,children:e.jsx(ke,{target:G?void 0:"_blank",href:G?void 0:Z,onClick:G&&E?re:te,children:e.jsx(Un,{size:"medium",image:oe,initials:ce})})}),e.jsxs(i,{vcenter:!0,column:!0,overflowX:"hidden",maxw:144,children:[e.jsxs(i,{vcenter:!0,row:!0,children:[e.jsx(ke,{"data-testid":"personal-information-url",target:G?void 0:"_blank",href:G?void 0:Z,onMouseEnter:ee,onMouseLeave:he,className:"employee-name-link",onClick:G&&E?re:void 0,children:e.jsx(j,{color:Pe,underline:E&&H,variant:"bodySmBold",noWrap:!0,children:R})}),n&&t?.minor&&t?.age>qk&&e.jsx(i,{ml:8,children:e.jsx(wr,{variant:"mono",children:t.age})})]}),E&&(b||S)&&e.jsx("div",{children:x&&W?e.jsx(i,{w:92,children:e.jsx(Ii,{variant:"indeterminate",height:"small"})}):e.jsxs(j,{variant:"captions",color:"mono700",children:[b&&e.jsxs(j,{inline:!0,variant:"captions",color:De,"data-testid":"laborHours",children:[f.toFixed(2)," hrs"]}),b&&S&&s&&" / ",S&&s&&e.jsx("span",{children:pt($)}),y&&e.jsx(j,{variant:"captions",color:Ye,children:p("schedule_builder.react_page.multilocation.hours_all_locations",{props:{hours:g}})})]})})]})]}),e.jsxs(i,{mr:6,children:[e.jsx(Kk,{employeeScheduleConfirmation:u,onClick:ue}
1),L&&e.jsx(Wk,{})]})]})};Xi.propTypes={ageInfo:d.shape({age:d.number,minor:d.bool}),canViewWages:d.bool,cloverPartnerId:d.string,className:d.string,dragRef:d.func,dragAttributes:d.object,dragListeners:d.object,employeeScheduleConfirmation:d.string,enabledOvertimeHours:d.bool,endDate:d.string.isRequired,hasOvertime:d.bool,hasOvertimeAllLocations:d.bool,hours:d.number,hoursInAllLocations:d.number,isHoursForecastVisible:d.bool,isLoadingLaborTotals:d.bool,isManager:d.bool,isWageForecastVisible:d.bool,jobId:d.string.isRequired,cloverBaseUrl:d.string,noDnD:d.bool,overtimeHours:d.number,shouldShowConsecutiveDayWarning:d.bool,sortByWeek:d.string,startDate:d.string.isRequired,userAvatar:d.string.isRequired,userId:d.string.isRequired,userName:d.string.isRequired,wages:d.number};Xi.defaultProps={hours:0,wages:0,hoursInAllLocations:0,isLoadingLaborTotals:!1};const a_=F((t,s)=>{const n=s.jobId,o=wt({relationship:"user",state:t,id:n}),a=kC(t,s),l=a.length>1||a.length===1&&a[0]!==n;return{userId:o,cloverPartnerId:uo({state:t,attribute:"partnerId",id:n}),cloverBaseUrl:vi(t),userAvatar:Cr({state:t,attribute:"avatar",userId:o}),employeeScheduleConfirmation:uo({state:t,attribute:"scheduleConfirmation",id:n}),childLaborComplianceSettingsEnabled:_s(t),isScheduledAtOtherLocations:l,ageInfo:OC(t,s.jobId),userName:Or(t,s.jobId),hasOvertime:AC(t,s),hasOvertimeAllLocations:LC(t,{userId:o,jobId:n}),isLoadingLaborTotals:aa(t),shouldShowConsecutiveDayWarning:RC(t,s),isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"}),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),canViewWages:Ls(t),isManager:He(t),sortByWeek:Es({state:t,attribute:"sortByWeek",sliceName:"schedule"})}},{})(r.memo(Xi));function Yn({owner:t,date:s,roleName:n}){const o=Jo(),l=`cell-${t?`${t.type}-${t.id}`:"no-owner"}-${s}${n?`-${n}`:""}`,c=o===Xs.EMPLOYEE_ROW,{setNodeRef:u,isOver:h}=kr({id:l,disabled:c,data:{type:"CELL",owner:t,date:s,roleName:n}});return{isOver:h&&o===Xs.SHIFT,setNodeRef:u}}const zk=({isEditMode:t,isApproved:s,hasNote:n,viewType:o,rangeType:a,isOpenShift:l})=>{const c=o===de.employee&&a===J.week&&!l,u=[];return t?(u.push($C),u.push({...BC,...!n&&{disabled:!0}}),u.push({...UC,...!s&&{disabled:!0}})):(u.push(HC),c&&u.push(FC)),MC.List(u)},Gk=({numNotesLeftInQuota:t,numShifts:s,prevNote:n,newNote:o})=>{const a=!n&&!!o;return!t||!a?!1:t&&a&&s>=t},Yk=({roleOption:t,defaultRoleOption:s,color:n,jobId:o,startOfWeek:a,timeRange:l,currentShiftDate:c,note:u,isOpenShift:h})=>{const m=Vh(a);return{roleName:t?.value||s?.value,color:n||t?.color||s?.color,owner:h?Js:o,shiftTimes:l,days:[m.indexOf(dr(c))],note:u}},Jk=(t,s)=>{if(!t)return null;const n=t?.level,o=t?.day_of_week,a=t?.role_name||t?.role?.name;if(n===Aa.user)return s;if(n===Aa.role)return a;
1if(n===Aa.location)return PC[o]},Xk=(t,s)=>{const n=t.filter(m=>m.id===s)[0],o=n?.start_at,a=n?.end_at,l=n?.role?.name||n?.role_name,c=n?.color||n?.role?.color,u=Ie(o).format(es("time_long")),h=Ie(a).format(es("time_long"));return{start:u,end:h,id:n.id,startAt:o,endAt:a,color:c,roleName:l}},l_=Cn().shape({roleName:Kt().nullable(),owner:Kt().required("Required"),shiftTimes:Cn().shape({to:Kt().required(),from:Kt().required()}).required("Required"),color:Kt().required("Required"),days:WC().required("Required"),shiftNotes:Kt()}),Qk=24,Zk=59,{cx:eR,cxEl:Jd}=O("TimeOffFormTotalHours"),tR=({onChange:t,onCancel:s,dayDurations:n})=>{const o=K(),[a,l]=r.useState([]);r.useEffect(()=>{l(VC(n))},[n]);const c=Fm(a),u=r.useCallback(f=>g=>{const b=[...a],x=Math.min(Qk,g);b[f].hours=x,l(b)},[a]),h=r.useCallback(f=>g=>{const b=[...a],x=Math.min(Zk,g);b[f].minutes=x,l(b)},[a]),m=r.useCallback(()=>{o(w.BUTTON_CLICKED,k.CLICK,{buttonText:"save",buttonInfo:"total hours"}),t(a)},[o,a,t]),_=r.useCallback(()=>{o(w.BUTTON_CLICKED,k.CLICK,{buttonText:"cancel",buttonInfo:"total hours"}),s()},[o,s]);return e.jsx(i,{w:494,className:eR(),children:e.jsxs(Qs,{"data-testid":"totalsScreen",children:[e.jsxs(i,{pb:16,h:378,scrollY:!0,children:[e.jsx(j,{component:"h3",variant:"heading3",children:p("schedule_builder.react_page.time_off.add.total_hours")}),a?.map((f,g)=>e.jsxs(i,{row:!0,spacebetween:!0,pb:16,vcenter:!0,className:Jd("dayDurationRow"),children:[e.jsx("div",{children:e.jsx(Jt,{children:Oe(f.date,"pretty")})}),e.jsxs(i,{row:!0,gap:8,children:[e.jsx(td,{value:f.hours,onChange:u(g),numberSuffix:"hr"}),e.jsx(td,{value:f.minutes,onChange:h(g),numberSuffix:"min"})]})]},g))]}),e.jsxs(i,{column:!0,pt:12,className:Jd("footer"),children:[e.jsxs(i,{spacebetween:!0,pb:16,vcenter:!0,children:[e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.total_hours"}),e.jsx(i,{w:80,children:e.jsx(An,{inline:!0,readOnly:!0,value:c,name:"totalHours"})})]}),e.jsxs(i,{row:!0,hright:!0,children:[e.jsx(i,{pr:16,children:e.jsx(V,{variant:"secondary",onClick:_,children:p("schedule_builder.react_page.time_off.add.cancel_cta")})}),e.jsx(V,{variant:"primary",onClick:m,children:p("actions.continue")})]})]})]})})},sR=r.memo(tR),Yr={MAIN_VIEW:"MAIN_VIEW",TOTAL_HOURS_EDIT_VIEW:"TOTAL_HOURS_EDIT_VIEW"},nR=["pto","pto_no_policy","paid_sick_leave","paid_sick_leave_no_policy"],{cx:rR,cxEl:jt}=O("TimeOffForm"),oR=({isValid:t,isSubmitting:s,categories:n,reasons:o,values:a,errors:l,touched:c,setFieldValue:u,renderEmployeeDropdown:h,renderLocationDropdown:m,disableEmployeeDropdown:_,disableLocationDropdown:f,employeeOptions:g,locationOptions:b,onEmployeeChange:x,futureOnly:E,isEditing:S,startOfWeekValue:y})=>{const C=K(),{wholeDay:v,dayDurations:T,startAt:D,endAt:L,category:A}=a,[P,M]=r.useState(Yr.MAIN_VIEW),[R,$]=r.useState(!0),B=Fm(T),W=r.useCallback(()=>{C(w.BUTTON_CLICKED,k.CLICK,{buttonText:"edit",buttonInfo:"total hours"}),M(Yr.TOTAL_HOURS_EDIT_VIEW)},[C]),N=r.useCallback(()=>{M(Yr.MAIN_VIEW)},[]),H=(()=>
1{if(E)return Ub();const Z=new Date;return Z.setMonth(Z.getMonth()-2),Z})(),q=r.useCallback(()=>{if(!v){u("dayDurations",[]),u("endAt","");return}u("timeRange",{to:"",from:""}),L||u("endAt",D);const Z=Sv(D,L),ee=jv(Z,T);u("dayDurations",ee)},[D,L,T,v,u]),G=r.useCallback(Z=>{u("dayDurations",Z),N()},[u,N]),re=r.useCallback(Z=>{const ee=Z.target.value;nR.includes(ee)?(u("reason",null),$(!1)):($(!0),u("reason",Cl[0].value)),u("category",ee)},[u]),ue=r.useCallback(Z=>{const ee=Z.target.value;u("employee",ee),x?.(ee)},[x,u]),je=r.useCallback(Z=>{u("reason",Z.target.value)},[u]),ce=r.useCallback(Z=>{const ee=Z.target.value;u("location",ee),u("category",n?.[0]?.value),x?.(ee)},[x,n,u]),oe=r.useCallback(Z=>{u("startAt",Z.target.value),new Date(Z.target.value)>new Date(L)&&u("endAt",Z.target.value)},[L,u]),ge=r.useCallback(Z=>{u("endAt",Z.target.value)},[u]),te=r.useCallback(({target:{checked:Z}})=>{C(w.TOGGLE_CLICKED,k.CLICK,{selection:Z,toggleText:"whole day"}),u("wholeDay",Z)},[C,u]);return r.useEffect(()=>{q()},[D,L,v]),P===Yr.TOTAL_HOURS_EDIT_VIEW?e.jsx(sR,{dayDurations:T,onChange:G,onCancel:N}):e.jsx(i,{w:"100%",className:rR(),children:e.jsxs(Qs,{"data-testid":"formScreen",children:[h&&e.jsxs(i,{mb:12,className:jt("employeeSelect",{"is-disabled":_}),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"time_off.select_employee"})}),e.jsx(Qt,{className:jt("select-control"),disabled:_,clearable:!1,value:a.employee,name:"employee",options:g,onChange:ue})]}),m&&e.jsxs(i,{mb:12,className:jt("locationSelect",{"is-disabled":f}),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"time_off.select_location"})}),e.jsx(Qt,{className:jt("select-control"),clearable:!1,value:a.location,name:"location",options:b,onChange:ce,disabled:f})]}),e.jsxs(i,{mb:12,className:jt("category",{"is-disabled":!!A}),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.category"})}),e.jsx(Qt,{className:jt("select-control"),clearable:!1,value:a.category,name:"category",options:n,onChange:re})]}),R&&e.jsxs(i,{mb:16,className:jt("reason"),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.reason"})}),e.jsx(Qt,{className:jt("select-control"),clearable:!1,value:a.reason,name:"reason",options:o,onChange:je})]}),e.jsxs(i,{mb:16,className:jt("note"),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.note"})}),e.jsx(ma,{component:"TextInput",type:"textarea",placeholder:p("schedule_builder.react_page.time_off.add.notes_placeholder"),theme:"lg",name:"notes"})]}),e.jsxs(i,{mb:16,row:!0,children:[e.jsxs(i,{mr:16,className:jt("startDate"),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.start_date"})}),e.jsx(Tn,{name:"startAt",hideClearIcon:!0,value:Qr(D),onChange:oe,blockDatesBefore:H?Qr(H):null,overrideZIndex:Number(ho.zindexFdbReactModal)+1,startOfWorkWeek:y})]}),v?e.jsxs(e.Fragment,{children:[e.jsxs(i,{mr:16,className:jt("endDate"),children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.end_date"})}),e.jsx(Tn,{name:"endAt",hideClearIcon:!0,value:Qr(L||D),blockDatesBefore:D,onChange:ge,overrideZIndex:Number(ho.zindexFdbReactModal)+1,startOfWorkWeek:y})]}),e.jsxs("div",{children:[e.jsx(i,{mb:8,children:e.jsx(Jt,{i18n:"schedule_builder.react_page.time_off.add.total_hours"})}),e.jsxs(i,{row:!0,children:[e.jsx(i,{w:90,pr:8,className:jt("totalHours"),children:e.jsx(Ct,{as:An,value:B,name:"totalHours",disabled:!0})}),e.jsx(V,{variant:"tertiaryPlain",onClick:W,children:p("actions.edit")})]})]})]}):e.jsx("div",{children:e.jsx(Ct,{as:ha,name:"timeRange",interval:15,i18nFromLabel:"schedule_builder.react_page.time_off.add.start_time",i18nToLabel:"schedule_builder.react_page.time_off.add.end_time",fromError:c.timeRange?.from&&l.timeRange?.from,toError:c.timeRange?.to&&l.timeRange?.to})})]}),e.jsx(i,{mb:16,className:jt("wholeDay"),children:e.jsx(Av,{name:"wholeDay",checked:v,onChange:te,label:p("schedule_builder.react_page.time_off.add.whole_day")})}),e.jsx(i,{row:!0,hright:!0,pt:12,className:jt("footer"),children:e.jsx(V,{type:"submit",variant:"primary",isLoading:s,disabled:!t,children:p(S?"actions.save":"schedule_builder.react_page.time_off.add.add_cta")})})]})})},aR=F(t=>({startOfWeekValue:rs(t)}))(oR),lR=r.memo(aR),iR=Cn().shape({category:Kt().required(),reason:Kt().nullable(),notes:Kt(),wholeDay:KC(),startAt:ir().required(),endAt:ir().when("wholeDay",{is:!0,then:ir().required().min(Bc("startAt"),"schedule_builder.validations.end_date_before")}),timeRange:Cn().when("wholeDay",{is:!1,then:Cn({from:Kt().required(),to:Kt().required().test(Bc("to"),"schedule_builder.validations.end_time_before",function(t){return!t||!this.parent.from?!1:bc(t)>bc(this.parent.from)})})})}
1),cR=({onSubmit:t,startAt:s,endAt:n,categories:o})=>{const a=K(),l=r.useMemo(()=>({category:Hm[0].value,reason:Cl[0].value,notes:"",wholeDay:!0,startAt:s,endAt:n,timeRange:{from:"",to:""},dayDurations:[]}),[s,n]),c=r.useCallback(async(u,{setSubmitting:h})=>{a(w.BUTTON_CLICKED,k.CLICK,{buttonText:"add"}),await t(u),h(!1)},[a,t]);return e.jsx(Ht,{onSubmit:c,initialValues:l,validationSchema:iR,children:u=>e.jsx(lR,{...u,categories:o,reasons:Cl})})},dR=r.memo(ut({tab:"time off"})(cR)),Qi=140,Ga="schedule_builder.shift_reassignment_selector",uR=({error:t=!1,onClick:s})=>{const n=t?"error":"no_recommendations";return r.useEffect(()=>{Rt({eventCategory:U.SHIFT_REASSIGNMENT,eventAction:w.ELEMENT_SHOWN,actionType:k.VIEW,productArea:"schedule",properties:{elementType:"carousel",outcome:n}})},[]),e.jsxs(i,{gap:8,bradiuss:!0,grow:1,vcenter:!0,bgcolor:"mono0",p:12,column:!0,h:Qi,children:[e.jsxs(i,{hcenter:!0,column:!0,children:[e.jsx(j,{color:"mono900",variant:"bodyBoldTight",children:p(`${Ga}.${n}.title`)}),e.jsx(j,{color:"mono700",variant:"bodySmTight",children:p(`${Ga}.${n}.subtitle`)})]}),e.jsx(i,{hcenter:!0,children:e.jsx(V,{variant:"primary",size:"small",onClick:s,children:p(`${Ga}.${n}.button_copy`)})})]})},i_=r.memo(uR),hR=({scrollDistance:t=240,onScrollPositionChange:s}={})=>{const n=r.useRef(null),o=r.useCallback(()=>{if(n.current&&s){const{scrollLeft:c,scrollWidth:u,clientWidth:h}=n.current,m=c<=0,_=Math.ceil(c+h)>=u;s(m,_)}},[s]),a=r.useCallback(()=>{n.current&&n.current.scrollBy({left:-t,behavior:"smooth"})},[t]),l=r.useCallback(()=>{n.current&&n.current.scrollBy({left:t,behavior:"smooth"})},[t]);return r.useEffect(()=>{const c=n.current;if(c)return c.addEventListener("scroll",o),o(),()=>{c.removeEventListener("scroll",o)}},[o]),{scrollContainerRef:n,scrollLeft:a,scrollRight:l,checkScrollPosition:o}},{cxEl:mR}=O("ReassignmentSelector"),pR=({handleSelection:t,selectedEE:s,setIsAtStart:n,setIsAtEnd:o,scrollLeftRef:a,scrollRightRef:l})=>{const c=I(Kh),u=r.useCallback((b,x)=>{n(b),o(x)},[n,o]),{scrollContainerRef:h,scrollLeft:m,scrollRight:_,checkScrollPosition:f}=hR({scrollDistance:240,onScrollPositionChange:u});r.useEffect(()=>{a&&(a.current=m)},[a,m]),r.useEffect(()=>{l&&(l.current=_)},[l,_]),r.useEffect(()=>{f()},[c,f]);const g=r.useCallback(()=>{window.open("/team","_blank")},[]);return c.length>0?e.jsx(i,{maxw:400,className:mR("scroll_container"),"data-testid":"ee-recommendation-scroll-container",pv:12,ph:6,row:!0,gap:12,h:Qi,ref:h,children:c.map((b,x)=>b.job_id&&e.jsx(Ov,{handleSelection:t,selectedEE:s,reasons:b.reasons,jobId:b.job_id,rank:x+1,available:c.length},b.job_id))}):e.jsx(i,{pt:12,grow:1,children:e.jsx(i_,{onClick:g})})},{cx:_R}=O("ReassignmentSelector"),Xd="schedule_builder.shift_reassignment_selector",fR=({employeeName:t,isMobile:s,isOpenShift:n,handleSelection:o,selectedEE:a,shiftId:l})=>{const c=qC(),u=K();c({eventCategory:U.SHIFT_REASSIGNMENT});const h=I(hs),m=X(),[_,f]=r.useState(!0),[g,b]=r.useState(!0),x=I(Kh)||[],E=I(zC);r.useEffect(()=>{l&&(m(Uc()),m(Hc(l)))},[l]),r.useEffect(()=>{E==="succeeded"&&x.length>0&&u({eventAction:w.ELEMENT_SHOWN,actionType:k.VIEW,productArea:"schedule",properties:{elementType:"carousel",outcome:E,available:x.length}})},[E]);const S=r.useRef(null),y=r.useRef(null),C=r.useCallback(()=>{m(Uc()),m(Hc(l))},[l]),v=r.useCallback(()=>{S.current?.()},[]),T=r.useCallback(()=>{y.current?.()},[]),D=r.useMemo(()=>Um(h),[h]),L=r.useMemo(()=>D&&Iu(),[D]),{handleOnClick:A}=So({planName:"plus",focusedFeature:"shift_reassignment"});return e.jsxs(i,{mb:12,w:s?"98%":"100%",children:[e.jsx(i,{p:12,bradiuss:!0,bgcolor:"mono100",children:e.jsxs(i,{className:_R(),column:!0,children:[e.jsxs(i,{row:!0,spacebetween:!0,children:[e.jsxs(i,{vcenter:!0,children:[e.jsx(Q,{color:"primary500",iconName:"Sparkle",size:"small"}),"Â ",e.jsx(j,{color:"mono900",variant:"bodySmBoldTight",children:p(n?`${Xd}.title_open_shift`:`${Xd}.title`,{props:{employee_name:t}})}),E==="succeeded"&&e.jsxs(j,{color:"mono900",variant:"bodySmBoldTight",children:["Â (",x.length,")"]})]}),e.jsxs(i,{vcenter:!0,children:[e.jsx(be,{dataTestId:"eeLeftScrollButton",disabled:_,icon:"ChevronLeft",size:"small",onClick:v,label:p("schedule_builder.actions.scroll_left")}),e.jsx(be,{dataTestId:"eeRightScrollButton",disabled:g,icon:"ChevronRight",size:"small",onClick:T,label:p("schedule_builder.actions.scroll_right")})]})]}),e.jsxs(i,{children:[E==="pending"&&e.jsx(i,{h:Qi,hcenter:!0,vcenter:!0,p:12,children:e.jsx($n,{size:"medium",variant:"dark"})}),E==="succeeded"&&e.jsx(pR,{handleSelection:o,selectedEE:a,setIsAtStart:f,setIsAtEnd:b,scrollLeftRef:S,scrollRightRef:y}),E==="failed"&&e.jsx(i,{pt:12,grow:1,children:e.jsx(i_,{error:!0,onClick:C})})]})]})}),L&&e.jsx(tp,{onClick:A,isEssentialsLocation:!0}
1)]})},bR="https://cdn.joinhomebase.com/assets/reassignment-selector-paywall-bundle-DRrDAIBG.png",{cx:gR}=O("ReassignmentSelectorPaywall"),Ya="schedule_builder.shift_reassignment_selector.paywall",xR=({onClose:t})=>e.jsxs(i,{"data-testid":"reassignment-paywall",maxw:452,className:gR(),bcolor:"mono300",bw:1,bradiusm:!0,mb:12,row:!0,children:[e.jsx(i,{w:"50%",children:e.jsx(qm,{alt:"paywall-image-angel-salvadore",src:bR,style:{borderRadius:"8px 0 0 8px"}})}),e.jsxs(i,{w:"50%",children:[e.jsx(i,{justifyContentEnd:!0,children:e.jsx(be,{icon:"Close",size:"small",onClick:t,label:p("schedule_builder.actions.close")})}),e.jsxs(i,{pl:12,pr:12,children:[e.jsx(j,{color:"mono900",variant:"heading4",children:p(`${Ya}.title`)}),e.jsx(j,{color:"mono700",variant:"bodySmTight",children:p(`${Ya}.subtitle`)}),e.jsx(la,{to:"/manage_plans?view=focus&plan=plus&origin=paywall&feature_key=shift_reassignment",children:e.jsxs(i,{row:!0,vcenter:!0,children:[e.jsx(j,{color:"primary500",variant:"bodySmBold",children:p(`${Ya}.link`)}),e.jsx(Q,{iconName:"ArrowRight",size:"small",color:"primary500"})]})})]})]})]}),CR=t=>`__header_${t}`;function ER(t,s){const n=String(s??"").trim().length>0;if(t.isSectionHeader)return!n;if(!n)return!0;const o=String(s).trim().toLowerCase(),a=String(t.label??""),l=String(t.value??"");return a.toLowerCase().includes(o)||l.toLowerCase().includes(o)}function SR(t,s,n=""){const o=[];for(const[a,l]of t){const{options:c,label:u,defaultWage:h}=l;a!==vn&&u&&o.push({value:CR(a),label:u,isSectionHeader:!0,sectionType:a,employeeName:a===Ss?n:void 0,defaultWage:a===Ss?h:void 0,disabled:!0});for(const m of c){const{color:_,label:f,value:g,wage:b,id:x}=m,E=g??"";o.push({value:E,label:f,isSectionHeader:!1,optionValue:g,color:_,wage:b,id:x,isInbuilt:a===vn,isEmployee:a===Uo,isTeam:a===Ss,isColorMappingV1:s,disabled:!1})}}return o}const jR=Te(GC,YC,(t,s)=>ia(t,s.jobId),(t,s)=>uo({state:t,id:String(s.jobId),attribute:"wageRate"}),Uu,(t,s,n,o,a)=>{const l=[[vn,{options:JC(a)}]],c=[Ss,{options:t,label:Hu,defaultWage:o}],u=[Uo,{options:s,label:XC(n)}];return s.length===1&&s[0].value===null||l.push(u),l.push(c),l})((t,s)=>`selectRolePickerOptions-${s.jobId}`),yR=t=>e.jsx(Y,{asHTML:!0,i18n:"roles_select.add_new",i18nProps:{name:t}});function vR({name:t,value:s,onChange:n},o){const a=r.useRef(null),l=r.useCallback(c=>{a.current=c,typeof o=="function"?o(c):o&&(o.current=c)},[o]);return r.useEffect(()=>{const c=requestAnimationFrame(()=>{a.current?.focus?.()});return()=>cancelAnimationFrame(c)},[]),e.jsx(Zr,{w:"100%",h:40,children:e.jsx(ma,{component:"SelectInput",name:t,onChange:n,creatable:!0,newOptionText:yR,options:[],multi:!1,clearable:!0,hideClear:!s,placeholder:br,searchable:!0,inputProps:{maxLength:255},getRef:l,dataTestId:"new-role-field"})})}const Zi=r.forwardRef(vR);Zi.displayName="NewRoleField";Zi.propTypes={name:d.string.isRequired,value:d.string,onChange:d.func.isRequired};const{cxEl:vl}=O("RolePicker"),IR=({item:t})=>{const{label:s,defaultWage:n,employeeName:o,sectionType:a}=t,l=a===Ss&&o,c=r.useMemo(()=>({column:!0,mb:l?10:"initial"}),[l]);return e.jsxs(i,{...c,children:[e.jsx(i,{bgcolor:"primary050",ph:15,pb:1,children:e.jsx(j,{className:vl("label"),variant:"captions",color:"secondary",children:s!=null?String(s).toUpperCase():""})}),l?e.jsx(i,{mh:15,mt:6,children:e.jsx(j,{variant:"bodySm",color:"secondary",children:Bu({name:o,wage:n})})}):null]})},Qd=({item:t,formRoleNameValue:s,isValue:n=!1})=>{const{isInbuilt:o,isEmployee:a,color:l,label:c,wage:u,isColorMappingV1:h}=t;if(t.isSectionHeader)return e.jsx(IR,{item:t});const m=a?n?e.jsx(j,{children:c}):e.jsx(Hi,{wage:u,label:c}):o?e.jsx(Fi,{label:c,optionValue:t.value,value:s}):e.jsx(ba,{color:l,label:c,isColorMappingV1:h,showColor:!n});return e.jsx(i,{className:vl("select-option-wrap"),row:!0,vcenter:!0,h:n?void 0:44,ph:n?0:15,minw:0,spacebetween:!n&&a,children:n?e.jsx(i,{className:vl("role-label"),minw:0,grow:1,row:!0,vcenter:!0,children:m}):m})},{cx:TR}=O("RolePicker");function wR(t,s){return t==null||t===""||s.some(o=>!o.isSectionHeader&&o.value===t)?t:{value:t,label:t}}const Sa=r.forwardRef(function({name:s,onChange:n,onColorChange:o,employeeName:a,roleOptions:l,disabled:c,isColorMappingV1:u,onDropdownClick:h},m){const[_]=$u(s),{setFieldValue:f}=Wo(),[g,b]=r.useState(!0),x=r.useRef(!1),S=Io()?l.map(([M,R])=>[M,{...R,options:R.options.filter($=>$.label!==br)}]):l,y=r.useMemo(()=>
1SR(S,u,a),[S,u,a]),C=_.value??"",v=r.useMemo(()=>wR(_.value,y),[_.value,y]),T=r.useCallback(M=>e.jsx(Qd,{item:M,formRoleNameValue:C}),[C]),D=r.useCallback(M=>{if(!M)return null;const $=!M.isSectionHeader&&M.isInbuilt==null&&M.isEmployee==null&&M.isTeam==null?{...M,isInbuilt:!1,isEmployee:!1,isTeam:!0,isColorMappingV1:u,color:""}:M;return e.jsx(Qd,{item:$,formRoleNameValue:C,isValue:!0})},[C,u]),L=r.useCallback(M=>{const R=M?.target?.value;if(R!=null&&String(R).startsWith("__header_"))return;if(R===br){f(s,""),x.current=!0,b(!1);return}const $=y.find(B=>!B.isSectionHeader&&B.value===R);$?.color&&o($.color)},[s,o,y,f]),A=r.useCallback((M,R)=>{_.onChange(R),L(R)},[_,L]),P=r.useCallback(M=>{M?.target?.color&&o(M.target.color),n(M);const R=M?.target?.value;if((R===""||R==null)&&x.current){x.current=!1;return}x.current=!1,b(!0)},[n,o]);return g?e.jsx("div",{className:TR(),children:e.jsx(Mh,{name:s,value:v,onChange:A,onBlur:_.onBlur,onOpen:h,options:y,optionRenderer:T,valueRenderer:D,filterOption:ER,placeholder:p("schedule_builder.shift_form.select_role"),hideClear:!_.value,disabled:c,dataTestId:"role-picker-selected"})}):e.jsx(Zi,{value:_.value,onChange:P,name:s,ref:m})});Sa.displayName="RolePicker";Sa.defaultProps={onChange:()=>{}};Sa.propTypes={isColorMappingV1:d.bool.isRequired,name:d.string.isRequired,employeeName:d.string.isRequired,roleOptions:d.array.isRequired,onChange:d.func.isRequired,onColorChange:d.func.isRequired,disabled:d.bool,onDropdownClick:d.func};const DR=F((t,s)=>({roleOptions:jR(t,{jobId:s.jobId,isAdding:!1}),employeeName:ia(t,s.jobId)}))(Sa),c_=(t,s,n,o)=>!t||!s||!n||o===Bs.seeking_cover||o===Bs.pending_approval?!1:!Hb(s),d_=({shiftId:t,onCancel:s,isSubmitting:n,isValid:o})=>{const a=t?[{variant:"secondary",onClick:s,label:p("schedule_builder.shift_form.cancel")},{variant:"primary",type:"submit",isLoading:n,disabled:!o,label:p("schedule_builder.shift_form.cta_save")}]:[{variant:"primary",type:"submit",isLoading:n,disabled:!o,label:p("schedule_builder.shift_form.cta_add")}];return e.jsx(fr,{buttons:a})};d_.propTypes={onCancel:d.func,shiftId:d.string,isSubmitting:d.bool.isRequired,isValid:d.bool.isRequired};const kR=({name:t,value:s,onChange:n,selectedShift:o,onStartTimeDropdownClick:a,onEndTimeDropdownClick:l,disabled:c})=>e.jsx(ha,{name:t,value:s,onChange:n,selectedShift:o,interval:15,onStartTimeDropdownClick:a,onEndTimeDropdownClick:l,disabled:c});ha.propTypes={value:d.shape({name:d.string,from:d.string,to:d.string}),onChange:d.func,interval:d.number,selectedShift:d.string,onStartTimeDropdownClick:d.func,onEndTimeDropdownClick:d.func,disabled:d.bool};
1const RR=r.memo(kR),u_=({feature:t,isOnTrial:s,trialEndDate:n,children:o})=>e.jsxs(i,{row:!0,vcenter:!0,children:[o(s),s&&e.jsx(Nv,{ml:8,size:"xs",feature:t,tooltip:p("schedule_builder.react_page.paid_feature_tooltip",{props:{date:ur(n).format("MMMM Do")}})})]});u_.propTypes={isOnTrial:d.bool,trialEndDate:d.string,feature:d.string,children:d.func};const h_=F(t=>({isOnTrial:ZC(t),trialEndDate:QC(t)}))(u_),m_=({canManageNotes:t,changeToPlusTier:s,isNoteAllowed:n,numQuotaAllowed:o,numQuotaUsed:a,tierPlus:l,onFieldFocus:c,disabled:u})=>{const h=K(),m=r.useCallback(()=>{h(w.LINK_CLICKED,k.CLICK,{linkText:"upgrade now"}),s({billingFrequency:Ql.monthly,workflowSource:"paywall_modal"})},[h,s]),_=r.useCallback(()=>{h(w.FIELD_FOCUSED,k.FOCUS,{label:Cs.NOTES}),c&&c()},[h,c]);return t?e.jsxs(e.Fragment,{children:[e.jsx(i,{mb:8,mt:20,children:e.jsx(h_,{feature:"events",children:f=>e.jsx(j,{variant:"bodyBold",color:f?"primary500":"mono700",children:p("schedule_builder.shift_form.shift_notes")})})}),n?e.jsx(Ct,{as:yo,name:"note",textArea:!0,textAreaHeight:72,dataTestId:"shift-notes-input",placeholder:p("schedule_builder.shift_form.shift_notes_placeholder"),onFocus:_,disabled:u}):e.jsxs(dt,{variant:"info",title:p("schedule_builder.shift_form.notes.paywall_title"),children:[e.jsx(j,{variant:"bodySm",children:p("schedule_builder.shift_form.notes.paywall_desc",{props:{tier:Ir(l.get("name"))}})}),e.jsx(i,{tright:!0,children:e.jsx(Nt,{size:"small",onClick:m,children:p("schedule_builder.shift_form.notes.cta")})})]}),o&&a<o&&e.jsxs(i,{row:!0,mt:8,vcenter:!0,noWrap:!0,children:[e.jsx(i,{mr:3,children:e.jsx(j,{variant:"bodySm",children:p("schedule_builder.shift_form.notes.limit_warning",{props:{used:a,allowed:o}})})}),e.jsx(Mi,{size:"small",children:p("schedule_builder.shift_form.notes.limit_warning_cta")})]})]}):null};m_.propTypes={canManageNotes:d.bool.isRequired,changeToPlusTier:d.func.isRequired,currentShiftDate:d.string.isRequired,isNoteAllowed:d.bool.isRequired,numQuotaAllowed:d.number,numQuotaUsed:d.number,tierPlus:eE.map,onFieldFocus:d.func,disabled:d.bool};const LR=F((t,s)=>{const n=Vo(s.currentShiftDate);return{canManageNotes:Fu(t),isNoteAllowed:Ko(t,{shiftNoteQuotaId:n}),numQuotaUsed:io({state:t,attribute:"used",id:n}),numQuotaAllowed:io({state:t,attribute:"allowed",id:n}),tierPlus:Wu(t)}},{changeToPlusTier:Vu})(r.memo(m_)),{cx:AR}=O("EmployeeSelectInput"),OR={label:p("schedule_builder.react_page.open_shifts.label"),value:Js},p_=({employeeOptions:t,name:s,onChange:n,value:o,onOpen:a,disabled:l})=>e.jsx(ma,{className:AR(),component:"SelectInput",name:s,onChange:n,onOpen:a,value:o,hideClear:!o,options:[...t,OR],placeholder:p("schedule_builder.shift_form.select_employee"),disabled:l});p_.propTypes={employeeOptions:d.array,name:d.string,onChange:d.func,onOpen:d.func,value:d.string,disabled:d.bool};const NR=F((t,s)=>({employeeOptions:s.isRoleOrDepartment?tE(t,{roleId:s.roleId}):sE(t,s)}),{})(r.memo(p_)),{cx:MR}=O("CommonShiftSelector"),PR=2,$R=158,__=({deselectShiftRecommendation:t,onClick:s,selectedShift:n,setCommonShift:o,employeeFirstName:a,commonShifts:l})=>{const c=K(),u=r.useCallback(m=>{c(w.COMMON_SHIFT_CLICKED,k.CLICK,{common_shift_version:zh.INLINE});const _=Xk(l,m.value);o(m.value),n===m.value&&t(),s(_)},[l,t,s,n,o,c]),h=r.useMemo(()=>l.map(m=>({id:m.id,title:`${Ut(m.start_at,m.end_at)}`,subtitle:m.role?.name?m.role.name:p("schedule_builder.react_page.shifts.no_role"),nameForAlert:Jk(m,a)})),[l,a]);return e.jsx(i,{"data-testid":l.length===0&&"no-common-shifts",className:M
1R(),mb:l.length>0&&12,p:4,gap:16,row:!0,children:h.length>0&&h.slice(0,PR).map(m=>e.jsx(Al,{"data-testid":`common-shift-${m.id}`,grow:1,radioCanDeselect:!0,onClick:u,minw:$R,marginRight:0,value:m.id,selected:n===m.id,title:m.title,subtitle:m.subtitle,alertVariant:"info",alertText:m.nameForAlert?p("schedule_builder.react_page.shift_form.common_shift_detail",{props:{resource:m.nameForAlert}}):p("schedule_builder.react_page.shift_form.common_shift_default")},m.id))})};__.propTypes={commonShifts:d.array,deselectShiftRecommendation:d.func,employeeFirstName:d.string,jobId:d.string,onClick:d.func,selectedShift:d.string,setCommonShift:d.func};const BR=F((t,s)=>({commonShifts:qh(t),employeeFirstName:s.jobId?nE(t,s.jobId):null}),{})(r.memo(__)),UR=({violations:t})=>{if(t.length===0)return null;const s=t.map(n=>({primary:n}));return e.jsx(i,{mb:12,children:e.jsx(dt,{variant:"warning",children:t.length===1?e.jsx(i,{children:e.jsx(j,{variant:"body",children:t[0]})}):e.jsxs(e.Fragment,{children:[e.jsx(i,{mb:12,children:e.jsx(j,{variant:"bodyBold",children:p("schedule_builder.child_labor_compliance.schedule_violations.multiple")})}),e.jsx(Ol,{data:s,gapOverride:"4px",size:"medium"})]})})})},tr=t=>Yh(w.DROPDOWN_CLICKED,k.CLICK,{label:t,eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL}),f_=({currentShiftDate:t,employeeName:s,handleCancel:n,handleEmployeeSelection:o,isColorMappingV1:a,isMobile:l,isOpenShift:c,isRoleOrDepartment:u,isSubmitting:h,isValid:m,roleId:_,selectedShift:f,setCommonShift:g,setFieldValue:b,shiftId:x,showCommonShifts:E,isShiftReassignmentViewable:S,startOfWeek:y,values:C,setReassignmentCardSelected:v,handleEnableCoverForm:T,disabled:D,userId:L})=>{const A=K(),P=Sn(),[M,R]=r.useState(!S),[$,B]=r.useState([]),W=I(rE),N=I(Gh),H=I(_s),{rangeType:q}=ze(),G=I(ne=>Se({state:ne,id:x,attribute:"startAt"})),re=I(ne=>Se({state:ne,id:x,attribute:"endAt"})),ue=I(ne=>Se({state:ne,id:x,attribute:"isPublished"})),je=I(ne=>Se({state:ne,id:x,attribute:"coverRequestIndicator"})),ce=I(hs),oe=I(ne=>C.owner?wt({state:ne,id:C.owner,relationship:"user"}):null),ge=oe||L,te=I(ne=>oE(ne,{userId:ge}))??null,Z=r.useMemo(()=>t?bu(t,y).start:null,[t,y]),ee=I(ne=>C.owner&&Z?aE(ne,{jobId:C.owner,weekStart:Z}):null),he=!x,Ye=C?.shiftTimes?.from,De=C?.shiftTimes?.to,Pe=I(ne=>he&&C.owner&&t?lE(ne,String(C.owner),t):0),ke=I(ne=>C.owner&&t?iE(ne,{jobId:C.owner,currentDate:t}):[]),me=r.useMemo(()=>{if(!ee||!Ye||!De)return ee;try{return cE({weeklyData:ee,formFrom:Ye,formTo:De,oldStartTime:Fc(G),oldEndTime:Fc(re),isNewShift:he,countExistingShiftsOnDate:Pe,selectedDays:C.days,workedDayIndices:ke})}catch{return ee}},[ee,Ye,De,G,re,he,Pe,C.days,ke]),Fe=tr(Cs.ASSIGNEE),We=tr(Cs.ROLE),Xe=tr(Cs.COLOR),se=tr(Cs.START_TIME),Ne=tr(Cs.END_TIME),ye=Yh(w.BUTTON_CLICKED,k.CLICK,{label:Cs.APPLY_TO,eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL}),{handleWeekDayChange:Ve}=Wo(),$e=r.useCallback((ne,_e)=>{const xe=dE(_e,t);if(!xe){B([]);return}const Ce=uE(ne,xe,me,t,C.days?.length);B(Ce.map(ht=>ht.message))},[t,me,C.days]),Ee=r.useCallback(ne=>_e=>{ne(_e),Ve&&Ve(_e),$e(C.shiftTimes,te),ye(_e)},[Ve,$e,C.shiftTimes,te,ye]),Re=r.useCallback(()=>{g&&g(In)},[g]),Me=r.useCallback(()=>{R(!1)},[]),we=r.useCallback(ne=>{b("color",ne),Re()},[Re,b]),Ke=r.useMemo(()=>{const ne=!!x,_e=!!_,xe=q===J.month||q===J.custom;return ne||_e||xe},[x,_,q]),Qe=!!_&&!x,Ze=!!x,et=r.useCallback(ne=>{b(ne.target.name,{from:ne.target.value.from,to:ne.target.value.to}),$e(ne.target.value,te),Re()},[$e,te,Re,b]),tt=r.useCallback(ne=>{b("shiftTimes",{from:sd(ne.start),to:sd(ne.end)}),b("roleName",ne.roleName),b("color",ne.color)},[b]),st=r.useCallback(({jobId:ne,selected:_e})=>{b("owner",_e?ne:null),v(_e)},[b,v]),nt=r.useCallback(()=>{A(w.BUTTON_CLICKED,k.CLICK,{buttonText:"Find a cover",element:"find_cover_initiate",buttonAction:"initiate_cover_request",buttonLocation:"edit_shift_modal",eventCategory:U.INITIATE_FIND_COVER_REQUEST}),T(!0)},[T,A]),Be=c_(x,G,ue,je),ve=r.useMemo(()=>l?"98%":Be&&N?"55%":"100%",[l,N,Be]),xt=r.useMemo(()=>ce&&ce!==_n.BASIC,[ce]);return r.useEffect(()=>{H&&te&&C?.shiftTimes?.from&&C?.shiftTimes?.to&&oe&&$e(C.shiftTimes,te)},[H,te,$e,oe,C.shiftTimes]),e.jsxs(Qs,{children:[e.jsxs(i,{minh:"min(200px, 35vh)",maxh:"calc(min(736px, 90vh) - 150px)",overflowY:"auto",scrollY:!0,children:[e.jsx(UR,{violations:$}),Ze&&!D&&!P&&e.jsx(e.Fragment,{children:S?e.jsx(fR,{isMobile:l,isOpenShift:c,selectedEE:C.owner,handleSelection:st,employeeName:s,roleId:_,isRoleOrDepartment:u,shiftId:x}):e.jsx(e.Fragment,{children:M&&e.jsx(xR,{onClose:Me})})}),e.jsx(i,{mb:12,alignItemsCenter:!0,justifyContentSpaceBetween:!0,flex:!0,children:Ke&&e.jsxs(e.Fragment,{children:[e.jsx(i,{w:ve,children:e.jsx(Ct,{as:NR,name:"owner",roleId:_,isRoleOrDepartment:u,onChange:o,onOpen:Fe,disabled:D})}),N&&Be&&!D?e.jsxs(e.Fragment,{children:[e.jsx(i,{children:p("schedule_builder.common.or")}),e.jsx(i,{children:e.jsx(V,{startIcon:xt?"Sparkle":void 0,variant:"secondary",onClick:nt,children:p("schedule_builder.smart_covers.submit_cta")})})]}):null]})}),E&&e.jsxs(e.Fragment,{children:[W==="loading"&&e.jsx(i,{mb:12,children:e.jsx(Ii,{height:"small",variant:"indeterminate"})}),W==="succeeded"&&e.jsx(BR,{deselectShiftRecommendation:Re,setCommonShift:g,selectedShift:f,onClick:tt,jobId:C.owner})]}),e.jsx(i,{grow:1,mb:12,children:e.jsx(Ct,{as:RR,name:"shiftTimes",selectedShift:f,onChange:et,onStartTimeDropdownClick:se,onEndTimeDropdownClick:Ne,disabled:D})}),e.jsxs(i,{mb:12,row:!0,spacebetween:!0,children:[e.jsx(i,{mr:8,grow:1,children:e.jsx(Ct,{as:DR,name:"roleName",jobId:C.owner,disabled:Qe||D,onColorChange:we,isColorMappingV1:a,onDropdownClick:We})}),e.jsx(Ct,{as:Ui,name:"color",isColorMappingV1:a,onDropdownClick:Xe,disabled:D})]}),e.jsxs(i,{mb:12,children:[e.jsx(i,{mb:8,children:e.jsx(j,{variant:"bodyBold",children:p("schedule_builder.shift_form.apply_to")})}),e.jsx(i,{grow:1,children:e.jsx(Ct,{name:"days",children:({field:ne})=>
1e.jsx(Vm,{...ne,startOfWeek:y,onChange:Ee(ne.onChange),disabled:D,embedded:P})})})]}),e.jsx(i,{mb:12,children:e.jsx(LR,{currentShiftDate:t,disabled:D})})]}),e.jsx(i,{pv:8,children:e.jsx(d_,{shiftId:x,onCancel:n,isSubmitting:h,isValid:m&&!D})})]})};f_.propTypes={commonShiftsLoaded:d.bool,currentShiftDate:d.string.isRequired,employeeName:d.string,handleCancel:d.func.isRequired,handleEmployeeSelection:d.func,isColorMappingV1:d.bool.isRequired,isLoadingCommonShifts:d.bool,isMobile:d.bool,isOpenShift:d.bool,isRoleOrDepartment:d.bool,isSubmitting:d.bool.isRequired,isValid:d.bool.isRequired,roleId:d.string,selectedShift:d.object,setCommonShift:d.func,setFieldValue:d.func.isRequired,shiftId:d.string,showCommonShifts:d.bool,isShiftReassignmentViewable:d.bool,startOfWeek:d.number,values:d.object.isRequired,disabled:d.bool,userId:d.string};const b_=r.memo(f_),g_=({employeeName:t,userAvatar:s,scheduleAvailabilities:n})=>{const o=Zl(t),a=r.useMemo(()=>kl(s),[s]);return t?e.jsxs(i,{row:!0,vcenter:!0,children:[e.jsx(Un,{size:"large",image:a,initials:o}),e.jsxs(i,{ml:8,ellipsis:!0,maxw:400,children:[e.jsx(j,{variant:"heading2",color:"mono900",children:t}),e.jsx(i,{column:!0,children:n?.map(({id:l,title:c,startAt:u,endAt:h,allDay:m,job:{id:_}})=>{const f=p(`${Wc}.${c?.toLowerCase()}`),g=m?p(`${Wc}.whole_day`):Ut(u,h);return e.jsx("div",{children:e.jsx(j,{variant:"caption",children:`${f}: ${g}`})},`jobAvailability-${_}-${l}`)})})]})]}):null};g_.propTypes={employeeName:d.string,userAvatar:d.string,scheduleAvailabilities:d.array};const x_=r.memo(g_),{cx:HR}=O("ShiftFormAdd"),FR=[de.employee,de.startTime],C_=({clearCommonShifts:t,currentLocationId:s,currentShiftDate:n,employeeName:o,fetchCommonShifts:a,initialValues:l,isColorMappingV1:c,isRoleOrDepartment:u,jobId:h,mobile:m,onClose:_,onCreateTimeOff:f,roleId:g,scheduleAvailabilities:b,selectedShift:x,setCommonShift:E,setFormikValues:S,setTab:y,startOfWeek:C,submitShift:v,tab:T,tabs:D,timeOffCategories:L,userAvatar:A,userId:P})=>{const{viewType:M}=ze(),R=FR.includes(M),$=r.useCallback(N=>{R&&(t(),a({jobId:N,locationId:s,dayOfWeek:dr(n)}))},[s,n]);r.useEffect(()=>{$(h)},[h]);const B=r.useCallback(N=>{const H=N.target?.value===Js?void 0:N.target?.value;$(H)},[$]),W=r.useCallback(async N=>{f({...N,job:h,onSuccess:_})},[f,h,_]);return e.jsxs(i,{className:HR(),w:"100%",children:[o&&e.jsx(x_,{employeeName:o,userAvatar:A,scheduleAvailabilities:b}),e.jsx(i,{bbw:1,bcolor:"mono300",mb:15,children:e.jsx(i,{w:"fit-content",children:e.jsx(Km,{tabs:D,value:T,onChange:y})})}),T===ys.CUSTOM&&e.jsx(Ht,{onSubmit:v,initialValues:l,validationSchema:l_,validateOnMount:!0,children:N=>(S(N.values),e.jsx(b_,{...N,currentShiftDate:n,handleCancel:_,handleEmployeeSelection:B,isMobile:m,isRoleOrDepartment:u,selectedShift:x,setCommonShift:E,scheduleAvailabilities:b,showCommonShifts:R,shiftId:null,startOfWeek:C,roleId:g,isColorMappingV1:c,jobId:h,locationId:s,userId:P}))}),T===ys.TIME_OFF&&e.jsx(dR,{onSubmit:W,startAt:n,endAt:n,jobId:h,categories:L})]})};C_.propTypes={currentLocationId:d.string,currentShiftDate:d.string.isRequired,employeeName:d.string,initialValues:d.object,isColorMappingV1:d.bool,isRoleOrDepartment:d.bool,jobId:d.string,mobile:d.bool,onClose:d.func.isRequired,onCreateTimeOff:d.func,roleId:d.string,scheduleAvailabilities:d.array,setCommonShift:d.func,setFormikValues:d.func,setTab:d.func,startOfWeek:d.number,submitShift:d.func,tab:d.string,tabs:d.object,timeOffCategories:d.array,userAvatar:d.string};const WR=F((t,s)=>{const n=s.jobId,o=n?wt({state:t,relationship:"user",id:n}):null;return{currentLocationId:ct(t),isColorMappingV1:ks(t)===1,jobId:n,timeOffCategories:Pk(t,n),userId:o}},{onCreateTimeOff:mE,fetchCommonShifts:hE,clearCommonShifts:Jh})(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL})(C_))),{cx:VR}=O("ShiftFormCoverRequest"),KR=({shiftId:t,onClose:s,handleBackToShiftForm:n})=>{const o=X(),a=I(pE),l=I(_E),u=I(E=>fE({state:E,id:t,relationship:"owner"}))?.id,h=I(E=>Xh(E,t)),m=I(E=>Ti(E,t)),_=I(bE),f=I(E=>{if(!h?.owner)return null;if(h.owner.type==="job"){const S=wt({state:E,id:h.owner.id,relationship:"location"}),y=Array.isArray(S)?S[0]:S;return y?Dn({state:E,id:y,attribute:"name"}):null}return h.owner.type==="location"?Dn({state:E,id:h.owner.id,attribute:"name"}):null}),g=r.useMemo(()=>
1{if(!h)return{};const E=new Date(h.startAt),S=new Date(h.endAt),y=S.getTime()-E.getTime(),C=Math.floor(y/(1e3*60*60)),v=Math.floor(y%(1e3*60*60)/(1e3*60)),T=C>0?`${C} hrs `:"",D=v>0?`${v} min`:"",L=C===0&&v===0?"":`( ${T}${D} )`;return{weekday:Ie(E).format("ddd").toUpperCase(),day:Ie(E).format("D"),month:Ie(E).format("MMM"),employeeName:m||"Unassigned",startTime:Ie(E).format("h:mma").toLowerCase(),endTime:Ie(S).format("h:mma").toLowerCase(),durationText:L,role:h.roleName||"",location:f||""}},[h,m,f]);r.useEffect(()=>{o(gE({shift_id:t}))},[o,t]);const b=r.useCallback(()=>{n&&n()},[n]),x=r.useCallback(async(E,S,y)=>{try{const C=E.reduce((v,T)=>(v[T]="1",v),{});await Eo("/covers/batch_create",{owes:C,reason:S||"",requirement:y||"",shift_id:Number(t),requester:Number(u)}),_&&o(ui({startDate:_?.start,endDate:_?.end})),o(xE()),o(ie.clearFindCoverShiftId()),s&&s(),o(ie.showNotification({message:p("schedule_builder.smart_covers.cover_request_toast_success"),type:"success"}))}catch{o(ie.clearFindCoverShiftId()),s&&s(),o(ie.showNotification({message:p("schedule_builder.smart_covers.cover_request_toast_error"),type:"error"}))}},[t,o,u,s,_]);return e.jsx(i,{className:VR(),w:"100%",children:e.jsx(Mv,{isLoading:l,employees:a,onClose:b,onBack:b,shift:g,onSubmit:x})})},qR=r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL})(KR)),Il=t=>{if(Array.isArray(t))return t.map(Il);if(t!==null&&typeof t=="object"){const s=t;if("entities"in s&&"ids"in s&&typeof s.entities=="object"&&Array.isArray(s.ids))return{entities:Il(s.entities),ids:s.ids};const n={},o=[];for(const[a,l]of Object.entries(s))if(l!==null&&typeof l=="object"&&("attributes"in l||"relationships"in l)){const c=l,u=c.id||a;if(n[u]={id:u,...c.attributes||{}},c.relationships)for(const[h,m]of Object.entries(c.relationships))n[u][h]=m.data;o.push(u)}else if(l!==null&&typeof l=="object"&&"id"in l){const c=l.id||a;n[c]=l,o.push(c)}else n[a]=l;return{entities:n,ids:o}}return t},zR=Nr("scheduleBuilder/approveClaimRequest",({onCancel:t,onSuccess:s,onDone:n,onError:o,id:a,uxContext:l},{dispatch:c,getState:u})=>{try{const h=u(),m=Vc({state:h,id:a,relationship:"job"}),_=Vc({state:h,id:a,relationship:"shift"}),f={owner:m,startAt:Se({state:h,id:_,attribute:"startAt"}),endAt:Se({state:h,id:_,attribute:"endAt"})},g=()=>eg(`/schedule_builder/claim_requests/${a}/approve`).then(b=>{const{data:x,included:E}=b;if(x&&x.type==="shift"){const y=Object.values(Il({data:x,included:E||[]})?.entities);y.length>0&&c(CE(y[0]))}if(E){const S=E.filter(C=>C.type==="shiftConflict").map(C=>{const v=C.attributes.type,T=EE.fromApiValue(v);return{id:C.id,type:"conflict",conflictType:T,sourceId:C.relationships.shift.data.id,sourceType:C.relationships.shift.data.type,targetId:C.relationships.conflict.data.id,targetType:C.relationships.conflict.data.type}});S.length>0&&c(SE(S));const y=E.filter(C=>C.type==="shiftNotesQuota").map(C=>({id:C.id,type:C.type,unlimited:C.attributes.unlimited,month:C.attributes.month,year:C.attributes.year}));y.length>0&&c(jE.upsertMany(y))}c(yE(a)),c(ie.updatePendingJobLaborTotalsIds(m)),c(vE(b))});return c(IE({shifts:[f]})).then(uv).then(b=>{const x=Object.values(b);return x.length>0?c(TE({deprecatedModal:!0,conflicts:x,uxContext:l,onApprove:()=>g().then(()=>{c(Oa()),s()}).catch(o).finally(()=>{n()}),onRequestClose:()=>{c(Oa()),t()}})):g().then(()=>{c(Oa()),s()}).catch(o).finally(()=>{n()})}).catch(o).finally(()=>{n()})}catch(h){wE(h,"SB: approve claim request"),o(h),n()}}),GR=Te(sa,(t,s)=>s.startAt,(t,s)=>s.endAt,(t,s)=>s.jobId,(t,s,n,o)=>t.length?t.some(a=>a.job?.id===o?Vb([s,n],[a.startAt,a.endAt]):!1):!1)((t,s)=>`selectClaimHasTimeOffConflict-${s.startAt}-${s.endAt}-${s.jobId}`),YR=Te((t,s)=>GR(t,{startAt:Se({state:t,id:s.shiftId,attribute:"startAt"}),endAt:Se({state:t,id:s.shiftId,attribute:"endAt"}),jobId:s.jobId}),ta,(t,s)=>Se({state:t,id:s.shiftId,attribute:"startAt"}),(t,s)=>Se({state:t,id:s.shiftId,attribute:"endAt"}),(t,s)=>s.jobId,(t,s,n,o,a)=>t?"schedule_builder.react_page.open_shift.claim_requests.warning_availability_conflict":kE({shifts:s,startAt:n,endAt:o,jobId:a})?"schedule_builder.react_page.open_shift.claim_requests.warning_scheduling_conflict":"")((t,s)=>
1`selectClaimWarningI18n-${s.jobId}-${s.shiftId}`),JR=Te(DE,(t,s)=>Se({state:t,id:s.shiftId,attribute:"startAt"}),(t,s)=>Se({state:t,id:s.shiftId,attribute:"endAt"}),(t,s)=>s.shiftId,(t,s,n,o)=>{const a=t.filter(h=>h.shift?.id===o),l=Fb(s,n,Wb),c=(Math.round(l*100)/100).toFixed(2);return a.sort((h,m)=>gu(h.createdAt,m.createdAt)).reduce((h,m)=>(h.push({id:m.id,jobId:m.job?.id,hours:c,createdAt:Oe(m.createdAt,"full_12"),childLaborViolationTypes:m.childLaborViolationTypes}),h),[])})((t,s)=>`selectClaimRequestData-${s.shiftId}`),dn="schedule_builder.react_page.open_shift.claim_requests",{cx:XR}=O("ClaimRequestInfo"),E_=({avatarUrl:t,claimRequestTotalsLoading:s,cost:n,createdAt:o,locationId:a,overtimes:l,totalOvertime:c,pendingResponse:u,userId:h,userName:m,warningI18n:_,childLaborViolationTypes:f})=>{const g=Qo(),[b,x]=r.useState(!1),E=Zl(m),S=r.useMemo(()=>kl(t),[t]),y=r.useCallback(()=>{x(!b)},[b]),C=!1,v=u,T=r.useCallback(()=>{g.push({pathname:pv(`/team/${h}/job_details`),state:{enableEditMode:!0,editField:"wage_rate",locationId:a}}),lr(OE,{properties:{link_text:NE.ADD_WAGE}})()},[g,h,a]),D=r.useMemo(()=>n?pt(n):e.jsx(Nt,{className:XR("add-wage",`user-${h} location-${a}`),underline:!0,onClick:T,children:p(`${dn}.add_wage`)}),[n,T,h,a]),L=(f?.length||0)>0;return e.jsxs(i,{row:!0,vtop:!0,minw:312,maxw:376,gap:12,children:[e.jsx("div",{"data-testid":"avatar-wrapper",children:e.jsx(Un,{image:S,initials:E})}),e.jsxs(i,{gap:6,column:!0,children:[e.jsxs(i,{row:!0,vcenter:!0,gap:4,children:[e.jsx(j,{color:"mono900",variant:"bodyBoldTight",children:m}),C]}),!u&&e.jsxs(e.Fragment,{children:[L&&e.jsx(Ah,{warningText:p("notifications.requests.trade.child_labor_violations")}),_&&e.jsx(pl,{variant:"warning",message:p(_)}),c>0&&e.jsx(Ae,{content:!!l?.length&&e.jsx(i,{column:!0,children:l.map(A=>Object.keys(A).map(P=>e.jsx(j,{variant:"caption",children:p(`${dn}.warning_overtime_tooltip`,{props:{hours:A[P],overtimeType:P}})},`${P}-${A[P]}`)))}),children:e.jsx(pl,{variant:"warning",message:p(`${dn}.warning_overtime`,{props:{hours:c}})})}),e.jsxs(i,{row:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySmBoldTight",children:p(`${dn}.claimed_on`)}),e.jsxs(j,{color:"mono700",variant:"bodySmTight",children:["Â ",s?"Loading...":Kb(o)]})]}),e.jsxs(i,{row:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySmBoldTight",children:p(`${dn}.estimated_pay`)}),"Â ",e.jsx(j,{color:"mono700",variant:"bodySmTight",children:s?"Loading...":D})]})]}),u&&v&&e.jsxs(i,{vcenter:!0,row:!0,children:[e.jsx(j,{color:"mono700",variant:"bodySmBoldTight",children:p(`${dn}.insights`)}),e.jsx(be,{size:"small",icon:b?"ChevronUp":"ChevronDown",onClick:y,label:b?p("schedule_builder.actions.hide_insights"):p("schedule_builder.actions.show_insights")})]}),b&&e.jsx(i,{h:120,bgcolor:"accent500"})]})]})};E_.propTypes={avatarUrl:d.string.isRequired,claimRequestTotalsLoading:d.bool.isRequired,cost:d.number,createdAt:d.string.isRequired,locationId:d.number.isRequired,overtimes:d.array,totalOvertime:d.number,userId:d.string.isRequired,userName:d.string.isRequired,warningI18n:d.string.isRequired,childLaborViolationTypes:d.arrayOf(d.string)};const QR=F((t,s)=>({avatarUrl:AE(t,s.jobId),claimRequestTotalsLoading:LE(t),cost:Na({state:t,attribute:"cost",id:s.id}),locationId:ct(t),overtimes:Na({state:t,attribute:"overtimes",id:s.id}),totalOvertime:Na({state:t,attribute:"totalOvertime",id:s.id}),userId:RE(t,s.jobId),userName:Or(t,s.jobId),warningI18n:YR(t,{shiftId:s.shiftId,jobId:s.jobId})}))(E_),{cxEl:ZR}=O("OpenShiftDetails"),S_=({startAt:t,endAt:s,color:n,roleName:o,isColorMappingV1:a})=>e.jsxs(i,{bw:1,p:12,bcolor:"mono300",bradiusm:!0,column:!0,gap:6,children:[e.jsx(j,{variant:"eyebrow",color:"mono900",children:p("schedule_builder.react_page.open_shift.details.title")}),e.jsxs(i,{vcenter:!0,row:!0,gap:4,children:[e.jsx(i,{className:ZR(a?n:`${n}-v2`),w:18,h:18,bradiusl:!0}),e.jsx(j,{variant:"bodySm",color:"mono900",children:o||"No role"})]}),e.jsxs(i,{vcenter:!0,row:!0,gap:4,children:[e.jsx(Q,{size:"small",iconName:"TimeClock",color:"mono700"}),e.jsxs(j,{variant:"bodySm",color:"mono900",children:[xu(t),"Â (",qb(t,s),")"]})]})]});
1S_.propTypes={startAt:d.string.isRequired,endAt:d.string.isRequired,color:d.string.isRequired,roleName:d.string,isColorMappingV1:d.bool.isRequired};const eL=r.memo(S_),gs="schedule_builder.react_page.open_shift.claim_form",j_=({shiftId:t,onClose:s,onOpenEditShiftDetails:n,selectedClaimRequestId:o,setSelectedClaimRequestId:a,onAssignShift:l,claims:c,shiftColor:u,roleName:h,startAt:m,endAt:_,isColorMappingV1:f})=>{const[g,b]=r.useState(!1),[x,E]=r.useState(!1),[S,y]=r.useState(!1),C=r.useCallback(()=>{b(!g)},[g]),v=r.useCallback(()=>{E(!0),l({id:o,onSuccess:()=>{s()},onError:()=>{Qh.error(p("errors.something_went_wrong"))},onCancel:s,onDone:()=>{E(!1)}})},[o,s,l]),T=r.useCallback(R=>{R.selected?a(R.value):a(null)},[a]),D=c.length>0,L=r.useCallback(()=>{y(!0)},[]),A=r.useCallback(()=>{y(!1)},[]),P=[],M=P.length>0;return e.jsxs(i,{maxw:410,minh:380,mt:32,ph:24,children:[e.jsx(i,{mb:8,children:e.jsx(j,{variant:"heading2",color:"mono900",children:p(`${gs}.title`,{props:{count:c.length}})})}),e.jsx(j,{color:"mono700",children:p(`${gs}.subtitle`,{props:{count:c.length}})}),e.jsxs(i,{minh:300,column:!0,mt:12,pb:12,children:[D?e.jsx(i,{column:!0,grow:1,scrollY:!0,pl:4,pt:4,maxh:350,mb:12,children:c.map(R=>e.jsx(i,{mb:12,children:e.jsx(Al,{radioCanDeselect:!0,value:R.id,onClick:T,selected:o===R.id,content:e.jsx(QR,{id:R.id,jobId:R.jobId,shiftId:t,createdAt:R.createdAt,childLaborViolationTypes:R.childLaborViolationTypes})})},R.id))}):e.jsx(i,{column:!0,grow:1,children:e.jsx(eL,{shiftId:t,color:u,roleName:h,startAt:m,endAt:_,isColorMappingV1:f})}),M&&e.jsxs(i,{mv:24,children:[e.jsxs(i,{row:!0,vcenter:!0,spacebetween:!0,children:[e.jsx(j,{variant:"heading3",color:"mono900",children:p("schedule_builder.react_page.open_shift.pending_response.title",{props:{count:P.length}})}),e.jsx(be,{icon:g?"ChevronUp":"ChevronDown",onClick:C,label:g?p("schedule_builder.actions.hide_pending_responses"):p("schedule_builder.actions.show_pending_responses")})]}),g&&e.jsx(i,{pv:12,children:P.map(R=>e.jsx(i,{},R.id))})]}),e.jsx(fr,{buttons:[{label:p(`${gs}.assign_shift_cta`),onClick:v,variant:"primary",disabled:x||!D||o===null},{label:p(`${gs}.edit_shift_details_cta`),variant:"tertiary",onClick:L}]})]}),e.jsx(Mt,{open:S,onClose:A,title:p(`${gs}.edit_shift_confirmation_title`),children:()=>e.jsxs(i,{children:[e.jsx(i,{column:!0,mb:24,w:400,children:e.jsx(j,{children:p(`${gs}.edit_shift_confirmation_message`)})}),e.jsx(fr,{buttons:[{label:p(`${gs}.edit_shift_confirmation_cta`),variant:"primaryDestructive",onClick:n},{label:p(`${gs}.edit_shift_cancel_cta`),variant:"tertiary",onClick:A}]})]})})]})};j_.propTypes={shiftId:d.string.isRequired,isColorMappingV1:d.bool.isRequired,onClose:d.func.isRequired,onAssignShift:d.func.isRequired,onOpenEditShiftDetails:d.func.isRequired,claims:d.arrayOf(d.shape({id:d.string.isRequired,jobId:d.string.isRequired,createdAt:d.string.isRequired,hours:d.string.isRequired})),selectedClaimRequestId:d.string,setSelectedClaimRequestId:d.func.isRequired,shiftColor:d.string.isRequired,roleName:d.string.isRequired,startAt:d.string.isRequired,endAt:d.string.isRequired};const tL=r.memo(j_),{cx:sL}=O("TimelineItem"),nL=({timelineDataItem:t,renderTime:s,isLastEvent:n})=>e.jsxs(i,{className:sL(),children:[e.jsxs(i,{spacebetween:!0,children:[e.jsxs(i,{vcenter:!0,children:[e.jsx(i,{mr:8,minw:8,minh:8,bradiusfull:!0,bgcolor:"primary700"}),e.jsx(i,{children:e.jsx(j,{variant:"bodyBoldTight",color:"primary",children:t.title})})]}),e.jsx(i,{children:e.jsxs(j,{variant:"bodySmTight",color:"secondary",children:[Oe(t.date,"pretty_short_day"),s&&` ${zb(t.date)}`]})})]}),e.jsxs(i,{row:!0,children:[e.jsx(i,{mr:8,vcenter:!0,hcenter:!0,minw:8,minh:n?void 0:52,children:!n&&e.jsx(i,{minw:1,minh:36,bgcolor:"mono300"})}),e.jsx(i,{mt:4,children:e.jsx(j,{variant:"bodySmTight",color:"primary",children:t.subtitle})})]})]}),{cx:rL}=O("Timeline"),y_=({data:t,renderTime:s})=>e.jsx(i,{className:rL(),children:t.map((n,o)=>e.jsx(nL,{timelineDataItem:n,isLastEvent:o===t.length-1,renderTime:s},n.date.replace(" ","-")))}),sr="schedule_builder.react_page.shift.approvals_history_paywall",oL=["see_who_requested","see_who_approved","always_have_audit"],v_=({shouldShowApprovalsPaywall:t,children:s,products:n,onUpgrade:o})=>{const a=K(),l=BE(n,UE.ESSENTIALS),c=r.useCallback(()=>{a(w.BUTTON_CLICKED,k.CLICK,{tab:ys.APPROVALS,buttonText:p(`${sr}.upgrade_cta`)}),o({billingFrequency:Ql.monthly,workflowSource:"paywall_modal"})},[a,o]),u=r.useMemo(()=>({price:l}),[l]);return t?e.jsxs(i,{column:!0,children:[e.jsx(i,{pb:16,children:e.jsx(Y,{i18n:`${sr}.title`})}),oL.map(h=>e.jsxs(i,{row:!0,mb:8,children:[e.jsx(i,{mr:8,vcenter:!0,children:e.jsx(Zh,{type:"circle",size:"xs"})}),e.jsx(i,{children:e.jsx(Y,{fs14:!0,lh:"20px",i18n:`${sr}.bullets.${h}`})})]},h)),e.jsx(i,{mv:16,children:e.jsx(V,{variant:"primary",size:"medium",onClick:c,children:p(`${sr}.upgrade_cta`)})}),e.jsx(Y,{i18n:`${sr}.more`,i18nProps:u})]}):s};v_.propTypes={shouldShowApprovalsPaywall:hv.bool.isRequired};const aL=F(t=>({shouldShowApprovalsPaywall:PE(t),products:ME(t)}),{onUpgrade:$E})(r.memo(v_)),lL=({shiftEventData:t,isLoading:s})=>e.jsx(aL,{children:s?e.jsx(i,{vcenter:!0,hcenter:!0,mt:50,children:e.jsx(Di,{isLoading:s})}):e.jsx(i,{mv:30,maxh:330,scrollY:!0,children:e.jsx(y_,{data:t,renderTime:!0})})}),iL=F((t,s)=>({shiftEventData:HE(t,s),isLoading:wi(t)}))(r.memo(lL)),I_=({text:t,author:s,createdAt:n,isLoading:o})=>!o||t?e.jsxs(i,{mt:36,maxh:400,overflow:"auto",children:[e.jsx(gv,{fs18:!0,fw600:!0,color:Xl.navy,i18n:"schedule_builder.react_page.shift.shift_notes"}),e.jsx(i,{mt:12,children:e.jsx(Y,{whiteSpace:"pre-wrap",asHTML:!0,marginTop:12,children:t})}),e.jsx(i,{mt:12,children:e.jsxs(Y,{fs14:!0,children:[s," ",Oe(n,"pretty_no_year_short")]})})]}):e.jsx(i,{vcenter:!0,hcenter:!0,mt:50,children:e.jsx(Di,{isLoading:o})});I_.propTypes={id:d.string.isRequired,text:d.string,author:d.string,createdAt:d.str
1ing,isLoading:d.bool.isRequired};const cL=F((t,s)=>{const{id:n}=vs({state:t,id:s.id,relationship:"note"}),o=ca(t,n);return{text:o?.text,author:o?.author,createdAt:o?.createdAt,isLoading:wi(t)}})(r.memo(I_)),dL=({syncError:t})=>{const n=(l=>{const c="schedule_builder.react_page.edit_shift_popup.sync_error",u={body:`${c}.${l}.body`,title:`${c}.${l}.title`,link:`${c}.${l}.link`,endIcon:"ExternalLink"};return{error:{body:u.body},other:{body:u.body},missed_job_id:{...u,endIcon:"ArrowRight",href:`${window.location.origin}/team/import`},missed_employee_role:{...u,href:"https://www.toasttab.com/login"},wrong_job_partner_id:{...u,endIcon:"ArrowRight",href:`${window.location.origin}/team/import`},wrong_role_partner_id:{...u,href:`${window.location.origin}/team/import?ref=schedule`},duplicate_shift_id:{...u}}[l]})(t);if(!(l=>l&&"title"in l&&"link"in l&&"endIcon"in l)(n))return e.jsx(dt,{variant:"warning",children:e.jsx(j,{variant:"body",children:p(n.body)})});const a=!n.href?.startsWith(window.location.origin);return e.jsxs(dt,{action:e.jsx(Nt,{href:n.href,size:"small",endIcon:n.endIcon,target:a?"_blank":void 0,children:p(n.link)}),forceStacked:!0,variant:"warning",children:[e.jsx(j,{variant:"heading4",children:p(n.title)}),e.jsx(j,{variant:"body",children:p(n.body)})]})},{cx:uL}=O("ShiftFormEdit"),T_=({clearCommonShifts:t,currentShiftDate:s,employeeName:n,onFetchShift:o,formikValues:a,handlerId:l,handleSubmit:c,handleSubmitSuccess:u,hasTimecard:h,initialValues:m,isColorMappingV1:_,isRoleOrDepartment:f,isShiftReassignmentViewable:g,mobile:b,onAssignShift:x,fetchClaimRequestTotals:E,claims:S,onClose:y,onCopy:C,onDelete:v,onShowTooltipForCopy:T,onShowTooltipForDelete:D,rangeType:L,roleId:A,scheduleAvailabilities:P,setFormikValues:M,setTab:R,shiftId:$,shiftSyncError:B,startOfWeek:W,submitShift:N,tab:H,tabs:q,trackUx:G,userAvatar:re,userId:ue,color:je,roleName:ce,startAt:oe,endAt:ge,isOpenShift:te,setReassignmentCardSelected:Z,handleEnableCoverForm:ee})=>{const[he,Ye]=r.useState(S.length>0),[De,Pe]=r.useState(null);r.useEffect(()=>(o($),he&&E($),()=>t()),[he]);const ke=r.useCallback(()=>{const se=U.SCHEDULE_BUILDER_DELETE_CONFIRMATION_MODAL;G(w.DELETE_CONFIRMATION_MODAL_SHOWN,k.VIEW,{eventCategory:se}),v({id:$}).then(()=>{D&&D(l)})},[G,D,l,v,$]),me=r.useCallback(()=>{G(w.COPY_SHIFT_CLICKED,k.CLICK),T(),sm(m,a)?y():c(a,u),C($)},[m,T,y,$,c,u,a,G,C]),Fe=r.useCallback(()=>{G(w.EDIT_SHIFT_CLICKED,k.CLICK),Ye(!1)},[G]),We=I(hs),Xe=r.useMemo(()=>KE.includes(We)&&Date.now()<Su.getTime(),[We]);return he?e.jsx(tL,{shiftId:$,onOpenEditShiftDetails:Fe,selectedClaimRequestId:De,setSelectedClaimRequestId:Pe,onClose:y,shiftColor:je,roleName:ce,startAt:oe,endAt:ge,claims:S,isColorMappingV1:_,onAssignShift:x}):e.jsxs(i,{className:uL(),children:[n&&e.jsx(x_,{employeeName:n,userAvatar:re,scheduleAvailabilities:P}),e.jsx(i,{absolute:!0,top:16,right:L===J.day?64:112,children:e.jsx(Ae,{placement:"top",content:p("actions.delete"),children:e.jsx(be,{onClick:ke,icon:"Delete",destructive:!0,label:p("actions.delete"),disabled:h})})}),L!==J.day&&e.jsx(i,{absolute:!0,top:16,right:64,children:e.jsx(Ae,{placement:"top",content:p("actions.copy"),children:e.jsx(be,{onClick:me,icon:"Copy",label:p("actions.copy")})})}),B&&e.jsx(i,{mv:16,children:e.jsx(dL,{syncError:B})}),e.jsxs(i,{w:"100%",children:[L!==J.month&&e.jsx(i,{bbw:1,bs:"solid",bcolor:"mono300",mb:15,children:e.jsx(i,{w:"fit-content",children:e.jsx(Km,{tabs:q,value:H,onChange:R})})}),H===ys.CUSTOM&&e.jsxs(i,{children:[h&&e.jsxs(i,{vcenter:!0,mv:20,children:[e.jsx(Q,{iconName:"Info",size:"small",color:"info300",mr:5}),e.jsx(j,{variant:"bodySm",color:"info300",children:p("schedule_builder.react_page.shift_form.disabled_state.shift_has_timecard")})]}),e.jsx(Ht,{onSubmit:N,initialValues:m,validationSchema:l_,validateOnMount:!0,children:se=>(M(se.values),e.jsx(b_,{...se,handleEnableCoverForm:ee,employeeName:n,currentShiftDate:s,handleCancel:y,isMobile:b,isRoleOrDepartment:f,scheduleAvailabilities:P,shiftId:$,startOfWeek:W,isColorMappingV1:_,roleId:A,isOpenShift:te,isShiftReassignmentViewable:g||Xe,setReassignmentCardSelected:Z,disabled:h,userId:ue}))})]}),H===ys.NOTES&&e.jsx(cL,{id:$}),H===ys.APPROVALS&&e.jsx(iL,{id:$})]})]})};T_.propTypes={clearCommonShifts:d.func,currentShiftDate:d.string.isRequired,onFetchShift:d.func,formikValues:d.object,handlerId:d.string,handleSubmit:d.func,handleSubmitSuccess:d.func,hasTimecard:d.bool,initialValues:d.object,isColorMappingV1:d.bool,isRoleOrDepartment:d.bool,mobile:d.bool,onClose:d.func.isRequired,onCopy:d.func.isRequired,onDelete:d.func,onShowTooltipForCopy:d.func,onShowTooltipForDelete:d.func,rangeType:d.string,roleId:d.string,
1scheduleAvailabilities:d.array,setFormikValues:d.func,setTab:d.func,shiftId:d.string,startOfWeek:d.number,submitShift:d.func,tab:d.string,tabs:d.object,trackUx:d.func,shiftSyncError:d.string};const hL=F((t,s)=>{const n=s.jobId,o=s.shiftId,a=n?wt({state:t,relationship:"user",id:n}):null;return{jobId:n,userId:a,shiftSyncError:em(t,o),isColorMappingV1:ks(t)===1,claims:JR(t,s),isShiftReassignmentViewable:FE(t,s)}},{onDelete:tm,onAssignShift:zR,onFetchShift:VE,clearCommonShifts:Jh,fetchClaimRequestTotals:WE,onCopy:ie.startCopyPaste})(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL})(T_))),{cx:mL}=O("ShiftFormContainer"),w_=({childLaborViolationData:t,color:s,currentLocationId:n,currentShiftDate:o,defaultRoleOption:a,defaultTab:l,employeeName:c,handlerId:u,isAdding:h,isApproved:m,isNoteAllowed:_,isOpenShift:f,isRoleOrDepartment:g,jobId:b,locationState:x,mobile:E,note:S,numNotesLeftInQuota:y,onClose:C,onShowTooltipForCopy:v,onShowTooltipForDelete:T,onSubmit:D,roleId:L,roleOption:A,scheduleAvailabilities:P,shiftId:M,showNotification:R,syncError:$,startOfWeek:B,timeRange:W,startAt:N,endAt:H,roleName:q,userAvatar:G,userId:re,userDateOfBirth:ue,autoOpenCoverModal:je=!1,openCoverRequestModal:ce,hasTimecard:oe,commonShifts:ge})=>{const te=X(),Z=!h,ee=K({isEdit:Z,notePaywallShown:!_}),he=Kn(),Ye=r.useRef(S),De=r.useRef(b),Pe=r.useRef(f),[ke,me]=r.useState(!1),{viewType:Fe,rangeType:We}=ze(),[Xe,se]=r.useState(In),[Ne,ye]=r.useState(l||ys.CUSTOM),[Ve,$e]=r.useState(),[Ee,Re]=r.useState(!1),Me=r.useMemo(()=>zk({isEditMode:Z,isApproved:m,hasNote:!!S,viewType:Fe,rangeType:We,isOpenShift:f}),[Z,m,S,Fe,We,f]);r.useEffect(()=>{if(je&&Z){const _e=setTimeout(()=>{me(!0)},100);return()=>clearTimeout(_e)}},[je,Z]),r.useEffect(()=>{ce&&me(!0)},[ce]);const we=I(_s),Ke=I(rm);r.useEffect(()=>{const _e=ue!=null?QE(ue,new Date).age:void 0,xe=t?.violationTypes?.length>0,Ce={shift_id:M,employee_id:re,...we&&{shift_start_time:W?.from,shift_end_time:W?.to,shift_date:o,employee_age:_e,state:x,school_session_mode:!!Ke,...xe&&{violation_type:t.violationTypes.join(",")}},...h&&{common_shift_displayed:ge?.length>0}};ee(w.SHIFT_MODAL_VIEWED,k.VIEW,Ce)},[]);const Qe=r.useCallback(_e=>{_e.stopPropagation(),te(ie.clearFindCoverShiftId()),C()},[C,te]),Ze=r.useCallback(()=>{me(!1),C()},[C]),et=r.useMemo(()=>Yk({roleOption:A,defaultRoleOption:a,color:s,jobId:b,startOfWeek:B,timeRange:W,currentShiftDate:o,note:S,isOpenShift:f}),[A,a,s,b,B,W,o,S,f]),tt=r.useCallback(({numShifts:_e,newNote:xe})=>{Gk({numNotesLeftInQuota:y,numShifts:_e,newNote:xe,prevNote:Ye.current})&&ee(w.SHIFT_NOTES_QUOTA_LIMIT_REACHED,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER})},[y,ee]),st=r.useCallback((_e,xe,Ce,ht)=>{if(h)ee(w.SAVE_SHIFT_CLICKED,k.CLICK,{common_shift_version:zh.INLINE,add_shift_type:Xe===In?Kc.CUSTOM:Kc.COMMON,shift_id:_e,hasNotes:!!xe});else{const St=De.current!==Ce||Pe.current===!1&&ht==="location"||Pe.current===!0&&ht==="user";ee(w.SAVE_SHIFT_CLICKED,k.CLICK,{hasNotes:!!xe,shiftOwnerChanged:St,shiftReassignmentUsed:Ee})}},[h,Xe,ee,Ee]),nt=r.useCallback(()=>{R({message:p("schedule_builder.react_page.shifts.error_message.unable_to_save"),type:"error"})},[R]),Be=r.useCallback((_e,xe,Ce)=>{const{shiftTimes:{from:ht,to:St},owner:qe,...ft}=_e;C(),D({onDone:()=>xe({numShifts:ft.days.length,newNote:ft.note}),onFailure:Ce,uxContext:he(),jobLaborTotalsId:b,onShiftAdded:st,payload:{id:Z?M:null,currentShiftDate:o,from:ht,to:St,owner:qe,...ft}})},[C,D,he,b,st,Z,M,o]),ve=r.useCallback(()=>{Be(Ve,tt,nt)},[Ve,Be,tt,nt]),xt=r.useCallback(()=>{me(!0)},[me]),ne=r.useCallback(()=>{me(!1)},[me]);return e.jsxs(i,{w:E?"100%":"auto",minh:"min(350px, 50vh)",maxh:"min(736px, 90vh)",p:20,className:mL(),bgcolor:"default",bradiuss:!0,shadow:"z2",maxw:500,minw:456,children:[e.jsx(i,{absolute:!0,top:16,right:16,children:e.jsx(be,{onClick:Qe,icon:"Close",dataTestId:"close-shift-modal",label:p("schedule_builder.actions.close")})}),ke&&e.jsx(qR,{onClose:Ze,handlerId:re,shiftId:M,showNotification:R,handleBackToShiftForm:ne}),!ke&&Z&&e.jsx(hL,{handleEnableCoverForm:xt,currentShiftDate:o,defaultTab:l,employeeName:c,formikValues:Ve,handlerId:u,handleSubmit:Be,handleSubmitSuccess:tt,initialValues:et,isRoleOrDepartment:g,jobId:b,onClose:C,onShowTooltipForCopy:v,onShowTooltipForDelete:T,rangeType:We,roleId:L,scheduleAvailabilities:P,setFormikValues:$e,setTab:ye,shiftId:M,startOfWeek:B,submitShift:ve,syncError:$,tab:Ne,tabs:Me,trackUx:ee,color:s,roleName:q,startAt:N,endAt
1:H,isOpenShift:f,userAvatar:G,setReassignmentCardSelected:Re,hasTimecard:oe}),!ke&&!Z&&e.jsx(WR,{currentLocationId:n,currentShiftDate:o,employeeName:c,formikValues:Ve,initialValues:et,isRoleOrDepartment:g,jobId:b,onClose:C,rangeType:We,roleId:L,scheduleAvailabilities:P,selectedShift:Xe,setCommonShift:se,setFormikValues:$e,setTab:ye,startOfWeek:B,submitShift:ve,tab:Ne,tabs:Me,userAvatar:G})]})};w_.propTypes={commonShifts:d.array,clearCommonShifts:d.func,currentShiftDate:d.string.isRequired,defaultTab:d.string,employeeName:d.string,endAt:d.string,fetchShift:d.func,handlerId:d.string,isAdding:d.bool,isApproved:d.bool,isOpenShift:d.bool,isRoleOrDepartment:d.bool,jobId:d.string,mobile:d.bool,note:d.string,onClose:d.func.isRequired,onShowTooltipForCopy:d.func,onShowTooltipForDelete:d.func,roleId:d.string,shiftId:d.string,startAt:d.string,userAvatar:d.string,openCoverRequestModal:d.bool,hasTimecard:d.bool};const pL=F((t,s)=>{const n=s.jobId,o=n?wt({state:t,relationship:"user",id:n}):null,a=s.isAdding,l=s.shiftId,c=Vo(s.currentShiftDate),u=s.currentShiftDate;return{userId:o,syncError:Se({state:t,id:l,attribute:"syncError"}),color:Se({state:t,id:l,attribute:"color"}),currentLocationId:ct(t),defaultRoleOption:XE(t,s),isApproved:a?!1:Se({state:t,id:l,attribute:"isApproved"}),isNoteAllowed:Ko(t,{shiftNoteQuotaId:c}),note:JE(t,{shiftId:l}),numNotesLeftInQuota:YE(t,{shiftNoteQuotaId:c}),roleOption:GE(t,s),scheduleAvailabilities:Ca(t,{jobId:n,date:u}),startOfWeek:Dn({state:t,attribute:"startOfWeek",id:ct(t)}),employeeName:n?Or(t,n):null,userAvatar:n?Cr({state:t,attribute:"avatar",userId:o}):null,timeRange:zE(t,s),hasTimecard:Se({state:t,id:l,attribute:"hasTimecard"}),childLaborViolationData:l?nm(t,{shiftId:l}):null,locationState:qE(t),userDateOfBirth:o?Cr({state:t,attribute:"dateOfBirth",userId:o}):null,commonShifts:qh(t)}},{onSubmit:ki,showNotification:ie.showNotification})(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_SHIFT_MODAL})(w_))),D_=({anchorEl:t,date:s,defaultTab:n,endAt:o,handlerId:a,isAdding:l,isManager:c,isOpenShift:u,isRoleOrDepartment:h,jobId:m,onClose:_,onShowTooltipForCopy:f,onShowTooltipForDelete:g,open:b,roleId:x,shiftId:E,startAt:S,color:y,roleName:C,autoOpenCoverModal:v,openCoverRequestModal:T})=>!t||!c?null:e.jsx(zn,{open:b,anchorEl:t,showArrow:!0,stickToViewport:!0,placement:"left-end",children:e.jsx(nn,{onClickAway:_,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsx("div",{children:e.jsx(pL,{jobId:m,onClose:_,currentShiftDate:s,shiftId:E,isAdding:l,isOpenShift:u,isRoleOrDepartment:h,defaultTab:n,roleId:x,onShowTooltipForDelete:g,onShowTooltipForCopy:f,handlerId:a,startAt:S,endAt
1:o,color:y,roleName:C,autoOpenCoverModal:v,openCoverRequestModal:T})})})});D_.propTypes={anchorEl:d.object,date:d.string.isRequired,defaultTab:d.string,endAt:d.string,handlerId:d.string,isAdding:d.bool,isManager:d.bool,isOpenShift:d.bool,isRoleOrDepartment:d.bool,jobId:d.string,onClose:d.func.isRequired,onShowTooltipForCopy:d.func,onShowTooltipForDelete:d.func,open:d.bool,roleId:d.string,shiftId:d.string,startAt:d.string,autoOpenCoverModal:d.bool,openCoverRequestModal:d.bool};const Ns=F(t=>({isManager:He(t)}))(D_),k_={employee:Zp,timeOffBlackouts:s_,events:t_,openShifts:e_,preferred:n_},Zd="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='14'%20height='14'%20fill='none'%3e%3cpath%20fill='%23FFF0EE'%20d='M5%203h4v8H5z'/%3e%3cpath%20fill='%23D72505'%20stroke='%23FFF0EE'%20d='M2.93%202.132.8%205.873a2.28%202.28%200%200%200%200%202.256l2.128%203.739c.4.7%201.139%201.133%201.94%201.133h4.26c.806%200%201.542-.433%201.941-1.133l2.132-3.739c.399-.699.399-1.557%200-2.256l-2.129-3.739A2.24%202.24%200%200%200%209.132%201h-4.26c-.806%200-1.542.433-1.941%201.132Zm3.99%202.325c0-.056.041-.087.08-.087s.08.031.08.087v2.739c0%20.055-.041.087-.08.087s-.08-.032-.08-.087zM7%209.065c.145%200%20.272.12.272.283A.277.277%200%200%201%207%209.63a.277.277%200%200%201-.272-.282c0-.163.127-.283.272-.283Z'/%3e%3c/svg%3e",eu="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='14'%20height='14'%20fill='none'%3e%3cpath%20fill='%23FDF3E6'%20d='M6%208h3v3H6z'/%3e%3cpath%20fill='%23eb7f00'%20stroke='%23FDF3E6'%20d='m13.299%2010.522-.001-.001-4.999-8.53V1.99c-.576-.988-2.019-.985-2.597-.001L.706%2010.52v.002c-.587.998.151%202.229%201.296%202.229H12c1.142%200%201.88-1.229%201.299-2.228ZM6.938%204.938c0-.035.028-.063.062-.063s.063.029.063.063v3a.07.07%200%200%201-.02.048C7.03%207.998%207.021%208%207.02%208q-.004.002-.021-.006a.1.1%200%200%201-.04-.025c-.018-.018-.022-.03-.022-.033zM7%2010.25a.237.237%200%201%201%200-.474.237.237%200%200%201%200%20.474Z'/%3e%3c/svg%3e",tu="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='14'%20height='14'%20fill='none'%3e%3cpath%20fill='%23FDF3E6'%20d='M6%208h3v3H6z'/%3e%3cpath%20fill='%23C0490A'%20stroke='%23FDF3E6'%20d='m13.299%2010.522-.001-.001-4.999-8.53V1.99c-.576-.988-2.019-.985-2.597-.001L.706%2010.52v.002c-.587.998.151%202.229%201.296%202.229H12c1.142%200%201.88-1.229%201.299-2.228ZM6.938%204.938c0-.035.028-.063.062-.063s.063.029.063.063v3a.07.07%200%200%201-.02.048C7.03%207.998%207.021%208%207.02%208q-.004.002-.021-.006a.1.1%200%200%201-.04-.025c-.018-.018-.022-.03-.022-.033zM7%2010.25a.237.237%200%201%201%200-.474.237.237%200%200%201%200%20.474Z'/%3e%3c/svg%3e",su=["Critical","Warning","WarningSecondary"],Ms=r.forwardRef(({bcolor:t,bgcolor:s,bw:n=1,children:o,className:a,dataTestId:l,onClick:c,onContextMenu:u,oneLine:h,title:m,titleColor:_,titleIconName:f,titleIconColor:g,titleIconTooltip:b,titleIconTooltipPlacement:x,titleRightIconName:E,titleRightIconColor:S,titleRightIconTooltip:y,titleRightIconTooltipTrackingPayload:C,hasSmallGap:v,childLaborComplianceSettingsEnabled:T=!1,...D},L)=>{const A=K(),P=v?"4px":"12px",M=r.useCallback(()=>{C&&A(w.TOOLTIP_VIEWED,k.VIEW,C)},[A,C]);return e.jsxs(i,{className:a,bcolor:t,bgcolor:s,bradiuss:!0,bw:t?n:null,pv:2,ph:8,pl:8,pointer:!!c,row:h,gap:h?`0 ${P}`:0,column:!h,dataTestId:l,wrap:h,ref:L,onClick:c,onContextMenu:u,relative:!0,...D,children:[T&&E&&e.jsx(i,{absolute:!0,top:2,right:6,onMouseEnter:M,children:e.jsx(Ae,{content:y,children:su.includes(E)?e.jsx("img",{className:`FDBIcon--${E} icon`,src:new URL(Object.assign({"./images/Critical.min.svg":Zd,"./images/Warning.min.svg":eu,"./images/WarningSecondary.min.svg":tu})[`./images/${E}.min.svg`],import.meta.url).href}):e.jsx(Q,{iconName:E,color:S,size:"xsmall"})})}),m&&e.jsxs(i,{vcenter:!0,gap:4,row:!0,children:[f&&e.jsx(Ae,{content:b,placement:x,children:su.includes(f)?e.jsx("img",{className:`FDBIcon--${f} icon`,src:new URL(Object.assign({"./images/Critical.min.svg":Zd,"./images/Warning.min.svg":eu,"./images/WarningSecondary.min.svg":tu})[`./images/${f}.min.svg`],import.meta.url).href}):e.jsx(Q,{iconName:f,color:g,size:"xsmall"})}),e.jsx(j,{color:_,variant:"captionBold",noWrap:!0,children:m})]}),o]})});Ms.displayName="CellItem";const is="schedule_builder.react_page.time_off_blackout_form",_L=({isValid:t,isSubmitting:s,values:n,setFieldValue:o,isExisting:a,onDeleteTimeOffBlackout:l})=>{r.useEffect(()=>{gu(n.startDate,n.endDate)===1&&o("endDate",n.startDate)},[o,n.endDate,n.startDate]);const c=a?`${is}.edit_header`:`${is}.create_header`,u=Number(ho.zindexFdbReactModal)+1;return e.jsxs(Qs,{children:[e.jsx(i,{hcenter:!0,children:e.jsx(j,{variant:"heading2",color:"mono900",children:p(c)})}),e.jsxs(i,{mv:16,spaceevenly:!0,children:[e.jsx(i,{mr:16,children:e.jsx(i,{w:200,children:e.jsx(Tn,{label:p(`${is}
1.start_date`),hasAsterisk:!0,name:"startDate",blockDatesBefore:ms(),overrideZIndex:u})})}),e.jsx(i,{w:200,children:e.jsx(Tn,{label:p(`${is}.end_date`),hasAsterisk:!0,name:"endDate",blockDatesBefore:n.startDate?n.startDate:ms(),overrideZIndex:u})})]}),e.jsx(i,{ml:10,mb:54,maxw:430,children:e.jsx(ZE,{name:"employeesCount",label:p(`${is}.employees_count_desc`),hasAsterisk:!0,leftAlign:!0,places:0,helperText:p(`${is}.employees_count_warning`)})}),e.jsx(e.Fragment,{children:a?e.jsxs(i,{spacebetween:!0,ph:10,children:[e.jsx(V,{variant:"secondaryDestructive",loading:s,onClick:l,children:p(`${is}.delete_time_off_cta`)}),e.jsx(V,{type:"submit",loading:s,disabled:!t,children:p(`${is}.edit_time_off_cta`)})]}):e.jsx(i,{hcenter:!0,children:e.jsx(V,{type:"submit",loading:s,disabled:!t,children:p(`${is}.add_time_off_cta`)})})})]})},fL=r.memo(_L),bL=Cn().shape({employeesCount:eS().required().integer().min(0),startDate:ir().required(),endDate:ir().required().when("startDate",(t,s)=>t?s.min(t):s)}),R_=({onSubmit:t,onDeleteTimeOffBlackout:s,startDate:n,endDate:o,employeesCount:a,isExisting:l})=>{const c=r.useMemo(()=>({startDate:n||ms("YYYY-MM-DD"),endDate:o||ms("YYYY-MM-DD"),employeesCount:a!==void 0?a:3}),[n,o,a]),u=r.useCallback(h=>t(h),[t]);return e.jsx(Ht,{onSubmit:u,initialValues:c,validationSchema:bL,children:h=>e.jsx(fL,{...h,onDeleteTimeOffBlackout:s,isExisting:l})})};R_.propTypes={onSubmit:d.func.isRequired,onDeleteTimeOffBlackout:d.func.isRequired,isExisting:d.bool.isRequired};const{cx:gL}=O("TimeOffBlackoutFormModal"),L_=({onClose:t,isOpen:s,onCreateTimeOffBlackout:n,onUpdateTimeOffBlackout:o,onDeleteTimeOffBlackout:a,startDate:l,endDate:c,employeesCount:u,id:h})=>{const m=!!h,_=K({isEdit:m,eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_BLACKOUT_MODAL});r.useEffect(()=>{s&&_(w.TIME_OFF_BLACKOUT_MODAL_SHOWN,k.VIEW)},[s]);const f=r.useCallback(()=>{_(w.BUTTON_CLICKED,k.CLICK,{buttonText:"delete"}),a({id:h})},[_,a,h]),g=r.useCallback(()=>{_(w.TIME_OFF_BLACKOUT_MODAL_CLOSED,k.CLICK),t()},[_,t]),b=r.useCallback(x=>{m?_(w.BUTTON_CLICKED,k.CLICK,{buttonText:"save"}):_(w.ADD_TIME_OFF_BLACKOUT_CTA_CLICKED,k.CLICK),(m?o:n)({payload:x,id:h}),t()},[_,m,o,n,h,t]);return e.jsx(Fn,{auto:!0,isOpen:s,onRequestClose:g,children:e.jsx(i,{w:450,mb:12,className:gL(),children:e.jsx(R_,{startDate:l,endDate:c,employeesCount:u,onSubmit:b,onDeleteTimeOffBlackout:f,isExisting:m})})})};L_.propTypes={isOpen:d.bool.isRequired,onCreateTimeOffBlackout:d.func.isRequired,onDeleteTimeOffBlackout:d.func.isRequired,onUpdateTimeOffBlackout:d.func.isRequired,onClose:d.func.isRequired,startDate:d.string,endDate:d.string,employeesCount:d.number,id:d.string};const A_=F(null,{onCreateTimeOffBlackout:nS,onUpdateTimeOffBlackout:sS,onDeleteTimeOffBlackout:tS})(r.memo(L_)),{cx:xL}=O("BlackoutCellItem"),CL=({onClick:t})=>e.jsx(Ms,{bgcolor:"warning100",bcolor:"orange300",className:xL(),onClick:t,pointer:!!t,titleIconName:"WarningSecondary",titleIconColor:"warning300",title:p("schedule_builder.react_page.limited_time_off.title")}),O_=({blackoutId:t,endDate:s,employeesCount:n,isManager:o,startDate:a,isCopyPasteMode:l})=>{const c=K(),[u,h]=r.useState(!1),m=r.useCallback(()=>{u||c(w.TIME_OFF_BLACKOUT_CLICKED,k.CLICK),h(!u)},[c,u]);return e.jsxs(e.Fragment,{children:[e.jsx(CL,{onClick:o&&!l?m:null}),e.jsx(A_,{isOpen:u,onClose:m,mode:"update",startDate:a,endDate:s,employeesCount:n,id:t})]})};O_.propTypes={blackoutId:d.string.isRequired,startDate:d.string,endDate:d.string,employeesCount:d.number,isManager:d.bool,isCopyPasteMode:d.bool};const ec=F((t,s)=>({isManager:He(t),startDate:aS(t,s.blackoutId),endDate:oS(t,s.blackoutId),employeesCount:rS(t,s.blackoutId)}))(r.memo(O_)),ot="schedule_builder.react_page.events.form",EL=()=>{const t=K(),s=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{buttonText:p("schedule_builder.react_page.events.no_remaining_events.learn_more")})},[t]);return e.jsxs(i,{column:!0,children:[e.jsx(Y,{fs16:!0,fw600:!0,i18n:"schedule_builder.react_page.events.no_remaining_events.title"}),e.jsx(i,{mv:10,children:e.jsx(Y,{fs14:!0,fw600:!0,grayMediumDark:!0,i18n:"schedule_builder.react_page.events.no_remaining_events.content"})}),e.jsx(Dv,{fullWidth:!0,loadFullPage:!0,variant:"primary",onClick:s,children:p("schedule_builder.react_page.events.no_remaining_events.learn_more")})]})},SL=r.memo(EL),N_=({id:t,onDelete:s,isDeleting:n,isSubmitting:o,disableSubmit:a})=>e.jsx(i,{spacebetween:!0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(V,{variant:"primaryDestructive",startIcon:"Delete",onClick:s,loading:n,disabled:o,children:p(`${ot}.delete`)}),e.jsx(V,{loading:o,disabled:a,type:"submit",children:p(`${ot}.update`)})]}):e.jsx(V,{fullWidth:!0,startIcon:"Add",type:"submit",loading:o,disabled:a,children:p(`${ot}.add_title`)})});
1N_.propTypes={id:d.string,isDeleting:d.bool.isRequired,isSubmitting:d.bool.isRequired,disableSubmit:d.bool.isRequired,onDelete:d.func.isRequired};const jL=r.memo(N_),M_=({allowed:t,used:s})=>e.jsxs(i,{mb:10,children:[e.jsx(i,{mr:5,inlineBlock:!0,children:e.jsx(Y,{fs12:!0,i18n:`${ot}.has_remaining`,i18nProps:{used:s,allowed:t}})}),e.jsx(Mi,{size:"xs",children:p(`${ot}.learn_more`)})]});M_.propTypes={allowed:d.number,used:d.number};const yL=r.memo(M_),{cx:vL}=O("EventForm"),P_=({id:t,date:s,initialDate:n})=>e.jsxs(i,{mb:20,row:!0,vbottom:!0,children:[e.jsx(i,{mr:20,children:e.jsx(Y,{fs20:!0,fw600:!0,className:vL("title"),i18n:`${ot}.${t?"edit_title":"add_title"}`})}),n?e.jsx(Y,{fs14:!0,fw600:!0,grayDark:!0,children:Ie(s).format("ddd, MMM D")}):null]});P_.propTypes={id:d.string,date:d.string,initialDate:d.string};const IL=r.memo(P_),$_=({initialDate:t,date:s,holiday:n,onDateChange:o,onHolidayChange:a,isHolidaySettingEnabled:l})=>{const c=Number(ho.zindexFdbReactModal)+1;return e.jsxs("div",{children:[t?null:e.jsx(i,{mb:10,children:e.jsx(Tn,{label:p(`${ot}.date`),name:"date",hasAsterisk:!0,value:s?Qr(s):null,onChange:o,overrideZIndex:c})}),e.jsx(i,{mb:10,children:e.jsx(hr,{name:"title",label:p(`${ot}.title`),hasAsterisk:!0})}),e.jsx(i,{mb:20,children:e.jsx(hr,{name:"description",label:p(`${ot}.desc`),textArea:!0,minRows:3,maxRows:6})}),l&&e.jsx(i,{mb:20,row:!0,vtop:!0,children:e.jsx(Ct,{as:$v,name:"holiday",value:n,onChange:a,hideHtmlInput:!0,style:{position:"relative",top:"-8px",padding:0,color:n?null:Xl.grayMedium},label:e.jsxs(i,{column:!0,children:[e.jsx(i,{mb:1,children:e.jsx(Y,{fw600:!0,fs14:!0,navyLight:!0,i18n:`${ot}.mark_as_holiday_label`})}),e.jsxs(Y,{fs14:!0,grayMediumDark:!0,children:[p(`${ot}.mark_as_holiday_desc`)," ",e.jsx(Nt,{component:la,to:"/settings/time_tracking/overtime",size:"small",allowWrap:!0,children:p(`${ot}.settings`)})]})]})})})]})};$_.propTypes={initialDate:d.string,date:d.string,title:d.string,description:d.string,holiday:d.bool,isHolidaySettingEnabled:d.bool,onDateChange:d.func.isRequired,onHolidayChange:d.func.isRequired};const TL=r.memo($_),tc=({isEdit:t,unlimited:s,allowed:n,used:o})=>t?!1:!s&&(!n||o>=n),wL=({isEdit:t,unlimited:s,allowed:n,used:o})=>t||s?!1:!s&&n-o===1,{cx:DL}=O("EventForm"),B_=({allowed:t,used:s,unlimited:n,onDelete:o,values:a,setFieldValue:l,isSubmitting:c,initialDate:u,isDeleting:h,isValid:m,isHolidaySettingEnabled:_})=>{const{id:f,date:g,holiday:b}=a,x=r.useCallback(C=>{const v=C.target.value;l("date",v?Oe(v,"parsable_date"):null)},[l]),E=r.useCallback(C=>{l("holiday",C)},[l]),S=h||!m,y=!tc({unlimited:n,allowed:t,used:s,isEdit:!!f});return e.jsx(Qs,{style:{margin:0},children:e.jsx(i,{relative:!0,className:DL(),w:"100%",borderbox:!0,children:y?e.jsxs(e.Fragment,{children:[e.jsx(IL,{id:f,date:g,initialDate:u}),!n&&e.jsx(yL,{allowed:t,used:s}),e.jsx(TL,{initialDate:u,date:g,holiday:b,onDateChange:x,onHolidayChange:E,isHolidaySettingEnabled:_}),e.jsx(i,{mt:30,children:e.jsx(jL,{id:f,onDelete:o,isDeleting:h,isSubmitting:c,disableSubmit:S})})]}):e.jsx(SL,{})})})};B_.propTypes={id:d.string,initialDate:d.string,title:d.string,description:d.string,holiday:d.bool,unlimited:d.bool.isRequired,isHolidaySettingEnabled:d.bool,allowed:d.number,used:d.number,onDelete:d.func,onClose:d.func,values:d.object.isRequired,setFieldValue:d.func.isRequired,isSubmitting:d.bool.isRequired,isDeleting:d.bool.isRequired};const kL=r.memo(B_),sc=({id:t,date:s,title:n,description:o,holiday:a,isHolidaySettingEnabled:l,allowed:c,used:u,unlimited:h,onDeleteEvent:m,onClose:_,onCreateEvent:f,onUpdateEvent:g,showCreateBanner:b,onShowReadonlyModal:x})=>{const E=K(),S=K({eventCategory:U.SCHEDULE_BUILDER_EVENT_DELETE_MODAL}),[y,C]=r.useState(!1),v=X(),T=r.useCallback(({title:A,date:P})=>{const M={};return A?.trim()||(M.no_title=!0),!s&&!P&&(M.no_date=!0),M},[s]),D=r.useCallback(A=>{E(t?w.SAVE_EVENT_CTA_CLICKED:w.ADD_EVENT_CTA_CLICKED,k.CLICK);const P=wL({isEdit:!!t,unlimited:h,allowed:c,used:u});return(t?g({id:t,payload:A}):f({payload:A})).then(()=>{_(),P&&E(w.EVENTS_QUOTA_LIMIT_REACHED,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER}),b&&(E(w.ADD_EVENT_SUCCESS_BANNER,k.VIEW,{eventCategory:ae.SCHEDULE_BUILDER}),x({text:p(`${ot}.event_created`),persist:!1,timeoutDelay:4e3}))})},[E,t,h,c,u,g,f,_,b,x]),L=r.useCallback(()=>{E(w.BUTTON_CLICKED,k.CLICK,{buttonText:Rn.DELETE}),_(),v(dS({title:p(`${ot}.delete_title`),message:p(`${ot}.confirm_message`),submitText:p(`${ot}.approve`),cancelText:p(`${ot}.reject`),onShow:()=>S(w.DELETE_CONFIRMATION_MODAL_SHOWN,k.VIEW),onConfirm:()=>{S(w.BUTTON_CLICKED,k.CLICK,{buttonText:"yes"}),C(!0),m({id:t}).then(()=>{_()}).finally(()=>{C(!1)})},onCancel:()=>S(w.BUTTON_CLICKED,k.CLICK,{buttonText:"no"}),onDismiss:()=>S(w.DISMISS_CLICKED,k.CLICK)}))},[E,S,v,m,t,_]);return e.jsx(Ht,{validateOnMount:!0,initialValues:{id:t,date:s||ms("MM/DD/YYYY"),title:n,description:o,holiday:a}
1,onSubmit:D,validate:T,children:A=>e.jsx(kL,{...A,unlimited:h,allowed:c,used:u,onDelete:L,initialDate:s,isDeleting:y,isHolidaySettingEnabled:l})})};sc.defaultProps={id:"",date:"",title:"",description:"",holiday:!1,unlimited:!1,isHolidaySettingEnabled:!1,showCreateBanner:!1,onClose:()=>{}};sc.propTypes={id:d.string,date:d.string,title:d.string,description:d.string,holiday:d.bool,unlimited:d.bool,showCreateBanner:d.bool,isHolidaySettingEnabled:d.bool,allowed:d.number,used:d.number,onCreateEvent:d.func,onUpdateEvent:d.func,onDeleteEvent:d.func,onClose:d.func};const U_=F((t,s)=>{const{allowed:n,used:o,unlimited:a}=zi(t,s);return{allowed:n,used:o,unlimited:s.unlimited??a,title:Is({state:t,attribute:"title",eventId:s.id}),description:Is({state:t,attribute:"description",eventId:s.id}),holiday:Is({state:t,attribute:"holiday",eventId:s.id}),isHolidaySettingEnabled:Dn({state:t,attribute:"isHolidaySettingEnabled",id:ct(t)})}},{onCreateEvent:cS,onUpdateEvent:iS,onDeleteEvent:lS,onShowReadonlyModal:zo})(r.memo(sc)),H_=({date:t,title:s,description:n})=>e.jsxs(i,{column:!0,gap:20,children:[e.jsx(Y,{grayDark:!0,fs14:!0,fw600:!0,text:xu(t)}),e.jsxs(i,{column:!0,children:[e.jsx(Y,{fs14:!0,fw600:!0,grayDark:!0,i18n:`${ot}.title`}),e.jsx(Y,{fs16:!0,navyLight:!0,text:s})]}),!!n&&e.jsxs(i,{column:!0,children:[e.jsx(Y,{fs14:!0,fw600:!0,grayDark:!0,i18n:`${ot}.desc`}),e.jsx(Y,{fs16:!0,navyLight:!0,text:n})]})]});H_.propTypes={id:d.string.isRequired,date:d.string.isRequired,title:d.string.isRequired,description:d.string};const RL=F((t,s)=>({date:Is({state:t,attribute:"date",eventId:s.id}),title:Is({state:t,attribute:"title",eventId:s.id}),description:Is({state:t,attribute:"description",eventId:s.id})}),null)(H_),{cx:LL}=O("EventFormPopover"),F_=({id:t,isEmployee:s,anchorEl:n,open:o,onClose:a,date:l,unlimited:c,allowed:u,used:h,isAdding:m})=>{const _=K();r.useEffect(()=>{o&&_(w.ADD_EVENT_MODAL_SHOWN,k.VIEW,{isEdit:!!t,eventPaywallShown:tc({unlimited:c,allowed:u,used:h,isEdit:!!t})})},[o]);const f=r.useCallback(g=>{g.target.type||_(w.ADD_EVENT_MODAL_CLOSED,k.CLICK),a(g)},[_,a]);return o?e.jsx(zn,{showArrow:!0,open:o,anchorEl:n,children:e.jsx(nn,{onClickAway:f,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsxs("div",{children:[e.jsx(i,{absolute:!0,top:12,right:12,children:e.jsx(om,{onClick:f})}),e.jsx(i,{p:25,className:LL(),bgcolor:"mono0",bcolor:"mono300",bradiuss:!0,shadow:"z2",w:310,children:s?e.jsx(RL,{id:t}):e.jsx(U_,{id:m?null:t,date:l,onClose:a})})]})})}):null};F_.propTypes={children:d.object,id:d.string,date:d.string,allowed:d.number,used:d.number,unlimited:d.bool,onSubmit:d.func,onDelete:d.func,isEmployee:d.bool,isAdding:d.bool};const W_=F((t,s)=>{const{allowed:n,used:o,unlimited:a}=zi(t,s);return{allowed:n,used:o,unlimited:a,isEmployee:!He(t)}},null)(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_ADD_EVENT_MODAL})(F_))),{cx:AL}=O("EventItem"),OL=10,nu=({title:t,selected:s,onClick:n})=>e.jsx(Ms,{bw:s?2:1,className:AL(),onClick:n,titleIconName:"Calendar",titleIconColor:"mono900",title:t}),V_=({title:t,eventId:s,date:n})=>{const[o,a]=r.useState(null),l=r.useCallback(()=>{a(null)},[]),c=r.useCallback(u=>{u.stopPropagation(),a(u.currentTarget)},[]);return e.jsxs(e.Fragment,{children:[t.length>OL?e.jsx(Ae,{content:t,open:o?!1:void 0,children:e.jsx(nu,{title:t,onClick:c,selected:!!o})}):e.jsx(nu,{title:t,onClick:c,selected:!!o}),!!o&&e.jsx(W_,{id:s,date:n,anchorEl:o,open:!!o,onClose:l})]})};V_.propTypes={eventId:d.string.isRequired,title:d.string.isRequired,date:d.string.isRequired,isManager:d.bool};const nc=F((t,s)=>({title:Is({state:t,attribute:"title",eventId:s.eventId}),date:Is({state:t,attribute:"date",eventId:s.eventId}),isManager:He(t)}),{})(r.memo(ut({triggeredFrom:Rn.EVENT})(V_))),{cx:NL,cxEl:ML}=O("MultilocationPopper"),K_=({anchorEl:t,isManager:s,isOpen:n,locationIdsForUser:o,onClose:a,roleName:l,shiftId:c,shiftLocationId:u,shiftLocationName:h,timeRange:m,userAvatar:_,userName:f})=>{const g=r.useCallback(()=>{a(),at("shiftSelectedScroll",c),uS(u)},[a,c,u]);return t&&s?e.jsx(zn,{open:n,anchorEl:t,showArrow:!0,placement:"left",children:e.jsx(nn,{onClickAway:a,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsx("div",{children:e.jsxs(i,{className:NL(),w:394,p:25,bgcolor:"mono0",bradiusm:!0,children:[e.jsxs(i,{mb:15,children:[e.jsxs(i,{vcenter:!0,children:[e.jsx(Un,{size:"medium",image:_}),e.jsx(i,{column:!0,pl:8,children:e.jsx(i,{children:e.jsx(j,{variant:"body",color:"mono900",children:f})})})]}),e.jsx(i,{ml:40,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:m})}),e.jsx(i,{absolute:!0,top:16,right:16,children:e.jsx(be,{onClick:a,icon:"Close",dataTestId:"close-shift-modal",size:"small",label:p("schedule_builder.actions.close")})})]}),e.jsx(gn,{}),e.jsxs(i,{children:[e.jsx(i,{mt:16,children:e.jsx(j,{variant:"body",color:"mono900",children:l})}),e.jsx(i,{mt:16,children:e.jsx(j,{variant:"bodyBold",color:"mono900",children:h})}),o.includes(u)&&e.jsxs(i,{mt:48,left:192,hcenter:!0,pointer:!0,vcenter:!0,onClick:g,children:[e.jsx(i,{className:ML("shift-link"),children:e.jsx(j,{variant:"bodyBold",color:"purple500",children:p("schedule_builder.react_page.multilocation.view_shift_at_location")})}),e.jsx(i,{ml:8,children:e.jsx(Q,{iconName:"ArrowRight",size:"medium",color:"purple500"})})]})]})]})})})}):null};
1K_.propTypes={anchorEl:d.object,isManager:d.bool,isOpen:d.bool,locationIdsForUser:d.array,onClose:d.func.isRequired,roleName:d.string,shiftId:d.string,shiftLocationId:d.string,shiftLocationName:d.string,timeRange:d.string,userAvatar:d.string,userName:d.string};const PL=F((t,s)=>({isManager:He(t),userAvatar:Cr({state:t,attribute:"avatar",userId:s.userId})}))(K_),$L="schedule_builder.react_page.edit_shift_popup.sync_error",Jr={conflict:{iconName:"Critical",iconColor:"red300",titleColor:void 0},partnerError:{iconName:"Warning",iconColor:"warning300"},openWithRequests:{iconTooltip:p("schedule_builder.react_page.shifts.tooltips.claim_request")},openNoRequests:{iconTooltip:p("schedule_builder.react_page.shifts.tooltips.open_shift")},overtime:{iconName:"Overtime",iconColor:void 0,titleColor:void 0,iconTooltip:p("schedule_builder.react_page.shifts.tooltips.overtime")},overnight:{iconName:"Overnight",iconColor:void 0,titleColor:void 0,iconTooltip:p("schedule_builder.react_page.shifts.tooltips.overnight")}},BL=({conflictType:t,hasOvertime:s,isOvernight:n,syncError:o,userName:a})=>{const l={iconName:void 0,iconColor:void 0,titleColor:void 0,iconTooltip:void 0};return o?{...Jr.partnerError,iconTooltip:p($L+`.${o}.tooltip_message`)}:t?{...Jr.conflict,iconTooltip:p(`schedule_builder.react_page.shifts.tooltips.${t}_conflict`,{props:{name:a}})}:s?Jr.overtime:n?Jr.overnight:l},q_=({noUserName:t,userName:s,isOpenShift:n})=>{if(!(t&&!n))return n?p(`${gl}.open`):s},z_=({noUserName:t,roleName:s,isOpenShift:n})=>{if(t&&!n)return s||p(`${gl}.no_role`);if(t&&n)return`(${s||p(`${gl}.no_role`)})`;if(s)return`(${s})`},UL=({hasShiftRequests:t,event_name:s})=>t&&s!=="undefined"?`${Ir(s==="open_shift"?"open shift":s)} approved`:"Shift Approved",HL=({coverStatus:t,tradeStatus:s,claimStatus:n})=>{const o=[t,s,n].filter(l=>!!(l&&Ma[l]));return o.length===0?null:o.length===1?o[0]:o.sort((l,c)=>{const u=Ma[l]??1/0,h=Ma[c]??1/0;if(u!==h)return u-h;const m=l.includes("cover"),_=c.includes("cover");return Number(_)-Number(m)}
1)[0]},{cx:FL,cxEl:WL}=O("MultilocationShiftItem"),VL=({endAt:t,isOpen:s,hasNote:n,noUserName:o,onClick:a,roleName:l,shiftId:c,shiftLocationName:u,startAt:h,userName:m})=>{const{rangeType:_}=ze(),f=p("schedule_builder.react_page.multilocation.tooltip",{props:{location_name:u}}),g=q_({noUserName:o,userName:m}),b=z_({noUserName:o,roleName:l}),x=_===J.month||_===J.custom?g:b;return e.jsxs(Ms,{className:FL(),bgcolor:"mono300",dataTestId:WL(c),onClick:a,shiftLocationName:u,titleIconTooltip:f,titleIconName:"Location",titleIconColor:"mono700",titleIconTooltipPlacement:"top",title:u,children:[e.jsxs(i,{style:{display:_===J.day?"flex":"block"},vcenter:!0,children:[e.jsx(i,{pr:16,children:e.jsx(j,{variant:"captions",children:Ut(h,t)})}),e.jsxs(i,{vcenter:!0,children:[n&&e.jsx(i,{pointer:!0,"data-testid":"ShiftItem__shift-notes",children:e.jsx(Ae,{content:p("schedule_builder.react_page.shifts.tooltips.shift_note"),children:e.jsx(Q,{iconName:"Document",color:"purple500",size:"xsmall"})})}),x&&e.jsx(i,{ellipsis:!0,ml:n?4:0,children:e.jsx(j,{noWrap:!0,variant:"captions",children:x})})]})]}),x!==b&&e.jsx(i,{ellipsis:!0,children:e.jsx(j,{noWrap:!0,variant:"captions",color:l?"mono900":"mono700",children:b})})]})},G_=({endAt:t,isOpen:s,hasNote:n,locationIdsForUser:o,noUserName:a,roleName:l,shiftId:c,shiftLocationId:u,shiftLocationName:h,startAt:m,userId:_,userName:f})=>{const g=r.useRef(null),[b,x]=r.useState(!1),E=r.useCallback(()=>{x(!0)},[]),S=r.useCallback(()=>{x(!1)},[]);return e.jsxs("div",{ref:g,children:[e.jsx(VL,{endAt:t,isOpen:s,hasNote:n,noUserName:a,onClick:E,roleName:l,shiftId:c,shiftLocationName:h,startAt:m,userName:f}),b&&e.jsx(PL,{anchorEl:g.current,isOpen:b,locationIdsForUser:o,onClose:S,roleName:l,shiftId:c,shiftLocationId:u,shiftLocationName:h,timeRange:Ut(m,t),userId:_,userName:f})]})};G_.propTypes={endAt:d.string,hasNote:d.bool,isOpen:d.bool,roleName:d.string,shiftId:d.string,shiftLocationId:d.string,shiftLocationName:d.string,startAt:d.string,userId:d.string,userName:d.string};const Y_=F((t,s)=>{const n=vs({state:t,id:s.shiftId,relationship:"owner"})?.id,o=wt({state:t,relationship:"location",id:n});return{endAt:Se({state:t,id:s.shiftId,attribute:"endAt"}),hasNote:!!Se({state:t,id:s.shiftId,attribute:"note"}),isOpen:Se({state:t,id:s.shiftId,attribute:"isOpen"}),roleName:Se({state:t,id:s.shiftId,attribute:"roleName"}),shiftLocationId:o,shiftLocationName:Dn({state:t,attribute:"name",id:o}),startAt:Se({state:t,id:s.shiftId,attribute:"startAt"}),userId:wt({state:t,relationship:"user",id:n}),userName:Ti(t,s.shiftId)}},{})(r.memo(ut({triggeredFrom:Rn.EVENT})(G_))),Tl="schedule_builder.react_page.availability",KL=({noEmployeeName:t,isFullDay:s})=>{let n=p(`${Tl}.preferred.title`);return s&&!t&&(n=`${n} (${p(`${Tl}.all_day`)})`),n},qL=({noEmployeeName:t,isFullDay:s,employeeName:n,timeRange:o})=>s?t?p(`${Tl}.all_day`):n:o,{cx:zL}=O("PreferredItem"),J_=({allDay:t,startAt:s,endAt:n,employeeName:o,noEmployeeName:a,jobId:l,date:c,isManager:u})=>{const{rangeType:h}=ze(),m=h===J.day,[_,f]=r.useState(null),g=r.useCallback(()=>{f(null)},[]),b=r.useCallback(x=>{f(x.currentTarget)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{className:zL({dayView:m}),onClick:u?b:null,children:[e.jsxs(i,{relative:!0,children:[e.jsx(j,{variant:"captionBold",color:"mono700",children:KL({noEmployeeName:a,isFullDay:t})}),!m&&e.jsx(i,{absolute:!0,top:-6,right:0,children:e.jsx(be,{icon:"Add",size:"small",label:p("schedule_builder.actions.add_shift")})})]}),e.jsx(i,{children:e.jsx(j,{variant:"captions",color:"mono700",capitalize:!0,children:qL({noEmployeeName:a,isFullDay:t,timeRange:Ut(s,n),employeeName:o})})}),!a&&!t&&e.jsx(i,{children:e.jsx(j,{variant:"captions",color:"mono700",children:o})})]}),!!_&&e.jsx(Ns,{isAdding:!0,jobId:l,open:!!_,anchorEl:_,onClose:g,date:c,startAt:m&&!t?Oe(s,"time"):void 0,endAt:m&&!t?Oe(n,"time"):void 0})]})};J_.propTypes={id:d.string.isRequired,employeeName:d.string,allDay:d.bool,startAt:d.string,endAt:d.string,noEmployeeName:d.bool,isManager:d.bool};const X_=F((t,s)=>{const n=Si({state:t,relationship:"job",id:s.id});return{jobId:n,allDay:Hs({state:t,attribute:"allDay",id:s.id}),startAt:Hs({state:t,attribute:"startAt",id:s.id}),endAt:Hs({state:t,attribute:"endAt",id:s.id}),date:Hs({state:t,attribute:"date",id:s.id}),employeeName:ia(t,n),isManager:He(t)}})(r.memo(J_)),Ja="schedule_builder.react_page.employee_shift_modal",Xa="schedule_builder.react_page.employee_shift_modal.shift_note",Qa="schedule_builder.react_page.claim_shift",Q_=({author:t,createdAt:s,endAt
1:n,isHubAccount:o,isOpen:a,isOpenShift:l,onClaimShift:c,onClose:u,onShowReadonlyModal:h,roleName:m,shiftId:_,startAt:f,text:g})=>{const[b,x]=r.useState(0),[E,S]=r.useState(0),[y,C]=r.useState(!0),v=A=>tg(`/schedule_builder/labor/${A}/open_shift_totals`),T=r.useCallback(()=>{o||v(_).then(A=>{const{hours:P,cost:M}=A?.data?.attributes||{};x(P||0),S(M||0)}).finally(()=>{C(!1)})},[o,_]);r.useEffect(()=>{l&&T()},[l,T]);const D=r.useCallback(()=>c(_).then(A=>{h({text:A?.payload||p(`${Qa}.request_sent`),persist:!1,timeoutDelay:5e3}),u()}),[_,c,h,u]),L=l?`${Ja}.open_shift`:`${Ja}.shift_details`;return e.jsx(Mt,{title:p(L),width:460,open:a,onClose:u,buttons:[{label:p(`${Ja}.done`),variant:"primary",onClick:()=>u()}],children:()=>e.jsxs(i,{children:[e.jsxs(i,{children:[e.jsx(j,{variant:"bodySmBold",color:"mono700",children:Gb(f)}),e.jsx(j,{variant:"bodyBold",children:Ut(f,n)}),e.jsx(j,{children:m})]}),e.jsx(i,{mt:24,children:g?e.jsxs(i,{"data-testid":"shiftNote",children:[e.jsx(j,{variant:"bodySmBold",color:"mono700",children:p(`${Xa}.title`)}),e.jsx(j,{children:g}),e.jsx(j,{variant:"captions",children:p(`${Xa}.created_details`,{props:{author:t,date:Oe(s,"pretty_no_year_short")}})})]}):e.jsx(i,{"data-testid":"noShiftNote",children:e.jsx(j,{variant:"bodySmBold",color:"mono700",children:p(`${Xa}.unavailable`)})})}),l&&!o&&e.jsxs(i,{"data-testid":"claimRequestSection",hcenter:!0,column:!0,mt:24,gap:8,children:[e.jsx(V,{variant:"secondary",fullWidth:!0,onClick:D,children:p(`${Qa}.button`)}),y?e.jsx(da,{type:"grayBar"}):e.jsx(j,{variant:"captionBold",color:"mono700",children:p(`${Qa}.details`,{props:{wage:pt(E),hours:b.toFixed(2)}})})]})]})})};Q_.propTypes={author:d.string,createdAt:d.string,endAt:d.string,id:d.string.isRequired,isHubAccount:d.bool,isOpen:d.bool,isOpenShift:d.bool,onClaimShift:d.func,onClose:d.func,onShowReadonlyModal:d.func,roleName:d.string,shiftId:d.string,startAt:d.string,text:d.string};const GL=F((t,s)=>{const n=vs({state:t,id:s.id,relationship:"note"})?.id,o=ca(t,n);return{shiftId:s.id,text:o?.text,author:o?.author,createdAt:o?.createdAt,isLoading:wi(t),isHubAccount:am(t)}},{onClaimShift:hS,onShowReadonlyModal:zo})(r.memo(Q_));function YL({id:t,date:s,roleName:n,color:o,note:a,owner:l,from:c,to:u,startAt:h,endAt:m,disabled:_=!1}){const f={type:Xs.SHIFT,id:t,date:s,roleName:n,color:o,note:a,owner:l,from:c,to:u,startAt:h,endAt:m},{setNodeRef:g,isDragging:b,attributes:x,listeners:E}=rh({id:`shift-${t}`,disabled:_,data:f});return{isDragging:b,setNodeRef:g,attributes:x,listeners:E}}const{cx:JL,cxEl:XL}=O("ShiftItem"),Z_=r.memo(({isColorMappingV1:t,shiftId:s,isPublished:n,color:o,roleName:a,selected:l,onClick:c,onContextMenu:u,userName:h,conflictType:m,childLaborViolationMessage:_,titleRightIconTooltipTrackingPayload:f,isOpenShift:g,hasShiftRequests:b,coverRequestIndicator:x,tradeRequestIndicator:E,shiftClaimIndicator:S,eventName:y,hasOvertime:C,isManager:v,note:T,startAt:D,endAt:L,noUserName:A,hasNote:P,onClickNotes:M,noConflict:R,oneLine:$,isRoleOrDepartment:B,rangeType:W,shiftSyncError:N,childLaborComplianceSettingsEnabled:H,isDragging:q})=>{const{iconColor:G,iconName:re,iconTooltip:ue,titleColor:je}=BL({conflictType:m,hasOvertime:C,isOvernight:ji(D,L),syncError:N,userName:h}),ce=q_({noUserName:A,isOpenShift:g,userName:h}),oe=z_({noUserName:A,isOpenShift:g,roleName:a}),ge=UL({hasShiftRequests:b,event_name:y?y.event_name:void 0}),te=r.useMemo(()=>HL({coverStatus:x,tradeStatus:E,claimStatus:S}),[x,E,S]),Z=bS[te]||"",ee=W===J.month||W===J.custom||B?ce:oe,he=n?ao(t,o):xi.purple900;return e.jsx(Ms,{className:JL({[`${t?`${o}`:`${o}-v2`}`]:!0,[`${ao(t,o)}`]:!0,published:n,unpublished:!n,hasRole:!!a,selected:l,noConflict:R,hasConflict:!!m,isDragging:q}),dataTestId:XL(s),onClick:c,onContextMenu:u,oneLine:$,title:`${Ut(D,L)}`,titleColor:je,titleIconName:re,titleIconTooltip:ue,titleIconColor:G,titleRightIconName:_?"Warning":void 0,titleRightIconTooltip:_||void 0,titleRightIconTooltipTrackingPayload:f,childLaborComplianceSettingsEnabled:H,children:e.jsxs(i,{ellipsis:!0,row:!0,wrap:!0,children:[(P||ee)&&e.jsxs(i,{vcenter:!0,ellipsis:!0,mr:10,children:[P&&e.jsx(i,{onClick:M,pointer:!0,"data-testid":"ShiftItem__shift-notes",children:e.jsx(Ae,{content:T,children:e.jsx(Q,{iconName:"Document",color:he,size:"xsmall"})})}),ee&&e.jsx(i,{ellipsis:!0,ml:P?4:0,children:e.jsx(j,{noWrap:!0,variant:"captions",children:ee})})]}),ee!==oe&&!B&&e.jsx(i,{ellipsis:!0,mr:10,children:e.jsx(j,{noWrap:!0,variant:"captions",color:a?he:"mono700",children:oe})}),v&&te&&e.jsxs(i,{flex:!0,gap:5,vcenter:!0,ellipsis:!0,children:[[Bs.seeking_cover,Bs.seeking_trade,Bs.seeking_claim].includes(te)&&e.jsx(Q,{iconName:"Refresh",color:he,size:"xsmall"}),[Bs.pending_approval,Bs.pending_approval_open_shift].includes(te)&&e.jsx(Q,{iconName:"Warning",color:he,size:"xsmall"}),e.jsx(j,{noWrap:!0,variant:"captions",color:he,children:Z})]}),v&&b&&!te&&e.jsx(i,{ellipsis:!0,children:e.jsx(j,{noWrap:!0,variant:"captions",color:he,children:ge})})]})})});Z_.displayName="ShiftItemContent";const QL=({isColorMappingV1:t,shiftId:s,isPublished:n,color:o,currentLocationId:a,roleName:l,selected:c,onClick:u,onContextMenu:h,userName:m,conflictType:_,childLaborViolationMessage:f,titleRightIconTooltipTrackingPayload:g,isOpenShift:b,jobId:x,hasShiftRequests:E,coverRequestIndicator:S,tradeRequestIndicator:y,shiftClaimIndicator:C,eventName:v,hasOvertime:T,isManager:D,note:L,startAt:A,endAt:P,noUserName:M,hasNote:R,onClickNotes:$,noConflict:B,oneLine:W,isRoleOrDepartment:N,rangeType:H,shiftSyncError:q,childLaborComplianceSettingsEnabled:G,disableDrag:re=!1})=>{const ue=r.useMemo(()=>b?{type:"location",id:a}:{type:"job",id:x},[b,x,a]),{isDragging:je,setNodeRef:ce,attributes:oe,listeners:ge}=YL({id:s,date:null,roleName:l,color:o,note:L,owner:ue,from:no(A),to:no(P),startAt:A,endAt:P,disabled:re});return e.jsx("div",{ref:D?ce:void 0,...D?oe:{},...D?ge:{},children:e.jsx(Z_,{isColorMappingV1:t,shiftId:s,isPublished:n,color:o,roleName:l,selected:c,onClick:u,onContextMenu:h,userName:m,conflictType:_,childLaborViolationMessage:f,titleRightIconTooltipTrackingPayload:g,isOpenShift:b,hasShiftRequests:E,coverRequestIndicator:S,tradeRequestIndicator:y,shiftClaimIndicator:C,eventName:v,hasOvertime:T,isManager:D,note:L,startAt:A,endAt:P,noUserName:M,hasNote:R,onClickNotes:$,noConflict:B,oneLine:W,isRoleOrDepartment:N,rangeType:H,shiftSyncError:q,isDragging:je,childLaborComplianceSettingsEnabled:G})})},ef=({color:t,isColorMappingV1:s,conflictType:n,currentLocationId:o,endAt:a,hasShiftRequests:l,coverRequestIndicator:c,tradeRequestIndicator:u,shiftClaimIndicator:h,eventName:m,hasTimecard:_,hasOvertime:f,isOpenShift:g,isPublished:b,note:x,roleName:E,startAt:S,shiftId:y,userName:C,ownerId:v,roleId:T,isCopyPasteMode:D,onDelete:L,onCopy:A,noUserName:P,isManager:M,noConflict:R,oneLine:$,handleShowTooltipForDelete:B,hasSeenToolTip:W,createOTE:N,handlerId:H,isRoleOrDepartment:q,hasNote:G,showClaimModal:re=!1,shiftSyncError:ue,findCoverShiftId:je,disableDrag:ce=!1,childLaborViolationData:oe,userIdByShiftId:ge})=>{const te=K(),{rangeType:Z}=ze(),ee=r.useMemo(()=>
1{if(oe)return{element:"compliance_warning",shift_id:y,employee_id:ge,violation_type:oe.violationTypes?.length>0?oe.violationTypes.join(","):void 0}},[y,oe,ge]),he=I(Gh),Ye=I(_s),De=r.useRef(null),[Pe,ke]=r.useState(!1),[me,Fe]=r.useState(!1),[We,Xe]=r.useState(null),[se,Ne]=r.useState(!1),[ye,Ve]=r.useState(!1),$e=je===y,[Ee,Re]=r.useState(!1);r.useEffect(()=>{$e&&ke(!0)},[$e,y]),r.useEffect(()=>{De.current&&ts("shiftSelectedScroll")===y&&(De.current.scrollIntoView({behavior:"smooth",block:"center"}),ke(!0),at("shiftSelectedScroll",null)),re&&ke(re)},[De,y,re]);const Me=g?null:v,we=r.useCallback(()=>{Fe(!1)},[]),Ke=r.useCallback(()=>{te(w.COPY_SHIFT_CLICKED,k.CLICK),we(),A(y)},[y,we,te,A]),Qe=r.useCallback(()=>{te(w.DELETE_SHIFT_CLICKED,k.CLICK),we(),L({id:y})},[y,te,we,L]),Ze=r.useCallback(()=>{te(w.BUTTON_CLICKED,k.CLICK,{buttonText:"Find a cover",element:"find_cover_initiate",buttonAction:"initiate_cover_request",buttonLocation:"shift_context_menu",eventCategory:U.INITIATE_FIND_COVER_REQUEST}),we(),Re(!0),ke(!0)},[te,we]),et=c_(y,S,b,c),tt=r.useMemo(()=>{const Ce=[];return Z!==J.day&&Ce.push([{label:p("schedule_builder.react_page.shift_context_menu.copy"),iconName:"Copy",onClick:Ke}]),he&&et&&Ce.push([{label:p("schedule_builder.smart_covers.submit_cta"),iconName:"List",onClick:Ze}]),_||Ce.push([{label:p("schedule_builder.react_page.shift_context_menu.delete"),iconName:"Delete",redText:!0,onClick:Qe}]),Ce},[_,Qe,Ke,Z,he,et,Ze]),st=r.useMemo(()=>Oe(S,"parsable_reversed"),[S]),nt=r.useCallback(Ce=>{Ce.preventDefault(),Fe(!0)},[]),Be=r.useCallback(Ce=>{D||(Ce.preventDefault(),Ce.stopPropagation(),te(w.EDIT_SHIFT_CLICKED,k.CLICK),ke(!0))},[D,te]),ve=r.useCallback(Ce=>{te(w.BUTTON_CLICKED,k.CLICK),Xe(ys.NOTES),Be(Ce)},[te,Be]),xt=r.useCallback(()=>{ke(!1),Xe(null),Re(!1)},[]),ne=r.useCallback(()=>{Ne(!0)},[]),_e=r.useCallback(()=>{Ne(!1),N("sb_right_click_tooltip_shown")},[N]),xe=r.useCallback(()=>{(G||g)&&Ve(Ce=>!Ce)},[G,g]);return e.jsxs("div",{ref:De,children:[e.jsx(Ae,{placement:"left",open:se&&!W,variant:"primary",title:p("schedule_builder.react_page.shifts.tooltips.right_click.title"),content:p("schedule_builder.react_page.shifts.tooltips.right_click.desc"),buttonTitle:p("schedule_builder.react_page.shifts.tooltips.right_click.cta"),onDismissClick:_e,onButtonClick:_e,children:e.jsx(QL,{shiftId:y,color:t,isColorMappingV1:s,currentLocationId:o,isPublished:b,jobId:Me,selected:Pe||me,hasOvertime:f,isManager:M,note:x,roleName:E,onClick:M?Be:xe,onContextMenu:!D&&M?nt:null,onClickNotes:ve,userName:C,conflictType:n,childLaborViolationMessage:oe?.message,titleRightIconTooltipTrackingPayload:ee,isOpenShift:g,hasShiftRequests:l,coverRequestIndicator:c,tradeRequestIndicator:u,shiftClaimIndicator:h,eventName:m,startAt:S,endAt
1:a,noUserName:P,hasNote:G||!!x,noConflict:R,oneLine:$,isRoleOrDepartment:q,rangeType:Z,shiftSyncError:ue,disableDrag:ce,childLaborComplianceSettingsEnabled:Ye})}),Pe&&e.jsx(Ns,{anchorEl:De.current,shiftId:y,open:Pe,onClose:xt,date:st,isOpenShift:g,isRoleOrDepartment:q,jobId:Me,defaultTab:We,roleId:T,onShowTooltipForDelete:B,onShowTooltipForCopy:ne,handlerId:H,color:t,roleName:E,startAt:S,endAt:a,autoOpenCoverModal:$e,openCoverRequestModal:Ee}),ye&&e.jsx(GL,{isOpen:ye,onClose:xe,id:y,isOpenShift:g,startAt:S,endAt:a,roleName:E}),M&&me&&e.jsx(si,{open:me,onClose:we,anchorEl:De.current,menuItemSections:tt})]})};ef.propTypes={color:d.oneOf(Yl.concat(Jl)).isRequired,isColorMappingV1:d.bool.isRequired,conflictType:d.string,currentLocationId:d.string,endAt:d.string,hasShiftRequests:d.bool,coverRequestIndicator:d.string,tradeRequestIndicator:d.string,shiftClaimIndicator:d.string,eventName:d.object,hasNote:d.bool,hasOvertime:d.bool,hasTimecard:d.bool,isOpenShift:d.bool,isPublished:d.bool,note:d.string,roleName:d.string,startAt:d.string,userName:d.string,ownerId:d.string,roleId:d.string,isCopyPasteMode:d.bool,onDelete:d.func.isRequired,onCopy:d.func.isRequired,noUserName:d.bool,isManager:d.bool,noConflict:d.bool,oneLine:d.bool,isRoleOrDepartment:d.bool,shiftSyncError:d.string};const kn=F((t,{shiftId:s})=>({color:Se({state:t,id:s,attribute:"color"})||Bo(t===1),isColorMappingV1:ks(t)===1,conflictType:fS(t,{id:s}),currentLocationId:String(ct(t)),endAt:Se({state:t,id:s,attribute:"endAt"}),hasShiftRequests:Se({state:t,id:s,attribute:"isApproved"}),eventName:Se({state:t,id:s,attribute:"approvalEvent"}),coverRequestIndicator:Se({state:t,id:s,attribute:"coverRequestIndicator"}),tradeRequestIndicator:Se({state:t,id:s,attribute:"tradeRequestIndicator"}),shiftClaimIndicator:Se({state:t,id:s,attribute:"shiftClaimIndicator"}),hasOvertime:!!_S({state:t,attribute:"hasOvertime",id:s}),hasTimecard:Se({state:t,id:s,attribute:"hasTimecard"}),isOpenShift:Se({state:t,id:s,attribute:"isOpen"}),isPublished:Se({state:t,id:s,attribute:"isPublished"}),note:(()=>{const n=vs({state:t,id:s,relationship:"note"})?.id;return ca(t,n)?.text})(),hasNote:!!Se({state:t,id:s,attribute:"note"}),roleName:Se({state:t,id:s,attribute:"roleName"}),startAt:Se({state:t,id:s,attribute:"startAt"}),ownerId:vs({state:t,id:s,relationship:"owner"})?.id,roleId:vs({state:t,id:s,relationship:"role"})?.id,userName:Ti(t,s),isManager:He(t),noConflict:pS(t,{id:s}),childLaborViolationData:nm(t,{shiftId:s}),userIdByShiftId:mS(t,s),hasSeenToolTip:im(t,cm.RIGHT_CLICK_TOOL_TIP_SHOWN),isCopyPasteMode:!!tn(t),shiftSyncError:em(t,s),findCoverShiftId:lm(t)}),{onCopy:ie.startCopyPaste,onDelete:tm,createOTE:jr})(r.memo(ut({triggeredFrom:Rn.SHIFT})(ef))),tf=({id:t,isApproved:s,isLoading:n,onApprove:o,onDelete:a,onDecline:l,onClose:c,startAt:u,endAt:h,isWholeDay:m})=>{const _=K(),[f,g]=r.useState(!1),[b,x]=r.useState(null),E=r.useMemo(()=>Bv({startAt:u,endAt:h,wholeDay:m}),[u,h,m]),S=r.useCallback(async()=>{if(_(w.BUTTON_CLICKED,k.CLICK,{buttonText:"delete"}),s)try{x(await ES(t))}catch{x(null)}g(!0),_(w.DELETE_CONFIRMATION_MODAL_SHOWN,k.VIEW,{eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_DELETE_MODAL})},[_,s,t]),y=r.useCallback(()=>{_(w.BUTTON_CLICKED,k.CLICK,{buttonText:"delete",eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_DELETE_MODAL}),a({id:t}).then(()=>{g(!1),x(null),c()})},[_,a,t,c]),C=r.useCallback(()=>{_(w.BUTTON_CLICKED,k.CLICK,{buttonText:"cancel",eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_DELETE_MODAL}),g(!1),x(null)},[_]),v=r.useCallback(()=>{_(w.DISMISS_CLICKED,k.CLICK,{eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_DELETE_MODAL}),g(!1),x(null)},[_]),T=r.useCallback(()=>l(t).then(()=>c()),[l,t,c]),D=r.useCallback(()=>o(t).then(()=>c()),[o,t,c]);return e.jsxs(e.Fragment,{children:[e.jsx(i,{hright:!s,p:20,gap:20,spacebetween:!0,children:s?e.jsx(V,{isLoading:n,variant:"secondaryDestructive",onClick:S,children:p(`${qs}.delete`)}):e.jsxs(e.Fragment,{children:[e.jsx(V,{isLoading:n,variant:"secondary",onClick:T,children:p(`${qs}.decline`)}),e.jsx(V,{isLoading:n,variant:"primary",onClick:D,children:p(`${qs}.approve`)})]})}),e.jsx(Uv,{open:f,dateRangeText:E,payrollImpact:b,onConfirm:y,onBack:C,onDismiss:v})]})};tf.propTypes={id:d.string,onClose:d.func.isRequired,onDecline:d.func.isRequired,onApprove:d.func.isRequired,onDelete:d.func.isRequired,isApproved:d.bool.isRequired,isLoading:d.bool.isRequired,startAt:d.string,endAt:d.str
1ing,isWholeDay:d.bool};const ZL=F(null,{onDelete:CS,onApprove:xS,onDecline:gS})(tf),sf=({startAt:t,endAt:s,dayDuration:n,notes:o,createdAt:a,isWholeDay:l,ptoAvailable:c})=>{const u=r.useMemo(()=>[[Bt(t),al(t)],[Bt(s),al(s)]],[t,s]),h=r.useMemo(()=>l?qc(n):`${gc(t)} - ${gc(s)}`,[n,l,t,s]),m=r.useMemo(()=>Yb(a),[a]);return e.jsxs(i,{btw:1,bbw:1,bs:"solid",bcolor:"default",ph:20,children:[e.jsx(i,{spacebetween:!0,pv:20,children:u.map(([_,f],g)=>e.jsxs(i,{column:!0,hright:!!g,children:[e.jsx(Y,{fs14:!0,navyLight:!0,fw600:!0,uppercase:!0,text:_}),e.jsx(Y,{fs30:!0,navyLight:!0,fw600:!0,text:f})]},_+g))}),e.jsxs(i,{column:!0,pv:20,btw:1,bbw:1,bs:"solid",bcolor:"default",children:[e.jsxs(i,{spacebetween:!0,vcenter:!0,children:[e.jsx(Y,{grayXdark:!0,fs14:!0,fw600:!0,i18n:`${qs}.hours_requested`}),e.jsx(Y,{navyLight:!0,fs18:!0,fw600:!0,text:h})]}),c!==void 0&&e.jsxs(i,{spacebetween:!0,pt:16,children:[e.jsx(Y,{grayXdark:!0,fs14:!0,fw600:!0,i18n:`${qs}.pto_available_after_approval`}),e.jsx(Y,{navyLight:!0,fs18:!0,fw600:!0,text:qc(c)})]})]}),e.jsxs(i,{column:!0,gap:10,pv:20,children:[!!o&&e.jsx(Y,{fs16:!0,navyLight:!0,text:`"${o}"`}),e.jsx(Y,{fs14:!0,grayXdark:!0,i18n:`${qs}.requested`,i18nProps:{date:m}})]})]})};sf.propTypes={dayDuration:d.number.isRequired,isWholeDay:d.bool,createdAt:d.string.isRequired,notes:d.string.isRequired,startAt:d.string.isRequired,endAt:d.string.isRequired,ptoAvailable:d.number};const nf=({avatarUrl:t,username:s,reason:n,category:o,isApproved:a})=>{const l=`${jS}.${n==="vacation"?"unpaid_vacation":n}`,c=`${SS}.${o}`,u=n?`${p(c)} | ${p(l)}`:p(c);return e.jsxs(i,{p:20,row:!0,gap:10,children:[e.jsx(Hv,{url:t,size:30}),e.jsxs(i,{column:!0,children:[e.jsx(Y,{fs16:!0,navy:!0,fw700:!0,text:s}),e.jsx(i,{mb:5,children:e.jsx(Y,{fs14:!0,grayMediumDark:!0,text:u})}),a&&e.jsx(i,{bgcolor:"green300",bradiusm:!0,ph:10,pv:1,vcenter:!0,hcenter:!0,w:"fit-content",children:e.jsx(Y,{uppercase:!0,fs12:!0,color:"white",i18n:`${qs}.approved`})})]})]})};nf.propTypes={avatarUrl:d.string.isRequired,reason:d.string,username:d.string.isRequired,category:d.string.isRequired,isApproved:d.bool.isRequired};const{cx:eA}=O("TimeOffPopper"),rf=({id:t,open:s,anchorEl:n,dayDuration:o,avatarUrl:a,reason:l,username:c,category:u,notes:h,startAt:m,endAt:_,isWholeDay:f,isApproved:g,isPendingUpdate:b,createdAt:x,onClose:E,ptoAvailable:S})=>{const y=K(),C=X();r.useEffect(()=>
1{s&&(y(w.TIME_OFF_POPPER_SHOWN,k.VIEW),C(vS(t)))},[y,C,t,s]);const v=r.useCallback(()=>{y(w.DISMISS_CLICKED,k.CLICK),E()},[y,E]),T=r.useCallback(D=>{D.stopPropagation(),v()},[v]);return e.jsx(e.Fragment,{children:e.jsx(zn,{placement:"left",open:s,anchorEl:n,showArrow:!0,children:e.jsx(nn,{onClickAway:v,mouseEvent:"onMouseDown",touchEvent:"onTouchStart",children:e.jsxs(i,{className:eA(),minw:400,w:"-webkit-fill-available",bgcolor:"mono0",bradiuss:!0,shadow:"z2",children:[e.jsx(i,{absolute:!0,right:20,top:20,pointer:!0,onClick:T,children:e.jsx(Q,{iconName:"Close",size:"small"})}),e.jsx(nf,{avatarUrl:a,username:c,reason:l,category:u,isApproved:g}),e.jsx(sf,{startAt:m,endAt:_,dayDuration:o,notes:h,createdAt:x,isWholeDay:f,ptoAvailable:S}),e.jsx(ZL,{isApproved:g,isLoading:b,id:t,onClose:E,startAt:m,endAt:_,isWholeDay:f})]})})})})};rf.propTypes={id:d.string,open:d.bool,anchorEl:d.object,dayDuration:d.number,avatarUrl:d.string,reason:d.string,username:d.string,category:d.string,createdAt:d.string,notes:d.string,startAt:d.string,endAt:d.string,isWholeDay:d.bool,isApproved:d.bool,isPendingUpdate:d.bool,onFetchTimeOffDetails:d.func.isRequired,ptoAvailable:d.number};const tA=F((t,s)=>({isPendingUpdate:yS(t),dayDuration:Mk(t,s.id),reason:Xt({state:t,attribute:"reason",id:s.id}),category:Xt({state:t,attribute:"category",id:s.id}),notes:Xt({state:t,attribute:"notes",id:s.id}),createdAt:Xt({state:t,attribute:"createdAt",id:s.id}),avatarUrl:Cr({state:t,attribute:"avatar",userId:wt({state:t,relationship:"user",id:s.jobId})}),username:ia(t,s.jobId),ptoAvailable:Xt({state:t,attribute:"ptoAvailable",id:s.id})}))(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_TIME_OFF_POPPER})(rf))),sA=({isFullDayRequest:t,hoursRequested:s,oneLine:n})=>{const o=p("schedule_builder.react_page.time_offs.all_day"),a=n?`(${o})`:o;return t?a:s},nA=({isApproved:t})=>t?"TimeOffApproved":"Warning",{cx:rA}=O("TimeOffItem"),of=({isApproved:t,isFullDayRequest:s,isManager:n,startAt:o,timeOffId:a,jobId:l,endAt:c,employeeFullName:u,noEmployeeName:h,oneLine:m,inline:_=!1})=>{const[f,g]=r.useState(null),[b,x]=r.useState(!1),E=r.useCallback(L=>{L.stopPropagation(),g(L.currentTarget),x(!b)},[b]),S=r.useCallback(()=>{x(!1)},[]),y=Ut(o,c),C=p("schedule_builder.react_page.time_offs.title"),v=sA({isFullDayRequest:s,hoursRequested:y,oneLine:m}),T=r.useMemo(()=>e.jsx(Ae,{content:p(`schedule_builder.react_page.time_offs.tooltips.${t?"approved":"pending"}`),children:e.jsx(Q,{iconName:nA({isApproved:t}),size:"xsmall",color:t?null:"mono900"})}),[t]),D=e.jsxs(e.Fragment,{children:[T,e.jsx(j,{variant:"captions",color:"mono900",children:p("schedule_builder.react_page.time_offs.pending_approval")})]});return e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{bgcolor:"mono300",className:rA({approved:t}),onClick:n?E:null,titleIconName:"Ban",titleIconColor:"mono700",title:C,oneLine:m,hasSmallGap:!0,children:[e.jsxs(i,{vcenter:!0,gap:4,row:!0,mr:8,children:[h&&t&&T,e.jsx(j,{variant:"captions",color:"mono900",capitalize:!m,children:v}),!t&&_&&D]}),!h&&e.jsxs(i,{vcenter:!0,gap:4,row:!0,ellipsis:!0,children:[t&&T,e.jsx(j,{noWrap:!0,variant:"captions",color:"mono900",children:u})]}),!t&&!_&&e.jsx(i,{vcenter:!0,gap:4,row:!0,children:D})]}),n&&b&&e.jsx(tA,{id:a,jobId:l,open:b,anchorEl:f,onClose:S,isApproved:t,isWholeDay:s,startAt:o,endAt:c})]})};of.propTypes={isApproved:d.bool,isFullDayRequest:d.bool,isManager:d.bool,startAt:d.string,endAt:d.string,timeOffId:d.string,jobId:d.string,employeeFullName:d.string,noEmployeeName:d.bool,oneLine:d.bool,inline:d.bool};const go=F((t,s)=>{const n=Hh({state:t,id:s.timeOffId,relationship:"job"});return{jobId:n,isApproved:Xt({state:t,attribute:"isApproved",id:s.timeOffId}),isFullDayRequest:Xt({state:t,attribute:"isWholeDay",id:s.timeOffId}),startAt:Xt({state:t,attribute:"startAt",id:s.timeOffId}),endAt:Xt({state:t,attribute:"endAt",id:s.timeOffId}),employeeFullName:Or(t,n),isManager:He(t)}})(r.memo(of)),af="schedule_builder.react_page.availability",oA=({allDay:t,hoursRequested:s,oneLine:n})=>{const o=p(`${af}.all_day`),a=n?`(${o})`:o;return t?a:s},{cx:aA}
1=O("UnavailabilityItem"),lf=({allDay:t,startAt:s,endAt:n,employeeName:o,noEmployeeName:a,oneLine:l})=>{const c=Ut(s,n),u=p(`${af}.unavailable.title`),h=oA({hoursRequested:c,allDay:t,oneLine:l}),m=r.useCallback(_=>{_.stopPropagation()},[]);return e.jsxs(Ms,{bgcolor:"mono100",className:aA(),title:u,oneLine:l,hasSmallGap:!0,onClick:m,children:[e.jsx(i,{mr:8,children:e.jsx(j,{variant:"captions",color:"mono900",capitalize:!l,children:h})}),!a&&e.jsx(i,{ellipsis:!0,children:e.jsx(j,{noWrap:!0,variant:"captions",color:"mono900",children:o})})]})};lf.propTypes={id:d.string.isRequired,employeeName:d.string.isRequired,allDay:d.bool,startAt:d.string,endAt:d.string,noEmployeeName:d.bool,oneLine:d.bool};const xo=F((t,s)=>{const n=Si({state:t,relationship:"job",id:s.id});return{allDay:Hs({state:t,attribute:"allDay",id:s.id}),startAt:Hs({state:t,attribute:"startAt",id:s.id}),endAt:Hs({state:t,attribute:"endAt",id:s.id}),employeeName:Or(t,n)}})(r.memo(lf));function lA({type:t,id:s,locationIdsForUser:n}){switch(t){case"shift":return e.jsx(kn,{noUserName:!0,shiftId:s});case"openShift":return e.jsx(kn,{oneLine:!0,shiftId:s,noUserName:!0});case"multiLocationShift":return e.jsx(Y_,{shiftId:s,noUserName:!0,locationIdsForUser:n});case"event":return e.jsx(nc,{eventId:s});case"timeOffBlackout":return e.jsx(ec,{blackoutId:s});case"timeOff":return e.jsx(go,{noEmployeeName:!0,timeOffId:s,inline:!0});case"scheduleAvailability":return e.jsx(xo,{noEmployeeName:!0,id:s});case"preferred":return e.jsx(X_,{noEmployeeName:!0,id:s})}}const iA=({id:t,type:s,left:n,width:o,onGetSquareHeight:a,locationIdsForUser:l})=>{const[c,u]=Pv();return r.useEffect(()=>{s==="openShift"&&a(u.height)},[s,a,u.height]),e.jsx(i,{ref:c,absolute:!0,top:0,left:n,w:o,children:lA({type:s,id:t,locationIdsForUser:l})},t)},cA=F((t,s)=>k_[s.groupType](t,s.meta||{})[s.groupIndex][s.index])(iA),dA=({onClick:t,squaresCount:s,cellHeight:n,locationIdsForUser:o,type:a,meta:l,index:c,hidden:u})=>{const[h,m]=r.useState(n),_=r.useCallback(f=>{m(f)},[]);return e.jsx(i,{onClick:t,h,relative:!0,hide:u,children:[...Array(s)].map((f,g)=>e.jsx(cA,{groupIndex:c,index:g,groupType:a,locationIdsForUser:o,meta:l,onGetSquareHeight:_},g))})},ru=F((t,s)=>({squaresCount:(k_[s.type](t,s.meta||{})[s.index]||[]).length}))(dA),cf=(t,s)=>{const n=t.clientX,o=t.target.getBoundingClientRect(),a=(n-o.left)/o.width*100;let l="";return a<=25?l=`${s}:00`:a>25&&a<=75?l=`${s}:30`:l=`${s+1}:00`,l},rc=({isManager:t,hour:s,onClick:n})=>{const o=r.useCallback(a=>{const l=cf(a,s);n?.(a.target,l)},[s,n]);return e.jsx(i,{grow:1,basis:0,onClick:t?o:null},s)};rc.defaultProps={};rc.propTypes={hour:d.number,isManager:d.bool,onClick:d.func};const uA=F(t=>({isManager:He(t)}))(rc),oc=({businessHours:t,groupsCount:s,hasPreferredItems:n,locationIdsForUser:o,cellHeight:a,onEmptyHourClick:l,meta:c,type:u,hovered:h,canAdd:m,pt:_})=>{const f=r.useCallback(g=>{if(g.target!==g.currentTarget)return;const b=cf(g,t[0]);l?.(g.target,b)},[t,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(i,{grow:1,basis:0,gap:4,column:!0,pt:_||4,pb:m?12:4,onClick:f,children:[[...Array(s)].map((g,b)=>e.jsx(ru,{index:b,meta:c,cellHeight:a,locationIdsForUser:o,type:u,onClick:f},b)),n&&s===0&&e.jsx(ru,{index:0,meta:c,cellHeight:a,type:"preferred",hidden:!h})]}),t.slice(1,t.length).map(g=>e.jsx(uA,{hour:g,onClick:l},g))]})};oc.defaultProps={groupsCount:0};oc.propTypes={groupsCount:d.number.isRequired,locationIdsForUser:d.arrayOf(d.string),type:d.string.isRequired,meta:d.object,onEmptyHourClick:d.func,hovered:d.bool};const Br=r.memo(oc),{cx:hA}=O("EmployeeRow"),df=({businessHours:t,date:s,enabledOvertimeHours:n,groupsCount:o,hours:a,hoursInAllLocations:l,jobId:c,locationIdsForUser:u,overtimeHours:h,preferredGroupsCount:m,userId:_,wages:f})=>{const g=r.useMemo(()=>({userId:_,jobId:c,date:s}),[_,c,s]),b=r.useMemo(()=>({type:"job",id:c}),[c]),[x,E]=r.useState(),[S,y]=r.useState(),[C,v]=r.useState(),[T,D]=r.useState(!1),[L,A]=r.useState(!1),{isOver:P,setNodeRef:M}=Yn({owner:b,date:s}),R=r.useCallback(()=>{A(!0)},[]),$=r.useCallback(()=>{A(!1)},[]),B=r.useCallback((N,H)=>{Number(H?.split(":")[0])>=kS||(v(N),E(H),y(null),D(!0))},[]),W=r.useCallback(()=>D(!1),[]);return e.jsxs(i,{row:!0,ref:M,className:hA({dragIsOver:P,hovered:L}),onMouseOver:R,onMouseLeave:$,children:[e.jsx(i,{grow:2,basis:0,borderbox:!0,pl:28,pv:6,overflowX:"hidden",minw:Ri,children:e.jsx(a_,{enabledOvertimeHours:n,hours:a,hoursInAllLocations:l,jobId:c,noDnD:!0,overtimeHours:h,wages:f})}),e.jsx(Br,{businessHours:t,groupsCount:o,hasPreferredItems:m>0,locationIdsForUser:u,cellHeight:44,onEmptyHourClick:B,meta:g,type:"employee",hovered:L}),T&&e.jsx(Ns,{isAdding:!0,jobId:c,anchorEl:C,open:T,onClose:W,date:s,startAt:x,endAt:S})]})};df.propTypes={businessHours:d.array.isRequired,date:d.string.isRequired,enabledOvertimeHours:d.bool,groupsCount:d.number.isRequired,hours:d.number,hoursInAllLocations:d.number,jobId:d.string.isRequired,locationIdsForUser:d.arrayOf(d.string),overtimeHours:d.number,preferredGroupsCount:d.number,userId:d.string,wages:d.number};const mA=F((t,{jobId:s,date:n})=>{const o=wt({state:t,relationship:"user",id:s});return{enabledOvertimeHours:DS(t),groupsCount:Zp(t,{userId:o,jobId:s,date:n}).length,hours:wS(t,{jobId:s,date:n}),hoursInAllLocations:dm(t,{jobId:s}),overtimeHours:TS(t),preferredGroupsCount:n_(t,{jobId:s,date:n}).length,userId:o,wages:IS(t,{jobId:s,date:n})}})(df),ja=({count:t,cxEl:s,i18nTitle:n,iconName:o,...a}
1)=>e.jsx(i,{grow:2,basis:0,borderbox:!0,className:s("cell"),pl:28,pb:0,minw:280,minh:32,...a,children:e.jsxs(i,{row:!0,vcenter:!0,children:[e.jsx(i,{mr:12,children:e.jsx(Q,{size:"small",iconName:o,color:"mono700"})}),e.jsx(i,{children:e.jsx(j,{variant:"bodySm",children:n&&p(n,{props:{count:t}})})})]})});ja.propTypes={count:d.number,cxEl:d.func,i18nTitle:d.string,iconName:d.string};const uf=({businessHours:t,date:s,groupsCount:n,cxEl:o})=>{const a=r.useMemo(()=>({date:s}),[s]);return e.jsxs(i,{row:!0,children:[e.jsx(ja,{cxEl:o,iconName:"Calendar",i18nTitle:"schedule_builder.react_page.day_view.events.title",count:n,vtop:!0,pt:8,minh:42}),e.jsx(Br,{businessHours:t,groupsCount:n,cellHeight:ua,type:"events",meta:a,pt:8})]})};uf.propTypes={businessHours:d.array.isRequired,cxEl:d.func,date:d.string,groupsCount:d.number.isRequired};const pA=F((t,s)=>({groupsCount:t_(t,s).length}))(uf),{cx:_A}=O("NoPrint"),xs=({children:t})=>e.jsx(i,{className:_A(),children:t}),{cx:fA}=O("ViewByWithSearch"),{cx:bA}=O("ViewByWithSearchOverride");function hf({searchValue:t,toggleSearch:s,onSetSearchTerm:n}){const[o,a]=r.useState(t),l=r.useCallback(m=>{a(m.target.value)},[]),c=r.useCallback(()=>a(""),[]),u=r.useCallback(()=>{n(""),s()},[n,s]),h=r.useCallback(um(n,RS,{trailing:!0}),[n]);return r.useEffect(()=>{h(o?.trim()||"")},[o,h]),e.jsxs(i,{row:!0,vbottom:!0,gap:12,ml:-8,children:[e.jsx(be,{size:"small",onClick:u,icon:"ChevronLeft",label:p("schedule_builder.actions.back")}),e.jsxs(i,{column:!0,gap:4,children:[e.jsx(j,{color:"mono700",variant:"captionBold",children:p("schedule_builder.react_page.search")}),e.jsx(i,{className:fA(),children:e.jsx(yo,{cx:bA,dataTestId:"search-input",type:"text",value:o,onChange:l,endIcon:e.jsx(Q,{iconName:"Clear",size:"medium",color:"purple500",onClick:c}),placeholder:p("schedule_builder.react_page.search"),autoFocus:!0})})]})]})}hf.propTypes={searchValue:d.string,toggleSearch:d.func,onSetSearchTerm:d.func};const gA=F(()=>({}),{onSetSearchTerm:ie.setSearchTerm})(hf),xA=(t,s,n)=>{switch(t){case J.day:return n;case J.week:return s;default:return null}},CA=(t,s,n,o,a,l)=>{switch(l(w.DROPDOWN_CLICKED,k.CLICK,{field:"view_by_type",dropdown_selection:t}),t){case"first_name":n({viewType:de.employee});break;case"last_name":n({viewType:de.employee});break;case"custom":n({viewType:de.employee});break;case"department":case"role":case"start_time":n({viewType:t});break;default:return null}},{cx:EA}=O("ViewByWithSearch"),mf=({canManageSchedule:t,customJobIds:s,hasDepartmentsAccess:n,isLoadingLaborTotals:o,isManager:a,onChangeRoute:l,onUpdateSortByWeek:c,scheduleIsLoading:u,sortByWeek:h,stopCopyPaste:m,toggleSearch:_,updateSortByDay:f,viewType:g})=>{const{rangeType:b}=ze(),x=X(),E=K(),S=r.useMemo(()=>h===Lt.POSITION?mt.custom:h,[h]),y=r.useMemo(()=>b===J.week?S:ts(gr),[b,S]);let C=g;g===de.department&&!n&&(C=de.employee),g===de.employee&&(C=y||mt.firstName);const[v,T]=r.useState(C),[D,L]=r.useState(a);r.useEffect(()=>{D&&!o&&L(!1)},[o]),r.useEffect(()=>{u||T(C)},[u,C]);const A=g===de.employee||g===de.startTime,P=r.useCallback(M=>{const R=M.target.value;if(t&&b===J.week&&[mt.firstName,mt.lastName,mt.custom].includes(R)){const $=R===mt.custom?Lt.POSITION:R;c({sortByWeek:$,ids:s})}if(b===J.day&&(f(R),at(gr,R)),R===de.startTime?at("viewType",R):at("viewType",de.employee),!n&&R===de.department){x(ei({minTier:"plus",feature:"departments",mppFocusViewProps:{focusedFeature:"permissionAndDepartments"}}));return}m(),CA(R,a,l,b,s,E),T(R)},[t,b,n,m,a,l,s,E,c,f,x]);return e.jsxs(i,{row:!0,gap:"xs",alignItemsCenter:!0,className:EA(),children:[e.jsx(j,{color:"mono700",variant:"bodySmBold",noWrap:!0,children:p("schedule_builder.react_page.view_by_label")}),u&&D?e.jsx(i,{grow:1,children:e.jsx(Ii,{height:"small",variant:"indeterminate"})}):e.jsxs(i,{row:!0,vcenter:!0,gap:"xs",grow:1,minh:0,children:[e.jsx(i,{dataTestId:"view-by",grow:1,minh:0,children:e.jsx(Qt,{dataTestId:"view-by-select",onChange:P,options:a?MS[b]:PS[b],value:v})}),A&&e.jsx(be,{size:"small",onClick:_,icon:"Search",label:p("schedule_builder.actions.search")})]})]})};mf.propTypes={canManageSchedule:d.bool,createOneTimeEvent:d.func,customJobIds:d.array,hasDepartmentsAccess:d.bool,isLoadingLaborTotals:d.bool,isManager:d.bool,onCh
1angeRoute:d.func,onUpdateSortByWeek:d.func,scheduleIsLoading:d.bool,sortByWeek:d.string,stopCopyPaste:d.func,toggleSearch:d.func,updateSortByDay:d.func,viewType:d.string};const SA=F(t=>({hasDepartmentsAccess:Yo(t,{name:"departments"}),canManageSchedule:Dr(t),isLoadingLaborTotals:aa(t),isManager:He(t)||t.getIn(["session"])?.currentUser?.is_managerial,customJobIds:AS(t),scheduleIsLoading:eh(t),sortByWeek:LS(t)}),{onChangeRoute:Go,onUpdateSortByWeek:NS,stopCopyPaste:ie.stopCopyPaste,updateSortByDay:OS,createOneTimeEvent:jr})(mf);function pf({searchTerm:t}){const{viewType:s}=ze(),n=K(),[o,a]=r.useState(t!==""),l=r.useCallback(()=>{n(w.EMPLOYEE_SEARCH_CLICKED,k.CLICK),a(!o)},[o,n]);return e.jsx(e.Fragment,{children:o?e.jsx(gA,{searchValue:t,toggleSearch:l}):e.jsx(SA,{viewType:s,toggleSearch:l})})}pf.propTypes={searchTerm:d.string};const _f=F(t=>({searchTerm:$S(t)}))(r.memo(pf)),{cx:jA,cxEl:Za}=O("HeaderRow"),yA=({businessHours:t})=>e.jsxs(i,{row:!0,sticky:!0,className:jA(),style:{top:0,zIndex:10},shadow:"z1",shadowDirection:"bottom",children:[e.jsx(i,{className:Za("cell","first"),borderbox:!0,minw:Ri,children:e.jsx(i,{pr:40,w:"100%",children:e.jsx(xs,{children:e.jsx(_f,{})})})}),t.map(s=>e.jsxs(i,{className:Za("cell","hourly"),children:[e.jsx("div",{className:Za("cell-border")}),e.jsx(wr,{variant:"mono",children:BS[s]})]},s))]}),vA=r.memo(yA),ff=({businessHours:t,currentLocationId:s,groupsCount:n,date:o,cxEl:a})=>{const l=r.useMemo(()=>({date:o}),[o]),c=r.useMemo(()=>({type:"location",id:s}),[s]),{setNodeRef:u}=Yn({owner:c,date:o}),[h,m]=r.useState(),[_,f]=r.useState(),[g,b]=r.useState(!1),x=r.useCallback((S,y)=>{f(S),m(y),b(!0)},[]),E=r.useCallback(()=>b(!1),[]);return e.jsxs(i,{ref:u,row:!0,bcolor:"mono300",bbw:0,children:[e.jsx(ja,{cxEl:a,iconName:"Progress",i18nTitle:"schedule_builder.react_page.day_view.open_shifts.title",count:n,pt:4}),e.jsx(Br,{businessHours:t,groupsCount:n,type:"openShifts",cellHeight:ua,onEmptyHourClick:x,meta:l,canAdd:!0}),g&&e.jsx(Ns,{isAdding:!0,isOpenShift:!0,anchorEl:_,open:g,onClose:E,date:o,startAt:h,endAt:null})]})};ff.propTypes={businessHours:d.array.isRequired,currentLocationId:d.string.isRequired,cxEl:d.func,date:d.string,groupsCount:d.number.isRequired};const IA=F((t,s)=>({currentLocationId:String(ct(t)),groupsCount:e_(t,s).length}))(ff),{cxEl:TA}=O("TeamMemberCount"),bf=({numberOfEmployees:t,numberOfOtherJobLocationIds:s,numberOfUserIdsNotInLocation:n,hasMultipleLocations:o})=>{const a=o,l=n>0;return e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"bodySmBold",color:"mono700",children:p("schedule_builder.react_page.multilocation.team_members_count",{props:{count:t}})}),a&&l&&e.jsxs(i,{"data-testid":TA("member-location-count"),row:!0,vcenter:!0,mt:2,children:[e.jsx(Q,{iconName:"Location",color:"mono700",size:"small"}),e.jsx(i,{ml:5,children:e.jsx(j,{variant:"captions",color:"mono700",children:p("schedule_builder.react_page.multilocation.scheduled_location",{props:{numUsers:n,count:s}})})})]})]})};bf.propTypes={numberOfEmployees:d.number,numberOfOtherJobLocationIds:d.number,numberOfUserIdsNotInLocation:d.number};const gf=F(t=>({numberOfEmployees:Li(t,{sortBy:""}).length,numberOfOtherJobLocationIds:FS(t).length,numberOfUserIdsNotInLocation:HS(t).length,hasMultipleLocations:US(t)||t.getIn(["session"])?.multipleLocations}),{})(r.memo(bf)),{cx:wA}=O("TeamCountRow"),xf=({businessHours:t,cxEl:s})=>e.jsxs(i,{className:wA(),row:!0,bgcolor:"mono100",children:[e.jsx(i,{grow:2,basis:0,borderbox:!0,className:s("cell"),pl:28,pt:2,pb:4,minw:280,children:e.jsx(gf,{})}),e.jsx(Br,{businessHours:t,groupsCount:0,cellHeight:ua,type:"notApplicableForTeamMemberCount"})]});xf.propTypes={businessHours:d.array.isRequired,cxEl:d.func};const Cf=({businessHours:t,groupsCount:s,date:n,cxEl:o})=>{const a=r.useMemo(()=>({date:n}),[n]);return s?e.jsxs(i,{row:!0,children:[e.jsx(ja,{cxEl:o,iconName:"TimeOffDenied",i18nTitle:"schedule_builder.react_page.limited_time_off.title",vtop:!0,pt:4}),e.jsx(Br,{businessHours:t,groupsCount:s,cellHeight:ua,type:"timeOffBlackouts",meta:a})]}):e.jsx(e.Fragment,{})};Cf.propTypes={businessHours:d.array.isRequired,cxEl:d.func,date:d.string,groupsCount:d.number.isRequired};const DA=F((t,s)=>({groupsCount:s_(t,s).length}))(Cf),ac=({hours:t,wages:s,employeesCount:n,isWageForecastVisible:o,isHoursForecastVisible:a,isPeopleForecastVisible:l})=>e.jsxs(i,{column:!0,pv:8,mr:11,children:[o&&e.jsx(i,{tright:!0,children:e.jsx(j,{variant:"captions",children:s})}),a&&e.jsx(i,{tright:!0,children:e.jsx(j,{variant:"captions",children:t})}),l&&e.jsxs(i,{row:!0,vcenter:!0,hright:!0,children:[e.jsx(i,{mr:3,children:e.jsx(Q,{size:"xsmall",iconName:"User"})}),e.jsx(j,{variant:"captions",children:n})]})]});ac.propTypes={hour:d.number,wages:d.string,hours:d.string,employeesCount:d.number,isWageForecastVisible:d.bool,isHoursForecastVisible:d.bool,isPeopleForecastVisible:d.bool};const kA=t=>e.jsx(ac,{...t}),RA=F((t,s)=>({hours:KS(t,s),wages:VS(t,s),employeesCount:WS(t,s)}))(r.memo(kA)),LA=t=>e.jsx(ac,{...t}),AA=F((t,s)=>({hours:GS(t,s),wages:zS(t,s),employeesCount:qS(t,s)}))(r.memo(LA)),{cx:OA}=O("TotalsWidget"),NA=({businessHours:t,isWageForecastVisible:s,isHoursForecastVisible:n,isPeopleForecastVisible:o,date:a})=>!s&&!n&&!o?null:e.jsxs(i,{row:!0,zIndex:1,sticky:!0,className:OA(),style:{bottom:0},bgcolor:"mono0",shadow:"z1",shadowDirection:"top",color:"mono700",children:[e.jsxs(i,{basis:0,grow:2,pl:28,row:!0,spacebetween:!0,minw:Ri,borderbox:!0,children:[e.jsxs(i,{row:!0,vcenter:!0,pv:4,children:[e.jsx(i,{mr:4,children:e.jsx(Q,{iconName:"TimeClock",size:"small"})}),e.jsx(j,{variant:"bodySm",children:p("schedule_builder.react_page.totals_widget.title")})]}),e.jsx(AA,{date:a,isWageForecastVisible:s,isHoursForecastVisible:n,isPeopleForecastVisible:o})]}),t.map(l=>e.jsx(i,{grow:1,basis:0,hright:!0,children:e.jsx(RA,{date:a,isWageForecastVisible:s,isHoursForecastVisible:n,isPeopleForecastVisible:o,hour:l})},l))]}),MA=F(t=>({isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"})&&Ls(t),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),isPeopleForecastVisible:Le({state:t,attribute:"isPeopleForecastVisible"})}))(r.memo(NA)),{cx:PA,cxEl:Xr}
1=O("DayView"),Ef=({businessHours:t,jobIds:s,isEventsVisible:n,date:o,locationIdsForUser:a})=>t.length?e.jsxs(i,{className:PA(),relative:!0,children:[e.jsx(vA,{businessHours:t,date:o}),n&&e.jsx(pA,{businessHours:t,date:o,cxEl:Xr}),e.jsx(DA,{businessHours:t,date:o,cxEl:Xr}),e.jsx(IA,{businessHours:t,date:o,cxEl:Xr}),e.jsx(xf,{businessHours:t,date:o,cxEl:Xr}),s.map(l=>e.jsx(mA,{businessHours:t,jobId:l,locationIdsForUser:a,date:o},l)),e.jsx(MA,{businessHours:t,date:o})]}):null;Ef.propTypes={businessHours:d.array,jobIds:d.arrayOf(d.string).isRequired,locationIdsForUser:d.arrayOf(d.string).isRequired,isEventsVisible:d.bool};const Sf=F((t,s)=>({businessHours:Hk(t,s),isEventsVisible:Le({state:t,attribute:"isEventsVisible"})}))(r.memo(Ef)),jf=({jobIds:t,locationIdsForUser:s})=>{const{rangeStart:n}=ze();return e.jsx(Sf,{jobIds:t,date:n,locationIdsForUser:s})};jf.propTypes={jobIds:d.arrayOf(d.string),locationIdsForUser:d.arrayOf(d.string)};const $A=F(t=>{const s=YS(t);return{jobIds:Li(t,{sortBy:s}),locationIdsForUser:Ai(t)}})(jf),yf=({jobIds:t,locationIdsForUser:s})=>{const{rangeStart:n}=ze();return e.jsx(Sf,{jobIds:t,date:n,locationIdsForUser:s})};yf.propTypes={jobIds:d.arrayOf(d.string),locationIdsForUser:d.arrayOf(d.string)};const BA=F(t=>({jobIds:JS(t),locationIdsForUser:Ai(t)}))(yf),{cx:UA}=O("EmptySpaceItem"),Ur=r.forwardRef((t,s)=>e.jsx(i,{ref:s,className:UA(),h:32,borderbox:!0,bw:2,bs:"dashed",bcolor:"purple500",bgcolor:"mono100",bradiuss:!0})),HA=({currentLocationId:t,handlerId:s,handleShowTooltipForDelete:n,isManager:o,locationIdsForUser:a,noUserName:l,shiftLocationId:c,shiftId:u})=>String(t)===String(c)?e.jsx(kn,{shiftId:u,noUserName:l,handleShowTooltipForDelete:n,handlerId:s}):o&&e.jsx(Y_,{locationIdsForUser:a,shiftId:u,noUserName:l}),FA=F((t,s)=>{const n=vs({state:t,id:s.shiftId,relationship:"owner"})?.id,o=wt({state:t,relationship:"location",id:n});return{currentLocationId:ct(t)||t.getIn(["session"])?.currentLocation?.id,shiftLocationId:o}},{})(r.memo(ut({triggeredFrom:Rn.SHIFT})(HA))),{cx:WA}=O("AddAction"),vf=({day:t,onClick:s})=>{const n=K(),o=r.useCallback(()=>{s(),n(w.ADD_SHIFT_CLICKED,k.CLICK)},[n,s]);return e.jsx(i,{absoluteCover:!0,dataTestId:"add-action",className:WA(t),onClick:o,vcenter:!0,hcenter:!0,pointer:!0,children:e.jsx(be,{icon:"Add",size:"small",label:p("schedule_builder.actions.add_shift")})})};vf.propTypes={day:d.string.isRequired,onClick:d.func};const VA=r.memo(vf),KA=Nr("scheduleBuilder/pasteCopiedShift",({uxContext:t,date:s,owner:n,roleName:o,updateOwner:a,updateRoleName:l},{dispatch:c,getState:u})=>{const h=u(),m=tn(h),_=Xh(h,m),f=Dn({state:h,attribute:"startOfWeek",id:ct(h)}),g=Vh(f).indexOf(dr(s)),{startAt:b,roleName:x,endAt:E,color:S,note:y}=_,C=_.owner,v=Vo(b),T=Ko(h,{shiftNoteQuotaId:v}),D=a?n:C,L=l?o:x,A=y?.id?ca(h,y?.id):null;return c(ki({uxContext:t,payload:{owner:D,roleName:L,color:S,currentShiftDate:s,days:[g],from:no(b),to:no(E),...T&&A&&{note:A.text}}}))}),{cx:qA}=O("PasteShiftItem"),If=({fullWidth:t,date:s,onPaste:n,owner:o,roleName:a})=>{const l=r.useCallback(()=>{n({date:s,owner:o,updateOwner:!!o,roleName:a,updateRoleName:!!a})},[s,n,o,a]);return e.jsx(V,{className:qA(),variant:"secondary",size:"small",onClick:l,fullWidth:t,uxElement:"paste_shift",children:p("schedule_builder.react_page.paste_shift")})};If.propTypes={fullWidth:d.bool,date:d.string.isRequired,onPaste:d.func.isRequired,owner:d.oneOfType([d.object,d.string]),roleName:d.string};const lc=F(()=>({}),{onPaste:KA})(If),{cxEl:zA}=O("ShiftPreoccupied"),Tf=({onAddClick:t,isCopyPasteMode:s,date:n,owner:o,roleName:a})=>{const[l,c]=r.useState(!1),u=r.useRef(null),[h,m]=r.useState(null);return r.useEffect(()=>{setTimeout(()=>c(!0),1)},[]),r.useEffect(()=>{const _=()=>{if(u.current){const b=u.current.getBoundingClientRect();
1m({top:b.bottom-20,left:b.left,width:b.width})}};_();let f=null,g=!1;return u.current&&(f=u.current.closest('[style*="overflow: auto"]'),f?f.addEventListener("scroll",_):(window.addEventListener("scroll",_,!0),g=!0)),()=>{f&&f.removeEventListener("scroll",_),g&&window.removeEventListener("scroll",_,!0)}},[]),e.jsxs(e.Fragment,{children:[e.jsx(i,{ref:u,absolute:!0,style:{top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),h&&e.jsx(XS,{children:e.jsx(i,{className:zA(l?"shiftWrapperHovered":"shiftWrapper"),flex:!0,style:{position:"fixed",top:h.top,left:h.left,width:h.width,justifyContent:"center"},children:s?e.jsx(lc,{date:n,owner:o,roleName:a}):e.jsx(V,{variant:"secondary",size:"small",onClick:t,children:fu(p("schedule_builder.react_page.actions.add"))})})})]})};Tf.propTypes={date:d.string,isCopyPasteMode:d.bool,onAddClick:d.func,owner:d.oneOfType([d.object,d.string]),roleName:d.string};const GA=r.memo(Tf),{cx:YA}=O("HoverOverlay"),JA=({children:t})=>e.jsx(i,{className:YA(),children:t}),{cx:XA}=O("WVEmptyCellItem"),QA=32,wf=({date:t,owner:s,onAddActionClick:n,isCopyPasteMode:o,isEventCell:a,roleName:l,setHovered:c})=>{const u=r.useRef(),[h,m]=r.useState(!1),[_,f]=r.useState(!1),g=r.useCallback(()=>{const E=u.current.clientHeight<QA;m(!0),f(E),c(E)},[c]),b=r.useCallback(()=>{m(!1),c(!1)},[c]),x=r.useCallback(()=>{m(!1),c(!1),n()},[c,n]);return e.jsxs(i,{ref:u,className:XA(t),onMouseOver:g,onMouseLeave:b,children:[h&&!_&&e.jsx(JA,{children:!a&&o?e.jsx(i,{mt:6,children:e.jsx(lc,{date:t,roleName:l,owner:s,fullWidth:!0})}):e.jsx(VA,{day:t,onClick:x})}),h&&_&&e.jsx(GA,{onAddClick:x,date:t,isCopyPasteMode:o,owner:s,roleName:l})]})};wf.propTypes={roleName:d.string,owner:d.any,date:d.string.isRequired,onAddActionClick:d.func,isCopyPasteMode:d.bool,isEventCell:d.bool};const ya=r.memo(wf),{cx:ZA}=O("GridCell");function e1({bg:t,className:s="",children:n,...o},a){return e.jsx(i,{bgcolor:t,ref:a,className:`${s} ${ZA()}`,column:!0,...o,children:n})}const Ue=r.forwardRef(e1),{cx:t1}=O("EWVEmployeeCell"),el="schedule_builder.react_page.shifts.tooltips.right_click";function Df({createOTE:t,date:s,jobId:n,unavailableScheduleAvailabilityIds:o,preferredScheduleAvailabilityIds:a,timeOffIds:l,shiftIds:c,isManager:u,isCopyPasteMode:h,locationIdsForUser:m,hasSeenToolTip:_}){const f=r.useMemo(()=>({type:"job",id:n}),[n]),g=r.useRef(null),[b,x]=r.useState(null),[E,S]=r.useState(!1),[y,C]=r.useState(!1),[v,T]=r.useState(void 0),L=o.length+l.length+c.length===0,{isOver:A,setNodeRef:P}=Yn({owner:f,date:s});r.useEffect(()=>{x(g.current)},[y]);const M=r.useCallback(()=>C(!1),[]),R=r.useCallback(()=>{C(N=>!N)},[]),$=r.useCallback(()=>{T(null),t("sb_right_click_tooltip_shown")},[t]),B=r.useCallback(()=>{T(!0)},[]),W=!_&&!!v;return e.jsxs(Ue,{ref:P,className:t1({dragIsOver:A,hovered:E}),"data-testid":Bt(s).toLowerCase(),children:[W&&e.jsx(Ae,{variant:"primary",open:W,title:p(`${el}.title`),content:p(`${el}.desc`),buttonTitle:p(`${el}.cta`),onDismissClick:$,onButtonClick:$,placement:"left",children:e.jsx(i,{})}),u&&o.map(N=>e.jsx(xo,{noEmployeeName:!0,id:N},N)),l.map(N=>e.jsx(go,{noEmployeeName:!0,timeOffId:N},N)),c.map(N=>e.jsx(FA,{shiftId:N,isManager:u,locationIdsForUser:m,noUserName:!0,handleShowTooltipForDelete:B},N)),u&&!h&&L&&a.map(N=>e.jsx(X_,{noEmployeeName:!0,id:N,date:s},N)),y&&e.jsx(Ur,{ref:g}),u&&!y&&e.jsx(ya,{date:s,owner:n,setHovered:S,onAddActionClick:R,isCopyPasteMode:h}),y&&e.jsx(Ns,{isAdding:!0,jobId:n,anchorEl:b,open:y,onClose:M,date:s})]})}Df.propTypes={createOTE:d.func,jobId:d.string.isRequired,date:d.string.isRequired,isCopyPasteMode:d.bool,isManager:d.bool,locationIdsForUser:d.arrayOf(d.string),unavailableScheduleAvailabilityIds:d.arrayOf(d.string).isRequired,preferredScheduleAvailabilityIds:d.arrayOf(d.string).isRequired,timeOffIds:d.arrayOf(d.string).isRequired,shiftIds:d.arrayOf(d.string).isRequired,hasSeenToolTip:d.bool};const s1=F((t,{jobId:s,date:n})=>{const o=wt({state:t,relationship:"user",id:s});return{unavailableScheduleAvailabilityIds:Gd(t,{jobId:s,date:n,title:"Unavailable"}),preferredScheduleAvailabilityIds:Gd(t,{jobId:s,date:n,title:"Preferred"}),timeOffIds:$k(t,{jobId:s,date:n}),shiftIds:QS(t,{userId:o,jobId:s,date:n})}},{createOTE:jr})(Df),{cx:n1,cxEl:r1}=O("EWVEmployeeFirstCell"),o1=({dropRef:t,isDropOver:s,...n})=>e.jsx(Ue,{ref:t,minw:sn.WEEK_VIEW,className:n1({isDropOver:s}),blw:0,pt:4,children:e.jsx(a_,{...n,className:r1("content")})}),a1=F((t,s)=>({wages:sj(t,s),hours:tj(t,s),enabledOvertimeHours:ej(t),hoursInAllLocations:dm(t,s),overtimeHours:ZS(t)}))(o1),{cx:l1}=O("GridRow");function i1({bg:t,className:s,children:n,...o},a){return e.jsx(i,{bgcolor:t,ref:a,className:`${s} ${l1()}`,row:!0,...o,children:n})}const Et=r.forwardRef(i1),{cx:kf}=O("EWVEmployeeRow"),Rf=r.memo(({jobId:t,dates:s,locationIdsForUser:n,isManager:o,hasSeenToolTip:a,isCopyPasteMode:l,index:c,dragAttributes:u,dragListeners:h,isDropOver:m})=>e.jsxs(e.Fragment,{children:[e.jsx(a1,{dragAttributes:u,dragListeners:h,isDropOver:m,jobId:t,index:c}),s?.map(_=>e.jsx(s1,{date:_,jobId:t,locationIdsForUser:n,isManager:o,hasSeenToolTip:a,isCopyPasteMode:l},_))]})),c1=r.memo(({data:t,index:s,isOverlay:n=!1})=>{const{dates:o,innerJobIds:a,isCopyPasteMode:l,isManager:c,hasSeenToolTip:u,locationIdsForUser:h}=t,m=a[s];return e.jsx(Et,{bg:"mono0",className:kf({overlay:n}),children:e.jsx(Rf,{jobId:m,dates:o,locationIdsForUser:h,isManager:c,hasSeenToolTip:u,isCopyPasteMode:l,index:s,isDropOver:!1})})}),d1=r.memo(({data:t,index:s,disableDrag:n=!1})=>{const{dates:o,innerJobIds:a,isCopyPasteMode:l,isManager:c,hasSeenToolTip:u,locationIdsForUser:h}=t,m=a[s],{isDragging:_,isOver:f,setNodeRef:g,attributes:b,listeners:x,transform:E,transition:S}=Fv({id:m,disabled:n||!c}),y=E&&!_,C={ref:g,bg:"mono0",className:kf({placeholder:_,dragIsOver:f}),...y&&{style:{transform:nj.Transform.toString(E),transition:S,backgroundColor:xi.mono0}}};return e.jsx(Et,{...C,children:e.jsx(Rf,{jobId:m,dates:o,locationIdsForUser:h,isManager:c,hasSeenToolTip:u,isCopyPasteMode:l,index:s,dragAttributes:c?b:void 0,dragListeners:c?x:void 0,isDropOver:f})})});function Lf({data:t,index:s,disableDrag:n=!1,isOverlay:o=!1}
1){const l=Jo()===Xs.SHIFT;return o||l?e.jsx(c1,{data:t,index:s,isOverlay:o}):e.jsx(d1,{data:t,index:s,disableDrag:n})}const u1=r.memo(Lf),Af=Nr("scheduleBuilder/sortEmployees",({sortBy:t,ids:s},{dispatch:n,getState:o})=>{const a=o();switch(t){case Lt.FIRST_NAME:s=Pa(a);break;case Lt.LAST_NAME:s=Pa(a);break;case Lt.CUSTOM:s=Pa(a);break;case Lt.POSITION:n(ie.setCustomJobIds(s));break}return n(rj({sort_by:t,ids:s}))});function h1(){const t=r.useRef(null),s=r.useCallback(o=>{const a=String(o.active.id);return(t.current?.getItems()||[]).includes(a)&&t.current?.getOverlayData(a)||null},[]),n=r.useCallback((o,a,l)=>{const{over:c}=o;if(c&&a&&a.jobId!==String(c.id)){const u=String(c.id);t.current?.handleReorder(a.jobId,u)}l?.()},[]);return{callbacksRef:t,handleDragStart:s,handleDragEnd:n}}function m1(t,s){r.useEffect(()=>{if(t)return t.current=s,()=>{t.current=null}},[t,s])}const p1=[{title:p("schedule_builder.agent.opt_in.dialog.item_one.title"),description:p("schedule_builder.agent.opt_in.dialog.item_one.description"),iconName:"Draft",iconColor:"purple500",iconBgColor:"purple100"},{title:p("schedule_builder.agent.opt_in.dialog.item_two.title"),description:p("schedule_builder.agent.opt_in.dialog.item_two.description"),iconName:"Warning",iconColor:"orange300",iconBgColor:"orange100"},{title:p("schedule_builder.agent.opt_in.dialog.item_three.title"),description:p("schedule_builder.agent.opt_in.dialog.item_three.description"),iconName:"Checkmark",iconColor:"green300",iconBgColor:"green100"}],_1=()=>{const t=K(),s=X(),n=I(hm),{rangeStartMoment:o,rangeEndMoment:a}=Mr(),[,l]=At(Gs,!1),[c,u]=At(Nn,!1),[h,m]=At(xl,!1),[_,f]=r.useState(!1),g=I(Rs),b=I(Oi),x=I(oj),E=I(aj),S=I(lj),y=r.useMemo(()=>S.filter($=>!$.isTemplate),[S]),C=r.useRef(null);r.useEffect(()=>{if(!b||!x||!E)return;const $=`${x}_${E}`;C.current!==$&&(C.current=$,ts(Gs)!==!0&&(c||h||y.length===0&&s(hn(!0))))},[s,b,x,E,y,h,c]);const v=r.useMemo(()=>Zs(o,a),[o,a]);r.useEffect(()=>{n&&(f(!1),t(w.MODAL_VIEWED,k.VIEW,{modal_source:"schedule_assistant_trigger"}))},[n]);const T=r.useCallback(()=>{t(w.DISMISS_CLICKED,k.CLICK,{element:"opt_in_modal",dismiss_method:"x_button"}),s(zc(!0)),s(hn(!1))},[s]),D=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{element:"opt_in_dismiss",button_text:"Not now"}),s(zc(!0)),s(hn(!1))},[s]),L=r.useCallback(()=>{t(w.BUTTON_CLICKED,k.CLICK,{element:"opt_in_cta",button_text:"Build my schedule"}),l(!0),u(!1),y.length===0&&s(_h(!0)),s(Mn(!0)),s(hn(!1))},[s,y,l,u]),A=r.useCallback($=>{t($?w.CHECKBOX_SELECTED:w.CHECKBOX_UNSELECTED,k.CLICK,{element:"opt_in_modal_auto_assign"}),s(oi($)),at(ai,$)},[s,t]),P=r.useCallback(()=>{A(!g)},[g,A]),M=r.useCallback($=>{t(w.CHECKBOX_CLICKED,k.CLICK,{element:"opt_in_modal",text:"Don't show this again",is_checked:$}),f($),u($),m($)},[u,m,t]),R=r.useCallback(()=>{M(!_)},[_,M]);return e.jsx(Mt,{open:n,onClose:T,width:480,noPadding:!0,children:()=>e.jsxs(i,{p:40,children:[e.jsxs(i,{flex:!0,alignItemsCenter:!0,gap:8,children:[e.jsx(wr,{variant:"warning",children:p("schedule_builder.agent.opt_in.dialog.beta")}),e.jsx(i,{children:e.jsx(j,{variant:"bodySmTight",color:"mono700",children:p("schedule_builder.agent.opt_in.dialog.beta_feedback")})})]}),e.jsx(i,{pt:16,children:e.jsx(j,{variant:"heading1",children:p("schedule_builder.agent.opt_in.dialog.title")})}),e.jsx(i,{column:!0,gap:4,pt:4,children:e.jsx(j,{variant:"bodySm",color:"mono700",children:p("schedule_builder.agent.opt_in.dialog.draft_headline",{props:{dates:v}})})}),e.jsxs(i,{pt:4,children:[p1.map(($,B)=>e.jsxs(i,{row:!0,alignItemsCenter:!0,pt:16,gap:12,children:[e.jsx(i,{p:12,bradiusm:!0,bgcolor:$.iconBgColor,children:e.jsx(ns,{iconName:$.iconName,size:"medium",color:$.iconColor})}),e.jsx(i,{children:e.jsx(i,{column:!0,children:e.jsx(j,{variant:"bodySmBoldTight",children:$.title})})})]},B)),e.jsx(i,{pt:24,pb:16,children:e.jsxs(i,{column:!0,gap:12,children:[e.jsxs(i,{flex:!0,alignItemsStart:!0,bw:1,bcolor:"mono300",bradiusm:!0,ph:12,pv:8,children:[e.jsx(i,{alignItemsCenter:!0,mt:-4,children:e.jsx(ro,{name:"schedule-builder-agent-auto-assign",checked:g,onClick:A,labelTextProps:{variant:"bodyBold",color:"mono700"},"aria-label":p("schedule_builder.agent.opt_in.dialog.auto_assign.label")})}),e.jsx(i,{column:!0,pointer:!0,onClick:P,"aria-hidden":!0,mt:1,children:e.jsx(j,{color:"secondary",variant:"bodySmTight",children:p("schedule_builder.agent.opt_in.dialog.auto_assign.label")})})]}),e.jsx(V,{fullWidth:!0,onClick:L,children:p("schedule_builder.agent.opt_in.dialog.button_primary_text",{props:{dates:v}})}),e.jsx(V,{variant:"secondary",fullWidth:!0,onClick:D,children:p("schedule_builder.agent.opt_in.dialog.button_secondary_text")})]})})]}),e.jsxs(i,{flex:!0,alignItemsCenter:!0,children:[e.jsx(ro,{name:"schedule-builder
1-agent-dont-show-again",checked:_,onClick:M,"aria-label":p("schedule_builder.agent.opt_in.dialog.dont_show_again")}),e.jsx(i,{pointer:!0,onClick:R,"aria-hidden":!0,children:e.jsx(j,{variant:"bodySmTight",color:"secondary",children:p("schedule_builder.agent.opt_in.dialog.dont_show_again")})})]})]})})},f1=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_ONBOARDING})(_1),{cx:b1}=O("CopyPasteModeOverlay"),Of=({onExit:t,hideNoitifcation:s})=>{const n=r.useCallback(o=>{o.key==="Escape"&&t()},[t]);return r.useEffect(()=>{s()}),r.useEffect(()=>(po().addEventListener("keydown",n),()=>po().removeEventListener("keydown",n)),[n]),e.jsx("div",{className:b1(),children:e.jsx(dt,{variant:"info",title:p("schedule_builder.copy_mode_banner.alert.title"),action:e.jsx(V,{variant:"secondary",onClick:t,size:"small",children:p("schedule_builder.copy_mode_banner.alert.exit")}),children:p("schedule_builder.copy_mode_banner.alert.desc")})})};Of.propTypes={copyPasteFirstTimeInstructionsShown:d.bool,onExit:d.func.isRequired,hideNoitifcation:d.func.isRequired};const Nf=F(()=>({}),{onExit:ie.stopCopyPaste,hideNoitifcation:ie.hideNotification})(r.memo(Of)),{cx:ou,cxEl:g1}=O("EWVHeaderCell");function Mf({date:t}){const s=r.useMemo(()=>Cu(t),[t]),[n,o]=r.useState(!1),a=r.useCallback(()=>{o(!0)},[]),l=r.useCallback(()=>{o(!1)},[]),c=r.useMemo(()=>s?ou("today"):ou(),[s]),u=r.useMemo(()=>n?"purple900":"purple500",[n]),h=r.useMemo(()=>s?2:0,[s]),m=r.useMemo(()=>n?"purple100":"",[n]),_=r.useMemo(()=>s?"purple500":"mono900",[s]);return e.jsx(Ue,{className:c,hcenter:!0,"data-testid":Bt(t).toLowerCase(),btw:0,bbw:0,children:e.jsx(i,{vcenter:!0,hcenter:!0,row:!0,borderbox:!0,w:"100%",grow:1,children:e.jsx(la,{to:`/schedule/employee/day/${t}`,className:g1("pill"),children:e.jsx(i,{row:!0,gap:3,bcolor:u,bw:h,bradiusfull:!0,ph:12,pv:4,onMouseEnter:a,onMouseLeave:l,bgcolor:m,children:e.jsx(j,{variant:"heading4",color:_,children:`${Jb(t)}, ${ll(t)}`})})})})})}Mf.propTypes={date:d.string.isRequired};const x1=r.memo(Mf),{cx:C1}=O("EWVHeaderFirstCell");function E1(){return e.jsx(Ue,{minw:sn.WEEK_VIEW,className:C1(),blw:0,btw:0,bbw:0,vcenter:!0,children:e.jsx(i,{pl:24,pr:16,children:e.jsx(_f,{})})})}const S1=r.memo(E1),{cx:j1}=O("EWVHeaderRow"),Pf=64,y1=()=>{const t=I(Ft);return e.jsxs(Et,{className:j1(),top:0,shadow:"z1",shadowDirection:"bottom",h:Pf,children:[e.jsx(S1,{}),t?.map(s=>e.jsx(x1,{date:s},s))]})},v1=r.memo(y1),I1=Nr("scheduleBuilder/fetchWidgetData",({canViewSales:t,canViewLabor:s,...n},{dispatch:o})=>Ab.unstable_batchedUpdates(()=>{t&&o(ij({startDate:n.start_date,endDate:n.end_date})),s&&o(cj({startDate:n.start_date,endDate:n.end_date}))})),{cx:T1}=O("DepartmentDetails"),ic=({showName:t,name:s,hours:n,wages:o,bold:a,percentage:l})=>e.jsxs(i,{className:T1(),spacebetween:!0,vcenter:!0,h:24,dataTestId:"department-block",children:[e.jsx(Y,{fs12:!0,navy:!0,children:t?s:""}),e.jsxs(Y,{fs12:!0,fw600:a,grayXdark:!0,children:[n.toFixed()," h | ",pt(o,{precision:0})," | ",l,"%"]})]});ic.defaultProps={bold:!0,showName:!0,hours:0,wages:0};ic.propTypes={departmentId:d.string.isRequired,name:d.string,hours:d.number,wages:d.number,bold:d.bool};const $f=F((t,s)=>({name:_i({state:t,id:s.departmentId,attribute:"name"}),wages:bi(t,s),hours:fi(t,s),percentage:dj(t,s)}),{})(r.memo(ic)),{cx:w1}=O("DepartmentsCell"),D1=({departments:t,date:s})=>e.jsx(Ue,{className:w1(),overflowY:"visible",vcenter:!1,spacebetween:!0,"data-testid":Bt(s).toLowerCase(),children:e.jsx(i,{column:!0,pt:31,ph:10,children:t.map(n=>e.jsx($f,{departmentId:n,showName:!1,bold:!1,date:s},n))})}),k1=F(t=>({departments:mm(t)}),{})(r.memo(D1)),{cx:R1}=O("DepartmentsFirstCell"),L1=({departments:t,day:s})=>e.jsx(Ue,{className:R1(),grow:2,hcenter:!1,spacebetween:!0,overflowY:"visible",blw:0,children:e.jsxs(i,{ph:10,column:!0,children:[e.jsx(i,{mv:6,children:e.jsx(Y,{fs12:!0,fw600:!0,navy:!0,uppercase:!0,i18n:"schedule_builder.react_page.forecast_widget.department_widget.by_department"})}),e.jsx(i,{column:!0,children:t.map(n=>e.jsx($f,{departmentId:n,day:s},n))})]})}),A1=F(t=>({departments:mm(t)}),{})(r.memo(L1)),{cx:O1}=O("DepartmentsRow"),N1=({dates:t})=>e.jsxs(Et,{className:O1(),children:[e.jsx(A1,{}),t?.map(s=>e.jsx(k1,{date:s},s))]}),M1=r.memo(N1);var tl={},au;function P1(){return au||(au=1,(function(t){Object.defineProperty(t,"__esMo
1dule",{value:!0});var s="fas",n="cloud-sun",o=640,a=512,l=[],c="f6c4",u="M575.2 325.7c.2-1.9.8-3.7.8-5.6 0-35.3-28.7-64-64-64-12.6 0-24.2 3.8-34.1 10-17.6-38.8-56.5-66-101.9-66-61.8 0-112 50.1-112 112 0 3 .7 5.8.9 8.7-49.6 3.7-88.9 44.7-88.9 95.3 0 53 43 96 96 96h272c53 0 96-43 96-96 0-42.1-27.2-77.4-64.8-90.4zm-430.4-22.6c-43.7-43.7-43.7-114.7 0-158.3 43.7-43.7 114.7-43.7 158.4 0 9.7 9.7 16.9 20.9 22.3 32.7 9.8-3.7 20.1-6 30.7-7.5L386 81.1c4-11.9-7.3-23.1-19.2-19.2L279 91.2 237.5 8.4C232-2.8 216-2.8 210.4 8.4L169 91.2 81.1 61.9C69.3 58 58 69.3 61.9 81.1l29.3 87.8-82.8 41.5c-11.2 5.6-11.2 21.5 0 27.1l82.8 41.4-29.3 87.8c-4 11.9 7.3 23.1 19.2 19.2l76.1-25.3c6.1-12.4 14-23.7 23.6-33.5-13.1-5.4-25.4-13.4-36-24zm-4.8-79.2c0 40.8 29.3 74.8 67.9 82.3 8-4.7 16.3-8.8 25.2-11.7 5.4-44.3 31-82.5 67.4-105C287.3 160.4 258 140 224 140c-46.3 0-84 37.6-84 83.9z";t.definition={prefix:s,iconName:n,icon:[o,a,l,c,u]},t.faCloudSun=t.definition,t.prefix=s,t.iconName=n,t.width=o,t.height=a,t.ligatures=l,t.unicode=c,t.svgPathData=u})(tl)),tl}var $1=P1();const nr=({label:t,onClick:s,className:n,isActive:o,isExpanded:a,children:l})=>e.jsx("button",{type:"button",className:n,onClick:s,"aria-label":t,"aria-pressed":o,"aria-expanded":a,children:l}),{cx:B1,cxEl:rr}=O("ForecastWidgetActions"),U1=({onToggleBlock:t,onToggleWidget:s,widgetExpanded:n,isSalesForecastEnabled:o,isWeatherForecastEnabled:a,isWagePercentageForecastEnabled:l,isDepartmentsForecastEnabled:c,canViewSales:u,canViewLabor:h})=>{const m=K(),_=r.useCallback(()=>{m(w.ICON_CLICKED,k.CLICK,{iconDescription:"sales",enabled:!o}),t("isSalesForecastEnabled")},[o,t,m]),f=r.useCallback(()=>{m(w.ICON_CLICKED,k.CLICK,{iconDescription:"target labor %",enabled:!l}),t("isWagePercentageForecastEnabled")},[l,t,m]),g=r.useCallback(()=>{m(w.ICON_CLICKED,k.CLICK,{iconDescription:"weather",enabled:!a}),t("isWeatherForecastEnabled")},[a,t,m]),b=r.useCallback(()=>{m(w.ICON_CLICKED,k.CLICK,{iconDescription:"s&l by dept",enabled:!c}),t("isDepartmentsForecastEnabled")},[c,t,m]),x=r.useCallback(()=>{m(w.CARET_CLICKED,k.CLICK,{caret_direction:n?"close":"open"}),s(!n)},[s,m,n]);return e.jsxs(i,{className:B1(),children:[n&&e.jsxs(e.Fragment,{children:[u&&e.jsx(Ae,{content:e.jsx(Y,{i18n:"schedule_builder.react_page.forecast_widget.forecast_widget_actions.sales"}),placement:"top",children:e.jsx("div",{children:e.jsx(Fs,{feature:"sales_forecast",focusedFeature:"businessInsights",children:e.jsx(nr,{className:rr("salesToggle",{active:o}),isActive:o,label:p("schedule_builder.react_page.forecast_widget.forecast_widget_actions.sales"),onClick:_,children:e.jsx(Q,{iconName:"Money",size:"small"})})})})}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{content:e.jsx(Y,{i18n:"schedule_builder.react_page.forecast_widget.forecast_widget_actions.target_labor_percentage"}),placement:"top",children:e.jsx("div",{children:e.jsx(Fs,{feature:"sales_forecast",focusedFeature:"businessInsights",children:e.jsx(nr,{className:rr("laborTargetToggle",{active:l}),isActive:l,label:p("schedule_builder.react_page.forecast_widget.forecast_widget_actions.target_labor_percentage"),onClick:f,children:e.jsx(Q,{iconName:"ChartColumn",size:"small"})})})})}),e.jsx(Ae,{content:e.jsx(Y,{i18n:"schedule_builder.react_page.forecast_widget.forecast_widget_actions.s_and_l_by_dept"}),placement:"top",children:e.jsx("div",{children:e.jsx(Fs,{feature:"sales_forecast",focusedFeature:"businessInsights",children:e.jsx(nr,{className:rr("byDepartmentToggle",{active:c}),isActive:c,label:p("schedule_builder.react_page.forecast_widget.forecast_widget_actions.s_and_l_by_dept"),onClick:b,children:e.jsx(Q,{iconName:"BusinessAddress",size:"small"})})})})})]}),e.jsx(Ae,{content:e.jsx(Y,{i18n:"schedule_builder.react_page.forecast_widget.forecast_widget_actions.weather"}),placement:"top",children:e.jsx("div",{children:e.jsx(Fs,{feature:"sales_forecast",focusedFeature:"none",children:e.jsx(nr,{className:rr("weatherToggle",{active:a}),isActive:a,label:p("schedule_builder.react_page.forecast_widget.forecast_widget_actions.weather"),onClick:g,children:e.jsx(uj,{icon:$1.faCloudSun})})})})}),e.jsx("div",{className:rr("separator")})]}),e.jsx(nr,{isExpanded:n,label:p(n?"schedule_builder.react_page.forecast_widget.forecast_widget_actions.collapse_widget":"schedule_builder.react_page.forecast_widget.forecast_widget_actions.expand_widget"),onClick:x,children:e.jsx(Q,{iconName:n?"CaretDown":"CaretUp",size:"small"})})]})},Bf=({target:t,actual:s,onSave:n})=>{const o=K(),[a,l]=r.useState();r.useEffect(()=>{t&&l(t)},[t]);const c=r.useCallback(_=>l(_.target.value),[l]),u=r.useCallback(()=>{o(w.LABOR_TARGET_UPDATED,k.CLICK),n(a)},[n,o,a]),h=ds(s),m=ds(t);return e.jsxs(i,{row:!0,vcenter:!0,children:[e.jsx(i,{maxw:70,children:e.jsx(An,{inline:!0,textAlign:"right",type:"percent",placeholder:"N/A",fontSize:"14",size:"narrow",value:a,name:"target",onChange:c,onBlur:u})}),e.jsx(Y,{style:{marginLeft:8,whiteSpace:"noWrap"},fs:14,fw600:!0,red:h||m||s?.toFixed(1)>t?.toFixed(1),green:!h&&!m&&s?.toFixed(1)<=t?.toFixed(1),children:h?"N/A":`${s.toFixed(1)}%`})]})};Bf.propTypes={target:d.number,actual:d.number,onSave:d.func.isRequired};const Uf=r.memo(Bf),{cx:H1}=O("LaborTargetCell"),Hf=({date:t,onSave:s,actual:n,target:o})=>{const a=r.useCallback(l=>s({date:t,value:l,weekly:!1}),[t,s]);return e.jsx(Ue,{className:H1(),hcenter:!1,"data-testid":Bt(t).toLowerCase(),children:e.jsx(i,{ph:8,hright:!0,h:"100%",children:e.jsx(Uf,{actual:n,target:o,onSave:a})})})};Hf.propTypes={date:d.string.isRequired,actual:d.number,target:d.number,onSave:d.func.isRequired};const F1=F((t,s)=>({actual:mj(t,s),target:hj({state:t,attribute:"value",id:s.date})}),{onSave:pm})(r.memo(Hf)),W1=os(Wn,t=>fm({state:t,attribute:"weekly",value:!0}),(t,s)=>s.find(n=>n.id===`summary_${t}`));os(t=>fm({state:t,attribute:"weekly",value:!1}),W1,(t,s)=>s?s.value:t.reduce((n,o)=>n+o.value,0)/7);function Ff(t,s){return t&&s?t/s*100:null}const V1=os(gi,_m,Ff);Te(bm,(t,s)=>gm(t,s.date),Ff)((t,s)=>`selectLaborTargetForDate-${s.date}`);const{cx:K1}=O("LaborTargetSummaryCell"),Wf=({target:t,actual:s,onSave:n})=>{const o=r.useCallback(a=>n({value:a,weekly:!0}),[n]);return e.jsx(Ue,{className:K1(),blw:0,children:e.jsxs(i,{spacebetween:!0,vcenter:!0,ph:10,borderbox:!0,w:"100%",children:[e.jsxs("div",{children:[e.jsx("div",{children:e.jsx(Y,{fs:14,uppercase:!0,fw600:!0,i18n:"schedule_builder.react_page.forecast_widget.labor_target_forecast.title"})}),e.jsx("div",{children:e.jsx(Y,{fs:12,navy:!0,i18n:"schedule_builder.react_page.forecast_widget.labor_target_forecast.desc"})})]}),e.jsx(i,{pl:8,children:e.jsx(Uf,{target:t,actual:s,onSave:o})})]})})};Wf.propTypes={target:d.number,actual:d.number,onSave:d.func.isRequired};const q1=F((t,s)=>({target:pj(t,s),actual:V1(t,s)}),{onSave:pm})(r.memo(Wf)),{cx:z1}=O("LaborTargetsRow"),G1=({dates:t,isLoaded:s})=>
1e.jsxs(Et,{className:z1({isLoaded:s}),children:[e.jsx(q1,{}),t?.map(n=>e.jsx(F1,{date:n},n))]}),Y1=F(t=>({isLoaded:!_j(t)&&!xm(t)}))(r.memo(G1)),{cx:J1}=O("SalesCell"),X1=800,Q1=(t,s)=>ds(t)||ds(s)||t===""||s===""?ds(t)===ds(s)||t===s:parseFloat(t)===parseFloat(s),Vf=({date:t,sales:s,isPastDay:n,onSave:o,manual:a})=>{const[l,c]=r.useState(),u=r.useRef(),h=a||s;r.useEffect(()=>{h&&(u.current=s,c(s))},[h,s]);const m=r.useCallback(b=>{ds(b)||o({id:t,payload:{value:b,manual:!0}})},[o,t]),_=r.useMemo(()=>um(m,X1),[m]);r.useEffect(()=>()=>_.cancel(),[_]);const f=r.useCallback(b=>{const x=b.target.value;c(x),!Q1(x,u.current)&&_(x)},[_]),g=r.useCallback(()=>{_.cancel(),String(l)!==String(u.current)&&m(l)},[_,m,l]);return e.jsx(Ue,{className:J1(),hcenter:!1,"data-testid":Bt(t).toLowerCase(),children:e.jsx(i,{ph:8,hright:!0,vcenter:!0,h:"100%",children:e.jsx(Ae,{content:h?p(`schedule_builder.react_page.forecast_widget.sales_forecast.${a?"tooltip_manual":"tooltip_estimate"}`):void 0,placement:"top",children:e.jsx("span",{children:n?e.jsx(Y,{fs:14,children:h?pt(s):"N/A"}):e.jsx(An,{inline:!0,textAlign:"right",type:"currency",placeholder:"N/A",fontSize:"14",size:"narrow",value:l,onChange:f,onBlur:g})})})})})};Vf.propTypes={date:d.string.isRequired,sales:d.number,onSave:d.func.isRequired,isPastDay:d.bool,manual:d.bool};const Z1=F((t,s)=>({sales:gm(t,s.date),manual:bj(t,s.date),isPastDay:fj(t,s)}),{onSave:gj})(r.memo(Vf)),{cx:eO}=O("SalesSummaryCell"),Kf=({sales:t})=>e.jsx(Ue,{className:eO(),blw:0,children:e.jsxs(i,{spacebetween:!0,vcenter:!0,ph:10,borderbox:!0,h:"100%",children:[e.jsx(Y,{fs:14,uppercase:!0,fw600:!0,i18n:"schedule_builder.react_page.forecast_widget.sales_forecast.title"}),e.jsx(Y,{fs:14,fw600:!0,children:pt(t)})]})});Kf.propTypes={sales:d.number};const tO=F((t,s)=>({sales:_m(t,s)}))(r.memo(Kf)),{cx:sO}=O("SalesRow"),nO=({dates:t,isLoaded:s})=>e.jsxs(Et,{className:sO({isLoaded:s}),children:[e.jsx(tO,{}),t?.map(n=>e.jsx(Z1,{date:n},n))]}),rO=F(t=>({isLoaded:!xm(t)}))(r.memo(nO)),{cx:oO}=O("TotalsDayCell"),cc=({hours:t,wages:s,numEmployees:n,isWageForecastVisible:o,isHoursForecastVisible:a,isPeopleForecastVisible:l,canViewWages:c,date:u})=>e.jsx(Ue,{className:oO(),"data-testid":Bt(u).toLowerCase(),pt:0,minh:44,children:e.jsxs(i,{spacebetween:!0,vcenter:!0,ph:10,borderbox:!0,h:"100%",children:[e.jsx("div",{"data-testid":"day-totals-employee-count",children:l&&e.jsxs(i,{vcenter:!0,row:!0,children:[e.jsx(Q,{iconName:"User",size:"xsmall",mr:3}),e.jsx(j,{variant:"captions",color:"mono700",children:n})]})}),e.jsxs("div",{children:[e.jsx(i,{tright:!0,children:o&&c&&e.jsx(j,{variant:"captions",color:"mono700",children:pt(s)})}),e.jsx(i,{tright:!0,children:a&&e.jsx(j,{variant:"captions",color:"mono700",children:t.toFixed(2)})})]})]})});cc.propTypes={date:d.string.isRequired,wages:d.number,hours:d.number,numEmployees:d.number,isWageForecastVisible:d.bool,isHoursForecastVisible:d.bool,isPeopleForecastVisible:d.bool,canViewWages:d.bool};cc.defaultProps={numEmployees:0,wages:0,hours:0};const aO=F((t,s)=>({wages:bm(t,{date:s.date}),hours:Cj(t,{date:s.date}),numEmployees:xj(t,s),isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"}),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),isPeopleForecastVisible:Le({state:t,attribute:"isPeopleForecastVisible"}),canViewWages:Ls(t)}))(r.memo(cc)),{cx:lO}=O("TotalsSummaryCell"),dc=({hours:t,wages:s,isWageForecastVisible:n,isHoursForecastVisible:o,canViewWages:a})=>e.jsx(Ue,{minw:sn.WEEK_VIEW,className:lO(),blw:0,pt:0,minh:44,children:e.jsxs(i,{spacebetween:!0,vcenter:!0,ph:10,borderbox:!0,h:"100%",children:[e.jsxs("div",{children:[n&&a&&e.jsx(j,{color:"mono700",variant:"captionBold",children:p("schedule_builder.react_page.forecast_widget.totals_block.wages")}),o&&e.jsx(j,{color:"mono700",variant:"captionBold",children:p("schedule_builder.react_page.forecast_widget.totals_block.hours")})]}),e.jsxs("div",{children:[n&&a&&e.jsx(i,{tright:!0,children:e.jsx(j,{color:"mono700",variant:"captionBold",children:pt(s)})}),o&&e.jsx(i,{tright:!0,children:e.jsx(j,{color:"mono700",variant:"captionBold",children:t.toFixed(2)})})]})]})});dc.propTypes={wages:d.number,hours:d.number,isWageForecastVisible:d.bool,isHoursForecastVisible:d.bool,canViewWages:d.bool};dc.defaultProps={wages:0,hours:0};const iO=F((t,s)=>({wages:gi(t,s),hours:Rh(t,s),isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"}),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),canViewWages:Ls(t)}))(r.memo(dc)),{cx:cO}=O("TotalsRow"),qf=({dates:t,showLaborSummaryRow:s})=>s&&e.jsxs(Et,{className:cO(),children:[e.jsx(iO,{}),t?.map(n=>e.jsx(aO,{date:n},n))]})||e.jsx(e.Fragment,{});
1qf.propTypes={dates:d.array.isRequired,showLaborSummaryRow:d.bool};const dO=F(t=>({showLaborSummaryRow:Le({state:t,attribute:"isWageForecastVisible"})||Le({state:t,attribute:"isHoursForecastVisible"})||Le({state:t,attribute:"isPeopleForecastVisible"})}),{})(r.memo(qf)),{cx:uO}=O("WeatherCell"),zf=({date:t})=>{const s=I(Cm),n=I(u=>Ej(u,t)),{min:o,max:a,icon:l}=n;function c(){return s?e.jsx(da,{centered:!0}):l?e.jsxs(i,{hright:!0,borderbox:!0,vcenter:!0,h:"100%",ph:10,children:[e.jsx(Y,{fs14:!0,grayXdark:!0,text:`${a}°`}),e.jsx(Ae,{content:e.jsx(Y,{i18n:`schedule_builder.react_page.forecast_widget.weather_widget.${l}`}),placement:"top",children:e.jsx(i,{mh:12,children:e.jsx(Zh,{type:l,size:20,color:"grayXdark"})})}),e.jsx(Y,{fs14:!0,grayXdark:!0,text:`${o}°`})]}):null}return e.jsx(Ue,{className:uO(),overflowY:"hidden",hcenter:!1,spacebetween:!0,"data-testid":Bt(t).toLowerCase(),children:c()})};zf.propTypes={isLoading:d.bool,min:d.number,max:d.number,icon:d.string,date:d.string};const{cx:hO}=O("WeatherFirstCell"),mO=()=>e.jsx(Ue,{className:hO(),grow:2,overflowY:"hidden",hcenter:!1,spacebetween:!0,blw:0,children:e.jsx(i,{spacebetween:!0,vcenter:!0,ph:10,borderbox:!0,h:"100%",children:e.jsx(Y,{fs:14,uppercase:!0,fw600:!0,i18n:"schedule_builder.react_page.forecast_widget.weather_widget.weather_forecast"})})}),pO=r.memo(mO),{cx:_O}=O("WeatherRow"),fO=({dates:t,isLoaded:s})=>e.jsxs(Et,{className:_O({isLoaded:s}),children:[e.jsx(pO,{}),t?.map(n=>e.jsx(zf,{date:n},n))]}),bO=F(t=>({isLoaded:!Cm(t)}))(r.memo(fO)),{cx:gO}=O("ForecastWidget"),xO=({dates:t,onUpdateScheduleProperties:s,isSalesForecastEnabled:n,isWeatherForecastEnabled:o,isWagePercentageForecastEnabled:a,isDepartmentsForecastEnabled:l,isBudgetForecastEnabled:c,onFetchWidgetData:u,onFetchWeatherForecast:h,canViewSales:m,canViewLabor:_})=>{const[f,g]=r.useState(c),[b,x]=r.useState({});r.useEffect(()=>{t[0]&&t[6]&&(u({start_date:t[0],end_date:t[6],canViewSales:m,canViewLabor:_}),o&&h({start_date:t[0],end_date:t[6]}))},[t[0],m,_,o]),r.useEffect(()=>{x({isSalesForecastEnabled:n,isWeatherForecastEnabled:o,isWagePercentageForecastEnabled:a,isDepartmentsForecastEnabled:l})},[n,o,a,l]);const E=r.useCallback(C=>{b[C]=!b[C],x({...b}),s({[C]:b[C]})},[b,s]),S=r.useCallback(C=>{g(C),s({isBudgetForecastEnabled:C})},[g,s]),y=m&&b.isSalesForecastEnabled||_&&b.isWagePercentageForecastEnabled||b.isDepartmentsForecastEnabled||b.isWeatherForecastEnabled;return e.jsxs(i,{className:gO(),children:[e.jsx(U1,{widgetExpanded:f,onToggleWidget:S,onToggleBlock:E,isSalesForecastEnabled:b.isSalesForecastEnabled,isWeatherForecastEnabled:b.isWeatherForecastEnabled,isWagePercentageForecastEnabled:b.isWagePercentageForecastEnabled,isDepartmentsForecastEnabled:b.isDepartmentsForecastEnabled,canViewSales:m,canViewLabor:_}),e.jsx(dO,{dates:t}),f&&y&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{maxh:210,children:[m&&b.isSalesForecastEnabled&&e.jsx(rO,{dates:t}),_&&b.isWagePercentageForecastEnabled&&e.jsx(Y1,{dates:t}),_&&b.isDepartmentsForecastEnabled&&e.jsx(M1,{dates:t})]}),b.isWeatherForecastEnabled&&e.jsx(bO,{dates:t})]})]})},CO=F(t=>({canViewSales:Sj(t),isSalesForecastEnabled:Le({state:t,attribute:"isSalesForecastEnabled"}),isWeatherForecastEnabled:Le({state:t,attribute:"isWeatherForecastEnabled"}),isWagePercentageForecastEnabled:Le({state:t,attribute:"isWagePercentageForecastEnabled"}),isDepartmentsForecastEnabled:Le({state:t,attribute:"isDepartmentsForecastEnabled"}),isBudgetForecastEnabled:Le({state:t,attribute:"isBudgetForecastEnabled"}),canViewLabor:Lh(t),dates:Ft(t)}),{onUpdateScheduleProperties:Em,onFetchWidgetData:I1,onFetchWeatherForecast:jj})(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_EXPANDED_FORECAST})(xO))),EO=(t,s,n,o,a,l)=>{const c={};let u=1;return s&&(c.eventRowIndex=u,u++),t&&(c.blackoutRowIndex=u,u++),n&&(c.openShiftRowIndex=u,u++),o&&(c.teamMembersCountRowIndex=u,u++),c.viewRowsStartIndex=u,u+=l,a&&(c.addEmployeeRowIndex=u,u++),{rowsCounter:u,indices:c}},SO=(t,s)=>{if(!t||!Array.isArray(t)||s==null)return-1;const n=t.map(String),o=String(s);return n.indexOf(o)},{cx:jO}=O("EWVEventCell");function Gf({canManageEmployees:t,canManageSchedule:s,eventIds:n,date:o}){const[a,l]=r.useState(!1),[c,u]=r.useState(!1),h=r.useRef(null),[m,_]=r.useState(null);r.useEffect(()=>{_(h.current)},[a]);const f=r.useCallback(()=>{u(!1),l(!0)},[]),g=r.useCallback(()=>
1{l(!1)},[]);return e.jsxs(Ue,{"data-testid":Bt(o).toLowerCase(),className:jO({hovered:c}),minh:32,pt:8,children:[e.jsxs(e.Fragment,{children:[n.map(b=>e.jsx(nc,{eventId:b},b)),a&&e.jsx(Ur,{ref:h}),(t||s)&&e.jsx(ya,{isEventCell:!0,date:o,onAddActionClick:f,setHovered:u})]}),a&&e.jsx(W_,{date:o,anchorEl:m,open:a,onClose:g})]})}Gf.propTypes={canManageEmployees:d.bool.isRequired,date:d.string.isRequired,eventIds:d.array.isRequired};const yO=F((t,s)=>({canManageEmployees:Ni(t),canManageSchedule:Dr(t),eventIds:Dk(t,s.date)}))(r.memo(Gf)),{cx:vO}=O("EWVEventsFirstCell");function Yf({eventsCount:t}){return e.jsx(Ue,{className:vO(),blw:0,minw:sn.WEEK_VIEW,minh:30,pt:8,pb:4,children:e.jsx(i,{ml:24,vcenter:!0,children:e.jsx(h_,{feature:"events",children:s=>e.jsxs(i,{row:!0,children:[e.jsx(i,{vcenter:!0,children:e.jsx(Q,{iconName:"Calendar",size:"small",color:"mono700"})}),e.jsx(i,{pl:12,children:e.jsx(j,{variant:"bodySm",color:"mono900",children:p("schedule_builder.react_page.events.title",{props:{count:t}})})})]})})})})}Yf.propTypes={eventsCount:d.number.isRequired};const IO=F(t=>({eventsCount:wk(t)}))(r.memo(Yf)),{cx:TO}=O("EWVEventsRow");function Jf({dates:t}){return e.jsxs(Et,{bg:"mono0",className:TO(),children:[e.jsx(IO,{}),t?.map(s=>e.jsx(yO,{date:s},s))]})}Jf.propTypes={dates:d.array.isRequired};const wO=F(t=>({dates:Ft(t)}))(r.memo(Jf)),{cx:DO}=O("EWVOpenShiftCell");function Xf({shifts:t,date:s,currentLocationId:n,isCopyPasteMode:o,isManager:a,selectedOpenShiftId:l}){const c=r.useRef(null),[u,h]=r.useState(null),[m,_]=r.useState(!1),[f,g]=r.useState(!1),b=r.useMemo(()=>({type:"location",id:n}),[n]),{isOver:x,setNodeRef:E}=Yn({owner:b,date:s});r.useEffect(()=>{h(c.current)},[f]);const S=r.useCallback(()=>g(!1),[]),y=r.useCallback(()=>{g(C=>!C)},[]);return e.jsxs(Ue,{"data-testid":Bt(s).toLowerCase(),ref:E,className:DO({dragIsOver:x,hovered:m}),bbw:0,children:[t.map(C=>e.jsx(kn,{shiftId:C.id,noUserName:!0,isOpen:!0,showClaimModal:C.id===l?.toString()},C.id)),f&&e.jsx(Ur,{ref:c}),a&&!f&&e.jsx(ya,{date:s,owner:b,onAddActionClick:y,setHovered:_,isCopyPasteMode:o}),f&&e.jsx(Ns,{isAdding:!0,isOpenShift:!0,anchorEl:u,open:f,onClose:S,date:s})]})}Xf.propTypes={date:d.string.isRequired,shifts:d.array.isRequired,isCopyPasteMode:d.bool,isManager:d.bool,currentLocationId:d.string.isRequired};const kO=F((t,s)=>({shifts:Yp(t,s),currentLocationId:String(ct(t)),isCopyPasteMode:!!tn(t),isManager:He(t)}))(r.memo(Xf)),{cx:RO}=O("EWVOpenShiftsFirstCell");function Qf({openShiftsCount:t,formattedTotalHours:s}){return e.jsx(Ue,{minw:sn.WEEK_VIEW,className:RO(),blw:0,bbw:0,children:e.jsxs(i,{row:!0,ml:24,vcenter:!0,children:[e.jsx(i,{vcenter:!0,children:e.jsx(Q,{iconName:"Progress",size:"small",color:"mono700"})}),e.jsxs(i,{pl:12,children:[e.jsx(j,{variant:"bodySm",color:"mono900",children:p("schedule_builder.react_page.open_shifts.title",{props:{count:t}})}),e.jsxs(j,{variant:"captions",color:"mono700",children:[s," Hrs"]})]})]})})}Qf.propTypes={formattedTotalHours:d.string.isRequired,openShiftsCount:d.number.isRequired,className:d.string};const LO=F(t=>({openShiftsCount:Rk(t),formattedTotalHours:Lk(t)}))(r.memo(Qf)),{cx:AO}=O("EWVOpenShiftsRow");function Zf({dates:t,selectedOpenShiftId:s}){return e.jsxs(Et,{className:AO(),children:[e.jsx(LO,{}),t?.map(n=>e.jsx(kO,{date:n,selectedOpenShiftId:s},n))]})}Zf.propTypes={dates:d.array.isRequired};const OO=r.memo(Zf),{cx:lu}=O("EWVTeamMemberRow");function eb({dates:t}){return e.jsxs(Et,{bbw:0,bg:"none",className:lu(),children:[e.jsx(Ue,{minw:sn.WEEK_VIEW,className:lu(),pt:2,pb:4,blw:0,bbw:0,minh:24,children:e.jsx(i,{pl:24,children:e.jsx(gf,{})})}),t?.map(s=>e.jsx(Ue,{bbw:0,minh:20,blw:0},s))]})}eb.propTypes={dates:d.array.isRequired};const NO=r.memo(eb),MO=({onAddEmployee:t,onSetAddTeamPageContext:s,onShowEnforcementDialog:n,canCloseEnforcementDialog:o,shouldShowEnforcementDialog:a,cloverBaseUrl:l})=>{const c=K(),u=Qo(),h=Tm(),m=r.useCallback(()=>{c(w.ADD_EMPLOYEES_CLICKED,k.CLICK),a?n({productArea:ae.SCHEDULE_BUILDER,canCloseDialog:o}):Sn()?Ji(l,{location:"add_new_employee"}):h?(s({calledFrom:"schedule_builder"}),u.push(wm)):t()},[c,u,h,t,s,o,a,n,l]);return a?e.jsxs(i,{ph:16,pv:14,row:!0,vcenter:!0,children:[e.jsx(i,{mr:8,ml:-8,pointer:!0,children:e.jsx(qv,{content:p("enforcement.employee_cap.tooltip")})}),e.jsx(Nt,{variant:"tertiary",size:"medium",onClick:m,children:e.jsx(j,{color:"primary500",variant:"bodyBold",children:p("enforcement.employee_cap.schedule.add_employee")})})]}):e.jsx(i,{ph:8,pv:14,children:e.jsx(V,{dataTestId:"add-employee-button",variant:"tertiaryPlain",onClick:m,children:p("schedule_builder.add_employees")})})},PO=F(t=>({shouldShowEnforcementDialog:jm(t),canCloseEnforcementDialog:Sm(t),cloverBaseUrl:vi(t)}),{onAddEmployee:()=>Im({calledFrom:"schedule_builder"}),onSetAddTeamPageContext:vm,onShowEnforcementDialog:ym})(r.memo(MO)),$O=({blackoutId:t})=>e.jsx(Ue,{"data-testid":"blackout-period",minh:28,children:t&&e.jsx(ec,{blackoutId:t})}),BO=F((t,s)=>({blackoutId:yi(t,s)}))(r.memo($O)),UO=()=>e.jsx(Ue,{grow:2,overflowY:"hidden",vtop:!0,spacebetween:!0,blw:0,minw:sn.WEEK_VIEW,minh:28,pt:4,children:e.jsx(i,{pl:24,vcenter:!0,children:e.jsxs(i,{row:!0,children:[e.jsx(i,{vcenter:!0,children:e.jsx(Q,{iconName:"TimeOffDenied",size:"small",color:"mono700"})}),e.jsx(i,{pl:12,children:e.jsx(j,{variant:"bodySm",color:"mono900",children:p("schedule_builder.react_page.limited_time_off.title")})})]})})}),HO=r.memo(UO),FO=({dates:t})=>e.jsxs(Et,{bg:"mono0",children:[e.jsx(HO,{}),t?.map(s=>e.jsx(BO,{date:s},s))]}),WO=F(t=>({dates:Ft(t)}))(r.memo(FO)),VO=({data:t,index:s,setRowHeight:n,RowComponent:o})=>{const a=r.useRef(),l=r.useCallback(()=>{const h=a.current?.getBoundingClientRect();h&&n(s,h.height||0)},[n,s]),c=r.useRef(new ResizeObserver(l));r.useEffect(()=>{const h=c.current;return h.observe(a.current),()=>{h.disconnect()}},[l]);const u=r.useMemo(()=>{const{dates:h,selectedOpenShiftId:m}=t;switch(s){case 0:return null;case t.eventRowIndex:return e.jsx(wO,{});case t.blackoutRowIndex:return e.jsx(WO,{});case t.openShiftRowIndex:return e.jsx(OO,{dates:h,selectedOpenShiftId:m});case t.teamMembersCountRowIndex:return e.jsx(NO,{dates:h});case t.addEmployeeRowIndex:return e.jsx(PO,{});default:return e.jsx(o,{data:t,index:s-t.viewRowsStartIndex})}},[t,s]);return e.jsx("div",{ref:a,children:u})},KO=r.memo(VO),qO=({viewRowsCount:t,viewRowData:s,RowComponent:n,showOpenShifts:o,showEmployeesCount:a,selectedOpenShiftId:l})=>{const c=r.useRef(null),u=r.useRef({}),h=r.useRef(null),m=I(Ft),_=I(R=>!!tn(R)),f=I(yj),g=I(R=>Le({state:R,attribute:"isEventsVisible"})),b=I(He),x=I(Ni),E=I(R=>im(R,cm.RIGHT_CLICK_TOOL_TIP_SHOWN)),y=I(lm)||l||null,C=I(R=>y?vs({state:R,id:y,relationship:"owner"}):null),v=r.useMemo(()=>
1{if(!C)return null;const R=C;return R?.type==="job"?String(R.id):null},[C]),T=r.useCallback((R,$)=>{u.current[R]!==$&&(u.current[R]=$,h.current?.measure())},[]),{rowData:D,rowsCount:L}=r.useMemo(()=>{const{rowsCounter:R,indices:$}=EO(f,g,o,a,x,t);return{rowsCount:R,rowData:{...s,setRowHeight:T,...$,dates:m,isManager:b,hasSeenToolTip:E,isCopyPasteMode:_,selectedOpenShiftId:l}}},[f,g,o,a,x,t,s,T,m,b,E,_,l]),A=fh({count:L,getScrollElement:()=>c.current,estimateSize:R=>u.current[R]??60,overscan:vj});r.useEffect(()=>(h.current=A,()=>{h.current=null}),[A]);const P=D?.innerJobIds,M=r.useMemo(()=>SO(P,v),[P,v]);return r.useEffect(()=>{M>=0&&A.scrollToIndex(M,{align:"center"})},[M,A]),e.jsxs(i,{ref:c,w:"100%",style:{flex:"1 1 0",minHeight:0,overflow:"auto"},children:[e.jsx(i,{w:"100%",h:Pf,sticky:!0,style:{zIndex:100,top:0,left:0},children:e.jsx(v1,{})}),e.jsx(i,{w:"100%",relative:!0,style:{height:`${A.getTotalSize()}px`},children:A.getVirtualItems().map(R=>e.jsx(i,{"data-index":R.index,ref:A.measureElement,absolute:!0,style:{top:0,left:0,width:"100%",transform:`translateY(${R.start}px)`},children:e.jsx(KO,{data:D,index:R.index,setRowHeight:T,RowComponent:n})},R.index))}),b&&e.jsx(i,{sticky:!0,style:{zIndex:100,bottom:0,left:0,width:"100%"},children:e.jsx(CO,{})})]})},zO=r.memo(qO),{cx:GO}=O("WeekViewWrapper"),YO=({viewRowsCount:t,viewRowData:s,RowComponent:n,showOpenShifts:o,showEmployeesCount:a,dates:l,isCopyPasteMode:c,selectedOpenShiftId:u})=>e.jsx(i,{h:"100%",children:e.jsxs(i,{column:!0,spacebetween:!0,h:"100%",minh:"calc(100% - 132px)",className:GO(),children:[!l||l.length!==7?void 0:e.jsx(zO,{viewRowsCount:t,viewRowData:s,RowComponent:n,showOpenShifts:o,showEmployeesCount:a,selectedOpenShiftId:u}),e.jsx(f1,{}),c&&e.jsx(Nf,{})]})}),uc=F(t=>({dates:Ft(t),isCopyPasteMode:!!tn(t)}))(r.memo(YO)),JO=({employeeRowCallbacksRef:t})=>{const s=X(),n=Dm(),o=I(C=>Es({state:C,attribute:"sortByWeek",sliceName:"schedule"}))||Lt.FIRST_NAME,a=I(hi),l=I(Ai),c=I(Ft),u=I(C=>Li(C,{sortBy:o})),h=r.useCallback(C=>{s(Af(C))},[s]),[m,_]=r.useState(u),f=r.useRef(null),g=K(),[b,x]=r.useState(null);r.useEffect(()=>{g(w.PAGE_VIEWED,k.VIEW)},[]),r.useEffect(()=>{o===Lt.POSITION&&!a&&Array.isArray(f.current)?_(f.current):_(u)},[u,o,a]),r.useEffect(()=>{const C=Rl.parse(n.search);C.openShiftId&&x(C.openShiftId)},[n.search]);const E=r.useCallback((C,v)=>{if(!C||!v||C===v)return;const T=m.indexOf(C),D=m.indexOf(v);if(T===-1||D===-1)return;const L=Wv(m,T,D);f.current=L,_(L),h({sortBy:Lt.POSITION,ids:L})},[m,h]),S=r.useCallback(C=>m.includes(C)?{jobId:C,dates:c||[],locationIdsForUser:l||[]}:null,[m,c,l]);m1(t,{handleReorder:E,getItems:()=>m,getOverlayData:S});const y=r.useMemo(()=>({innerJobIds:m,locationIdsForUser:l}),[m,l]);return e.jsx(Vv,{items:m||[],strategy:Kv,children:e.jsx(uc,{viewRowsCount:(m||[]).length,viewRowData:y,RowComponent:u1,showOpenShifts:!0,showEmployeesCount:!0,selectedOpenShiftId:b})})};function XO(t,s,n,o){const{owner:a,date:l,roleName:c,type:u,startAt:h,endAt:m,..._}=t,{owner:f,date:g,roleName:b}=s,x=l!==g,E={..._,date:x?g:l};let S=!1,y=!1,C=x;return n===de.employee&&o===J.week?(S=!sm(a,f),C=C||S,E.owner=f,E.roleName=c):n===de.role||n===de.department?(y=c!==b,C=C||y,E.roleName=b,b==="uncategorized"&&(E.role=null),E.owner=a):o===J.month?(E.roleName=c,E.owner=a):o===J.day&&(E.roleName=c,E.owner=f),C?{updatePayload:E,trackingData:{isDateChanged:x,isEmployeeChanged:S,isRoleChanged:y}}:null}function QO({viewType:t,rangeType:s,trackUx:n,uxContext:o}){const a=X(),l=r.useCallback(u=>{const h=u.active.data.current;return bo(h,Xs.SHIFT)?h:null},[]),c=r.useCallback((u,h,m)=>{const{over:_}=u;if(!_){m?.();return}const f=h,g=_.data.current;if(!bo(f,Xs.SHIFT)||!Op(g,"CELL")){m?.();return}const b=XO(f,g,t||"",s||"");if(!b){m?.();return}n(w.SHIFT_CHANGED,k.DRAG,b.trackingData),a(ki({uxContext:o(),jobLaborTotalsId:f.owner?.id,payload:b.updatePayload})),m?.()},[a,n,o,t,s]);return{handleDragStart:l,handleDragEnd:c}}function ZO({viewType:t,rangeType:s,trackUx:n,uxContext:o}){const[a,l]=r.useState(null),[c,u]=r.useState(null),h=r.useRef(null),m=r.useRef(null),{handleDragStart:_,handleDragEnd:f}=QO({viewType:t,rangeType:s,trackUx:n,uxContext:o}),{callbacksRef:g,handleDragStart:b,handleDragEnd:x}=h1();return ih({onDragStart(E){const S=b(E);if(S){m.current=S,u(S);return}const y=_(E);h.current=y,l(y)},onDragEnd(E){if(m.current){x(E,m.current),m.current=null,u(null);return}f(E,h.current),h.current=null,l(null)},onDragCancel(){h.current=null,m.current=null,l(null),u(null)}}),{activeDragData:a,activeRowOverlayData:c,employeeRowCallbacksRef:g}}const{cx:eN}=O("DWVRWVCell");function tb({date:t,shiftIds:s,roleId:n,roleName:o,className:a,isManager:l,isCopyPasteMode:c}){const u=r.useRef(null),[h,m]=r.useState(null),[_,f]=r.useState(!1),[g,b]=r.useState(!1),{isOver:x,setNodeRef:E}=Yn({date:t,roleName:o});r.useEffect(()=>{m(u.current)},[g]);const S=r.useCallback(()=>b(!1),[]),y=r.useCallback(()=>{b(C=>!C)},[]);return e.jsxs(Ue,{bg:"white",ref:E,className:eN({dragIsOver:x,hovered:_,[a]:!!a}),"data-testid":Bt(t).toLowerCase(),children:[s.map(C=>e.jsx(kn,{shiftId:C,isRoleOrDepartment:!0},C)),g&&e.jsx(Ur,{ref:u}),l&&!g&&e.jsx(ya,{date:t,roleName:o,setHovered:f,onAddActionClick:y,isCopyPasteMode:c}),g&&e.jsx(Ns,{isAdding:!0,isOpenShift:!0,anchorEl:h,open:g,onClose:S,date:t,roleId:n})]})}
1tb.propTypes={className:d.string,roleId:d.string.isRequired,date:d.string.isRequired,isManager:d.bool,isCopyPasteMode:d.bool};const wl=F((t,{roleId:s,date:n})=>({isManager:He(t),shiftIds:kh(t,{roleId:s,date:n}),isCopyPasteMode:!!tn(t),roleName:s==="uncategorized"?"uncategorized":km(t,s)?.name}))(r.memo(tb)),{cxEl:tN}=O("DWVRWVFirstCell");function sb({name:t,hours:s,wages:n,isHoursForecastVisible:o,isWageForecastVisible:a,canViewWages:l,isLoadingLaborTotals:c,className:u,isManager:h}){const[m,_]=r.useState(h);return r.useEffect(()=>{m&&!c&&_(!1)},[c]),e.jsx(Ue,{bg:"mono0",className:tN(u),vcenter:!0,children:e.jsxs(i,{spacebetween:!0,column:!0,hleft:!0,pl:8,w:"100%",children:[e.jsx(i,{mb:4,maxw:186,ellipsis:!0,children:e.jsx(Y,{fw400:!0,fs:14,navy:!0,text:t,capitalize:!0})}),h&&(o||a)&&e.jsx("div",{children:m&&c?e.jsx(da,{}):e.jsxs(Y,{fw400:!0,navy:!0,fs:12,children:[o&&e.jsx(Y,{"data-testid":"laborHours",text:`${s.toFixed(2)} Hrs`}),o&&a&&l&&" / ",a&&l&&e.jsx(Y,{children:pt(n)})]})})]})})}sb.propTypes={name:d.string.isRequired,className:d.string,isWageForecastVisible:d.bool,isHoursForecastVisible:d.bool,isLoadingLaborTotals:d.bool,isManager:d.bool,canViewWages:d.bool,hours:d.number.isRequired,wages:d.number.isRequired};const Dl=F((t,{roleId:s})=>({name:s==="uncategorized"?"uncategorized":km(t,s)?.name,isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"}),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),canViewWages:Ls(t),hours:Tj(t,{roleId:s}),wages:Ij(t,{roleId:s}),isLoadingLaborTotals:aa(t),isManager:He(t)}))(r.memo(sb)),{cx:iu}=O("DWVRow");function nb({roles:t,dates:s,isDeptNotSet:n}){return e.jsxs(e.Fragment,{children:[t.map(o=>e.jsxs(Et,{className:iu(),children:[e.jsx(Dl,{roleId:o,className:"DWV"}),s?.map(a=>e.jsx(wl,{date:a,roleId:o,className:"DWV"},a))]},o)),n&&e.jsxs(Et,{className:iu(),children:[e.jsx(Dl,{roleId:"uncategorized",className:"DWV"}),s?.map(o=>e.jsx(wl,{date:o,roleId:"uncategorized",className:"DWV"},o))]},"uncategorized")]})}nb.propTypes={departmentId:d.string.isRequired,roles:d.arrayOf(d.string).isRequired,dates:d.array.isRequired,isDeptNotSet:d.bool};const sN=F((t,{departmentId:s})=>({dates:Ft(t),roles:bl(t,{departmentId:s})}))(r.memo(nb)),{cx:nN}=O("ClearScheduleModal"),Dt={REVERT:"revert",CLEAR:"clear",CLEAR_DEPARTMENT:"clear_department"},rb=({isOpen:t,onClose:s,type:n=Dt.REVERT,onRevertSchedule:o,onClearEntireSchedule:a,currentDateRange:l,departmentId:c,departmentIdsToClear:u})=>{const[h,m]=r.useState(!1),_=K(),f=r.useMemo(()=>{switch(n){case Dt.CLEAR:return U.SCHEDULE_BUILDER_CLEAR_SCHEDULE_MODAL;case Dt.CLEAR_DEPARTMENT:return U.SCHEDULE_BUILDER_CLEAR_DEPARTMENT_SCHEDULE_MODAL;case Dt.REVERT:default:return U.SCHEDULE_BUILDER_REVERT_SCHEDULE_MODAL}},[n]);r.useEffect(()=>{t&&_(w.DELETE_CONFIRMATION_MODAL_SHOWN,k.VIEW,{eventCategory:f})},[t]);const g=r.useCallback(async()=>{_(w.BUTTON_CLICKED,k.CLICK,{buttonAction:n===Dt.REVERT?"revert_schedule":"clear_schedule",buttonText:"yes",buttonLocation:n===Dt.REVERT?"revert_schedule_modal":"clear_schedule_modal",eventCategory:f,hasPredictedShifts:0}),m(!0);try{const E=n===Dt.REVERT?o:a;u&&u.length>0?await Promise.all(u.map(S=>E({start_date:l.start,end_date:l.end,department_id:S}))):await E({start_date:l.start,end_date:l.end,department_id:c})}finally{m(!1),s()}},[_,f,n,o,a,l.start,l.end,c,u,s]),b=r.useCallback(()=>{_(w.BUTTON_CLICKED,k.CLICK,{eventCategory:f,buttonAction:n===Dt.REVERT?"revert_schedule":"clear_schedule",buttonText:"no",buttonLocation:n===Dt.REVERT?"revert_schedule_modal":"clear_schedule_modal"}),s()},[f,_,s,n]),x=r.useCallback(()=>{h||(_(w.DISMISS_CLICKED,k.CLICK,{eventCategory:f}),s())},[h,f,_,s]);return e.jsx(Fn,{auto:!0,hideCloseIcon:!0,isOpen:t,onRequestClose:x,shouldCloseOnOverlayClick:!h,children:e.jsxs(i,{column:!0,vcenter:!0,relative:!0,tcenter:!0,w:500,className:nN(),children:[e.jsx(i,{absolute:!0,right:0,top:0,children:e.jsx(om,{onClick:x})}),e.jsx(Y,{fw600:!0,fs24:!0,navy:!0,i18n:`${cn}.${n}.title`}),e.jsxs(i,{column:!0,mt:15,mb:20,children:[e.jsx(i,{mv:8,children:e.jsx(Y,{i18n:`${cn}.${n}.description`})}),n===Dt.CLEAR&&e.jsx(i,{mv:8,children:e.jsx(Y,{i18n:`${cn}.${n}.note`})}),e.jsx(i,{mv:8,children:e.jsx(Y,{i18n:`${cn}.${n}
1.confirm_message`})})]}),e.jsx(fr,{buttons:[{label:p(`${cn}.confirm_action`),variant:"primary",isLoading:h,onClick:g},{label:p(`${cn}.reject_action`),variant:"secondary",isLoading:h,onClick:b}]})]})})};rb.propTypes={isOpen:d.bool,onClose:d.func.isRequired,type:d.string,currentDateRange:d.shape({start:d.string,end:d.string}).isRequired,onRevertSchedule:d.func.isRequired,onClearEntireSchedule:d.func.isRequired,departmentId:d.string,departmentIdsToClear:d.arrayOf(d.string)};const ob=F(t=>({currentDateRange:it(t)}),{onRevertSchedule:Dj,onClearEntireSchedule:wj})(r.memo(rb)),sl="schedule_builder.react_page.grid.row_header",{cx:rN}=O("DWVRowsHeader");function ab({name:t,wages:s,hours:n,isLoadingLaborTotals:o,departmentId:a,onShowDrawer:l,onSetDepartmentId:c,onShowPrintScheduleDrawer:u,canViewWages:h,isManager:m}){const[_,f]=r.useState(m),[g,b]=r.useState(!1),x=K({isByDepartment:!0}),E=Kn();r.useEffect(()=>{_&&!o&&f(!1)},[o]);const S=r.useCallback(()=>{b(!1)},[]),y=r.useCallback(()=>{b(!0)},[]),C=r.useCallback(()=>{c({departmentId:a}),x(w.PUBLISH_BUTTON_CLICKED,k.CLICK),l({uxContext:{...E(),isByDepartment:!0}})},[x,c,a,l,E]),v=r.useCallback(()=>{c({departmentId:a}),x(w.BUTTON_CLICKED,k.CLICK,{buttonText:"print_icon"}),u({uxContext:E()})},[a,u,c,x,E]);return e.jsxs(i,{w:"100%",row:!0,spacebetween:!0,vcenter:!0,bgcolor:"grayLight",bcolor:"grayMediumLight",bs:"solid",btw:1,pv:5,ph:12,className:rN(),children:[e.jsxs(i,{row:!0,vcenter:!0,gap:15,children:[e.jsx(Y,{fw700:!0,fs14:!0,grayDark:!0,uppercase:!0,text:t}),m&&e.jsx(e.Fragment,{children:_&&o?e.jsx(da,{}):e.jsx(i,{children:e.jsxs(Y,{fs14:!0,uppercase:!0,fw700:!0,black:!0,children:[n.toFixed(2)," hrs",h?" / "+pt(s,{precision:0}):""]})})})]}),e.jsxs(i,{row:!0,gap:20,children:[e.jsx(be,{icon:"Print",size:"small",label:p(`${sl}.print_department`),onClick:v,dataTestId:"print-single-department"}),m&&e.jsxs(e.Fragment,{children:[e.jsx(V,{variant:"secondary",size:"small",onClick:y,children:p(`${sl}.clear`)}),e.jsx(V,{variant:"secondary",size:"small",onClick:C,children:p(`${sl}.publish`)})]})]}),g&&e.jsx(ob,{isOpen:g,onClose:S,type:Dt.CLEAR_DEPARTMENT,departmentId:a})]})}ab.propTypes={name:d.string.isRequired,departmentId:d.string.isRequired,wages:d.number.isRequired,hours:d.number.isRequired,canViewWages:d.bool,isManager:d.bool,isLoadingLaborTotals:d.bool,onShowDrawer:d.func.isRequired,onSetDepartmentId:d.func.isRequired,viewType:d.string,startDate:d.string,endDate:d.string};const oN=F((t,{departmentId:s})=>({name:_i({state:t,id:s,attribute:"name"}),wages:bi(t,{departmentId:s}),hours:fi(t,{departmentId:s}),isLoadingLaborTotals:aa(t),canViewWages:Ls(t),isManager:He(t),viewType:jh(t),startDate:Wn(t),endDate:Lr(t)}),{onShowDrawer:ie.showPublishDrawer,onSetDepartmentId:ie.setDepartmentId,onShowPrintScheduleDrawer:ie.showPrintScheduleDrawer})(r.memo(ab)),aN=({data:t,index:s})=>{const{departmentIds:n,deptNotSetId:o}=t,a=n[s];return e.jsxs(i,{className:"DepartmentBlock",children:[e.jsx(oN,{departmentId:a}),e.jsx(sN,{isDeptNotSet:a===o,departmentId:a})]},a)},lN=r.memo(aN),iN=({departmentIds:t,deptNotSetId:s})=>{const n=K();r.useEffect(()=>{n(w.PAGE_VIEWED,k.VIEW)},[]);const o=r.useMemo(()=>{const a=(t||[]).filter(c=>c!==s);return{departmentIds:s?[...a,s]:[...a],deptNotSetId:s}},[t,s]);return e.jsx(uc,{viewRowsCount:o.departmentIds.length,viewRowData:o,RowComponent:lN})},cN=F(t=>({departmentIds:Rj(t),deptNotSetId:kj(t,{attribute:"name",value:Dh})[0]?.id}))(r.memo(iN)),{cx:dN,cxEl:nl}=O("DayCell"),lb=r.memo(({isCopyPasteMode:t,blackoutId:s,date:n,eventIds:o,isManager:a,isAvailabilitiesVisible:l,shiftIds:c,timeOffPartialDayIds:u,timeOffWholeDayIds:h,unavailableScheduleAvailabilityPartialDayIds:m,unavailableScheduleAvailabilityWholeDayIds:_,hovered:f})=>{const[g,b]=r.useState(!1),x=r.useRef(null),[E,S]=r.useState(null);r.useEffect(()=>{x.current?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),S(x.current)},[g]);const{rangeStart:y,rangeType:C}=ze(),v=r.useMemo(()=>C===J.custom||xc(y)===xc(n),[n,y,C]),T=r.useMemo(()=>Cu(n),[n]),D=r.useCallback(()=>{t||b(!0)},[t]),L=r.useCallback(()=>{b(!1)},[]),A=ll(n)===1;return e.jsxs(e.Fragment,{children:[e.jsxs(i,{pl:4,pt:8,row:!0,spacebetween:!0,vcenter:!0,onClick:a?D:null,children:[e.jsx(la,{to:`/schedule/employee/day/${n}`,className:nl("pill"),children:e.jsx(i,{bcolor:"purple500",bw:T?2:0,bradiu
1sfull:!0,w:A?50:28,h:28,vcenter:!0,hcenter:!0,borderbox:!0,children:e.jsx(j,{variant:"bodySm",color:v?"mono900":"mono500",children:A?al(n):ll(n)})})}),a&&!t&&e.jsx("div",{className:nl("add-shift-icon"),children:f&&e.jsx(be,{icon:"Add",onClick:D,size:"small",label:p("schedule_builder.actions.add_shift")})})]}),!!s&&e.jsx(ec,{isCopyPasteMode:t,blackoutId:s}),o.map(P=>e.jsx(nc,{isCopyPasteMode:t,eventId:P},P)),c.map(P=>e.jsx(kn,{shiftId:P,isCopyPasteMode:t,oneLine:!0},P)),h.map(P=>e.jsx(go,{timeOffId:P,oneLine:!0},P)),l&&_.map(P=>e.jsx(xo,{id:P,oneLine:!0},P)),u.map(P=>e.jsx(go,{timeOffId:P,oneLine:!0},P)),l&&m.map(P=>e.jsx(xo,{id:P,oneLine:!0},P)),t&&f&&e.jsx(lc,{date:n,fullWidth:!0}),g&&e.jsx(Ur,{ref:x}),a&&e.jsx(i,{className:nl("add-shift"),onClick:D}),g&&e.jsx(Ns,{isAdding:!0,anchorEl:E,open:g,onClose:L,date:n})]})});lb.propTypes={blackoutId:d.string,date:d.string,isCopyPasteMode:d.bool,isManager:d.bool,eventIds:d.array,hovered:d.bool,shiftIds:d.array,timeOffPartialDayIds:d.array,timeOffWholeDayIds:d.array,unavailableScheduleAvailabilityPartialDayIds:d.array,unavailableScheduleAvailabilityWholeDayIds:d.array};const uN=({date:t,isCopyPasteMode:s,blackoutId:n,eventIds:o,isManager:a,isAvailabilitiesVisible:l,shiftIds:c,timeOffPartialDayIds:u,timeOffWholeDayIds:h,unavailableScheduleAvailabilityPartialDayIds:m,unavailableScheduleAvailabilityWholeDayIds:_})=>{const{setNodeRef:f}=Yn({date:t}),[g,b]=r.useState(!1),x=r.useCallback(()=>b(!0),[]),E=r.useCallback(()=>b(!1),[]);return e.jsx(i,{className:dN(),dataTestId:t,brw:1,bcolor:"mono300",column:!0,minh:144,ph:8,pt:0,pb:4,gap:4,h:"100%",borderbox:!0,ref:f,onMouseOver:x,onMouseLeave:E,children:e.jsx(lb,{isCopyPasteMode:s,blackoutId:n,date:t,eventIds:o,isManager:a,isAvailabilitiesVisible:l,shiftIds:c,timeOffPartialDayIds:u,timeOffWholeDayIds:h,unavailableScheduleAvailabilityPartialDayIds:m,unavailableScheduleAvailabilityWholeDayIds:_,hovered:g})})},hN=F((t,s)=>({blackoutId:yi(t,s),eventIds:kk(t,s),shiftIds:Lj(t,s),timeOffPartialDayIds:Uk(t,s),timeOffWholeDayIds:Bk(t,s),unavailableScheduleAvailabilityPartialDayIds:Nk(t,s),unavailableScheduleAvailabilityWholeDayIds:Ok(t,s)}))(uN),ib=({dates:t,cxEl:s,isAvailabilitiesVisible:n,isManager:o,isCopyPasteMode:a})=>e.jsx(e.Fragment,{children:t.map(l=>e.jsx(i,{className:s("day-cell"),children:e.jsx(hN,{date:l,isAvailabilitiesVisible:n,isManager:o,isCopyPasteMode:a})},l))});ib.propTypes={dates:d.array.isRequired,cxEl:d.func,isAvailabilitiesVisible:d.bool,isManager:d.bool,isCopyPasteMode:d.bool};const mN=F(t=>({dates:Ft(t)}))(r.memo(ib)),{cx:pN,cxEl:or}=O("MonthView"),cb=({isCopyPasteMode:t,startOfWeekValue:s,isAvailabilitiesVisible:n,isManager:o})=>{const a=r.useMemo(()=>$a.slice(s,$a.length).concat($a.slice(0,s)),[s]);return e.jsxs("div",{className:pN(),children:[e.jsx(i,{className:or("sticky-header"),style:{top:0},children:e.jsx(i,{className:or("calendar","header"),children:a.map(l=>e.jsx(i,{className:or("header-cell"),children:e.jsx(j,{variant:"bodySmBold",color:"mono700",children:l})},l))})}),e.jsx(i,{className:or("calendar"),children:e.jsx(mN,{cxEl:or,isAvailabilitiesVisible:n,isManager:o,isCopyPasteMode:t})}),t&&e.jsx(Nf,{})]})};cb.propTypes={isCopyPasteMode:d.bool,startOfWeekValue:d.number,topPosition:d.number,isAvailabilitiesVisible:d.bool,isManager:d.bool};const _N=F(t=>({isCopyPasteMode:!!tn(t),startOfWeekValue:rs(t),isAvailabilitiesVisible:oa(t),isManager:He(t)}))(r.memo(cb)),{cx:fN}=O("MonthViewWrapper"),db=({dates:t,isAvailabilitiesVisible:s,isTimeOffsVisible:n})=>{const o=K();return r.useEffect(()=>{o(w.PAGE_VIEWED,k.VIEW)},[]),e.jsx(i,{bgcolor:"mono100",className:fN(),mb:24,relative:!0,children:!t||!t.length?null:e.jsx(_N,{isAvailabilitiesVisible:s,isTimeOffsVisible:n})})};db.propTypes={dates:d.arrayOf(d.string),isAvailabilitiesVisible:d.bool,isTimeOffsVisible:d.bool};const cu=F(t=>({dates:Ft(t)}))(r.memo(db)),{cx:bN}=O("RWVRow");function gN({data:t,index:s}){const{dates:n,roleIds:o}=t,a=o[s];return e.jsxs(Et,{className:bN(),children:[e.jsx(Dl,{roleId:a,className:"RWV"}),n?.map(l=>e.jsx(wl,{date:l,roleId:a,className:"RWV"},l))]})}const xN=r.memo(gN),ub=({roleIds:t})=>{const s=K();r.useEffect(()=>{s(w.PAGE_VIEWED,k.VIEW)},[]);const n=r.useMemo(()=>({roleIds:["uncategorized",...t||[]]}),[t]);return e.jsx(uc,{viewRowsCount:n.roleIds.length,viewRowData:n,RowComponent:xN})};
1ub.propTypes={roleIds:d.arrayOf(d.string),dateRange:d.arrayOf(d.string)};const CN=F(t=>({roleIds:Aj(t)}))(r.memo(ub)),du={mobil_ios:"https://itunes.apple.com/us/app/homebase/id871544379?mt=8",mobile_android:"https://play.google.com/store/apps/details?id=com.joinhomebase.homebase.homebase"},{cx:EN,cxEl:uu}=O("DownloadMobileAppModal"),SN=({isOpen:t,onClose:s})=>e.jsx(Fn,{auto:!0,noPadding:!0,isOpen:t,onRequestClose:s,children:e.jsxs(i,{className:EN(),tcenter:!0,column:!0,hcenter:!0,vcenter:!0,p:24,children:[e.jsx(i,{hcenter:!0,children:e.jsx(qm,{h:186,src:new URL("https://cdn.joinhomebase.com/assets/shifts-bundle-CJ33wdgS.png",import.meta.url).href})}),e.jsx(Y,{fs24:!0,navy:!0,fw600:!0,i18n:"schedule_builder.react_page.download_mobile_app.title"}),e.jsx(i,{mt:12,mb:24,children:e.jsx(Y,{navy:!0,fs14:!0,i18n:"schedule_builder.react_page.download_mobile_app.subtitle"})}),e.jsxs(i,{row:!0,spacebetween:!0,gap:20,w:"100%",children:[e.jsx("a",{href:du.mobil_ios,target:"_blank",className:uu("btn"),children:e.jsx("img",{src:new URL("https://cdn.joinhomebase.com/assets/download-app-store-bundle-wH_Z_LlZ.png",import.meta.url).href,height:"auto",width:"100%",alt:"App store"})}),e.jsx("a",{href:du.mobile_android,target:"_blank",className:uu("btn"),children:e.jsx("img",{src:new URL("https://cdn.joinhomebase.com/assets/download-google-play-bundle-3JnpNb_-.png",import.meta.url).href,height:"auto",width:"100%",alt:"Google play"})})]})]})}),jN=({isLargeScreen:t})=>{const s=X(),n=K(),o=I(Oi),a=I(hm),l=I(Oj),c=I(Nj),u=I(Mj),h=I(Nl),m=I(Pj),{rangeStartMoment:_,rangeEndMoment:f}=Mr(),g=`${_.format("YYYY-MM-DD")}_${f.format("YYYY-MM-DD")}`,b=r.useRef(u),[,x]=At(Gs,!1),[E,S]=At(Nn,!1),y=ts(xl)===!0,C=r.useMemo(()=>Zs(_,f),[_,f]);ps(w.PAGE_VIEWED,k.VIEW,{sba_enabled:!0,sba_trigger_visible:!0}),r.useEffect(()=>{c&&n(w.TOOLTIP_VIEWED,k.VIEW,{element:"schedule_assistant_tooltip"})},[c,n]),r.useEffect(()=>()=>{s(ln(!1))},[s]),r.useEffect(()=>{if(u&&(b.current=!0),!(o&&y&&!a&&!b.current&&l!==g&&!E)){c&&s(ln(!1));return}h||s(Ml()),c||s(ln(!0))},[s,o,h,a,y,l,u,E,g,c]);const v=r.useCallback(()=>{ts(xl)===!0?(x(!0),S(!1),s(Mn(!0))):s(hn(!0)),s(Ba(g)),s(ln(!1))},[s,g,x,S]),T=r.useCallback(()=>{v()},[v]),D=r.useCallback(()=>{n(w.BUTTON_CLICKED,k.CLICK,{element:"schedule_assistant_trigger",button_text:"Schedule Assistant"}),s(Ba(g)),s(hn(!0)),s(ln(!1))},[s,g,n]),L=r.useCallback(()=>{s(Ba(g)),s(ln(!1))},[s,g]);return!o||!m?null:e.jsx(Ae,{title:p("schedule_builder.agent.opt_in.tooltip.title"),variant:"primary",open:c,onDismissClick:L,content:e.jsxs(i,{children:[e.jsx(j,{variant:"bodySmTight",children:p("schedule_builder.agent.opt_in.tooltip.content",{props:{dates:C}})}),e.jsx(i,{pt:12,onClick:D,pointer:!0,children:e.jsx(j,{variant:"bodySmTight",underline:!0,children:p("schedule_builder.agent.opt_in.tooltip.show_me")})})]}),placement:"top",children:e.jsx(i,{p:t?8:6,bradiusm:!0,bgcolor:"purple500",onClick:T,pointer:!0,children:e.jsx(ns,{iconName:"ScheduleBuilder",size:t?"large":"medium",color:"mono0"})})})},yN=Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_PRE_ASSIGN})(jN),{cx:vN}=O("ConflictsSwitch"),hb=({conflictsCount:t,conflictsEnabled:s,toggleConflicts:n})=>{const o=K(),a=r.useCallback(()=>{o(w.CONFLICTS_TOGGLE_BUTTON_CLICKED,k.CLICK,{num_conflicts:t}),n()},[o,n,t]);return t===0?null:e.jsxs(i,{row:!0,vcenter:!0,gap:8,className:vN(),children:[e.jsx(ph,{onChange:a,checked:s}),e.jsx(j,{variant:"bodySmBold",children:p(`${js}.show_conflicts`)}),e.jsx(Uj,{variant:"loud",text:t.toString()})]})};hb.propTypes={conflictsCount:d.number,conflictsEnabled:d.bool.isRequired,toggleConflicts:d.func.isRequired};const IN=F(t=>({conflictsCount:Bj(t).length,conflictsEnabled:$j(t)}),{toggleConflicts:ie.toggleConflicts})(r.memo(hb)),hu=(t,s,n,o)=>{if(o===J.custom)return o="week",n*=cr(t.start,t.end,"weeks")+1,{start:Ta(t.start,n,o),end:Ta(t.end,n,o)};let a=t.start;return o===J.month&&(a=s),{start:Ta(a,n,o)}},mb=({isLargeScreen:t,onChange:s,currentWeek:n,rangeType:o})=>{const{rangeStart:a}=ze(),l=K(),c=r.useCallback(()=>{l(w.DATE_ARROW_CLICKED,k.CLICK),s(hu(n,a,-1,o))},[s,l,n,o,a]),u=r.useCallback(()=>
1{l(w.DATE_ARROW_CLICKED,k.CLICK),s(hu(n,a,1,o))},[s,l,n,o,a]);return e.jsxs(e.Fragment,{children:[e.jsx(be,{icon:"ChevronLeft",size:t?"medium":"small",onClick:c,dataTestId:"NavigationButtonSet__left-button",label:p("schedule_builder.actions.previous_period")}),e.jsx(be,{icon:"ChevronRight",size:t?"medium":"small",onClick:u,dataTestId:"NavigationButtonSet__right-button",label:p("schedule_builder.actions.next_period")})]})};mb.propType={currentWeek:d.object,onChange:d.func,rangeType:d.string.isRequired};const TN=F(t=>({currentWeek:it(t)}))(r.memo(mb)),{cx:wN}=O("PublishButton"),DN=({unpublishedShiftsCount:t,onShowDrawer:s,onSetDepartmentId:n,isLargeScreen:o})=>{const a=Kn(),l=K(),c=r.useCallback(()=>{n({departmentId:null}),l(w.PUBLISH_BUTTON_CLICKED,k.CLICK),s({uxContext:a()})},[n,s,l,a]);return e.jsx(V,{className:wN(),variant:"primary",disabled:t===0,onClick:c,startIcon:"Send",size:o?"medium":"small",children:p("schedule_builder.react_page.publish_schedule",{props:{count:t}})})},kN=F(t=>({unpublishedShiftsCount:ea(t)}),{onShowDrawer:ie.showPublishDrawer,onSetDepartmentId:ie.setDepartmentId})(r.memo(DN)),{cx:RN}=O("RangeTypeSelector"),pb=({onChange:t,rangeType:s})=>{const n=[{label:p(`${js}.${J.week}`),value:J.week},{label:p(`${js}.${J.month}`),value:J.month},{label:p(`${js}.${J.day}`),value:J.day}];return e.jsx(Qt,{id:"sb-range-type",className:RN(),options:n,value:s===J.custom?J.month:s,onChange:t})};pb.propTypes={rangeType:d.string};const LN=r.memo(pb),_b=({navigateToSchedule:t,rangeType:s,rangeStart:n,rangeEnd:o,isLargeScreen:a})=>{const l=K(),c=r.useCallback(()=>{const{startDate:u,endDate:h}=gp(s,n,o);t({rangeStart:u,rangeEnd:h}),l(w.TODAY_BUTTON_CLICKED,k.CLICK)},[t,o,n,s,l]);return e.jsx(V,{variant:"secondary",onClick:c,size:a?"medium":"small",children:p(`${js}.today`)})};_b.propType={navigateToSchedule:d.func,rangeType:d.string.required,rangeStart:d.object,rangeEnd:d.object};const AN=F(()=>({}),{navigateToSchedule:Go})(r.memo(_b)),fb={CHILD_LABOR_COMPLIANCE_TOOLTIP_DISMISSED:"childLaborComplianceTooltipDismissed"},{cx:ON}=O("EventFormModal"),bb=({onClose:t,isOpen:s,id:n,unlimited:o,allowed:a,used:l})=>{const c=K();r.useEffect(()=>{s&&c(w.ADD_EVENT_MODAL_SHOWN,k.VIEW,{isEdit:!!n,eventPaywallShown:tc({unlimited:o,isEdit:!!n,allowed:a,used:l})})},[s]);const u=r.useCallback(h=>{c(w.ADD_EVENT_MODAL_CLOSED,k.CLICK),t(h)},[t,c]);return e.jsx(Fn,{auto:!0,isOpen:s,onRequestClose:u,children:e.jsx(i,{w:430,mb:12,className:ON(),children:e.jsx(U_,{showCreateBanner:!0,unlimited:!0,id:n,onClose:t})})})};bb.propTypes={id:d.string,isOpen:d.bool,unlimited:d.bool,allowed:d.number,used:d.number,onClose:d.func};const NN=F((t,s)=>{const{allowed:n,used:o,unlimited:a}=zi(t,s);return{allowed:n,used:o,unlimited:a}},null)(r.memo(ut({eventCategory:U.SCHEDULE_BUILDER_ADD_EVENT_MODAL})(bb))),{cx:MN}=O("PublishHistoryModal"),PN=[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"}],gb=({events:t,onClick:s,currentLimit:n,isLoading:o})=>{const a=r.useCallback(({value:c})=>s(c),[s]),l=r.useMemo(()=>t.map(c=>({title:e.jsx(Y,{i18n:"schedule_builder.react_page.publish_history_modal.event.published",i18nProps:{user:c.publisher}}),date:c.publishedAt,subtitle:e.jsxs(i,{pb:12,children:[e.jsxs(i,{children:[e.jsx(Y,{fw600:!0,i18n:"schedule_builder.react_page.publish_history_modal.event.period"}),` ${Oe(c.startDate,"parsable_date")} - ${Oe(c.endDate,"parsable_date")}`]}),e.jsxs(i,{children:[e.jsx(Y,{fw600:!0,i18n:"schedule_builder.react_page.publish_history_modal.event.shifts"}),` ${c.shiftsPublished}`]}),e.jsxs(i,{children:[e.jsx(Y,{fw600:!0,i18n:"schedule_builder.react_page.publish_history_modal.event.notified"}),` ${c.notified}`]})]})})),[t]);return e.jsxs(i,{p:20,className:MN(),children:[e.jsx(i,{tcenter:!0,mb:24,children:e.jsx(Y,{fs:24,fw600:!0,i18n:"schedule_builder.react_page.publish_history_modal.title"})}),e.jsx(i,{h:345,scrollY:!0,mb:8,children:e.jsx(Di,{isLoading:o,centeredAbsolute:!0,children:t.length?e.jsx(y_,{renderTime:!0,data:l}):e.jsx(i,{tcenter:!0,children:e.jsx(Y,{i18n:"schedule_builder.react_page.publish_history_modal.empty_state"})})})}),e.jsx(i,{row:!0,hcenter:!0,gap:"xs",children:PN.map(c=>e.jsx(Hj,{size:"medium",value:c.value,selected:c.value===n,onClick:a,children:c.label},c.value))})]})};gb.propTypes={events:d.array.isRequired,onClick:d.func.isRequired,currentLimit:d.number.isRequired,isLoading:d.bool};const $N=r.memo(gb),xb=({isOpen:t,onClose:s,events:n,onClearHistory:o,onFetch:a,isLoading:l})=>{const c=K(),[u,h]=r.useState(10),m=r.useMemo(()=>n.slice(0,u).map(({id:g,type:b,...x})=>x),[n,u]),_=r.useCallback(g=>{c(w.HISTORY_ITEM_COUNT_CLICKED,k.CLICK,{historyCount:g}),u<g&&a({limit:g}),h(g)},[c,u,a]),f=r.useCallback(g=>{c(w.PUBLISH_HISTORY_MODAL_CLOSED,k.CLICK),s(g)},[c,s]);return r.useEffect(()=>{t?(c(w.PUBLISH_HISTORY_MODAL_SHOWN,k.VIEW),a({limit:10}),h(10)):o()},[t]),e.jsx(Fn,{isOpen:t,onRequestClose:f,children:e.jsx($N,{events:m,onClick:_,currentLimit:u,isLoading:l})})};xb.propTypes={isOpen:d.bool.isRequired,onClose:d.func.isRequired,onFetch:d.func.isRequired,onClearHistory:d.func.isRequired,events:d.array.isRequired,isLoading:d.bool.isRequired};const BN=F(t=>({events:Wj(t),isLoading:Fj(t)}),{onFetch:Kj,onClearHistory:Vj})(ut({eventCategory:U.SCHEDULE_BUILDER_PUBLISH_HISTORY_MODAL})(xb)),{cx:mu}=O("CopyWeekForm"),Cb=({copyWeekModalIsOpen:t,currentWeek:s,departmentNotSetId:n,departmentOptions:o,onCloseCopyWeekModal:a,onCopySchedule:l,resetForm:c,roleOptions:u,jobOptions:h,startOfWeekValue:m})=>{const _=K(),{setFieldValue:f,values:g}=Wo(),[b,x]=r.useState(Ie(s.start).add(7,"days")),[E,S]=r.useState(Ie(s.end).add(7,"days")),[y,C]=r.useState(!1),[v,T]=r.useState(Ie(s.start).add(7,"days")),[D,L]=r.useState(Ie(s.end).add(7,"days")),[A,P]=r.useState(!1);r.useEffect(()=>{f("start_date",Ie(s.start).format("YYYY-MM-DD")),f("end_date",Ie(s.end).format("YYYY-MM-DD")),f("target_start_date",Ie(s.start).add(7,"days").format("YYYY-MM-DD")),f("target_end_date",Ie(s.end).add(7,"days").format("YYYY-MM-DD"))},[s.end,s.start,f]),r.useEffect(()=>{x(Ie(s.start).add(7,"days").format("YYYY-MM-DD")),S(Ie(s.end).add(7,"days").format("YYYY-MM-DD"))},[s.end,s.start]),r.useEffect(()=>{g.includeShifts===bt.ALL_SHIFTS?(f("department_ids",[]),f("role_ids",[]),f("job_ids",[])):g.includeShifts===bt.BY_DEPARTMENT?(f("role_ids",[]),f("job_ids",[])):g.includeShifts===bt.BY_ROLE?(f("department_ids",[]),f("job_ids",[])):g.includeShifts===bt.BY_TEAM_MEMBER&&(f("department_ids",[]),f("role_ids",[]))},[f,g.includeShifts]);const M=r.useCallback(W=>{x(W.startDate),S(W.endDate)},[x,S]),R=r.useCallback(()=>{P(!1)},[P]),$=r.useCallback(()=>{C(!0),_(w.BUTTON_CLICKED,k.CLICK,{button_text:yu.COPY_WEEK,copy_week_type:g.includeShifts,c
1opy_week_direction:Xj.COPY_FROM}),l({start_date:g.start_date||v,end_date:g.end_date||D,target_start_date:b,target_end_date:E,department_ids:g.department_ids,role_ids:g.role_ids.filter(W=>W!=="uncategorized"),job_ids:g.job_ids,includes_shifts_without_roles:g.includeShifts===bt.ALL_SHIFTS||g.department_ids.includes(n)||g.role_ids.includes("uncategorized"),noSuccessBanner:!0}).finally(()=>{T(b),L(E),P(!0),C(!1),c(),a()})},[n,E,a,l,c,b,D,v,_,g.department_ids,g.end_date,g.includeShifts,g.role_ids,g.job_ids,g.start_date]),B=r.useCallback(()=>{f("department_ids",[]),f("role_ids",[]),f("job_ids",[]),f("includeShifts",bt.ALL_SHIFTS),a()},[a,f]);return e.jsxs(i,{className:mu(),children:[e.jsx(Mt,{title:p("schedule_builder.react_page.copy_week_modal.title"),buttons:[{label:p("schedule_builder.react_page.copy_week_modal.copy_week"),variant:"primary",isLoading:y,onClick:$},{label:p("schedule_builder.react_page.copy_week_modal.cancel"),variant:"secondary",isLoading:y,onClick:B}],className:mu(),width:605,open:t,onClose:B,children:()=>e.jsxs(i,{mt:10,children:[e.jsx(j,{variant:"captions",color:"mono700",children:p("schedule_builder.react_page.copy_week_modal.sub_title")}),e.jsxs(i,{row:!0,pt:24,spacebetween:!0,vcenter:!0,children:[e.jsxs(i,{column:!0,children:[e.jsx(i,{children:e.jsx(j,{variant:"bodySm",color:"mono700",children:p("schedule_builder.react_page.copy_week_modal.copy_from")})}),e.jsx(i,{vcenter:!0,mt:12,children:e.jsx(j,{variant:"body",color:"mono900",children:`${Ie(s.start).format(es("pretty_no_wday"))} - ${Ie(s.end).format(es("pretty_no_wday"))}`})})]}),e.jsx(i,{mt:33,children:"to"}),e.jsxs(i,{column:!0,children:[e.jsx(i,{children:e.jsx(j,{variant:"bodySm",color:"mono700",children:p("schedule_builder.react_page.copy_week_modal.copy_to")})}),e.jsx(i,{w:285,mt:12,children:e.jsx($m,{onApplyRange:M,payrollInfo:[m],twiceWeekPayrollInfo:null,startDate:b,endDate:E,payrollPeriod:"week",startOfWorkWeek:m})})]})]}),e.jsx(i,{mt:32,children:e.jsx(li,{name:"includeShifts",label:p("schedule_builder.react_page.copy_week_modal.include_shifts_from"),value:g.includeShifts,children:[bt.ALL_SHIFTS,bt.BY_DEPARTMENT,bt.BY_ROLE,bt.BY_TEAM_MEMBER].map(W=>e.jsxs(e.Fragment,{children:[e.jsx(ii,{label:p(`schedule_builder.react_page.copy_week_modal.${W}`),value:W},W),g.includeShifts===bt.BY_DEPARTMENT&&W===bt.BY_DEPARTMENT&&e.jsx(i,{maxw:400,pl:35,children:e.jsx(Ua,{name:"department_ids",options:o,placeholder:p("schedule_builder.react_page.copy_week_modal.choose_departments"),displayAsText:!0,multiple:!0,menuMaxHeight:200})}),g.includeShifts===bt.BY_ROLE&&W===bt.BY_ROLE&&e.jsx(i,{maxw:400,pl:35,children:e.jsx(Ua,{name:"role_ids",options:u,placeholder:p("schedule_builder.react_page.copy_week_modal.choose_roles"),displayAsText:!0,multiple:!0,menuMaxHeight:200})}),g.includeShifts===bt.BY_TEAM_MEMBER&&W===bt.BY_TEAM_MEMBER&&e.jsx(i,{maxw:400,pl:35,children:e.jsx(Ua,{name:"job_ids",options:h,placeholder:p("schedule_builder.react_page.copy_week_modal.choose_team_members"),displayAsText:!0,multiple:!0,menuMaxHeight:200})})]}))})})]})}),e.jsx(Sh,{variant:"success",open:A,onClose:R,children:p("schedule_builder.react_page.copy_schedule_dialog.toast_success_message",{props:{target_start_date:Oe(v,"pretty_no_wday"),target_end_date:Oe(D,"pretty_no_wday")}})})]})};Cb.propTypes={copyWeekModalIsOpen:d.bool,currentWeek:d.shape({start:d.string,end:d.string}),departmentNotSetId:d.string,departmentOptions:d.array,onCloseCopyWeekModal:d.func,onCopySchedule:d.func,resetForm:d.func,roleOptions:d.array,jobOptions:d.array,startOfWeekValue:d.number};const UN=F(t=>({copyWeekModalIsOpen:Jj(t),currentWeek:it(t),departmentNotSetId:Yj(t),departmentOptions:Gj(t),roleOptions:zj(t),jobOptions:qj(t),startOfWeekValue:rs(t)}),{onCloseCopyWeekModal:ie.closeCopyWeekModal,onCopySchedule:ju})(Cb),HN=()=>e.jsx(Ht,{initialValues:Qj,validateOnBlur:!1,children:({resetForm:t})=>e.jsx(e.Fragment,{children:e.jsx(UN,{resetForm:t})})}),FN=Ge({productArea:ae.SCHEDULE,eventCategory:U.COPY_WEEK_MODAL})(HN),Eb=({anchorEl:t,canManageEmployees:s,handleAddEmployee:n,isManager:o,toggleEventModal:a,toggleTimeOffBlackoutFormModal:l,handleClickTimeOffBlackoutUpgradeWrapper:c})=>e.jsxs(Rm,{parentMenuOpen:t!==null,label:p(`${pe}.add`),iconName:"Add",dataTestId:p(`${pe}.add`),children:[o&&e.jsx(gt,{label:p(`${pe}.event`),onClick:a,dataTestId:p(`${pe}.event`)}),o&&e.jsx(Fs,{feature:"time_offs",focusedFeature:"basicTimeTrackingAndScheduling",onClick:c,children:e.jsx(gt,{label:p(`${pe}.time_off_blackout`),onClick:l,dataTestId:p(`${pe}.time_off_blackout`)})}),(o||s)&&e.jsx(gt,{label:p(`${pe}.team_member`),onClick:n,dataTestId:p(`${pe}.team_member`)})]});Eb.propTypes={anchorEl:d.object,canManageEmployees:d.bool,handleAddEmployee:d.func,isManager:d.bool,toggleEventModal:d.func,toggleTimeOffBlackoutFormModal:d.func};const Sb=({anchorEl:t,onClearEntireSchedule:s,onClearUnpublishedChanges:n})=>e.jsxs(Rm,{parentMenuOpen:t!==null,label:p(`${pe}.delete`),iconName:"Delete",dataTestId:p(`${pe}.delete`),children:[e.jsx(gt,{label:p(`${pe}.unpublished_changes`),onClick:n,redText:!0,dataTestId:p(`${pe}.unpublished_changes`)}),e.jsx(gt,{label:p(`${pe}.entire_schedule`),onClick:s,redText:!0,dataTestId:p(`${pe}.entire_schedule`)})]});Sb.propTypes={anchorEl:d.object,onClearEntireSchedule:d.func,onClearUnpublishedChanges:d.func};const{cx:WN}=O("MenuDropDown"),VN=({anchorEl:t,canCloseEnforcementDialog:s,canManageEmployees:n,childLaborComplianceSettingsEnabled:o,childLaborSchoolSessionEnabledForCurrentLocation:a,currentLocationId:l,currentWeek:c,isChildLaborComplianceTooltipNextClicked:u,isPlusOrAIOLocation:h,isManager:m,onAddEmployee:_,onOpenCopyWeekModal:f,onOpenSchedulingInsightsModal:g,onResendNotifications:b,onSetAddTeamPageContext:x,onShowEnforcementDialog:E,onShowPrintScheduleDrawer:S,onShowTemplatesDrawer:y,onToggleSchoolSession:C,rangeType:v,setMenuOpen:T,shouldAllowResendNotifications:D,shouldShowEnforcementDialog:L,showPredictiveGenerationModal:A,scheduleHasShiftsInCurrentDateRangeAndLocation:P,openCopyWeekDrawer:M,departmentIdsToClear:R,cloverBaseUrl:$})=>{const B=Kn(),W=Qo(),N=Tm(),H=[fb.CHILD_LABOR_COMPLIANCE_TOOLTIP_DISMISSED,l].join("-"),q=K({eventCategory:U.SCHEDULE_BUILDER_TOOLS_DROPDOWN}),[G,re]=r.useState(!1),[ue,je]=r.useState(!1),[ce,oe]=r.useState(!1),[ge,te]=r.useState(null),[Z,ee]=r.useState(!1),[he,Ye]=r.useState(!1),[De,Pe]=r.useState(!1),[ke,me]=r.useState(!1);r.useEffect(()=>{Pe(a)},[a]),r.useEffect(()=>{if(ts(H)){me(!1);return}me(!!o&&!!u)},[o,H,u]);const Fe=v===J.week,We=v===J.month,Xe=v===J.day,se=r.useCallback(()=>{T(!1)},[T]),Ne=r.useCallback(()=>{q(w.TEMPLATES_SELECTED,k.CLICK),se(),y()},[se,y,q]),ye=r.useCallback(()=>{f(),se()},[se,f]),Ve=r.useCallback(()=>{M(),se()},[se,M]),$e=r.useCallback(()=>{A({}),se(),q(w.BUTTON_CLICKED,k.CLICK,{buttonAction:"generate_predictive_schedule",buttonText:"generate_a_schedule",buttonLocation:"dropdown"})},[se,A,q]),Ee=r.useCallback(()=>{q(w.BUTTON_CLICKED,k.CLICK,{button_text:"got_it",element:"school_session_tooltip",tooltip_step:"2"}),at(H,!0),me(!1)},[H,me,q]),Re=r.useCallback(()=>{q(w.BUTTON_CLICKED,k.CLICK,{button_text:"dismiss",element:"school_session_tooltip",tooltip_step:"2"}),at(H,!0),me(!1)},[H,me,q]),Me=r.useCallback(()=>{q(w.BUTTON_CLICKED,k.CLICK,{buttonText:"print"}),se(),Fe?S({uxContext:B()}):setTimeout(window.print,500)},[se,S,q,B,Fe]),we=r.useCallback(()=>{q(w.BUTTON_CLICKED,k.CLICK,{buttonText:"export"});const ht=Oe(c.start,"parsable_date");window.open(sg(`/schedule_builder/export_day_view.csv?day=${ht}`)),se()},[c.start,se,q]),Ke=r.useCallback(()=>{se()},[se]),Qe=r.useCallback(()=>{G||q(w.PUBLISH_HISTORY_SELECTED,k.CLICK),se(),re(!G)},[se,G,q]),Ze=r.useCallback(()=>{ue||q(w.ADD_EVENT_SELECTED,k.CLICK),se(),je(!ue)},[se,ue,q]),et=r.useCallback(()=>{se()},[se]),tt=r.useCallback(()=>{ce||q(w.ADD_TIME_OFF_SELECTED,k.CLICK),se(),oe(!ce)},[se,ce,q]),st=r.useCallback(()=>{b({start_date:c.start,end_date:c.end}).then(()=>{Qh.success(p("schedule_builder.react_page.tools_menu.resend_notifications_success"))})},[c,b]),nt=r.useCallback(()=>{q(w.ADD_EMPLOYEE_SELECTED,k.CLICK),se(),L?E({productArea:ae.SCHEDULE_BUILDER,canCloseDialog:s}):Sn()?Ji($,{location:"add_new_employee"}):N?(x({calledFrom:"schedule_builder"}),W.push(wm)):_()},[s,$,se,W,N,_,x,E,L,q]),Be=r.useCallback(()=>{q(w.LINK_CLICKED,k.CLICK,{linkText:p(`${pe}.share_feedback`)}),se(),Ye(!0)},[se,q]),ve=r.useCallback(()=>{se(),te(Dt.REVERT),ee(!0)},[se]),xt=r.useCallback(()=>{se(),te(Dt.CLEAR),ee(!0)},[se]),ne=r.useCallback(()=>{ee(!1),te(null)},[]),_e=r.useCallback(()=>{q(w.BUTTON_CLICKED,k.CLICK,{buttonText:"Show upcoming events",product_area:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER_EVENT_MODAL}),se(),g()},[se,g,q]),xe=r.useCallback(()=>{const ht=!De;Pe(ht),C({payload:{school_session_enabled:!!ht}}),q(w.PAGE_VIEWED,k.VIEW,{productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER,school_session_mode:ht}),se()},[se,De,C,q]),Ce=r.useCallback(()=>{Ye(!1)},[Ye]);return e.jsxs(e.Fragment,{children:[e.jsxs(si,{open:!!t,onClose:se,anchorEl:t,disableScrollLock:!0,children:[Fe&&m&&(h?e.jsx(gt,{label:p(`${pe}.copy_week_to`),onClick:ye,iconName:"Copy",dataTestId:"menuOption-copy-week-to"}):e.jsx(gt,{label:p(`${pe}.copy_week_from`),onClick:Ve,iconName:"Copy",dataTestId:"menuOption-copy-week-from"})),!P&&e.jsx(Er,{children:e.jsx(gt,{label:e.jsx(i,{gap:8,flex:!0,children:e.jsx(i,{children:p(`${pe}.predictive_scheduling`)})}),iconName:"Sparkle",onClick:$e,dataTestId:p(`${pe}.predictive_scheduling`)})}),Fe&&m&&e.jsx(gt,{label:p(`${pe}.templates`),iconName:"Draft",onClick:Ne,dataTestId:p(`${pe}.templates`)}),e.jsx(gt,{label:p(`${pe}.print`),iconName:"Print",onClick:Me,dataTestId:p(`${pe}.print`)}),Xe&&e.jsx(gt,{label:p(`${pe}.export`),iconName:"Upload",onClick:we,dataTestId:p(`${pe}.export`)}),m&&e.jsx(Fs,{feature:"publish_history",focusedFeature:"basicTimeTrackingAndScheduling",onClick:Ke,children:e.jsx(gt,{label:p(`${pe}.publish_history`),iconName:"ReportDocument",onClick:Qe,dataTestId:p(`${pe}.publish_history`)})}),D&&m&&e.jsx(gt,{label:p(`${pe}.resend_publish_notifications`),iconName:"Send",onClick:st,dataTestId:p(`${pe}.resend_publish_notifications`)}),e.jsx(Wp,{children:e.jsx(gt,{label:p(`${pe}.show_upcoming_events`),iconName:"Schedule",onClick:_e,dataTestId:p(`${pe}.show_upcoming_events`)})}),m&&e.jsx(gn,{}),(m||n)&&e.jsx(Eb,{anchorEl:t,canManageEmployees:n,handleAddEmployee:nt,isManager:m,toggleEventModal:Ze,toggleTimeOffBlackoutFormModal:tt,handleClickTimeOffBlackoutUpgradeWrapper:et}),(Fe||We)&&m&&e.jsx(Sb,{anchorEl:t,onClearEntireSchedule:xt,onClearUnpublishedChanges:ve}),e.jsx(gn,{}),o&&e.jsxs(Ae,{title:p("schedule_builder.child_labor_compliance.tooltip.title_compliance_warnings"),variant:"primary",open:ke,onButtonClick:Ee,content:p("schedule_builder.child_labor_compliance.tooltip.description_compliance_warnings"),placement:"left",onDismissClick:Re,count:"2 of 2",buttonTitle:p("schedule_builder.child_labor_compliance.tooltip.got_it"),children:[e.jsxs(i,{className:WN("school-session-list"),flex:!0,alignItemsCenter:!0,justifyContentSpaceBetween:!0,w:"100%",children:[e.jsx(gt,{label:p(`${pe}.school_in_session`),iconName:"School",onClick:xe,dataTestId:p(`${pe}.school_in_session`)}),e.jsx(i,{pr:10,minw:34,children:De&&e.jsx(Q,{size:"large",color:"purple500",iconName:"Success"})})]}),e.jsx(gn,{})]}),e.jsx(gt,{label:p(`${pe}.share_feedback`),iconName:"Chat",onClick:Be,dataTestId:p(`${pe}.share_feedback`)})]}),e.jsx(BN,{isOpen:G,onClose:Qe}),e.jsx(NN,{isOpen:ue,onClose:Ze}),e.jsx(A_,{isOpen:ce,onClose:tt}),e.jsx(ob,{isOpen:Z,onClose:ne,type:ge,departmentIdsToClear:R}),e.jsx(FN,{}),e.jsx(Wi,{isOpen:he,onClose:Ce})]})},KN=F(t=>({isPlusOrAIOLocation:hs(t)===_n.PLUS||hs(t)===_n.ENTERPRISE,canCloseEnforcementDialog:Sm(t),canManageEmployees:Ni(t),currentLocationId:ct(t),currentWeek:it(t),isManager:He(t),isGeneralManager:ny(t),shouldAllowResendNotifications:sy(t),shouldShowEnforcementDialog:jm(t),isBasicLocation:hs(t)===_n.BASIC,scheduleHasShiftsInCurrentDateRangeAndLocation:ty(t),departmentIdsToClear:ey(t),childLaborSchoolSessionEnabledForCurrentLocation:Lm(t),childLaborComplianceSettingsEnabled:_s(t),isChildLaborComplianceTooltipNextClicked:Zj(t),cloverBaseUrl:vi(t)}),{onAddEmployee:()=>Im({calledFrom:"schedule_builder"}),onOpenCopyWeekModal:ie.openCopyWeekModal,onOpenSchedulingInsightsModal:ie.openSchedulingInsightsModal,onResendNotifications:oy,onSetAddTeamPageContext:vm,onShowEnforcementDialog:ym,onShowPrintScheduleDrawer:ie.showPrintScheduleDrawer,onShowTemplatesDrawer:ie.showTemplatesDrawer,showPredictiveGenerationModal:ie.showPredictiveGenerationModal,openCopyWeekDrawer:ie.showCopyWeekDrawer,onToggleSchoolSession:ry})(r.memo(VN)),{cx:qN}=O("ToolsMenu"),zN={productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER},jb=({childLaborComplianceSettingsEnabled:t,currentLocationId:s,onChildLaborComplianceTooltipNextClicked:n,rangeType:o,isJumpstartDrawerNeeded:a,isLargeScreen:l,scheduleLo
1aded:c})=>{const u=K(),h=r.useRef(null),m=[fb.CHILD_LABOR_COMPLIANCE_TOOLTIP_DISMISSED,s].join("-"),[_,f]=r.useState(!1),[g,b]=r.useState(!1),x=r.useCallback(()=>h.current,[]);r.useEffect(()=>{const v=t&&!a&&c&&!ts(m);b(v)},[t,m,a,c,b]);const E=r.useRef(!1);r.useEffect(()=>{g&&!E.current&&(E.current=!0,u(w.TOOLTIP_VIEWED,k.VIEW,{...zN,element:"school_session_tooltip",tooltip_step:"1/2"})),g||(E.current=!1)},[g,u]);const S=r.useCallback(()=>{u(w.TOOLS_DROPDOWN_CLICKED,k.CLICK),f(!_)},[_,u]),y=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{button_text:"Next",element:"next",tooltip_step:"1/2"}),n(!0),b(!1),f(!0)},[n,f,u]),C=r.useCallback(()=>{u(w.BUTTON_CLICKED,k.CLICK,{element:"close_school_session_tooltip"}),at(m,!0),b(!1)},[m,b,u]);return e.jsxs(i,{className:qN(),children:[e.jsx(Ae,{title:p("schedule_builder.child_labor_compliance.tooltip.title_school"),variant:"primary",open:g,onButtonClick:y,content:p("schedule_builder.child_labor_compliance.tooltip.description_school"),placement:"top",onDismissClick:C,count:"1 of 2",buttonTitle:p("schedule_builder.child_labor_compliance.tooltip.next"),children:e.jsx(i,{ref:h,inlineFlex:!0,children:e.jsx(be,{icon:"Settings",size:l?"medium":"small",label:p(`${pe}.tools`),dataTestId:"ToolsMenu",onClick:S})})}),e.jsx(KN,{anchorEl:_?x:null,rangeType:o,setMenuOpen:f})]})};jb.propTypes={rangeType:d.string};const GN=F(t=>({hasPendingData:Am(t),currentLocationId:ct(t),scheduleLoaded:ay(t),childLaborComplianceSettingsEnabled:_s(t),isJumpstartDrawerNeeded:ep(t)}),{onChildLaborComplianceTooltipNextClicked:ly})(r.memo(jb)),YN={isEventsVisible:"EVENTS_CLICKED",isHoursForecastVisible:"HOURS_FORECAST_CLICKED",isWageForecastVisible:"WAGES_FORECAST_CLICKED",isPeopleForecastVisible:"PEOPLE_FORECAST_CLICKED",isScheduleUsersOnly:"SCHEDULE_EMPLOYEES_CLICKED",isAvailabilitiesVisible:"AVAILABILITIES_CLICKED",isTimeOffsVisible:"TIME_OFFS_CLICKED"},JN=(t,s)=>{const n=YN[t];return w[`${s?"SHOW":"HIDE"}_${n}`]},pu={isEventsVisible:p(`${Yt}.events`),isShiftsAtThisLocationOnly:p(`${Yt}.shifts_location_only`),isHoursForecastVisible:p(`${Yt}.hours_forecast`),isWageForecastVisible:p(`${Yt}.wage_forecast`),isPeopleForecastVisible:p(`${Yt}.people_forecast`),isScheduleUsersOnly:p(`${Yt}.scheduled`),isAvailabilitiesVisible:p(`${Yt}.availabilities`),isTimeOffsVisible:p(`${Yt}.time_offs`)},_u=2,XN=(t,s,n,o)=>Object.keys(t).filter(a=>!o&&n.includes(a)||o&&!iy.includes(a)&&n.includes(a)),QN=(t,s)=>{switch(t){case J.week:return dy;case J.month:return cy;default:return Object.keys(s)}},ZN=(t,s,n,o,a,l,c,u)=>{const h=[],m=XN(t,l,QN(l,t),s);return Object.entries(t||{}).forEach(([_])=>{if(u){if(!m.includes(_)||_===yt.IS_SCHEDULE_USERS_ONLY&&(n===de.department||n===de.role)||_===yt.IS_WAGE_FORECAST_VISIBLE&&!a||_===yt.IS_SHIFTS_AT_THIS_LOCATION_ONLY&&(!o||c<_u))return;h.push({name:_,value:_,label:pu[_]});const f=c>=_u&&o?yt.IS_SHIFTS_AT_THIS_LOCATION_ONLY:yt.IS_SCHEDULE_USERS_ONLY;_===f&&!s&&u&&h.push({divider:!0})}else{if(_!==yt.IS_SCHEDULE_USERS_ONLY)return;h.push({name:_,value:_,label:pu[_]})}}),h},{cx:eM,cxEl:tM}=O("Filters"),yb=({isLargeScreen:t,canManageJobs:s,canViewWages:n,isHubAccount:o,isLoaded:a,onSetEmployeeViewFilter:l,onShowReadOnlyModal:c,onUpdateScheduleProperties:u,rangeType:h,isEventsVisible:m,isManager:_,isScheduleUsersOnly:f,isShiftsAtThisLocationOnly:g,isHoursForecastVisible:b,isWageForecastVisible:x,isPeopleForecastVisible:E,isAvailabilitiesVisible:S,isTimeOffsVisible:y,onUpdateShowHideAvailabilities:C,onUpdateShowHideShiftsLocationsOnly:v,onUpdateShowHideTimeOffs:T,totalNumberOfLocations:D,viewType:L})=>{const[A,P]=r.useState([]),[M,R]=r.useState(!1),$=r.useRef([]),B=r.useRef(null),W=r.useMemo(()=>({isEventsVisible:m,isScheduleUsersOnly:f,isShiftsAtThisLocationOnly:g,isHoursForecastVisible:b,isWageForecastVisible:x,isPeopleForecastVisible:E,isAvailabilitiesVisible:S,isTimeOffsVisible:y}),[m,f,g,b,x,E,S,y]);r.useEffect(()=>{a&&(P(Object.keys(W).filter(oe=>W[oe])),$.current=Object.keys(W).filter(oe=>W[oe]))},[a]);const N=K({eventCategory:U.SCHEDULE_BUILDER_TOOLS_DROPDOWN}),H=r.useMemo(()=>ZN(W,o,L,s,n,h,D,_),[W,o,L,s,n,h,D,_]),q=r.useCallback(oe=>{R(!1),P(oe);const ge=H.map(Z=>({name:Z.name,value:oe.includes(Z.name)}))||[],te={};for(let Z=0;Z<ge.length;Z++){const{name:ee,value:he}=ge[Z];if(N(JN(ee,he),k.CLICK,{checked:he}),ee===yt.IS_SCHEDULE_USERS_ONLY){l(he?Gc.SCHEDULED:Gc.ALL);continue}if(ee===yt.IS_WAGE_FORECAST_VISIBLE&&!n){c({text:p("schedule_builder.common.do_not_have_permission"),persist:!1,timeoutDelay:1e4});continue}if(ee===yt.IS_AVAILABILITIES_VISIBLE){C(he),at(yt.IS_AVAILABILITIES_VISIBLE,he);continue}if(ee===yt.IS_TIME_OFFS_VISIBLE){T(he),at(yt.IS_TIME_OFFS_VISIBLE,he);continue}if(ee===yt.IS_SHIFTS_AT_THIS_LOCATION_ONLY){v(he),at(yt.IS_SHIFTS_AT_THIS_LOCATION_ONLY,he);continue}te[ee]=he}u(te)},[H,u,N,n,l,c,C,T,v]),G=r.useCallback(oe=>{P(oe.target.value)},[]),re=r.useCallback(oe=>{const ge=oe.length>0?oe:$.current;P(ge),R(!1)},[]),ue=r.useCallback(()=>{R(!1)},[]),je=r.useCallback(()=>{B.current.click(),R(!0)},[]),ce=r.useMemo(()=>{let oe=0;for(let ge=0;ge<H.length;ge++){const te=H[ge];A.includes(te.value)&&oe++}return oe===0?"":` (${oe})`},[A,H]);return e.jsxs(i,{className:eM(),relative:!0,children:[e.jsx(i,{absolute:!0,l:0,r:0,style:{visibility:"hidden"},children:e.jsx(Qt,{ref:B,className:tM("select"),startIcon:"Filter",multiple:!0,displayAsText:!0,placeholder:p(`${Yt}.placeholder`),showApplyActions:!0,options:H,value:A,onChange:G,onApply:q,onCancel:re,onClose:ue})}),e.jsx(V,{variant:"secondary",size:t?"medium":"small",endIcon:M?"CaretUp":"CaretDown",onClick:je,children:`${p(`${js}.filters`)}${ce}`})]})};yb.propTypes={canManageJobs:d.bool,canViewWages:d.bool,isAvailabilitiesVisible:d.bool,isHubAccount:d.bool,isLoaded:d.bool,isShiftsAtThisLocationOnly:d.bool,isTimeOffsVisible:d.bool,onSetEmployeeViewFilter:d.func,onShowReadOnlyModal:d.func,onUpdateShowHideAvailabilities:d.func,onUpdateShowHideShiftsLocationsOnly:d.func,onUpdateShowHideTimeOffs:d.func,rangeType:d.string,totalNumberOfLocations:d.number,viewType:d.string};const sM=F((t,s)=>({isHubAccount:am(t),canViewWages:Ls(t),canManageJobs:py(t),isLoaded:my(t),isEventsVisible:Le({state:t,attribute:"isEventsVisible"}),isScheduleUsersOnly:hi(t),isHoursForecastVisible:Le({state:t,attribute:"isHoursForecastVisible"}),isWageForecastVisible:Le({state:t,attribute:"isWageForecastVisible"}),isPeopleForecastVisible:Le({state:t,attribute:"isPeopleForecastVisible"}
1),isAvailabilitiesVisible:oa(t),isTimeOffsVisible:na(t),isShiftsAtThisLocationOnly:hy(t),totalNumberOfLocations:uy(t)}),{onUpdateScheduleProperties:Em,onShowReadOnlyModal:zo,onSetEmployeeViewFilter:ie.setEmployeeViewFilter,onUpdateShowHideAvailabilities:ie.updateShowHideAvailabilities,onUpdateShowHideTimeOffs:ie.updateShowHideTimeOffs,onUpdateShowHideShiftsLocationsOnly:ie.updateShowHideShiftsLocationsOnly})(r.memo(yb)),{cx:nM}=O("SendToPartnerButton"),rM=({partner:t,onSetDepartmentId:s,isLargeScreen:n,showSendToPartnerDrawer:o})=>{const a=K(),l=Kn(),c=Ir(t),u=r.useCallback(()=>{s({departmentId:""}),a(w.SEND_PACKET_CLICKED,k.CLICK),o({uxContext:l()})},[s,a,o,l]);return e.jsx(V,{className:nM(),variant:"primary",onClick:u,startIcon:"Send",size:n?"medium":"small",children:p("schedule_builder.react_page.send_to_partner",{props:{partner:c}})})},oM=F(null,{onShowDrawer:Yc,onSetDepartmentId:_y,showSendToPartnerDrawer:Yc})(r.memo(rM)),{cxEl:aM}=O("ScheduleBuilderHeader"),lM=[xy,Cy],iM=[de.startTime,de.role,de.department],vb=({canManageSchedule:t,currentWeek:s,isManager:n,jobPositionIds:o,onSort:a,onUpdateSortByDay:l,navigateToSchedule:c,rangeStart:u,rangeType:h,scheduleIsLoading:m,scheduleIsLoaded:_,sortByWeek:f,startOfWeekValue:g,viewType:b,locationPartner:x,shiftSyncStatuses:E=[],unpublishedShiftsCount:S})=>{const y=X(),C=Qu(),{rangeStartMoment:v,rangeEndMoment:T}=Mr({rangeStartOverride:u}),D=r.useRef(h===J.month?ms(Je):u),L=r.useMemo(()=>o?.join(",")??"",[o]);r.useEffect(()=>{o&&y(ie.setCustomJobIds(o))},[L]),r.useEffect(()=>{!m&&_&&t&&(h===J.day&&l({sortByDay:ts(gr)||mt.firstName}),h===J.week&&a({sortBy:f||Lt.FIRST_NAME,ids:o}))},[a,l,m,_]);const A=async()=>{try{const H=await Eo(Dy(),{start_date:s.start,end_date:s.end});y(ie.setSyncShiftStatus(H))}catch(H){if(H instanceof ng||H instanceof SyntaxError&&H.message.includes("is not valid JSON"))return;eo(H)}};r.useEffect(()=>{A()},[s]);const P=r.useCallback(({start:H,end:q})=>{D.current=H,c({rangeStart:H,rangeEnd:q})},[c]),M=r.useCallback(H=>{const q=H.stateKey;let G=J.week,re=H.startDate.format(Je),ue=H.endDate.format(Je);lM.includes(q)?G=J.month:Ey(H.startDate,H.endDate)?G=J.month:cr(re,ue,"days")===0?G=J.day:Sy(re,ue,g)?G=J.week:(re=so(re),ue=ol(ue),(q===Yv||cr(re,ue,"weeks")>0||q===jy)&&(G=J.custom)),c({rangeType:G,rangeStart:re,rangeEnd:ue})},[g,c]),R=r.useCallback(H=>{const q=J[H.target.value];q===J.month&&(D.current=u);const G=xA(q,f,ts(gr));c({rangeType:q,rangeStart:D.current||u,viewType:iM.includes(G)?G:de.employee})},[c,u,f]),$=(E||[]).find(H=>!H.sync_status),B=S===0&&x==="toast"&&$,W=h===J.week,N=aM("control",{small:!C});return e.jsx(wn.Toolbar,{filters:e.jsxs(e.Fragment,{children:[e.jsx(xs,{children:e.jsx(AN,{isLargeScreen:C,rangeType:h,rangeStart:v,rangeEnd:T})}),e.jsx(i,{className:N,children:e.jsx(Gv,{onApplyRange:M,startDate:Cc(g,v.format(es("parsable_reversed"))),endDate:Cc(g,T.format(es("parsable_reversed"))),startOfWorkWeek:g,allowSingleDayRange:!0,presets:[yy(),vy(),Iy(),Ty(),wy()]})}),e.jsx(xs,{children:e.jsx(i,{row:!0,children:e.jsx(TN,{isLargeScreen:C,onChange:P,rangeType:h})})})]}),viewOptions:e.jsxs(e.Fragment,{children:[e.jsx(xs,{children:e.jsx(IN,{})}),e.jsx(xs,{children:e.jsx(i,{minw:100,className:N,children:e.jsx(LN,{onChange:R,rangeType:h})})}),e.jsx(xs,{children:e.jsx(sM,{rangeType:h,viewType:b,isLargeScreen:C,isManager:n})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(xs,{children:e.jsx(GN,{isLargeScreen:C,rangeType:h})}),n&&e.jsx(xs,{children:B?e.jsx(oM,{partner:x,isLargeScreen:C}):e.jsxs(i,{row:!0,alignItemsCenter:!0,gap:"xs",children:[e.jsx(kN,{isLargeScreen:C}),W&&e.jsx(yN,{isLargeScreen:C})]})})]})})};vb.propTypes={canManageSchedule:d.bool,currentWeek:d.object,isAvailabilitiesVisible:d.bool,isManager:d.bool,isTimeOffsVisible:d.bool,jobPositionIds:d.arrayOf(d.string),navigateToSchedule:d.func,onSort:d.func,onSetAvailabilitiesVisible:d.func,onSetTimeOffsVisible:d.func,onUpdateSortByDay:d.func,rangeStart:d.string,rangeType:d.string,scheduleIsLoading:d.bool,scheduleIsLoaded:d.bool,sortByWeek:d.string,startOfWeekValue:d.number,viewType:d.string,locationPartner:d.string,
1shiftSyncStatuses:d.array,unpublishedShiftsCount:d.number};const cM=F(t=>{const s=Es({state:t,attribute:"sortByWeek",sliceName:"schedule"});return{canManageSchedule:Dr(t),currentWeek:it(t),jobPositionIds:by(t,{sortBy:s}),scheduleIsLoading:Es({state:t,attribute:"pending",sliceName:"schedule"}),scheduleIsLoaded:Es({state:t,attribute:"succeeded",sliceName:"schedule"}),sortByWeek:s,startOfWeekValue:rs(t),locationPartner:fy(t),shiftSyncStatuses:pi(t),unpublishedShiftsCount:ea(t)}},{onSort:Af,onUpdateSortByDay:gy,navigateToSchedule:Go})(r.memo(vb)),Ib=({message:t,type:s,onHide:n,isAI:o,isScheduleInsightsModalDismissed:a,onOpenSchedulingInsightsModal:l})=>(r.useEffect(()=>{t&&setTimeout(()=>{n(),a||l()},1e4)},[t,s,n,l,a]),t?e.jsx(i,{fixed:!0,left:"50%",bottom:20,w:500,zIndex:100,children:e.jsx(i,{relative:!0,left:"-50%",children:e.jsx(dt,{isAI:o,variant:s,children:t})})}):null);Ib.propTypes={message:d.string,isAI:d.bool,type:d.string,onHide:d.func.isRequired};const dM=F(t=>({message:Ly(t),type:Ry(t),isAI:ky(t),isScheduleInsightsModalDismissed:Tu(t)}),{onHide:ie.hideNotification,onOpenSchedulingInsightsModal:ie.openSchedulingInsightsModal})(Ib),{cx:uM,cxEl:ar}=O("ScheduleBuilderViewWrapper"),Tb=({children:t,currentWeek:s,hasDepartmentsAccess:n,isManager:o})=>{const a=en(),l=Io(),[c,u]=r.useState(!1);r.useEffect(()=>{zv.isMobileOnly&&u(!0)},[]);const h=r.useCallback(()=>{u(!1)},[]),m=ze(),_=Om({...m});return a({view_type:_.rangeType}),e.jsx(wn,{classNames:{root:ar("page"),childrenWrapper:ar("page-content")},title:p("nav_links.schedule.top_level"),fullWidthOpts:{hideHeader:!0},children:e.jsxs(wn.FullWidth,{classNames:{root:ar("full-width"),childrenWrapper:ar("full-width-content")},toolbar:s?e.jsx(cM,{..._,isManager:o}):void 0,children:[e.jsx(i,{column:!0,w:"100%",h:"100%",minh:0,className:uM({embedded:l}),overflowX:"auto",overflowY:"auto",children:e.jsx(i,{className:ar("content"),column:!0,grow:1,minh:0,h:"100%",children:t})}),e.jsx(SN,{isOpen:c,onClose:h}),e.jsx(dM,{})]})})};
1Tb.propTypes={currentWeek:d.shape({start:d.string,end:d.string}),hasDepartmentsAccess:d.bool,isManager:d.bool};const hM=F(t=>({currentWeek:it(t),hasDepartmentsAccess:Yo(t,{name:"departments"}),isManager:He(t)}))(r.memo(Tb)),mM={[J.week]:{[de.employee]:JO,[de.department]:cN,[de.role]:CN},[J.month]:{[de.employee]:cu},[J.custom]:{[de.employee]:cu},[J.day]:{[de.employee]:$A,[de.startTime]:BA}},pM=()=>{const{viewType:t,rangeType:s}=ze(),n=en(),o=K(),a=Kn(),[l,c]=r.useState(!0),u=X(),{activeDragData:h,activeRowOverlayData:m,employeeRowCallbacksRef:_}=ZO({viewType:t,rangeType:s,trackUx:o,uxContext:a}),f=I(He),g=I(Wn),b=I(Lr),x=I(Am),E=I(Dr),S=I(Oy).join(","),y=I(_s),C=I(Ny,mv),v=I(Lm),T=I(rs),D=I(rm);n({isByDepartment:!1,viewSubType:t,viewType:s});const L=r.useCallback(()=>{u(il({startDate:g,endDate:b}))},[il,g,b]);r.useEffect(()=>{x&&L()},[x,L]),r.useEffect(()=>{u(My())},[u]);const A=r.useMemo(()=>{if(!g||!b)return[];const M=bu(g,T).start,R=[];let $=M;for(;$<=b;)R.push($),$=kt($,7);return R},[g,b,T]);r.useEffect(()=>{g&&b&&(Qv(),u(ie.closeSchedulingInsightsModal()),u(ui({startDate:g,endDate:b,force:l})),u(ie.resetJumpstartDrawer()),c(!1),y&&A.length>0&&C.length>0&&(u(Py({startDate:g,endDate:b})),A.forEach(M=>{u($y({jobIds:C,startDate:M}))})))},[g,b,y,A,C,D]),r.useEffect(()=>{E&&u(By({startDate:g,endDate:b}))},[E,g,b,u]),r.useEffect(()=>{g&&S!==""&&(eI(),(f||f===void 0)&&u(Uy({jobIds:S,startDate:g,endDate:b})))},[g,S,f]),r.useEffect(()=>{g&&b&&E&&u(Hy({startDate:g,endDate:b}))},[E,g]),r.useLayoutEffect(()=>{y&&u(Fy(!!v))},[v,u,y]);const P=r.useMemo(()=>{const M=mM[s][t];return e.jsx(M,{employeeRowCallbacksRef:_})},[s,t,_]);return e.jsxs(hM,{children:[P,e.jsxs(bh,{dropAnimation:null,children:[h?.type===Xs.SHIFT&&e.jsx(Tk,{dragData:h}),m&&e.jsx(Lf,{isOverlay:!0,index:0,data:{innerJobIds:[m.jobId],dates:m.dates,locationIdsForUser:m.locationIdsForUser,isManager:!0,isCopyPasteMode:!1,hasSeenToolTip:!0}})]})]})},_M=r.memo(Ge({productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER,version:Ay})(pM)),fM=({startOfWeek:t,onSetCurrentDateRange:s,onSetViewType:n,onSetRangeType:o,onSetPublishedCount:a,departmentsAccess:l,canManageTier:c,sessionIsLoaded:u,scheduleIsLoading:h,onLoadSession:m,isPredictiveSchedulingModalOpen:_,isPredictiveGenerationFeedbackDialogOpen:f,isGeneratingSchedulePrediction:g,isManager:b,hasPredictionFailed:x,isCopyWeekDrawerOpen:E,isTemplatesDrawerOpen:S,isProductGrowthImageToScheduleWebEnrolled:y,currentPublishedCount:C})=>{const{rangeStart:v,rangeEnd:T,viewType:D,rangeType:L}=ze(),[A,P]=r.useState(!1),M=Dm(),R=X(),{rosterStatus:$,scheduleStatus:B}=I(vo)||{},W=I(ce=>ce.getIn(["session","currentLocation","published_count"])),N=I(ce=>gh(ce,"productgrowth_imagetoschedule_web")),H=I(Zy),q=I(Oi),G=I(ev),re=q&&G,ue=!q,je=b&&C===0&&$===En&&B===En&&N===Pm.FLOATING_PANEL;return r.useEffect(()=>{localStorage.setItem(tv,v)},[v]),r.useEffect(()=>{localStorage.setItem(sv,T)},[T]),r.useEffect(()=>{localStorage.setItem(Nm,D),n(D)},[D]),r.useEffect(()=>{localStorage.setItem(nv,L),o(L)},[L]),r.useEffect(()=>{m(),R(rv())},[m,R]),r.useEffect(()=>{a(W)},[]),r.useEffect(()=>{y&&b&&R(ov())},[R,b,y]),r.useEffect(()=>{const ce=Om({rangeStart:v,rangeEnd:T,viewType:D,rangeType:L,startOfWeek:t,departmentsAccess:l}),oe={...ce,rangeStart:ce.rangeType===J.custom?ce.rangeStart:v};Wh.replace({pathname:Mm(oe),search:M.search});const ge=Rl.parse(M.search);if(ge.findCoverForShift){const te=ge.findCoverForShift;at("shiftSelectedScroll",te),R(ie.setFindCoverShiftId({shiftId:te})),av("findCoverForShift",void 0)}s({start:ce.rangeStart,end:ce.rangeEnd}),c&&D===de.department&&D!==ce.viewType&&R(ei({minTier:"plus",feature:"departments",mppFocusViewProps:{focusedFeature:"permissionAndDepartments"}}))},[s,t,v,T,D,L,l,c,M.search,R]),u?b&&re?e.jsx(vD,{}):e.jsxs(e.Fragment,{children:[h&&e.jsx(qa,{}),!h&&g&&!_&&!f&&e.jsx(Er,{children:e.jsx(qa,{})}),e.jsx(_M,{}),e.jsx(Ik,{}),e.jsx(ik,{partner:"toast"}),b&&S&&e.jsx(xI,{}),b&&E&&e.jsx(pI,{}),b&&ue&&e.jsxs(e.Fragment,{children:[e.jsx(DI,{}),e.jsxs(Er,{children:[x&&e.jsx(MD,{}),_&&e.jsx(OD,{}),f&&!h&&e.jsx(kD,{})]})]}),e.jsx(Wp,{children:e.jsx(YD,{})}),e.jsx(ID,{children:e.jsx(CI,{})}),e.jsx(_v,{showFloatingPanel:je,isOpen:A,setIsOpen:P,isFtuxSeen:H,productArea:ae.SCHEDULE,eventCategory:U.SCHEDULE_BUILDER,ftuxPanelType:ae.SCHEDULE,oneTimeEventName:fv.SCHEDULING_FTUX_SEEN,children:e.jsx(SI,{})}),e.jsx(HD,{})]}):e.jsx(qa,{})},bM=F(t=>({startOfWeek:rs(t),departmentsAccess:Yo(t,{name:"departments"}),canManageTier:Xy(t),scheduleIsLoading:Es({state:t,attribute:"isFetching",sliceName:"schedule"}),sessionIsLoaded:Jy(t)==="succeeded",isPredictiveSchedulingModalOpen:Yy(t),isPredictiveGenerationFeedbackDialogOpen:Gy(t),isGeneratingSchedulePrediction:zy(t),isManager:He(t),hasPredictionFailed:qy(t),isCopyWeekDrawerOpen:Ky(t),isTemplatesDrawerOpen:Vy(t),isProductGrowthImageToScheduleWebEnrolled:xh(t),
1currentPublishedCount:Wy(t)}),{onLoadSession:Qy,onSetCurrentDateRange:ie.setCurrentDateRange,onSetViewType:ie.setViewType,onSetRangeType:ie.setRangeType,onSetPublishedCount:ie.setPublishedCount})(r.memo(fM)),gM=[de.employee,de.department,de.role],xM=()=>{const t=localStorage.getItem(Nm);return Mm({rangeStart:ms(Je),viewType:gM.includes(t)?t:de.employee,rangeType:J.week})},bP=()=>(r.useEffect(()=>{Zv()},[]),e.jsxs(lv,{children:[e.jsx(Jc,{path:[Hr.SCHEDULE_BUILDER_WEEK_VIEW_REGEX_PATH,Hr.SCHEDULE_BUILDER_MONTH_VIEW_REGEX_PATH,Hr.SCHEDULE_BUILDER_DAY_VIEW_REGEX_PATH,Hr.SCHEDULE_BUILDER_CUSTOM_VIEW_REGEX_PATH],children:e.jsx(bM,{})}),e.jsx(Jc,{path:`${iv}*`,children:e.jsx(cv,{to:xM()})})]}));export{bP as default}; 2//# sourceMappingURL=index-chunk-CRHJw1hb.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.